···1212 default.value = { };
1313 type = homes-type;
1414 };
1515-1616- config = {
1717- assertions = lib.attrs.mapToList (name: value: {
1818- assertion = !(builtins.isNull value.pkgs);
1919- message = "A Nixpkgs instance is required for the home-manager home \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist.";
2020- }) config.homes;
2121- };
2215}
+6-2
packetmix/modules/nilla-home/homes-type.nix
···1616 name = "home";
1717 description = "A home-manager home";
1818 module =
1919- { config }@submodule:
1919+ { config, name }@submodule:
2020 let
2121 home_name = config.__module__.args.dynamic.name;
2222 home_name_parts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" home_name;
···106106 description = "The created Home Manager home for each of the systems.";
107107 type = lib.types.attrs.of lib.types.raw;
108108 writable = false;
109109- default.value = result;
109109+ default.value =
110110+ if builtins.isNull config.pkgs then
111111+ "A Nixpkgs instance is required for the home-manager home \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist."
112112+ else
113113+ result;
110114 };
111115 };
112116
+32-69
packetmix/modules/nilla-home/nixos.nix
···3737 homeManager = submodule.config.home-manager;
3838 in
3939 (lib.fp.pipe [
4040+ (
4141+ value:
4242+ if builtins.isNull homeManager && value != [ ] then
4343+ builtins.throw "A home-manager instance is required to enable homes for the NixOS system \"${name}\", but none was provided and \"inputs.home-manager\" does not exist."
4444+ else
4545+ value
4646+ )
4047 (lib.attrs.mapToList (
4148 homeName: home:
4249 let
4350 homeNameParts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" homeName;
4451 username = builtins.elemAt homeNameParts 0;
5252+ homeHasHomeManager = !(builtins.isNull home.home-manager);
5353+ homeIsValidForSystem =
5454+ home ? result.${config.pkgs.stdenv.hostPlatform.system or config.pkgs.system};
4555 in
4646- {
4747- inherit home homeName username;
4848- }
5656+ if !homeHasHomeManager then
5757+ builtins.throw "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it needs a home-manager instance, none was provided and \"inputs.home-manager\" does not exist."
5858+ else if !homeIsValidForSystem then
5959+ builtins.throw "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it isn't valid for \"${
6060+ config.pkgs.stdenv.hostPlatform.system or config.pkgs.system
6161+ }\" systems."
6262+ else
6363+ {
6464+ inherit home homeName username;
6565+ }
4966 ))
6767+ (
6868+ values:
6969+ let
7070+ existingUsernames = builtins.filter (value: value.username != null) values;
7171+ uniqueUsernames = lib.lists.unique existingUsernames;
7272+ in
7373+ if existingUsernames != uniqueUsernames then
7474+ builtins.throw "There are multiple homes for a single user in the NixOS system \"${name}\". Please make sure you've only enabled a single home per user."
7575+ else
7676+ values
7777+ )
5078 (builtins.map (
5179 {
5280 home,
5381 homeName,
5454- ...
8282+ username,
5583 }@identity:
5684 warnIf (home.home-manager != homeManager)
5785 "The home \"${homeName}\" isn't using the same home-manager input as the NixOS system \"${name}\". This may work, but is not officially supported by the Nilla Home or Nilla NixOS maintainers. Please fix this before reporting any bugs you may find."
···94122 );
95123 };
96124 };
9797-9898- config = {
9999- assertions = lib.lists.flatten (
100100- lib.attrs.mapToList (
101101- name: value:
102102- let
103103- hasNixpkgs = !(builtins.isNull value.pkgs);
104104- requestedHomes = value.homes != [ ];
105105- hasHomeManager = !(builtins.isNull value.home-manager);
106106- in
107107- [
108108- {
109109- assertion = hasNixpkgs;
110110- message = "A Nixpkgs instance is required for the NixOS system \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist.";
111111- }
112112- {
113113- assertion = !requestedHomes || hasHomeManager;
114114- message = "A home-manager instance is required to enable homes for the NixOS system \"${name}\", but none was provided and \"inputs.home-manager\" does not exist.";
115115- }
116116- (lib.attrs.mapToList (
117117- homeName: home:
118118- let
119119- homeHasHomeManager = !(builtins.isNull home.home-manager);
120120- homeIsValidForSystem = home ? result.${value.pkgs.stdenv.hostPlatform.system};
121121- in
122122- [
123123- {
124124- assertion = homeHasHomeManager;
125125- message = "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it needs a home-manager instance, none was provided and \"inputs.home-manager\" does not exist.";
126126- }
127127- {
128128- assertion = !homeHasHomeManager || !hasNixpkgs || homeIsValidForSystem;
129129- message = "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it isn't valid for \"${value.pkgs.stdenv.hostPlatform.system}\" systems.";
130130- }
131131- ]
132132- ) value.homes)
133133- (
134134- let
135135- usernames = lib.attrs.mapToList (
136136- homeName: home:
137137- let
138138- homeHasHomeManager = !(builtins.isNull home.home-manager);
139139- homeIsValidForSystem = home ? result.${value.pkgs.stdenv.hostPlatform.system};
140140- in
141141- if homeHasHomeManager && hasNixpkgs && homeIsValidForSystem then
142142- let
143143- homeNameParts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" homeName;
144144- username = builtins.elemAt homeNameParts 0;
145145- in
146146- username
147147- else
148148- null
149149- ) value.homes;
150150- existingUsernames = builtins.filter (username: username != null) usernames;
151151- uniqueUsernames = lib.lists.unique existingUsernames;
152152- in
153153- {
154154- assertion = !hasNixpkgs || (existingUsernames == uniqueUsernames);
155155- message = "There are multiple homes for a single user in the NixOS system \"${name}\". Please make sure you've only enabled a single home per user.";
156156- }
157157- )
158158- ]
159159- ) global.config.systems.nixos
160160- );
161161- };
162125}