-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: modularize nixosSystem with hosts
- Loading branch information
Showing
3 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
specialArgs, | ||
isNixOS, | ||
... | ||
}: let | ||
username = "${specialArgs.username}"; | ||
mkHost = host: type: let | ||
lib = specialArgs.inputs.nixpkgs.lib; | ||
home-manager = specialArgs.inputs.home-manager; | ||
nixpkgs = specialArgs.inputs.nixpkgs; | ||
in | ||
if isNixOS | ||
then | ||
lib.nixosSystem { | ||
inherit specialArgs; | ||
modules = [ | ||
./${host} | ||
../modules/${type} | ||
../options/${type} | ||
home-manager.nixosModules.home-manager | ||
{ | ||
home-manager = { | ||
# Because we use Home-Manager as a pure configuration manager. | ||
useUserPackages = lib.mkForce false; | ||
useGlobalPkgs = lib.mkForce true; | ||
|
||
extraSpecialArgs = specialArgs; | ||
users."${username}" = { | ||
imports = [ | ||
../home/${type} | ||
]; | ||
}; | ||
}; | ||
} | ||
]; | ||
} | ||
else | ||
home-manager.lib.homeManagerConfiguration { | ||
extraSpecialArgs = specialArgs; | ||
pkgs = import nixpkgs {config.allowUnfree = lib.mkForce true;}; | ||
modules = [ | ||
../home/${type} | ||
]; | ||
}; | ||
in | ||
builtins.listToAttrs (builtins.attrValues (builtins.mapAttrs (host: type: { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
name = | ||
if isNixOS | ||
then host | ||
else "${username}@${host}"; | ||
value = mkHost host type; | ||
}) { | ||
"dekomori" = "desktop"; | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Conversion of the dictionary
{ "dekomori" = "desktop" }
into a dictionary with nested dictionaries{ "dekomori" = { name = "dekomori"; value = <nixosConfig> } }
.Conversion of the dictionary from the first step into a list of dictionaries
[ { name = "dekomori"; value = <nixosConfig> } ]
.Conversion of the list from the second step back into a dictionary
{ dekomori = <nixosConfig> }
.