From e6629c356440121a45d6c7d5b3effb1acda8b215 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 4 Apr 2025 17:25:56 +0300 Subject: [PATCH 1/3] bluespec: Fix wrong executable name for `bsc` and also use `makeBinaryWrapper` because it inherits argv0 better. Wrapping `/bin/bsc` with `makeBinaryWrapper` didn't fix the scriptname issue. ``` Error Bluespec executable not found: /nix/store/nhsa69in3vhyjx2hxnilzkqmb8j2m2mp-bluespec-2024.07/bin/core/.bsc-wrapped ``` --- pkgs/by-name/bl/bluespec/package.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/bl/bluespec/package.nix b/pkgs/by-name/bl/bluespec/package.nix index 766bc20cfdaf..13ac23bcd26b 100644 --- a/pkgs/by-name/bl/bluespec/package.nix +++ b/pkgs/by-name/bl/bluespec/package.nix @@ -22,7 +22,7 @@ asciidoctor, texliveFull, which, - makeWrapper, + makeBinaryWrapper, cctools, targetPackages, # install -m 644 lib/libstp.dylib /private/tmp/nix-build-bluespec-2024.07.drv-5/source/inst/lib/SAT @@ -168,7 +168,7 @@ stdenv.mkDerivation rec { pkg-config texliveFull tcl - makeWrapper + makeBinaryWrapper ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # https://github.com/B-Lang-org/bsc/blob/main/src/comp/bsc.hs#L1838 @@ -212,9 +212,12 @@ stdenv.mkDerivation rec { postFixup = '' # https://github.com/B-Lang-org/bsc/blob/65e3a87a17f6b9cf38cbb7b6ad7a4473f025c098/src/comp/bsc.hs#L1839 - wrapProgram $out/bin/bsc --prefix PATH : ${ - lib.makeBinPath (if stdenv.hostPlatform.isDarwin then [ cctools ] else [ targetPackages.stdenv.cc ]) - } + # `/bin/bsc` is a bash script which the script name to call the binary in the `/bin/core` directory + # thus wrapping `/bin/bsc` messes up the scriptname detection in it. + wrapProgram $out/bin/core/bsc \ + --prefix PATH : ${ + lib.makeBinPath (if stdenv.hostPlatform.isDarwin then [ cctools ] else [ targetPackages.stdenv.cc ]) + } ''; doCheck = true; From 366a24706ebccb15b1d7c4eaae528bddc3da2864 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 4 Apr 2025 17:28:15 +0300 Subject: [PATCH 2/3] bluespec: Conditionalize `withDocs` deps --- pkgs/by-name/bl/bluespec/package.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/bl/bluespec/package.nix b/pkgs/by-name/bl/bluespec/package.nix index 13ac23bcd26b..3a7ca3d8d7be 100644 --- a/pkgs/by-name/bl/bluespec/package.nix +++ b/pkgs/by-name/bl/bluespec/package.nix @@ -160,16 +160,18 @@ stdenv.mkDerivation rec { [ automake autoconf - asciidoctor bison flex ghcWithPackages perl pkg-config - texliveFull tcl makeBinaryWrapper ] + ++ lib.optionals withDocs [ + texliveFull + asciidoctor + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # https://github.com/B-Lang-org/bsc/blob/main/src/comp/bsc.hs#L1838 # /nix/store/7y0vlsf6l8lr3vjsbrirqrsbx4mwqiwf-cctools-binutils-darwin-1010.6/bin/strip: error: unknown argument '-u' From fd4d38d9315327da30f7a3cd81ad4fa3eeb0305d Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 4 Apr 2025 18:07:39 +0300 Subject: [PATCH 3/3] bluespec: Add a simple `installCheckPhase` --- pkgs/by-name/bl/bluespec/package.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/by-name/bl/bluespec/package.nix b/pkgs/by-name/bl/bluespec/package.nix index 3a7ca3d8d7be..5f9fd46c3aa0 100644 --- a/pkgs/by-name/bl/bluespec/package.nix +++ b/pkgs/by-name/bl/bluespec/package.nix @@ -223,6 +223,7 @@ stdenv.mkDerivation rec { ''; doCheck = true; + doInstallCheck = true; # TODO To fix check-suite: # On darwin @@ -281,6 +282,13 @@ stdenv.mkDerivation rec { ) ''; + installCheckPhase = '' + output="$($out/bin/bsc 2>&1 || true)" + echo "bsc output:" + echo "$output" + echo "$output" | grep -q "to get help" + ''; + meta = { description = "Toolchain for the Bluespec Hardware Definition Language"; homepage = "https://github.com/B-Lang-org/bsc";