3

Resume

I am currently trying to install dot-net-core-sdk 2.0 with the Nix package manager in NixOs.

I am very new to both NixOs, Nix, bash scripting and stuff like ELF. Yet I think I've successfully managed to create a valid Nix package description for dot-net-core-sdk 2.0.

However, when I try to create a new console project it complains that it can't find the console template:

No templates matched the input template name: console.

The long story...

I have defined my Nix package and build script as follows:

dotnet-sdk.nix

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "dotnet-sdk-2.0";

  builder = ./builder.sh;

  libPath = stdenv.lib.makeLibraryPath
    [ lttng-tools kerberos zlib gettext openssl icu libunwind eject stdenv.cc.cc glib ];

  src = fetchurl {
    url = "https://download.microsoft.com/download/1/B/4/1B4DE605-8378-47A5-B01B-2C79D6C55519/dotnet-sdk-2.0.0-linux-x64.tar.gz";
    sha256 = "6059a6f72fb7aa6205ef4b52583e9c041fd128e768870a0fc4a33ed84c98ca6b";
  };
}

builder.sh

source $stdenv/setup

mkdir -p $out/dotnet-sdk

echo "unpacking $src..."
tar xvfa $src -C $out/dotnet-sdk

echo "unpacking dotnet-sdk..."
p=$out/libexec/dotnet
mkdir -p $out/libexec
mv $out/dotnet-sdk $p

ls -lrth $p

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --force-rpath --set-rpath $libPath --debug $p/dotnet

echo "libPath"
echo $libPath

mkdir -p $out/bin
ln -s $p/dotnet $out/bin/dotnet

I can successfully build the package with

$ sudo nix-build dotnet-sdk.nix 

Which results in a long output that ends with

