Skip to content

Commit 071ca2c

Browse files
authored
create update scripts, use universal manifest (#257)
* create update scripts, use universal manifest * update other universal plugin locations * fix some things, pin jellyfin stable * create root update script * run update scripts when updating flake.lock * retain yaml whitespace
1 parent f3b947f commit 071ca2c

14 files changed

Lines changed: 590 additions & 286 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: CI
2+
23
on:
34
pull_request:
45
push:
56
branches:
67
- main
8+
79
jobs:
810
prepare:
911
name: Find Checks 🔍
@@ -12,19 +14,23 @@ jobs:
1214
checks: ${{ steps.checks.outputs.checks }}
1315
steps:
1416
- uses: actions/checkout@v7
17+
1518
- name: Install Nix
1619
uses: cachix/install-nix-action@v31
1720
with:
1821
nix_path: nixpkgs=channel:nixos-unstable
22+
1923
- name: Setup Cachix
2024
uses: cachix/cachix-action@v17
2125
with:
2226
name: kiriwalawren
2327
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
28+
2429
- name: Find Checks 🔍
2530
id: checks
2631
run: |
2732
nix eval --json '.#checks.x86_64-linux' --apply builtins.attrNames | perl -pe 's|(.*)|checks=\1|' >> $GITHUB_OUTPUT
33+
2834
checks:
2935
name: ${{ matrix.check }}
3036
needs: prepare
@@ -35,21 +41,25 @@ jobs:
3541
check: ${{ fromJSON(needs.prepare.outputs.checks) }}
3642
steps:
3743
- uses: actions/checkout@v7
44+
3845
- name: Install Nix
3946
uses: cachix/install-nix-action@v31
4047
with:
4148
nix_path: nixpkgs=channel:nixos-unstable
49+
4250
- name: Setup Cachix
4351
uses: cachix/cachix-action@v17
4452
with:
4553
name: kiriwalawren
4654
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
55+
4756
# Enable KVM for VM tests
4857
- name: Enable KVM group perms
4958
run: |
5059
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5160
sudo udevadm control --reload-rules
5261
sudo udevadm trigger --name-match=kvm
62+
5363
- name: Run Check 📋
5464
run: |
5565
if nix eval --raw ".#checks.x86_64-linux.${{ matrix.check }}.passthru.meta.requiresNetwork" 2>/dev/null | grep -q "true"; then

.github/workflows/docs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
name: Deploy Documentation
2+
23
on:
34
push:
45
branches:
56
- main
67
workflow_dispatch:
8+
79
permissions:
810
contents: read
911
pages: write
1012
id-token: write
13+
1114
concurrency:
1215
group: "pages"
1316
cancel-in-progress: false
17+
1418
jobs:
1519
build:
1620
name: Build Documentation
1721
runs-on: ubuntu-latest
1822
steps:
1923
- uses: actions/checkout@v7
24+
2025
- name: Install Nix
2126
uses: cachix/install-nix-action@v31
2227
with:
2328
nix_path: nixpkgs=channel:nixos-unstable
29+
2430
- name: Setup Cachix
2531
uses: cachix/cachix-action@v17
2632
with:
2733
name: kiriwalawren
2834
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
35+
2936
- name: Build Documentation
3037
run: |
3138
nix build .#docs -L
39+
3240
- name: Copy build artifacts
3341
run: |
3442
cp -r result/ _site/
43+
3544
- name: Upload artifact
3645
uses: actions/upload-pages-artifact@v5
46+
3747
deploy:
3848
name: Deploy to GitHub Pages
3949
environment:

.github/workflows/update-flake.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
name: Update Flake Lock
2+
23
on:
34
workflow_dispatch:
45
schedule:
56
# Run every Sunday at 00:00 UTC
67
- cron: '0 0 * * 0'
8+
79
permissions:
810
contents: write
911
pull-requests: write
12+
1013
jobs:
1114
update:
1215
runs-on: ubuntu-latest
1316
steps:
1417
- uses: actions/checkout@v7
18+
1519
- name: Install Nix
1620
uses: cachix/install-nix-action@v31
1721
with:
1822
nix_path: nixpkgs=channel:nixos-unstable
23+
1924
- name: Setup Cachix
2025
uses: cachix/cachix-action@v17
2126
with:
2227
name: kiriwalawren
2328
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
29+
2430
- name: Update flake.lock
2531
run: nix flake update
32+
33+
- name: Update non-flake pins
34+
run: ./update.sh
35+
2636
- name: Create Pull Request
2737
run: |
2838
BRANCH="update-flake-lock"

docs/examples/jellyfin-plugins.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@ nix store prefetch-file --json "https://example.com/manifest.json" | jq -r .hash
126126
## Secrets
127127

128128
All attributes of `nixflix.jellyfin.plugins.<name>.config` support the `{ _secret = "/path/to/secret"; }` syntax.
129+

modules/caddy/default.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
with lib;
8+
let
9+
cfg = config.nixflix;
10+
in
11+
{
12+
13+
config.services.caddy = mkIf (cfg.enable && cfg.caddy.enable) {
14+
enable = true;
15+
package = mkIf cfg.theme.enable (
16+
pkgs.caddy.withPlugins {
17+
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20250618171559-80962887e4c6" ];
18+
hash = "sha256-Li9eQjPeyOytfPdJXgtM3fh7qK/4WtgjmaweltQAk14=";
19+
}
20+
);
21+
globalConfig = ''
22+
${optionalString (cfg.caddy.tls.acmeEmail != null) "email ${cfg.caddy.tls.acmeEmail}"}
23+
'';
24+
};
25+
}

modules/caddy/update.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
5+
TARGET_FILE="$REPO_ROOT/modules/caddy/default.nix"
6+
7+
ARCH=$(uname -m)
8+
case "$ARCH" in
9+
x86_64) SYSTEM="x86_64-linux" ;;
10+
aarch64) SYSTEM="aarch64-linux" ;;
11+
*)
12+
echo "Unsupported architecture: $ARCH" >&2
13+
exit 1
14+
;;
15+
esac
16+
17+
echo "=== Updating Caddy replace-response plugin ==="
18+
19+
# Get latest commit for caddyserver/replace-response
20+
RESPONSE=$(curl -sf "https://api.github.com/repos/caddyserver/replace-response/commits?per_page=1")
21+
NEW_SHA=$(echo "$RESPONSE" | jq -r '.[0].sha')
22+
COMMIT_DATE=$(echo "$RESPONSE" | jq -r '.[0].commit.committer.date')
23+
24+
# Build Go pseudo-version: v0.0.0-YYYYMMDDHHMMSS-<first 12 chars of SHA>
25+
TIMESTAMP=$(date -u -d "$COMMIT_DATE" '+%Y%m%d%H%M%S')
26+
NEW_VERSION="v0.0.0-${TIMESTAMP}-${NEW_SHA:0:12}"
27+
28+
CURRENT_VERSION=$(grep -o 'replace-response@[^"]*' "$TARGET_FILE" | head -1 | cut -d'@' -f2)
29+
30+
if [[ "$NEW_VERSION" == "$CURRENT_VERSION" ]]; then
31+
echo " replace-response: already at $CURRENT_VERSION"
32+
echo "Done."
33+
exit 0
34+
fi
35+
36+
echo " replace-response: $CURRENT_VERSION$NEW_VERSION"
37+
38+
# Update version string first
39+
sed -i "s|replace-response@${CURRENT_VERSION}|replace-response@${NEW_VERSION}|g" "$TARGET_FILE"
40+
41+
# Get current vendorHash
42+
CURRENT_HASH=$(grep -A3 'pkgs.caddy.withPlugins' "$TARGET_FILE" |
43+
grep 'hash = ' | sed 's/.*hash = "\(.*\)".*/\1/')
44+
45+
# Build with fake hash to obtain the real vendorHash from the error output
46+
TMP_NIX=$(mktemp --suffix=.nix)
47+
trap "rm -f $TMP_NIX" EXIT
48+
49+
cat >"$TMP_NIX" <<EOF
50+
let
51+
flake = builtins.getFlake "path:${REPO_ROOT}";
52+
pkgs = flake.inputs.nixpkgs.legacyPackages.${SYSTEM};
53+
in pkgs.caddy.withPlugins {
54+
plugins = [ "github.com/caddyserver/replace-response@${NEW_VERSION}" ];
55+
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
56+
}
57+
EOF
58+
59+
echo " Computing new vendorHash (this may take a moment)..."
60+
BUILD_OUTPUT=$(nix build --impure --file "$TMP_NIX" --no-link 2>&1 || true)
61+
62+
NEW_HASH=$(echo "$BUILD_OUTPUT" | grep "got:" | grep -o 'sha256-[A-Za-z0-9+/]*=' | tail -1)
63+
64+
if [[ -z "$NEW_HASH" ]]; then
65+
echo "Error: could not determine new vendorHash" >&2
66+
echo "nix build output:" >&2
67+
echo "$BUILD_OUTPUT" >&2
68+
# Restore original version
69+
sed -i "s|replace-response@${NEW_VERSION}|replace-response@${CURRENT_VERSION}|g" "$TARGET_FILE"
70+
exit 1
71+
fi
72+
73+
echo " New vendorHash: $NEW_HASH"
74+
sed -i "s|${CURRENT_HASH}|${NEW_HASH}|g" "$TARGET_FILE"
75+
76+
echo ""
77+
echo "Done."

0 commit comments

Comments
 (0)