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

Disallow reading flake.lock #5250

Merged
merged 1 commit into from
Sep 14, 2021
Merged

Conversation

edolstra
Copy link
Member

With --no-write-lock-file, it's possible that flake.lock is out of sync with the actual inputs used by the evaluation. So doing fromJSON (readFile ./flake.lock) will give wrong results.

Fixes #4639.

With --no-write-lock-file, it's possible that flake.lock is out of
sync with the actual inputs used by the evaluation. So doing fromJSON
(readFile ./flake.lock) will give wrong results.

Fixes NixOS#4639.
@edolstra edolstra merged commit 2c751c0 into NixOS:master Sep 14, 2021
@edolstra edolstra deleted the censor-flake-lock branch September 14, 2021 20:27
@grahamc
Copy link
Member

grahamc commented Sep 15, 2021 via email

@edolstra
Copy link
Member Author

Yes, this is imperfect. It would probably be better to filter flake.lock while copying the source tree to the store.

  1. is a good point, I guess we should allow access to flake.lock in the legacy case.

@thufschmitt
Copy link
Member

It would probably be better to filter flake.lock while copying the source tree to the store.

I think that might have some unattended side-effects. For example I have something along the lines of nix.registry.p.flake = ./. in my NixOS config, meaning that I want the flake.lock to be in the store.

  1. is a good point, I guess we should allow access to flake.lock in the legacy case.

What about, as a first approximation, only disallow access to the flake.lock when

  1. The evaluation runs in “pure” mode, and
  2. The flake.lock is at the root of a store path (/nix/store/foobar/flake.lock)
    ?

@grahamc
Copy link
Member

grahamc commented Sep 15, 2021 via email

@edolstra
Copy link
Member Author

Yes, the correct solution would be to make a copy of the source tree and write the lock file. That's pretty slow/disk-space-inefficient though...

Alternatively we can mark the top-level source tree as dirty (so no rev etc. attributes are passed). That way configurations that assert a clean tree would at least fail.

@grahamc
Copy link
Member

grahamc commented Sep 15, 2021 via email

@figsoda
Copy link
Member

figsoda commented Sep 15, 2021

this should only be enabled when using flakes, or else stuff like flake-compat wouldn't work

@tomberek
Copy link
Contributor

tomberek commented Jun 20, 2022

fromJSON (readFile ./flake.lock)

Would it be acceptable to expose the in-memory lockFileStr? A small modification to call-flake.nix would do it. This would remove the incentive or need to do the imperfect fromJSON/readFile.

Alternative would be to expose it as a builtin, but that would make it ambiguous with getFlake or in other situations.

eg: tomberek@a6a1e5c

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

Successfully merging this pull request may close these issues.

Make flake.lock unreadable in flake evaluation
5 participants