Move clicks.codes to systemd
previously we were using pm2 to manage clicks.codes. This was bad for several
reasons, but one of the largest was that it was challenging to auto-restart on
server start. By instead using systemd, we get this for free, as well as
integrating our logging with the rest of our services, etc.!
In a followup commit, we may add a script to automatically pull from git and
restart if necessary, unless we decide that this should be done through CI such
as Jenkins
Change-Id: Icb5f86cd1b5cc6c48d5f700fd7f6be6b448fe8f4
Reviewed-on: https://git.clicks.codes/c/Clicks/NixFiles/+/184
Reviewed-by: Samuel Shuert <coded@clicks.codes>
Tested-by: Skyler Grey <minion@clicks.codes>
diff --git a/modules/common/users.nix b/modules/common/users.nix
index b15feae..e869e76 100644
--- a/modules/common/users.nix
+++ b/modules/common/users.nix
@@ -37,13 +37,6 @@
group = "clicks";
shell = pkgs.bashInteractive;
};
- users.users.websites = {
- isSystemUser = true;
- createHome = true;
- home = "/services/websites";
- group = "clicks";
- shell = pkgs.bashInteractive;
- };
users.users.backups = {
isSystemUser = true;
createHome = true;
diff --git a/services/websites/default.nix b/services/websites/default.nix
new file mode 100644
index 0000000..5985b84
--- /dev/null
+++ b/services/websites/default.nix
@@ -0,0 +1,10 @@
+{ pkgs, config, lib, ... }: {
+ systemd.user.services."clicks.codes" = {
+ Unit.Description = "Run clicks.codes";
+ Install.WantedBy = [ "default.target" ];
+
+ Service.ExecStart = "${pkgs.nix}/bin/nix develop --command pnpm start";
+ Service.WorkingDirectory = "${config.home.homeDirectory}/clicks.codes";
+ Service.Environment = "PATH=${pkgs.git}/bin";
+ };
+}