nixos/parts/hosts/default.nix

80 lines
2.1 KiB
Nix
Raw Normal View History

2025-02-03 07:55:17 +01:00
{
inputs,
withSystem,
lib,
...
}:
with lib; let
2025-02-18 20:17:57 +01:00
mkSystemImports = hostname: let
hostDirectory = ./. + ("/" + hostname);
nixFiles = filter (file: hasSuffix ".nix" file) (attrNames (builtins.readDir hostDirectory));
imports = map (file: ./. + ("/" + hostname + "/" + file)) nixFiles;
in {
inherit imports;
};
2025-02-03 07:55:17 +01:00
mkSystem = {
hostname,
username,
modules ? [],
2025-02-18 20:17:57 +01:00
system ? "x86_64-linux",
2025-02-03 07:55:17 +01:00
}:
2025-02-18 20:17:57 +01:00
withSystem system (
{system, ...}: let
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
pkgsUnstable = import inputs.nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
in
2025-02-03 07:55:17 +01:00
inputs.nixpkgs.lib.nixosSystem {
inherit system;
2025-02-18 20:17:57 +01:00
specialArgs = {inherit inputs hostname username pkgs pkgsUnstable;};
2025-02-03 07:55:17 +01:00
modules =
[
inputs.disko.nixosModules.disko
2025-02-18 20:17:57 +01:00
inputs.nixos-generators.nixosModules.all-formats
2025-02-03 07:55:17 +01:00
inputs.home-manager.nixosModules.home-manager
inputs.agenix.nixosModules.default
inputs.agenix-rekey.nixosModules.default
2025-02-20 00:02:02 +01:00
inputs.nix-index-database.nixosModules.nix-index
2025-02-18 20:17:57 +01:00
inputs.nixos-facter-modules.nixosModules.facter
../modules/base/user.nix
(mkSystemImports hostname)
2025-02-03 07:55:17 +01:00
]
2025-02-18 20:17:57 +01:00
++ modules
++ (
lib.optional (builtins.pathExists ./${hostname}/facter.json)
{config.facter.reportPath = ./${hostname}/facter.json;}
);
2025-02-03 07:55:17 +01:00
}
);
in {
2025-02-18 20:17:57 +01:00
config.flake.nixosConfigurations = {
2025-02-03 07:55:17 +01:00
laptop = mkSystem {
hostname = "laptop";
2025-02-18 20:17:57 +01:00
username = "nickolaj";
2025-02-03 07:55:17 +01:00
modules = [
2025-02-18 20:17:57 +01:00
../modules/required.nix
../modules/shell.nix
../modules/graphical.nix
../modules/devenv.nix
2025-02-03 07:55:17 +01:00
];
};
desktop = mkSystem {
hostname = "desktop";
2025-02-18 20:17:57 +01:00
username = "nickolaj";
2025-02-03 07:55:17 +01:00
modules = [
2025-02-18 20:17:57 +01:00
../modules/required.nix
../modules/shell.nix
../modules/graphical.nix
../modules/devenv.nix
2025-02-03 07:55:17 +01:00
];
};
};
}