-
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.
refactor: peel back
mkSystem
abstractions
- Remove `lib/system.nix` - Remove `lib/user.nix` - Move system creation functions to `hosts/flake-module.nix` - Greatly reduce abstractions, could still be reduced further Also: - Reduced module `specialArgs` to just `self` & `inputs` - Manually import `hardware-configuration.nix` in `configuration.nix`
- Loading branch information
1 parent
029ec20
commit 4deb81b
Showing
8 changed files
with
84 additions
and
209 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,83 @@ | ||
{ self, ... }: | ||
{ self, inputs, lib, ... }: | ||
let | ||
inherit (self.lib) mkNixOSConfig mkHMConfig; | ||
specialArgs = { inherit self inputs; }; | ||
|
||
# Define my user, used by most configurations | ||
# see initUser in lib/user.nix | ||
userMatt = { | ||
name = "matt"; | ||
description = "Matt Sturgeon"; | ||
initialPassword = "init"; | ||
isAdmin = true; | ||
}; | ||
guessUsername = name: | ||
let | ||
parts = lib.splitString "@" name; | ||
len = builtins.length parts; | ||
in | ||
if len == 2 then builtins.head parts else name; | ||
|
||
guessHostname = name: | ||
let | ||
parts = lib.splitString "@" name; | ||
len = builtins.length parts; | ||
in | ||
lib.optionalString (len == 2) (builtins.elemAt parts 1); | ||
|
||
mkSystem = name: | ||
{ system | ||
, username ? "matt" | ||
, fullname ? "Matt Sturgeon" | ||
, modules ? [ ] | ||
, ... | ||
}: inputs.nixpkgs.lib.nixosSystem { | ||
inherit system specialArgs; | ||
modules = modules ++ [ | ||
./${name}/configuration.nix | ||
self.nixosModules.common | ||
self.nixosModules.nixos | ||
inputs.home-manager.nixosModules.home-manager | ||
{ | ||
users.users.${username} = { | ||
description = fullname; | ||
extraGroups = [ "wheel" "networkmanager" ]; | ||
initialPassword = "init"; | ||
isNormalUser = true; | ||
}; | ||
home-manager = { | ||
useGlobalPkgs = true; | ||
useUserPackages = true; | ||
extraSpecialArgs = specialArgs; | ||
sharedModules = [ self.homeModules.home ]; | ||
users.${username} = ./${name}/home.nix; | ||
}; | ||
} | ||
]; | ||
}; | ||
|
||
mkHome = name: | ||
{ system | ||
, username ? guessUsername name | ||
, hostname ? guessHostname name | ||
, modules ? [ ] | ||
, ... | ||
}: inputs.home-manager.lib.homeManagerConfiguration { | ||
extraSpecialArgs = specialArgs; | ||
pkgs = inputs.nixpkgs.legacyPackages.${system}; | ||
modules = modules ++ [ | ||
# FIXME doesn't support username-specific configs | ||
./${hostname}/home.nix | ||
self.homeModules.common | ||
self.homeModules.home | ||
{ | ||
home.username = username; | ||
home.homeDirectory = "/home/${username}"; | ||
} | ||
]; | ||
}; | ||
in | ||
{ | ||
flake = { | ||
# NixOS configurations | ||
nixosConfigurations = { | ||
matebook = mkNixOSConfig { | ||
hostname = "matebook"; | ||
hmUsers = [ userMatt ]; | ||
nixosModules = with self.nixosModules; [ common nixos ]; | ||
homeManagerModules = [ self.homeModules.home ]; | ||
}; | ||
nixosConfigurations = builtins.mapAttrs mkSystem { | ||
matebook = { system = "x86_64-linux"; }; | ||
}; | ||
|
||
# Standalone home-manager configuration entrypoint | ||
homeConfigurations = { | ||
"matt@desktop" = mkHMConfig { | ||
hostname = "desktop"; | ||
user = userMatt; | ||
modules = with self.homeModules; [ common home ]; | ||
}; | ||
# Standalone home-manager configurations | ||
homeConfigurations = builtins.mapAttrs mkHome { | ||
"matt@desktop" = { system = "x86_64-linux"; }; | ||
}; | ||
}; | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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