Compare commits

...
Sign in to create a new pull request.

19 commits

Author SHA1 Message Date
bd24e3a5f7 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:53:18 +07:00
78cc1b95bb surrender
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:51:24 +07:00
0790da4e32 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:40:52 +07:00
3a007a9b1d 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:39:59 +07:00
c38811e3a0 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:29:19 +07:00
36613e377a m2
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:21:37 +07:00
6b623a0734 m1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:19:15 +07:00
dc28c16a32 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:13:57 +07:00
3a9e6eed7f 1
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:08:36 +07:00
2106be1b57 m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 08:05:33 +07:00
e8c14e7447 m
All checks were successful
ci/woodpecker/push/job Pipeline was successful
2026-04-19 08:00:53 +07:00
bd15dc3433 m
All checks were successful
ci/woodpecker/push/job Pipeline was successful
2026-04-19 07:56:54 +07:00
4a210f0762 m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 07:08:59 +07:00
db90cac05a m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 07:05:14 +07:00
03e967124a m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 06:58:54 +07:00
cc5c91a9b6 m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 06:49:47 +07:00
7df70294d3 m
Some checks failed
ci/woodpecker/push/job Pipeline failed
2026-04-19 06:34:39 +07:00
2a8804ca02 m 2026-04-19 06:23:17 +07:00
d7ff9947e5 m 2026-04-19 06:22:23 +07:00
6 changed files with 128 additions and 9 deletions

View file

@ -1,9 +1,18 @@
when: when:
- event: push - event: push
- branch: master
steps: steps:
deploy: - name: smoke
commands: image: bash
- sh ~/nixconf/update.sh commands:
- nh os switch -H sortug ~/nixconf --target-host root@sortug - pwd
- whoami
- hostname
- printf '%s %s %s\n' "$(date --iso-8601=seconds)" "$(hostname)" "$(git rev-parse --short HEAD)" >> /var/tmp/woodpecker-smoke.log
- tail -n 5 /var/tmp/woodpecker-smoke.log
- name: deploy
image: bash
commands:
- '[ "${CI_COMMIT_BRANCH:-}" = "master" ] || { echo "skipping deploy on branch ${CI_COMMIT_BRANCH:-unknown}"; exit 0; }'
- bash ./scripts/deploy-app.sh

26
.woodpecker/wtf Normal file
View file

@ -0,0 +1,26 @@
steps:
checks:
image: nixos/nix:latest
commands:
- nix develop --accept-flake-config -c bun install --frozen-lockfile
- nix develop --accept-flake-config -c bun run lint
- nix develop --accept-flake-config -c bun run typecheck
- nix develop --accept-flake-config -c bun run build
- nix develop --accept-flake-config -c bun run update:bun-nix
- git diff --exit-code bun.nix
- nix build --accept-flake-config .#default
when:
- event: [pull_request, push]
---
steps:
deploy:
image: nixos/nix:latest
commands:
- sudo -n /usr/local/libexec/deploy-sortug
when:
- event: push
- branch: master

26
.woodpecker/wtfisthis Normal file
View file

@ -0,0 +1,26 @@
steps:
checks:
image: nixos/nix:latest
commands:
- nix develop --accept-flake-config -c bun install --frozen-lockfile
- nix develop --accept-flake-config -c bun run lint
- nix develop --accept-flake-config -c bun run typecheck
- nix develop --accept-flake-config -c bun run build
- nix develop --accept-flake-config -c bun run update:bun-nix
- git diff --exit-code bun.nix
- nix build --accept-flake-config .#default
when:
- event: [pull_request, push]
---
steps:
deploy:
image: nixos/nix:latest
commands:
- sudo -n /usr/local/libexec/deploy-sortug
when:
- event: push
- branch: master

11
lol.lmao Normal file
View file

@ -0,0 +1,11 @@
1
2
3
4
5
6
7
8
9
10
11

View file

@ -2,6 +2,14 @@
let let
cfg = config.services.kotsukotsu; cfg = config.services.kotsukotsu;
launcher = pkgs.writeShellScript "kotsukotsu-launch" ''
exec ${cfg.currentPath}/bin/kotsukotsu
'';
ensureCurrent = pkgs.writeShellScript "kotsukotsu-ensure-current" ''
if [ ! -e ${cfg.currentPath} ]; then
ln -sfn ${cfg.package} ${cfg.currentPath}
fi
'';
in in
{ {
options.services.kotsukotsu = { options.services.kotsukotsu = {
@ -38,6 +46,12 @@ in
description = "Directory for the persistent SQLite database."; description = "Directory for the persistent SQLite database.";
}; };
currentPath = lib.mkOption {
type = lib.types.str;
default = "/var/lib/kotsukotsu/current";
description = "Stable symlink path that points at the active app package.";
};
user = lib.mkOption { user = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "kotsukotsu"; default = "kotsukotsu";
@ -71,6 +85,10 @@ in
assertion = lib.hasPrefix "/" cfg.dataDir; assertion = lib.hasPrefix "/" cfg.dataDir;
message = "services.kotsukotsu.dataDir must be an absolute path."; message = "services.kotsukotsu.dataDir must be an absolute path.";
} }
{
assertion = lib.hasPrefix "/" cfg.currentPath;
message = "services.kotsukotsu.currentPath must be an absolute path.";
}
]; ];
users.groups = lib.mkIf (cfg.group == "kotsukotsu") { users.groups = lib.mkIf (cfg.group == "kotsukotsu") {
@ -104,7 +122,8 @@ in
}; };
serviceConfig = { serviceConfig = {
ExecStart = lib.getExe cfg.package; ExecStart = launcher;
ExecStartPre = ensureCurrent;
Group = cfg.group; Group = cfg.group;
Restart = "on-failure"; Restart = "on-failure";
User = cfg.user; User = cfg.user;

28
scripts/deploy-app.sh Normal file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
target_host="${1:-root@sortug.com}"
service_name="${SERVICE_NAME:-kotsukotsu}"
current_path="${CURRENT_PATH:-/var/lib/kotsukotsu/current}"
health_url="${HEALTH_URL:-http://127.0.0.1:5174/healthz}"
store_path="$(nix build --accept-flake-config --print-out-paths .#default | tail -n 1)"
echo "Built ${store_path}"
echo "Copying package to ${target_host}"
nix copy --to "ssh://${target_host}" "${store_path}"
echo "Activating release on ${target_host}"
ssh "${target_host}" "
set -euo pipefail
ln -sfn '${store_path}' '${current_path}'
systemctl restart '${service_name}'
for _ in 1 2 3 4 5 6 7 8 9 10; do
if curl -fsS '${health_url}' >/dev/null; then
exit 0
fi
sleep 1
done
echo 'health check failed for ${service_name}' >&2
exit 1
"