···12 default.value = { };
13 type = homes-type;
14 };
15-16- config = {
17- assertions = lib.attrs.mapToList (name: value: {
18- assertion = !(builtins.isNull value.pkgs);
19- message = "A Nixpkgs instance is required for the home-manager home \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist.";
20- }) config.homes;
21- };
22}
···16 name = "home";
17 description = "A home-manager home";
18 module =
19- { config }@submodule:
20 let
21 home_name = config.__module__.args.dynamic.name;
22 home_name_parts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" home_name;
···106 description = "The created Home Manager home for each of the systems.";
107 type = lib.types.attrs.of lib.types.raw;
108 writable = false;
109- default.value = result;
0000110 };
111 };
112
···16 name = "home";
17 description = "A home-manager home";
18 module =
19+ { config, name }@submodule:
20 let
21 home_name = config.__module__.args.dynamic.name;
22 home_name_parts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" home_name;
···106 description = "The created Home Manager home for each of the systems.";
107 type = lib.types.attrs.of lib.types.raw;
108 writable = false;
109+ default.value =
110+ if builtins.isNull config.pkgs then
111+ "A Nixpkgs instance is required for the home-manager home \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist."
112+ else
113+ result;
114 };
115 };
116
+32-69
packetmix/modules/nilla-home/nixos.nix
···37 homeManager = submodule.config.home-manager;
38 in
39 (lib.fp.pipe [
000000040 (lib.attrs.mapToList (
41 homeName: home:
42 let
43 homeNameParts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" homeName;
44 username = builtins.elemAt homeNameParts 0;
00045 in
46- {
47- inherit home homeName username;
48- }
000000049 ))
0000000000050 (builtins.map (
51 {
52 home,
53 homeName,
54- ...
55 }@identity:
56 warnIf (home.home-manager != homeManager)
57 "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."
···94 );
95 };
96 };
97-98- config = {
99- assertions = lib.lists.flatten (
100- lib.attrs.mapToList (
101- name: value:
102- let
103- hasNixpkgs = !(builtins.isNull value.pkgs);
104- requestedHomes = value.homes != [ ];
105- hasHomeManager = !(builtins.isNull value.home-manager);
106- in
107- [
108- {
109- assertion = hasNixpkgs;
110- message = "A Nixpkgs instance is required for the NixOS system \"${name}\", but none was provided and \"inputs.nixpkgs\" does not exist.";
111- }
112- {
113- assertion = !requestedHomes || hasHomeManager;
114- 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.";
115- }
116- (lib.attrs.mapToList (
117- homeName: home:
118- let
119- homeHasHomeManager = !(builtins.isNull home.home-manager);
120- homeIsValidForSystem = home ? result.${value.pkgs.stdenv.hostPlatform.system};
121- in
122- [
123- {
124- assertion = homeHasHomeManager;
125- 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.";
126- }
127- {
128- assertion = !homeHasHomeManager || !hasNixpkgs || homeIsValidForSystem;
129- 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.";
130- }
131- ]
132- ) value.homes)
133- (
134- let
135- usernames = lib.attrs.mapToList (
136- homeName: home:
137- let
138- homeHasHomeManager = !(builtins.isNull home.home-manager);
139- homeIsValidForSystem = home ? result.${value.pkgs.stdenv.hostPlatform.system};
140- in
141- if homeHasHomeManager && hasNixpkgs && homeIsValidForSystem then
142- let
143- homeNameParts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" homeName;
144- username = builtins.elemAt homeNameParts 0;
145- in
146- username
147- else
148- null
149- ) value.homes;
150- existingUsernames = builtins.filter (username: username != null) usernames;
151- uniqueUsernames = lib.lists.unique existingUsernames;
152- in
153- {
154- assertion = !hasNixpkgs || (existingUsernames == uniqueUsernames);
155- 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.";
156- }
157- )
158- ]
159- ) global.config.systems.nixos
160- );
161- };
162}
···37 homeManager = submodule.config.home-manager;
38 in
39 (lib.fp.pipe [
40+ (
41+ value:
42+ if builtins.isNull homeManager && value != [ ] then
43+ 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."
44+ else
45+ value
46+ )
47 (lib.attrs.mapToList (
48 homeName: home:
49 let
50 homeNameParts = builtins.match "([a-z][-a-z0-9]*)(@([-A-Za-z0-9]+))?(:([-_A-Za-z0-9]+))?" homeName;
51 username = builtins.elemAt homeNameParts 0;
52+ homeHasHomeManager = !(builtins.isNull home.home-manager);
53+ homeIsValidForSystem =
54+ home ? result.${config.pkgs.stdenv.hostPlatform.system or config.pkgs.system};
55 in
56+ if !homeHasHomeManager then
57+ 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."
58+ else if !homeIsValidForSystem then
59+ builtins.throw "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it isn't valid for \"${
60+ config.pkgs.stdenv.hostPlatform.system or config.pkgs.system
61+ }\" systems."
62+ else
63+ {
64+ inherit home homeName username;
65+ }
66 ))
67+ (
68+ values:
69+ let
70+ existingUsernames = builtins.filter (value: value.username != null) values;
71+ uniqueUsernames = lib.lists.unique existingUsernames;
72+ in
73+ if existingUsernames != uniqueUsernames then
74+ 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."
75+ else
76+ values
77+ )
78 (builtins.map (
79 {
80 home,
81 homeName,
82+ username,
83 }@identity:
84 warnIf (home.home-manager != homeManager)
85 "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."
···122 );
123 };
124 };
00000000000000000000000000000000000000000000000000000000000000000125}