Thanks @NobbZ and @tomberek!
The change in this commit makes the build behave as expected:
for i in $(seq 5); do nix-build 2> /dev/null ; done
/nix/store/nf608j8d0jpgs7ds1wralmn72shs5jja-nix-channel-app-0.0.1
/nix/store/nf608j8d0jpgs7ds1wralmn72shs5jja-nix-channel-app-0.0.1
/nix/store/nf608j8d0jpgs7ds1wralmn72shs5jja-nix-channel-app-0.0.1
/nix/store/nf608j8d0jpgs7ds1wralmn72shs5jja-nix-channel-app-0.0.1
/nix/store/nf608j8d0jpgs7ds1wralmn72shs5jja-nix-channel-app-0.0.1
Now on to the next issue, how do I get the built version “into a channel”?
I’ve built it twice on Travis, and the second build on Travis ends with:
these paths will be fetched (0.18 MiB download, 0.67 MiB unpacked):
/nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1
copying path '/nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1' from 'https://magthe-temp.cachix.org'...
All done.
So I think that means the cache does contains a built version.
I’ve added the following line to .nix-channels
:
https://github.com/magthe/nix-channel-app/archive/master.tar.gz nix-channel-app
and updated channels:
$ nix-channel --update
these derivations will be built:
/nix/store/xr34rr965qp63fsrmy40b4np3dvgi8yx-nix-channel-app.drv
building '/nix/store/xr34rr965qp63fsrmy40b4np3dvgi8yx-nix-channel-app.drv'...
unpacking channels...
created 3 symlinks in user environment
However, when I try to install the package, using nix-env -i nix-channel-app
I end up building the app. The build output (truncated):
nix-env -i nix-channel-app
unpacking 'https://github.com/NixOS/nixpkgs-channels/archive/0c960262d159d3a884dadc3d4e4b131557dad116.tar.gz'...
copying path '/nix/store/2l5bkv1s788nfzzghwf9ckkc6j0zy75k-busybox-1.31.1-x86_64-unknown-linux-musl' from 'https://cache.nixos.org'...
copying path '/nix/store/jc2jzf3ww11696jrp6l20crbzdnj7x5g-apr-1.7.0' from 'https://cache.nixos.org'...
copying path '/nix/store/1z8wd00d9px0n20jzys93rdpafrndqij-aws-c-common-0.3.11' from 'https://cache.nixos.org'...
....
installing
Installing executable ze-app in /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1/bin
Warning: The directory
/nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1/bin is not
in the system search path.
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1
shrinking /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1/bin/ze-app
strip is /nix/store/7bhi29ainf5rjrk7k7wyhndyskzyhsxh-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1/bin
patching script interpreter paths in /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1
checking for references to /build/ in /nix/store/64ji2j8160idj14vxm1vfw1ykm0ds0r8-nix-channel-app-0.0.1...
building '/nix/store/kmhhapfv7p8rdwqvjjqinyfrf0fx1w5a-user-environment.drv'...
created 23 symlinks in user environment
It certainly looks like the built binary is identical to the cached version, the same hash, but why isn’t it just pulled out of the cache when installing?