From 48838c7006a24fe29716c63b946f1cc4b50e2d95 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 22 Nov 2024 17:31:08 +0100 Subject: [PATCH] Add options for enabling docker-compose services --- lib/modules/programs.nix | 3 +- lib/modules/programs/docker.nix | 42 ++++++++++++++++++++++++ scripts/Arch/Software/docker/main.fish | 2 ++ scripts/Common/Software/docker/main.fish | 14 ++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 lib/modules/programs/docker.nix diff --git a/lib/modules/programs.nix b/lib/modules/programs.nix index 1c3cc67f..cf1a76c1 100644 --- a/lib/modules/programs.nix +++ b/lib/modules/programs.nix @@ -30,7 +30,6 @@ let ["aliae" "aliae"] ["brave" "Brave Browser"] ["discord" "Discord"] - ["docker" "docker"] ["firefox" "Firefox Web Browser"] ["openssh" "OpenSSH"] ["osu!lazer" "osu!lazer"] @@ -51,6 +50,7 @@ let ["logo-ls" "logo-ls"] ["lutris" "Lutris"] ["minegrub-theme" "Minegrub Theme"] + ["nginx" "nginx"] ["nodejs-n" "n"] ["nuke-usb" "nuke-usb"] ["nvidia-dkms" "Nvidia Drivers"] @@ -83,6 +83,7 @@ let ]; in { imports = [ + ./programs/docker.nix ./programs/git.nix ./programs/nextcloud.nix ./programs/oh-my-posh.nix diff --git a/lib/modules/programs/docker.nix b/lib/modules/programs/docker.nix new file mode 100644 index 00000000..59d1e418 --- /dev/null +++ b/lib/modules/programs/docker.nix @@ -0,0 +1,42 @@ +{ lib, ... }: +let + inherit (lib) mkEnableOption mkOption types; + + commonOptions = { + enable = mkEnableOption "docker"; + }; +in { + options = { + valhalla = { + programs.docker = commonOptions; + + users = mkOption { + type = types.attrsOf (types.submodule ( + { ... }: { + options = { + programs.docker = commonOptions; + }; + })); + }; + + linux = { + programs = { + docker = { + services = { + anki-sync.enable = mkEnableOption "Anki Sync server"; + drone.enable = mkEnableOption "drone server"; + forgejo.enable = mkEnableOption "Forgejo server"; + jellyfin.enable = mkEnableOption "Jellyfin media server"; + minecraft.enable = mkEnableOption "Minecraft server"; + nextcloud.enable = mkEnableOption "Nextcloud server"; + teamspeak.enable = mkEnableOption "TeamSpeak server"; + trackmania.enable = mkEnableOption "TrackMania server"; + vaultwarden.enable = mkEnableOption "Vaultwarden server"; + woodpecker.enable = mkEnableOption "Woodpecker CI server"; + }; + }; + }; + }; + }; + }; +} diff --git a/scripts/Arch/Software/docker/main.fish b/scripts/Arch/Software/docker/main.fish index 4cdaee8a..dfdca988 100755 --- a/scripts/Arch/Software/docker/main.fish +++ b/scripts/Arch/Software/docker/main.fish @@ -10,6 +10,8 @@ begin docker-compose \ docker-buildx \ docker-scan + + installSWBase $argv end runInstaller $argv diff --git a/scripts/Common/Software/docker/main.fish b/scripts/Common/Software/docker/main.fish index ed6b4fa6..75d86ecb 100755 --- a/scripts/Common/Software/docker/main.fish +++ b/scripts/Common/Software/docker/main.fish @@ -12,5 +12,19 @@ begin sudo usermod -aG docker "$_flag_user" end + function installSWDependencies -V dir -V args + source "$dir/../../../lib/settings.fish" + set -la argv $args + argparse -i "name=" "user=" -- $argv + set -l services (getProgramConfig --name "$_flag_name" --user "$_flag_user" --json | jq '.services') + + for service in (echo "$services" | jq '. | keys[]' --raw-output0 | string split0) + + if echo "$services" | SERVICE=$service jq --exit-status ".[env.SERVICE].enable" >/dev/null + fish "$dir/services/$service/main.fish" $argv + end + end + end + runInstaller $argv end