refactor(docker): share more vars between compose.nix files
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-02-15 12:16:15 -05:00
parent 1c8b80283e
commit f481168458
18 changed files with 115 additions and 70 deletions

View file

@ -1,28 +1,33 @@
{...}: let {...}: let
configPath = "/var/lib/docker-data"; globalEnv = {
configPath = "/var/lib/docker-data";
mainUID = "1000";
mainGID = "1000";
TZ = "America/New_York";
};
in { in {
imports = [ imports = [
(import ./forgejo/compose.nix configPath) (import ./forgejo/compose.nix globalEnv)
(import ./freshrss/compose.nix configPath) (import ./freshrss/compose.nix globalEnv)
(import ./gameyfin/compose.nix configPath) (import ./gameyfin/compose.nix globalEnv)
(import ./hauk/compose.nix configPath) (import ./hauk/compose.nix globalEnv)
(import ./immich/compose.nix configPath) (import ./immich/compose.nix globalEnv)
(import ./music/jbots/compose.nix configPath) (import ./music/jbots/compose.nix globalEnv)
(import ./nextcloud/compose.nix configPath) (import ./nextcloud/compose.nix globalEnv)
(import ./resume/compose.nix configPath) (import ./resume/compose.nix globalEnv)
(import ./vaultwarden/compose.nix configPath) (import ./vaultwarden/compose.nix globalEnv)
(import ./wg-easy/compose.nix configPath) (import ./wg-easy/compose.nix globalEnv)
(import ./media/bazarr/compose.nix configPath) (import ./media/bazarr/compose.nix globalEnv)
(import ./media/joal/compose.nix configPath) (import ./media/joal/compose.nix globalEnv)
(import ./media/jellystat/compose.nix configPath) (import ./media/jellystat/compose.nix globalEnv)
(import ./media/prowlarr/compose.nix configPath) (import ./media/prowlarr/compose.nix globalEnv)
(import ./media/radarr/compose.nix configPath) (import ./media/radarr/compose.nix globalEnv)
(import ./media/seerr/compose.nix configPath) (import ./media/seerr/compose.nix globalEnv)
(import ./media/sonarr/compose.nix configPath) (import ./media/sonarr/compose.nix globalEnv)
]; ];
services.borgbackup.configs.docker = { services.borgbackup.configs.docker = {
paths = [configPath]; paths = [globalEnv.configPath];
}; };
} }

View file

