NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.3k stars 1.49k forks source link

non-deterministic closureinfo from same store #4840

Open ajs124 opened 3 years ago

ajs124 commented 3 years ago

Describe the bug Realizing the same closureinfo derivation twice leads to two different outputs. That in and of itself is not that weird, because it can happen easily as long as the close includes any path that is not reproducible, what is weird however is it happening on the same host.

diff -ru /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info/registration /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info.check/registration
--- /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info/registration       1970-01-01 01:00:01.000000000 +0100
+++ /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info.check/registration 1970-01-01 01:00:01.000000000 +0100
@@ -665,8 +665,8 @@
 /nix/store/57g080n6rmzzq93gm5m9yc87zvqlh4yi-glibc-2.32-46-bin
 /nix/store/vaf92wc23m067q9aig6zjkcnjvrg768n-glibc-2.32-46
 /nix/store/59ppqq4p0b8sgm2ka443lfv9jiv1p4s3-initrd-linux-5.10.37
-sha256:0h7393ar8cb7l7x8qk1anv9za7pw6cc6r15kr55m32bmwk4swbj0
-23039080
+sha256:0dcqf7i7piqh1098sabwrxx5c610fmfrnk6sbyi7j3nxv5gpnmnx
+23036720

 9
 /nix/store/14c4d94qg2qpriqqbi6jfk001h1j5514-keymap
@@ -1941,8 +1941,8 @@
 /nix/store/vaf92wc23m067q9aig6zjkcnjvrg768n-glibc-2.32-46
 /nix/store/xiwckad47jy5vfibqym7pmjjr30caw80-aws-c-common-0.5.5
 /nix/store/dyc2fjjk7igl8vi6wnhn9y065zjgqcn9-kernel-modules
-sha256:0r9q39m85l1lfbbsp1jr8l2dr9szf5jxp75hp6aip3b0ihqa03rl
-6230104
+sha256:1hj3gfhkpdjs9ia62x8byfgcln61xd0hpyiy0599gqlhw566dc2p
+6230168

 2
 /nix/store/3pvvw40cddikklg56c6xzrjcy731djhj-linux-5.10.37
@@ -3120,8 +3120,8 @@
 /nix/store/wq2b68y4hi98zzm8p1jk7ybf23ly56m0-coreutils-8.32
 /nix/store/ylz1dd8ks4cfag4mwks5dqsfqs2lcyzq-glibc-locales-2.32-46
 /nix/store/nrr6ddvxifp3bmlgrvmpsa2qp2kycir6-linux-5.10.37-modules-shrunk
-sha256:1s828j8p7hzqar707b7avkv59n099ia0pwnn7zg1wjlsr1zij1gi
-2095712
+sha256:0biw53s2mq31vz3zpcy6dc2r8ivzlxdrf1b2fw4zsyvkjbqfcqnw
+2091976

 1
 /nix/store/nrr6ddvxifp3bmlgrvmpsa2qp2kycir6-linux-5.10.37-modules-shrunk
diff -ru /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info/total-nar-size /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info.check/total-nar-size
--- /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info/total-nar-size     1970-01-01 01:00:01.000000000 +0100
+++ /nix/store/v3gdspvjfp0ri4g8ahadcsrc26ra4lfx-closure-info.check/total-nar-size       1970-01-01 01:00:01.000000000 +0100
@@ -1 +1 @@
-1201968216
+1201962184

The reason I care about this is because it leads to NixOS tests failing on my hydra, because of hash mismatches in nixos-install (because the nix.db in the test is generated with nix-store --load-db from that registration file). In this case:

copying path '/nix/store/dyc2fjjk7igl8vi6wnhn9y065zjgqcn9-kernel-modules' to 'local'...                                                                                               
hash mismatch importing path '/nix/store/dyc2fjjk7igl8vi6wnhn9y065zjgqcn9-kernel-modules';                                                                                            
  wanted: sha256:0r9q39m85l1lfbbsp1jr8l2dr9szf5jxp75hp6aip3b0ihqa03rl                                                                                                                 
  got:    sha256:1hj3gfhkpdjs9ia62x8byfgcln61xd0hpyiy0599gqlhw566dc2p                                                                                                                 

Here, sha256:0r9q39m85l1lfbbsp1jr8l2dr9szf5jxp75hp6aip3b0ihqa03rl is the hash that this path has on cache.nixos.org and sha256:1hj3gfhkpdjs9ia62x8byfgcln61xd0hpyiy0599gqlhw566dc2p is what is in the nix store on that machine.

Steps To Reproduce

I'm not quire sure, to be honest. I guess…

  1. Have a store path in your local store and also be available on cache.nixos.org, while both have different contents
  2. Run closureInfo (or exportReferencesGraph, same thing) on it
  3. Observe that it sometimes returns the one and sometimes the other

Expected behavior

I expect exportReferencesGraph to return the same thing twice when run on the same host twice. Especially if it's about the narhash of a path that's locally available.

nix-env --version output nix-env (Nix) 2.4pre20210503_6d2553a

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info