package hakurei-source { description = "hakurei source tree"; exclude = true; version# = "0.4.10"; output = remoteGit { url = "https://src.rosa.moe/hakurei"; tag = "v"+version; checksum = "SZdto_lQCgwebCqUHJREQcHwwO1pHn3euOwFvXYEri0G-46zUhx0hX4buFt2XvkS"; }; } package hakurei { description = "low-level userspace tooling for Rosa OS"; website = "https://hakurei.app"; anitya = 388834; source = hakurei-source; enterSource = true; writable = true; chmod = true; ccommon = true; env = [ "CGO_ENABLED=1", "GOCACHE=/tmp/gocache", "CC=clang -O3 -Werror", ]; exec = generic { chdir = false; cross = "\x00"; build = ` mkdir -p /work`+prefix+`/bin/ echo "Building hakurei for $(go env GOOS)/`+arch+`." go generate ./... GOARCH='`+arch+`' go build -trimpath -tags=rosa -o /work`+prefix+`/bin -ldflags="-s -w -buildid= -linkmode external -extldflags=-static -X hakurei.app/internal/info.buildVersion=$(cat cmd/dist/VERSION) -X hakurei.app/internal/info.hakureiPath=`+prefix+`/bin/hakurei -X hakurei.app/internal/info.hsuPath=`+prefix+`/bin/hsu " ./cmd/hakurei ./cmd/sharefs echo "Building hsu for $(go env GOOS)/$(go env GOARCH)." GOARCH='`+arch+`' CGO_ENABLED=0 go build -trimpath -tags=rosa -o /work`+prefix+`/bin -ldflags="-s -w -buildid= -X main.hakureiPath=`+prefix+`/bin/hakurei " ./cmd/hsu`; check = ` echo echo '##### Testing hakurei.' GOARCH='`+arch+`' go test`+arch { default = ""; cross = " "+ "-tags=qemu "+ "-exec='qemu-"+linuxArch+" -L "+prefix+"/"+arch+"'"; }+` -ldflags='`+arch { default = "-buildid= -linkmode external -extldflags=-static"; cross = "-buildid= -linkmode internal"; }+`' ./...`; install = ` chmod 4511 /work`+prefix+`/bin/hsu `; }; tools = [ go, pkgconf, net-tools, acl, wayland, wayland-protocols, ]; inputs = [ libseccomp, acl, fuse, xcb, wayland, wayland-protocols, util-linux, kernel-headers, ]; runtime = nil; native = [ qemu ]; } package hakurei-dist { description = "low-level userspace tooling for Rosa OS (distribution tarball)"; website = "https://hakurei.app"; source = hakurei-source; enterSource = true; writable = true; chmod = true; ccommon = true; env = [ "CGO_ENABLED=1", "GOCACHE=/tmp/gocache", "CC=clang -O3 -Werror", ]; exec = generic { chdir = false; cross = ` unset CC CXX export \ HAKUREI_ARCH='`+arch+`' \ HAKUREI_SYSROOT='`+prefix+`/`+arch+`' \ HAKUREI_EMULATOR='qemu-`+linuxArch+` -L `+prefix+`/`+arch+`' `; build = ` NAME=make`; check = ` NAME=all`; install = ` DESTDIR=/work "./${NAME}.sh" `; }; tools = [ go, pkgconf, net-tools, acl, wayland, wayland-protocols, ]; inputs = [ libseccomp, acl, fuse, xcb, wayland, wayland-protocols, util-linux, kernel-headers, ]; runtime = nil; native = [ qemu ]; } package hakurei-dist-race { description = "low-level userspace tooling for Rosa OS (distribution tarball with race instrument)"; website = "https://hakurei.app"; source = hakurei-source; enterSource = true; writable = true; chmod = true; env = [ "CGO_ENABLED=1", "GOCACHE=/tmp/gocache", "CC=clang -O3 -Werror", "HAKUREI_RACE=1", ]; exec = generic { chdir = false; build = ` NAME=make`; check = ` NAME=all`; install = ` DESTDIR=/work "./${NAME}.sh" `; }; tools = [ go, pkgconf, net-tools, acl, ]; inputs = [ libseccomp, acl, fuse, xcb, wayland, wayland-protocols, util-linux, kernel-headers, ]; runtime = nil; } package earlyinit { description = "Rosa OS initramfs init program"; exclude = true; source = hakurei-source; enterSource = true; writable = true; chmod = true; ccommon = true; env = [ "CGO_ENABLED=1", "GOCACHE=/tmp/gocache", "CC=clang -O3 -Werror", ]; exec = generic { chdir = false; cross = ` export GOARCH='`+arch+`' `; build = ` go build -trimpath -o /work/ -ldflags="-s -w -buildid= -linkmode external -extldflags=-static -X hakurei.app/internal/info.buildVersion=$(cat cmd/dist/VERSION) " ./cmd/earlyinit`; }; tools = [ go ]; } package system-image-test { description = "Rosa OS system image for hakurei-test"; version = unversioned; exclude = true; extra = [ musl, mksh, toybox, hakurei, xdg-dbus-proxy, kmod, kernel, acl, util-linux, noto, sway, mako, libnotify, wayland-utils, pulseaudio-client, xset, foot, dbus, pipewire, wireplumber, ]; overlay = "/mnt"; exec = generic { cross = "\x00"; build = ` mksquashfs \ /mnt`+prefix+` \ /work/system.img \ -all-root`; }; tools = [ squashfs-tools ]; } package hakurei-tests { description = "hakurei integration test suite in a Rosa OS guest"; exclude = true; source = hakurei-source; enterSource = true; env = [ "GOCACHE=/tmp/gocache", "CC=clang -O3 -Werror", ]; extra = [ kernel, kernel-source, initramfs-image, system-image-test, ]; exec = generic { chdir = false; cross = ` export GOARCH=`+arch+` `; build = ` go build \ -trimpath \ -o /work/ \ -tags=testsuite,rosa \ ./cmd/hakurei/testsuite ../extra/kernel-source/scripts/extract-vmlinux \ ../extra/kernel/`+arch { default = "vmlinuz.efi"; amd64 = "bzImage"; }+` > /tmp/kernel `; check = ` qemu-system-`+linuxArch+` \ `+arch { default = "-enable-kvm"; cross = ""; }+` \ -machine `+arch { default = "virt"; amd64 = "q35"; }+` \ -cpu `+arch { default = "host"; cross = "max"; }+` \ -serial stdio \ -m 4G \ -smp `+jobsE+` \ -kernel /tmp/kernel \ -initrd ../extra/initramfs-image/initramfs.zst \ -drive file=../extra/system-image-test/system.img,readonly=on,format=raw,if=virtio \ -virtfs local,path=/work,mount_tag=rosa,security_model=none,readonly=on \ -append 'console=`+arch { default = "ttyS0"; arm64 = "ttyAMA0"; }+`,115200n8 -- strict no_recover no_remount bindable_misc mount_tmp 9p early_hsurc system="`+arch { default = "/devices/pci*/*/virtio*/block/*"; arm64 = "/devices/platform/*.pcie/pci*/*/virtio*/block/*"; }+`" initial="/host/testsuite"' | stdbuf -o 0 tr -d '\r' | tee /dev/stderr | \ (grep -q -m 1 'unable to continue, please reboot and resolve the problem manually' && kill -KILL "$$" || true) `; }; tools = [ go, qemu, coreutils, ]; }