summaryrefslogtreecommitdiff
path: root/module.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-01-26 05:43:47 -0500
committerseth <[email protected]>2024-01-26 05:43:47 -0500
commit90c83b4694150bdcfe4fcac1c55fcfdef17c3612 (patch)
tree74f3a8d9cac0b972fc7e50fdcf2403f60e39795e /module.nix
initial commit
Diffstat (limited to 'module.nix')
-rw-r--r--module.nix72
1 files changed, 72 insertions, 0 deletions
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";
+ };
+ }
+ '';
+ };
+ });
+ };
+}