nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit 1553eda4d5edddca6e143eb378035ddafe2941ea
parent a6c60efe3be2e017981232a55c0dc163fbb32b6b
Author: mtmn <miro@haravara.org>
Date:   Mon, 13 Apr 2026 14:51:57 +0200

corpus: add secondary instance

Diffstat:
Mflake.nix | 1+
Mhosts/nixaran/configuration.nix | 0
Amodules/services/corpus-pstmn.nix | 5+++++
Mmodules/services/corpus.nix | 77+++--------------------------------------------------------------------------
Amodules/services/mk-corpus.nix | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msecrets.nix | 1+
Asecrets/corpus-pstmn.age | 0
7 files changed, 89 insertions(+), 74 deletions(-)

diff --git a/flake.nix b/flake.nix @@ -174,6 +174,7 @@ "static" "miniflux" "corpus" + "corpus-pstmn" "napkins" "listenbrainz-mpd" "redlib" diff --git a/hosts/nixaran/configuration.nix b/hosts/nixaran/configuration.nix Binary files differ. diff --git a/modules/services/corpus-pstmn.nix b/modules/services/corpus-pstmn.nix @@ -0,0 +1,5 @@ +import ./mk-corpus.nix { + optionName = "corpusPstmn"; + defaultPort = 8322; + defaultSecretFile = ../../secrets/corpus-pstmn.age; +} diff --git a/modules/services/corpus.nix b/modules/services/corpus.nix @@ -1,75 +1,4 @@ -{ - config, - lib, - pkgs, - inputs, - ... -}: let - cfg = config.services.haravara.corpus; -in { - options.services.haravara.corpus = { - enable = lib.mkEnableOption "Scorpus - ListenBrainz frontend"; - - port = lib.mkOption { - type = lib.types.port; - default = 8321; - }; - - domain = lib.mkOption { - type = lib.types.str; - }; - - dataDir = lib.mkOption { - type = lib.types.str; - default = "/var/lib/corpus"; - }; - - databaseFile = lib.mkOption { - type = lib.types.str; - default = "${cfg.dataDir}/corpus.db"; - }; - - secretFile = lib.mkOption { - type = lib.types.path; - default = ../../secrets/corpus.age; - }; - }; - - config = lib.mkIf cfg.enable { - age.secrets.corpus = { - file = cfg.secretFile; - owner = "corpus"; - }; - - systemd.services.corpus = { - description = "Scorpus - ListenBrainz frontend"; - wantedBy = ["multi-user.target"]; - after = ["network.target"]; - - environment = { - PORT = toString cfg.port; - DATABASE_FILE = cfg.databaseFile; - }; - - serviceConfig = { - ExecStart = "${inputs.corpus.packages.${pkgs.stdenv.hostPlatform.system}.default}/bin/scorpus-server"; - EnvironmentFile = config.age.secrets.corpus.path; - Restart = "always"; - User = "corpus"; - Group = "corpus"; - StateDirectory = "corpus"; - WorkingDirectory = cfg.dataDir; - }; - }; - - users.users.corpus = { - isSystemUser = true; - group = "corpus"; - }; - users.groups.corpus = {}; - - services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' - reverse_proxy 127.0.0.1:${toString cfg.port} - ''; - }; +import ./mk-corpus.nix { + optionName = "corpus"; + defaultSecretFile = ../../secrets/corpus.age; } diff --git a/modules/services/mk-corpus.nix b/modules/services/mk-corpus.nix @@ -0,0 +1,79 @@ +{ + optionName, + defaultPort ? 8321, + defaultSecretFile, +}: { + config, + lib, + pkgs, + inputs, + ... +}: let + cfg = config.services.haravara.${optionName}; +in { + options.services.haravara.${optionName} = { + enable = lib.mkEnableOption "Scorpus - ListenBrainz frontend"; + + port = lib.mkOption { + type = lib.types.port; + default = defaultPort; + }; + + domain = lib.mkOption { + type = lib.types.str; + }; + + dataDir = lib.mkOption { + type = lib.types.str; + default = "/var/lib/corpus"; + }; + + databaseFile = lib.mkOption { + type = lib.types.str; + default = "${cfg.dataDir}/corpus.db"; + }; + + secretFile = lib.mkOption { + type = lib.types.path; + default = defaultSecretFile; + }; + }; + + config = lib.mkIf cfg.enable { + age.secrets.${optionName} = { + file = cfg.secretFile; + owner = "corpus"; + }; + + systemd.services.${optionName} = { + description = "Scorpus - ListenBrainz frontend"; + wantedBy = ["multi-user.target"]; + after = ["network.target"]; + + environment = { + PORT = toString cfg.port; + DATABASE_FILE = cfg.databaseFile; + }; + + serviceConfig = { + ExecStart = "${inputs.corpus.packages.${pkgs.stdenv.hostPlatform.system}.default}/bin/scorpus-server"; + EnvironmentFile = config.age.secrets.${optionName}.path; + Restart = "always"; + User = "corpus"; + Group = "corpus"; + StateDirectory = "corpus"; + WorkingDirectory = cfg.dataDir; + }; + }; + + users.users.corpus = { + isSystemUser = true; + group = "corpus"; + }; + users.groups.corpus = {}; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' + reverse_proxy 127.0.0.1:${toString cfg.port} + ''; + }; +} diff --git a/secrets.nix b/secrets.nix @@ -18,4 +18,5 @@ in { "secrets/mpd-host.age".publicKeys = allKeys; "secrets/scorpus.age".publicKeys = allKeys; "secrets/corpus.age".publicKeys = allKeys; + "secrets/corpus-pstmn.age".publicKeys = allKeys; } diff --git a/secrets/corpus-pstmn.age b/secrets/corpus-pstmn.age Binary files differ.