Skip to content

Commit

Permalink
Add purs-versions script to list supported registry versions (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashoneyman authored Jul 19, 2023
1 parent e7aadf4 commit dc2e788
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions app/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
writeText,
nodejs,
compilers,
purs-versions,
dhall,
dhall-json,
git,
Expand Down Expand Up @@ -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]}
'';
};

Expand Down Expand Up @@ -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]}
'';
};
}
24 changes: 14 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ${prev.lib.concatMapStringsSep " " (x: prev.lib.removePrefix "purs-" (builtins.replaceStrings ["_"] ["."] x)) (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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion scripts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
nodejs,
writeText,
compilers,
purs-versions,
dhall,
dhall-json,
licensee,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit dc2e788

Please sign in to comment.