Hello,
I have an issue. I am integrating home manger into my nixos config and I wanted to add per-user support by passing an extra username argument. For this, I created a wrapper
home = username: args: (import ./home.nix (args // {username = username;}));
Now, if I understand nix correctly, doing
import ./home.nix {arg1=1; arg2=2; username="myuser";}
Should be exactly the same as doing
(home "myuser") {arg1=1; arg2=2;}
However, my wrapper doesn’t seem to work.
My semi-full config:
flake.nix in /etc/nixos/
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
# Due to https://github.com/nix-community/plasma-manager/issues/556
url = "github:nix-community/plasma-manager/d4fae34";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
};
outputs =
{
self,
nixpkgs,
home-manager,
plasma-manager,
...
}@inputs:
let
home = username: args: (import ./home.nix (args // {username = username;}));
in
{
nixosConfigurations.victus-nix = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [ plasma-manager.homeModules.plasma-manager ];
home-manager.users.myname = home "myname";
}
];
};
};
}
my dummy home.nix
{ config, pkgs, ... }@args:
{
home = {
stateVersion = "25.05";
packages = with pkgs; [];
};
}
If I try `nixos-rebuild build` I get
error: function 'anonymous lambda' called without required argument 'pkgs'
at /etc/nixos/home.nix:1:1:
1| { config, pkgs, ... }@args:
| ^
2| {
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/etc/nixos#nixosConfigurations."victus-nix".config.system.build.toplevel'' returned non-zero exit status 1.
However if I replace home "myname" with just import ./home.nix\ it works.
HOWEVER it also works if I just leave it as import ./home.nix and change ./home.nix to
{ username }:
{ config, pkgs, ... }@args:
{
home = {
stateVersion = "25.05";
packages = with pkgs; [];
};
}
It suddenly seems to work the way I intended??
What is going on? What I suspect is something somewhere is looking up expected named arguments of the function import ./home.nix and not passing the pkgs if it isnt a named argument, (as it also works if the wrapper explicitly names pkgs). But, like, how would I even check that is what is happening?