...
unpacking dotnet-sdk...
total 136K
-rw-r--r-- 1 nixbld1 nixbld 8.0K Jul 20 23:06 ThirdPartyNotices.txt
-rw-r--r-- 1 nixbld1 nixbld 1.1K Jul 20 23:06 LICENSE.txt
-rwxr-xr-x 1 nixbld1 nixbld 104K Jul 20 23:16 dotnet
drwxr-xr-x 3 nixbld1 nixbld 4.0K Aug  3 19:34 store
drwxr-xr-x 3 nixbld1 nixbld 4.0K Aug  3 19:34 shared
drwxr-xr-x 3 nixbld1 nixbld 4.0K Aug  3 19:34 sdk
drwxr-xr-x 3 nixbld1 nixbld 4.0K Aug  3 19:34 host
drwxr-xr-x 4 nixbld1 nixbld 4.0K Aug  3 19:34 additionalDeps
patching ELF file `/nix/store/f1sankahbj7pss7vjrvbmng9z7gd08a6-dotnet-sdk-2.0/libexec/dotnet/dotnet'
Kernel page size is 4096 bytes
new rpath is `/nix/store/xdv40bsxp4c7m2nw63nrnkadmivczk24-lttng-tools-2.9.3/lib:/nix/store/b7yiqkykhj3lr7dlb3v81rsdasjg32jw-libkrb5-1.15/lib:/nix/store/sg6ri2jj92sbv7f4rvchzr00d24pi4nq-zlib-1.2.11/lib:/nix/store/s70cbg1lh45h3gl6xplz6bi2qdszi2cf-gettext-0.19.8/lib:/nix/store/b6d4mxvj5wdnf28lpww73pllmm0zd2nv-openssl-1.0.2l/lib:/nix/store/03gqmzrbh1pr5izy24gmyw1bfdzpy6q8-icu4c-58.2/lib:/nix/store/f4xflmvgszhrwa1r1jn5fddz8j196qzv-libunwind-1.1/lib:/nix/store/awxn3kfww8hjnd1pyji4zdmmi2x3kvzb-util-linux-2.29.2/lib:/nix/store/lc9cdddv2xv45ighz8znsanjfgkcdgbx-gcc-5.4.0-lib/lib:/nix/store/75pmwxf02m6i4vd3b0iybc3w54xf4r2z-glib-2.50.3/lib'
rpath is too long, resizing...
DT_NULL index is 28
replacing section `.dynamic' with size 560
replacing section `.dynstr' with size 22942
replacing section `.interp' with size 80
this is an executable
using replaced section `.interp'
using replaced section `.dynstr'
using replaced section `.dynamic'
last replaced is 22
looking at section `.interp'
looking at section `.note.ABI-tag'
replacing section `.note.ABI-tag' which is in the way
looking at section `.note.gnu.build-id'
replacing section `.note.gnu.build-id' which is in the way
looking at section `.hash'
replacing section `.hash' which is in the way
looking at section `.dynsym'
replacing section `.dynsym' which is in the way
looking at section `.dynstr'
looking at section `.gnu.version'
first reserved offset/addr is 0x8a38/0x408a38
first page is 0x400000
needed space is 36624
needed space is 36680
needed pages is 1
changing alignment of program header 2 from 2097152 to 4096
changing alignment of program header 3 from 2097152 to 4096
clearing first 38856 bytes
rewriting section `.dynamic' from offset 0x19da8 (size 544) to offset 0x270 (size 560)
rewriting section `.dynstr' from offset 0x4308 (size 22320) to offset 0x4a0 (size 22942)
rewriting section `.dynsym' from offset 0x1d10 (size 9720) to offset 0x5e40 (size 9720)
rewriting section `.hash' from offset 0x1298 (size 2680) to offset 0x8438 (size 2680)
rewriting section `.interp' from offset 0x1238 (size 28) to offset 0x8eb0 (size 80)
rewriting section `.note.ABI-tag' from offset 0x1254 (size 32) to offset 0x8f00 (size 32)
rewriting section `.note.gnu.build-id' from offset 0x1274 (size 36) to offset 0x8f20 (size 36)
rewriting symbol table section 3
libPath
/nix/store/xdv40bsxp4c7m2nw63nrnkadmivczk24-lttng-tools-2.9.3/lib:/nix/store/b7yiqkykhj3lr7dlb3v81rsdasjg32jw-libkrb5-1.15/lib:/nix/store/sg6ri2jj92sbv7f4rvchzr00d24pi4nq-zlib-1.2.11/lib:/nix/store/s70cbg1lh45h3gl6xplz6bi2qdszi2cf-gettext-0.19.8/lib:/nix/store/b6d4mxvj5wdnf28lpww73pllmm0zd2nv-openssl-1.0.2l/lib:/nix/store/03gqmzrbh1pr5izy24gmyw1bfdzpy6q8-icu4c-58.2/lib:/nix/store/f4xflmvgszhrwa1r1jn5fddz8j196qzv-libunwind-1.1/lib:/nix/store/awxn3kfww8hjnd1pyji4zdmmi2x3kvzb-util-linux-2.29.2/lib:/nix/store/lc9cdddv2xv45ighz8znsanjfgkcdgbx-gcc-5.4.0-lib/lib:/nix/store/75pmwxf02m6i4vd3b0iybc3w54xf4r2z-glib-2.50.3/lib
/nix/store/f1sankahbj7pss7vjrvbmng9z7gd08a6-dotnet-sdk-2.0

I can now successfully execute the help and version functions on the dotnet binary without getting weird errors about missing object files:

$ result/bin/dotnet --version
2.0.0

However, when I try to create a new console application I get following error:

$ /etc/nixos/dotnet-sdk/result/bin/dotnet new console
No templates matched the input template name: console.

Templates      Short Name      Language      Tags
-------------------------------------------------

I have no idea why it can't find the templates, but I have a weak hypothesis that maybe I screwed something up in the binary by using --force-rpath when I modify the binary with patchelf in the buildscript..

  • Does my package configuration and buildscript look okay? (eg. is the problem unrelated to my Nix package description and buildscript)

  • Is there something obvious I am missing, such as somehow providing a link to some of the auxiliary net core directories when modifying the binary with patchelf?

  • Something else I can do to make net core sdk 2.0 work in NixOs?

  • Not sure if it's related, but coreclr is marked as broken atm: github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/… – simendsjo Aug 22 '17 at 16:04
  • 1
    I suspect dotnet is looking for the template in some location and is not finding it there. Assuming that dotnet-sdk-2.0.0-linux-x64.tar.gz contains the template, then the problem is likely in your buildscript. If you use strace to run dotnet you can determine where dotnet is looking for the templates. – Emmanuel Rosa Aug 22 '17 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.