Add a shared `homelab.host` module that provides host metadata for multiple consumers: - tier: deployment tier (test/prod) for future homelab-deploy service - priority: alerting priority (high/low) for Prometheus label filtering - role: primary role of the host (dns, database, monitoring, etc.) - labels: free-form labels for additional metadata Host configurations updated with appropriate values: - ns1, ns2: role=dns with dns_role labels - nix-cache01: priority=low, role=build-host - vault01: role=vault - jump: role=bastion - template, template2, testvm01, vaulttest01: tier=test, priority=low The module is now imported via commonModules in flake.nix, making it available to all hosts including minimal configurations like template2. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
233 lines
6.0 KiB
Nix
233 lines
6.0 KiB
Nix
{
|
|
description = "Homelab v5 Nixos Server Configurations";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11";
|
|
nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
};
|
|
alerttonotify = {
|
|
url = "git+https://git.t-juice.club/torjus/alerttonotify?ref=master";
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
};
|
|
labmon = {
|
|
url = "git+https://git.t-juice.club/torjus/labmon?ref=master";
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
};
|
|
nixos-exporter = {
|
|
url = "git+https://git.t-juice.club/torjus/nixos-exporter";
|
|
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
nixpkgs-unstable,
|
|
sops-nix,
|
|
alerttonotify,
|
|
labmon,
|
|
nixos-exporter,
|
|
...
|
|
}@inputs:
|
|
let
|
|
system = "x86_64-linux";
|
|
overlay-unstable = final: prev: {
|
|
unstable = import nixpkgs-unstable {
|
|
inherit system;
|
|
config.allowUnfree = true;
|
|
};
|
|
};
|
|
commonOverlays = [
|
|
overlay-unstable
|
|
alerttonotify.overlays.default
|
|
labmon.overlays.default
|
|
];
|
|
# Common modules applied to all hosts
|
|
commonModules = [
|
|
(
|
|
{ config, pkgs, ... }:
|
|
{
|
|
nixpkgs.overlays = commonOverlays;
|
|
system.configurationRevision = self.rev or self.dirtyRev or "dirty";
|
|
}
|
|
)
|
|
sops-nix.nixosModules.sops
|
|
nixos-exporter.nixosModules.default
|
|
./modules/homelab
|
|
];
|
|
allSystems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
forAllSystems =
|
|
f: nixpkgs.lib.genAttrs allSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
|
|
in
|
|
{
|
|
nixosConfigurations = {
|
|
ns1 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/ns1
|
|
];
|
|
};
|
|
ns2 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/ns2
|
|
];
|
|
};
|
|
ha1 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/ha1
|
|
];
|
|
};
|
|
template1 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/template
|
|
];
|
|
};
|
|
template2 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/template2
|
|
];
|
|
};
|
|
http-proxy = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/http-proxy
|
|
];
|
|
};
|
|
ca = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/ca
|
|
];
|
|
};
|
|
monitoring01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/monitoring01
|
|
labmon.nixosModules.labmon
|
|
];
|
|
};
|
|
jelly01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/jelly01
|
|
];
|
|
};
|
|
nix-cache01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/nix-cache01
|
|
];
|
|
};
|
|
pgdb1 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/pgdb1
|
|
];
|
|
};
|
|
nats1 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/nats1
|
|
];
|
|
};
|
|
testvm01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/testvm01
|
|
];
|
|
};
|
|
vault01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/vault01
|
|
];
|
|
};
|
|
vaulttest01 = nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = {
|
|
inherit inputs self sops-nix;
|
|
};
|
|
modules = commonModules ++ [
|
|
./hosts/vaulttest01
|
|
];
|
|
};
|
|
};
|
|
packages = forAllSystems (
|
|
{ pkgs }:
|
|
{
|
|
create-host = pkgs.callPackage ./scripts/create-host { };
|
|
vault-fetch = pkgs.callPackage ./scripts/vault-fetch { };
|
|
}
|
|
);
|
|
devShells = forAllSystems (
|
|
{ pkgs }:
|
|
{
|
|
default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
ansible
|
|
opentofu
|
|
openbao
|
|
(pkgs.callPackage ./scripts/create-host { })
|
|
];
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|