Add options for enabling docker-compose services

This commit is contained in:
Manuel Thalmann 2024-11-22 17:31:08 +01:00
parent db0b8637ab
commit bc914ff88e
4 changed files with 60 additions and 1 deletions

View file

@ -30,7 +30,6 @@ let
["aliae" "aliae"] ["aliae" "aliae"]
["brave" "Brave Browser"] ["brave" "Brave Browser"]
["discord" "Discord"] ["discord" "Discord"]
["docker" "docker"]
["firefox" "Firefox Web Browser"] ["firefox" "Firefox Web Browser"]
["openssh" "OpenSSH"] ["openssh" "OpenSSH"]
["osu!lazer" "osu!lazer"] ["osu!lazer" "osu!lazer"]
@ -51,6 +50,7 @@ let
["logo-ls" "logo-ls"] ["logo-ls" "logo-ls"]
["lutris" "Lutris"] ["lutris" "Lutris"]
["minegrub-theme" "Minegrub Theme"] ["minegrub-theme" "Minegrub Theme"]
["nginx" "nginx"]
["nodejs-n" "n"] ["nodejs-n" "n"]
["nuke-usb" "nuke-usb"] ["nuke-usb" "nuke-usb"]
["nvidia-dkms" "Nvidia Drivers"] ["nvidia-dkms" "Nvidia Drivers"]
@ -83,6 +83,7 @@ let
]; ];
in { in {
imports = [ imports = [
./programs/docker.nix
./programs/git.nix ./programs/git.nix
./programs/nextcloud.nix ./programs/nextcloud.nix
./programs/oh-my-posh.nix ./programs/oh-my-posh.nix

View file

@ -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";
};
};
};
};
};
};
}

View file

@ -10,6 +10,8 @@ begin
docker-compose \ docker-compose \
docker-buildx \ docker-buildx \
docker-scan docker-scan
installSWBase $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -12,5 +12,19 @@ begin
sudo usermod -aG docker "$_flag_user" sudo usermod -aG docker "$_flag_user"
end 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 runInstaller $argv
end end