Skip to content

Commit

Permalink
feat: add spago-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Jan 22, 2024
1 parent 910d5aa commit 14abdfb
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 6 deletions.
26 changes: 22 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@

flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;

spago = {
url = "github:deemp/spago/add-flake-bk";
flake = false;
};
};

outputs = {
outputs = inputs@{
self,
nixpkgs,
slimlock,
flake-compat,
spago
}: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
Expand Down Expand Up @@ -68,6 +74,7 @@
in
{
inherit purs purs-unstable spago spago-unstable purs-tidy purs-tidy-unstable purs-backend-es purs-backend-es-unstable purescript-language-server purescript-language-server-unstable;
spago-dev = pkgs.callPackage ./spago-dev.nix { src = inputs.spago.outPath; };
}
// purs-bin
// spago-bin
Expand Down Expand Up @@ -160,7 +167,7 @@
default = pkgs.mkShell {
name = "purescript-overlay";
buildInputs = [
self.packages.${system}.spago-0_93_19
self.packages.${system}.spago-dev
self.packages.${system}.purs-unstable
self.packages.${system}.purs-tidy-unstable
self.packages.${system}.purs-backend-es-unstable
Expand Down
78 changes: 78 additions & 0 deletions spago-dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{ system
, lib
, src
, stdenv
, slimlock
, purix
, purs
, spago
, nodejs
, esbuild
, python3
, git
, installShellFiles
}:
let
spagoBin = purix.buildSpagoPackages {
inherit src purs spago;
packages = [ "spago-bin" ];
};

npmDependencies = (slimlock.buildPackageLock { inherit src; }).overrideAttrs (x: {
nativeBuildInputs = (x.nativeBuildInputs or [ ]) ++ [ python3 ];
});
in
stdenv.mkDerivation {
name = "spago-dev";

version = "0.93.24";

meta = {
mainProgram = "spago";
};

nativeBuildInputs = [
purs
spago
python3
nodejs
git
installShellFiles
esbuild
];

inherit src;

configurePhase = ''
cp -r ${spagoBin}/{*,.*} .
chmod +w -R output
ln -s ${npmDependencies}/js/node_modules .
'';

buildPhase = ''
spago bundle --offline -p spago-bin
'';

installPhase = ''
PACKAGE=$out/node_modules/spago-bin
mkdir -p $PACKAGE
cp bin/bundle.js package.json README.md LICENSE $PACKAGE
ln -s ${npmDependencies}/js/node_modules/{*,.*} $out/node_modules
BIN=$PACKAGE/bundle.js
chmod +x $BIN
patchShebangs $BIN
SPAGO=$out/bin/spago
mkdir -p $out/bin
ln -s $BIN $SPAGO
BASH_COMPLETIONS=$out/share/bash-completion/completions/
mkdir -p $BASH_COMPLETIONS
$SPAGO --bash-completion-script $SPAGO > $BASH_COMPLETIONS/spago
'';
}

0 comments on commit 14abdfb

Please sign in to comment.