Refer to a flake in a local folder

Seems like this issue has arisen since I have updated to nixos-24.11.

I am developing a NixOS configuration that depends on a flake I am also developing, which is hosted on Github. In the current context, I have to improve the Github flake and then test the result on the local machine’s /etc/nixos configuration.

Before the NixOS upgrade, I used to casually develop in a clone of the flake, and refer to the flake directly from that folder. Once successful, I used to push the changes to Github and then upgrade the local machine flake input by pointing to the URL instead of the local folder.

It used to work wonderfully, but now, I get this kind of warnings when I point to a local folder:

warning: will not write lock file of flake 'git+file:///etc/nixos' because it has an unlocked input ('git+file:///PATH_TO_THE_CLONE')

Does this mean I have to push every tiny change to the flake to Github just to try it on the local machine?

1 Like

I am also running into this and it’s hindering my work flow severely.

There have sprung up several issues around this, but there seems to be no workaround:

The closest workaround seems to be to create a temporary commit in your checkout, before using flake lock in the dependent, but I agree that this is not satisfactory.

1 Like

Lix doesn’t seem to have that issue. I think that’s the workaround, I’ll be using for now: Lix | Switching To Lix, at least during development

As you said, NOT satisfactory…

Can I help fixing this, somehow?

Knock yourself out. I’m not willing to get involved deeper ATM, as certain people have started hounding me around whenever I bring up an issue …

Guess it’s nice to see I’m not alone with this problem.

Allow me to quote myself on the workaround that I just posted on the liked issue:

I created a script (nix-flake-update) that uses nix v2.20 to update the lock file, and then jq to “clean” it, before verifying that current nix accepts the lock file.

The script, with further comments how and why it works (and drawbacks), can be found here:
nix-wiplib/pkgs/scripts/nix-flake-update.sh at 65a5bcfa19296ca3d4833cfb08a946fe1529f2c5 · NiklasGollenstede/nix-wiplib · GitHub
The flake also experts the script as overlay and package.
Sometimes the script fails the first time I run it, but then success. I haven’t investigated that yet.

No, because it’s a warning. Building with an overriden dirty input should still work, but Nix won’t write a lock file anymore (which is the correct thing to do: it’s not a lock file if it has an unlocked input in it). You just have to pass --override-input to commands like nix build or nixos-rebuild rather than nix flake lock.

3 Likes

Thank you so much for your time, that solves the problem for me.

That worked. Thanks for taking the time to clear that up!