Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use mkDerivation with src instead of runCommand for test derivation #357

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

Kranzes
Copy link
Member

@Kranzes Kranzes commented Aug 3, 2024

The problem with using runCommand and recreating the src directory with
lndir is that it changes the file types of individual files, they will
now be a symlink instead of a regular file. If you have a crate that tests
that a file is of regular type then it will fail inside the crate2nix derivation.

The problem with using runCommand and recreating the src directory with
lndir is that it changes the file types of individual files, they will
now be a symlink instead of a regular file. If you have a crate that tests
that a file is of regular type then it will fail inside the crate2nix derivation.
@Kranzes Kranzes requested a review from kolloch August 3, 2024 23:51
@apoelstra
Copy link
Contributor

As a user with a ton of disk space I would prefer this (many of my uses of crate2nix involve nasty hacks to un-symlink files so that I can either modify them or just pass "file exists and is -f checks".

But this will use more disk space and slow things down, possibly by a lot on large repos.

@Kranzes
Copy link
Member Author

Kranzes commented Aug 4, 2024

I think people should filter their src's properly with something like lib.fileset. They shouldn't be copying over the entire repo to the nix store. It's not that bad IMO.

@Kranzes Kranzes merged commit 236f6ad into master Aug 10, 2024
4 checks passed
apoelstra added a commit to apoelstra/crate2nix that referenced this pull request Oct 18, 2024
In a "normal" Rust crate, the installPhase will do nothing, since stdenv
setup.sh will look for a file called Makefile, and then bail out when it
doesn't find it.

However, in a Rust crate that has a file called Makefile, the
installPhase will run, and will do broken things. In particular, I see
consistent failures of the form

```
...
++ [[ -z '' ]]
++ [[ -e Makefile ]]
++ foundMakefile=1
++ '[' -n /nix/store/1avx3g6yx60xgbfvrzalysz572cr8ghg-run-tests-rust_secp256k1-zkp-0.11.0 ']'
++ mkdir -p /nix/store/1avx3g6yx60xgbfvrzalysz572cr8ghg-run-tests-rust_secp256k1-zkp-0.11.0
mkdir: cannot create directory '/nix/store/1avx3g6yx60xgbfvrzalysz572cr8ghg-run-tests-rust_secp256k1-zkp-0.11.0': File exists
+ exitHandler
+ exitCode=1
...
```

This derivation was introduced in nix-community#357; previously we simply used
runCommand which has no notion of "phases". When we switched to stdenv
we moved the runCommand functionality into buildPhase and didn't
consider that any of the other default phases might do bad stuff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants