nix
nix copied to clipboard
`--override-input` does not affect `flake.lock` in `self.outPath`
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