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

Trying to fix reproducible paths section and it's not working out #875

Closed
1 task
henrik-ch opened this issue Jan 27, 2024 · 1 comment
Closed
1 task

Comments

@henrik-ch
Copy link
Contributor

Inspired by @fricklerhandwerk 's comment on #845 I went after:

To share my attempt I created a draft PR - not with the purpose of merging, but describing the steps I took:
#874

The issue (at least from the point of my incomplete understanding), is that the problem that the Reproducible source paths best practice example advertises, doesn't occur.

Please see the file snippets here below and below the built derivation path which doesn't contain myproject.
On the other hand, as the example points out, myproject gets included in the store path.

Can you please shed light on why this makes the example non-reproducible, as the built derivation path doesn't contain the myscript path, and nothing else of the derivation output seems to have a link to the store path either?

Below please find some details on what I did - but on reflection, they might not be necessary, as this perhaps is more of a principles question?


myscript

echo "Hello World"

spaths.nix

let pkgs = import <nixpkgs> {}; in

pkgs.stdenv.mkDerivation {
  name = "foo";
  src = ./.;

  installPhase = ''
    mkdir -p $out/bin
    cp myscript $out/bin/
  '';

and the nix-build spaths.nix execution result:

github/slask/myproject took 6s 
❯ nix-build spaths.nix 
this derivation will be built:
  /nix/store/71jb2qyr017y8ai0yci2rlhky2xzrc3m-foo.drv
building '/nix/store/71jb2qyr017y8ai0yci2rlhky2xzrc3m-foo.drv'...
unpacking sources
unpacking source archive /nix/store/fd6bw7bm2jjvdwnjg0kdy3aqk7f8828d-myproject
source root is myproject
patching sources
configuring
no configure script, doing nothing
building
no Makefile or custom buildPhase, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo
checking for references to /build/ in /nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo...
patching script interpreter paths in /nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo
stripping (with command strip and flags -S -p) in  /nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo/bin
/nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo

Important Line: /nix/store/36ldrk4hlgyddmi6ksy5rv8lxn0b3bfz-foo

As I am thinking this through, I see myproject in the source archive path, but that doesn't matter, as long as it's not part of the produced derivation?

Thank you to anyone who has time to clarify and for shedding any light on this.

@fricklerhandwerk
Copy link
Collaborator

fricklerhandwerk commented Jan 27, 2024

Run nix show-derivation /nix/store/71jb2qyr017y8ai0yci2rlhky2xzrc3m-foo.drv and check inputSrcs - it will contain your myproject. Renaming your directory will force a rebuild and produce a different store path in inputSrcs. The reason is that ./. eventually ends up being string-coerced and therefore copied to the store.

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

No branches or pull requests

2 participants