Refactor flake infrastructure code

This was LONG overdue...
This commit is contained in:
Kiana Sheibani 2024-03-20 01:07:09 -04:00
parent e5347dffcb
commit 2d9c13c7a2

103
flake.nix
View file

@ -29,73 +29,66 @@ outputs = { self,
email = "kiana.a.sheibani@gmail.com"; email = "kiana.a.sheibani@gmail.com";
moduleArgs = { inherit username fullname email; } // inputs; moduleArgs = { inherit username fullname email; } // inputs;
lib = nixpkgs.lib;
mkConfig =
{ platform,
system ? "x86_64-linux",
configModules ? [ ./config ],
configExtraModules ? [],
homeModules ? [ ./home-manager ],
homeExtraModules ? []
}:
nixpkgs.lib.nixosSystem {
inherit system;
modules =
configModules ++
configExtraModules ++
[
./platform.nix
{ _module.args = moduleArgs;
inherit platform; }
./hardware-configuration/${platform}.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = moduleArgs;
home-manager.sharedModules = [ ./platform.nix { inherit platform; } ];
home-manager.users.${username} = {
imports = homeModules ++ homeExtraModules;
};
}
];
};
in { in {
nixosConfigurations = { nixosConfigurations = {
"${username}-desktop" = lib.nixosSystem { "${username}-desktop" = mkConfig {
system = "x86_64-linux"; platform = "desktop";
modules = [
./config
./platform.nix
./hardware-configuration/desktop.nix
{ _module.args = moduleArgs;
platform = "desktop"; }
home-manager.nixosModules.home-manager
{
home-manager.users.${username} = import ./home-manager;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [ ./platform.nix { platform = "desktop"; } ];
home-manager.extraSpecialArgs = moduleArgs;
}
];
}; };
"${username}-laptop" = lib.nixosSystem { "${username}-laptop" = mkConfig {
system = "x86_64-linux"; platform = "laptop";
modules = [ configExtraModules = [
./config
{ _module.args = moduleArgs;
platform = "laptop"; }
./platform.nix
./hardware-configuration/laptop.nix
home-manager.nixosModules.home-manager
nixos-hardware.nixosModules.microsoft-surface-pro-intel nixos-hardware.nixosModules.microsoft-surface-pro-intel
{
home-manager.users.${username} = import ./home-manager;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [ ./platform.nix { platform = "laptop"; } ];
home-manager.extraSpecialArgs = moduleArgs;
}
]; ];
}; };
"${username}-mobile" = lib.nixosSystem { "${username}-mobile" = mkConfig {
platform = "mobile";
system = "aarch64-linux"; system = "aarch64-linux";
modules = [ configModules = [
./config ./config
./mobile/config.nix ./mobile/config.nix
{ _module.args = moduleArgs;
platform = "mobile"; }
./platform.nix
./hardware-configuration/mobile.nix
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
(import (mobile-nixos + /lib/configuration.nix) { device = "pine64-pinephonepro"; }) (import (mobile-nixos + /lib/configuration.nix)
(sxmo + /modules/sxmo) (sxmo + /modules/tinydm) { device = "pine64-pinephonepro"; })
{ (sxmo + /modules/sxmo)
home-manager.users.${username} = import ./mobile/home-manager.nix; (sxmo + /modules/tinydm)
];
home-manager.useGlobalPkgs = true; homeModules = [
home-manager.useUserPackages = true; ./mobile/home-manager.nix
home-manager.sharedModules = [ ./platform.nix { platform = "mobile"; } ];
home-manager.extraSpecialArgs = moduleArgs;
}
]; ];
}; };
}; };