aboutsummaryrefslogtreecommitdiffhomepage
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/mkDub.nix25
-rw-r--r--nix/pkglst/meson-pkgs.nix17
-rw-r--r--nix/pkglst/shell-pkgs.nix (renamed from nix/shell-packages.nix)1
-rwxr-xr-xnix/shell/meson.nix10
4 files changed, 47 insertions, 6 deletions
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 <nixpkgs> {},
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 <nixpkgs> {} }:
+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/shell-packages.nix b/nix/pkglst/shell-pkgs.nix
index 9e40e24..7587c02 100644
--- a/nix/shell-packages.nix
+++ b/nix/pkglst/shell-pkgs.nix
@@ -12,4 +12,5 @@ with pkgs; [
sqlite
nix-prefetch-git
validatePkgConfig
+ jq
]
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 <nixpkgs> {} }:
+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