about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGustavo Coutinho de Souza <dev@onemoresuza.mailer.me>2023-12-02 13:13:44 -0300
committerGustavo Coutinho de Souza <dev@onemoresuza.mailer.me>2023-12-14 19:27:37 -0300
commita47d6e0fd6edf862d53ea8554a181f810acb21b5 (patch)
tree57f3bd4482f617d9564421b14a945e5a0b0aa4cb
parenta0e632e84e16311d6a5ec0a2209a06b68ac646f0 (diff)
downloadnixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar.gz
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar.bz2
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar.lz
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar.xz
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.tar.zst
nixlib-a47d6e0fd6edf862d53ea8554a181f810acb21b5.zip
hare: unstable-2023-10-23 -> unstable-2023-11-27
And also:
- move platform and arch to outer let-in
- patch tzdata paths to use the nix store
- set `outputs` to `[ "out" "man" ]`
- append `nixpkgs` `hare version`'s output
- compact `postFixup` phase
- rework description
- move `binutils-unwrapped` only to `buildInputs`

[1]: https://nixpk.gs/pr-tracker.html?pr=265124
-rw-r--r--pkgs/by-name/ha/hare/001-tzdata.patch28
-rw-r--r--pkgs/by-name/ha/hare/package.nix85
2 files changed, 66 insertions, 47 deletions
diff --git a/pkgs/by-name/ha/hare/001-tzdata.patch b/pkgs/by-name/ha/hare/001-tzdata.patch
new file mode 100644
index 000000000000..bb510514eb53
--- /dev/null
+++ b/pkgs/by-name/ha/hare/001-tzdata.patch
@@ -0,0 +1,28 @@
+diff --git a/time/chrono/+freebsd.ha b/time/chrono/+freebsd.ha
+index 26d78ab1..6861bfe8 100644
+--- a/time/chrono/+freebsd.ha
++++ b/time/chrono/+freebsd.ha
+@@ -2,7 +2,7 @@
+ // (c) Hare authors <https://harelang.org>
+ 
+ def LOCALTIME_PATH: str = "/etc/localtime";
+-def ZONEINFO_PREFIX: str = "/usr/share/zoneinfo/";
++def ZONEINFO_PREFIX: str = "@tzdata@/share/zoneinfo/";
+ 
+ // The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
+ // leap second data.
+diff --git a/time/chrono/+linux.ha b/time/chrono/+linux.ha
+index 600f606c..8d5617e2 100644
+--- a/time/chrono/+linux.ha
++++ b/time/chrono/+linux.ha
+@@ -2,8 +2,8 @@
+ // (c) Hare authors <https://harelang.org>
+ 
+ def LOCALTIME_PATH: str = "/etc/localtime";
+-def ZONEINFO_PREFIX: str = "/usr/share/zoneinfo/";
++def ZONEINFO_PREFIX: str = "@tzdata@/share/zoneinfo/";
+ 
+ // The filepath of the system's "leap-seconds.list" file, which contains UTC/TAI
+ // leap second data.
+-export def UTC_LEAPSECS_FILE: str = "/usr/share/zoneinfo/leap-seconds.list";
++export def UTC_LEAPSECS_FILE: str = "@tzdata@/share/zoneinfo/leap-seconds.list";
diff --git a/pkgs/by-name/ha/hare/package.nix b/pkgs/by-name/ha/hare/package.nix
index a78b3706f678..c509955c6f09 100644
--- a/pkgs/by-name/ha/hare/package.nix
+++ b/pkgs/by-name/ha/hare/package.nix
@@ -6,26 +6,40 @@
 , makeWrapper
 , qbe
 , scdoc
+, tzdata
+, substituteAll
 }:
 
 let
   # We use harec's override of qbe until 1.2 is released, but the `qbe` argument
   # is kept to avoid breakage.
   qbe = harec.qbeUnstable;
+  # https://harelang.org/platforms/
+  arch = stdenv.hostPlatform.uname.processor;
+  platform = lib.strings.toLower stdenv.hostPlatform.uname.system;
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "hare";
-  version = "unstable-2023-10-23";
+  version = "unstable-2023-11-27";
+
+  outputs = [ "out" "man" ];
 
   src = fetchFromSourcehut {
     owner = "~sircmpwn";
     repo = "hare";
-    rev = "1048620a7a25134db370bf24736efff1ffcb2483";
-    hash = "sha256-slQPIhrcM+KAVAvjuRnqNdEAEr4Xa4iQNVEpI7Wl+Ks=";
+    rev = "d94f355481a320fb2aec13ef62cb3bfe2416f5e4";
+    hash = "sha256-Mpl3VO4xvLCKHeYr/FPuS6jl8CkyeqDz18mQ6Zv05oc=";
   };
 
+  patches = [
+    # Replace FHS paths with nix store
+    (substituteAll {
+      src = ./001-tzdata.patch;
+      inherit tzdata;
+    })
+  ];
+
   nativeBuildInputs = [
-    binutils-unwrapped
     harec
     makeWrapper
     qbe
@@ -36,62 +50,39 @@ stdenv.mkDerivation (finalAttrs: {
     binutils-unwrapped
     harec
     qbe
+    tzdata
   ];
 
-  # Append the distribution name to the version
-  env.LOCALVER = "nix";
+  makeFlags = [
+    "HARECACHE=.harecache"
+    "PREFIX=${builtins.placeholder "out"}"
+    "PLATFORM=${platform}"
+    "ARCH=${arch}"
+  ];
 
-  configurePhase =
-    let
-      # https://harelang.org/platforms/
-      arch =
-        if stdenv.isx86_64 then "x86_64"
-        else if stdenv.isAarch64 then "aarch64"
-        else if stdenv.hostPlatform.isRiscV && stdenv.is64bit then "riscv64"
-        else "unsupported";
-      platform =
-        if stdenv.isLinux then "linux"
-        else if stdenv.isFreeBSD then "freebsd"
-        else "unsupported";
-    in
-    ''
-      runHook preConfigure
+  enableParallelBuilding = true;
 
-      cp config.example.mk config.mk
-      makeFlagsArray+=(
-        PREFIX="${builtins.placeholder "out"}"
-        HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)"
-        BINOUT="$(mktemp -d --tmpdir bin.XXXXXXXX)"
-        PLATFORM="${platform}"
-        ARCH="${arch}"
-      )
+  # Append the distribution name to the version
+  env.LOCALVER = "nixpkgs";
 
-      runHook postConfigure
-    '';
+  strictDeps = true;
 
   doCheck = true;
 
-  postFixup =
-    let
-      binPath = lib.makeBinPath [
-        binutils-unwrapped
-        harec
-        qbe
-      ];
-    in
-    ''
-      wrapProgram $out/bin/hare --prefix PATH : ${binPath}
-    '';
+  preConfigure = ''
+    ln -s config.example.mk config.mk
+  '';
 
-  setupHook = ./setup-hook.sh;
+  postFixup = ''
+    wrapProgram $out/bin/hare \
+      --prefix PATH : ${lib.makeBinPath [binutils-unwrapped harec qbe]}
+  '';
 
-  strictDeps = true;
-  enableParallelBuilding = true;
+  setupHook = ./setup-hook.sh;
 
   meta = {
     homepage = "https://harelang.org/";
-    description =
-      "A systems programming language designed to be simple, stable, and robust";
+    description = "Systems programming language designed to be simple, stable, and robust";
     license = lib.licenses.gpl3Only;
     maintainers = with lib.maintainers; [ onemoresuza ];
     mainProgram = "hare";