diff --git a/flake.nix b/flake.nix index 9fd2926..a55c8e5 100644 --- a/flake.nix +++ b/flake.nix @@ -7,11 +7,16 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + website = { + url = "git+ssh://forgejo@git.ily.rs:4201/lew/website.git"; + flake = false; + }; }; - outputs = { self, nixpkgs, sops-nix, ... }: { + outputs = { self, nixpkgs, sops-nix, website, ... }: { nixosConfigurations.lab = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; + specialArgs = { inherit website; }; modules = [ sops-nix.nixosModules.sops ./hosts/lab diff --git a/hosts/lab/wynne.nix b/hosts/lab/wynne.nix index 4d0c57d..e55454c 100644 --- a/hosts/lab/wynne.nix +++ b/hosts/lab/wynne.nix @@ -1,12 +1,15 @@ -{ pkgs, ... }: +{ pkgs, website, ... }: let port = 4322; dataDir = "/srv/wynne"; + buildDir = "${dataDir}/build"; deployScript = pkgs.writeShellScript "wynne-deploy" '' set -e - cd ${dataDir}/repo - ${pkgs.git}/bin/git pull + rm -rf ${buildDir} + cp -r ${website} ${buildDir} + chmod -R u+w ${buildDir} + cd ${buildDir} ${pkgs.pnpm}/bin/pnpm install --frozen-lockfile ASTRO_DB_REMOTE_URL=file:${dataDir}/data/guestbook.db ${pkgs.pnpm}/bin/pnpm build ''; @@ -27,9 +30,9 @@ in systemd.services.wynne-deploy = { description = "Build wynne.rs from source"; + path = [ pkgs.nodejs ]; serviceConfig = { Type = "oneshot"; - User = "lew"; ExecStart = deployScript; }; }; @@ -46,12 +49,12 @@ in }; serviceConfig = { Type = "simple"; - WorkingDirectory = "${dataDir}/repo"; + WorkingDirectory = buildDir; ExecStart = "${pkgs.nodejs}/bin/node dist/server/entry.mjs"; Restart = "on-failure"; User = "wynne"; Group = "wynne"; - ReadWritePaths = [ "${dataDir}/data" ]; + ReadWritePaths = [ dataDir ]; }; }; diff --git a/justfile b/justfile index d6f50ee..e185ac0 100644 --- a/justfile +++ b/justfile @@ -14,3 +14,8 @@ check: update: git pull sudo nixos-rebuild switch --flake /etc/nixos#lab + +[doc("Pull latest website source, then rebuild and activate")] +update-site: + nix flake update website + sudo nixos-rebuild switch --flake /etc/nixos#lab