From d0465e3837a71afae2f1a6f42eb923350d826e27 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Jan 2021 10:45:51 -0500 Subject: shell.nix project.nix spine.nix mkDub.nix --- nix/mkDub.nix | 25 +++++++++++++++++++------ nix/pkglst/meson-pkgs.nix | 17 +++++++++++++++++ nix/pkglst/shell-pkgs.nix | 16 ++++++++++++++++ nix/shell-packages.nix | 15 --------------- nix/shell/meson.nix | 10 ++++++++++ 5 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 nix/pkglst/meson-pkgs.nix create mode 100644 nix/pkglst/shell-pkgs.nix delete mode 100644 nix/shell-packages.nix create mode 100755 nix/shell/meson.nix (limited to 'nix') diff --git a/nix/mkDub.nix b/nix/mkDub.nix index 8f4014b..2a6570f 100644 --- a/nix/mkDub.nix +++ b/nix/mkDub.nix @@ -1,8 +1,10 @@ { pkgs ? import {}, stdenv ? pkgs.stdenv, - ldc ? pkgs.ldc, + ldc ? null, + dcompiler ? pkgs.ldc, dub ? pkgs.dub }: +assert dcompiler != null; with stdenv; let # Filter function to remove the .dub package folder from src @@ -16,7 +18,7 @@ let fromDub = dubDep: mkDerivation rec { name = "${src.name}-${version}"; version = rev-to-version dubDep.fetch.rev; - nativeBuildInputs = [ ldc dub ]; + nativeBuildInputs = [ dcompiler dub ]; src = dep2src dubDep; buildPhase = '' runHook preBuild @@ -37,7 +39,7 @@ let # The target output of the Dub package targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; # Remove reference to build tools and library sources - disallowedReferences = deps: [ ldc dub ] ++ builtins.map dep2src deps; + disallowedReferences = deps: [ dcompiler dub ] ++ builtins.map dep2src deps; removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; in { inherit fromDub; @@ -52,10 +54,10 @@ in { ... } @ attrs: stdenv.mkDerivation (attrs // { pname = package.name; - nativeBuildInputs = [ ldc dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; + nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; disallowedReferences = disallowedReferences deps; passthru = passthru // { - inherit dub ldc pkgs; + inherit dub dcompiler pkgs; }; src = lib.cleanSourceWith { filter = filterDub; @@ -68,7 +70,18 @@ in { runHook preBuild export HOME=$PWD ${lib.concatMapStringsSep "\n" dub-add-local deps} - dub build --compiler=ldc2 --build=release --combined --skip-registry=all + for dc_ in dmd ldmd2 gdmd; do + echo "check for D compiler $dc_" + dc=$(type -P $dc_ || echo "") + if [ ! "$dc" == "" ]; then + break + fi + done + if [ "$dc" == "" ]; then + exit "Error: could not find D compiler" + fi + echo "$dc_ used as D compiler to build $pname" + dub build --compiler=$dc --build=release --combined --skip-registry=all runHook postBuild ''; checkPhase = '' diff --git a/nix/pkglst/meson-pkgs.nix b/nix/pkglst/meson-pkgs.nix new file mode 100644 index 0000000..0066e34 --- /dev/null +++ b/nix/pkglst/meson-pkgs.nix @@ -0,0 +1,17 @@ +{ pkgs ? import {} }: +let + dub2nix-src = fetchTarball { + url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; + }; + dub2nix = (import dub2nix-src) { inherit pkgs; }; +in +with pkgs; [ + nix + meson + ninja + dub + ldc + sqlite + nix-prefetch-git + validatePkgConfig +] diff --git a/nix/pkglst/shell-pkgs.nix b/nix/pkglst/shell-pkgs.nix new file mode 100644 index 0000000..7587c02 --- /dev/null +++ b/nix/pkglst/shell-pkgs.nix @@ -0,0 +1,16 @@ +{ pkgs ? import {} }: +let + dub2nix-src = fetchTarball { + url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; + }; + dub2nix = (import dub2nix-src) { inherit pkgs; }; +in +with pkgs; [ + nixFlakes + dub + ldc + sqlite + nix-prefetch-git + validatePkgConfig + jq +] diff --git a/nix/shell-packages.nix b/nix/shell-packages.nix deleted file mode 100644 index 9e40e24..0000000 --- a/nix/shell-packages.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ pkgs ? import {} }: -let - dub2nix-src = fetchTarball { - url = "https://github.com/lionello/dub2nix/archive/master.tar.gz"; - }; - dub2nix = (import dub2nix-src) { inherit pkgs; }; -in -with pkgs; [ - nixFlakes - dub - ldc - sqlite - nix-prefetch-git - validatePkgConfig -] diff --git a/nix/shell/meson.nix b/nix/shell/meson.nix new file mode 100755 index 0000000..8c06eb8 --- /dev/null +++ b/nix/shell/meson.nix @@ -0,0 +1,10 @@ +{ pkgs ? import {} }: +pkgs.mkShell { + buildInputs = with pkgs; [ + (import ../pkgs/meson-pkgs.nix { inherit pkgs; }) + ]; + shellHook = '' + meson setup --wipe build && ninja -v -C build + ''; +} +# nix-shell nix/shell/meson.nix -- cgit v1.2.3