Compare commits

...

4 commits

8 changed files with 158 additions and 23 deletions

View file

@ -45,6 +45,7 @@
valhalla = {
DerGeret = import ./profiles/machines/manuel/DerGeret/Arch/config.nix;
ManuSurface = import ./profiles/machines/manuel/ManuSurface/Arch/config.nix;
server = import ./profiles/machines/manuel/server.nix;
};
};
}

View file

@ -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

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

@ -0,0 +1,72 @@
{ lib, config, ... }:
let fs = import ../../../lib/modules/partition/fs.nix;
in {
imports = [ ./defaults.nix ];
config = {
valhalla = {
partition = {
os = {
partitions = {
Boot = {
index = 1;
type = "uefi";
size = "+1G";
format = fs.fat32;
mountPoint = config.valhalla.boot.efiMountPoint;
};
Swap = {
index = 2;
type = "swap";
};
OS = {
index = 3;
label = lib.mkDefault config.valhalla.boot.label;
type = "linux";
format = fs.ext4;
mountPoint = "/";
};
};
};
};
hostname = "nuth.ch";
timeZone = "Europe/Zurich";
keyMap = "de_CH-latin1";
keyboardLayout = "ch";
i18n = {
localeSettings = let defaultLocale = "en_US.UTF-8";
in {
LANG = "de_CH.UTF-8";
LANGUAGE = defaultLocale;
LC_MESSAGE = defaultLocale;
};
};
software = {
essential = true;
server = true;
};
programs.docker.enable = true;
linux.programs = {
docker = {
services = {
drone.enable = true;
forgejo.enable = true;
minecraft.enable = true;
nextcloud.enable = true;
teamspeak.enable = true;
trackmania.enable = true;
vaultwarden.enable = true;
woodpecker.enable = true;
};
};
};
};
};
}

View file

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

View file

@ -14,31 +14,33 @@ function backupAction -V dir
set -l deployScript (getDeploymentScript)
if fish "$dir/../../../lib/modules/partition/confirm.fish" "Do you wish to store the backup on an SSH server?" n
read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER
read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT
read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER
if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ]
set -x VALHALLA_BACKUP_SERVER_PORT 22
if [ -z "$VALHALLA_BACKUP_DIR" ]
if fish "$dir/../../../lib/modules/partition/confirm.fish" "Do you wish to store the backup on an SSH server?" n
read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER
read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT
read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER
if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ]
set -x VALHALLA_BACKUP_SERVER_PORT 22
end
if [ -n "$VALHALLA_BACKUP_USER" ]
set -x VALHALLA_BACKUP_SERVER "$VALHALLA_BACKUP_SERVER_USER@$VALHALLA_BACKUP_SERVER"
end
echo
echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"
echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication."
echo
echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)"
echo "ssh -o PasswordAuthentication=no -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true"
read -P "Press enter once you're done: "
echo
end
if [ -n "$VALHALLA_BACKUP_USER" ]
set -x VALHALLA_BACKUP_SERVER "$VALHALLA_BACKUP_SERVER_USER@$VALHALLA_BACKUP_SERVER"
end
echo
echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"
echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication."
echo
echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)"
echo "ssh -o PasswordAuthentication=no -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true"
read -P "Press enter once you're done: "
echo
read -xP "Please specify the path to the directory to save the backup to: " VALHALLA_BACKUP_DIR
end
read -xP "Please specify the path to the directory to save the backup to: " VALHALLA_BACKUP_DIR
runHook backupSoftware || begin
echo "Backing up software..."

View file

@ -12,5 +12,20 @@ begin
sudo usermod -aG docker "$_flag_user"
end
function installSWDependencies -V dir -V args
source "$dir/../../../lib/settings.fish"
set -la argv $args
echo "args: $argv"
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

View file

@ -173,6 +173,6 @@ begin
end
function getBackupArgs
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose"{,.base}".yml" (getServiceRoot $argv)
printf "%s\n" --base-directory (getServiceRoot $argv) --hidden --no-ignore "^(docker-compose\.secrets\.yml|data)\$"
end
end