@ -1,11 +1,16 @@
rwDataDir: { {
configPath,
mainUID,
mainGID,
...
}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (config.sops) secrets; inherit (config.sops) secrets;
rwPath = rwDataDir + "/forgejo"; rwPath = configPath + "/forgejo";
in { in {
virtualisation.docker.compose."forgejo" = { virtualisation.docker.compose."forgejo" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -29,9 +34,8 @@ in {
environment = { environment = {
APP_NAME = "Gitea"; APP_NAME = "Gitea";
# TODO: change ids USER_UID = mainUID;
USER_UID = "1000"; USER_GID = mainGID;
USER_GID = "1000";
ROOT_URL = "https://git.nelim.org"; ROOT_URL = "https://git.nelim.org";
SSH_DOMAIN = "git.nelim.org"; SSH_DOMAIN = "git.nelim.org";

View file

@ -1,11 +1,11 @@
rwDataDir: { {configPath, ...}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (config.sops) secrets; inherit (config.sops) secrets;
rwPath = rwDataDir + "/freshrss"; rwPath = configPath + "/freshrss";
in { in {
virtualisation.docker.compose."freshrss" = { virtualisation.docker.compose."freshrss" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,4 +1,8 @@
rwDataDir: { {
mainUID,
mainGID,
...
}: {
config, config,
pkgs, pkgs,
... ...
@ -11,7 +15,7 @@ in {
services."gameyfin" = { services."gameyfin" = {
image = pkgs.callPackage ./images/gameyfin.nix pkgs; image = pkgs.callPackage ./images/gameyfin.nix pkgs;
restart = "always"; restart = "always";
user = "1000:1000"; user = "${mainUID}:${mainGID}";
env_file = [secrets.gameyfin.path]; env_file = [secrets.gameyfin.path];
environment.GAMEYFIN_USER = "mathis"; environment.GAMEYFIN_USER = "mathis";

View file

@ -1,4 +1,4 @@
rwDataDir: {pkgs, ...}: { {...}: {pkgs, ...}: {
virtualisation.docker.compose."hauk" = { virtualisation.docker.compose."hauk" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,4 +1,4 @@
rwDataDir: { {configPath, ...}: {
config, config,
lib, lib,
pkgs, pkgs,
@ -8,7 +8,7 @@ rwDataDir: {
inherit (config.sops) secrets; inherit (config.sops) secrets;
rwPath = rwDataDir + "/immich"; rwPath = configPath + "/immich";
envFile = "${./env}"; envFile = "${./env}";
UPLOAD_LOCATION = "${rwPath}/data"; UPLOAD_LOCATION = "${rwPath}/data";

View file

@ -1,5 +1,11 @@
rwDataDir: {pkgs, ...}: let {
rwPath = rwDataDir + "/media/bazarr"; configPath,
mainUID,
mainGID,
TZ,
...
}: {pkgs, ...}: let
rwPath = configPath + "/media/bazarr";
in { in {
virtualisation.docker.compose."bazarr" = { virtualisation.docker.compose."bazarr" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -9,9 +15,9 @@ in {
restart = "always"; restart = "always";
environment = { environment = {
PUID = "1000"; PUID = mainUID;
PGID = "1000"; PGID = mainGID;
TZ = "America/New_York"; inherit TZ;
}; };
ports = [ ports = [

View file

@ -1,11 +1,15 @@
rwDataDir: { {
configPath,
TZ,
...
}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (config.sops) secrets; inherit (config.sops) secrets;
rwPath = rwDataDir + "/jellystat"; rwPath = configPath + "/jellystat";
in { in {
virtualisation.docker.compose."jellystat" = { virtualisation.docker.compose."jellystat" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -21,7 +25,7 @@ in {
POSTGRES_IP = "jellystat-db"; POSTGRES_IP = "jellystat-db";
POSTGRES_PORT = 5432; POSTGRES_PORT = 5432;
TZ = "America/New_York"; inherit TZ;
}; };
ports = ["3070:3000"]; ports = ["3070:3000"];

View file

@ -1,5 +1,5 @@
rwDataDir: {pkgs, ...}: let {configPath, ...}: {pkgs, ...}: let
rwPath = rwDataDir + "/media/joal"; rwPath = configPath + "/media/joal";
in { in {
virtualisation.docker.compose."joal" = { virtualisation.docker.compose."joal" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,5 +1,11 @@
rwDataDir: {pkgs, ...}: let {
rwPath = rwDataDir + "/media/prowlarr"; configPath,
mainUID,
mainGID,
TZ,
...
}: {pkgs, ...}: let
rwPath = configPath + "/media/prowlarr";
in { in {
virtualisation.docker.compose."prowlarr" = { virtualisation.docker.compose."prowlarr" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -10,9 +16,9 @@ in {
restart = "always"; restart = "always";
environment = { environment = {
PUID = "1000"; PUID = mainUID;
PGID = "1000"; PGID = mainGID;
TZ = "America/New_York"; inherit TZ;
}; };
volumes = ["${rwPath}/data:/config"]; volumes = ["${rwPath}/data:/config"];
@ -29,7 +35,7 @@ in {
LOG_LEVEL = "info"; LOG_LEVEL = "info";
LOG_HTML = "false"; LOG_HTML = "false";
CAPTCHA_SOLVER = "none"; CAPTCHA_SOLVER = "none";
TZ = "America/New_York"; inherit TZ;
# https://github.com/FlareSolverr/FlareSolverr/pull/1300#issuecomment-2379596654 # https://github.com/FlareSolverr/FlareSolverr/pull/1300#issuecomment-2379596654
DRIVER = "nodriver"; DRIVER = "nodriver";

View file

@ -1,5 +1,11 @@
rwDataDir: {pkgs, ...}: let {
rwPath = rwDataDir + "/media/radarr"; configPath,
mainUID,
mainGID,
TZ,
...
}: {pkgs, ...}: let
rwPath = configPath + "/media/radarr";
in { in {
virtualisation.docker.compose."radarr" = { virtualisation.docker.compose."radarr" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -11,9 +17,9 @@ in {
ports = ["7878:7878"]; ports = ["7878:7878"];
environment = { environment = {
PUID = "1000"; PUID = mainUID;
PGID = "1000"; PGID = mainGID;
TZ = "America/New_York"; inherit TZ;
}; };
volumes = [ volumes = [

View file

@ -1,5 +1,9 @@
rwDataDir: {pkgs, ...}: let {
rwPath = rwDataDir + "/media/seerr"; configPath,
TZ,
...
}: {pkgs, ...}: let
rwPath = configPath + "/media/seerr";
in { in {
virtualisation.docker.compose."seerr" = { virtualisation.docker.compose."seerr" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -10,7 +14,7 @@ in {
environment = { environment = {
LOG_LEVEL = "debug"; LOG_LEVEL = "debug";
TZ = "America/New_York"; inherit TZ;
}; };
volumes = [ volumes = [

View file

@ -1,5 +1,11 @@
rwDataDir: {pkgs, ...}: let {
rwPath = rwDataDir + "/media/sonarr"; configPath,
mainUID,
mainGID,
TZ,
...
}: {pkgs, ...}: let
rwPath = configPath + "/media/sonarr";
in { in {
virtualisation.docker.compose."sonarr" = { virtualisation.docker.compose."sonarr" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};
@ -11,9 +17,9 @@ in {
ports = ["8989:8989"]; ports = ["8989:8989"];
environment = { environment = {
PUID = "1000"; PUID = mainUID;
PGID = "1000"; PGID = mainGID;
TZ = "America/New_York"; inherit TZ;
}; };
volumes = [ volumes = [

View file

@ -1,11 +1,11 @@
rwDataDir: { {configPath, ...}: {
pkgs, pkgs,
self, self,
... ...
}: let }: let
inherit (self.packages.${pkgs.system}) jmusicbot; inherit (self.packages.${pkgs.system}) jmusicbot;
rwPath = rwDataDir + "/music/jbots"; rwPath = configPath + "/music/jbots";
image = pkgs.callPackage ./images/jmusicbot.nix {inherit pkgs jmusicbot;}; image = pkgs.callPackage ./images/jmusicbot.nix {inherit pkgs jmusicbot;};
in { in {
virtualisation.docker.compose."jbots" = { virtualisation.docker.compose."jbots" = {

View file

@ -1,4 +1,4 @@
rwDataDir: { {configPath, ...}: {
config, config,
pkgs, pkgs,
... ...
@ -6,7 +6,7 @@ rwDataDir: {
inherit (config.sops) secrets; inherit (config.sops) secrets;
mainContainerName = "app-server"; mainContainerName = "app-server";
rwPath = rwDataDir + "/nextcloud"; rwPath = configPath + "/nextcloud";
in { in {
virtualisation.docker.compose."nextcloud" = { virtualisation.docker.compose."nextcloud" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,11 +1,11 @@
rwDataDir: { {configPath, ...}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (config.sops) secrets; inherit (config.sops) secrets;
rwPath = rwDataDir + "/resume"; rwPath = configPath + "/resume";
in { in {
virtualisation.docker.compose."resume" = { virtualisation.docker.compose."resume" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,5 +1,5 @@
rwDataDir: {pkgs, ...}: let {configPath, ...}: {pkgs, ...}: let
rwPath = rwDataDir + "/vaultwarden"; rwPath = configPath + "/vaultwarden";
in { in {
virtualisation.docker.compose."vaultwarden" = { virtualisation.docker.compose."vaultwarden" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};

View file

@ -1,5 +1,5 @@
rwDataDir: {pkgs, ...}: let {configPath, ...}: {pkgs, ...}: let
rwPath = rwDataDir + "/wg-easy"; rwPath = configPath + "/wg-easy";
in { in {
virtualisation.docker.compose."wg-easy" = { virtualisation.docker.compose."wg-easy" = {
networks.proxy_net = {external = true;}; networks.proxy_net = {external = true;};