Refactor home-manager module imports

This commit is contained in:
Riley Apeldoorn 2023-06-19 15:15:59 +02:00
parent 7b502cc207
commit 05d9dd9808
4 changed files with 67 additions and 44 deletions

View file

@ -11,57 +11,75 @@
nixos-hardware.url = github:NixOS/nixos-hardware; nixos-hardware.url = github:NixOS/nixos-hardware;
}; };
outputs = args@{ home-manager, nixpkgs, agenix, nixos-hardware, ... }: with nixpkgs; { outputs = args@{ self, home-manager, nixpkgs, agenix, nixos-hardware, ... }: with nixpkgs; {
# Configurations for NixOS machines. # Configurations for NixOS machines.
nixosConfigurations = nixosConfigurations = let
let mkUserConfig = path: { # Generate a user configuration for the given user, based on the given home manager
imports = [ home-manager.nixosModules.home-manager ]; # configuration.
config = { userConfig = user: home: [
home-manager.users."riley" = (import "${path}/home.nix"); home-manager.nixosModules.home-manager
({ config, ... }: {
home-manager.users."${user}" = (home // {
config.home = {
inherit (config.system) stateVersion;
username = user;
}; };
}; }).config;
in { })
];
# Desktop system in {
"strawberry" = lib.nixosSystem { # Desktop system
system = "x86_64-linux"; "strawberry" = lib.nixosSystem {
modules = [ system = "x86_64-linux";
(mkUserConfig ./system/strawberry) modules = [
agenix.nixosModules.default ./system/strawberry/core.nix
./system/strawberry/core.nix ./shared/core
./shared/core ] ++ (userConfig "riley" self.homeConfigurations."strawberry");
./shared/secrets.nix specialArgs = args;
];
specialArgs = args;
};
# Thinkpad
"lime" = lib.nixosSystem {
system = "x86_64-linux";
modules = [
(mkUserConfig ./system/lime)
agenix.nixosModules.default
nixos-hardware.nixosModules.lenovo-thinkpad-x390
nixos-hardware.nixosModules.common-gpu-nvidia-disable
./system/lime/core.nix
./shared/core
./shared/secrets.nix
];
specialArgs = args;
};
}; };
# Thinkpad
"lime" = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./system/lime/core.nix
./shared/core
] ++ (userConfig "riley" self.homeConfigurations."lime");
specialArgs = args;
};
};
# Configurations for non-NixOS machines. # Configurations for non-NixOS machines.
homeConfigurations = with home-manager.lib; { homeConfigurations = with home-manager.lib; let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ self.overlays.default ];
};
in {
# riley @ dev-lt-63
"dev-lt-63" = homeManagerConfiguration { "dev-lt-63" = homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."x86_64-linux"; inherit pkgs;
modules = [ modules = [
./system/dev-lt-63/home.nix ./system/dev-lt-63/home.nix
./shared/home ./shared/home
]; ];
}; };
# riley @ strawberry
"strawberry" = homeManagerConfiguration {
inherit pkgs;
modules = [
./system/strawberry/home.nix
./shared/home
];
};
# riley @ lime
"lime" = homeManagerConfiguration {
inherit pkgs;
modules = [
./system/lime/home.nix
./shared/home
];
};
}; };
overlays = { overlays = {

View file

@ -1,8 +1,10 @@
{ pkgs, ... }: { pkgs, agenix, ... }:
{ {
imports = [ imports = [
agenix.nixosModules.default
../secrets.nix
./services.nix ./services.nix
./backups.nix ./backups.nix
./users.nix ./users.nix

View file

@ -1,6 +1,10 @@
{ lib, modulesPath, ... }: { { lib, modulesPath, nixos-hardware, ... }: {
imports = [./hardware-configuration.nix]; imports = [
./hardware-configuration.nix
nixos-hardware.nixosModules.lenovo-thinkpad-x390
nixos-hardware.nixosModules.common-gpu-nvidia-disable
];
custom = { custom = {
gui.enable = true; gui.enable = true;
@ -15,7 +19,5 @@
system.stateVersion = "22.11"; system.stateVersion = "22.11";
services.xserver.libinput.enable = true; services.xserver.libinput.enable = true;
home-manager.users."riley".home.stateVersion = "22.11";
} }

View file

@ -9,4 +9,5 @@
}; };
}; };
programs.iamb.enable = true; programs.iamb.enable = true;
home.stateVersion = "22.11";
} }