Nixlock: A minimal, flake-compatible input pinning method using only Nix itself

https://codeberg.org/FrdrCkII/nixlock

9 Likes

How do one actually create/save/update the lock file? I guess it’s something like:

nix-instantiate --eval --strict lock.nix > lock.lock

Is this correct? By the way, great idea for using Nix itself for locking!

1 Like

Actually, it should be:

nix-instantiate --impure --strict --eval \
    --expr '(import ./default.nix {pure = true;})' \
    > lock.tmp
mv -f lock.tmp lock.nix

It’s a bit complicated; you can find commands in the justfile.

I am trying to implement a simpler version, without complex commands. I have made some progress and now writing the documentation.

I think this should be import ./lock.nix {} since default.nix doesn’t appear to care about any pure arg. But then that gets back to what @bryango said.

Oh, yes. I got it wrong. But nixlock actually doesn’t care about the file name, I usually name it default.nix.

1 Like