summaryrefslogtreecommitdiff
path: root/modules/flake
diff options
context:
space:
mode:
authorSeth Flynn <[email protected]>2025-02-22 07:30:27 -0500
committerSeth Flynn <[email protected]>2025-02-22 07:30:27 -0500
commit8a5e7449bf53b8ad0daf6847d76df7c91385740f (patch)
tree0c60b1332f4b7efbb06c7c7b42690492d8c85642 /modules/flake
parent24a32770a1515b7e25ec1bb3e44d3c2442c1c6d6 (diff)
flake/colmena: initcolmena
Diffstat (limited to 'modules/flake')
-rw-r--r--modules/flake/colmena.nix117
-rw-r--r--modules/flake/default.nix3
2 files changed, 120 insertions, 0 deletions
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;
+}