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

--override-input does not affect flake.lock in self.outPath #6894

Open
tejing1 opened this issue Aug 10, 2022 · 2 comments
Open

--override-input does not affect flake.lock in self.outPath #6894

tejing1 opened this issue Aug 10, 2022 · 2 comments
Labels

Comments

@tejing1
Copy link

tejing1 commented Aug 10, 2022

Describe the bug

One of the notable uses of flakes is to provide traceability. For example, one may include a reference to self.outPath in one's nixos configuration in order to retain a copy of the flake that was used to create the generation. However, this fails to correctly record the source in the case where --override-input is used.

Steps To Reproduce

$ find
.
./flake.nix
$ cat flake.nix
{
  inputs.nixpkgs.url = github:nixos/nixpkgs/nixos-22.05;
  outputs = {self, nixpkgs, ...}@inputs: {
    inherit self;
  };
}
$ cat $(nix eval --raw .\#self.outPath)/flake.lock
warning: creating lock file '/mnt/persist/share/data/tejing/work/tmpflake/flake.lock'
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1660120254,
        "narHash": "sha256-EMBa86JQ6W0och5Kxb1XmprgN/HFsSuJ9fRa2PtV3uk=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "e4c9d950a3c54a0760b127d406f6528eb625eed8",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-22.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}
$ cat $(nix eval --raw .\#self.outPath --override-input nixpkgs github:nixos/nixpkgs/nixos-unstable)/flake.lock
warning: not writing modified lock file of flake 'path:/mnt/persist/share/data/tejing/work/tmpflake':
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/e4c9d950a3c54a0760b127d406f6528eb625eed8' (2022-08-10)
  → 'github:nixos/nixpkgs/39d7f929fbcb1446ad7aa7441b04fb30625a4190' (2022-08-08)
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1660120254,
        "narHash": "sha256-EMBa86JQ6W0och5Kxb1XmprgN/HFsSuJ9fRa2PtV3uk=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "e4c9d950a3c54a0760b127d406f6528eb625eed8",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-22.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

Expected behavior

I would expect the flake.lock in self to reflect the actual evaluation conditions, rather than the flake.lock that happened to be in the source, when they differ due to command-line overrides.

nix-env --version output

$ nix-env --version
nix-env (Nix) 2.8.1
@tejing1 tejing1 added the bug label Aug 10, 2022
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/what-would-you-change-in-nix-or-nixos/21086/3

@pbsds
Copy link

pbsds commented Mar 2, 2023

This also applies to --recreate-lock-file --no-write-lock-file. --no-write-lock-file should still update the flake.lock in the store, but not in the local flake checkout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants