During compilation, we build two derivations - one for the dependencies
and another for the user's crate itself. Passing `postInstall` to
`buildPackage` pass-throughs it into both derivations, which is not what
most users would probably expect.
This commit adds `postInstall` as an explicit configuration option (so
that it's neatly documented), zeroing it out for the dependencies-only
derivation.
I don't think there's any use case for something like `postInstallDeps`,
so it's not introduced here.
Closes https://github.com/nix-community/naersk/issues/237
When a dependency gets fetched from Git, it's possible for its name to
contain slashes - e.g. because the dependency's branch name contains
one:
```
something-something = { git = "...", branch = "JIRA-123/dev" }
```
Currently, because we don't sanitize those slashes, trying to compile
such `Cargo.toml` / `Cargo.lock` would fail - e.g. given a dependency
from branch `JIRA-123/dev`, we'd try to extract it into path
`JIRA-123/dev` instead of something flat such as `JIRA-123_dev`.
This commit fixes this issue by sanitizing all the `nkey`s - basically,
for all dependency paths, we replace `/` with `_`.
The choice of underscore is arbitrary, just seemed like a good fit.
Without this change you'd get errors like this when adding a
`git`-dependency to a `Cargo.toml` which is pinned to a tag:
fetching Git repository 'git://github.com/ma27/nixpkgs-fmt'fatal: couldn't find remote ref refs/heads/v1.2.0-rnix-0.10
error: program 'git' failed with exit code 128
* Update to a more recent revision of nixpkgs
* Add nixpkgs-21.11 for testing
* Add nixpkgs-21.05 for testing
* Drop nixpkgs-20.09, branch is EOL
* Drop nixpkgs-20.05, branch is EOL
* Bump ripgrep-all to v0.9.6 to make tests pass
* Previously the CARGO_TARGET_DIR environment was set to the `out`
directory which resulted in cargo placing all of its artifacts there
instead of the default `target` directory
* Later on, the build scripts would then copy the (empty) `target`
directory to `$out` resulting in cargo rebuilding the entire
dependency tree from scratch whenever the top level crate's source was
changed
* Now we omit the CARGO_TARGET_DIR environment variable and inspect the
`target` directory for any binaries instead of the `out` directory
From what I can tell the readme test is failing because the config.nix differs from the README.md source
To regenerate the README, run:
```sh
./script/gen
```
and commit the results.
This reverts commit f9e6e8dd78. We should
`export CARGO_TARGET_DIR`, otherwise subsequent `cargo` calls will
rebuild everything (because they won't find the target dir).
Some tests like the wasm one were never executed because they are
neither --fast, nor tested in the main CI.
This copies the fast.yml into test.yml, minus the --fast flag.
Flake sources are nix derivations, which means they automatically get
made read-only. This causes overwriting Cargo.toml and potentially
build.rs fail. The cure to this is to either chmod the sources after
copy, or in this case copy without preserving the file's original mode.