-
Notifications
You must be signed in to change notification settings - Fork 132
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
Build spago from source #981
base: master
Are you sure you want to change the base?
Conversation
See also: #963 The big question here is whether @f-f wants to build spago with Nix or not. If so, then the next question is what to do about the generated BuildInfo file, which is necessary for the build. In the linked PR I made a fake one and included it in the build with If there isn't a desire to build Spago with Nix, then all that's really needed is a dev shell and this PR could be trimmed down to only include that. |
spaghetto/flake.nix
Outdated
easy-purescript-nix = { | ||
url = "github:justinwoo/easy-purescript-nix"; | ||
inputs.flake-utils.follows = "flake-utils"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this and purescript-overlay are both included because purifix
depends on easy-purescript-nix. Maybe if the easy-purescript-nix dependency is forced then it should just be used in place of purescript-overlay.
Now, |
@deemp a few notes:
|
This is the derivation that was used to build Spago, which I believe @f-f is referring to: Now, though, Spago is built by recording the hash and url of its tarball from NPM: The overlay just unpacks the tarball. So that wouldn't be suitable for building Spago from source here (but the first derivation could be). |
@f-f, thank you for reviews. I haven't noticed the usage of I'll try to write a fixed-output derivation to build spago with spago. Probably, it'll be possible to automate hash production. |
I tried to use js = (inputs.dream2nix.lib.makeFlakeOutputs {
systems = [ system ];
config.projectRoot = ./.;
source = ./.;
# autoProjects = true;
projects = {
spago = {
name = "spago";
relPath = "";
subsystem = "nodejs";
translator = "package-lock";
subsystemInfo = {
nodejs = 18;
};
};
};
});
js-modules = js.packages.${system}.spago.overrideAttrs (x: {
installPhase = ''
mkdir $out
cp -r node_modules/* $out
'';
}); However, when I tried to copy them into a FOD, several node packages triggered an error. I found no info about this error. error: illegal path references in fixed-output derivation '/nix/store/rjl96zjihzfwinb2l84rpnmqbxn12bv5-spago.drv' These packages were I found bad packages via a ternary search by Doing I decided to just bundle in the FOD and apply any other improvements in other derivations. |
The previous stab at building spago with nix used slimlock and that worked just fine: |
I added a pre-commit hook that builds a The hook can be installed by entering the default devshell in On my computer, this hook took from several seconds to two minutes. The FOD used
@thomashoneyman, how can I tell |
Completions work in a devshell. nix develop .#spago
spago ini<TAB> |
Now, I believe the pre-commit part is excessive. The FOD should be available as a function of a commit hash and that FOD |
@deemp are you still interested in this? I would like to have a flake in Spago itself, if it's possible to keep it simple |
@f-f, yes, I am. I have a couple of questions, though. Does If no, we'll have to use a fixed-output derivation and store its hash somewhere. Main options:
In 1, we'll have a derivation for each commit, but will have to force-push extended commits. Please, let me know if there are other options. Which one do you prefer? |
@deemp we can (and should) definitely support offline building (which is my preferred option) - but that means that we would need the build inputs (the |
They can just be inputs to the flake (see how purifix does it). They could then be copied into a .spago directory or spago could accept flags to pass the paths of the two repos, which in this case would be store paths. |
Ah, I see. Then I guess #575 is the next blocker for this |
For what it's worth, you don't need to bring in the registry or registry-index to build Spago from its dependencies, because the lock file includes everything Nix needs. In purescript-overlay I was previously building Spago from source from the lockfile and package-lock.json alone. |
We now have a |
This comment is likely relevant to this PR: thomashoneyman/purescript-overlay#47 (comment) |
@deemp still interested in contributing this or shall we close it? |
@f-f, sorry, was busy with studies. I'm interested in this. I'll have time next week so please don't close it yet. |
No worries at all. Thanks! |
I updated the flake to bundle spago with
Fetching dependencies...
Merge cache-db.json files...
Error 1 of 2:
in module Data.Map.Internal
at /nix/store/n61fnbpabgyvaz563sbhykqg4hxqra26-ordered-collections/src/Data/Map/Internal.purs:72:1 - 72:112 (>
Module Data.Function.Uncurried was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 2 of 2:
in module Data.Set.NonEmpty
at /nix/store/n61fnbpabgyvaz563sbhykqg4hxqra26-ordered-collections/src/Data/Set/NonEmpty.purs:32:1 - 32:39 (l>
Module Data.Function.Uncurried was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
purs compile failed with exit code 1.
Error 1 of 2:
in module Data.Map.Internal
at /nix/store/n61fnbpabgyvaz563sbhykqg4hxqra26-ordered-collections/src/Data/Map/Internal.purs:72:1 - 72:112 (>
Module Data.Function.Uncurried was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 2 of 2:
in module Data.Set.NonEmpty
at /nix/store/n61fnbpabgyvaz563sbhykqg4hxqra26-ordered-collections/src/Data/Set/NonEmpty.purs:32:1 - 32:39 (l>
Module Data.Function.Uncurried was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
lines 42-55/55 (END) |
I've updated the PR. Now, I get these errors: Error found:
in module Spago.BuildInfo
at /nix/store/00hmlncdnz5pzvk6p10baaszjya4ywl4-spago/src/Spago/BuildInfo.purs:78:25 - 78:43 (line 78, column 25 - line 78, >
Type of expression lacks required label "spago-bin".
while checking that type Record (() @Type)
is at least as general as type { "spago-bin" :: t0
| t1
}
while checking that expression packages
has type { "spago-bin" :: t0
| t1
}
while checking type of property accessor packages."spago-bin"
in value declaration mkBuildInfo
where t0 is an unknown type
t1 is an unknown type
See https://github.com/purescript/documentation/blob/master/errors/PropertyIsMissing.md for more information,
or to contribute content related to this error.
...skipping...
Error found:
in module Spago.BuildInfo
at /nix/store/00hmlncdnz5pzvk6p10baaszjya4ywl4-spago/src/Spago/BuildInfo.purs:78:25 - 78:43 (line 78, column 25 - line 78, >
Type of expression lacks required label "spago-bin".
while checking that type Record (() @Type)
is at least as general as type { "spago-bin" :: t0
| t1
}
while checking that expression packages
has type { "spago-bin" :: t0
| t1
}
while checking type of property accessor packages."spago-bin"
in value declaration mkBuildInfo
where t0 is an unknown type
t1 is an unknown type
See https://github.com/purescript/documentation/blob/master/errors/PropertyIsMissing.md for more information,
or to contribute content related to this error. |
@deemp the format of the |
Seems like this is a problem with But now there is I don't get what's the problem with using it directly. |
b888c0e
to
6e15324
Compare
@f-f, building Should I move the code for bulding |
build.nix
Outdated
inherit system; | ||
overlays = [ | ||
purescript-overlay.overlays.default | ||
(self: super: { purescript = self.purs-unstable; nodejs = super.nodejs_18; }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This node version is now the default & will eventually be deprecated. It’d be better to throw
an error if the version is less than 18 if you wanted to check I think.
build.nix
Outdated
chmod +w -R . | ||
|
||
cp -r ${nodeDependencies}/js/node_modules . | ||
cp -r ${spagoDependencies.spago-bin}/output . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use ln -s
to not copy the files in.
flake.nix
Outdated
@@ -3,6 +3,9 @@ | |||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; | |||
purescript-overlay.url = "github:thomashoneyman/purescript-overlay"; | |||
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs"; | |||
flake-utils.url = "github:numtide/flake-utils"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn’t used
@toastal, thank you for a review. I'm going to finish thomashoneyman/purescript-overlay#71. When it works, I'll move the |
- set it as the default package - add to a devshell
@toastal, @thomashoneyman, the spago derivation works. However, I used the not yet merged PR thomashoneyman/purescript-overlay#71. Could you please check both PRs? In this PR (to spago repo), you can run nix develop .#dev
spago <TAB>
--help build graph publish sources
--version bundle init registry test/
-h docs install repl uninstall
-v fetch ls run upgrade |
Depends on thomashoneyman/purescript-overlay#71
Description of the change
dev
devshell to checkspago
completions and version