diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index dc90a7549928..b8914e4d3a95 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -154,6 +154,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - `services.homepage-dashboard` now takes it's configuration using native Nix expressions, rather than dumping templated configurations into `/var/lib/homepage-dashboard` where they were previously managed manually. There are now new options which allow the configuration of bookmarks, services, widgets and custom CSS/JS natively in Nix. +- `hare` may now be cross-compiled. For that to work, however, `haredoc` needed to stop being built together with it. Thus, the latter is now its own package with the name of `haredoc`. + - The legacy and long deprecated systemd target `network-interfaces.target` has been removed. Use `network.target` instead. - `services.frp.settings` now generates the frp configuration file in TOML format as [recommended by upstream](https://github.com/fatedier/frp#configuration-files), instead of the legacy INI format. This has also introduced other changes in the configuration file structure and options. diff --git a/pkgs/by-name/ha/hare/002-dont-build-haredoc.patch b/pkgs/by-name/ha/hare/002-dont-build-haredoc.patch new file mode 100644 index 000000000000..0e921477766e --- /dev/null +++ b/pkgs/by-name/ha/hare/002-dont-build-haredoc.patch @@ -0,0 +1,43 @@ +diff --git a/Makefile b/Makefile +index 2482be1f..9d58bc81 100644 +--- a/Makefile ++++ b/Makefile +@@ -5,7 +5,7 @@ all: + include config.mk + include makefiles/$(PLATFORM).$(ARCH).mk + +-all: $(BINOUT)/hare $(BINOUT)/haredoc docs ++all: $(BINOUT)/hare docs + + HARE_DEFINES = \ + -D PLATFORM:str='"$(PLATFORM)"' \ +@@ -79,11 +79,10 @@ docs: \ + docs/haredoc.1 \ + docs/hare-run.1 \ + docs/hare-test.1 \ +- docs/haredoc.5 \ + docs/hare-module.5 + +-MAN1 = hare hare-build hare-cache hare-deps haredoc hare-run hare-test +-MAN5 = haredoc hare-module ++MAN1 = hare hare-build hare-cache hare-deps hare-run hare-test ++MAN5 = hare-module + + bootstrap: + @BINOUT=$(BINOUT) ./scripts/genbootstrap +@@ -104,7 +103,6 @@ install-cmd: + '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1' \ + '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man5' + install -m755 '$(BINOUT)/hare' '$(DESTDIR)$(BINDIR)/hare' +- install -m755 '$(BINOUT)/haredoc' '$(DESTDIR)$(BINDIR)/haredoc' + for i in $(MAN1); do install -m644 docs/$$i.1 '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done + for i in $(MAN5); do install -m644 docs/$$i.5 '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done + +@@ -115,7 +113,6 @@ install-mods: + + uninstall: + rm -- '$(DESTDIR)$(BINDIR)/hare' +- rm -- '$(DESTDIR)$(BINDIR)/haredoc' + for i in $(MAN1); do rm -- '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done + for i in $(MAN5); do rm -- '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done + rm -r -- '$(DESTDIR)$(STDLIB)' diff --git a/pkgs/by-name/ha/hare/package.nix b/pkgs/by-name/ha/hare/package.nix index 9468e049c4e5..49e4d91db7f5 100644 --- a/pkgs/by-name/ha/hare/package.nix +++ b/pkgs/by-name/ha/hare/package.nix @@ -9,6 +9,7 @@ , scdoc , tzdata , substituteAll +, fetchpatch , callPackage , enableCrossCompilation ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.is64bit) , pkgsCross @@ -32,6 +33,11 @@ in let arch = stdenv.hostPlatform.uname.processor; + qbePlatform = { + x86_64 = "amd64_sysv"; + aarch64 = "arm64"; + riscv64 = "rv64"; + }.${arch}; platform = lib.toLower stdenv.hostPlatform.uname.system; embeddedOnBinaryTools = let @@ -74,6 +80,14 @@ stdenv.mkDerivation (finalAttrs: { src = ./001-tzdata.patch; inherit tzdata; }) + # Use correct comment syntax for debug+riscv64. + (fetchpatch { + url = "https://git.sr.ht/~sircmpwn/hare/commit/80e45e4d931a6e90d999846b86471cac00d2a6d5.patch"; + hash = "sha256-S7nXpiO0tYnKpmpj+fLkolGeHb1TrmgKlMF0+j0qLPQ="; + }) + # Don't build haredoc since it uses the build `hare` bin, which breaks + # cross-compilation. + ./002-dont-build-haredoc.patch ]; nativeBuildInputs = [ @@ -95,6 +109,10 @@ stdenv.mkDerivation (finalAttrs: { "PREFIX=${builtins.placeholder "out"}" "ARCH=${arch}" "VERSION=${finalAttrs.version}-nixpkgs" + "QBEFLAGS=-t${qbePlatform}" + "CC=${stdenv.cc.targetPrefix}cc" + "AS=${stdenv.cc.targetPrefix}as" + "LD=${stdenv.cc.targetPrefix}ld" # Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does # not follow the FHS. "HAREPATH=$(SRCDIR)/hare/stdlib" diff --git a/pkgs/by-name/ha/harec/package.nix b/pkgs/by-name/ha/harec/package.nix index 11470c7f828f..e95ad7ed7095 100644 --- a/pkgs/by-name/ha/harec/package.nix +++ b/pkgs/by-name/ha/harec/package.nix @@ -7,6 +7,11 @@ let platform = lib.toLower stdenv.hostPlatform.uname.system; arch = stdenv.hostPlatform.uname.processor; + qbePlatform = { + x86_64 = "amd64_sysv"; + aarch64 = "arm64"; + riscv64 = "rv64"; + }.${arch}; in stdenv.mkDerivation (finalAttrs: { pname = "harec"; @@ -31,6 +36,10 @@ stdenv.mkDerivation (finalAttrs: { "PREFIX=${builtins.placeholder "out"}" "ARCH=${arch}" "VERSION=${finalAttrs.version}-nixpkgs" + "QBEFLAGS=-t${qbePlatform}" + "CC=${stdenv.cc.targetPrefix}cc" + "AS=${stdenv.cc.targetPrefix}as" + "LD=${stdenv.cc.targetPrefix}ld" ]; strictDeps = true; diff --git a/pkgs/by-name/ha/haredoc/package.nix b/pkgs/by-name/ha/haredoc/package.nix new file mode 100644 index 000000000000..2476e7d937c5 --- /dev/null +++ b/pkgs/by-name/ha/haredoc/package.nix @@ -0,0 +1,55 @@ +{ lib +, stdenv +, scdoc +, hare +}: +let + arch = stdenv.hostPlatform.uname.processor; +in +stdenv.mkDerivation { + pname = "haredoc"; + outputs = [ "out" "man" ]; + inherit (hare) version src; + + strictDeps = true; + enableParallelBuilding = true; + + nativeBuildInputs = [ + scdoc + hare + ]; + + preBuild = '' + HARECACHE="$(mktemp -d)" + export HARECACHE + ''; + + buildPhase = '' + runHook preBuild + + hare build -qR -a ${arch} -o haredoc ./cmd/haredoc + scdoc haredoc.1 + scdoc haredoc.5 + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm0755 ./haredoc $out/bin/haredoc + install -Dm0644 ./haredoc.1 $out/share/man/man1/haredoc.1 + install -Dm0644 ./haredoc.5 $out/share/man/man5/haredoc.5 + + runHook postInstall + ''; + + meta = { + homepage = "https://harelang.org/"; + description = "Hare's documentation tool"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ onemoresuza ]; + mainProgram = "haredoc"; + inherit (hare.meta) platforms badPlatforms; + }; +} diff --git a/pkgs/development/compilers/qbe/default.nix b/pkgs/development/compilers/qbe/default.nix index aeb739bb84d0..00c91e2671ec 100644 --- a/pkgs/development/compilers/qbe/default.nix +++ b/pkgs/development/compilers/qbe/default.nix @@ -12,7 +12,10 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-UgtJnZF/YtD54OBy9HzGRAEHx5tC9Wo2YcUidGwrv+s="; }; - makeFlags = [ "PREFIX=$(out)" ]; + makeFlags = [ + "PREFIX=$(out)" + "CC=${stdenv.cc.targetPrefix}cc" + ]; doCheck = true;