From 50e5e78968f8ef4d91558d6486dc0c31051a2b8d Mon Sep 17 00:00:00 2001 From: June <june@jsts.xyz> Date: Sun, 19 Jan 2025 19:05:15 +0100 Subject: [PATCH] yate: clean up and nicely format nix configuration --- config/hosts/yate/configuration.nix | 4 +- config/hosts/yate/default.nix | 3 +- config/hosts/yate/service.nix | 48 ---------------------- config/hosts/yate/yate.nix | 64 ++++++++++++++++++++++++----- 4 files changed, 55 insertions(+), 64 deletions(-) delete mode 100644 config/hosts/yate/service.nix diff --git a/config/hosts/yate/configuration.nix b/config/hosts/yate/configuration.nix index f350966..6b1fa99 100644 --- a/config/hosts/yate/configuration.nix +++ b/config/hosts/yate/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ ... }: { networking = { @@ -6,7 +6,5 @@ domain = "z9.ccchh.net"; }; -# users.users.chaos.password = "yes"; - system.stateVersion = "23.11"; } diff --git a/config/hosts/yate/default.nix b/config/hosts/yate/default.nix index 009e1a1..66738e8 100644 --- a/config/hosts/yate/default.nix +++ b/config/hosts/yate/default.nix @@ -1,11 +1,10 @@ -{ config, pkgs, ... }: +{ ... }: { imports = [ ./configuration.nix ./networking.nix ./yate.nix - ./service.nix ./sops.nix ]; } diff --git a/config/hosts/yate/service.nix b/config/hosts/yate/service.nix deleted file mode 100644 index 9013060..0000000 --- a/config/hosts/yate/service.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ config, pkgs, ... }: - -{ -# systemd.managerEnvironment = { -# SYSTEMD_LOG_LEVEL = "debug"; -# }; - - - - sops.secrets."git_clone_key" = { - mode = "0600"; - owner = "yate"; - group = "yate-config"; - restartUnits = [ "yate.service" ]; -}; - - systemd.services.yate = { - enable = true; - description = "Yate telehony engine"; - unitConfig = { - After= "network-online.target"; - }; - serviceConfig = { - ExecStart = "${pkgs.yate}/bin/yate -c /etc/yate -e /etc/yate/share"; - Type="simple"; - Restart="always"; - User="yate"; - Group="yate-config"; - StateDirectory = "yate"; - StateDirectoryMode = "0775"; - # ... - }; - wantedBy = [ "default.target" ]; - requires = [ "network-online.target" ]; - preStart = "echo \"\n\" >> /run/secrets/git_clone_key - sleep 5 - SSH_SUCCESS=1 - ${pkgs.openssh}/bin/ssh -q -i /run/secrets/git_clone_key forgejo@git.hamburg.ccc.de 2> /var/lib/yate/SSH_CHECK_LOG || SSH_SUCCESS=0 - if [ $SSH_SUCCESS = 1 ]; then - rm -rf /var/lib/yate/* - rm -rf /var/lib/yate/.* - env GIT_SSH_COMMAND=\"${pkgs.openssh}/bin/ssh -i /run/secrets/git_clone_key\" ${pkgs.git}/bin/git clone forgejo@git.hamburg.ccc.de:CCCHH/yate-config.git /var/lib/yate - ${pkgs.git}/bin/git -C /var/lib/yate config --add safe.directory \"/var/lib/yate\" - fi"; - - # ... - }; -} diff --git a/config/hosts/yate/yate.nix b/config/hosts/yate/yate.nix index 3f9b054..d3ed2f9 100644 --- a/config/hosts/yate/yate.nix +++ b/config/hosts/yate/yate.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: { environment.systemPackages = [ @@ -11,18 +11,60 @@ # Just disable it for now. networking.firewall.enable = false; - users.users.yate = { - description = "yate service user"; - group = "yate-config"; - isNormalUser = true; + users = { + users.yate = { + description = "yate service user"; + group = "yate-config"; + isNormalUser = true; + }; + + groups.yate-config = { + members = [ "colmema-deploy" "chaos" "root" "yate"]; + }; }; + environment.etc.yate = { + user = "yate"; + group = "yate-config"; + mode = "symlink"; + source = "/var/lib/yate"; + }; - users.groups.yate-config = {}; - users.groups.yate-config.members = [ "colmema-deploy" "chaos" "root" "yate"]; + sops.secrets."git_clone_key" = { + mode = "0600"; + owner = "yate"; + group = "yate-config"; + restartUnits = [ "yate.service" ]; + }; - environment.etc.yate.user = "yate"; - environment.etc.yate.group = "yate-config"; - environment.etc.yate.mode = "symlink"; - environment.etc.yate.source = "/var/lib/yate"; + systemd.services.yate = { + enable = true; + description = "Yate telehony engine"; + unitConfig = { + After= "network-online.target"; + }; + serviceConfig = { + ExecStart = "${pkgs.yate}/bin/yate -c /etc/yate -e /etc/yate/share"; + Type="simple"; + Restart="always"; + User="yate"; + Group="yate-config"; + StateDirectory = "yate"; + StateDirectoryMode = "0775"; + }; + wantedBy = [ "default.target" ]; + requires = [ "network-online.target" ]; + preStart = '' + echo \"\n\" >> /run/secrets/git_clone_key + sleep 5 + SSH_SUCCESS=1 + ${pkgs.openssh}/bin/ssh -q -i /run/secrets/git_clone_key forgejo@git.hamburg.ccc.de 2> /var/lib/yate/SSH_CHECK_LOG || SSH_SUCCESS=0 + if [ $SSH_SUCCESS = 1 ]; then + rm -rf /var/lib/yate/* + rm -rf /var/lib/yate/.* + env GIT_SSH_COMMAND=\"${pkgs.openssh}/bin/ssh -i /run/secrets/git_clone_key\" ${pkgs.git}/bin/git clone forgejo@git.hamburg.ccc.de:CCCHH/yate-config.git /var/lib/yate + ${pkgs.git}/bin/git -C /var/lib/yate config --add safe.directory \"/var/lib/yate\" + fi + ''; + }; }