diff options
| -rw-r--r-- | flake.lock | 40 | ||||
| -rw-r--r-- | flake.nix | 17 | ||||
| -rw-r--r-- | modules/flake/colmena.nix | 117 | ||||
| -rw-r--r-- | modules/flake/default.nix | 3 |
4 files changed, 177 insertions, 0 deletions
@@ -57,6 +57,30 @@ "url": "https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/archive/codeberg-10.tar.gz" } }, + "colmena": { + "inputs": { + "flake-compat": [], + "flake-utils": "flake-utils", + "nix-github-actions": [], + "nixpkgs": [ + "nixpkgs" + ], + "stable": [] + }, + "locked": { + "lastModified": 1739900653, + "narHash": "sha256-hPSLvw6AZQYrZyGI6Uq4XgST7benF/0zcCpugn/P0yM=", + "owner": "zhaofengli", + "repo": "colmena", + "rev": "2370d4336eda2a9ef29fce10fa7076ae011983ab", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "colmena", + "type": "github" + } + }, "comin": { "inputs": { "nixpkgs": [ @@ -175,6 +199,21 @@ "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" + } + }, "getchpkgs": { "inputs": { "nixpkgs": [ @@ -468,6 +507,7 @@ "agenix": "agenix", "catppuccin": "catppuccin", "codeberg-infra": "codeberg-infra", + "colmena": "colmena", "comin": "comin", "determinate": "determinate", "flake-parts": "flake-parts", @@ -9,6 +9,10 @@ outputs = inputs: + let + flakeModules = import ./modules/flake; + in + inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" @@ -18,6 +22,7 @@ ]; imports = [ + flakeModules.colmena inputs.getchpkgs.flakeModules.checks inputs.getchpkgs.flakeModules.configurations @@ -28,6 +33,8 @@ ./systems ./users ]; + + flake = { inherit flakeModules; }; }; inputs = { @@ -71,6 +78,16 @@ flake = false; }; + colmena = { + url = "github:zhaofengli/colmena"; + inputs = { + nixpkgs.follows = "nixpkgs"; + stable.follows = ""; + nix-github-actions.follows = ""; + flake-compat.follows = ""; + }; + }; + comin = { url = "github:nlewo/comin"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/modules/flake/colmena.nix b/modules/flake/colmena.nix new file mode 100644 index 0000000..8c3627d --- /dev/null +++ b/modules/flake/colmena.nix @@ -0,0 +1,117 @@ +{ + config, + lib, + inputs, + self, + ... +}: + +let + namespace = "colmena"; + + nodes = lib.filterAttrs ( + name: _: + !(lib.elem name [ + "meta" + "defaults" + ]) + ) config.${namespace}; + hasNodes = lib.length (lib.attrNames nodes) > 0; + + metaSubmodule = { + options = { + allowApplyAll = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to allow deployments without a node filter set."; + }; + + description = lib.mkOption { + type = lib.types.str; + description = "A short description for the configuration."; + example = lib.literalExpression "A Colmena Hive"; + }; + + machinesFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "Use the machines listed in this file when building this hive configuration."; + }; + + name = lib.mkOption { + type = lib.types.str; + default = "hive"; + description = "The name of the configuration."; + }; + + nixpkgs = lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.raw; + default = inputs.nixpkgs.legacyPackages.x86_64-linux; + defaultText = lib.literalExpression "inputs.nixpkgs.legacyPackages.x86_64-linux"; + description = "The pinned Nixpkgs package set."; + example = lib.literalExpression '' + import inputs.nixpkgs { system = "x86_64-linux"; } + ''; + }; + + nodeNixpkgs = lib.mkOption { + type = lib.types.attrsOf (lib.types.lazyAttrsOf lib.types.raw); + default = { }; + description = "Node-specific Nixpkgs pins."; + }; + + nodeSpecialArgs = lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.raw; + default = { }; + description = "Node-specific special args."; + }; + + specialArgs = lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.raw; + default = { }; + description = "A set of special arguments to be passed to NixOS modules."; + }; + }; + }; + + colmenaSubmodule = { + freeformType = lib.types.lazyAttrsOf lib.types.deferredModule; + + options = { + meta = lib.mkOption { + type = lib.types.submodule metaSubmodule; + default = { }; + description = '' + Options for the `meta` attribute set. + + See <link xlink:href="https://colmena.cli.rs/unstable/reference/meta.html"/> + ''; + }; + + defaults = lib.mkOption { + type = lib.types.deferredModule; + default = { }; + description = "Module imported by all nodes."; + }; + }; + }; +in + +{ + options.${namespace} = lib.mkOption { + type = lib.types.submodule colmenaSubmodule; + default = { }; + description = '' + Options for `colmena`. + + See <link xlink:href="https://colmena.cli.rs/unstable/"/> + ''; + }; + + config = lib.mkIf hasNodes { + flake = { + inherit (config) colmena; + colmenaHive = inputs.colmena.lib.makeHive self.colmena; + }; + }; +} diff --git a/modules/flake/default.nix b/modules/flake/default.nix new file mode 100644 index 0000000..5837b64 --- /dev/null +++ b/modules/flake/default.nix @@ -0,0 +1,3 @@ +{ + colmena = ./colmena.nix; +} |
