I’m not using home-manager
as a module (this is a deliberate choice because I want users to be able to independently handle their HM configs without admin-rights), so I have no access to osConfig
.
However, I propagate unstable
via a system-level overlay like so:
{ inputs, pkgs, unstable, ... }:
{
nixpkgs.overlays = [
(import ...)
];
# this *adds* unstable to the available args for all modules
_module.args.unstable = import inputs.nixpkgs-unstable { inherit (pkgs) system config; };
nix.nixPath = [ "nixpkgs=${pkgs.path}" "unstable=${unstable.path}" ];
}
and then in my flake:
homeConfigurations = (
import ./home/hm-builder.nix {
inherit (nixpkgs) lib;
inherit inputs;
systemConfigs = inputs.self.nixosConfigurations // inputs.self.darwinConfigurations;
}
).getHMConfigs; # all top level user names (dirs) under ./home will be used and paired with hostnames if the user is defined in the host definition
where getHMConfigs
calls mkHome
(for defined user/host combinations):
mkHome = username: hostname: (
let
inherit (systemConfigs."${hostname}") pkgs config;
inherit (systemConfigs."${hostname}"._module.args) unstable;
inherit (pkgs) system;
osConfig = config;
homeDirectory = "${if lib.hasInfix "darwin" system then "/Users" else "/home"}/${username}";
configHome = "${homeDirectory}/.config";
in
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
../home/home.nix
(if builtins.pathExists (./. + "/${username}/overlays") then (./. + "/${username}/overlays") else {})
];
extraSpecialArgs = { inherit inputs username unstable hostname homeDirectory osConfig; };
});
and finally (just for context) home.nix
:
{ pkgs
, unstable
, username
, homeDirectory /* ? pkgs.config.homeDirectory */
, hostname
, lib ? pkgs.lib
, ... }:
{
imports = [
./switch.nix # put the switch script (to apply this flake for system and HM config) in the user's ${HOME}/.local/bin
(./. + "/${username}/${hostname}") # much simplified: just enforce that the user@host has indeed a defined default.nix in place
];
home.sessionPath = [ "${homeDirectory}/bin" ]; # add to PATH
fonts.fontconfig.enable = true;
home.username = username;
home.homeDirectory = homeDirectory;
home.stateVersion = "22.11";
}
This works perfectly fine on linux
, but on darwin
I get
error: attribute '_module' missing
at /nix/store/f8fwzhc3ibdy04c9a2xfx0dh3h1lp6ia-source/home/hm-builder.nix:12:16:
11| inherit (systemConfigs."${hostname}") pkgs config;
12| inherit (systemConfigs."${hostname}"._module.args) unstable;
| ^
13| inherit (pkgs) system;
So the question is, how can I pass the osConfig’s _module
attribute from the darwinConfigurations.${myhostname}
in the same way as is automatically done for nixosConfigurations
?