From 48b05290b8ce5700f7e89ee17cc91313654d9c9e Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Wed, 19 Jul 2023 16:27:50 -0400 Subject: [PATCH 1/2] Add purs-versions script --- app/default.nix | 5 +++-- flake.nix | 24 ++++++++++++++---------- scripts/default.nix | 3 ++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/default.nix b/app/default.nix index 20394fef..46c23eed 100644 --- a/app/default.nix +++ b/app/default.nix @@ -8,6 +8,7 @@ writeText, nodejs, compilers, + purs-versions, dhall, dhall-json, git, @@ -76,7 +77,7 @@ in { ''; postFixup = '' wrapProgram $out/bin/${name} \ - --set PATH ${lib.makeBinPath [compilers dhall dhall-json licensee git coreutils gzip gnutar]} + --set PATH ${lib.makeBinPath [compilers purs-versions dhall dhall-json licensee git coreutils gzip gnutar]} ''; }; @@ -109,7 +110,7 @@ in { ''; postFixup = '' wrapProgram $out/bin/${name} \ - --set PATH ${lib.makeBinPath [compilers dhall dhall-json licensee git coreutils gzip gnutar]} + --set PATH ${lib.makeBinPath [compilers purs-versions dhall dhall-json licensee git coreutils gzip gnutar]} ''; }; } diff --git a/flake.nix b/flake.nix index 212ae656..30c4a3a3 100644 --- a/flake.nix +++ b/flake.nix @@ -71,28 +71,31 @@ # # To add a new compiler to the list, just update the flake: # $ nix flake update - compilers = let - # Only include the compiler at normal MAJOR.MINOR.PATCH versions. - stableOnly = - prev.lib.filterAttrs (name: _: (builtins.match "^purs-[0-9]+_[0-9]+_[0-9]+$" name != null)) - prev.purs-bin; - in + supportedCompilers = prev.lib.filterAttrs (name: _: (builtins.match "^purs-[0-9]+_[0-9]+_[0-9]+$" name != null)) prev.purs-bin; + + # An attrset containing all the PureScript binaries we want to make + # available. + compilers = prev.symlinkJoin { name = "purs-compilers"; paths = prev.lib.mapAttrsToList (name: drv: prev.writeShellScriptBin name '' exec ${drv}/bin/purs "$@" '') - stableOnly; + supportedCompilers; }; + + purs-versions = prev.writeShellScriptBin "purs-versions" '' + echo ${builtins.concatStringsSep " " (prev.lib.attrNames supportedCompilers)} + ''; in { apps = prev.callPackages ./app { - inherit compilers package-lock spago-lock; + inherit compilers purs-versions package-lock spago-lock; }; scripts = prev.callPackages ./scripts { - inherit compilers package-lock spago-lock; + inherit compilers purs-versions package-lock spago-lock; }; - inherit compilers package-lock spago-lock; + inherit purs-versions compilers package-lock spago-lock; }; }; in @@ -278,6 +281,7 @@ packages = with pkgs; [ # All stable PureScript compilers registry.compilers + registry.purs-versions # TODO: Hacky, remove when I can run spago test in a pure env run-tests-script diff --git a/scripts/default.nix b/scripts/default.nix index 012f5ffe..a275b7ec 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -7,6 +7,7 @@ nodejs, writeText, compilers, + purs-versions, dhall, dhall-json, licensee, @@ -48,7 +49,7 @@ ''; postFixup = '' wrapProgram $out/bin/${name} \ - --set PATH ${lib.makeBinPath [ compilers dhall dhall-json licensee git coreutils gzip gnutar ]} + --set PATH ${lib.makeBinPath [ compilers purs-versions dhall dhall-json licensee git coreutils gzip gnutar ]} ''; }; in { From 62bc6f486575faae1399132c04cb42ecb249c963 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Wed, 19 Jul 2023 16:33:38 -0400 Subject: [PATCH 2/2] space-separate --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 30c4a3a3..5c76deff 100644 --- a/flake.nix +++ b/flake.nix @@ -86,7 +86,7 @@ }; purs-versions = prev.writeShellScriptBin "purs-versions" '' - echo ${builtins.concatStringsSep " " (prev.lib.attrNames supportedCompilers)} + echo ${prev.lib.concatMapStringsSep " " (x: prev.lib.removePrefix "purs-" (builtins.replaceStrings ["_"] ["."] x)) (prev.lib.attrNames supportedCompilers)} ''; in { apps = prev.callPackages ./app {