Open magthe opened 2 years ago
After asking for help on the PureScript Discourse I've ended up with the following
{ pkgs ? import <nixpkgs> { }) }:
with pkgs;
let spagoPkgs = import ./spago-packages.nix { inherit pkgs; };
in stdenv.mkDerivation rec {
pname = "hu-frontend";
src = lib.cleanSource ./.;
version = "0.1";
buildInputs = [
spagoPkgs.installSpagoStyle
spagoPkgs.buildSpagoStyle
spagoPkgs.buildFromNixStore
purescript
spago
];
unpackPhase = ''
cp $src/{packages,spago}.dhall .
cp -r $src/src .
install-spago-style
'';
buildPhase = ''
build-spago-style ./src/*.purs
spago bundle-app --no-build --no-install
'';
installPhase = ''
install -D -m644 ./index.js $out/srv/hu-frontend.js
'';
}
It works locally but is very different from the instructions in the project's README. Are the instructions simply outdated?
Thank you for leaving that here, I also had major troubles getting this to work, but with your template it's working!
Is there a complete solution that allows calling spago2nix from nix?
Also, I'm getting [error] Directory "/" is not accessible. Permissions {readable = True, writable = False, executable = False, searchable = True}
from spago on spago bundle-app --no-build --no-install
step.
EDIT: the culprit was global spago cache. spago --global-cache skip
helped
I'm struggling with setting up a derivation for my project and I think it'd be useful to have a beginner friendly (complete) example. Or maybe you have some public project using
spago2nix
that you can point to?This is what I have at the moment:
and it results in