From 47cc37283586785522b3bf423ee849e80e52aae4 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 7 Mar 2024 17:49:41 +0100 Subject: [PATCH] delft: allow deployment through colemena Provide an output that translates nixosConfigurations to a colmena- compatible output. Colmena provides a convenient wrapper around building and deploying machines, than the bare nixos-rebuild we had been using up until now. --- delft/flake.lock | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- delft/flake.nix | 22 +++++++++++++- 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/delft/flake.lock b/delft/flake.lock index c328993b..4857ff1c 100644 --- a/delft/flake.lock +++ b/delft/flake.lock @@ -23,6 +23,29 @@ "type": "github" } }, + "colmena": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "stable": "stable" + }, + "locked": { + "lastModified": 1706509311, + "narHash": "sha256-QQKQ6r3CID8aXn2ZXZ79ZJxdCOeVP+JTnOctDALErOw=", + "owner": "zhaofengli", + "repo": "colmena", + "rev": "c84ccd0a7a712475e861c2b111574472b1a8d0cd", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "colmena", + "type": "github" + } + }, "cpiotools": { "inputs": { "nixpkgs": "nixpkgs_3" @@ -84,6 +107,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1673956053, @@ -100,6 +139,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": "systems_2" }, @@ -195,7 +249,7 @@ }, "nix": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "lowdown-src": "lowdown-src", "nixpkgs": [ "hydra", @@ -371,7 +425,7 @@ }, "rfc39": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ] @@ -393,6 +447,7 @@ "root": { "inputs": { "agenix": "agenix", + "colmena": "colmena", "disko": "disko", "hydra": "hydra", "hydra-scale-equinix-metal": "hydra-scale-equinix-metal", @@ -406,6 +461,22 @@ "rfc39": "rfc39" } }, + "stable": { + "locked": { + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/delft/flake.nix b/delft/flake.nix index f27cbb85..f2b377e5 100644 --- a/delft/flake.nix +++ b/delft/flake.nix @@ -4,6 +4,9 @@ inputs.agenix.url = "github:ryantm/agenix"; inputs.agenix.inputs.nixpkgs.follows = "nixpkgs"; + inputs.colmena.url = "github:zhaofengli/colmena"; + inputs.colmena.inputs.nixpkgs.follows = "nixpkgs"; + inputs.disko.url = "github:nix-community/disko"; inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; @@ -20,7 +23,7 @@ inputs.rfc39.url = "github:NixOS/rfc39"; inputs.rfc39.inputs.nixpkgs.follows = "nixpkgs"; - outputs = flakes @ { self, agenix, disko, hydra, hydra-scale-equinix-metal, nix, nixpkgs, nixos-channel-scripts, nix-netboot-serve, rfc39 }: + outputs = flakes @ { self, agenix, colmena, disko, hydra, hydra-scale-equinix-metal, nix, nixpkgs, nixos-channel-scripts, nix-netboot-serve, rfc39 }: let inherit (nixpkgs) lib; @@ -67,12 +70,29 @@ ]; }; + colmena = { + meta = { + description = "NixOS.org infrastructure"; + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + }; + }; + } // builtins.mapAttrs + (name: value: { + nixpkgs.system = value.config.nixpkgs.system; + imports = value._module.args.modules; + deployment = { + targetHost = "${name}.nixos.org"; + }; + }) (self.nixosConfigurations); + # TODO: flake-utils.lib.eachDefaultSystem devShell.x86_64-linux = let pkgs = import nixpkgs { system = "x86_64-linux"; }; in pkgs.mkShell { buildInputs = with pkgs; [ agenix.packages.x86_64-linux.agenix + colmena.packages.x86_64-linux.colmena ]; }; };