chore: install Claude Code from its package repository, add style guide
Replace mkosi.prepare with Anthropic's rpm repository (mkosi.sandbox/), switch the workflow to the gitea context, and start STYLE.md with a consistent file header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
10 files changed
+96
-28
No files matched your search
@@ -1,28 +1,27 @@
|
|||||||
# agent OS image
|
# agent OS image
|
||||||
#
|
#
|
||||||
# Builds the OS image and publishes it as version "latest" of the generic package agent, where VMs
|
# Builds the OS image and publishes it as version "latest". VMs fetch the build
|
||||||
# fetch their updates (mkosi.extra/usr/lib/sysupdate.d). Runs on every push, weekly for Fedora and
|
# images as updates (mkosi.extra/usr/lib/sysupdate.d). Runs on every push,
|
||||||
# Claude Code updates, and by hand.
|
# weekly for package updates, and by hand for critical CVE's.
|
||||||
name: os
|
name: os
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 2 * * 0" # weekly (Sunday), picks up Fedora and Claude Code updates
|
- cron: "0 2 * * 0" # weekly (Sunday), picks up package updates
|
||||||
workflow_dispatch: # run by hand, e.g. for a CVE
|
workflow_dispatch: # run by hand, e.g. for a CVE
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
os:
|
os:
|
||||||
runs-on: linux
|
runs-on: linux
|
||||||
env:
|
env:
|
||||||
PKG: ${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/agent/latest
|
PKG: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/agent/latest
|
||||||
AUTH: "Authorization: token ${{ github.token }}"
|
AUTH: "Authorization: token ${{ gitea.token }}"
|
||||||
steps:
|
steps:
|
||||||
- name: Install tools
|
- name: Install tools
|
||||||
run: dnf install -yq mkosi sbsigntools
|
run: dnf install -yq mkosi sbsigntools
|
||||||
- name: Check out
|
- name: Check out
|
||||||
uses: builtin:checkout
|
uses: builtin:checkout
|
||||||
# Signs systemd-boot and the UKI for Secure Boot (mkosi.conf, [Validation]).
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
KEY: ${{ secrets.SECUREBOOT_KEY }}
|
KEY: ${{ secrets.SECUREBOOT_KEY }}
|
||||||
@@ -35,7 +34,6 @@ jobs:
|
|||||||
zstd -q --rm -T0 -19 agent_*.root-*.raw
|
zstd -q --rm -T0 -19 agent_*.root-*.raw
|
||||||
qemu-img convert -c -O qcow2 "$(basename agent_*.efi .efi).raw" agent.qcow2
|
qemu-img convert -c -O qcow2 "$(basename agent_*.efi .efi).raw" agent.qcow2
|
||||||
sha256sum agent_*.efi agent_*.root-*.raw.zst > SHA256SUMS
|
sha256sum agent_*.efi agent_*.root-*.raw.zst > SHA256SUMS
|
||||||
# Signs SHA256SUMS with the key whose public half is mkosi.extra/usr/lib/systemd/import-pubring.pgp.
|
|
||||||
- name: Sign
|
- name: Sign
|
||||||
working-directory: mkosi.output
|
working-directory: mkosi.output
|
||||||
env:
|
env:
|
||||||
@@ -44,7 +42,6 @@ jobs:
|
|||||||
export GNUPGHOME=$(mktemp -d)
|
export GNUPGHOME=$(mktemp -d)
|
||||||
gpg -q --batch --import <<< "$KEY"
|
gpg -q --batch --import <<< "$KEY"
|
||||||
gpg -q --batch -o SHA256SUMS.gpg --detach-sign SHA256SUMS
|
gpg -q --batch -o SHA256SUMS.gpg --detach-sign SHA256SUMS
|
||||||
# Replaces the previous version. SHA256SUMS goes last: until it's there, VMs find no update.
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
working-directory: mkosi.output
|
working-directory: mkosi.output
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
# Build outputs.
|
|
||||||
mkosi.output/
|
mkosi.output/
|
||||||
# The Secure Boot private key (the SECUREBOOT_KEY secret); mkosi.crt is its certificate.
|
|
||||||
mkosi.key
|
mkosi.key
|
||||||
@@ -23,7 +23,7 @@ As soon as Claude is logged in, `claude-remote.service` starts `claude remote-co
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
`mkosi.conf` defines the OS (`mkosi.extra/` is copied to `/`, `mkosi.repart/` is the disk layout, `mkosi.prepare` installs Claude Code).
|
`mkosi.conf` defines the OS (`mkosi.extra/` is copied to `/`, `mkosi.repart/` is the disk layout, `mkosi.sandbox/` adds the Claude Code package repository).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkosi build
|
mkosi build
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Style guide
|
||||||
|
|
||||||
|
For everyone who changes this repository, people and AI agents alike.
|
||||||
|
|
||||||
|
## General
|
||||||
|
|
||||||
|
- Keep it simple. Prefer fewer files, fewer lines and the defaults. Delete what isn't needed.
|
||||||
|
- Each fact lives in one place. Elsewhere, refer to it by path instead of repeating it.
|
||||||
|
- Write plain English in short sentences.
|
||||||
|
|
||||||
|
## File header
|
||||||
|
|
||||||
|
Every file that allows comments starts with a header. It goes after the shebang, if there is one:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#!/bin/sh
|
||||||
|
# Image version
|
||||||
|
#
|
||||||
|
# Prints the build time in UTC (YYYYMMDDhhmm). Every build gets a higher version than the one
|
||||||
|
# before, which is how systemd-sysupdate tells that an update is newer.
|
||||||
|
```
|
||||||
|
|
||||||
|
- Line 1 is a title: a few words, in sentence case, with no full stop.
|
||||||
|
- Then a line with only the comment character.
|
||||||
|
- Then what the file does and why, naming the files it works with by path.
|
||||||
|
|
||||||
|
Files that can't hold comments (JSON, `subuid`, `machine-id`) are explained in the file that uses
|
||||||
|
them or in the README.
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
|
||||||
|
- Explain why, not what. Leave out comments that only repeat the code.
|
||||||
|
- Put a comment right above the line or block it is about.
|
||||||
|
- Wrap comments at 100 columns.
|
||||||
|
|
||||||
|
## Shell
|
||||||
|
|
||||||
|
- Use `#!/bin/sh` with `set -eu`. Switch to `#!/bin/bash` with `set -euo pipefail` only when the
|
||||||
|
script needs bash.
|
||||||
|
- Quote variables: `"$var"`.
|
||||||
|
|
||||||
|
## Config files
|
||||||
|
|
||||||
|
- Put one value per line in lists, with a comment explaining the less obvious entries.
|
||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
# agent: a Fedora VM image that runs Claude Code in the background, built with mkosi.
|
# agent: a Fedora VM image that runs Claude Code in the background, built with mkosi.
|
||||||
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.prepare adds Claude Code.
|
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.sandbox/ adds the Claude Code repo.
|
||||||
# The root filesystem, /etc included, is read-only and replaced whole by updates; all state lives
|
# The root filesystem, /etc included, is read-only and replaced whole by updates; all state lives
|
||||||
# on /var. Claude can't change the OS: it runs its tools in containers.
|
# on /var. Claude can't change the OS: it runs its tools in containers.
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ Bootloader=systemd-boot
|
|||||||
# - openssh-server ssh login for the user (keys only)
|
# - openssh-server ssh login for the user (keys only)
|
||||||
# - zram-generator-defaults compressed swap in RAM
|
# - zram-generator-defaults compressed swap in RAM
|
||||||
# - podman, podman-docker containers, for all of Claude's toolchains (also as docker)
|
# - podman, podman-docker containers, for all of Claude's toolchains (also as docker)
|
||||||
|
# - claude-code Claude Code (mkosi.sandbox/etc/yum.repos.d)
|
||||||
# - git-core, openssh-clients Claude Code uses git; it pushes over ssh
|
# - git-core, openssh-clients Claude Code uses git; it pushes over ssh
|
||||||
# - the rest basic command-line tools Claude uses on the host
|
# - the rest basic command-line tools Claude uses on the host
|
||||||
Packages=
|
Packages=
|
||||||
@@ -46,6 +47,7 @@ Packages=
|
|||||||
zram-generator-defaults
|
zram-generator-defaults
|
||||||
podman
|
podman
|
||||||
podman-docker
|
podman-docker
|
||||||
|
claude-code
|
||||||
git-core
|
git-core
|
||||||
openssh-clients
|
openssh-clients
|
||||||
curl
|
curl
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"permissions": { "defaultMode": "bypassPermissions" },
|
"permissions": { "defaultMode": "bypassPermissions" },
|
||||||
"skipDangerousModePermissionPrompt": true,
|
"skipDangerousModePermissionPrompt": true
|
||||||
"env": { "DISABLE_AUTOUPDATER": "1" }
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Installs Claude Code: the latest stable release, checked against the sha256 in its release manifest.
|
|
||||||
# The image updates weekly, so Claude's own auto-updater is off (/etc/claude-code/managed-settings.json).
|
|
||||||
set -eu
|
|
||||||
u=https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases
|
|
||||||
v=$(curl -fsS "$u/stable")
|
|
||||||
sum=$(curl -fsS "$u/$v/manifest.json" | tr -d ' \n' | sed -n 's/.*"linux-x64":{[^}]*"checksum":"\([0-9a-f]*\)".*/\1/p')
|
|
||||||
[ -n "$sum" ]
|
|
||||||
# The binary is ~300 MB: when the download stalls (under 1 kB/s for a minute), resume it.
|
|
||||||
curl -fsS --retry 10 --retry-all-errors --speed-limit 1000 --speed-time 60 -C - -o "$BUILDROOT/usr/bin/claude" "$u/$v/linux-x64/claude"
|
|
||||||
echo "$sum $BUILDROOT/usr/bin/claude" | sha256sum -c
|
|
||||||
chmod 755 "$BUILDROOT/usr/bin/claude"
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
mQINBGnK73ABEACnbytJXkjweYrwIr0aLEFRlH+C0nF44KxFc7gQmJ6PjSPMGZAD
|
||||||
|
dxZcaixU7zZl8WxEpVO0wLmIH8cf2zGOdyuZg1Yaugk1vHb2b8WBhAGCQJdPgB8W
|
||||||
|
XquedepEYtk56uP/gCoTjJDUZluEGBHnlnuujSJ4orxEdhSykEoAUfJZGEILPpMd
|
||||||
|
bphFt/Sn+Eb/TxM5jpKPdwnv8AShNF/1mZU1fWTQq9tRKJUakZj04gda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99+c0dPEHYO8DCeAHZizjkFrdYtUHdDU0YDYEGkLJa
|
||||||
|
bE+pgcpkHf5EvsZzHsyDbl95W/eh7pcXMbwkN+W4CBYUE9X4uHhqzWaC5yAVRWUA
|
||||||
|
1BJ9V4LjZfHPLEJt0I3TxzXiEg9/BVeaTYq9RjaxIFo9Nfk158HqJY6SA5jslBlx
|
||||||
|
Gv/No8u+xVcze2UJyGVfEIUfm92+0UAIkny3+5cuVV0ICzJxXlXj0CnLM9Lt50wE
|
||||||
|
p3suVwuBEviCbZ08eAH1Ht8gbBdSsiOkIU8CX3v/scwHHx5q0+NBL6xLrQObg13a
|
||||||
|
tRXBlKObfElkPN3lTUbUnJOW4U8uSjH8VRP+AujKWMDFe7x0zCs+iYY1mTOvbrTS
|
||||||
|
9n3CmZUmbynZ+E/QWNENpW/pDNZdWFy43PASmML5FHu4m9Sn
|
||||||
|
=oqMI
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Claude Code
|
||||||
|
#
|
||||||
|
# Anthropic's package repository, stable channel. The key's fingerprint is
|
||||||
|
# 31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE.
|
||||||
|
[claude-code]
|
||||||
|
name=Claude Code
|
||||||
|
baseurl=https://downloads.claude.ai/claude-code/rpm/stable
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=file:///etc/pki/rpm-gpg/claude-code.asc
|
||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# The image version: the build time, so every build is newer than the last.
|
# Image version
|
||||||
|
#
|
||||||
|
# The build time (UTC), so every build is newer than the last.
|
||||||
date -u +%Y%m%d%H%M
|
date -u +%Y%m%d%H%M
|
||||||
Reference in new issue
Block a user