-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update buildSpagoLock and refactor #71
Conversation
@toastal, could you please review? IDK why garnix is unhappy. |
flake.nix
Outdated
}; | ||
|
||
outputs = { | ||
outputs = inputs@{ |
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.
Doesn’t the { xx, ... }@inputs
need to come after? Regardless, long-term these are easier to maintain as just calling inputs.spago
in the one places you needed.
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.
flake.nix
Outdated
overlays = [ | ||
self.overlays.default | ||
slimlock.overlays.default | ||
(final: prev: rec { |
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 want to avoid using rec
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.
Sure. 6d5c973 doesn't introduce rec
anymore.
generate/default.nix
Outdated
@@ -31,7 +34,8 @@ in | |||
|
|||
buildPhase = '' | |||
ln -s ${npmDependencies}/js/node_modules . | |||
cp -r ${packages.${name}}/output . | |||
cp -r ${packages.${name}}/{*,.*} . |
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.
Should this be ln -s
too?
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.
Yes. Fixed in 1638337
nix/build-spago-lock.nix
Outdated
${mkBuildCommands} | ||
|
||
mkdir -p $out | ||
cp -r .spago $out |
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.
same about ln -s
. There are some trade offs, but I think it saves disk space more generally & an occasional optimization of the storage can clean up loose links.
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.
AFAIU, it's only possible to symlink something in a derivation $out
.
Hence, to cache the built output
, it's necessary to copy it to $out
at least once.
spago-dev.nix
Outdated
spago | ||
python3 | ||
nodejs | ||
git |
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.
Git is needed!?
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.
Yes. From the spago README:
Minimal dependencies: users should not be expected to install a myriad of tools on their system to support various workflows. Spago only expects git and purs to be installed.
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.
It's needed because Spago uses git to interact with the registry repositories. If we only use spago in offline mode (ie. spago build --offline
) then I believe the calls to fetch the registry will be skipped and we don't need git
.
Generally things look okay, but I’m not entirely sure on much of the context here. So I can’t really comment on the larger picture here. One thing that feels like something that could be looked at is shrinking the |
Yes, I had the same idea about However, I don't know whether it's possible to determine a "working set" of files that are necessary to build a package. Consider a case when a fileset is determined based on a local project directory. If that project contains symlinks to files located outside of that directory, symlinked files won't be included into the derivation Thus, I think we should tell users to pass to
|
Ah ha. That makes sense, especially with better context of how this is actually working now. |
Hey @deemp! I’m happy to optimize the buildSpagoLock stuff, and we can use Spagonto build projects now that it has a working offline mode and the new lock file format. However, I don’t want to build Spago from source if we can stick with the current approach of grabbing “binaries” from NPM. Would you mind explaining the motivation to build from source here? To be blunt it will make for a much faster review on my part if we narrowed to just changes to how buildSpagoLock etc works. I apologize for slow responses this week, it’s a hectic one! |
Hello, @thomashoneyman!
My goal is to be able to incrementally package PureScript projects using Nix. I build spago here because:
I think it's not necessary to build or provide the However, I think it may be convenient to have a derivation in the I see that the
Currently,
Now, I see that my code doesn't account for
|
I've just realized I won't be able to build each package separately because I can build all dependencies at once, but it's less granular than the current solution that uses just the So, I'd rather fix the generated |
1e9e362
to
7f2a045
Compare
e6de7e3
to
6def68f
Compare
flake.nix
Outdated
overlays = [ | ||
self.overlays.default | ||
slimlock.overlays.default | ||
(_: prev: { nodejs = prev.nodejs_20; }) |
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.
What is the point of this? Do you need a specific feature from 20? Even if you did, you should do the check to see if it’s the current version is already greater as this will be unnecessary in the future or fail when v20 is deprecated.
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.
fixed in 2b33591
generate/bin/src/Run.purs
Outdated
@@ -434,7 +434,7 @@ writePursTidyUpdates updates = do | |||
pure (updateStable (updateUnstable named)) | |||
|
|||
case named' of | |||
Nothing -> Console.log "Failed to update named manifest" *> liftEffect (Process.exit 1) | |||
Nothing -> Console.log "Failed to update named manifest" *> liftEffect (Process.exit' 1) |
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.
Shouldn’t these be like Console.error
?
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.
IDK. @thomashoneyman?
BTW, there are quite many
Console.log "something"
liftEffect $ Process.exit' 1
It may be better to use a dedicated function.
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.
Sure, it probably ought to be Console.error
; the way this is run all the output is going to the console so there won't be an observable difference, but it's the proper thing to do.
@deemp we could add a die
function that wraps this up, I'm happy with that. It's what Spago does.
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.
applied the suggestion in 62ce26e
I'm sorry I haven't looked at this yet — I'm having an exceptionally busy work + life period at the moment. |
@deemp Thank you for your contributions! I'm excitedly waiting to see it land to be able to send my own PRs. I believe the maintainers of this repo are using alejandra for formatting (although I see a few exceptions here and there). I think you are using a different formatter? Is it possible for you to reformat the code you touched with alejandra? |
A check could be added like in <purescript/registry-dev@bc61b98>, but oof does alejandra have the worst of the formats IMO vs. nixpkgs-fmt or nixfmt. Upstream in Nixpkgs they are looking to make modifications to nixfmt to look more like nixpkgs-fmt, but that hasn’t yet landed
--
toastal ไข่ดาว | https://toast.al
PGP: 7944 74b7 d236 dab9 c9ef e7f9 5cce 6f14 66d4 7c9e
|
@bakhtiyarneyman, I preferred nixpkgs-fmt because of kamadorueda/alejandra#372. However, as that issue is resolved now, I should check alejandra again. In this repo, I initially used my hands ™️ to not break the surrounding formatted code. I noticed that mostly only my code was re-formatted after I added alejandra as the default formatter and formatted the code. Hence, I think you're right that maintainers used alejandra. |
Neat trick! |
For what it’s worth I don’t have an opinion on what formatter is used so long as we use one. If it’s easier for yall to use a different one then I’m fine with that. |
The default formatter for now is alejandra. One can run |
Sorry. To be clear I was referring to this future Nixpkgs RFC/merge request which looks to to fork |
@toastal, I see the implementation isn't merged yet. Could you please create a separate issue that suggests to use the standard formatter once it's ready? |
No, it’s not merged, but the style the style from the RFC will eventually apply to all of Nixpkgs & by proxy trickle down as a largely defacto style. Deviating from that tends to make just another hurdle to contribution & alejandra’s output is the most dissimilar to what is actively being worked on. Their fork of |
I've created one (#75).
I think it's enough for my PR to keep the de-facto used formatting to have relatively small diff. Hence, if you merge into main another PR that uses a different formatter, I'll rebase my PR on main and format the code using that formatter. |
@@ -33,5 +33,5 @@ stdenv.mkDerivation { | |||
ln -s $BIN $out/bin/${name} | |||
''; | |||
|
|||
meta = meta lib; | |||
meta = meta lib // {mainProgram = name;}; |
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.
Is this record merge necessary if the meta
function is already creating a meta attr with mainProgram = pname;
? This looks like a redundant merge to me.
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.
The meta function didn't set mainProgram
. Hence, there was this merge. I feel it's better to set mainProgram
where mkDerivationBasic.nix
function is called (09bdc08) because then,mainProgram
can be changed independently of name
.
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.
Looks good to me, thank you! Just a couple comments and, once addressed, we can merge.
Co-authored-by: Thomas Honeyman <hello@thomashoneyman.com>
Co-authored-by: Thomas Honeyman <hello@thomashoneyman.com>
Related to purescript/spago#981.
buildSpagoLock
mainProgram
in packages so thatlib.getExe
works correctly (closes Set meta.mainProgram, use lib.getExe #68).generate
packageflake.nix
alejandra
as the default formatternix fmt
to format Nix files