From 336973e5b546e958049b46b30215e15ff5b2570c Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 3 Mar 2023 07:06:30 -0700 Subject: [PATCH] ci: switch to a system service --- configs/ci.nix | 4 +++- gui/default.nix | 2 +- hosts/europa/default.nix | 2 +- lib/default.nix | 12 +++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configs/ci.nix b/configs/ci.nix index e752ca7..e172624 100644 --- a/configs/ci.nix +++ b/configs/ci.nix @@ -3,12 +3,14 @@ let jobs = [ { name = "xin-ci-update"; + user = "qbit"; script = "cd ~/src/xin && ./bin/ci update"; startAt = "23:00"; path = [ ]; } { name = "xin-ci"; + user = "qbit"; script = "cd ~/src/xin && ./bin/ci"; startAt = "*:30:00"; path = [ ]; @@ -63,7 +65,7 @@ in with lib; { settings.allowed-users = [ "root" config.xinCI.user "nix-serve" ]; }; - systemd.user.services = + systemd.services = lib.listToAttrs (builtins.map xinlib.jobToService jobs); services = { diff --git a/gui/default.nix b/gui/default.nix index d2e3942..9f57722 100644 --- a/gui/default.nix +++ b/gui/default.nix @@ -79,7 +79,7 @@ in with lib; { ]; systemd.user.services = - (lib.listToAttrs (builtins.map xinlib.jobToService jobs)) + (lib.listToAttrs (builtins.map xinlib.jobToUserService jobs)) // promnesiaService; environment.systemPackages = with pkgs; [ diff --git a/hosts/europa/default.nix b/hosts/europa/default.nix index a8ac850..bffaa8b 100644 --- a/hosts/europa/default.nix +++ b/hosts/europa/default.nix @@ -210,7 +210,7 @@ in { '']; systemd.user.services = - lib.listToAttrs (builtins.map xinlib.jobToService jobs); + lib.listToAttrs (builtins.map xinlib.jobToUserService jobs); systemd.services."whytailscalewhy" = { description = "Tailscale restart on resume"; wantedBy = [ "post-resume.target" ]; diff --git a/lib/default.nix b/lib/default.nix index 2782d7e..9ea348f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,6 +5,16 @@ let # autogenreated ${name} ${src} ''; + jobToUserService = job: { + name = "${job.name}"; + value = { + serviceConfig = { + User = "${job.user}"; + }; + script = mkCronScript "${job.name}_script" job.script; + inherit (job) startAt path; + }; + }; jobToService = job: { name = "${job.name}"; value = { @@ -41,6 +51,6 @@ let system.autoUpgrade.enable = state != "DIRTY"; }; - xinlib = { inherit buildVer mkCronScript jobToService buildShell; }; + xinlib = { inherit buildVer mkCronScript jobToUserService jobToService buildShell; }; in xinlib