"nix copy" from files miscomputes mtime #751

Open
opened 2025-03-20 13:30:19 +00:00 by antifuchs · 1 comment

Describe the bug

nix copy --to file:///... and nix copy --from file:///... do not properly round-trip: The export with copy --to correctly writes a directory copying NARs, but then importing it back with nix copy --from file:///... results in an error, stating that the mtime on the store path is not the same as the file on the file system:

$ nix copy --from file:./attic-nars nixpkgs#attic-client --substitute-on-destination
warning: ignoring substitute for '/nix/store/sznkl4iwqvxprlg05fx24xx8bd8j7y6l-source' from 'https://cache.nixos.org', as it's not signed by any of the keys in 'trusted-public-keys'
error: 'lastModified' attribute mismatch in input 'path:/nix/store/sznkl4iwqvxprlg05fx24xx8bd8j7y6l-source?lastModified=1&narHash=sha256-cPfs8qMccim2RBgtKGF%2Bx9IBCduRvd/N5F4nYpU0TVE%3D&rev=6607cf789e541e7873d40d3a8f7815ea92204f32', expected 1741851582

Using touch -d '@0' attic-nars/**/* to reset the mtimes to the canonical value in the store results in a correct import.

Steps To Reproduce

  1. nix copy --to file:attic-nars nixpkgs#attic-client
  2. nix copy --from file:./attic-nars nixpkgs#attic-client
  3. See error above.

Expected behavior

The exported store paths should import correctly.

nix --version output

nix (Lix, like Nix) 2.92.0-pre20250309-0d1f794
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/asf/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/asf/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/asf/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/asf/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/hl36g3v54392ydmd9glzpqx8rn9fc032-lix-2.92.0-pre20250309-0d1f794/share

Additional context

Further to this error I'm confused about the warning that the cache isn't trusted: My nix.conf does list cache.nixos.org-1's public key as trusted.

## Describe the bug `nix copy --to file:///...` and `nix copy --from file:///...` do not properly round-trip: The export with `copy --to` correctly writes a directory copying NARs, but then importing it back with `nix copy --from file:///...` results in an error, stating that the mtime on the store path is not the same as the file on the file system: ```console $ nix copy --from file:./attic-nars nixpkgs#attic-client --substitute-on-destination warning: ignoring substitute for '/nix/store/sznkl4iwqvxprlg05fx24xx8bd8j7y6l-source' from 'https://cache.nixos.org', as it's not signed by any of the keys in 'trusted-public-keys' error: 'lastModified' attribute mismatch in input 'path:/nix/store/sznkl4iwqvxprlg05fx24xx8bd8j7y6l-source?lastModified=1&narHash=sha256-cPfs8qMccim2RBgtKGF%2Bx9IBCduRvd/N5F4nYpU0TVE%3D&rev=6607cf789e541e7873d40d3a8f7815ea92204f32', expected 1741851582 ``` Using `touch -d '@0' attic-nars/**/*` to reset the mtimes to the canonical value in the store results in a correct import. ## Steps To Reproduce 1. `nix copy --to file:attic-nars nixpkgs#attic-client ` 2. `nix copy --from file:./attic-nars nixpkgs#attic-client` 3. See error above. ## Expected behavior The exported store paths should import correctly. ## `nix --version` output ``` nix (Lix, like Nix) 2.92.0-pre20250309-0d1f794 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/asf/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/asf/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/asf/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/asf/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/hl36g3v54392ydmd9glzpqx8rn9fc032-lix-2.92.0-pre20250309-0d1f794/share ``` ## Additional context Further to this error I'm confused about the warning that the cache isn't trusted: My nix.conf does list `cache.nixos.org-1`'s public key as trusted.
Owner

This smells like some kind of absolutely hilarious flake bullshit. I don't know exactly what is being mismatched against. Needs further analysis.

This smells like some kind of absolutely hilarious flake bullshit. I don't know exactly what is being mismatched against. Needs further analysis.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#751
No description provided.