From 90c83b4694150bdcfe4fcac1c55fcfdef17c3612 Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 26 Jan 2024 05:43:47 -0500 Subject: initial commit --- module.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 module.nix (limited to 'module.nix') diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..cf243f9 --- /dev/null +++ b/module.nix @@ -0,0 +1,72 @@ +self: { + lib, + flake-parts-lib, + ... +}: let + inherit + (flake-parts-lib) + mkPerSystemOption + ; + + inherit + (lib) + literalExpression + mdDoc + mkOption + types + ; + + procfileSubmodule = { + config, + name, + system, + ... + }: { + options = { + processes = mkOption { + type = types.attrsOf types.str; + default = {}; + description = mdDoc "Attribute set mapping the names of processes to their command"; + example = literalExpression '' + { + redis = lib.getExe' pkgs.redis "redis-server"; + } + ''; + }; + + package = mkOption { + type = types.package; + description = mdDoc "Final package containing runner for Procfile"; + readOnly = true; + }; + }; + + config = { + package = self.lib.${system}.mkProcfileRunner { + inherit name; + procGroup = config.processes; + }; + }; + }; +in { + options = { + perSystem = mkPerSystemOption ({system, ...}: { + options.procfiles = mkOption { + type = types.attrsOf (types.submoduleWith { + modules = [procfileSubmodule]; + specialArgs = {inherit system;}; + }); + + default = {}; + description = mdDoc "Attribute set containing procfile declarations"; + example = literalExpression '' + { + daemons.processes = { + redis = lib.getExe' pkgs.redis "redis-server"; + }; + } + ''; + }; + }); + }; +} -- cgit v1.2.3