refactor: rename to agentos, hand-picked /etc, user presets at first boot
os / os (push) Waiting to run
os / os (push) Waiting to run
- Rename the image from agent to agentos (ImageId, hostname, CI, docs). - mkosi.finalize only copies /etc to /usr/share/factory/etc. The hand-written tmpfiles.d/factory-etc.conf links the 24 entries the image needs. - /etc/systemd is writable: PID 1 applies the system presets at first boot and preset-global.service the user presets, as in ParticleOS. - claude-remote runs in the user manager of agent, enabled by a user preset. - Root has no /var subvolume, and the verity partitions shrink to 16M. - Style pass over comments, CLAUDE.md and AGENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
25 files changed
+252
-248
No files matched your search
@@ -33,10 +33,10 @@ jobs:
|
||||
- name: Compress
|
||||
working-directory: mkosi.output
|
||||
run: |
|
||||
zstd -q --rm -9 agent_*.usr-*.raw
|
||||
zstd -q --rm -9 agentos_*.usr-*.raw
|
||||
- name: Checksum
|
||||
working-directory: mkosi.output
|
||||
run: sha256sum agent_*.efi agent_*.usr-*.raw.zst > SHA256SUMS
|
||||
run: sha256sum agentos_*.efi agentos_*.usr-*.raw.zst > SHA256SUMS
|
||||
- name: Sign
|
||||
working-directory: mkosi.output
|
||||
env:
|
||||
@@ -47,14 +47,14 @@ jobs:
|
||||
gpg -q --batch -o SHA256SUMS.gpg --detach-sign SHA256SUMS
|
||||
- name: Build qcow2
|
||||
working-directory: mkosi.output
|
||||
run: qemu-img convert -c -O qcow2 "$(basename agent_*.efi .efi).raw" agent.qcow2
|
||||
run: qemu-img convert -c -O qcow2 "$(basename agentos_*.efi .efi).raw" agentos.qcow2
|
||||
- name: Publish
|
||||
working-directory: mkosi.output
|
||||
env:
|
||||
PKG: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/agent/latest
|
||||
PKG: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/agentos/latest
|
||||
AUTH: "Authorization: token ${{ gitea.token }}"
|
||||
run: |
|
||||
curl -fsS -H "$AUTH" -X DELETE "$PKG" || true
|
||||
for f in agent_*.efi agent_*.usr-*.raw.zst agent.qcow2 agent_*.manifest SHA256SUMS.gpg SHA256SUMS; do
|
||||
for f in agentos_*.efi agentos_*.usr-*.raw.zst agentos.qcow2 agentos_*.manifest SHA256SUMS.gpg SHA256SUMS; do
|
||||
curl -fsS -o /dev/null -H "$AUTH" --upload-file "$f" "$PKG/$f"
|
||||
done
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
mkosi.output/
|
||||
mkosi.key
|
||||
mkosi.output/
|
||||
mkosi.cache/
|
||||
mkosi.tools/
|
||||
mkosi.tools.*
|
||||
@@ -6,13 +6,12 @@ every change.
|
||||
## Style
|
||||
|
||||
- Keep it simple. Prefer fewer files and fewer lines. Delete what isn't
|
||||
needed.
|
||||
needed. Write plain English in short sentences.
|
||||
- Follow the defaults and conventions of each tool and language. Only set an
|
||||
option when the default doesn't work, and say why.
|
||||
option when the default doesn't work.
|
||||
- Each fact lives in one place. Elsewhere, refer to it instead of repeating it.
|
||||
- Divide code and config into parts (files, directories, sections) that each
|
||||
stand on their own: reading one part alone tells you what it does and why.
|
||||
- Each fact lives in one place. Elsewhere, refer to it instead of repeating it.
|
||||
- Write plain English in short sentences.
|
||||
- Name each part for what it does. A part without a good name holds things
|
||||
that don't belong together.
|
||||
- A little copying beats a little dependency. Repeat a small piece rather than
|
||||
@@ -22,7 +21,7 @@ every change.
|
||||
|
||||
A file starts with a header, after the shebang if there is one. Leave it out
|
||||
when the name already says it all, as with `.gitignore`. A part made of
|
||||
many files, like a package, needs it in only one of them. For example:
|
||||
many files, like a package, needs it in only one file. For example:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
@@ -43,48 +42,56 @@ the file that uses them.
|
||||
### Comments
|
||||
|
||||
- Explain why, not what. Leave out comments that only repeat the code. Try to
|
||||
write clean code instead of many comments.
|
||||
- Put a comment right above the line or block it is about. A short note on
|
||||
one line may go at the end of that line, as a full sentence too.
|
||||
write clean code instead of comments.
|
||||
- Write full sentences that start with the name of what they describe:
|
||||
`# ManifestFormat lists the packages and versions in the image.` or
|
||||
`# link prints the tmpfiles line for /etc/$1.`
|
||||
- Put a comment right above the line or block it is about. A short note on
|
||||
one line may go at the end of that line, as a full sentence too.
|
||||
- Separate paragraphs and lists with a line holding only the comment
|
||||
character.
|
||||
- Wrap comments at 80 columns.
|
||||
|
||||
## Testing
|
||||
|
||||
`mkosi vm` boots the image in qemu and needs systemd on the host. Without it,
|
||||
run mkosi in a privileged podman container that boots systemd:
|
||||
`mkosi vm` boots the image in qemu. It needs systemd on the host, so run mkosi
|
||||
in a privileged podman container that boots systemd:
|
||||
|
||||
```sh
|
||||
podman build -t mkosi-vm - <<'END'
|
||||
FROM registry.fedoraproject.org/fedora:latest
|
||||
RUN dnf install -y mkosi git-core
|
||||
FROM registry.fedoraproject.org/fedora:45
|
||||
RUN dnf install -y mkosi git-core qemu-system-x86-core edk2-ovmf swtpm-tools \
|
||||
virtiofsd openssh-clients socat
|
||||
CMD ["/sbin/init"]
|
||||
END
|
||||
podman run -d --name mkosi --privileged --systemd=always -v <repo>:/repo \
|
||||
-v mkosi-cache:/root/.cache/mkosi -v mkosi-work:/var/tmp -w /repo mkosi-vm
|
||||
podman exec mkosi mkosi genkey # Run this once, if there is no mkosi.key.
|
||||
podman exec -d -t mkosi sh -c 'mkosi -f vm > mkosi.output/vm.log 2>&1'
|
||||
podman exec mkosi mkdir -p mkosi.cache
|
||||
podman exec -d -t mkosi sh -c 'mkosi -i -f \
|
||||
--kernel-command-line-extra=console=ttyS0 vm -- -serial chardev:console \
|
||||
> mkosi.output/vm.log 2>&1'
|
||||
podman exec mkosi mkosi ssh -- systemctl --failed
|
||||
```
|
||||
|
||||
podman resolves paths on the host, so `<repo>` is the repository's path there.
|
||||
The volume `mkosi-cache` keeps mkosi's package cache when the container is
|
||||
made again, so builds don't download every package anew.
|
||||
The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off the
|
||||
container's overlayfs. mkosi copies a tree with SELinux labels (as files from
|
||||
the host have) to overlayfs without any xattrs. That drops the file
|
||||
capabilities of newuidmap and newgidmap, and rootless podman fails in the VM.
|
||||
`mkosi vm` needs a terminal, hence `-d -t`; its console goes to the log.
|
||||
`mkosi ssh` runs a command as root, once the VM has booted. For the user
|
||||
- `mkosi -i` keeps the image with its packages installed in `mkosi.cache/`.
|
||||
Rebuilds start from it and skip installing packages.
|
||||
- The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off overlayfs.
|
||||
When mkosi copies files with SELinux labels to overlayfs, it drops all
|
||||
xattrs. That removes the file capabilities of newuidmap and newgidmap, and
|
||||
rootless podman fails in the VM.
|
||||
- `mkosi vm` needs a terminal, hence `-d -t`. Its console goes to the log.
|
||||
- The console of `mkosi vm` is hvc0, which the kernel can only use once the
|
||||
initrd loads its driver. `console=ttyS0` also sends the kernel log to the
|
||||
serial port, and `-serial chardev:console` sends that port to the same log.
|
||||
The log then shows early errors too, such as a panic or an initrd that
|
||||
can't find /usr. Arguments after `--` go to qemu.
|
||||
- `mkosi ssh` runs a command as root once the VM has booted. For the user
|
||||
`agent`, run `su - agent -c '<command>'`.
|
||||
|
||||
`mkosi.version` gives every run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build without a rebuild, pin
|
||||
its version (from `mkosi.output/agent_<version>.raw`):
|
||||
`mkosi.version` gives each run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build again, pin its version
|
||||
from `mkosi.output/agentos_<version>.raw`:
|
||||
|
||||
```sh
|
||||
mkosi --image-version 202611171816.c80e843 vm
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# agent-mkosi
|
||||
# agentos
|
||||
|
||||
A VM that runs [Claude Code](https://claude.com/claude-code) in the background.
|
||||
It is a minimal Fedora image built with
|
||||
@@ -20,13 +20,13 @@ claude.ai/code or the Claude app (Remote Control), or log in with ssh.
|
||||
|
||||
## Install
|
||||
|
||||
Download [the disk image](https://git.plabble.org/api/packages/Job79/generic/agent/latest/agent.qcow2),
|
||||
Download [the disk image](https://git.plabble.org/api/packages/Job79/generic/agentos/latest/agentos.qcow2),
|
||||
resize it to the disk size you want and boot it with UEFI and a TPM. At first
|
||||
boot, the screen offers a recovery key for the encrypted disk and asks for a
|
||||
root password. Then log in as root and put your ssh key in
|
||||
`/home/agent/.ssh/authorized_keys` (for root: `~/.ssh/authorized_keys`), which
|
||||
starts sshd. Run `claude` once as `agent` to sign in. The VM then shows up in
|
||||
claude.ai/code and the Claude app under its hostname: `agent-` and four hex
|
||||
claude.ai/code and the Claude app under its hostname: `agentos-` and four hex
|
||||
digits.
|
||||
|
||||
To start over, run `systemctl start factory-reset.target` as root. It reboots
|
||||
@@ -40,7 +40,7 @@ mkosi genkey # This is for local tests. CI uses the SECUREBOOT_KEY secret.
|
||||
mkosi build
|
||||
```
|
||||
|
||||
`mkosi.output/` then holds the disk image (`agent_<version>.raw`) and the UKI
|
||||
`mkosi.output/` then holds the disk image (`agentos_<version>.raw`) and the UKI
|
||||
and /usr partitions that make up an update.
|
||||
|
||||
To build and boot a test VM:
|
||||
|
||||
+57
-69
@@ -1,12 +1,12 @@
|
||||
# mkosi.conf builds a Fedora VM image that runs Claude Code in the background.
|
||||
# /usr is read-only and replaced whole by updates. The root filesystem holds
|
||||
# the state.
|
||||
# mkosi.conf builds agentos, a Fedora VM image that runs Claude Code. The
|
||||
# image holds a read-only /usr. The root filesystem, which holds the state,
|
||||
# is made at first boot.
|
||||
#
|
||||
# The other parts of the build:
|
||||
# - mkosi.extra/ is copied to /.
|
||||
# - mkosi.repart/ defines the disk image: the ESP and the /usr partitions.
|
||||
# - mkosi.extra/usr/lib/repart.d/ makes the root partition at first boot.
|
||||
# - mkosi.finalize keeps /etc in /usr, and links it into /etc at boot.
|
||||
# - mkosi.finalize keeps /etc in /usr/share/factory/etc.
|
||||
# - mkosi.sandbox/ adds the Claude Code package repository.
|
||||
# - mkosi.version gives each build its version.
|
||||
|
||||
@@ -14,41 +14,61 @@
|
||||
Distribution=fedora
|
||||
Release=45
|
||||
|
||||
[Build]
|
||||
# ToolsTree builds with mkosi's own Fedora tools, the same on every host,
|
||||
# so the host needs only mkosi and git (for mkosi.version). The tools land in
|
||||
# mkosi.tools/.
|
||||
ToolsTree=yes
|
||||
ToolsTreeRelease=%r
|
||||
Incremental=yes
|
||||
CacheDirectory=mkosi.cache
|
||||
|
||||
[Output]
|
||||
Format=disk
|
||||
ImageId=agent
|
||||
# Output writes agentos_<version>.* to mkosi.output/. The UKI and /usr
|
||||
# partitions are split into the files of an update.
|
||||
ImageId=agentos
|
||||
OutputDirectory=mkosi.output
|
||||
SplitArtifacts=uki,partitions
|
||||
ManifestFormat=json
|
||||
|
||||
[Content]
|
||||
# Content sets what goes into the image:
|
||||
# - Hostname is agentos- and four hex digits of the machine ID.
|
||||
# - WithDocs leaves out man pages. The image has no man to read them.
|
||||
# - Packages lists the packages installed into the image.
|
||||
# - UnifiedKernelImageFormat names the UKI agentos_<version>.efi, which matches
|
||||
# the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer.
|
||||
# - KernelCommandLine:
|
||||
# - rw has the initrd mount the root filesystem writable. It finds it by its
|
||||
# partition type (mkosi.extra/usr/lib/repart.d/50-root.conf).
|
||||
# - The image policy only accepts an encrypted root filesystem (or none, at
|
||||
# first boot) and a verity-checked /usr. Otherwise someone with the disk
|
||||
# could swap in a plain root filesystem. Our UKI would boot it, and their
|
||||
# code could unseal the key of the real one.
|
||||
# - The root btrfs keeps one copy of its metadata instead of two (DUP,
|
||||
# mkfs.btrfs's default). On a VM disk a second copy adds little.
|
||||
# - The mount rate limit is raised from 5, which holds back mounts at boot
|
||||
# and delays / and /usr by up to a second each.
|
||||
# - KernelInitrdModules are what the initrd needs to find the disks of a VM,
|
||||
# mount /usr and unlock the root filesystem. The kernel has virtio_blk,
|
||||
# sd_mod, the TPM drivers and btrfs built in.
|
||||
# - KernelModules keeps all modules but the hardware drivers, then adds back
|
||||
# the drivers a VM needs (disks, network, screen) and those of podman's
|
||||
# networks (veth, tun). The last matching line wins. Keyboard, USB and a
|
||||
# basic screen are built into the kernel.
|
||||
# - RemoveFiles drops System.map, which is only for debugging the kernel, and
|
||||
# the udev hwdb, which holds hardware names and quirks a VM doesn't need.
|
||||
# Without hwdb.d, systemd-hwdb-update can't build it again at boot.
|
||||
Hostname=agentos-????
|
||||
WithDocs=no
|
||||
Packages=
|
||||
kernel-core # It has no drivers or firmware VMs don't need.
|
||||
systemd # It is the init and service manager.
|
||||
dbus-broker # It is D-Bus, for the user manager and podman.
|
||||
systemd-udev # It has udev, sysupdate, repart and cryptsetup.
|
||||
systemd-networkd # It runs DHCP on every network card.
|
||||
systemd-resolved # It resolves DNS names.
|
||||
systemd-container # It has systemd-pull and gnupg2 for sysupdate.
|
||||
systemd-boot-unsigned # It is the boot loader, which mkosi signs.
|
||||
util-linux # It has login, for the console login.
|
||||
shadow-utils # It has newuidmap for rootless podman.
|
||||
systemd-pam # It gives logins a session and user manager.
|
||||
openssh-server # It lets you log in once there is a key.
|
||||
zram-generator-defaults # It sets up compressed swap in RAM.
|
||||
podman # It runs Claude's tools in containers.
|
||||
claude-code # It comes from mkosi.sandbox/etc/yum.repos.d.
|
||||
git-core # It brings openssh-clients to push over ssh.
|
||||
# The rest are basic command-line tools Claude uses on the host.
|
||||
kernel-core # Unlike kernel, this has no extra drivers.
|
||||
systemd # The init and service manager is PID 1.
|
||||
dbus-broker # D-Bus serves the user manager and podman.
|
||||
systemd-udev # Udev, sysupdate, repart, cryptsetup are here.
|
||||
systemd-networkd # DHCP runs on every network card.
|
||||
systemd-resolved # DNS names are resolved here.
|
||||
systemd-container # Sysupdate needs its systemd-pull and gnupg2.
|
||||
systemd-boot-unsigned # mkosi signs this boot loader.
|
||||
util-linux # The console login needs its login.
|
||||
shadow-utils # Rootless podman needs its newuidmap.
|
||||
systemd-pam # Logins get a session and user manager.
|
||||
openssh-server # You can log in with ssh once there is a key.
|
||||
zram-generator-defaults # Swap is compressed in RAM.
|
||||
podman # Claude runs its tools in containers.
|
||||
claude-code # Its repo is mkosi.sandbox/etc/yum.repos.d.
|
||||
git-core # Git pushes over ssh.
|
||||
curl
|
||||
tar
|
||||
gzip
|
||||
@@ -58,43 +78,19 @@ Packages=
|
||||
findutils
|
||||
procps-ng
|
||||
iproute
|
||||
WithDocs=no
|
||||
Locale=C.UTF-8
|
||||
# Hostname is agent- and four hex digits of the machine ID.
|
||||
Hostname=agent-????
|
||||
# UnifiedKernelImageFormat names the UKI in the ESP agent_<version>.efi, which
|
||||
# matches the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer.
|
||||
UnifiedKernelImageFormat=%i_%v
|
||||
KernelCommandLine=
|
||||
# The console shows on the serial port and the screen. The screen
|
||||
# comes last, so systemd-firstboot asks for the root password there.
|
||||
console=ttyS0,115200n8
|
||||
console=tty0
|
||||
quiet
|
||||
# The initrd finds the root filesystem by its partition type
|
||||
# (mkosi.extra/usr/lib/repart.d/50-root.conf) and mounts it writable.
|
||||
rw
|
||||
# The image policy only accepts an encrypted root filesystem (or none,
|
||||
# at first boot) and a verity-checked /usr. Otherwise someone with the
|
||||
# disk could swap in a plain root filesystem. Our UKI would boot it, and
|
||||
# their code could unseal the key of the real one.
|
||||
systemd.image_policy=root=encrypted+absent:usr=verity:esp=unprotected
|
||||
# The mount rate limit is raised from 5, which holds back mounts at
|
||||
# boot and delays / and /usr by up to a second each.
|
||||
systemd.setenv=SYSTEMD_REPART_MKFS_OPTIONS_BTRFS=--metadata=single
|
||||
SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50
|
||||
# KernelInitrdModules are the modules the initrd needs to find the disks of a
|
||||
# VM, mount /usr and unlock the root filesystem. The kernel has virtio_blk,
|
||||
# sd_mod, the TPM drivers and btrfs built in.
|
||||
KernelInitrdModules=
|
||||
virtio_scsi
|
||||
nvme
|
||||
dm-verity
|
||||
dm-crypt
|
||||
erofs
|
||||
# KernelModules keeps all modules but the hardware drivers, then the drivers a
|
||||
# VM needs (disks, network, screen) and those of rootless podman's networks
|
||||
# (pasta). The last matching line wins. Keyboard, USB and a basic screen are
|
||||
# built into the kernel.
|
||||
KernelModules=
|
||||
/*
|
||||
-/drivers/*
|
||||
@@ -109,31 +105,23 @@ KernelModules=
|
||||
virtio-gpu
|
||||
veth
|
||||
tun
|
||||
# RemoveFiles drops what the image doesn't use:
|
||||
# - System.map is only for debugging the kernel.
|
||||
# - The udev hwdb holds hardware names and quirks, nothing a VM needs. Without
|
||||
# hwdb.d, systemd-hwdb-update can't build it again at boot.
|
||||
RemoveFiles=
|
||||
/usr/lib/modules/*/System.map
|
||||
/usr/lib/udev/hwdb.bin
|
||||
/usr/lib/udev/hwdb.d
|
||||
|
||||
[Validation]
|
||||
# SecureBoot signs systemd-boot and the UKI, and puts our keys on the ESP.
|
||||
# systemd-boot enrolls them at first boot if the firmware is in setup mode (no
|
||||
# keys enrolled).
|
||||
# Validation signs the boot chain with mkosi.key, so the TPM unlocks the root
|
||||
# filesystem only for our UKIs.
|
||||
SecureBoot=yes
|
||||
# SignExpectedPcr signs the PCR 11 values that each UKI will measure, with
|
||||
# mkosi.key. The TPM then unlocks the root filesystem only for UKIs we signed,
|
||||
# also after updates (mkosi.extra/usr/lib/repart.d/50-root.conf).
|
||||
SignExpectedPcr=yes
|
||||
|
||||
[Runtime]
|
||||
# Runtime sets up the test VM of mkosi vm.
|
||||
# Runtime sets up the test VM of mkosi vm. Each run boots a fresh copy, with
|
||||
# root password root and no first boot questions.
|
||||
Ephemeral=yes
|
||||
CPUs=4
|
||||
RAM=4G
|
||||
RuntimeSize=40G
|
||||
QemuArgs=-serial chardev:console
|
||||
Credentials=passwd.plaintext-password.root=root
|
||||
KernelCommandLineExtra=systemd.firstboot=no
|
||||
@@ -1,18 +1,15 @@
|
||||
# This machine
|
||||
|
||||
You run on a small Fedora VM made for you, as the user `claude`, without root.
|
||||
A small Fedora VM, made for running Claude Code.
|
||||
|
||||
- **The OS is read-only**: you can't install anything on it. Run toolchains, languages and
|
||||
services in containers, with rootless `podman`. For quick commands:
|
||||
`podman run --rm -v "$PWD:/w" -w /w docker.io/library/python:3 python script.py`.
|
||||
For longer work, keep one dev container per worktree or session, named after its directory,
|
||||
that you install into:
|
||||
`podman run -d --name "${PWD##*/}" -v "$PWD:$PWD" -w "$PWD" quay.io/fedora/fedora:latest sleep infinity`,
|
||||
then `podman exec "${PWD##*/}" dnf install -y gcc` and `podman exec "${PWD##*/}" make`.
|
||||
Remove it with `podman rm -f` when the work is done.
|
||||
- On the host: git, ssh, curl, tar/gzip/xz/zstd, find, diff, ps, ip.
|
||||
- **Your files survive reboots**: your home (/home/claude), containers and images stay.
|
||||
/tmp is wiped at every boot. The VM may reboot at about 04:10 to update.
|
||||
- **To start over**, push what you want to keep, then remove all containers and images with
|
||||
`podman system reset --force` and delete everything in your home but `~/.claude` and
|
||||
`~/.claude.json`, which hold your Claude login.
|
||||
- Claude runs as the user `agent`, without root or sudo.
|
||||
- The OS is read-only. Packages can't be installed on it.
|
||||
- Run toolchains, languages and services in containers with rootless `podman`.
|
||||
- For longer work, keep one container per worktree, named after its directory:
|
||||
- Start: `podman run -d --name "${PWD##*/}" -v "$PWD:$PWD" -w "$PWD" quay.io/fedora/fedora:latest sleep infinity`
|
||||
- Install: `podman exec "${PWD##*/}" dnf install -y gcc`
|
||||
- Run: `podman exec "${PWD##*/}" make`
|
||||
- Remove: `podman rm -f "${PWD##*/}"`
|
||||
- On the host: git, ssh, curl, tar, gzip, xz, zstd, find, diff, ps, ip.
|
||||
- The home directory (/home/agent), containers and images survive reboots.
|
||||
- /tmp is wiped at every boot.
|
||||
@@ -1,16 +1,10 @@
|
||||
# 50-root.conf makes the root filesystem in the initrd at first boot, from the
|
||||
# free space after /usr, and grows it when the disk grows. It holds all state:
|
||||
# /etc (mkosi.finalize) and /var, which is its own btrfs subvolume. It is
|
||||
# encrypted with a key in the TPM, so a TPM is required. The key is sealed to
|
||||
# the signed PCR 11 policy of our UKIs (SignExpectedPcr= in mkosi.conf), and
|
||||
# the initrd unlocks it at every boot.
|
||||
# 50-root.conf makes the root filesystem at first boot, in the free space after
|
||||
# /usr, and grows it with the disk. It holds all state: /etc and /var.
|
||||
#
|
||||
# FactoryReset makes a factory reset wipe it: root runs systemctl start
|
||||
# factory-reset.target, and at the next boot it is made anew, as at first boot.
|
||||
# The key is in the TPM, sealed to the signed PCR 11 policy of our UKIs
|
||||
# (SignExpectedPcr= in mkosi.conf).
|
||||
[Partition]
|
||||
Type=root
|
||||
Format=btrfs
|
||||
Subvolumes=/var
|
||||
MakeDirectories=/var
|
||||
Encrypt=tpm2
|
||||
FactoryReset=yes
|
||||
@@ -1,4 +1,3 @@
|
||||
# 50-agent.conf raises the inotify instances per user. Containers (file
|
||||
# watchers, systemd in containers) run out of Fedora's 128. 8192 is common on
|
||||
# Kubernetes nodes.
|
||||
# 50-agent.conf raises the inotify instances per user from the kernel's 128,
|
||||
# which many containers running systemd can use up.
|
||||
fs.inotify.max_user_instances = 8192
|
||||
@@ -1,24 +1,26 @@
|
||||
# 50-agent.preset enables the services of the image. mkosi runs systemctl
|
||||
# preset-all, which applies it. It sorts before Fedora's presets, so it wins
|
||||
# where they disagree.
|
||||
# 50-agent.preset enables the services of the image. PID 1 applies it at first
|
||||
# boot, so a change reaches existing machines only after a factory reset. It
|
||||
# sorts before Fedora's presets, so it wins where they disagree.
|
||||
|
||||
# systemd-networkd is disabled by Fedora, which uses NetworkManager.
|
||||
enable systemd-networkd.service
|
||||
enable systemd-resolved.service
|
||||
# sshd.path starts sshd once there is an ssh key, so Fedora's preset of
|
||||
# sshd.service is overruled.
|
||||
|
||||
# preset-global.service applies the user presets.
|
||||
enable preset-global.service
|
||||
|
||||
# sshd.path starts sshd once there is an ssh key.
|
||||
enable sshd.path
|
||||
disable sshd.service
|
||||
# getty@.service is the login on the screen, which Fedora disables (tty1, and
|
||||
# tty2-6 through its autovt@ alias).
|
||||
|
||||
# getty@.service is the login on the screen, which Fedora disables.
|
||||
enable getty@.service
|
||||
enable claude-remote.path
|
||||
enable systemd-sysupdate-update.timer
|
||||
enable systemd-sysupdate-reboot.timer
|
||||
# authselect-apply-changes would rewrite /etc/authselect, which links into the
|
||||
# read-only /usr (mkosi.finalize), and fails.
|
||||
|
||||
# authselect-apply-changes fails, because /etc/authselect is on read-only /usr.
|
||||
disable authselect-apply-changes.service
|
||||
|
||||
# systemd-homed, systemd-userdbd and systemd-nsresourced are unused here.
|
||||
# Fedora enables them.
|
||||
disable systemd-homed.service
|
||||
disable systemd-homed-activate.service
|
||||
disable systemd-userdbd.socket
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# claude-remote.path starts claude-remote.service once Claude has a login: at
|
||||
# boot, or as soon as the user first logs in.
|
||||
[Unit]
|
||||
Description=Start Claude Remote Control once logged in
|
||||
|
||||
[Path]
|
||||
PathExists=/home/agent/.claude/.credentials.json
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,15 +0,0 @@
|
||||
# claude-remote.service runs Claude Code in the background, as the user agent
|
||||
# in its home, so it can be used from claude.ai/code or the Claude app.
|
||||
# claude-remote.path starts it once Claude is logged in.
|
||||
[Unit]
|
||||
Description=Claude Code Remote Control
|
||||
Wants=network-online.target user@1000.service
|
||||
After=network-online.target user@1000.service
|
||||
|
||||
[Service]
|
||||
User=agent
|
||||
WorkingDirectory=~
|
||||
Environment=XDG_RUNTIME_DIR=/run/user/1000
|
||||
ExecStart=/usr/bin/claude remote-control --name %H
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
@@ -0,0 +1,20 @@
|
||||
# preset-global.service applies the user presets at first boot, as PID 1 does
|
||||
# for the system presets. It runs before basic.target, so before any user
|
||||
# manager starts, which needs DefaultDependencies=no. It is the same as
|
||||
# ParticleOS's. systemd 263 can apply presets at build time instead, with
|
||||
# systemctl preset-all --vendor.
|
||||
[Unit]
|
||||
Description=Apply the user presets
|
||||
ConditionFirstBoot=yes
|
||||
DefaultDependencies=no
|
||||
Before=basic.target
|
||||
Conflicts=shutdown.target
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=systemctl preset-all --global
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
@@ -1,7 +1,5 @@
|
||||
# sshd.path starts sshd only once root or the user agent has an ssh key, so a
|
||||
# new VM has no open port. Root adds the keys after the first boot
|
||||
# (README.md). The ssh.authorized_keys.root credential also fills root's, such
|
||||
# as for mkosi ssh.
|
||||
# new VM has no open port.
|
||||
[Unit]
|
||||
Description=Start sshd once an ssh key is set
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# 50-agent.preset enables the user services of the image.
|
||||
# preset-global.service applies it at first boot.
|
||||
enable claude-remote.path
|
||||
@@ -0,0 +1,13 @@
|
||||
# claude-remote.path starts claude-remote.service once Claude is logged in.
|
||||
# It runs in the user manager of agent, which linger starts at boot
|
||||
# (mkosi.extra/usr/lib/tmpfiles.d/agent.conf). ConditionUser keeps it out of
|
||||
# the user manager of root.
|
||||
[Unit]
|
||||
Description=Start Claude Remote Control once logged in
|
||||
ConditionUser=agent
|
||||
|
||||
[Path]
|
||||
PathExists=%h/.claude/.credentials.json
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -0,0 +1,12 @@
|
||||
# claude-remote.service runs Claude Code in the background, in the home of the
|
||||
# user agent, so it can be used from claude.ai/code or the Claude app.
|
||||
# claude-remote.path starts it once Claude is logged in. The user manager can't
|
||||
# wait for the network, so Restart= retries until it is up.
|
||||
[Unit]
|
||||
Description=Claude Code Remote Control
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=~
|
||||
ExecStart=/usr/bin/claude remote-control --name %H
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
@@ -1,21 +1,20 @@
|
||||
# 10-usr.transfer writes the next version of /usr to the unused /usr
|
||||
# partition. The files come from .gitea/workflows/os.yml.
|
||||
# 10-usr.transfer writes the next version of /usr to the inactive /usr
|
||||
# partition.
|
||||
#
|
||||
# Verify=yes requires SHA256SUMS.gpg to be signed by a key in
|
||||
# systemd-sysupdate requires SHA256SUMS.gpg to be signed by a key in
|
||||
# /usr/lib/systemd/import-pubring.pgp, and SHA256SUMS checks each download.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
Verify=yes
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agent/latest/
|
||||
MatchPattern=agent_@v.usr-%a.@u.raw.zst
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agentos/latest/
|
||||
MatchPattern=agentos_@v.usr-%a.@u.raw.zst
|
||||
|
||||
[Target]
|
||||
Type=partition
|
||||
Path=auto
|
||||
MatchPattern=agent_@v
|
||||
MatchPattern=agentos_@v
|
||||
MatchPartitionType=usr
|
||||
PartitionFlags=0
|
||||
ReadOnly=1
|
||||
@@ -1,18 +1,17 @@
|
||||
# 11-usr-verity.transfer writes the dm-verity hashes that go with
|
||||
# 10-usr.transfer, which explains Verify=yes.
|
||||
# 10-usr.transfer, which explains how downloads are checked.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
Verify=yes
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agent/latest/
|
||||
MatchPattern=agent_@v.usr-%a-verity.@u.raw.zst
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agentos/latest/
|
||||
MatchPattern=agentos_@v.usr-%a-verity.@u.raw.zst
|
||||
|
||||
[Target]
|
||||
Type=partition
|
||||
Path=auto
|
||||
MatchPattern=agent_@v_verity
|
||||
MatchPattern=agentos_@v_verity
|
||||
MatchPartitionType=usr-verity
|
||||
PartitionFlags=0
|
||||
ReadOnly=1
|
||||
@@ -1,25 +1,23 @@
|
||||
# 20-uki.transfer installs the next UKI, which systemd-boot then boots by
|
||||
# default. For Verify=yes, see 10-usr.transfer.
|
||||
# default. For how downloads are checked, see 10-usr.transfer.
|
||||
#
|
||||
# The new UKI gets three tries (boot counting: the +@l-@d in its name).
|
||||
# systemd-bless-boot marks it good once a boot reaches boot-complete.target.
|
||||
# If no boot does, systemd-boot goes back to the previous UKI, and with it to
|
||||
# the previous /usr partition, because each UKI holds its usr hash. No
|
||||
# Mode=0444: systemd-boot can't rename a read-only file.
|
||||
# the previous /usr partition, because each UKI holds its usr hash.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
Verify=yes
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agent/latest/
|
||||
MatchPattern=agent_@v.efi
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/agentos/latest/
|
||||
MatchPattern=agentos_@v.efi
|
||||
|
||||
[Target]
|
||||
Type=regular-file
|
||||
Path=/EFI/Linux
|
||||
PathRelativeTo=boot
|
||||
MatchPattern=agent_@v+@l-@d.efi agent_@v+@l.efi agent_@v.efi
|
||||
MatchPattern=agentos_@v+@l-@d.efi agentos_@v+@l.efi agentos_@v.efi
|
||||
TriesLeft=3
|
||||
TriesDone=0
|
||||
InstancesMax=2
|
||||
@@ -1,7 +1,6 @@
|
||||
# agent.conf makes the home of the user agent
|
||||
# (mkosi.extra/usr/lib/sysusers.d/agent.conf), with Claude's login and podman
|
||||
# storage.
|
||||
d /home/agent 0700 agent agent -
|
||||
# agent.conf makes the home of the user agent.
|
||||
d /home/agent 0700 agent agent
|
||||
|
||||
# linger starts the user manager of agent at boot, for rootless podman and
|
||||
# Claude's own services.
|
||||
# claude-remote.path (mkosi.extra/usr/lib/systemd/user).
|
||||
f /var/lib/systemd/linger/agent
|
||||
@@ -0,0 +1,44 @@
|
||||
# factory-etc.conf links what the image needs from /usr/share/factory/etc
|
||||
# (mkosi.finalize) into the empty /etc at boot, so updates to /usr take effect
|
||||
# in /etc too. The rest of the factory is unused package config. /etc itself
|
||||
# holds what the machine writes: passwd, shadow, group, machine-id, ld.so.cache,
|
||||
# /etc/systemd and the ssh host keys. systemd's own etc.conf sets up
|
||||
# os-release, nsswitch.conf and pam.d.
|
||||
#
|
||||
# /etc/systemd is filled from the presets at first boot: by PID 1 for system
|
||||
# units, and by mkosi.extra/usr/lib/systemd/system/preset-global.service for
|
||||
# user units.
|
||||
#
|
||||
# subuid and subgid are copied, because shadow-utils won't read them through a
|
||||
# link. Rootless podman needs them.
|
||||
C /etc/subgid
|
||||
C /etc/subuid
|
||||
|
||||
# /etc/ssh is a writable directory, because sshd-keygen writes the host keys
|
||||
# there at first boot.
|
||||
d /etc/ssh 0755
|
||||
L /etc/ssh/moduli
|
||||
L /etc/ssh/ssh_config
|
||||
L /etc/ssh/ssh_config.d
|
||||
L /etc/ssh/sshd_config
|
||||
L /etc/ssh/sshd_config.d
|
||||
|
||||
# authselect holds the PAM files that /etc/pam.d links to.
|
||||
L /etc/authselect
|
||||
L /etc/security
|
||||
L /etc/environment
|
||||
L /etc/login.defs
|
||||
L /etc/shells
|
||||
|
||||
# pki and ssl hold the CA certificates, and crypto-policies the TLS and ssh
|
||||
# settings.
|
||||
L /etc/pki
|
||||
L /etc/ssl
|
||||
L /etc/crypto-policies
|
||||
L /etc/bashrc
|
||||
L /etc/profile
|
||||
L /etc/profile.d
|
||||
L /etc/protocols
|
||||
L /etc/services
|
||||
L /etc/hostname
|
||||
L /etc/claude-code
|
||||
+4
-44
@@ -1,48 +1,8 @@
|
||||
#!/bin/bash
|
||||
# mkosi.finalize keeps the /etc that the packages and mkosi.extra/etc made in
|
||||
# /usr/share/factory/etc, because the image ships only /usr (mkosi.repart). It
|
||||
# writes /usr/lib/tmpfiles.d/factory-etc.conf, with which systemd-tmpfiles
|
||||
# links each entry into the writable, empty /etc at boot. Updates to /usr then
|
||||
# take effect in /etc too. /etc itself holds only what the machine writes:
|
||||
# passwd, shadow, group, machine-id and the ssh host keys.
|
||||
# /usr/share/factory/etc, because the image ships only /usr. At boot,
|
||||
# mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf links from it what /etc needs.
|
||||
set -euo pipefail
|
||||
|
||||
factory=$BUILDROOT/usr/share/factory/etc
|
||||
cp -a --no-target-directory --update=none "$BUILDROOT/etc" "$factory"
|
||||
|
||||
# skip holds what /etc keeps for itself, and what other tmpfiles.d files
|
||||
# already set up, such as /etc/os-release.
|
||||
skip=$(printf '%s\n' passwd group shadow gshadow machine-id ssh
|
||||
sed -n 's|^[^#][^ ]* */etc/\([^/ ]*\).*|\1|p' "$BUILDROOT"/usr/lib/tmpfiles.d/*.conf)
|
||||
|
||||
# link prints the tmpfiles line for /etc/$1. Some entries are copied instead:
|
||||
# a symlink, because a relative one would point somewhere else from the
|
||||
# factory, and subuid and subgid, because shadow-utils won't read them through
|
||||
# a link.
|
||||
#
|
||||
# systemd gets L+, which replaces a directory. At first boot, PID 1 applies the
|
||||
# presets before systemd-tmpfiles runs, and so makes /etc/systemd/system. That
|
||||
# would block the link, and with it /etc/systemd/user and later updates.
|
||||
link() {
|
||||
if [[ $1 == subuid || $1 == subgid || -L $factory/$1 ]]; then
|
||||
echo "C /etc/$1"
|
||||
elif [[ $1 == systemd ]]; then
|
||||
echo "L+ /etc/$1"
|
||||
else
|
||||
echo "L /etc/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
{
|
||||
echo "# Generated by mkosi.finalize."
|
||||
# Entries ending in - are backups, such as passwd-.
|
||||
for path in "$factory"/*; do
|
||||
f=${path##*/}
|
||||
[[ $f == *- ]] || grep -qxF "$f" <<< "$skip" || link "$f"
|
||||
done
|
||||
# /etc/ssh is a writable directory instead of one link, because sshd-keygen
|
||||
# writes the host keys there at first boot. Its other entries are linked one
|
||||
# by one, so they still get updates from /usr.
|
||||
echo "d /etc/ssh 0755"
|
||||
for path in "$factory"/ssh/*; do link "ssh/${path##*/}"; done
|
||||
} > "$BUILDROOT/usr/lib/tmpfiles.d/factory-etc.conf"
|
||||
cp -a --no-target-directory --update=none "$BUILDROOT/etc" \
|
||||
"$BUILDROOT/usr/share/factory/etc"
|
||||
@@ -4,6 +4,6 @@ Type=usr-verity
|
||||
Label=%M_%A_verity
|
||||
Verity=hash
|
||||
VerityMatchKey=usr
|
||||
SizeMinBytes=64M
|
||||
SizeMaxBytes=64M
|
||||
SizeMinBytes=16M
|
||||
SizeMaxBytes=16M
|
||||
SplitName=%t.%U
|
||||
@@ -3,6 +3,6 @@
|
||||
[Partition]
|
||||
Type=usr-verity
|
||||
Label=_empty
|
||||
SizeMinBytes=64M
|
||||
SizeMaxBytes=64M
|
||||
SizeMinBytes=16M
|
||||
SizeMaxBytes=16M
|
||||
SplitName=-
|
||||
@@ -1,6 +1,5 @@
|
||||
# claude-code.repo adds Anthropic's package repository, stable channel. mkosi
|
||||
# uses it to install the claude-code package (mkosi.conf). The key's
|
||||
# fingerprint is 31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE.
|
||||
# uses it to install the claude-code package (mkosi.conf).
|
||||
[claude-code]
|
||||
name=Claude Code
|
||||
baseurl=https://downloads.claude.ai/claude-code/rpm/stable
|
||||
|
||||
Reference in new issue
Block a user