Explorar o código

feat(odin): add systemd service for automated home-manager setup

Add a user systemd service that clones the home configuration repository and switches to the flake profile on boot, ensuring the home environment is set up automatically for the thomas user on the odin host.
Zander Hawke hai 7 meses
pai
achega
9097ce9eed
Modificáronse 1 ficheiros con 29 adicións e 1 borrados
  1. 29 1
      hosts/odin/users/thomas.nix

+ 29 - 1
hosts/odin/users/thomas.nix

@@ -1,4 +1,4 @@
-{ config, ... }:
+{ config, lib, pkgs, ... }:
 {
   users.users.thomas = {
     isNormalUser = true;
@@ -13,4 +13,32 @@
       "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC5o7LT5wPYWgI8Mvr6RKOv+BcsbQgU7PCw2hheVu17alwF1uFUsAYV5BVQu+uv9uEm/UDsCNhfM6TwI0A1prdmtBz4pKiwXbj7fcdp6DcVOgTsPfawbXEpivtJvlhEatyTsR26MjHKnqpT0BxPvj6Ug6pvRkCYW5d2bWXiY9murmAX6Q5kSyNunkB8PdRTH+S47f7eOdCJY63VBOkkiG8M7XyPwFCDTYiHhbMZcejIdY9mB6kYnMQVRHDznQWiQxrcaE1fD/TY3db9GDcOVoo2aDBOZX7WT2+me67sU8dEK9+nSyhWDzBbEs8knu87ZlKPFwhl4slenRniKhbf22OpicXArtEcjEj0GyDJH5e+ZCIQ4eSQanA7TxnKFlDuaf+Qqx55UT+ya4vJJeik7nkzbRHaE9IoWhhiOaOnaN6kHIxuxB6z7EL3Gk7f78+I/qBaj5df6fgnXM3JBXKa5bRH2wqoSetJAo6EGpEgmU2huB1ktiGlO7BlF5XwSw6cb/KT7NSIXhncgLkCzsDVXxecVQv1FnPISBcp3+ti01ADVf2trgpPDbNTWV40Rgiefie0o2fc6KWAFfum1j5N3WWU+XVVmRjDmKKHiEJBLNKDAe0rQf+tryPW4c5GIN7aFoB+8dYFAuUyLd7Fu3vhZdmcckN5ryHunEc0dKPIiuoVZw=="
     ];
   };
+
+  systemd.user.services.setup-home-manager =
+    let
+      git = lib.getExe' pkgs.git "git";
+      nix = lib.getExe' pkgs.nix "nix";
+    in
+    {
+      description = "Setup home-manager configuration on boot";
+      after = [ "network-online.target" ];
+      wants = [ "network-online.target" ];
+      wantedBy = [ "default.target" ];
+
+      serviceConfig = {
+        Type = "oneshot";
+        RemainAfterExit = true;
+      };
+
+      script = ''
+        if [ "$USER" = "thomas" ] && [ ! -d "$HOME/workspace/control/home" ]; then
+          echo "Setting up home environment..."
+          mkdir -p "$HOME/workspace/control"
+          cd "$HOME/workspace/control"
+          ${git} clone [email protected]:control/home
+          cd home
+          ${nix} run github:nix-community/home-manager -- switch --flake .#thomas@odin
+        fi
+      '';
+    };
 }