You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The file access time is not normalized when importing that file to the store, leading to a potential build-time impurity.
Steps To Reproduce
Create a test file:
touch test
Create a default.nix file with these contents:
(import<nixpkgs>{}).runCommand"test"{}'' ls --full-time --time=atime ${./test} > $out''
Build it and show the result, notice how the resulting access time is not normalized to unix epoch 1:
$ nix-build
this derivation will be built:
/nix/store/zc8kj3fgb5rxij4kbx6p9ynlldig9kla-test.drv
building '/nix/store/zc8kj3fgb5rxij4kbx6p9ynlldig9kla-test.drv'...
/nix/store/gdzg99df8f8a6zpxxrzj2m7p439b09ln-test
$ cat result
-r--r--r-- 2 nobody nogroup 0 2023-05-31 19:01:19.000000000 +0000 /nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test
$ cp --copy-contents result before
$ rm result
$ nix-store --query --referrers-closure /nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test | xargs nix-store --delete
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/7rfrjpxmdf6qk5q4h20s8ikk9lnw3347' to '/home/tweagysil/test/time3/result'
deleting '/nix/store/zc8kj3fgb5rxij4kbx6p9ynlldig9kla-test.drv'
deleting '/nix/store/gdzg99df8f8a6zpxxrzj2m7p439b09ln-test'
deleting '/nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test'
deleting unused links...
note: currently hard linking saves 15891.46 MiB
3 store paths deleted, 0.00 MiB freed
Update the access time of the file:
$ touch test
Build it again and diff the result, noticing that the result is different:
$ nix-build
this derivation will be built:
/nix/store/zc8kj3fgb5rxij4kbx6p9ynlldig9kla-test.drv
building '/nix/store/zc8kj3fgb5rxij4kbx6p9ynlldig9kla-test.drv'...
/nix/store/gdzg99df8f8a6zpxxrzj2m7p439b09ln-test
$ diff before result
1c1
< -r--r--r-- 2 nobody nogroup 0 2023-05-31 19:04:54.000000000 +0000 /nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test
---
> -r--r--r-- 2 nobody nogroup 0 2023-05-31 19:06:44.000000000 +0000 /nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test
Notice also how the hash of the file (/nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test) did not change between the two builds, but the access time did change.
Expected behavior
The access time should get normalized to unix epoch 1, the same as is done to the modification time (mtime) already.
Additional context
The change time (ctime) and birth time (on some filesystems) is also not normalized, but this can't reasonable be fixed.
I confirm it isn't. I suspect it's indeed a bug, but I'd like to get @edolstra's opinion as it could have been a deliberate tradeoff from the origins of Nix (also note that build outputs aren't normalized either, except for their mtime)
atime could be useful for informing what garbage to collect first, as a store's garbage is also a cache, and atime is a good indicator of relevance. Performance may or may not be a challenge for the atime for GC idea.
Describe the bug
The file access time is not normalized when importing that file to the store, leading to a potential build-time impurity.
Steps To Reproduce
Create a
test
file:Create a
default.nix
file with these contents:Build it and show the result, notice how the resulting access time is not normalized to unix epoch 1:
Remove the imported file from the Nix store (requires a workaround, see Cannot delete store path with no roots #6141)
Update the access time of the file:
Build it again and diff the result, noticing that the result is different:
Notice also how the hash of the file (
/nix/store/vd14zxkay784callbkhnmd88qv3p2rip-test
) did not change between the two builds, but the access time did change.Expected behavior
The access time should get normalized to unix epoch 1, the same as is done to the modification time (mtime) already.
Additional context
The change time (ctime) and birth time (on some filesystems) is also not normalized, but this can't reasonable be fixed.
This work is sponsored by Antithesis ✨
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: