In my NixOS configuration, I have a module packages.nix that defines environment.systemPackages. There’s a basic set of packages included on all of my machines. But I want an option to add some packages to the set for a particular machine.
Here’s packages.nix:
{ config, pkgs, options, inputs, ... }:
with pkgs;
{
options = {
extraPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
};
};
config =
let
extra = config.extraPackages;
in
{
environment.systemPackages = extra ++ [
. . . LIST OF PACKAGES HERE . . .
];
}; # config
}
However, when I try to use the option in flake.nix, I have a problem:
nixosConfigurations = {
wombat11k = let hostnameNew = "wombat11k"; in nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
modules =
[
. . .
./packages.nix { extraPackages = [ kodi ]; }
];
}; # wombat11k
. . .
}
I get the message error: undefined variable 'kodi'. I’ve tried nixpkgs.kodi, pkgs.kodi and nixpkgs.lib.pkgs.kodi, but they don’t work either. What’s the magic incantation?