Skip to content

Method to copy lock entry from one flake to another #14564

@peterwaller-arm

Description

@peterwaller-arm

Describe the bug

I expected nix flake update --inputs-from ~/another-flake nixpkgs to copy the input from another-flake to the flake in $PWD.

It fails with:

warning: not writing lock file of flake 'git+file:///path-to-current-flake' because it has an unlocked input ('github:NixOS/nixpkgs/nixos-unstable?narHash=sha256-<hash>')

~/another-flake has a lockfile entry for nixpkgs which includes a rev and a narHash.

It seems to me that rather than failing, a useful natural behaviour would be to make use of the lock file entry in ~/another-flake. I'm not totally certain though what the intended behaviour of inputs-from is, and whether what I'm asking for is really a new feature request with a different name than --inputs-from.

Steps To Reproduce

  1. Have two flakes
  2. From the directory of one, the nixpkgs input from one to the other: nix flake update --inputs-from ~/another-flake nixpkgs
  3. Observe warning and that the lockfile is left unmodified.

Expected behavior

I expected the flake lock entry for the requested input (nixpkgs) to be essentially copied from one to the other.

Metadata

nix (Nix) 2.31.2

Additional context

If I supply --option allow-dirty-locks true, then the command succeeds, but it records the ref rather than the rev into the locked entry.

There is --reference-lock-file, but this does not seem to do what I'm after either.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions