aboutsummaryrefslogtreecommitdiffhomepage
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
parent2a9aa3b4007a73a6c9d4608cb9a8822247881fd6 (diff)
internal/rosa/package: migrate hakurei
Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/rosa/hakurei.go121
-rw-r--r--internal/rosa/hakurei_current.go26
-rw-r--r--internal/rosa/hakurei_release.go18
-rw-r--r--internal/rosa/images.go26
-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
7 files changed, 235 insertions, 190 deletions
diff --git a/internal/rosa/hakurei.go b/internal/rosa/hakurei.go
deleted file mode 100644
index ff56c1ea..00000000
--- a/internal/rosa/hakurei.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package rosa
-
-import "hakurei.app/internal/pkg"
-
-func (t Toolchain) newHakurei(
- suffix, build, check, install string,
- withHostname bool,
-) pkg.Artifact {
- hostname := `
-echo 'Building test helper (hostname).'
-go build -o /bin/hostname /usr/src/hostname/main.go
-`
- if !withHostname {
- hostname = ""
- }
-
- name := "hakurei" + suffix
- return t.NewPackage(name, hakureiVersion, t.NewPatchedSource(
- "hakurei-"+hakureiVersion, hakureiSource, false, hakureiPatches...,
- ), &PackageAttr{
- EnterSource: true,
- Writable: true,
- Env: []string{
- "CGO_ENABLED=1",
- "GOCACHE=/tmp/gocache",
- "CC=clang -O3 -Werror",
- },
-
- Paths: []pkg.ExecPath{pkg.Path(AbsUsrSrc.Append("hostname", "main.go"), false, pkg.NewFile(
- "hostname.go",
- []byte(`
-package main
-
-import "os"
-
-func main() {
- if name, err := os.Hostname(); err != nil {
- panic(err)
- } else {
- os.Stdout.WriteString(name)
- }
-}
-`),
- ))},
- }, &GenericHelper{
- InPlace: true,
- Build: hostname + `
-HAKUREI_VERSION='v` + hakureiVersion + `'
-` + build,
- Check: check,
- Install: install,
- },
- _go,
- H("pkg-config"),
-
- H("libseccomp"),
- H("acl"),
- H("fuse"),
- H("xcb"),
- H("wayland"),
- H("wayland-protocols"),
-
- _kernelHeaders,
- )
-}
-func init() {
- meta := Metadata{
- Name: "hakurei",
- Description: "low-level userspace tooling for Rosa OS",
- Website: "https://hakurei.app",
- Version: hakureiVersion,
-
- ID: 388834,
- }
- native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
- return &meta, t.newHakurei("", `
-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=${HAKUREI_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
-`, `
-echo '##### Testing hakurei.'
-go test -ldflags='-buildid= -linkmode external -extldflags=-static' ./...
-echo
-`, `
-mkdir -p /work/system/bin/
-(cd /work/system/libexec/hakurei && mv \
- hakurei \
- sharefs \
- ../../bin/)
-`, true)
- })
-}
-func init() {
- meta := Metadata{
- Name: "hakurei-dist",
- Description: "low-level userspace tooling for Rosa OS (distribution tarball)",
- Website: "https://hakurei.app",
- Version: hakureiVersion,
- }
- native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
- name := "all"
- if t.opts&OptSkipCheck != 0 {
- name = "make"
- }
- return &meta, t.newHakurei("-dist", `
-export HAKUREI_VERSION
-DESTDIR=/work ./`+name+`.sh
-`, "", "", true)
- })
-}
diff --git a/internal/rosa/hakurei_current.go b/internal/rosa/hakurei_current.go
deleted file mode 100644
index 4ad23772..00000000
--- a/internal/rosa/hakurei_current.go
+++ /dev/null
@@ -1,26 +0,0 @@
-//go:build current
-
-package rosa
-
-import (
- _ "embed"
-
- "hakurei.app/internal/pkg"
-)
-
-const hakureiVersion = "1.0-current"
-
-// hakureiSourceTarball is a compressed tarball of the hakurei source code.
-//
-//go:generate tar -zc -C ../.. --exclude .git --exclude *.tar.gz -f hakurei_current.tar.gz .
-//go:embed hakurei_current.tar.gz
-var hakureiSourceTarball []byte
-
-// hakureiSource is the source code at the time this package is compiled.
-var hakureiSource = pkg.NewTar(pkg.NewFile(
- "hakurei-current.tar.gz",
- hakureiSourceTarball,
-), pkg.TarGzip)
-
-// hakureiPatches are patches applied against the compile-time source tree.
-var hakureiPatches []KV
diff --git a/internal/rosa/hakurei_release.go b/internal/rosa/hakurei_release.go
deleted file mode 100644
index bdf710ed..00000000
--- a/internal/rosa/hakurei_release.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//go:build !current
-
-package rosa
-
-import "hakurei.app/internal/pkg"
-
-const hakureiVersion = "0.4.2"
-
-// hakureiSource is the source code of a hakurei release.
-var hakureiSource = newTar(
- "https://git.gensokyo.uk/rosa/hakurei/archive/"+
- "v"+hakureiVersion+".tar.gz",
- "jadgaOrxv5ABGvzQ_Rk0aPGz7U8K-427TbMhQNQ32scSizEnlR44Pu7NoWYWVZWq",
- pkg.TarGzip,
-)
-
-// hakureiPatches are patches applied against a hakurei release.
-var hakureiPatches []KV
diff --git a/internal/rosa/images.go b/internal/rosa/images.go
index 617b5b9d..7635dc6c 100644
--- a/internal/rosa/images.go
+++ b/internal/rosa/images.go
@@ -5,30 +5,6 @@ import (
"hakurei.app/internal/pkg"
)
-var _earlyInit = H("earlyinit")
-
-func init() {
- meta := Metadata{
- Name: "earlyinit",
- Description: "Rosa OS initramfs init program",
- Version: Unversioned,
- }
- native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
- return &meta, t.newHakurei("-early-init", `
-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=${HAKUREI_VERSION}
-" ./cmd/earlyinit
-echo
-`, "", "", false)
- })
-}
-
func init() {
meta := Metadata{
Name: "system-image",
@@ -61,7 +37,7 @@ func init() {
native.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
return &meta, t.New("initramfs", TNoToolchain, t.Append(nil,
_zstd,
- _earlyInit,
+ H("earlyinit"),
H("gen_init_cpio"),
), nil, nil, `
gen_init_cpio -t 4294967295 -c /usr/src/initramfs | zstd > /work/initramfs.zst
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 ];
+}