···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}
+5-1
packetmix/modules/nilla-home/homes-type.nix
···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
+31-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 = home ? result.${config.pkgs.stdenv.hostPlatform.system or config.pkgs.system};
4554 in
4646- {
4747- inherit home homeName username;
4848- }
5555+ if !homeHasHomeManager then
5656+ 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."
5757+ else if !homeIsValidForSystem then
5858+ builtins.throw "You've asked for the home \"${homeName}\" to be activated in the NixOS system \"${name}\", but it isn't valid for \"${
5959+ config.pkgs.stdenv.hostPlatform.system or config.pkgs.system
6060+ }\" systems."
6161+ else
6262+ {
6363+ inherit home homeName username;
6464+ }
4965 ))
6666+ (
6767+ values:
6868+ let
6969+ existingUsernames = builtins.filter (value: value.username != null) values;
7070+ uniqueUsernames = lib.lists.unique existingUsernames;
7171+ in
7272+ if existingUsernames != uniqueUsernames then
7373+ 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."
7474+ else
7575+ values
7676+ )
5077 (builtins.map (
5178 {
5279 home,
5380 homeName,
5454- ...
8181+ username,
5582 }@identity:
5683 warnIf (home.home-manager != homeManager)
5784 "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."
···93120 )
94121 );
95122 };
9696- };
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- );
161123 };
162124}