SchOS/shell.nix
Nexoniarz 6f3175d8a5 flock, fcntl record locks
There were none: fcntl answered F_SETLK with EINVAL and flock was not a
system call. Alpine's apk, which runs unmodified on SchOS through
Alpine's own musl, locks its database before reading it and stopped
there.

kernel/fs/lock.c keeps one table of advisory locks keyed by (dev, inum):
flock() for the whole file, owned by the open file description;
F_SETLK/F_SETLKW/F_GETLK for byte ranges, owned by the process and
released when it closes any descriptor on the file or exits; and the
F_OFD_* forms, ranges owned by the description. flock and record locks
do not see each other, as on Linux. Waiters sleep until any release and
are interrupted by a signal.

cmd/locktest checks each between a parent and a child, including range
splitting, F_GETLK's report, and a blocked waiter being woken.

shell.nix gains pkg-config, meson, ninja, m4, bison, flex and xz, for
the X ports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
2026-10-24 12:22:36 +02:00

60 lines
2.2 KiB
Nix

# A development shell with everything docs/guides/building.md asks for.
#
# nix-shell # then: make, make qemu, make iso
#
# Why this exists: the UEFI loader is the one part that genuinely cannot be
# built without clang and lld. `make` falls back to the GNU toolchain for the
# kernel, so a machine with only gcc gets a kernel that builds and a loader that
# silently stays whatever it was -- which is exactly the failure that left a
# stale boot splash on this tree for half a day.
#
# Pinned to whatever nixpkgs the host is on rather than to a flake input, on
# purpose: this is a convenience for one developer's machine, not a
# reproducibility claim. If it ever needs to be the latter it wants a flake.
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
name = "schos";
nativeBuildInputs = with pkgs; [
# The cross-compiler, and the reason this file exists. clang targets
# bare-metal ELF, 16-bit code and PE/COFF from one install; lld-link is what
# produces BOOTX64.EFI.
clang
lld
llvm # llvm-objcopy, llvm-objdump
# The host compiler, for tools/ -- mkfs, mkschfs, the SchFS suites. Must be
# a real Unix compiler: those need <unistd.h> and <dirent.h>.
gcc
gnumake
perl # generates the interrupt vector table
python3 # boot logo, crash-screen QR, mklogo
qemu # make qemu, and every test harness
OVMF # firmware for the UEFI path; the Makefile searches for it
xorriso # make iso
mtools # ESP staging
curl gnutar # fetching ports
xz # ...some of which are .tar.xz
# The X ports (docs/plan/xorg.md): half of them configure with autotools
# and half with meson, and all of them ask pkg-config for each other.
# libxcb generates its protocol code with python; libX11 and xkbcomp need
# m4 and bison at build time.
pkg-config
meson
ninja
gnum4
bison
flex
];
shellHook = ''
echo "schos: clang $(clang --version | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')," \
"$(qemu-system-x86_64 --version | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
echo " make | make qemu | make schfs-check | make iso"
'';
}