Closed JonathanILevi closed 1 year ago
cc @ThomasMader
@JonathanILevi Can you please create a minimal example to reproduce the problem?
It's true that dynamic linking probably doesn't make much sense in NixOS for package building. You seem to only want to build your project for development reasons it seems and you are talking about dynamic linking right?
I am not thinking about release building currently. I don't know whether dynamic linking or static linking makes more sense. I am not actually even sure which I am doing now.
Here is a minimal example. https://bitbucket.org/JonathanILevi/nix-d-link/src/master/
There is a shell.nix which is a modified version of the generated one (which tried to include druntime
and phobos2
packages).
Once in a pure nix-shell (nix-shell --pure
): If you run run-syslib.sh
it will crash because it was unable to find libs. If you run run-locallib.sh
it works by using local lib files which I extracted from my arch rig.
@ThomasMader
I don't have any experiences with cabal or Haskell so I don't really see what's going on in your example. Could you please try to make a smaller example to pin down the problem?
I thought of something like this for shell.nix:
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "dmd-compile";
buildInputs = [ dmd ];
shellHook = ''
tmpdir=/tmp/compile_test
echo tmpdir: $tmpdir
mkdir -p $tmpdir
cd $tmpdir
echo '
import std.stdio;
void main() {
writeln("works");
}
' > test.d
dmd test.d
./test
rm -rf $tmpdir
exit
'';
}
Okay, I will see if I can make a more minimal example.
Your shell.nix seems to be using dmd but my problem is linking to the runtime and Phobos libs with with a different linker.
More similar to what I am trying to do is use a D library in a C application (but still with Phobos and the runtime). The C linker needs to link the Druntime and Phobos along with the D library's libs.
I will see if I can make an example reproducing the problem with C rather than Haskell.
Ok, so you basically do something like in this thread: https://forum.dlang.org/thread/ikqgiybsarzziufrnbna@forum.dlang.org
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.
Closing this since this has been stale for a while and it sounds to me (a naive reader) like Thomas answered the question, but I'm happy to reopen if I'm overreaching.
D has a runtime that is required for many features of the language. I have a library for a (Haskell) project of mine which is written in D but requires bindings and the DRuntime & Phobos to be linked.
When I build my project on my arch rig I just needed to have DMD (D compiler) installed and cabal would find the needed libs.
I tried running a nix-shell with DMD but cabal still cannot find the DRuntime & Phobos libs. I think this is because the nixpkgs dmd does not expose them (by default nix hides things).
I think it would make sense for the DRuntime and Phobos to be separate nixpkgs ("dmd-druntime" and "dmd-phobos" because LDC (another D compiler) has different DRuntime & Phobos libs). Or can the nixpkgs dmd expose the libs? Or am I just doing everything wrong?