Hi,
I’m learning nix with this awesome book someone here showed me and I’m struggling with a notion explained in it:
I’m learning what nix modules are and how I could use them to modularize my configuration. However I’m have issues when using the ‘specialArgs’ variable described in the book as a variable to pass extra arguments to all modules.
It works perfectly when I try to define it to pass arguments to the configuration.nix module when building my system-wide configuration, but nix complains about it being unexpected when defining it for the homeManagerConfiguration modules.
Here is the flake:
Summary
{
description = "JM445's Nix system configuration flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.05";
home-manager.url = "github:nix-community/home-manager/release-23.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixpie.url = "git+https://gitlab.cri.epita.fr/cri/infrastructure/nixpie.git";
};
outputs = inputs@{ nixpkgs, home-manager, nixpie, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {allowUnfree = true;};
};
lib = nixpkgs.lib;
nixpiepkg = nixpie.packages.${system};
in {
homeManagerConfigurations = {
jm445 = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
specialArgs = {nixpie = nixpiepkg;}; # This raise an error
modules = [
./user/home.nix
{
home = {
username = "jm445";
homeDirectory = "/home/jm445";
};
}
];
};
};
nixosConfigurations = {
nixos = lib.nixosSystem {
inherit system;
specialArgs = {nixpie = nixpiepkg;}; # This works as expected
modules = [
./system/configuration.nix
];
};
};
};
}
When passing my specialArgs to nixosSystem modules, I am able to install a package that is inside ‘nixpie’ but I would prefer to install it at the user level with home manager.
What am I missing ?
Thank’s,
JM