aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/package
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-22 00:07:25 +0900
committerOphestra <cat@gensokyo.uk>2026-05-22 00:07:25 +0900
commitf3a6f7ddf97f6e681b2db1318b47d51ab86a5c13 (patch)
treed8b7cb2ff733e37f9926b24a0f7b0e0e4e74206f /internal/rosa/package
parent2a9aa3b4007a73a6c9d4608cb9a8822247881fd6 (diff)
internal/rosa/package: migrate hakurei
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/package')
-rw-r--r--internal/rosa/package/hakurei/2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch61
-rw-r--r--internal/rosa/package/hakurei/hostname11
-rw-r--r--internal/rosa/package/hakurei/package.az162
3 files changed, 234 insertions, 0 deletions
diff --git a/internal/rosa/package/hakurei/2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch b/internal/rosa/package/hakurei/2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch
new file mode 100644
index 00000000..58389048
--- /dev/null
+++ b/internal/rosa/package/hakurei/2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch
@@ -0,0 +1,61 @@
+From 2a9aa3b4007a73a6c9d4608cb9a8822247881fd6 Mon Sep 17 00:00:00 2001
+From: Ophestra <cat@gensokyo.uk>
+Date: Thu, 21 May 2026 23:34:50 +0900
+Subject: [PATCH] cmd/dist: include version in release
+
+This makes HAKUREI_VERSION optional during build.
+
+Signed-off-by: Ophestra <cat@gensokyo.uk>
+---
+ cmd/dist/VERSION | 1 +
+ cmd/dist/main.go | 7 ++++++-
+ flake.nix | 1 -
+ 3 files changed, 7 insertions(+), 2 deletions(-)
+ create mode 100644 cmd/dist/VERSION
+
+diff --git a/cmd/dist/VERSION b/cmd/dist/VERSION
+new file mode 100644
+index 00000000..0eec13e4
+--- /dev/null
++++ b/cmd/dist/VERSION
+@@ -0,0 +1 @@
++v0.4.2
+diff --git a/cmd/dist/main.go b/cmd/dist/main.go
+index 9ed7f2f8..d876cf83 100644
+--- a/cmd/dist/main.go
++++ b/cmd/dist/main.go
+@@ -18,8 +18,13 @@ import (
+ "os/signal"
+ "path/filepath"
+ "runtime"
++ "strings"
+ )
+
++//go:generate sh -c "git describe --tags > VERSION"
++//go:embed VERSION
++var version string
++
+ // getenv looks up an environment variable, and returns fallback if it is unset.
+ func getenv(key, fallback string) string {
+ if v, ok := os.LookupEnv(key); ok {
+@@ -47,7 +52,7 @@ func main() {
+
+ verbose := os.Getenv("VERBOSE") != ""
+ runTests := os.Getenv("HAKUREI_DIST_MAKE") == ""
+- version := getenv("HAKUREI_VERSION", "untagged")
++ version = getenv("HAKUREI_VERSION", strings.TrimSpace(version))
+ prefix := getenv("PREFIX", "/usr")
+ destdir := getenv("DESTDIR", "dist")
+
+diff --git a/flake.nix b/flake.nix
+index 4de35204..09520be2 100644
+--- a/flake.nix
++++ b/flake.nix
+@@ -139,7 +139,6 @@
+ GOCACHE="$(mktemp -d)" \
+ PATH="${pkgs.pkgsStatic.musl.bin}/bin:$PATH" \
+ DESTDIR="$out" \
+- HAKUREI_VERSION="v${hakurei.version}" \
+ ./all.sh
+ '';
+ }
diff --git a/internal/rosa/package/hakurei/hostname b/internal/rosa/package/hakurei/hostname
new file mode 100644
index 00000000..de72c9d1
--- /dev/null
+++ b/internal/rosa/package/hakurei/hostname
@@ -0,0 +1,11 @@
+package main
+
+import "os"
+
+func main() {
+ if name, err := os.Hostname(); err != nil {
+ panic(err)
+ } else {
+ os.Stdout.WriteString(name)
+ }
+}
diff --git a/internal/rosa/package/hakurei/package.az b/internal/rosa/package/hakurei/package.az
new file mode 100644
index 00000000..f0d89150
--- /dev/null
+++ b/internal/rosa/package/hakurei/package.az
@@ -0,0 +1,162 @@
+package hakurei-source {
+ description = "hakurei source tree";
+ exclude = true;
+
+ version* = "0.4.2";
+ output = remoteTar {
+ url = "https://git.gensokyo.uk/rosa/hakurei/archive/"+
+ "v"+version+".tar.gz";
+ checksum = "jadgaOrxv5ABGvzQ_Rk0aPGz7U8K-427TbMhQNQ32scSizEnlR44Pu7NoWYWVZWq";
+ compress = gzip;
+ };
+}
+
+package hakurei {
+ description = "low-level userspace tooling for Rosa OS";
+ website = "https://hakurei.app";
+ anitya = 388834;
+
+ source = hakurei-source;
+ patches = [ "2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch" ];
+ enterSource = true;
+ writable = true;
+ chmod = true;
+
+ env = [
+ "CGO_ENABLED=1",
+ "GOCACHE=/tmp/gocache",
+ "CC=clang -O3 -Werror",
+ ];
+
+ files = {
+ "hostname/main.go": "hostname";
+ };
+
+ exec = generic {
+ inPlace = true;
+ build = `
+echo 'Building test helper (hostname).'
+go build -o /bin/hostname /usr/src/hostname/main.go
+
+mkdir -p /work/system/libexec/hakurei/
+
+echo "Building hakurei for $(go env GOOS)/$(go env GOARCH)."
+go generate ./...
+go build -trimpath -tags=rosa -o /work/system/libexec/hakurei -ldflags="-s -w
+ -buildid=
+ -linkmode external
+ -extldflags=-static
+ -X hakurei.app/internal/info.buildVersion=$(cat cmd/dist/VERSION)
+ -X hakurei.app/internal/info.hakureiPath=/system/bin/hakurei
+ -X hakurei.app/internal/info.hsuPath=/system/bin/hsu
+ -X main.hakureiPath=/system/bin/hakurei
+" ./...
+echo`;
+ check = `
+echo '##### Testing hakurei.'
+go test -ldflags='-buildid= -linkmode external -extldflags=-static' ./...
+echo`;
+ install = `
+mkdir -p /work/system/bin/
+(cd /work/system/libexec/hakurei && mv \
+ hakurei \
+ sharefs \
+ ../../bin/)
+`;
+ };
+
+ inputs = [
+ go,
+ pkg-config,
+
+ libseccomp,
+ acl,
+ fuse,
+ xcb,
+ wayland,
+ wayland-protocols,
+ kernel-headers,
+ ];
+}
+
+package hakurei-dist {
+ description = "low-level userspace tooling for Rosa OS (distribution tarball)";
+ website = "https://hakurei.app";
+
+ source = hakurei-source;
+ patches = [ "2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch" ];
+ enterSource = true;
+ writable = true;
+ chmod = true;
+
+ env = [
+ "CGO_ENABLED=1",
+ "GOCACHE=/tmp/gocache",
+ "CC=clang -O3 -Werror",
+ ];
+
+ files = {
+ "hostname/main.go": "hostname";
+ };
+
+ exec = generic {
+ inPlace = true;
+ build = `
+echo 'Building test helper (hostname).'
+go build -o /bin/hostname /usr/src/hostname/main.go
+
+NAME=make`;
+ check = `
+NAME=all`;
+ install = `
+DESTDIR=/work "./${NAME}.sh"
+`;
+ };
+
+ inputs = [
+ go,
+ pkg-config,
+
+ libseccomp,
+ acl,
+ fuse,
+ xcb,
+ wayland,
+ wayland-protocols,
+ kernel-headers,
+ ];
+}
+
+package earlyinit {
+ description = "Rosa OS initramfs init program";
+ exclude = true;
+
+ source = hakurei-source;
+ patches = [ "2a9aa3b4007a73a6c9d4608cb9a8822247881fd6.patch" ];
+ enterSource = true;
+ writable = true;
+ chmod = true;
+
+ env = [
+ "CGO_ENABLED=1",
+ "GOCACHE=/tmp/gocache",
+ "CC=clang -O3 -Werror",
+ ];
+
+ exec = generic {
+ inPlace = true;
+ build = `
+mkdir -p /work/system/libexec/hakurei/
+
+echo '# Building earlyinit.'
+go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w
+ -buildid=
+ -linkmode external
+ -extldflags=-static
+ -X hakurei.app/internal/info.buildVersion=$(cat cmd/dist/VERSION)
+" ./cmd/earlyinit
+echo`;
+ };
+
+ inputs = [ go ];
+}