selected := get-environment-variable("VPAC_TARGET_ARCH") arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" } arm := string=?("aarch64", arch) revision := if arm { "7f173671b6d1f1a8ceda2c693eadbb0eb58c4aa4" } else { "c34a6707e1d8d3a23d0b1bfe6e6dbb16290e4f75" } repo := string-append("vinix-", revision) support := string-append(repo, "/build-support") raw := string-append("https://raw.githubusercontent.com/vlang/vinix/", revision) defpkgbuild(vinix-desktop-init, #:pkgname, "vinix-desktop-init", #:pkgver, if arm { "20261130" } else { "20261128" }, #:pkgrel, 1, #:pkgdesc, "Vinix desktop PID 1 for the default release image", #:arch, [#:x86-64, #:aarch64], #:url, "https://github.com/vlang/vinix", #:license, "GPL-2.0-only", #:depends, ["busybox", "zsh", "vinix-filesystem"], #:provides, ["init"], #:conflicts, ["busybox-init"], #:source, if arm { list(string-append(repo, ".tar.gz::https://codeload.github.com/vlang/vinix/tar.gz/", revision), "check-init.py") } else { list(string-append(raw, "/build-support/init-amd64/desktop-init"), string-append(raw, "/LICENSE")) }, #:sha256sums, if arm { list("4ee336414b9b1228be8f4ac8ea691914e71bf5ae34e9db40da66741ea4ffbded", "84b1cce0288d66b83b3eb663fe80de1a1da2c1d429c002e4aabdf08d009692e4") } else { list("167b40c6491947b9ddb5330fa7cf1e02d5a636eb6569ee3d6c6150d4d0fd94a4", "8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643") }, #:build, fn() { if arm { init := string-append(support, "/init-aarch64") host-libraries := get-environment-variable("VINIX_HOST_LIBRARY_PATH") run("env", string-append("LIBRARY_PATH=", if string?(host-libraries) { host-libraries } else { "" }), string-append(support, "/run-v-tool.sh"), string-append(init, "/compile_init.v"), "desktop", string-append(srcdir(), "/desktop-init.c")) ; The raw syscall implementation supplies its own stdio and memory ABI. ; Use Clang's freestanding headers for stdint and stddef. run("clang", "--target=aarch64-linux-none", "-nostdlibinc", "-nostdlib", "-ffreestanding", "-O2", "-fno-stack-protector", "-fno-builtin", "-ffunction-sections", "-fdata-sections", "-I", init, "-c", "desktop-init.c", "-o", "desktop-init.o") run("clang", "--target=aarch64-linux-none", "-c", string-append(init, "/syscall_abi.S"), "-o", "syscall_abi.o") run("ld.lld", "-m", "aarch64elf", "--nostdlib", "-static", "--gc-sections", "-z", "max-page-size=16384", "-o", "desktop-init", "desktop-init.o", "syscall_abi.o") run("v", "-os", "linux", "-arch", "arm64", "-gc", "none", "-manualfree", "-d", "no_backtrace", "-d", "no_segfault_handler", "-o", "desktop-watchdog.c", string-append(init, "/desktopwatch/main.v")) run("vinix-cc", "-D_GNU_SOURCE", "-O2", "-static", "-fno-stack-protector", "-o", "desktop-watchdog", "desktop-watchdog.c") } }, #:check, fn() { if arm { run("python3", "check-init.py") } else { run("sh", "-n", "desktop-init") } }, #:package, fn() { run("install", "-Dm755", "desktop-init", string-append(pkgdir(), "/sbin/init")) if arm { run("install", "-Dm755", "desktop-init", string-append(pkgdir(), "/usr/libexec/vinix-desktop-init")) run("install", "-Dm755", "desktop-watchdog", string-append(pkgdir(), "/usr/libexec/vinix-desktop-watchdog")) } license-file := if arm { string-append(repo, "/LICENSE") } else { "LICENSE" } run("install", "-Dm644", license-file, string-append(pkgdir(), "/usr/share/licenses/vinix-desktop-init/LICENSE")) })