Generate hosts for hydra
This commit is contained in:
		
					parent
					
						
							
								10de1e428a
							
						
					
				
			
			
				commit
				
					
						c1a2aa1d63
					
				
			
		
					 5 changed files with 61 additions and 18 deletions
				
			
		
							
								
								
									
										8
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -38,16 +38,16 @@
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "nixpkgs": {
 | 
					    "nixpkgs": {
 | 
				
			||||||
      "locked": {
 | 
					      "locked": {
 | 
				
			||||||
        "lastModified": 1689679375,
 | 
					        "lastModified": 1690538549,
 | 
				
			||||||
        "narHash": "sha256-LHUC52WvyVDi9PwyL1QCpaxYWBqp4ir4iL6zgOkmcb8=",
 | 
					        "narHash": "sha256-FfScFHxidupVGPw9BrQOHz/SoFLRjoNmVC5ymS+g8xU=",
 | 
				
			||||||
        "owner": "NixOS",
 | 
					        "owner": "NixOS",
 | 
				
			||||||
        "repo": "nixpkgs",
 | 
					        "repo": "nixpkgs",
 | 
				
			||||||
        "rev": "684c17c429c42515bafb3ad775d2a710947f3d67",
 | 
					        "rev": "de5ca86149b0c4ff8bf69782cd25896fff0254e1",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "original": {
 | 
					      "original": {
 | 
				
			||||||
        "owner": "NixOS",
 | 
					        "owner": "NixOS",
 | 
				
			||||||
        "ref": "nixos-unstable",
 | 
					        "ref": "nixos-unstable-small",
 | 
				
			||||||
        "repo": "nixpkgs",
 | 
					        "repo": "nixpkgs",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										44
									
								
								flake.nix
									
										
									
									
									
								
							
							
						
						
									
										44
									
								
								flake.nix
									
										
									
									
									
								
							| 
						 | 
					@ -1,13 +1,15 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  inputs = {
 | 
					  inputs = {
 | 
				
			||||||
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
 | 
					    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
 | 
				
			||||||
    nixos-generators = {
 | 
					    nixos-generators = {
 | 
				
			||||||
      url = "github:nix-community/nixos-generators";
 | 
					      url = "github:nix-community/nixos-generators";
 | 
				
			||||||
      inputs.nixpkgs.follows = "nixpkgs";
 | 
					      inputs.nixpkgs.follows = "nixpkgs";
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  outputs = { self, nixpkgs, nixos-generators, ... }: {
 | 
					  outputs = { self, nixpkgs, nixos-generators, ... }@inputs: let
 | 
				
			||||||
 | 
					    helper = (import ./helper.nix) inputs; 
 | 
				
			||||||
 | 
					  in {
 | 
				
			||||||
    hosts = {
 | 
					    hosts = {
 | 
				
			||||||
      hydra = {
 | 
					      hydra = {
 | 
				
			||||||
        site = "vs";
 | 
					        site = "vs";
 | 
				
			||||||
| 
						 | 
					@ -32,7 +34,7 @@
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    generateColmenaHost = name: host : {
 | 
					    generateColmenaHost = name: host: {
 | 
				
			||||||
      deployment = {
 | 
					      deployment = {
 | 
				
			||||||
        targetHost = "${name}.${host.site}.grzb.de";
 | 
					        targetHost = "${name}.${host.site}.grzb.de";
 | 
				
			||||||
        targetUser = "colmena-deploy";
 | 
					        targetUser = "colmena-deploy";
 | 
				
			||||||
| 
						 | 
					@ -43,7 +45,7 @@
 | 
				
			||||||
        ./configuration/proxmox-vm
 | 
					        ./configuration/proxmox-vm
 | 
				
			||||||
        ./configuration/proxmox-vm/hardware-configuration.nix
 | 
					        ./configuration/proxmox-vm/hardware-configuration.nix
 | 
				
			||||||
        ./hosts/${name}
 | 
					        ./hosts/${name}
 | 
				
			||||||
      ];
 | 
					      ] ++ nixpkgs.lib.optional (builtins.pathExists ./hosts/${name}/secrets.nix) ./hosts/${name}/secrets.nix;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    colmena = {
 | 
					    colmena = {
 | 
				
			||||||
| 
						 | 
					@ -54,18 +56,35 @@
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    } // builtins.mapAttrs (self.generateColmenaHost) self.hosts;
 | 
					    } // builtins.mapAttrs (self.generateColmenaHost) self.hosts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hydraJobs = {
 | 
					    nixosConfigurations = nixpkgs.lib.mapAttrs (name: config: let
 | 
				
			||||||
      nixConfigurations.nitter = let system = "x86_64-linux";
 | 
					      nodeNixpkgs = self.outputs.colmena.meta.nodeNixpkgs.${name} or self.outputs.colmena.meta.nixpkgs;
 | 
				
			||||||
      in nixpkgs.lib.nixosSystem {
 | 
					      nodeNixos = import (nodeNixpkgs.path + "/nixos/lib/eval-config.nix");
 | 
				
			||||||
        inherit system;
 | 
					      in nodeNixos {
 | 
				
			||||||
        modules = [
 | 
					        modules = [
 | 
				
			||||||
          ./configuration/common
 | 
					          #self.outputs.colmena.defaults
 | 
				
			||||||
          ./configuration/proxmox-vm
 | 
					          config
 | 
				
			||||||
          ./hosts/nitter
 | 
					          #inputs.colmena.nixosModules.deploymentOptions
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            _module.args.name = nixpkgs.lib.mkForce name;
 | 
				
			||||||
 | 
					            _module.args.nodes = self.outputs.nixosConfigurations;
 | 
				
			||||||
 | 
					            #nixpkgs.overlays = nixpkgs.lib.attrValues self.overlays;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
      };
 | 
					        inherit (nodeNixpkgs) system;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ) (builtins.removeAttrs self.outputs.colmena ["meta" "defaults"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    hydraJobs = {
 | 
				
			||||||
 | 
					      nixosConfigurations = nixpkgs.lib.mapAttrs (_: config: config.config.system.build.toplevel) self.outputs.nixosConfigurations;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					    nixosConfigurations = (builtins.mapAttrs (helper.mapToNixosConfigurations) self.hosts);
 | 
				
			||||||
 | 
					    hydraJobs = {
 | 
				
			||||||
 | 
					      nixConfigurations = helper.buildHosts self.nixosConfigurations;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Generate a base VM image for Proxmox with `nix build .#base-proxmox`
 | 
					    # Generate a base VM image for Proxmox with `nix build .#base-proxmox`
 | 
				
			||||||
    packages.x86_64-linux = {
 | 
					    packages.x86_64-linux = {
 | 
				
			||||||
      base-proxmox = nixos-generators.nixosGenerate {
 | 
					      base-proxmox = nixos-generators.nixosGenerate {
 | 
				
			||||||
| 
						 | 
					@ -78,5 +97,6 @@
 | 
				
			||||||
        format = "proxmox";
 | 
					        format = "proxmox";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										25
									
								
								helper.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								helper.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					{ nixpkgs, ... }@inputs:
 | 
				
			||||||
 | 
					rec {
 | 
				
			||||||
 | 
					  generateNixosSystem = name: {
 | 
				
			||||||
 | 
					    system ? "x86_64-linux",
 | 
				
			||||||
 | 
					    group ? null,
 | 
				
			||||||
 | 
					    modules ? [],
 | 
				
			||||||
 | 
					    site
 | 
				
			||||||
 | 
					  }: let
 | 
				
			||||||
 | 
					    localNixpkgs = nixpkgs.lib.attrByPath [ "nixpkgs-${name}" ] nixpkgs inputs;
 | 
				
			||||||
 | 
					  in localNixpkgs.lib.nixosSystem {
 | 
				
			||||||
 | 
					    system = system;
 | 
				
			||||||
 | 
					    modules = modules ++ [
 | 
				
			||||||
 | 
					      ./configuration/common
 | 
				
			||||||
 | 
					      ./configuration/proxmox-vm
 | 
				
			||||||
 | 
					      ./configuration/proxmox-vm/hardware-configuration.nix
 | 
				
			||||||
 | 
					      ./hosts/${name}
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mapToNixosConfigurations = name: host: generateNixosSystem name host;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  filterUnderscore = hosts: (nixpkgs.lib.filterAttrs (name: host: (builtins.substring 0 1 name) != "_") hosts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buildHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) (filterUnderscore hosts);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  imports = [
 | 
					  imports = [
 | 
				
			||||||
    ./configuration.nix
 | 
					    ./configuration.nix
 | 
				
			||||||
    ./secrets.nix
 | 
					 | 
				
			||||||
    ./hydra.nix
 | 
					    ./hydra.nix
 | 
				
			||||||
    ./nix-serve.nix
 | 
					    ./nix-serve.nix
 | 
				
			||||||
    ./nginx.nix
 | 
					    ./nginx.nix
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  imports = [
 | 
					  imports = [
 | 
				
			||||||
    ./configuration.nix
 | 
					    ./configuration.nix
 | 
				
			||||||
    ./secrets.nix
 | 
					 | 
				
			||||||
    ./coturn.nix
 | 
					    ./coturn.nix
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue