Skip to content

Instantly share code, notes, and snippets.

@orzklv
Created September 28, 2025 18:32
Show Gist options
  • Save orzklv/0f7a31486a7cde4948fbc8e59ada19f4 to your computer and use it in GitHub Desktop.
Save orzklv/0f7a31486a7cde4948fbc8e59ada19f4 to your computer and use it in GitHub Desktop.
Generate nix module config out of list
{
lib,
config,
inputs,
...
}: let
cfg = config.kolyma.www;
bnest = mod: lib.strings.splitString "." mod;
nest = keys: value:
if keys == []
then value
else {${builtins.head keys} = nest (builtins.tail keys) value;};
# Generate an app configuration
generate = app: {...}: let
nested =
"services.${app.option}"
|> bnest
|> nest;
in {
imports = [
inputs.${app.inputs}.nixosModules.${app.module}
];
config = {
${nested} = {
enable = true;
proxy = {
enable = true;
inherit (app) domain;
};
};
};
};
# Each app is following this
# {
# inputs = "example";
# module = "default";
# option = "some.example";
# domain = "example.com";
# secrets = {};
# }
convert = map generate cfg.apps;
in {
imports = lib.mkIf cfg.enable convert;
options.kolyma.www.apps = lib.kotype.apps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment