The situation is that I have been using a flake.nix
NixOS setup so far, and I would like to try out an npins
based NixOS setup (i.e. one that uses a configuraiton.nix).
I have a ~/nixos-conf
directory with a default.nix
(I could call it configuration.nix
, but I don’t think it matters ultimately?).
I’ve gotten npins
initialized, and I have the following in my sources.json
:
1 │ {
2 │ "pins": {
3 │ "nixpkgs": {
4 │ "type": "Channel",
5 │ "name": "nixpkgs-unstable",
6 │ "url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.05pre552261.8b8c94078445/nixexprs.t
│ ar.xz",
7 │ "hash": "0p9z4sj3svk28agmk98bi24gnw81r5nwknxvrhyz4v6dp5wymn4i"
8 │ }
9 │ },
10 │ "version": 3
11 │ }
So, nixpkgs
(unstable) is currently pinned by npins
for my configuration project.
Next up, in my configuration.nix
(which I’m calling default.nix
), I have:
{
config,
...
}:
let
hostName = config.networking.hostName;
sources = import ./npins;
in
{
environment.etc."nixpkgs".source = sources.nixpkgs;
# my guess is this nixpkgs overlay may not be needed anymore? but i'm not yet sure.
nixpkgs.overlays =
let
npinsOverlay = self: _super: {
inherit (sources) nixpkgs;
};
in
[ npinsOverlay ];
nix.nixPath = [
# so that <nixpkgs> has the right path
"nixpkgs=/home/bzm3r/nixos-conf/npins"
# so that nixos-rebuild etc. have the right path
"nixos-config=/home/bzm3r/nixos-conf/default.nix"
# don not understand why this last one is needed
# therefore left it out
# "/nix/var/nix/profiles/per-user/root/channels"
];
...
}
Finally, only because I am currently still on the system configured by the flakes.nix
setup, I decided to set up a shell.nix
that lets me run my nixos-rebuild switch
a little more ergonomically:
{
sources ? import ./npins,
pkgs ? import sources.nixpkgs {}
}:
pkgs.mkShell {
buildInputs = with pkgs; [
nix
];
shellHook = ''
export nixpkgs=${sources.nixpkgs.outPath}
export NIX_PATH=nixpkgs=${sources.nixpkgs.outPath}:nixos-config=/home/bzm3r/nixos-conf/default.nix
'';
}
(which I think is equivalent to setting export NIX_PATH=nixpkgs=~/nixos-conf/npins:nixos-config=~/nixos-conf/default.nix
?)
Ultimately, I end up getting this error:
❯ nixos-rebuild switch
error:
… while evaluating the attribute 'config'
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:9:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:18:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full trace)
error: infinite recursion encountered
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:233:21:
232| (regularModules ++ [ internalModule ])
233| ({ inherit lib options config specialArgs; } // specialArgs);
| ^
234| in mergeModules prefix (reverseList collected);
building Nix...
error:
… while evaluating the attribute 'config'
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:9:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:18:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full trace)
error: infinite recursion encountered
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:233:21:
232| (regularModules ++ [ internalModule ])
233| ({ inherit lib options config specialArgs; } // specialArgs);
| ^
234| in mergeModules prefix (reverseList collected);
building the system configuration...
error:
… while evaluating the attribute 'config.system.build.toplevel'
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:9:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:320:18:
319| options = checked options;
320| config = checked (removeAttrs config [ "_module" ]);
| ^
321| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full trace)
error: infinite recursion encountered
at /nix/store/a1n82l7alhh1fn33nyp7p5qk43lr87z9-source/lib/modules.nix:233:21:
232| (regularModules ++ [ internalModule ])
233| ({ inherit lib options config specialArgs; } // specialArgs);
| ^
234| in mergeModules prefix (reverseList collected);
Any tips on what I could google next, or try out next, would be very helpful!
(here’s the github repo for all the above, in case it’s helpful: here’s the github repo for all the above: https://github.com/bzm3r/nixos-conf/tree/no-flakes)