-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Add buildDubPackage and dub-to-nix for building dub based packages #299618
Conversation
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 looks like a fine first iteration.
Could you somehow make clear that you (and perhaps @jtbx too) maintain the dlang support? A comment on top of the files or even setting yourself as the codeowner.
Some smaller things and questions:
|
||
installPhase = "install -D bin/lit $out/bin/lit"; | ||
doCheck = true; |
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.
Not sure how the other derivation wrappers do this but if this is this generally desirable for dub packages, perhaps it could be enabled by default.
checkPhase = '' | ||
runHook preCheck | ||
dub test | ||
runHook postCheck | ||
''; |
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 would probably make sense to have in buildDubPackage.
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.
I'll try to come up with a sane default once I get back home.
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 turns out Literate
didn't actually have any tests, but had a Makefile
entry for testing. I'll try to build serve-d
to test if the checking logic actually works.
installPhase = '' | ||
runHook preInstall | ||
install -Dm755 bin/lit -t $out/bin | ||
runHook preInstall | ||
''; |
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 there no standardised install command for dub?
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.
No, but I can file an issue asking about it. Such a feature would be useful outside of packaging anyway.
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.
There exist an optional targetPath
value inside dub.sdl
or dub.json
, AFAICT defaulting to ./.
. It's where it puts the final binaries and the files inside copyPath
.
Perhaps some jq
based manipulation could be done to the file to add/update it and set it to a fixed directory, though I am not certain if this is robust enough.
(You can convert from .sdl
to .json
with a dub
command, so jq
could be used in either case)
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.
alternatively this could be an argument to buildDubPackage
I would be happy to :) |
05593ac
to
9b22fc4
Compare
Added a By the way, what should we call this language internally? I am using |
Ugh, I just remembered an annoying limitation of GH CODEOWNER: You two must have commit access. I'd say add a comment in the files instead. |
That's a bit annoying, yes. I'll add some comments, then. |
I added some extra builder options for I created |
Okay, so I set |
there is Edit: after testing, it doesn't really make a difference, or just makes it worse (at least for me). If people really want to use this, they can just use |
Okay, I updated #288841 to the new lockfile format, here's how you could do extra dub dependencies: |
Okay, I added both release notes and docs for the things added by this PR (mostly based off of the Run |
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.
thank you for the documentation! I left a few comments
* `dubTestFlags ? []`: The flags to pass to `dub test`. | ||
* `compiler ? ldc`: The D compiler to be used by `dub`. | ||
|
||
## Lockfiles {#dub-lockfiles} |
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.
I think this section should go before the example. There are two steps: 1/generate the lock file, 2/ write nix code like in this example
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.
I just swapped the lockfile and the parameters part around.
I think new the comment above dubLock
in the example is enough indication of what to read next.
7546833
to
e521bec
Compare
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.
Result of nixpkgs-review pr 299618
run on x86_64-linux 1
2 packages blacklisted:
- nixos-install-tools
- tests.nixos-functions.nixos-test
6 packages built:
- Literate
- btdu
- dub-to-nix
- serve-d
- tests.haskell.cabalSdist.assumptionLocalHasDirectReference
- tests.haskell.cabalSdist.localHasNoDirectReference
Successfully ran btdu
.
Great work! I especially like the docs :)
{ | ||
"dependencies": {} | ||
} |
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 could be inlined or even just be the default of buildDubPackage.
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 could be inlined, but I don't think many packages have 0 dependencies. If we have a default, it won't show a missing attribute error, which is worse IMO.
Thanks for all the help and reviews, everyone! I'll get back cleaning up my other PR now. |
Description of changes
Closes #301302
This PR adds three main things:
buildDubPackage
helper functiondub-to-nix
helper scriptmakeDubDep
utility function to be used inside the files generated bydub-to-nix
The idea first came up in #288841 where I ended up implementing it. I though it would be a better idea to separate those changes into different PR, which is this one.
I also ended up migrating all 2 packages that use
dub
inside of nixpkgs.Literate
didn't even have anything to lock withdub-to-nix
, so it has an empty dependency list.The changes done to
btdu
is much more visible, though. The package declaration became much shorter, even when it only had 4 packages to lock.I removed
btdu
's update script for now, maybe when I implement something likepassthru.fetch-deps
frombuildDotnetModule
forbuildDubPackage
I'll add a new one back.I inited the
serve-d
package in this PR too to showcase that this works with many dependencies too.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.