nix-infra/flake.nix

103 lines
2.8 KiB
Nix
Raw Normal View History

2024-11-20 05:46:39 +01:00
{
inputs = {
2024-11-20 05:46:39 +01:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
2024-11-20 05:46:39 +01:00
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-11-20 05:46:39 +01:00
};
2024-11-20 05:46:39 +01:00
outputs = { self, nixpkgs, nixos-generators, ... }@inputs: let
helper = (import ./helper.nix) inputs;
in {
hosts = {
2024-11-20 05:46:39 +01:00
hydra = {
site = "vs";
2024-11-20 05:46:39 +01:00
};
2024-11-20 05:46:39 +01:00
iperf = {
site = "vs";
};
2024-11-20 05:46:39 +01:00
jackett = {
site = "vs";
};
2024-11-20 05:46:39 +01:00
nitter = {
site = "vs";
2024-11-20 05:46:39 +01:00
};
2024-11-20 05:46:39 +01:00
nixos-coturn = {
site = "vs";
};
tor-relay = {
site = "vs";
};
2024-11-20 05:46:39 +01:00
web-public-2 = {
site = "vs";
};
};
2024-11-20 05:46:39 +01:00
2024-11-20 05:46:39 +01:00
generateColmenaHost = name: host: {
deployment = {
targetHost = "${name}.${host.site}.grzb.de";
targetUser = "colmena-deploy";
2024-11-20 05:46:39 +01:00
};
2024-11-20 05:46:39 +01:00
imports = [
./configuration/common
./configuration/proxmox-vm
2024-11-20 05:46:39 +01:00
./configuration/proxmox-vm/hardware-configuration.nix
./hosts/${name}
2024-11-20 05:46:39 +01:00
] ++ nixpkgs.lib.optional (builtins.pathExists ./hosts/${name}/secrets.nix) ./hosts/${name}/secrets.nix;
};
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
2024-11-20 05:46:39 +01:00
};
};
} // builtins.mapAttrs (self.generateColmenaHost) self.hosts;
2024-11-20 05:46:39 +01:00
nixosConfigurations = nixpkgs.lib.mapAttrs (name: config: let
nodeNixpkgs = self.outputs.colmena.meta.nodeNixpkgs.${name} or self.outputs.colmena.meta.nixpkgs;
nodeNixos = import (nodeNixpkgs.path + "/nixos/lib/eval-config.nix");
in nodeNixos {
modules = [
2024-11-20 05:46:39 +01:00
#self.outputs.colmena.defaults
config
#inputs.colmena.nixosModules.deploymentOptions
{
_module.args.name = nixpkgs.lib.mkForce name;
_module.args.nodes = self.outputs.nixosConfigurations;
#nixpkgs.overlays = nixpkgs.lib.attrValues self.overlays;
}
];
2024-11-20 05:46:39 +01:00
inherit (nodeNixpkgs) system;
}
) (builtins.removeAttrs self.outputs.colmena ["meta" "defaults"]);
hydraJobs = {
nixosConfigurations = nixpkgs.lib.mapAttrs (_: config: config.config.system.build.toplevel) self.outputs.nixosConfigurations;
};
2024-11-20 05:46:39 +01:00
2024-11-20 05:46:39 +01:00
/*
nixosConfigurations = (builtins.mapAttrs (helper.mapToNixosConfigurations) self.hosts);
hydraJobs = {
nixConfigurations = helper.buildHosts self.nixosConfigurations;
};
*/
2024-11-20 05:46:39 +01:00
# Generate a base VM image for Proxmox with `nix build .#base-proxmox`
packages.x86_64-linux = {
base-proxmox = nixos-generators.nixosGenerate {
system = "x86_64-linux";
modules = [
./configuration/common
./configuration/nixos-generators
./configuration/proxmox-vm
];
format = "proxmox";
};
};
2024-11-20 05:46:39 +01:00
2024-11-20 05:46:39 +01:00
};
}