From bf0e38f514e954963af9ecb3e6eeb5faf336f0cb Mon Sep 17 00:00:00 2001 From: Peter Lehmann <36541313+peterablehmann@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:54:45 +0100 Subject: [PATCH] Setup colmena --- .envrc | 1 + .gitignore | 1 + flake.lock | 124 +++++++++++++++++++++++++++++++++++++++++++++++++---- flake.nix | 37 ++++++++++++++++ 4 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 .envrc create mode 100644 .gitignore diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/flake.lock b/flake.lock index 763731f..c16b427 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,29 @@ { "nodes": { + "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", + "ref": "main", + "repo": "colmena", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -7,11 +31,11 @@ ] }, "locked": { - "lastModified": 1710332572, - "narHash": "sha256-7JYT5Qya6QuM2szCrdVcNghoz7ar+ClzaqKJ4cfJaKQ=", + "lastModified": 1710427903, + "narHash": "sha256-sV0Q5ndvfjK9JfCg/QM/HX/fcittohvtq8dD62isxdM=", "owner": "nix-community", "repo": "disko", - "rev": "59e50d4ecbac78701c2f9950ff2b886ac66741ce", + "rev": "21d89b333ca300bef82c928c856d48b94a9f997c", "type": "github" }, "original": { @@ -20,13 +44,62 @@ "type": "github" } }, + "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-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" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1710272261, - "narHash": "sha256-g0bDwXFmTE7uGDOs9HcJsfLFhH7fOsASbAuOzDC+fhQ=", + "lastModified": 1710451336, + "narHash": "sha256-pP86Pcfu3BrAvRO7R64x7hs+GaQrjFes+mEPowCfkxY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0ad13a6833440b8e238947e47bea7f11071dc2b2", + "rev": "d691274a972b3165335d261cc4671335f5c67de9", "type": "github" }, "original": { @@ -70,7 +143,9 @@ }, "root": { "inputs": { + "colmena": "colmena", "disko": "disko", + "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" } @@ -81,11 +156,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1710195194, - "narHash": "sha256-KFxCJp0T6TJOz1IOKlpRdpsCr9xsvlVuWY/VCiAFnTE=", + "lastModified": 1710433464, + "narHash": "sha256-IXlPoWgIRovZ32mYvqqdBgOQln71LouE/HBhbKc1wcw=", "owner": "Mic92", "repo": "sops-nix", - "rev": "e52d8117b330f690382f1d16d81ae43daeb4b880", + "rev": "6c32d3b9c7593f4b466ec5404e59fc09a803a090", "type": "github" }, "original": { @@ -93,6 +168,37 @@ "repo": "sops-nix", "type": "github" } + }, + "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, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ab2b9d2..2042dff 100644 --- a/flake.nix +++ b/flake.nix @@ -11,22 +11,57 @@ # SOPS Nix sops-nix.url = "github:Mic92/sops-nix"; + + # Flake-Utils + flake-utils.url = "github:numtide/flake-utils"; + + # Colmena + colmena.url = "github:zhaofengli/colmena/main"; + colmena.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self , nixpkgs + , disko , sops-nix + , flake-utils + , colmena , ... } @ inputs: let inherit (self) outputs; + conf = self.nixosConfigurations; + in + (flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; in { + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + # pkgs is needed here because colmena would otherwise be in the scope two times + pkgs.colmena + sops + jq + ]; + }; + })) // + { + colmena = { + # see for details: + # https://github.com/zhaofengli/colmena/issues/60#issuecomment-1510496861 + meta = { + nixpkgs = import inputs.nixpkgs { system = "x86_64-linux"; }; + nodeSpecialArgs = builtins.mapAttrs (name: value: value._module.specialArgs) conf; + }; + } // builtins.mapAttrs (name: value: { imports = value._module.args.modules; }) conf; + nixosConfigurations = { mns = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; system = "x86_64-linux"; + extraModules = [ inputs.colmena.nixosModules.deploymentOptions ]; modules = [ ./nodes/mns self.nixosModules.common @@ -35,6 +70,7 @@ monitoring = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; system = "x86_64-linux"; + extraModules = [ inputs.colmena.nixosModules.deploymentOptions ]; modules = [ ./nodes/monitoring self.nixosModules.common @@ -43,6 +79,7 @@ sync = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; system = "x86_64-linux"; + extraModules = [ inputs.colmena.nixosModules.deploymentOptions ]; modules = [ ./nodes/sync self.nixosModules.common