nixos/hosts/default.nix

81 lines
2.2 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
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-05-20 19:25:57 +02:00
specialArgs = {inherit inputs hostname username 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
inputs.dankMaterialShell.nixosModules.dankMaterialShell
2025-04-27 23:58:02 +02:00
inputs.niri.nixosModules.niri
../modules/base
../modules/programs
2025-12-12 04:02:55 +01:00
../modules/desktop
2025-02-18 20:17:57 +01:00
(mkSystemImports hostname)
2025-08-21 10:31:50 +02:00
{nixpkgs.config.allowUnfree = true;}
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-20 22:50:06 +01:00
bootstrap = mkSystem {
hostname = "bootstrap";
username = "nixos";
};
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
};
desktop = mkSystem {
hostname = "desktop";
2025-02-18 20:17:57 +01:00
username = "nickolaj";
2025-02-03 07:55:17 +01:00
};
2025-02-20 14:09:12 +01:00
work = mkSystem {
hostname = "work";
username = "nickolaj";
};
2025-03-09 20:30:33 +01:00
homelab = mkSystem {
hostname = "homelab";
username = "nickolaj";
};
2025-02-03 07:55:17 +01:00
};
}