Created
September 10, 2023 13:53
-
-
Save infinisil/e29ee58a8184eeb7a2e139c2b2d3e4ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, lib, config, ... }: with lib.types; | |
let | |
postgresqlInstanceType = submodule { | |
options.connectionString = lib.mkOption { | |
type = str; | |
}; | |
}; | |
in { | |
options.services = lib.mkOption { | |
type = attrsOf (submodule { | |
options.process = lib.mkOption { | |
type = str; | |
}; | |
options.args = lib.mkOption { | |
type = listOf str; | |
}; | |
}); | |
}; | |
options.postgresqlInstances = lib.mkOption { | |
type = attrsOf postgresqlInstanceType; | |
}; | |
options.postgresql = lib.mkOption { | |
type = postgresqlInstanceType; | |
}; | |
config.services = lib.mapAttrs' (name: cfg: | |
lib.nameValuePair "postgresql-${name}" { | |
process = "postgresql"; | |
args = [ cfg.connectionString ]; | |
} | |
}) config.postgresql; | |
# mkAliasSomething would also be nice here | |
config.postgresqlInstances.default = config.postgresql; | |
# ^ Module | |
# v User | |
#config.postgresql.instances.foo.connectionString = "bla"; | |
config.postgresqlInstances.bar.connectionString = "baz"; | |
config.postgresql.connectionString = "bla"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
must have been a GitHub bug: it was showing no indentation whatsoever but it looks good now 👍