lionello / dub2nix Goto Github PK
View Code? Open in Web Editor NEWCLI tool to create Nix expressions for D-lang Dub projects
License: MIT License
CLI tool to create Nix expressions for D-lang Dub projects
License: MIT License
Consider this simple Dub package:
diff --git a/dub.sdl b/dub.sdl
new file mode 100644
index 0000000..ed75c45
--- /dev/null
+++ b/dub.sdl
@@ -0,0 +1,2 @@
+name "test"
+dependency "mir-ion" version="~>2.0"
diff --git a/dub.selections.json b/dub.selections.json
new file mode 100644
index 0000000..73b904a
--- /dev/null
+++ b/dub.selections.json
@@ -0,0 +1,10 @@
+{
+ "fileVersion": 1,
+ "versions": {
+ "mir-algorithm": "3.21.0",
+ "mir-core": "1.6.0",
+ "mir-cpuid": "1.2.11",
+ "mir-ion": "2.2.0",
+ "silly": "1.1.1"
+ }
+}
diff --git a/source/app.d b/source/app.d
new file mode 100644
index 0000000..ab73b3a
--- /dev/null
+++ b/source/app.d
@@ -0,0 +1 @@
+void main() {}
After generating dub.selections.nix
, mkDub.nix
and test.nix
(with --output
), and trying to build the result, it fails with:
this derivation will be built:
/nix/store/lr3xd1azg8a98bpyilyfwix6zqi0qbsg-test.drv
building '/nix/store/lr3xd1azg8a98bpyilyfwix6zqi0qbsg-test.drv'...
unpacking sources
unpacking source archive /nix/store/rk7kivayz7sxa3pmkcrwjicpawmmfbph-source
source root is source
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
Registered package: mir-core (version: 1.6.0)
Registered package: mir-cpuid (version: 1.2.11)
Registered package: silly (version: 1.1.1)
Registered package: mir-algorithm (version: 3.21.0)
Registered package: mir-ion (version: 2.2.0)
Starting Performing "release" build using dmd for x86_64.
Building test ~master: building configuration [application]
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `pure` function `mir.algebraic.Algebraic!(IonExt_).Algebraic.opEquals!().opEquals` cannot call impure function `mir.annotated.U!(Algebraic!(IonExt_)).Annotated.opEquals`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `@nogc` function `mir.algebraic.Algebraic!(IonExt_).Algebraic.opEquals!().opEquals` cannot call non-@nogc function `mir.annotated.U!(Algebraic!(IonExt_)).Annotated.opEquals`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: function `mir.annotated.U!(Algebraic!(IonExt_)).Annotated.opEquals` is not `nothrow`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1429,10): Error: function `mir.algebraic.Algebraic!(IonExt_).Algebraic.opEquals!().opEquals` may throw but is marked as `nothrow`
/nix/store/a9aywjvvc66p4l146hcmik39ddxbghsp-mir-algorithm/source/mir/annotated.d(69,54): Error: template instance `mir.algebraic.Algebraic!(IonExt_).Algebraic.opEquals!()` error instantiating
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/internal/meta.d(683,39): instantiated from here: `U!(Algebraic!(IonExt_))`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(858,36): 12 recursive instantiations from here: `ReplaceTypeUnless!(isVariant, This, Algebraic!(IonExt_), IonNull, bool, long, double, string, Blob, Clob, Timestamp, This[], StringMap!(This), Annotated!(This))`
/nix/store/01jyvn04x0r8cd26ysrrca91mvxsj1r2-mir-ion/source/mir/algebraic_alias/ion_ext.d(56,25): instantiated from here: `Algebraic!(IonExt_)`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `pure` function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` cannot call impure function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `@nogc` function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` cannot call non-@nogc function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals` is not `nothrow`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1429,10): Error: function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` may throw but is marked as `nothrow`
/nix/store/a9aywjvvc66p4l146hcmik39ddxbghsp-mir-algorithm/source/mir/annotated.d(69,54): Error: template instance `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!()` error instantiating
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/internal/meta.d(683,39): instantiated from here: `U!(Algebraic!(Ion_))`
/nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(858,36): 12 recursive instantiations from here: `ReplaceTypeUnless!(isVariant, This, Algebraic!(Ion_), typeof(null), bool, long, double, string, Blob, Clob, Timestamp, This[], StringMap!(This), Annotated!(This))`
/nix/store/a9aywjvvc66p4l146hcmik39ddxbghsp-mir-algorithm/source/mir/algebraic_alias/ion.d(60,22): instantiated from here: `Algebraic!(Ion_)`
Error dmd failed with exit code 1.
error: builder for '/nix/store/lr3xd1azg8a98bpyilyfwix6zqi0qbsg-test.drv' failed with exit code 2;
last 10 log lines:
> /nix/store/01jyvn04x0r8cd26ysrrca91mvxsj1r2-mir-ion/source/mir/algebraic_alias/ion_ext.d(56,25): instantiated from here: `Algebraic!(IonExt_)`
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `pure` function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` cannot call impure function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals`
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: `@nogc` function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` cannot call non-@nogc function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals`
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1474,36): Error: function `mir.annotated.U!(Algebraic!(Ion_)).Annotated.opEquals` is not `nothrow`
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(1429,10): Error: function `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!().opEquals` may throw but is marked as `nothrow`
> /nix/store/a9aywjvvc66p4l146hcmik39ddxbghsp-mir-algorithm/source/mir/annotated.d(69,54): Error: template instance `mir.algebraic.Algebraic!(Ion_).Algebraic.opEquals!()` error instantiating
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/internal/meta.d(683,39): instantiated from here: `U!(Algebraic!(Ion_))`
> /nix/store/7y1iy4qlxhnykxi56gb4cjwdx5dppj81-mir-core/source/mir/algebraic.d(858,36): 12 recursive instantiations from here: `ReplaceTypeUnless!(isVariant, This, Algebraic!(Ion_), typeof(null), bool, long, double, string, Blob, Clob, Timestamp, This[], StringMap!(This), Annotated!(This))`
> /nix/store/a9aywjvvc66p4l146hcmik39ddxbghsp-mir-algorithm/source/mir/algebraic_alias/ion.d(60,22): instantiated from here: `Algebraic!(Ion_)`
> Error dmd failed with exit code 1.
For full logs, run 'nix-store -l /nix/store/lr3xd1azg8a98bpyilyfwix6zqi0qbsg-test.drv'.
This seems to be due to a DMD bug. However, this bug only manifests with --combined
.
Considering that --combined
might be an unusual way to build Dub packages, perhaps it may make sense to replace it with --temp-build
?
Replacing --combined
with --temp-build
causes the above simple package to successfully build.
https://github.com/lionello/dub2nix/runs/1802023355
... runnable/gdb1.d -g -fPIC ()
Test runnable/gdb1.d failed. The logged output:
/build/dmd/generated/linux/release/64/dmd -conf= -m64 -Irunnable -g -fPIC -odtest_results/runnable -oftest_results/runnable/gdb1_0 runnable/gdb1.d
gdb test_results/runnable/gdb1_0 --batch -x test_results/runnable/gdb1_0.gdb
Breakpoint 1 at 0x401147: file ../../druntime/import/core/internal/entrypoint.d, line 29.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libthread_db.so.1".
Breakpoint 1, main (argc=3, argv=0x7fffffffbbb8) at ../../druntime/import/core/internal/entrypoint.d:29
29 return _d_run_main(argc, argv, &_Dmain);
RESULT=test_results/runnable/gdb1_0.gdb:5: Error in sourced command file:
No symbol "args" in current context.
==============================
Test runnable/gdb1.d failed: expected rc == 0, exited with rc == 1
make[1]: *** [Makefile:156: test_results/runnable/gdb1.d.out] Error 1
make[1]: *** Waiting for unfinished jobs....
... runnable/foreach4.d -fPIC (-inline -release -g -O)
make: *** [Makefile:188: start_runnable_tests] Error 2
make: Leaving directory '/build/dmd/test'
builder for '/nix/store/sf0216c7c6fx532fdypf7hcjslx4fzf1-dmd-2.091.1.drv' failed with exit code 2
error: build of '/nix/store/bjkd37d3pjlqb7jd846kr62pwrnq0rvx-dub-1.23.0.drv', '/nix/store/sf0216c7c6fx532fdypf7hcjslx4fzf1-dmd-2.091.1.drv', '/nix/store/zg0iqmk5l2mjdch1isyqk5419g1xdbi9-dtools-2.085.1.drv' failed
Error: Process completed with exit code 100.
$ nix-build --show-trace
error: while evaluating the attribute 'package' of the derivation 'btdu-0.1.0' at /nix/store/i03nyp29ps71c0qyay9299ivj5h15zsd-nixos-20.09.2750.85abeab48b5/nixos/pkgs/stdenv/generic/make-derivation.nix:192:11:
cannot coerce a set to a string, at /nix/store/i03nyp29ps71c0qyay9299ivj5h15zsd-nixos-20.09.2750.85abeab48b5/nixos/pkgs/stdenv/generic/make-derivation.nix:192:11
this is due to the fact that package
is a set and it cannot be an argument to mkDerivation here:
https://github.com/lionello/dub2nix/blob/master/mkDub.nix#L65
While using this program on, for example, this repo, it crashes with the following backtrace:
Running ./bin/dub2nix save
# Prefetching vibe-d-0.8.5
# Prefetching stdx-allocator-2.77.5
std.json.JSONException@../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/json.d(2006): Expecting ',' or '}', not '"'.
----------------
/nix/store/nz28krn5dsrgpwrx8y0j2liv9injlsa5-dmd-2.091.1/include/dmd/std/exception.d:516 pure @safe void std.exception.bailOut!(std.json.JSONException).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x588b05]
/nix/store/nz28krn5dsrgpwrx8y0j2liv9injlsa5-dmd-2.091.1/include/dmd/std/exception.d:437 pure @safe bool std.exception.enforce!(std.json.JSONException).enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x588a86]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/json.d:2596 pure @safe void vibe.data.json.enforceJson!("../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/json.d", 2006uL).enforceJson(bool, lazy immutable(char)[]) [0x58ed94]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/json.d:2006 @safe void vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer.readDictionary!(vibe.data.serialization.Traits!(dub2nix.NixPrefetchGit, vibe.data.serialization.DefaultPolicy).Traits).readDictionary(scope void delegate(immutable(char)[]) @safe) [0x58ea3e]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/serialization.d:773 @safe dub2nix.NixPrefetchGit vibe.data.serialization.deserializeValueImpl!(vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer, vibe.data.serialization.DefaultPolicy).deserializeValueDeduced!(dub2nix.NixPrefetchGit).deserializeValueDeduced(ref vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer) [0x58e059]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/serialization.d:576 @safe dub2nix.NixPrefetchGit vibe.data.serialization.deserializeValueImpl!(vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer, vibe.data.serialization.DefaultPolicy).deserializeValue!(dub2nix.NixPrefetchGit).deserializeValue(ref vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer) [0x58dffc]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/serialization.d:299 @safe dub2nix.NixPrefetchGit vibe.data.serialization.deserializeWithPolicy!(vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer, vibe.data.serialization.DefaultPolicy, dub2nix.NixPrefetchGit, immutable(char)[]).deserializeWithPolicy(immutable(char)[]) [0x58c87d]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/serialization.d:265 @safe dub2nix.NixPrefetchGit vibe.data.serialization.deserialize!(vibe.data.json.JsonStringSerializer!(immutable(char)[], false).JsonStringSerializer, dub2nix.NixPrefetchGit, immutable(char)[]).deserialize(immutable(char)[]) [0x58c834]
../../../.dub/packages/vibe-d-0.8.5/vibe-d/data/vibe/data/json.d:1533 @safe dub2nix.NixPrefetchGit vibe.data.json.deserializeJson!(dub2nix.NixPrefetchGit, immutable(char)[]).deserializeJson(immutable(char)[]) [0x58c6a0]
../dub2nix/src/dub2nix.d:70 @safe dub2nix.NixPrefetchGit dub2nix.nixPrefetchGit(immutable(char)[], immutable(char)[]) [0x5723ed]
../dub2nix/src/dub2nix.d:84 @safe dub2nix.DubDep dub2nix.prefetch(immutable(char)[], immutable(char)[]) [0x572722]
../dub2nix/src/dub2nix.d:177 @safe dub2nix.DubDep dub2nix.createNixDeps(immutable(char)[]).progress!(std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple).progress(const(std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple)) [0x5941c5]
/nix/store/nz28krn5dsrgpwrx8y0j2liv9injlsa5-dmd-2.091.1/include/dmd/std/parallelism.d:1811 @safe void std.parallelism.TaskPool.amap!(dub2nix.createNixDeps(immutable(char)[]).progress).amap!(std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple[]).amap(std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple[]).doIt() [0x5940ad]
??:? void std.parallelism.run!(void delegate()).run(void delegate()) [0x5e49e3]
??:? void std.parallelism.Task!(std.parallelism.run, void delegate()).Task.impl(void*) [0x5e44af]
??:? void std.parallelism.AbstractTask.job() [0x62d76a]
??:? void std.parallelism.TaskPool.doJob(std.parallelism.AbstractTask*) [0x5e2f9b]
??:? void std.parallelism.TaskPool.executeWorkLoop() [0x5e3111]
??:? void std.parallelism.TaskPool.startWorkLoop() [0x5e30b7]
??:? void core.thread.osthread.Thread.run() [0x6099e9]
??:? thread_entryPoint [0x655a05]
??:? [0x7f1dd48deedc]
Program exited with code 1
I get similar crashes on my own projects and the exception seems to be thrown on each of the dependencies in dub2nix.nixPrefetchGit
, from some debugging I've done.
Running nix-prefetch-git manually on, for example vibe-d, yields this output for me:
{
"url": "[email protected]:vibe-d/vibe.d.git",
"rev": "7eaaf70311c50d3413dd724d227fa610c7aac253",
"date": "2020-06-09T15:20:48+02:00",
"path": "/nix/store/9nsmsskfn4qgmj78vb5i3c93765kj853-vibe.d",
"sha256": "012cwpsa2vl8xg54smzspi3dnks2gb19fp182pkby5zw9aihv64r",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}
Doesn't seem like malformed JSON to me and std.json.parseJSON
parses it just fine. The problem seems to be caused by the deserialiser of vibe.d encountering unknown fields and giving back a cryptic error message.
Specifying a git repository as an dependency in dub.json
instead of a version number does not seem to be supported. Example dub.json
:
{
// The regular fields…
"dependencies": {
"bar": {
"repository": "git+https://github.com/foo/bar.git",
"version": "<git revision>"
},
}
Example dub.selections.json
:
{
"fileVersion": 1,
"versions": {
"bar": {"version":"<git revision>","repository":"git+https://github.com/foo/bar.git"},
}
}
Error:
$ dub2nix save
Error: Expected '"' to start string.
I think this might also be an issue with phobos that leaks paths to the standard library into the executable.
tobias@balu:/tmp/dub-test$ nix-store -qR /nix/store/*dub2nix-0.2.6
/nix/store/ymr28y3gfbjp25cwn7nqihbciasxxgna-libunistring-0.9.10
/nix/store/nq7z9djyxaj6j7w9mgp94a6sds1jppi4-libidn2-2.3.2
/nix/store/s9qbqh7gzacs7h68b2jfmn9l6q4jwfjz-glibc-2.33-59
/nix/store/02hgizi6v46z0a1giis0q93wq6g22d77-ncurses-6.2
/nix/store/05kg55dyr06zfz4q28g603sz7q21xfc5-perl5.34.0-Test-RequiresInternet-0.05
/nix/store/pxrdzmp8ijlz2bpsxsj2ssrn3p2ybzzf-zlib-1.2.11
/nix/store/y8v9k1mjr73ns140bfzfyf3sm5avh4gc-openssl-1.1.1m
/nix/store/5f0mkdl0q9900dhm95f9fawf6q43313s-libssh2-1.10.0
/nix/store/5ndk10qnsb9hihr18k8ddladb5i96kyn-nghttp2-1.43.0-lib
/nix/store/pbfraw351mksnkp2ni9c4rkc9cpp89iv-bash-5.1-p12
/nix/store/qkr92xrcazqjsaxcr07a8li834zxrq5q-keyutils-1.6.3-lib
/nix/store/7q1fja0rfmghfj2xfplqsyw52qwj4qcj-libkrb5-1.18
/nix/store/i43cz21vzpcypgnkawrkm7m18zynliwv-brotli-1.0.9-lib
/nix/store/0ic9qsism3kjksnjvnr8yb9hbchl5yc5-curl-7.80.0
/nix/store/6l4wq77g8mj64111f66lwgizd931dg2s-perl5.34.0-IO-HTML-1.004
/nix/store/i3d23in6871kdv2q1bcml05q072vbrfl-perl5.34.0-TimeDate-2.33
/nix/store/816nc03zz1fq9vjdrx0ryx9ikmndifbg-perl5.34.0-HTTP-Date-6.05
/nix/store/kc0nrbhhxs4dhhjwz8sd43k5y7r76a0d-perl5.34.0-Encode-Locale-1.05
/nix/store/p11z3ldwjlmj8w2kvfy5vp9x1kj99j8b-perl5.34.0-URI-5.05
/nix/store/zagi7gm1201dplqqynsv11jxdnawdywf-perl5.34.0-LWP-MediaTypes-6.04
/nix/store/2025j2r6qri1qy4b2lzf9af749cakbz1-perl5.34.0-HTTP-Message-6.26
/nix/store/39ba5cbdy20ndrh7awbschhbdz9n8cka-perl5.34.0-HTTP-Daemon-6.01
/nix/store/4f5x1000fryla2pgzsf355yqdw28d3v3-perl5.34.0-Try-Tiny-0.30
/nix/store/5b40cks3m9nhkxiy4g9jsaqbp1vipc6g-attr-2.5.1
/nix/store/rf9d67pk49l2sq26qiwwp1wl727qf11f-acl-2.3.1
/nix/store/176gh50y24c0lx2bnnmsvf9wazb73php-coreutils-9.0
/nix/store/6wcdxh3h5jp9qgrccq3n71wnalca5mf5-perl-5.34.0
/nix/store/7ccycincvjj9rlk7x3mlv1sdqi3x2qzl-perl5.34.0-File-Listing-6.14
/nix/store/csidl7dwbl9qzchlzczrrxlxzsaazxfj-perl5.34.0-Net-HTTP-6.19
/nix/store/f1rq5gyzf43kd10h2wzlvizyivzd2ir7-perl5.34.0-Test-Needs-0.002006
/nix/store/g4sjg38sly59s9yns88r07a6ynyqfrj8-perl5.34.0-HTML-Tagset-3.20
/nix/store/ijsi6sjhmx9vvcyblklw6kagq7g20vk8-perl5.34.0-HTML-Parser-3.75
/nix/store/jvn1nv8p8i9dgpzcy36nqxyc5mvjb4v2-perl5.34.0-HTTP-Negotiate-6.01
/nix/store/kni8mhh8z77crjwznjcni8lxfkdvchzl-perl5.34.0-WWW-RobotRules-6.02
The only mention of license I can find is in dub.json
, which declares this repository propietary. Is this intentional? In any case, it'd be better to add a LICENSE.md
and/or mention the license in the readme file.
Currently mkDub
requires the presence of dub.json
. Should add support for SDL parsing and detect whichever format is present in the project.
Need a way to switch between ldc and dmd.
Should be able to make nix-prefetch-git
a dependency of dub2nix
so it doesn't need to be separately installed by the user.
Avoid using <nixpkgs>
for a reproducible build.
For example, this Dub package is on gitlab.com:
https://gitlab.com/AntonMeep/silly
This naive patch seems to work for me:
diff --git a/src/dub2nix.d b/src/dub2nix.d
index fd43743..e97e16f 100644
--- a/src/dub2nix.d
+++ b/src/dub2nix.d
@@ -16,12 +16,17 @@ unittest {
}
struct DubDependency {
+ enum Type {
+ github,
+ gitlab,
+ }
+ Type type;
string version_;
string repository;
static DubDependency fromJson(Json json) @safe {
if (json.type == Json.Type.string)
- return DubDependency(json.get!string, null);
+ return DubDependency(Type.github, json.get!string, null);
else {
return deserializeJson!DubDependency(json);
}
@@ -117,10 +122,10 @@ struct DubDep {
/// Fetch the repo information for package `pname` and version `ver`
auto resolveDependency(string pname, string ver) @safe {
+ import std.conv : to;
const repo = findRepo(pname);
- enforce(repo.kind == "github", "Only github repos are supported, got " ~ repo.kind);
const url = "https://" ~ repo.kind ~ ".com/" ~ repo.owner ~ '/' ~ repo.project ~ ".git";
- return DubDependency("v" ~ ver, url);
+ return DubDependency(repo.kind.to!(DubDependency.Type), "v" ~ ver, url);
}
/// Nix-prefetch the specified dependency
Hi, is there any reason why --output
copies mkDub.nix
, instead of simply making the generated .nix
file fetch it from this repository?
I think it would reduce clutter, but I'm not sure if there is some bigger disadvantage that I'm not seeing.
srcs
and sourceRoot
/setSourceRoot
I'm trying to use dub2nix on CyberShadow/btdu@9bbab62
I'm invoking it with
let pkgs = import <nixpkgs> { }; in
let mkDub = (import ./mkDub.nix {
inherit pkgs;
});
in
mkDub.mkDubDerivation {
version = "0.1.0"; # optional
src = ./.;
package = {
name = "btdu";
description = "sampling disk usage profiler for btrfs";
outPath = "foo";
};
}
when building dub attempts to write to the store:
$ nix-build --show-trace
these derivations will be built:
/nix/store/jxq676a3bgp8zb8iq2cslzw3qzrq312x-btdu-0.1.0.drv
building '/nix/store/jxq676a3bgp8zb8iq2cslzw3qzrq312x-btdu-0.1.0.drv'...
unpacking sources
unpacking source archive /nix/store/0lvppfcimz2p21f6146ncxfwj48waip2-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
Registered package: ncurses (version: 0.0.149)
Registered package: ae (version: 0.0.2833)
Registered package: btrfs (version: 0.0.11)
Performing "release" build using dmd for x86_64.
/nix/store/a8rk8i1b2597ihlqxr6m7vy3plfc3d0d-ncurses/.dub: Permission denied
builder for '/nix/store/jxq676a3bgp8zb8iq2cslzw3qzrq312x-btdu-0.1.0.drv' failed with exit code 2
error: build of '/nix/store/jxq676a3bgp8zb8iq2cslzw3qzrq312x-btdu-0.1.0.drv' failed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.