- Follow AGENTS.md style: headers start with the file's name, short notes are full sentences, comments within 80 columns. - Build with mkosi's tools tree, pinned to the image's release (ToolsTreeRelease=%r): rawhide's repositories made the image rawhide. - Incremental builds with mkosi.cache/ for faster local rebuilds. - Hostname= instead of systemd.hostname= on the kernel command line. - mkosi.finalize: bash, no cd, and L+ for /etc/systemd. PID 1 applies the presets at first boot and made /etc/systemd/system, which blocked the link, so /etc/systemd/user (the user's D-Bus) was missing. - Disable homed, userdbd and nsresourced with presets instead of deleting their units. Drop modules the kernel has built in. - mkosi.version adds the git commit to the version. - One dev container per worktree or session in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
26 files changed
+205
-243
No files matched your search
@@ -5,31 +5,37 @@ every change.
|
||||
|
||||
## Style
|
||||
|
||||
- Keep it simple. Prefer fewer files, fewer lines and the defaults. Delete what
|
||||
isn't needed.
|
||||
- Keep it simple. Prefer fewer files and fewer lines. Delete what isn't
|
||||
needed.
|
||||
- Follow the defaults and conventions of each tool and language. Only set an
|
||||
option when the default doesn't work, and say why.
|
||||
- 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 by path instead of
|
||||
repeating it.
|
||||
- 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
|
||||
share it or pull it in from elsewhere.
|
||||
|
||||
### File header
|
||||
|
||||
Every file that allows comments starts with a header. It goes after the
|
||||
shebang, if there is one:
|
||||
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:
|
||||
|
||||
```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.
|
||||
#!/bin/bash
|
||||
# mkosi.version prints the build time in UTC (YYYYMMDDhhmm) and the git
|
||||
# commit. Every build gets a higher version than the one before, which is how
|
||||
# systemd-sysupdate tells that an update is newer. The commit tells which
|
||||
# source an image was built from.
|
||||
```
|
||||
|
||||
- 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.
|
||||
- The first sentence starts with the name of the part the file is, and says
|
||||
what it does. That is the name the language or tool uses for it, such as a
|
||||
file name or a package name.
|
||||
- The rest says 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.
|
||||
@@ -38,10 +44,13 @@ the file that uses them.
|
||||
|
||||
- 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.
|
||||
- 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 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.`
|
||||
- Separate paragraphs and lists with a line holding only the comment
|
||||
character.
|
||||
- Wrap comments at 80 columns.
|
||||
|
||||
## Testing
|
||||
@@ -51,15 +60,13 @@ run mkosi in a privileged podman container that boots systemd:
|
||||
|
||||
```sh
|
||||
podman build -t mkosi-vm - <<'END'
|
||||
FROM registry.fedoraproject.org/fedora:45
|
||||
RUN dnf install -y mkosi qemu-kvm-core edk2-ovmf systemd-repart swtpm \
|
||||
openssh-clients socat && \
|
||||
dnf install -y $(mkosi dependencies)
|
||||
FROM registry.fedoraproject.org/fedora:latest
|
||||
RUN dnf install -y mkosi git-core
|
||||
CMD ["/sbin/init"]
|
||||
END
|
||||
podman run -d --name mkosi --privileged --systemd=always -v <repo>:/repo \
|
||||
-v mkosi-cache:/root/.cache/mkosi -w /repo mkosi-vm
|
||||
podman exec mkosi mkosi genkey # once, if there is no mkosi.key
|
||||
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 mkosi ssh -- systemctl --failed
|
||||
```
|
||||
@@ -76,5 +83,5 @@ with "has not been built yet". To boot an existing build without a rebuild, pin
|
||||
its version (from `mkosi.output/agent_<version>.raw`):
|
||||
|
||||
```sh
|
||||
mkosi --image-version 202611171816 vm
|
||||
mkosi --image-version 202611171816.c80e843 vm
|
||||
```
|
||||
Reference in new issue
Block a user