This commit is contained in:
parent
4ed9ba0d24
commit
a90630ecb6
98 changed files with 2063 additions and 729 deletions
171
nixos/flake.nix
171
nixos/flake.nix
|
|
@ -1,107 +1,106 @@
|
|||
{
|
||||
description = "Unified flake for Proxmox base image + live NixOS VMs";
|
||||
description = "NixOS HomeLab";
|
||||
|
||||
inputs = {
|
||||
# Nixpkgs repo for system packages
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
# nixos-generators lets us produce a "proxmox"-formatted image
|
||||
nixos-generators = {
|
||||
url = "github:nix-community/nixos-generators";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
# sops-nix secret management
|
||||
sops-nix = {
|
||||
url = "github:Mic92/sops-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixarr.url = "github:rasmus-kirk/nixarr";
|
||||
# simple-nixos-mailserver = {
|
||||
# url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
|
||||
# inputs.nixpkgs.follwos = "nixpkgs";
|
||||
# };
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixos-generators, sops-nix,... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
outputs = inputs @ {...}: let
|
||||
system = "x86_64-linux";
|
||||
|
||||
################################################################################
|
||||
# A) Define “live” NixOS VM configurations under nixosConfigurations
|
||||
################################################################################
|
||||
liveVMs = {
|
||||
traefik = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/traefik/host.nix ];
|
||||
};
|
||||
|
||||
sandbox = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/sandbox/host.nix ];
|
||||
};
|
||||
|
||||
dns = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/dns/host.nix ];
|
||||
};
|
||||
|
||||
monitoring = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/monitoring/host.nix sops-nix.nixosModules.sops ];
|
||||
};
|
||||
|
||||
forgejo = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/forgejo/host.nix sops-nix.nixosModules.sops ];
|
||||
};
|
||||
|
||||
runner01 = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./hosts/forgejo-runner/host.nix sops-nix.nixosModules.sops ];
|
||||
specialArgs.runnerId = "01";
|
||||
};
|
||||
|
||||
# dockerHost = pkgs.lib.nixosSystem {
|
||||
# inherit system;
|
||||
# modules = [
|
||||
# ./configuration.nix
|
||||
# ./users/plasmagoat.nix
|
||||
# ./hosts/docker-host.nix # Docker‐Host VM settings (shown below)
|
||||
# ];
|
||||
# };
|
||||
liveVMs = {
|
||||
traefik = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/traefik/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
################################################################################
|
||||
# B) Use nixos-generators to produce “template” images for Proxmox
|
||||
################################################################################
|
||||
|
||||
# 1) Existing Proxmox “base” image generator
|
||||
proxmoxTemplate = nixos-generators.nixosGenerate {
|
||||
system = "x86_64-linux";
|
||||
modules = [ ./base.nix ];
|
||||
format = "proxmox"; # outputs a .vma.zst suitable for qmrestore
|
||||
sandbox = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/sandbox/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
# 2) A “docker” generator which builds a Proxmox‐ready template
|
||||
docker = nixos-generators.nixosGenerate {
|
||||
system = "x86_64-linux";
|
||||
modules = [ ./templates/docker.nix ];
|
||||
format = "proxmox";
|
||||
mail = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/mail/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
################################################################################
|
||||
# 1) Export “live” VM configs so you can run:
|
||||
# nixos-rebuild switch --flake .#traefik --target-host root@<traefik-IP>
|
||||
# nixos-rebuild switch --flake .#sandbox --target-host root@<sandbox-IP>
|
||||
# nixos-rebuild switch --flake .#dockerHost --target-host root@<dockerHost-IP>
|
||||
################################################################################
|
||||
nixosConfigurations = liveVMs;
|
||||
keycloak = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/keycloak/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
################################################################################
|
||||
# 2) Export Proxmox template images under packages.x86_64-linux:
|
||||
#
|
||||
# • proxmox → `nix build .#proxmox` (generic base)
|
||||
# • docker → `nix build .#docker` (docker template)
|
||||
################################################################################
|
||||
packages.x86_64-linux = {
|
||||
proxmoxTemplate = proxmoxTemplate;
|
||||
docker = docker;
|
||||
dns = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/dns/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
monitoring = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/monitoring/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
media = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/media/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
inputs.nixarr.nixosModules.default
|
||||
];
|
||||
};
|
||||
|
||||
forgejo = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/forgejo/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
|
||||
runner01 = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/forgejo-runner/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
specialArgs.runnerId = "01";
|
||||
};
|
||||
|
||||
builder = inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
./hosts/nixos-builder/host.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = liveVMs;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue