Hi!
I want to upgrade my <nixpkgs> to get nushell latest version for a project I’m working on but I’m not able to set a path to <nixpkgs> since I’m building my configuration from a configuration.nix file located in another place to track it with git more easily.
I followed this answer to troubleshoot but I get the following error:
~/waves_nixconfig> sudo nixos-rebuild switch --upgrade
unpacking 2 channels...
error:
… while evaluating the attribute 'config'
at /nix/store/22d94ry10ivvac4z97713iw3wr78icxl-nixos-25.11/nixos/lib/modules.nix:361:9:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/22d94ry10ivvac4z97713iw3wr78icxl-nixos-25.11/nixos/lib/modules.nix:361:18:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
… while evaluating the module argument `inputs' in "/home/wavesinaroom/waves_nixconfig/configuration.nix":
… noting that argument `inputs` is not externally provided, so querying `_module.args` instead, requiring `config`
… if you get an infinite recursion here, you probably reference `config` in `imports`. If you are trying to achieve a conditional import behavior dependent on `config`, consider importing unconditionally, and using `mkEnableOption` and `mkIf` to control its effect.
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: infinite recursion encountered
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.nixos-rebuild --no-out-link' returned non-zero exit status 1.
The infinity recursion happens also with this command sudo nixos-rebuild switch -I nixos-config=~/waves_nixconfig/configuration.nix which is expected.
I managing my NixosWSL config with a flake that pins <nixpkgs> unstable and calls my configuration.nix file as a module the way we all are familiar with. I’m a bit confused about how to set <nixpkgs> path so I’d like ask for help but more importantly for reasons why infinite recursion happen. There’s some info here but I want to ask the community first to not to fall into a rabbit hole that delays my Nushell project for a long time.
~/waves_nixconfig/flake.nix
{
description = "Waves in a room set up";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, ... }@inputs:
{
nixosConfigurations."desktop" = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [ ./configuration.nix ];
};
};
}
~/waves_nixconfig/configuration.nix
{
inputs,
pkgs,
config,
...
}:
{
imports = [
inputs.nixos-wsl.nixosModules.default
inputs.home-manager.nixosModules.home-manager
./hardware-configuration.nix
];
wsl.enable = true;
wsl.defaultUser = "wavesinaroom";
wsl.wslConf.network.hostname = "desktop";
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
nix.nixPath = [
"nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
"nixos-config=${config.users.users.wavesinaroom.home}/waves_nixconfig/configuration.nix"
"/nix/var/nix/profiles/per-user/root/channels"
];
}