Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and Readme #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ let
in
pkgs.stdenv.mkDerivation rec {
# < ... >
src = ./.;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be src = ./src;, because the idea is that you directly consume sources without any directory structure. in addition, because requiring root sources is just not what i think anyone should do without a filter


buildInputs = [ spagoPackages.installSpagoStyle ];

buildPhase =
''
${spagoPkgs.installSpagoStyle} # == spago2nix install
${spagoPkgs.buildSpagoStyle} # == spago2nix build
installSpagoStyle # == spago2nix install

${spagoPackages.mkBuildProjectOutput { inherit src purescript; }}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below why I think purescript and not purs. Somehow it would be nice to enhance the example how to obtain this package. As easy-purescript is not yet in NIXOS stable, maybe a this should be somehow noted.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, really anyone who uses this tool should also be consuming easy-purescript-nix https://github.com/justinwoo/easy-purescript-nix/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work for me, build fails with /nix/store/whpnlfj79vd8p175rp1bwg0x7wz5lmj1-stdenv-linux/setup: line 81: /nix/store/q3m23c4r1zyvd40d5x4p2gfnmm04mdfx-build-project-output: Is a directory

'';
# < ... >
}
Expand Down
47 changes: 21 additions & 26 deletions src/Generate.purs
Original file line number Diff line number Diff line change
Expand Up @@ -146,44 +146,39 @@ INPUTS
in {
inherit inputs;

installSpagoStyle = pkgs.runCommand "install-spago-style" {} ''
>>$out echo "#!/usr/bin/env bash"
>>$out echo
>>$out echo "echo installing dependencies..."
>>$out echo "${builtins.toString (
builtins.map cpPackage (builtins.attrValues inputs))}"
>>$out echo "echo done."
chmod +x $out
installSpagoStyle = pkgs.writeShellScriptBin "install-spago-style" ''
echo "installing dependencies..."
${builtins.toString (
builtins.map cpPackage (builtins.attrValues inputs))}
echo "done."
'';

buildSpagoStyle = pkgs.runCommand "build-spago-style" {} ''
>>$out echo "#!/usr/bin/env bash"
>>$out echo
>>$out echo "echo building project..."
>>$out echo "purs compile ${builtins.toString (
builtins.map getGlob (builtins.attrValues inputs))}" \"\$@\"
>>$out echo "echo done."
chmod +x $out
buildSpagoStyle = pkgs.writeShellScriptBin "build-spago-style" ''
EXTRA_FILES="$@"

echo "echo building project..."
echo "purs compile ${builtins.toString (
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this should also depend on purs/purescript. Currently it circumvents nix. But I did not change it as maybe the whole function is not needed anymore now that we have mkBuildProjectOutput.
Otherwise it could be ${purescript}/bin/purs.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually do use this script quite often, since mkBuildProjectOutput is the opposite of what i want to use when developing. but yes, changing it to using purescript from easy-purescript-nix is probably fine

builtins.map getGlob (builtins.attrValues inputs))}" \$EXTRA_FILES
echo "echo done."
'';

buildFromNixStore = pkgs.runCommand "build-from-store" {} ''
>>$out echo "#!/usr/bin/env bash"
>>$out echo
>>$out echo "echo building project using sources from nix store..."
>>$out echo "purs compile ${builtins.toString (
builtins.map getStoreGlob (builtins.attrValues inputs))}" \"\$@\"
>>$out echo "echo done."
chmod +x $out
buildFromNixStore = pkgs.writeShellScriptBin "build-from-store" ''
EXTRA_FILES="$@"

echo "echo building project using sources from nix store..."
echo "purs compile ${builtins.toString (
builtins.map getStoreGlob (builtins.attrValues inputs))}" \$EXTRA_FILES
echo "echo done."
'';

mkBuildProjectOutput =
{ src, purs }:
{ src, purescript }:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to depend on purescript, as that's the package that contains the purs binary?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, it's just a name change

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


pkgs.stdenv.mkDerivation {
name = "build-project-output";
src = src;

buildInputs = [ purs ];
buildInputs = [ purescript ];

installPhase = ''
mkdir -p $out
Expand Down