From 8a5e7449bf53b8ad0daf6847d76df7c91385740f Mon Sep 17 00:00:00 2001 From: Seth Flynn Date: Sat, 22 Feb 2025 07:30:27 -0500 Subject: flake/colmena: init --- modules/flake/colmena.nix | 117 ++++++++++++++++++++++++++++++++++++++++++++++ modules/flake/default.nix | 3 ++ 2 files changed, 120 insertions(+) create mode 100644 modules/flake/colmena.nix create mode 100644 modules/flake/default.nix (limited to 'modules') 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 + ''; + }; + + 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 + ''; + }; + + 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; +} -- cgit v1.2.3