diff --git a/.github/generate-matrix/action.yml b/.github/generate-matrix/action.yml index 55d7c43d..22f3cc6d 100644 --- a/.github/generate-matrix/action.yml +++ b/.github/generate-matrix/action.yml @@ -37,9 +37,9 @@ runs: uses: actions/upload-artifact@v4 with: name: matrix-${{ inputs.is-initial == 'true' && 'pre' || 'post' }}.json - path: matrix-${{ inputs.is-initial == 'true' && 'pre' || 'post' }}.json + path: .result/matrix-${{ inputs.is-initial == 'true' && 'pre' || 'post' }}.json - name: Update GitHub Comment uses: marocchino/sticky-pull-request-comment@v2.9.0 with: - path: comment.md + path: .result/comment.md diff --git a/default.nix b/default.nix index e7e67341..4c1797c1 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,15 @@ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - inherit (lock.nodes.flake-compat.locked) owner repo rev narHash; + inherit (lock.nodes.flake-compat.locked) + owner + repo + rev + narHash + ; flake-compat = fetchTarball { url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; sha256 = narHash; }; - thisFlake = import flake-compat {src = ./.;}; + thisFlake = import flake-compat { src = ./.; }; in - thisFlake.defaultNix +thisFlake.defaultNix diff --git a/flake.nix b/flake.nix index e23360a7..11fdb11a 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,10 @@ description = "Nix packages for D projects"; nixConfig = { - extra-substituters = ["https://dlang-community.cachix.org"]; - extra-trusted-public-keys = ["dlang-community.cachix.org-1:eAX1RqX4PjTDPCAp/TvcZP+DYBco2nJBackkAJ2BsDQ="]; + extra-substituters = [ "https://dlang-community.cachix.org" ]; + extra-trusted-public-keys = [ + "dlang-community.cachix.org-1:eAX1RqX4PjTDPCAp/TvcZP+DYBco2nJBackkAJ2BsDQ=" + ]; }; inputs = { @@ -17,33 +19,45 @@ }; }; - outputs = inputs @ { - self, - nixpkgs, - flake-parts, - ... - }: - flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; - imports = [./pkgs ./lib/mk-gh-actions-matrix.nix]; + outputs = + inputs@{ + self, + nixpkgs, + flake-parts, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + imports = [ + ./pkgs + ./lib + ]; - perSystem = {pkgs, ...}: { - devShells.default = import ./shells/default.nix {inherit pkgs;}; - devShells.ci = import ./shells/ci.nix {inherit pkgs;}; - }; + perSystem = + { pkgs, ... }: + { + devShells.default = import ./shells/default.nix { inherit pkgs; }; + devShells.ci = import ./shells/ci.nix { inherit pkgs; }; + }; - flake.templates = let - lib = nixpkgs.lib; - allTemplates = lib.pipe (builtins.readDir ./templates) [ - (lib.filterAttrs (k: v: v == "directory")) - (builtins.mapAttrs (k: v: rec { - path = ./templates + "/${k}"; - description = lib.removeSuffix "\n" ( - builtins.readFile (path + "/description.txt") - ); - })) - ]; - in + flake.templates = + let + lib = nixpkgs.lib; + allTemplates = lib.pipe (builtins.readDir ./templates) [ + (lib.filterAttrs (k: v: v == "directory")) + (builtins.mapAttrs ( + k: v: rec { + path = ./templates + "/${k}"; + description = lib.removeSuffix "\n" (builtins.readFile (path + "/description.txt")); + } + )) + ]; + in allTemplates; }; } diff --git a/lib/build-status.nix b/lib/build-status.nix index 1fa51822..5622b17b 100644 --- a/lib/build-status.nix +++ b/lib/build-status.nix @@ -1,13 +1,15 @@ -{lib, ...}: { - getBuildStatus = package: version: system: let - data = import ./../pkgs/${package}/build-status.nix {inherit lib;}; - in - data.${version}.${system} - or { +{ lib, ... }: +{ + getBuildStatus = + package: version: system: + let + data = import ./../pkgs/${package}/build-status.nix { inherit lib; }; + in + data.${version}.${system} or { # If not build status is found, we assume that the package builds # successfully with no workarounds. build = true; check = true; - skippedTests = []; + skippedTests = [ ]; }; } diff --git a/lib/dc.nix b/lib/dc.nix new file mode 100644 index 00000000..8d634063 --- /dev/null +++ b/lib/dc.nix @@ -0,0 +1,138 @@ +{ lib }: +let + inherit (import ./version-utils.nix { }) versionBetween; +in +rec { + /** + Mapping from $DC to $DMD name + + # Type + + ``` + dcToDmdMapping :: AttrSet String + ``` + */ + dcToDmdMapping = { + "dmd" = "dmd"; + "ldc" = "ldmd2"; + "gdc" = "gdmd"; + }; + + /** + Removes the "-binary" suffix (if any) from the package name. + + # Type + + ``` + normalizedName :: String -> String + ``` + + # Examples: + + ```nix + normalizedName "dmd" + => "dmd" + + normalizedName "dmd-binary" + => "dmd" + + normalizedName "ldc-binary" + => "ldc" + ``` + */ + normalizedName = name: lib.strings.removeSuffix "-binary" name; + + /** + Given an LDC version, returns the approximate DMD frontend version. + + # Type + + ``` + ldcToDmdVersion :: String -> String + ``` + + # Examples: + + ```nix + ldcToDmdVersion "1.23.0" + => "2.093.1" + + ldcToDmdVersion "1.1.0" + => "2.071.1" + + ldcToDmdVersion "1.38.0" + => "2.108.1" + ``` + */ + ldcToDmdVersion = + ldcVersion: + let + minor = 70 + (lib.toInt (lib.versions.minor ldcVersion)); + mid = if minor < 100 then "0" + toString minor else toString minor; + in + "2.${mid}.1"; + + /** + Given a D compiler derivation, returns the information needed to + generate a DMD frontend wrapper. + + # Type + + ``` + getDCInfo :: Derivation -> { name, dmdWrapperName, dmdWrapper, frontendVersion } + ``` + + # Examples: + + ```nix + getDCInfo { + pname = "dmd"; + version = "2.093.1"; + # ... + } + => { + name = "dmd"; + dmdWrapperName = "dmd"; + dmdWrapper = "/nix/store/...-dmd/bin/dmd"; + frontendVersion = "2.093.1"; + } + + getDCInfo { + pname = "ldc"; + version = "1.23.0"; + # ... + } + => { + name = "ldc"; + dmdWrapperName = "ldmd2"; + dmdWrapper = "/nix/store/...-ldc/bin/ldmd2"; + frontendVersion = "2.093.1"; + } + ``` + */ + getDCInfo = + dCompilerDrv@{ pname, version, ... }: + let + name = normalizedName pname; + dmdWrapperName = dcToDmdMapping."${name}"; + dmdWrapper = "${dCompilerDrv}/bin/${dmdWrapperName}"; + frontendVersion = + if name == "dmd" then + version + else if name == "ldc" then + ldcToDmdVersion version + else + throw "Unsupported compiler '${name}'"; + in + { + inherit + name + dmdWrapperName + dmdWrapper + frontendVersion + ; + + frontendVersionBetween = + minVersion: maxVersion: versionBetween minVersion maxVersion frontendVersion; + }; +} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 00000000..2bffdbb2 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,9 @@ +{ self, lib, ... }: +{ + flake.lib = { + build-status = import ./build-status.nix { inherit lib; }; + dc = import ./dc.nix { inherit lib; }; + inherit (import ./mk-gh-actions-matrix.nix { inherit self lib; }) allowedToFailMap; + versionUtils = import ./version-utils.nix { }; + }; +} diff --git a/lib/mk-gh-actions-matrix.nix b/lib/mk-gh-actions-matrix.nix index ff38c395..38e7238f 100644 --- a/lib/mk-gh-actions-matrix.nix +++ b/lib/mk-gh-actions-matrix.nix @@ -1,61 +1,52 @@ -{ - lib, - self, - ... -}: { - flake = { - lib = rec { - # See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories - # See https://www.flyci.net/#pricing - nixSystemToGHPlatform = { - # GH-hosted runners: - "x86_64-linux" = "ubuntu-latest"; - # "x86_64-darwin" = "macos-13"; - macos-13 is a 4 x86_64 vCPU / 14GB RAM - # "x86_64-darwin" = "macos-14"; # - macos-14 is a 3 aarch64 vCPU / 7GB RAM (but it seems faster than the macos-13 one) - # "aarch64-darwin" = "macos-14"; +{ lib, self, ... }: +rec { + # See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories + # See https://www.flyci.net/#pricing + nixSystemToGHPlatform = { + # GH-hosted runners: + "x86_64-linux" = "ubuntu-latest"; + # "x86_64-darwin" = "macos-13"; - macos-13 is a 4 x86_64 vCPU / 14GB RAM + # "x86_64-darwin" = "macos-14"; # - macos-14 is a 3 aarch64 vCPU / 7GB RAM (but it seems faster than the macos-13 one) + # "aarch64-darwin" = "macos-14"; - # FlyCI-hosted runners: - "x86_64-darwin" = "flyci-macos-large-latest-m1"; - "aarch64-darwin" = "flyci-macos-large-latest-m1"; - }; + # FlyCI-hosted runners: + "x86_64-darwin" = "flyci-macos-large-latest-m1"; + "aarch64-darwin" = "flyci-macos-large-latest-m1"; + }; - inherit (import ./build-status.nix {inherit lib;}) getBuildStatus; + inherit (import ./build-status.nix { inherit lib; }) getBuildStatus; - allowedToFailMap = lib.pipe (mkGHActionsMatrix.include) [ - (builtins.groupBy (p: p.package)) - (builtins.mapAttrs ( - n: v: - builtins.mapAttrs ( - s: ps: - (builtins.head ps).allowedToFail - ) - (builtins.groupBy (p: p.system) v) - )) - ]; + allowedToFailMap = lib.pipe (mkGHActionsMatrix.include) [ + (builtins.groupBy (p: p.package)) + (builtins.mapAttrs ( + n: v: builtins.mapAttrs (s: ps: (builtins.head ps).allowedToFail) (builtins.groupBy (p: p.system) v) + )) + ]; - mkGHActionsMatrix = { - include = lib.pipe (builtins.attrNames nixSystemToGHPlatform) [ - (builtins.concatMap - ( - system: let - platform = nixSystemToGHPlatform.${system}; - in - map (package: let - p = self.packages.${system}.${package}; - in { - os = platform; - allowedToFail = !(p.passthru.buildStatus or (throw "${package} does not expose build status")).build; - inherit system package; - attrPath = "packages.${system}.${lib.strings.escapeNixIdentifier package}"; - }) - (builtins.attrNames self.packages.${system}) - )) - (builtins.sort (a: b: - if (a.package == b.package) - then a.os == "ubuntu-latest" - else a.package < b.package)) - ]; - }; - }; + mkGHActionsMatrix = { + include = lib.pipe (builtins.attrNames nixSystemToGHPlatform) [ + (builtins.concatMap ( + system: + let + platform = nixSystemToGHPlatform.${system}; + in + map ( + package: + let + p = self.packages.${system}.${package}; + in + { + os = platform; + allowedToFail = + !(p.passthru.buildStatus or (throw "${package} does not expose build status")).build; + inherit system package; + attrPath = "packages.${system}.${lib.strings.escapeNixIdentifier package}"; + } + ) (builtins.attrNames self.packages.${system}) + )) + (builtins.sort ( + a: b: if (a.package == b.package) then a.os == "ubuntu-latest" else a.package < b.package + )) + ]; }; } diff --git a/lib/version-catalog.nix b/lib/version-catalog.nix index b07502f6..af5e3063 100644 --- a/lib/version-catalog.nix +++ b/lib/version-catalog.nix @@ -1,72 +1,69 @@ { lib, pkgs, + self', ... -}: let - inherit (builtins) attrNames listToAttrs map mapAttrs; +}: +let + inherit (builtins) + attrNames + listToAttrs + map + mapAttrs + ; inherit (lib) nameValuePair pipe optional; inherit (pkgs) callPackage; - darwinPkgs = { + extraPkgs = { + hostDCompiler = self'.packages.ldc-bootstrap; inherit (pkgs.darwin.apple_sdk.frameworks) Foundation; }; system = pkgs.hostPlatform.system; - filterBySystem = pkgs: - lib.filterAttrs - (_name: pkg: builtins.elem system pkg.meta.platforms) - pkgs; -in { - genPkgVersions = pkgName: let - mod = ../pkgs/${pkgName}/version-catalog.nix; - inherit - (import mod) - supportedVersions - getSourceVersion - getBinaryVersion - ; + filterBySystem = pkgs: lib.filterAttrs (_name: pkg: builtins.elem system pkg.meta.platforms) pkgs; +in +{ + genPkgVersions = + pkgName: + let + mod = ../pkgs/${pkgName}/version-catalog.nix; + inherit (import mod) supportedVersions getSourceVersion getBinaryVersion; - supportedTypes = - (optional (getBinaryVersion != null) "binary") - ++ (optional (getSourceVersion != null) "source"); + supportedTypes = + (optional (getBinaryVersion != null) "binary") ++ (optional (getSourceVersion != null) "source"); - sanitizeVersion = version: builtins.replaceStrings ["."] ["_"] version; + sanitizeVersion = version: builtins.replaceStrings [ "." ] [ "_" ] version; - getVersion = type: - if type == "source" - then getSourceVersion - else getBinaryVersion; - in { - flattened = type: let - nameSuffix = - if type == "binary" - then "-binary" - else ""; + getVersion = type: if type == "source" then getSourceVersion else getBinaryVersion; in - pipe (attrNames supportedVersions."${type}") [ - ( - map ( + { + flattened = + type: + let + nameSuffix = if type == "binary" then "-binary" else ""; + in + pipe (attrNames supportedVersions."${type}") [ + (map ( version: - nameValuePair - "${pkgName}${nameSuffix}-${sanitizeVersion version}" - (callPackage (getVersion type version) darwinPkgs) - ) - ) - listToAttrs - filterBySystem - ]; + nameValuePair "${pkgName}${nameSuffix}-${sanitizeVersion version}" ( + callPackage (getVersion type version) extraPkgs + ) + )) + listToAttrs + filterBySystem + ]; - hierarchical = { - "${pkgName}" = pipe supportedTypes [ - (map (type: - nameValuePair type ( - mapAttrs - (version: _: (callPackage (getVersion type version) darwinPkgs)) - supportedVersions."${type}" - ))) - listToAttrs - filterBySystem - ]; + hierarchical = { + "${pkgName}" = pipe supportedTypes [ + (map ( + type: + nameValuePair type ( + mapAttrs (version: _: (callPackage (getVersion type version) extraPkgs)) supportedVersions."${type}" + ) + )) + listToAttrs + filterBySystem + ]; + }; }; - }; } diff --git a/lib/version-utils.nix b/lib/version-utils.nix index 6769a5d5..b2b47902 100644 --- a/lib/version-utils.nix +++ b/lib/version-utils.nix @@ -1,5 +1,6 @@ -{...}: { - versionBetween = after: before: version: - ((builtins.compareVersions version after) >= 0) - && ((builtins.compareVersions version before) < 0); +{ ... }: +{ + versionBetween = + after: before: version: + ((builtins.compareVersions version after) >= 0) && ((builtins.compareVersions version before) < 0); } diff --git a/pkgs/default.nix b/pkgs/default.nix index 5ad9392f..9e6eafdb 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,46 +1,40 @@ -{ - inputs, - lib, - ... -}: let +{ inputs, lib, ... }: +let inherit (lib) optionalAttrs; -in { - imports = [inputs.flake-parts.flakeModules.easyOverlay]; - - perSystem = { - self', - pkgs, - ... - }: let - inherit - (import ../lib/version-catalog.nix {inherit lib pkgs;}) - genPkgVersions - ; - in { - overlayAttrs = self'.packages; - legacyPackages = - {} - // (genPkgVersions "dmd").hierarchical - // (genPkgVersions "ldc").hierarchical - // (genPkgVersions "dub").hierarchical; +in +{ + imports = [ inputs.flake-parts.flakeModules.easyOverlay ]; - packages = - { - ldc-binary = self'.packages."ldc-binary-1_34_0"; - ldc = self'.packages."ldc-1_30_0"; + perSystem = + { self', pkgs, ... }: + let + inherit (import ../lib/version-catalog.nix { inherit lib pkgs self'; }) genPkgVersions; + in + { + overlayAttrs = self'.packages; + legacyPackages = + { } + // (genPkgVersions "dmd").hierarchical + // (genPkgVersions "ldc").hierarchical + // (genPkgVersions "dub").hierarchical; - dub = self'.packages."dub-1_30_0"; - } - // (genPkgVersions "ldc").flattened "binary" - // (genPkgVersions "ldc").flattened "source" - // (genPkgVersions "dub").flattened "source" - // optionalAttrs pkgs.hostPlatform.isx86 ( + packages = { - dmd-bootstrap = self'.packages."dmd-binary-2_098_0"; - dmd = self'.packages."dmd-2_105_2"; + ldc-bootstrap = self'.packages."ldc-binary-1_25_0"; + ldc = self'.packages."ldc-1_30_0"; + + dub = self'.packages."dub-1_30_0"; } - // (genPkgVersions "dmd").flattened "binary" - // (genPkgVersions "dmd").flattened "source" - ); - }; + // (genPkgVersions "ldc").flattened "binary" + // (genPkgVersions "ldc").flattened "source" + // (genPkgVersions "dub").flattened "source" + // optionalAttrs pkgs.hostPlatform.isx86 ( + { + dmd-bootstrap = self'.packages."dmd-binary-2_098_0"; + dmd = self'.packages."dmd-2_105_2"; + } + // (genPkgVersions "dmd").flattened "binary" + // (genPkgVersions "dmd").flattened "source" + ); + }; } diff --git a/pkgs/dmd/binary.nix b/pkgs/dmd/binary.nix index 90f7a993..a15d5a02 100644 --- a/pkgs/dmd/binary.nix +++ b/pkgs/dmd/binary.nix @@ -1,7 +1,5 @@ +{ version, hashes }: { - version, - hashes, -}: { lib, stdenv, fetchurl, @@ -11,73 +9,75 @@ fixDarwinDylibNames, gccForLibs, ... -}: let +}: +let inherit (stdenv) hostPlatform; - inherit (import ../../lib/build-status.nix {inherit lib;}) getBuildStatus; + inherit (import ../../lib/build-status.nix { inherit lib; }) getBuildStatus; buildStatus = getBuildStatus "dmd" version stdenv.system; - OS = - if hostPlatform.isDarwin - then "osx" - else hostPlatform.parsed.kernel.name; - MODEL = - if OS == "osx" - then "" - else toString hostPlatform.parsed.cpu.bits; + OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name; + MODEL = if OS == "osx" then "" else toString hostPlatform.parsed.cpu.bits; in - stdenv.mkDerivation { - pname = "dmd-binary"; - inherit version; +stdenv.mkDerivation { + pname = "dmd-binary"; + inherit version; - passthru = { - inherit buildStatus; - }; + passthru = { + inherit buildStatus; + }; - src = fetchurl rec { - name = "dmd.${version}.${OS}.tar.xz"; - url = "http://downloads.dlang.org/releases/2.x/${version}/${name}"; - sha256 = hashes.${OS} or (throw "missing bootstrap sha256 for OS ${OS}"); - }; + src = fetchurl rec { + name = "dmd.${version}.${OS}.tar.xz"; + url = "http://downloads.dlang.org/releases/2.x/${version}/${name}"; + sha256 = hashes.${OS} or (throw "missing bootstrap sha256 for OS ${OS}"); + }; - dontConfigure = true; - dontBuild = true; + dontConfigure = true; + dontBuild = true; - nativeBuildInputs = - lib.optional hostPlatform.isLinux autoPatchelfHook - ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames; + nativeBuildInputs = + lib.optional hostPlatform.isLinux autoPatchelfHook + ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames; - propagatedBuildInputs = - [curl tzdata] - ++ (lib.optional hostPlatform.isLinux gccForLibs.libgcc) - ++ (lib.optional (lib.versionOlder version "2.084.0") stdenv.cc.cc.lib); + propagatedBuildInputs = + [ + curl + tzdata + ] + ++ (lib.optional hostPlatform.isLinux gccForLibs.libgcc) + ++ (lib.optional (lib.versionOlder version "2.084.0") stdenv.cc.cc.lib); - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - mkdir -p $out + mkdir -p $out - # Move `src`, `bin` and `lib` into place: - mv -v ${OS}/bin${MODEL} $out/bin - mv -v src ${OS}/lib${MODEL} $out/ + # Move `src`, `bin` and `lib` into place: + mv -v ${OS}/bin${MODEL} $out/bin + mv -v src ${OS}/lib${MODEL} $out/ - # fix paths in dmd.conf (one level less) - substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../" + # fix paths in dmd.conf (one level less) + substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../" - runHook postInstall - ''; + runHook postInstall + ''; - # Stripping on Darwin started to break libphobos2.a - # Undefined symbols for architecture x86_64: - # "_rt_envvars_enabled", referenced from: - # __D2rt6config16rt_envvarsOptionFNbNiAyaMDFNbNiQkZQnZQq in libphobos2.a(config_99a_6c3.o) - dontStrip = hostPlatform.isDarwin; + # Stripping on Darwin started to break libphobos2.a + # Undefined symbols for architecture x86_64: + # "_rt_envvars_enabled", referenced from: + # __D2rt6config16rt_envvarsOptionFNbNiAyaMDFNbNiQkZQnZQq in libphobos2.a(config_99a_6c3.o) + dontStrip = hostPlatform.isDarwin; - meta = with lib; { - description = "Digital Mars D Compiler Package"; - license = licenses.boost; - maintainers = [maintainers.lionello]; - homepage = "https://dlang.org/"; - platforms = ["x86_64-darwin" "i686-linux" "x86_64-linux"]; - }; - } + meta = with lib; { + description = "Digital Mars D Compiler Package"; + license = licenses.boost; + maintainers = [ maintainers.lionello ]; + homepage = "https://dlang.org/"; + platforms = [ + "x86_64-darwin" + "i686-linux" + "x86_64-linux" + ]; + }; +} diff --git a/pkgs/dmd/build-status.nix b/pkgs/dmd/build-status.nix index e47b468f..a0a88f76 100644 --- a/pkgs/dmd/build-status.nix +++ b/pkgs/dmd/build-status.nix @@ -1,19 +1,24 @@ -{lib}: let - inherit (lib) versionOlder versionAtLeast nameValuePair listToAttrs; +{ lib }: +let + inherit (lib) + versionOlder + versionAtLeast + nameValuePair + listToAttrs + ; - versionBetween = after: before: version: - ((builtins.compareVersions version after) >= 0) - && ((builtins.compareVersions version before) <= 0); + versionBetween = + after: before: version: + ((builtins.compareVersions version after) >= 0) && ((builtins.compareVersions version before) <= 0); - supportedVersions = - builtins.attrNames - (lib.importJSON ./supported-source-versions.json); + supportedVersions = builtins.attrNames (lib.importJSON ./supported-source-versions.json); latestVersion = lib.last supportedVersions; - mergeVersions = attrs: lib.foldr lib.recursiveUpdate {} attrs; + mergeVersions = attrs: lib.foldr lib.recursiveUpdate { } attrs; - between = start: end: func: + between = + start: end: func: lib.pipe supportedVersions [ (builtins.filter (version: versionBetween start end version)) (builtins.map (version: nameValuePair version (func version))) @@ -23,15 +28,13 @@ getInfo = version: rec { hasDruntimeRepo = versionOlder version "2.101.0"; - dmdTestDir = - if hasDruntimeRepo - then "dmd/test" - else "dmd/compiler/test"; + dmdTestDir = if hasDruntimeRepo then "dmd/test" else "dmd/compiler/test"; cxxTestDir = - if lib.versionAtLeast version "2.092.0" - then "${dmdTestDir}/runnable_cxx" - else "${dmdTestDir}/runnable"; + if lib.versionAtLeast version "2.092.0" then + "${dmdTestDir}/runnable_cxx" + else + "${dmdTestDir}/runnable"; skippedTests = [ @@ -53,84 +56,76 @@ "${dmdTestDir}/runnable/cdvecfill.sh" "${dmdTestDir}/compilable/cdcmp.d" ] - ++ lib.optionals (versionBetween "2.089.0" "2.092.2" version) [ - "${dmdTestDir}/dshell/test6952.d" - ]; + ++ lib.optionals (versionBetween "2.089.0" "2.092.2" version) [ "${dmdTestDir}/dshell/test6952.d" ]; - darwinSkippedTests = let - tests = - skippedTests - ++ [ - "${cxxTestDir}/cpp11.d" - "${cxxTestDir}/cpp_stdlib.d" - "${cxxTestDir}/cppa.d" - "${cxxTestDir}/externmangle2.d" - "${cxxTestDir}/cpp_abi_tests.d" - "${cxxTestDir}/externmangle.d" - "${dmdTestDir}/dshell/dll_cxx.d" - ] - ++ lib.optionals (versionBetween "2.099.0" latestVersion version) [ - "${cxxTestDir}/test22287.d" - "${cxxTestDir}/test7925.d" - ] - ++ lib.optionals (versionBetween "2.101.0" latestVersion version) [ - "${cxxTestDir}/test23135.d" - ] - ++ ( - if versionBetween "2.092.1" "2.098.1" version - then - if versionBetween "2.092.1" "2.097.2" version - then [ - "${dmdTestDir}/runnable/test15779.d" - "${dmdTestDir}/runnable/test17868.d" - "${dmdTestDir}/runnable/test17868b.d" - ] - else [ - "${dmdTestDir}/runnable/test17868.d" - "${dmdTestDir}/runnable/test17868b.d" - ] - else if versionBetween "2.100.0" "2.105.3" version - then [ - "${dmdTestDir}/runnable/objc_class.d" - "${dmdTestDir}/runnable/objc_self_test.d" + darwinSkippedTests = + let + tests = + skippedTests + ++ [ + "${cxxTestDir}/cpp11.d" + "${cxxTestDir}/cpp_stdlib.d" + "${cxxTestDir}/cppa.d" + "${cxxTestDir}/externmangle2.d" + "${cxxTestDir}/cpp_abi_tests.d" + "${cxxTestDir}/externmangle.d" + "${dmdTestDir}/dshell/dll_cxx.d" ] - else if versionAtLeast "2.105.5" version - then [ - "${dmdTestDir}/runnable/objc_class.d" - "${dmdTestDir}/runnable/objc_self_test.d" + ++ lib.optionals (versionBetween "2.099.0" latestVersion version) [ + "${cxxTestDir}/test22287.d" + "${cxxTestDir}/test7925.d" ] - else [] - ); - in + ++ lib.optionals (versionBetween "2.101.0" latestVersion version) [ "${cxxTestDir}/test23135.d" ] + ++ ( + if versionBetween "2.092.1" "2.098.1" version then + if versionBetween "2.092.1" "2.097.2" version then + [ + "${dmdTestDir}/runnable/test15779.d" + "${dmdTestDir}/runnable/test17868.d" + "${dmdTestDir}/runnable/test17868b.d" + ] + else + [ + "${dmdTestDir}/runnable/test17868.d" + "${dmdTestDir}/runnable/test17868b.d" + ] + else if versionBetween "2.100.0" "2.105.3" version then + [ + "${dmdTestDir}/runnable/objc_class.d" + "${dmdTestDir}/runnable/objc_self_test.d" + ] + else if versionAtLeast "2.105.5" version then + [ + "${dmdTestDir}/runnable/objc_class.d" + "${dmdTestDir}/runnable/objc_self_test.d" + ] + else + [ ] + ); + in lib.naturalSort tests; }; in - mergeVersions [ - ( - between "2.092.0" "2.105.4" (version: { - x86_64-linux = { - build = true; - check = true; - skippedTests = (getInfo version).skippedTests; - }; - }) - ) - ( - between "2.092.0" "2.096.2" (version: { - x86_64-darwin = { - build = true; - check = false; - skippedTests = (getInfo version).darwinSkippedTests; - }; - }) - ) - ( - between "2.098.0" "2.105.4" (version: { - x86_64-darwin = { - build = true; - check = true; - skippedTests = (getInfo version).darwinSkippedTests; - }; - }) - ) - ] +mergeVersions [ + (between "2.092.0" "2.105.4" (version: { + x86_64-linux = { + build = true; + check = true; + skippedTests = (getInfo version).skippedTests; + }; + })) + (between "2.092.0" "2.096.2" (version: { + x86_64-darwin = { + build = true; + check = false; + skippedTests = (getInfo version).darwinSkippedTests; + }; + })) + (between "2.098.0" "2.105.4" (version: { + x86_64-darwin = { + build = true; + check = true; + skippedTests = (getInfo version).darwinSkippedTests; + }; + })) +] diff --git a/pkgs/dmd/default.nix b/pkgs/dmd/default.nix deleted file mode 100644 index 2f63b6af..00000000 --- a/pkgs/dmd/default.nix +++ /dev/null @@ -1 +0,0 @@ -import ./2.100.nix diff --git a/pkgs/dmd/flake.nix b/pkgs/dmd/flake.nix deleted file mode 100644 index b6941435..00000000 --- a/pkgs/dmd/flake.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - inputs = { - dmd = { - url = github:dlang/dmd; - flake = false; - }; - druntime = { - url = github:dlang/druntime; - flake = false; - }; - phobos = { - url = github:dlang/phobos; - flake = false; - }; - tools = { - url = github:dlang/tools; - flake = false; - }; - primary.follows = "dmd"; - }; - outputs = {...}: let - versionBetween = after: before: version: - ((builtins.compareVersions version after) >= 0) - && ((builtins.compareVersions version before) < 0); - in { - isVersionSupported = version: versionBetween "2.092.1" "2.105.2" version; - }; -} diff --git a/pkgs/dmd/generic.nix b/pkgs/dmd/generic.nix index a1987b9b..cd4ef8a2 100644 --- a/pkgs/dmd/generic.nix +++ b/pkgs/dmd/generic.nix @@ -12,7 +12,8 @@ enableProfile ? false, enableRelease ? true, enableUnittest ? false, -}: { +}: +{ stdenv, lib, fetchFromGitHub, @@ -25,40 +26,24 @@ gdb, gcc11, Foundation, - callPackage, targetPackages, fetchpatch, bash, installShellFiles, git, unzip, - buildCompiler ? callPackage ./bootstrap.nix {}, -}: let - inherit (import ../../lib/build-status.nix {inherit lib;}) getBuildStatus; - inherit (import ../../lib/version-utils.nix {inherit lib;}) versionBetween; - - # results in "dmd" or "ldc", maybe "gdc" in the future. - buildCompilerAPI = builtins.substring 0 3 buildCompiler.name; - - # todo: replace buildCompilerPath with `getDmdWrapper buildCompiler` once - # pull request 53 is merged - in with (if buildCompilerAPI == "dmd" then { - buildCompilerPath = buildCompiler + /bin/dmd; - buildFrontendVersion = buildCompiler.version; - } - else if buildCompilerAPI == "ldc" then { - buildCompilerPath = buildCompiler + /bin/ldmd2; - - # Close enough! This gives the correct minor version number for all versions - # from 2.070 to 2.107 (the newest as of writing) - buildFrontendVersion = "2." - + toString (builtins.fromJSON (lib.versions.minor buildCompiler.version) + 70) + ".1"; - } - else throw ("Unrecognised build compiler " + buildCompiler.name)); let + hostDCompiler, +}: +let + inherit (import ../../lib/build-status.nix { inherit lib; }) getBuildStatus; + inherit (import ../../lib/version-utils.nix { inherit lib; }) versionBetween; + inherit (import ../../lib/dc.nix { inherit lib; }) getDCInfo; + + hostDCInfo = getDCInfo hostDCompiler; buildStatus = getBuildStatus "dmd" version stdenv.system; - pathConfig = runCommand "phobos-tzdata-curl-paths" {} '' + pathConfig = runCommand "phobos-tzdata-curl-paths" { } '' mkdir $out echo '${tzdata}/share/zoneinfo/' > $out/TZDatabaseDirFile echo '${lib.getLib curl}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}' > $out/LibcurlPathFile @@ -68,7 +53,7 @@ dmdConfFile = writeTextFile { name = "dmd.conf"; - text = lib.generators.toINI {} { + text = lib.generators.toINI { } { Environment = { DFLAGS = builtins.concatStringsSep " " [ "-I@out@/include/dmd" @@ -82,38 +67,23 @@ }; bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; - os = - if stdenv.isDarwin - then "osx" - else stdenv.hostPlatform.parsed.kernel.name; + os = if stdenv.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; - buildMode = - if enableRelease - then "release" - else "debug"; + buildMode = if enableRelease then "release" else "debug"; buildPath = "generated/${os}/${buildMode}/${bits}"; druntimeRepo = lib.versionOlder version "2.101.0"; - dmdPrefix = - if druntimeRepo - then "dmd" - else "dmd/compiler"; + dmdPrefix = if druntimeRepo then "dmd" else "dmd/compiler"; - druntimePrefix = - if druntimeRepo - then "druntime" - else "dmd/druntime"; + druntimePrefix = if druntimeRepo then "druntime" else "dmd/druntime"; - commonBuildFlags = {forMake}: + commonBuildFlags = + { forMake }: [ "SHELL=${bash}/bin/bash" "DMD=$(NIX_BUILD_TOP)/dmd/${buildPath}/dmd" - "CC=${ - if stdenv.isDarwin - then stdenv.cc - else gcc11 - }/bin/cc" - "HOST_DMD=${ buildCompilerPath }" + "CC=${if stdenv.isDarwin then stdenv.cc else gcc11}/bin/cc" + "HOST_DMD=${hostDCInfo.dmdWrapper}" "PIC=1" "BUILD=${buildMode}" ] @@ -128,243 +98,266 @@ ++ lib.optional enableProfile "ENABLE_PROFILE=1" ++ lib.optional enableUnittest "ENABLE_UNITTEST=1" ++ lib.optional enableCoverage "ENABLE_COVERAGE=1"; -in stdenv.mkDerivation rec { - pname = "dmd"; - inherit version; +in +stdenv.mkDerivation rec { + pname = "dmd"; + inherit version; - passthru = { - inherit buildStatus; - }; + passthru = { + inherit buildStatus; + }; - enableParallelBuilding = true; - - srcs = - [ - (fetchFromGitHub { - owner = "dlang"; - repo = "dmd"; - rev = "v${version}"; - sha256 = dmdSha256; - name = "dmd"; - }) - (fetchFromGitHub { - owner = "dlang"; - repo = "phobos"; - rev = "v${version}"; - sha256 = phobosSha256; - name = "phobos"; - }) - (fetchFromGitHub { - owner = "dlang"; - repo = "tools"; - rev = "v${version}"; - sha256 = toolsSha256; - name = "tools"; - }) - ] - ++ lib.optionals druntimeRepo [ - (fetchFromGitHub { - owner = "dlang"; - repo = "druntime"; - rev = "v${version}"; - sha256 = druntimeSha256; - name = "druntime"; - }) - ]; - - sourceRoot = "."; - - # https://issues.dlang.org/show_bug.cgi?id=19553 - hardeningDisable = ["fortify"]; - - patches = - lib.optionals (lib.versionOlder version "2.088.0") [ - # Migrates D1-style operator overloads in DMD source, to allow building with - # a newer DMD - (fetchpatch { - url = "https://github.com/dlang/dmd/commit/c4d33e5eb46c123761ac501e8c52f33850483a8a.patch"; - stripLen = 1; - extraPrefix = "dmd/"; - sha256 = "sha256-N21mAPfaTo+zGCip4njejasraV5IsWVqlGR5eOdFZZE="; - }) - ] - ++ lib.optionals (lib.versionOlder version "2.091.0") [ - # Patches deprecated printf formats in dmd backend - (fetchpatch { - url = "https://github.com/dlang/dmd/commit/efe6d473c30c07074461f3de0b7a8ba1343c5429.patch"; - stripLen = 1; - extraPrefix = "dmd/"; - sha256 = "sha256-DdAIHK42q4vyVJsuTN0nRZAAjWXRBZHY8oUidW4pMwI="; - }) - ] - ++ lib.optionals (lib.versionOlder version "2.096.1") [ - # Stop using feature deprecated from 2.097.0 on, link: - # https://dlang.org/changelog/2.097.0.html#fqn-bypass-deprecation - (fetchpatch { - url = "https://github.com/dlang/dmd/commit/5198eedf6ef4e113773c15eff42de195be438fa1.patch"; - stripLen = 1; - extraPrefix = "dmd/"; - sha256 = "sha256-4Bd3YD14jzMelVvR2t738Dtrf7xMlWJM6AdsB34wKyM="; - }) - ] - ++ lib.optionals (lib.versionOlder version "2.092.2") [ - # Fixes C++ tests that compiled on older C++ but not on the current one - (fetchpatch { - url = "https://github.com/dlang/druntime/commit/438990def7e377ca1f87b6d28246673bb38022ab.patch"; - stripLen = 1; - extraPrefix = "druntime/"; - sha256 = "sha256-/pPKK7ZK9E/mBrxm2MZyBNhYExE8p9jz8JqBdZSE6uY="; - }) - ] - ++ lib.optionals (versionBetween "2.102.2" "2.104.0" version) [ - (fetchpatch { - # Fix for: https://issues.dlang.org/show_bug.cgi?id=23846 - # Implemented in: https://github.com/dlang/dmd/pull/15139 - url = "https://github.com/dlang/dmd/commit/deaf1b81986c57d31a1b1163301ca4d157505220.patch"; - stripLen = 1; - extraPrefix = "dmd/"; - sha256 = "sha256-xgaIraFH3ZfIn99ms148MP7cKV63JgU90yEYq21noRw="; - }) - ]; - - postPatch = - # Older compilers use -dip25 in their build flags, but if the build - # compiler is 2.092 or newer it doesn't need it anymore, and from - # 2.103 on using the flag is a deprecation error. - lib.optionalString (lib.versionAtLeast buildFrontendVersion "2.092.0") '' - substituteInPlace ${dmdPrefix}/src/build.d --replace '"-dip25"' "" - '' - + '' - patchShebangs ${dmdPrefix}/test/{runnable,fail_compilation,compilable,tools}{,/extra-files}/*.sh - - # Grep'd string changed with gdb 12 - # https://issues.dlang.org/show_bug.cgi?id=23198 - substituteInPlace ${druntimePrefix}/test/exceptions/Makefile \ - --replace 'in D main (' 'in _Dmain (' - - # We're using gnused on all platforms - substituteInPlace ${druntimePrefix}/test/coverage/Makefile \ - --replace 'freebsd osx' 'none' - '' - + lib.optionalString (lib.versionAtLeast version "2.092.2") '' - substituteInPlace ${dmdPrefix}/test/dshell/test6952.d --replace "/usr/bin/env bash" "${bash}/bin/bash" - '' - # This test causes a linking failure before - # https://github.com/dlang/dmd/commit/cab51f946a8b2d3f0fcb856cf6c52a18a6779930 - + lib.optionalString stdenv.isLinux '' - substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" - '' - + lib.optionalString stdenv.isDarwin '' - substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" - ''; - - nativeBuildInputs = - [ - makeWrapper - which - installShellFiles - ] - ++ lib.optional (lib.versionOlder version "2.088.0") git; - - buildInputs = [curl tzdata] ++ lib.optional stdenv.isDarwin Foundation; - - nativeCheckInputs = [gdb] ++ lib.optional (lib.versionOlder version "2.089.0") unzip; - - dontConfigure = true; - - buildFlags = commonBuildFlags {forMake=true;}; - - # Build and install are based on http://wiki.dlang.org/Building_DMD - buildPhase = '' - runHook preBuild - - export buildJobs=$NIX_BUILD_CORES - if [ -z $enableParallelBuilding ]; then - buildJobs=1 - fi - export MAKEFLAGS="-j$buildJobs" - - make -C dmd $buildFlags - ${ - lib.optionalString druntimeRepo - "make -C druntime $buildFlags" - } - make -C phobos $buildFlags DFLAGS="${phobosDflags}" - make -C tools $buildFlags - - runHook postBuild + enableParallelBuilding = true; + + srcs = + [ + (fetchFromGitHub { + owner = "dlang"; + repo = "dmd"; + rev = "v${version}"; + sha256 = dmdSha256; + name = "dmd"; + }) + (fetchFromGitHub { + owner = "dlang"; + repo = "phobos"; + rev = "v${version}"; + sha256 = phobosSha256; + name = "phobos"; + }) + (fetchFromGitHub { + owner = "dlang"; + repo = "tools"; + rev = "v${version}"; + sha256 = toolsSha256; + name = "tools"; + }) + ] + ++ lib.optionals druntimeRepo [ + (fetchFromGitHub { + owner = "dlang"; + repo = "druntime"; + rev = "v${version}"; + sha256 = druntimeSha256; + name = "druntime"; + }) + ]; + + sourceRoot = "."; + + # https://issues.dlang.org/show_bug.cgi?id=19553 + hardeningDisable = [ "fortify" ]; + + patches = + lib.optionals (lib.versionOlder version "2.088.0") [ + # Migrates D1-style operator overloads in DMD source, to allow building with + # a newer DMD + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/c4d33e5eb46c123761ac501e8c52f33850483a8a.patch"; + stripLen = 1; + extraPrefix = "dmd/"; + sha256 = "sha256-N21mAPfaTo+zGCip4njejasraV5IsWVqlGR5eOdFZZE="; + }) + ] + ++ lib.optionals (lib.versionOlder version "2.091.0") [ + # Patches deprecated printf formats in dmd backend + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/efe6d473c30c07074461f3de0b7a8ba1343c5429.patch"; + stripLen = 1; + extraPrefix = "dmd/"; + sha256 = "sha256-DdAIHK42q4vyVJsuTN0nRZAAjWXRBZHY8oUidW4pMwI="; + }) + ] + ++ lib.optionals (lib.versionOlder version "2.096.1") [ + # Stop using feature deprecated from 2.097.0 on, link: + # https://dlang.org/changelog/2.097.0.html#fqn-bypass-deprecation + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/5198eedf6ef4e113773c15eff42de195be438fa1.patch"; + stripLen = 1; + extraPrefix = "dmd/"; + sha256 = "sha256-4Bd3YD14jzMelVvR2t738Dtrf7xMlWJM6AdsB34wKyM="; + }) + ] + ++ lib.optionals (lib.versionOlder version "2.092.2") [ + # Fixes C++ tests that compiled on older C++ but not on the current one + (fetchpatch { + url = "https://github.com/dlang/druntime/commit/438990def7e377ca1f87b6d28246673bb38022ab.patch"; + stripLen = 1; + extraPrefix = "druntime/"; + sha256 = "sha256-/pPKK7ZK9E/mBrxm2MZyBNhYExE8p9jz8JqBdZSE6uY="; + }) + ] + ++ lib.optionals (versionBetween "2.092.0" "2.101.0" version) [ + # `src/dmd/backend/cg.d` and `src/dmd/backend/var.d` contained arrays defined as + # result from IIFE at CT. These function expressions were inside a + # `extern (C++):` block, however they were returning static arrays, which + # is not allowed in C++. This patch marks them as `extern (D)`, to avoid + # this issue. + # See: https://github.com/dlang/dmd/pull/14127 + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/c4cea697e8658f103a69967587e75dd130506304.patch"; + stripLen = 1; + extraPrefix = "dmd/"; + sha256 = "sha256-JO52sxliPFjCe4qyo/eyWhDTg1x5bh1+7gPj1SYXIh8="; + }) + ] + ++ lib.optionals (versionBetween "2.102.2" "2.104.0" version) [ + (fetchpatch { + # Fix for: https://issues.dlang.org/show_bug.cgi?id=23846 + # Implemented in: https://github.com/dlang/dmd/pull/15139 + url = "https://github.com/dlang/dmd/commit/deaf1b81986c57d31a1b1163301ca4d157505220.patch"; + stripLen = 1; + extraPrefix = "dmd/"; + sha256 = "sha256-xgaIraFH3ZfIn99ms148MP7cKV63JgU90yEYq21noRw="; + }) + ]; + + postPatch = + # Older compilers use -dip25 in their build flags, but if the build + # compiler is 2.092 or newer it doesn't need it anymore, and from + # 2.103 on using the flag is a deprecation error. + lib.optionalString (lib.versionAtLeast hostDCInfo.frontendVersion "2.092.0") '' + substituteInPlace ${dmdPrefix}/src/build.d --replace '"-dip25"' "" + '' + + lib.optionalString (versionBetween "2.092.0" "2.103.0" version) '' + substituteInPlace ${dmdPrefix}/src/build.d --replace '"-w", "-de",' "" + '' + + '' + patchShebangs ${dmdPrefix}/test/{runnable,fail_compilation,compilable,tools}{,/extra-files}/*.sh + + # Grep'd string changed with gdb 12 + # https://issues.dlang.org/show_bug.cgi?id=23198 + substituteInPlace ${druntimePrefix}/test/exceptions/Makefile \ + --replace 'in D main (' 'in _Dmain (' + + # We're using gnused on all platforms + substituteInPlace ${druntimePrefix}/test/coverage/Makefile \ + --replace 'freebsd osx' 'none' + '' + + lib.optionalString (lib.versionAtLeast version "2.092.2") '' + substituteInPlace ${dmdPrefix}/test/dshell/test6952.d --replace "/usr/bin/env bash" "${bash}/bin/bash" + '' + # This test causes a linking failure before + # https://github.com/dlang/dmd/commit/cab51f946a8b2d3f0fcb856cf6c52a18a6779930 + + lib.optionalString stdenv.isLinux '' + substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" + '' + + lib.optionalString stdenv.isDarwin '' + substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" ''; - doCheck = buildStatus.check; + nativeBuildInputs = [ + makeWrapper + which + installShellFiles + ] ++ lib.optional (lib.versionOlder version "2.088.0") git; + + buildInputs = [ + curl + tzdata + ] ++ lib.optional stdenv.isDarwin Foundation; + + nativeCheckInputs = [ gdb ] ++ lib.optional (lib.versionOlder version "2.089.0") unzip; - checkInputs = lib.optional stdenv.isDarwin Foundation; + dontConfigure = true; - checkFlagsMake = commonBuildFlags {forMake=true;} ++ ["N=$(checkJobs)"]; - checkFlagsRunD = commonBuildFlags {forMake=false;}; + buildFlags = commonBuildFlags { forMake = true; }; - # many tests are disbled because they are failing - # NOTE: Purity check is disabled for checkPhase because it doesn't fare well - # with the DMD linker. See https://github.com/NixOS/nixpkgs/issues/97420 - checkPhase = '' - runHook preCheck - ${ - lib.optionalString (buildStatus.skippedTests != []) - (lib.concatMapStringsSep "\n" (test: ''rm -v ${test}'') buildStatus.skippedTests) - } - export checkJobs=$NIX_BUILD_CORES - if [ -z $enableParallelChecking ]; then - checkJobs=1 - fi + # Build and install are based on http://wiki.dlang.org/Building_DMD + buildPhase = '' + runHook preBuild - export MAKEFLAGS="-j$checkJobs" + export buildJobs=$NIX_BUILD_CORES + if [ -z $enableParallelBuilding ]; then + buildJobs=1 + fi + export MAKEFLAGS="-j$buildJobs" - # This will also test DRuntime for versions without - # a separate DRuntime repo - (NIX_ENFORCE_PURITY= \ - cd ${dmdPrefix}/test && env $checkFlagsRunD ${buildCompiler + /bin/rdmd} run.d -j $checkJobs all) + make -C dmd $buildFlags + ${lib.optionalString druntimeRepo "make -C druntime $buildFlags"} + make -C phobos $buildFlags DFLAGS="${phobosDflags}" + make -C tools $buildFlags - ${lib.optionalString druntimeRepo '' - NIX_ENFORCE_PURITY= \ - make -C druntime unittest $checkFlagsMake - ''} + runHook postBuild + ''; + + doCheck = buildStatus.check; + + checkInputs = lib.optional stdenv.isDarwin Foundation; + + checkFlagsMake = commonBuildFlags { forMake = true; } ++ [ "N=$(checkJobs)" ]; + checkFlagsRunD = commonBuildFlags { forMake = false; }; + + # many tests are disbled because they are failing + # NOTE: Purity check is disabled for checkPhase because it doesn't fare well + # with the DMD linker. See https://github.com/NixOS/nixpkgs/issues/97420 + checkPhase = '' + runHook preCheck + ${lib.optionalString (buildStatus.skippedTests != [ ]) ( + lib.concatMapStringsSep "\n" (test: ''rm -v ${test}'') buildStatus.skippedTests + )} + export checkJobs=$NIX_BUILD_CORES + if [ -z $enableParallelChecking ]; then + checkJobs=1 + fi + + export MAKEFLAGS="-j$checkJobs" + + # This will also test DRuntime for versions without + # a separate DRuntime repo + (NIX_ENFORCE_PURITY= \ + cd ${dmdPrefix}/test && env $checkFlagsRunD ${hostDCompiler + /bin/rdmd} run.d -j $checkJobs all) + ${lib.optionalString druntimeRepo '' NIX_ENFORCE_PURITY= \ - make -C phobos unittest $checkFlagsMake DFLAGS="${phobosDflags}" + make -C druntime unittest $checkFlagsMake + ''} - runHook postCheck - ''; + NIX_ENFORCE_PURITY= \ + make -C phobos unittest $checkFlagsMake DFLAGS="${phobosDflags}" - installPhase = '' - runHook preInstall + runHook postCheck + ''; - install -Dm755 dmd/${buildPath}/dmd $out/bin/dmd + installPhase = '' + runHook preInstall - installManPage dmd/docs/man/man*/* + install -Dm755 dmd/${buildPath}/dmd $out/bin/dmd - mkdir -p $out/include/dmd - cp -r {${druntimePrefix}/import/*,phobos/{std,etc}} $out/include/dmd/ + installManPage dmd/docs/man/man*/* - mkdir $out/lib - cp phobos/${buildPath}/libphobos2.* $out/lib/ + mkdir -p $out/include/dmd + cp -r {${druntimePrefix}/import/*,phobos/{std,etc}} $out/include/dmd/ - wrapProgram $out/bin/dmd \ - --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ - --set-default CC "${targetPackages.stdenv.cc}/bin/cc" + mkdir $out/lib + cp phobos/${buildPath}/libphobos2.* $out/lib/ - substitute ${dmdConfFile} "$out/bin/dmd.conf" --subst-var out + wrapProgram $out/bin/dmd \ + --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ + --set-default CC "${targetPackages.stdenv.cc}/bin/cc" - for tool in rdmd ddemangle dustmite; do - install -Dm755 tools/generated/${os}/${bits}/$tool $out/bin/$tool - done + substitute ${dmdConfFile} "$out/bin/dmd.conf" --subst-var out - runHook postInstall - ''; + for tool in rdmd ddemangle dustmite; do + install -Dm755 tools/generated/${os}/${bits}/$tool $out/bin/$tool + done - meta = with lib; { - description = "Official reference compiler for the D language"; - homepage = "https://dlang.org/"; - license = licenses.boost; - maintainers = with maintainers; [ThomasMader lionello dukc]; - platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; - }; - } + runHook postInstall + ''; + + meta = with lib; { + description = "Official reference compiler for the D language"; + homepage = "https://dlang.org/"; + license = licenses.boost; + maintainers = with maintainers; [ + ThomasMader + lionello + dukc + ]; + platforms = [ + "x86_64-linux" + "i686-linux" + "x86_64-darwin" + ]; + }; +} diff --git a/pkgs/dmd/nix-inputs.json b/pkgs/dmd/nix-inputs.json deleted file mode 100644 index bebb4e1e..00000000 --- a/pkgs/dmd/nix-inputs.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "inputs": { - "dmd": "github:dlang/dmd", - "druntime": "github:dlang/druntime", - "phobos": "github:dlang/phobos", - "tools": "github:dlang/tools" - }, - "primaryInput": "dmd" -} diff --git a/pkgs/dmd/version-catalog.nix b/pkgs/dmd/version-catalog.nix index 326193d0..359b976f 100644 --- a/pkgs/dmd/version-catalog.nix +++ b/pkgs/dmd/version-catalog.nix @@ -1,38 +1,34 @@ rec { supportedVersions = { - source = builtins.fromJSON ( - builtins.readFile ./supported-source-versions.json - ); + source = builtins.fromJSON (builtins.readFile ./supported-source-versions.json); - binary = builtins.fromJSON ( - builtins.readFile ./supported-binary-versions.json - ); + binary = builtins.fromJSON (builtins.readFile ./supported-binary-versions.json); }; - getSourceVersion = version: - assert builtins.hasAttr version supportedVersions.source; let + getSourceVersion = + version: + assert builtins.hasAttr version supportedVersions.source; + let componentHashes = supportedVersions.source."${version}"; in - import ./generic.nix ({ - inherit version; - dmdSha256 = componentHashes.dmd; - phobosSha256 = componentHashes.phobos; - toolsSha256 = componentHashes.tools; - } - // ( - if componentHashes ? "druntime" - then { - druntimeSha256 = componentHashes.druntime; - } - else {} - )); + import ./generic.nix ( + { + inherit version; + dmdSha256 = componentHashes.dmd; + phobosSha256 = componentHashes.phobos; + toolsSha256 = componentHashes.tools; + } + // (if componentHashes ? "druntime" then { druntimeSha256 = componentHashes.druntime; } else { }) + ); - getBinaryVersion = version: - assert builtins.hasAttr version supportedVersions.binary; let + getBinaryVersion = + version: + assert builtins.hasAttr version supportedVersions.binary; + let componentHashes = supportedVersions.binary."${version}"; in - import ./binary.nix { - inherit version; - hashes = componentHashes; - }; + import ./binary.nix { + inherit version; + hashes = componentHashes; + }; } diff --git a/pkgs/dub/build-status.nix b/pkgs/dub/build-status.nix index 1ad3a881..2b431a24 100644 --- a/pkgs/dub/build-status.nix +++ b/pkgs/dub/build-status.nix @@ -1 +1 @@ -{lib}: {} +{ lib }: { } diff --git a/pkgs/dub/default.nix b/pkgs/dub/default.nix index f47936b0..db78cd4a 100644 --- a/pkgs/dub/default.nix +++ b/pkgs/dub/default.nix @@ -1,7 +1,5 @@ +{ version, dubSha256 }: { - version, - dubSha256, -}: { lib, stdenv, fetchFromGitHub, @@ -12,170 +10,185 @@ dcompiler ? ldc, ... }: -assert dcompiler != null; let - inherit (import ../../lib/build-status.nix {inherit lib;}) getBuildStatus; +assert dcompiler != null; +let + inherit (import ../../lib/build-status.nix { inherit lib; }) getBuildStatus; buildStatus = getBuildStatus "dub" version stdenv.system; xdmdName = - if lib.hasPrefix "ldc" dcompiler.pname - then "ldmd2" - else if lib.hasPrefix "dmd" dcompiler.pname - then "dmd" - else (assert lib.hasPrefix "gdc" dcompiler.pname; "gdmd"); + if lib.hasPrefix "ldc" dcompiler.pname then + "ldmd2" + else if lib.hasPrefix "dmd" dcompiler.pname then + "dmd" + else + ( + assert lib.hasPrefix "gdc" dcompiler.pname; + "gdmd" + ); in - stdenv.mkDerivation rec { - pname = "dub"; - inherit version; - - passthru = { - inherit buildStatus; - }; - - enableParallelBuilding = true; - - src = fetchFromGitHub { - owner = "dlang"; - repo = "dub"; - rev = "v${version}"; - sha256 = dubSha256; - }; - - dubvar = "\\$DUB"; - postPatch = '' - patchShebangs test - - - # Can be removed with https://github.com/dlang/dub/pull/1368 - substituteInPlace test/fetchzip.sh \ - --replace "dub remove" "\"${dubvar}\" remove" - ''; - - nativeBuildInputs = [dcompiler libevent rsync]; - buildInputs = [curl]; - - buildPhase = '' - 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" +stdenv.mkDerivation rec { + pname = "dub"; + inherit version; + + passthru = { + inherit buildStatus; + }; + + enableParallelBuilding = true; + + src = fetchFromGitHub { + owner = "dlang"; + repo = "dub"; + rev = "v${version}"; + sha256 = dubSha256; + }; + + dubvar = "\\$DUB"; + postPatch = '' + patchShebangs test + + + # Can be removed with https://github.com/dlang/dub/pull/1368 + substituteInPlace test/fetchzip.sh \ + --replace "dub remove" "\"${dubvar}\" remove" + ''; + + nativeBuildInputs = [ + dcompiler + libevent + rsync + ]; + buildInputs = [ curl ]; + + buildPhase = '' + for dc_ in dmd ldmd2 gdmd; do + echo "... check for D compiler $dc_ ..." + dc=$(type -P $dc_ || echo "") + if [ ! "$dc" == "" ]; then + break fi - echo "$dc_ found and used as D compiler to build $pname" - $dc ./build.d - ./build - ''; - - doCheck = buildStatus.check; - - checkPhase = '' - export DUB=$NIX_BUILD_TOP/source/bin/dub - export PATH=$PATH:$NIX_BUILD_TOP/source/bin/ - export DC=${dcompiler.out}/bin/${xdmdName} - echo "DC out --> $DC" - export HOME=$TMP - - rm -rf test/issue502-root-import - rm test/issue674-concurrent-dub.sh - rm test/issue672-upgrade-optional.sh - rm test/issue990-download-optional-selected.sh - rm test/issue877-auto-fetch-package-on-run.sh - rm test/issue1037-better-dependency-messages.sh - rm test/issue1416-maven-repo-pkg-supplier.sh - rm test/issue1180-local-cache-broken.sh - rm test/issue1574-addcommand.sh - rm test/issue1524-maven-upgrade-dependency-tree.sh - rm test/issue1773-lint.sh - - rm test/ddox.sh - rm test/fetchzip.sh - rm test/feat663-search.sh - rm -rf test/git-dependency - rm test/interactive-remove.sh - rm test/timeout.sh - rm test/version-spec.sh - rm test/0-init-multi.sh - rm test/0-init-multi-json.sh - rm test/4-describe-data-1-list.sh - rm test/4-describe-data-3-zero-delim.sh - rm test/4-describe-import-paths.sh - rm test/4-describe-string-import-paths.sh - rm test/4-describe-json.sh - rm test/5-convert-stdout.sh - rm test/issue1003-check-empty-ld-flags.sh - rm test/issue103-single-file-package.sh - rm test/issue1040-run-with-ver.sh - rm test/issue1091-bogus-rebuild.sh - rm test/issue1194-warn-wrong-subconfig.sh - rm test/issue1277.sh - rm test/issue1372-ignore-files-in-hidden-dirs.sh - rm test/issue1447-build-settings-vars.sh - rm test/issue1531-toolchain-requirements.sh - rm test/issue346-redundant-flags.sh - rm test/issue361-optional-deps.sh - rm test/issue564-invalid-upgrade-dependency.sh - rm test/issue586-subpack-dep.sh - rm test/issue616-describe-vs-generate-commands.sh - rm test/issue686-multiple-march.sh - rm test/issue813-fixed-dependency.sh - rm test/issue813-pure-sub-dependency.sh - rm test/issue820-extra-fields-after-convert.sh - rm test/issue923-subpackage-deps.sh - rm test/single-file-sdl-default-name.sh - rm test/subpackage-common-with-sourcefile-globbing.sh - rm test/issue934-path-dep.sh - rm -r test/issue2258-dynLib-exe-dep # requires files below - rm -r test/1-dynLib-simple - rm -r test/1-exec-simple-package-json - rm -r test/1-exec-simple - rm -r test/1-staticLib-simple - rm -r test/2-dynLib-dep - rm -r test/2-staticLib-dep - rm -r test/2-dynLib-with-staticLib-dep - rm -r test/2-sourceLib-dep/ - rm -r test/3-copyFiles - rm -r test/custom-source-main-bug487 - rm -r test/custom-unittest - rm -r test/issue1262-version-inheritance-diamond - rm -r test/issue1003-check-empty-ld-flags - rm -r test/ignore-hidden-1 - rm -r test/ignore-hidden-2 - rm -r test/issue1427-betterC - rm -r test/issue130-unicode-* - rm -r test/issue1262-version-inheritance - rm -r test/issue1372-ignore-files-in-hidden-dirs - rm -r test/issue1350-transitive-none-deps - rm -r test/issue1775 - rm -r test/issue1447-build-settings-vars - rm -r test/issue1408-inherit-linker-files - rm -r test/issue1551-var-escaping - rm -r test/issue754-path-selection-fail - rm -r test/issue1788-incomplete-string-import-override - rm -r test/subpackage-ref - rm -r test/issue777-bogus-path-dependency - rm -r test/issue959-path-based-subpack-dep - rm -r test/issue97-targettype-none-nodeps - rm -r test/issue97-targettype-none-onerecipe - rm -r test/path-subpackage-ref - rm -r test/sdl-package-simple - rm -r test/dpath-variable # requires execution of dpath-variable.sh - - ./test/run-unittest.sh - ''; - - installPhase = '' - mkdir -p $out/bin - cp bin/dub $out/bin - ''; - - meta = with lib; { - description = "Package and build manager for D applications and libraries"; - homepage = "https://code.dlang.org/"; - license = licenses.mit; - maintainers = with maintainers; [ThomasMader]; - platforms = ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; - }; - } + done + if [ "$dc" == "" ]; then + exit "Error: could not find D compiler" + fi + echo "$dc_ found and used as D compiler to build $pname" + $dc ./build.d + ./build + ''; + + doCheck = buildStatus.check; + + checkPhase = '' + export DUB=$NIX_BUILD_TOP/source/bin/dub + export PATH=$PATH:$NIX_BUILD_TOP/source/bin/ + export DC=${dcompiler.out}/bin/${xdmdName} + echo "DC out --> $DC" + export HOME=$TMP + + rm -rf test/issue502-root-import + rm test/issue674-concurrent-dub.sh + rm test/issue672-upgrade-optional.sh + rm test/issue990-download-optional-selected.sh + rm test/issue877-auto-fetch-package-on-run.sh + rm test/issue1037-better-dependency-messages.sh + rm test/issue1416-maven-repo-pkg-supplier.sh + rm test/issue1180-local-cache-broken.sh + rm test/issue1574-addcommand.sh + rm test/issue1524-maven-upgrade-dependency-tree.sh + rm test/issue1773-lint.sh + + rm test/ddox.sh + rm test/fetchzip.sh + rm test/feat663-search.sh + rm -rf test/git-dependency + rm test/interactive-remove.sh + rm test/timeout.sh + rm test/version-spec.sh + rm test/0-init-multi.sh + rm test/0-init-multi-json.sh + rm test/4-describe-data-1-list.sh + rm test/4-describe-data-3-zero-delim.sh + rm test/4-describe-import-paths.sh + rm test/4-describe-string-import-paths.sh + rm test/4-describe-json.sh + rm test/5-convert-stdout.sh + rm test/issue1003-check-empty-ld-flags.sh + rm test/issue103-single-file-package.sh + rm test/issue1040-run-with-ver.sh + rm test/issue1091-bogus-rebuild.sh + rm test/issue1194-warn-wrong-subconfig.sh + rm test/issue1277.sh + rm test/issue1372-ignore-files-in-hidden-dirs.sh + rm test/issue1447-build-settings-vars.sh + rm test/issue1531-toolchain-requirements.sh + rm test/issue346-redundant-flags.sh + rm test/issue361-optional-deps.sh + rm test/issue564-invalid-upgrade-dependency.sh + rm test/issue586-subpack-dep.sh + rm test/issue616-describe-vs-generate-commands.sh + rm test/issue686-multiple-march.sh + rm test/issue813-fixed-dependency.sh + rm test/issue813-pure-sub-dependency.sh + rm test/issue820-extra-fields-after-convert.sh + rm test/issue923-subpackage-deps.sh + rm test/single-file-sdl-default-name.sh + rm test/subpackage-common-with-sourcefile-globbing.sh + rm test/issue934-path-dep.sh + rm -r test/issue2258-dynLib-exe-dep # requires files below + rm -r test/1-dynLib-simple + rm -r test/1-exec-simple-package-json + rm -r test/1-exec-simple + rm -r test/1-staticLib-simple + rm -r test/2-dynLib-dep + rm -r test/2-staticLib-dep + rm -r test/2-dynLib-with-staticLib-dep + rm -r test/2-sourceLib-dep/ + rm -r test/3-copyFiles + rm -r test/custom-source-main-bug487 + rm -r test/custom-unittest + rm -r test/issue1262-version-inheritance-diamond + rm -r test/issue1003-check-empty-ld-flags + rm -r test/ignore-hidden-1 + rm -r test/ignore-hidden-2 + rm -r test/issue1427-betterC + rm -r test/issue130-unicode-* + rm -r test/issue1262-version-inheritance + rm -r test/issue1372-ignore-files-in-hidden-dirs + rm -r test/issue1350-transitive-none-deps + rm -r test/issue1775 + rm -r test/issue1447-build-settings-vars + rm -r test/issue1408-inherit-linker-files + rm -r test/issue1551-var-escaping + rm -r test/issue754-path-selection-fail + rm -r test/issue1788-incomplete-string-import-override + rm -r test/subpackage-ref + rm -r test/issue777-bogus-path-dependency + rm -r test/issue959-path-based-subpack-dep + rm -r test/issue97-targettype-none-nodeps + rm -r test/issue97-targettype-none-onerecipe + rm -r test/path-subpackage-ref + rm -r test/sdl-package-simple + rm -r test/dpath-variable # requires execution of dpath-variable.sh + + ./test/run-unittest.sh + ''; + + installPhase = '' + mkdir -p $out/bin + cp bin/dub $out/bin + ''; + + meta = with lib; { + description = "Package and build manager for D applications and libraries"; + homepage = "https://code.dlang.org/"; + license = licenses.mit; + maintainers = with maintainers; [ ThomasMader ]; + platforms = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + }; +} diff --git a/pkgs/dub/flake.nix b/pkgs/dub/flake.nix deleted file mode 100644 index 0c2525cf..00000000 --- a/pkgs/dub/flake.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - inputs = { - dub = { - url = "github:dlang/dub"; - flake = false; - }; - primary.follows = "dub"; - }; -} diff --git a/pkgs/dub/version-catalog.nix b/pkgs/dub/version-catalog.nix index 5daea9ff..2b4b43d0 100644 --- a/pkgs/dub/version-catalog.nix +++ b/pkgs/dub/version-catalog.nix @@ -1,18 +1,18 @@ rec { supportedVersions = { - source = builtins.fromJSON ( - builtins.readFile ./supported-source-versions.json - ); + source = builtins.fromJSON (builtins.readFile ./supported-source-versions.json); }; getBinaryVersion = null; # unsupported - getSourceVersion = version: - assert builtins.hasAttr version supportedVersions.source; let + getSourceVersion = + version: + assert builtins.hasAttr version supportedVersions.source; + let componentHashes = supportedVersions.source."${version}"; in - import ./default.nix { - inherit version; - dubSha256 = componentHashes.dub; - }; + import ./default.nix { + inherit version; + dubSha256 = componentHashes.dub; + }; } diff --git a/pkgs/ldc/binary.nix b/pkgs/ldc/binary.nix index ea122d8e..f206eabc 100644 --- a/pkgs/ldc/binary.nix +++ b/pkgs/ldc/binary.nix @@ -1,7 +1,5 @@ +{ version, hashes }: { - version, - hashes, -}: { lib, stdenv, fetchurl, @@ -11,10 +9,11 @@ fixDarwinDylibNames, libxml2, ... -}: let +}: +let inherit (stdenv) hostPlatform system; - inherit (import ../../lib/build-status.nix {inherit lib;}) getBuildStatus; + inherit (import ../../lib/build-status.nix { inherit lib; }) getBuildStatus; buildStatus = getBuildStatus "ldc" version stdenv.system; systemToArchivePlatform = { @@ -31,57 +30,74 @@ "i686-windows" = "windows-x86"; }; - defaultSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; + defaultSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; supportedSystems = lib.pipe (builtins.attrNames systemToArchivePlatform) [ (builtins.filter (x: builtins.elem x defaultSystems)) (builtins.filter (sys: hashes.${systemToArchivePlatform.${sys}} != null)) ]; - tarballSuffix = - if hostPlatform.isWindows - then "7z" - else "tar.xz"; + tarballSuffix = if hostPlatform.isWindows then "7z" else "tar.xz"; archivePlatform = systemToArchivePlatform."${system}"; in - stdenv.mkDerivation { - pname = "ldc-binary"; - inherit version; +stdenv.mkDerivation { + pname = "ldc-binary"; + inherit version; - passthru = { - inherit buildStatus supportedSystems hashes; - }; + passthru = { + inherit buildStatus supportedSystems hashes; + }; - src = fetchurl rec { - name = "ldc2-${version}-${archivePlatform}.${tarballSuffix}"; - url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/${name}"; - sha256 = hashes."${archivePlatform}" or (throw "missing bootstrap sha256 for ${archivePlatform}"); - }; + src = fetchurl rec { + name = "ldc2-${version}-${archivePlatform}.${tarballSuffix}"; + url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/${name}"; + sha256 = hashes."${archivePlatform}" or (throw "missing bootstrap sha256 for ${archivePlatform}"); + }; - dontConfigure = true; - dontBuild = true; + dontConfigure = true; + dontBuild = true; - nativeBuildInputs = - lib.optional hostPlatform.isLinux autoPatchelfHook - ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames; + nativeBuildInputs = + lib.optional hostPlatform.isLinux autoPatchelfHook + ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames; - buildInputs = lib.optionals stdenv.hostPlatform.isLinux [libxml2 stdenv.cc.cc]; + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ + libxml2 + stdenv.cc.cc + ]; - propagatedBuildInputs = [curl tzdata]; + propagatedBuildInputs = [ + curl + tzdata + ]; - installPhase = '' - mkdir -p $out + installPhase = '' + mkdir -p $out - mv bin etc import lib LICENSE README $out/ - ''; + mv bin etc import lib LICENSE README $out/ + ''; - meta = with lib; { - description = "The LLVM-based D Compiler"; - homepage = "https://github.com/ldc-developers/ldc"; - # from https://github.com/ldc-developers/ldc/blob/master/LICENSE - license = with licenses; [bsd3 boost mit ncsa gpl2Plus]; - maintainers = with maintainers; [ThomasMader lionello]; - platforms = supportedSystems; - }; - } + meta = with lib; { + description = "The LLVM-based D Compiler"; + homepage = "https://github.com/ldc-developers/ldc"; + # from https://github.com/ldc-developers/ldc/blob/master/LICENSE + license = with licenses; [ + bsd3 + boost + mit + ncsa + gpl2Plus + ]; + maintainers = with maintainers; [ + ThomasMader + lionello + ]; + platforms = supportedSystems; + }; +} diff --git a/pkgs/ldc/bootstrap.nix b/pkgs/ldc/bootstrap.nix deleted file mode 100644 index 7af41852..00000000 --- a/pkgs/ldc/bootstrap.nix +++ /dev/null @@ -1,15 +0,0 @@ -import ./binary.nix { - version = "1.34.0"; - hashes = { - # ./scripts/fetch_binary.d --compiler=ldc --version=1.34.0 --dry-run=false - "android-aarch64" = "sha256-SJRdpd5tzhLPhJuY6rhN7r0Z2gCvEVDZxDMj0+tufUc="; - "android-armv7a" = "sha256-1URd7kpVA5m8DOPLO+6M3xhKvztHwIvNj2oka8TFcYw="; - "freebsd-x86_64" = "sha256-vI/ubxF0wyw/KdyoVzv7g4/6JiyJOdwgb/N7T6rne14="; - "linux-aarch64" = "sha256-LRD817uG0XMf6i+GaqCi/vDuURU4WInhFCeU+dAtHaE="; - "linux-x86_64" = "sha256-cnmsxGlsElSE2iVQcs+KVHKsKMv6XYin4N+XhUFt/BU="; - "osx-arm64" = "sha256-W45AEOW1EPsxizCgJYUOZyq7MhotN62xobsEAbr2/tU="; - "osx-x86_64" = "sha256-93aJN7ZNOLrQmKd6z/435trWg5F6B3XfOmKU/j5M5ig="; - "windows-x64" = "sha256-WrZnrDo/8hnsOsY2Ih8txErDz3OaNhVzwFFXsPJCEFM="; - "windows-x86" = "sha256-Vu/W9z7cB7VrcBqrlClknCYYni+GCDB4baGZOT6JS54="; - }; -} diff --git a/pkgs/ldc/build-status.nix b/pkgs/ldc/build-status.nix index 0200a355..6a6ca624 100644 --- a/pkgs/ldc/build-status.nix +++ b/pkgs/ldc/build-status.nix @@ -1,19 +1,20 @@ -{lib}: { +{ lib }: +{ "1.30.0" = { aarch64-darwin = { build = false; check = false; - skippedTests = []; + skippedTests = [ ]; }; x86_64-darwin = { build = false; check = false; - skippedTests = []; + skippedTests = [ ]; }; x86_64-linux = { build = true; check = false; - skippedTests = []; + skippedTests = [ ]; }; }; } diff --git a/pkgs/ldc/default.nix b/pkgs/ldc/default.nix deleted file mode 100644 index 5badb07e..00000000 --- a/pkgs/ldc/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./generic.nix { - version = "1.30.0"; - sha256 = "sha256-/bs3bwgkLZF5IqaiKnc5gCF/r6MQBG/F1kWUkK8j2s0="; -} diff --git a/pkgs/ldc/flake.nix b/pkgs/ldc/flake.nix deleted file mode 100644 index fd8bea7e..00000000 --- a/pkgs/ldc/flake.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - inputs = { - ldc = { - url = "github:ldc-developers/ldc"; - flake = false; - }; - primary.follows = "ldc"; - }; -} diff --git a/pkgs/ldc/generic.nix b/pkgs/ldc/generic.nix index 41858377..d7190e81 100644 --- a/pkgs/ldc/generic.nix +++ b/pkgs/ldc/generic.nix @@ -1,7 +1,5 @@ +{ version, sha256 }: { - version, - sha256, -}: { lib, stdenv, writeTextFile, @@ -12,24 +10,23 @@ curl, tzdata, mimalloc, - libconfig, lit, gdb, unzip, darwin, bash, pkg-config, - callPackage, makeWrapper, runCommand, targetPackages, - ldcBootstrap ? callPackage ./bootstrap.nix {}, + hostDCompiler, ... -}: let - inherit (import ../../lib/build-status.nix {inherit lib;}) getBuildStatus; +}: +let + inherit (import ../../lib/build-status.nix { inherit lib; }) getBuildStatus; buildStatus = getBuildStatus "ldc" version stdenv.system; - pathConfig = runCommand "phobos-tzdata-curl-paths" {} '' + pathConfig = runCommand "phobos-tzdata-curl-paths" { } '' mkdir $out echo ${tzdata}/share/zoneinfo/ > $out/TZDatabaseDirFile echo ${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} > $out/LibcurlPathFile @@ -67,151 +64,166 @@ };''; }; in - stdenv.mkDerivation rec { - pname = "ldc"; - inherit version; - - passthru = { - inherit buildStatus; - }; - - src = fetchurl { - url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"; - inherit sha256; - }; - - # https://issues.dlang.org/show_bug.cgi?id=19553 - hardeningDisable = ["fortify"]; - - postUnpack = - '' - patchShebangs . - '' - + '' - rm ldc-${version}-src/tests/d2/dmd-testsuite/fail_compilation/mixin_gc.d - rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/xtest46_gc.d - rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/testptrref_gc.d - - # test depends on current year - rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/ddocYear.d - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # https://github.com/NixOS/nixpkgs/issues/34817 - rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall - ''; - - postPatch = - '' - # Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow - substituteInPlace tests/d2/dmd-testsuite/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash" - '' - + lib.optionalString stdenv.hostPlatform.isLinux '' - substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" - ''; - - nativeBuildInputs = - [ - cmake - ldcBootstrap - lit - lit.python - llvmPackages_12.llvm.dev - llvmPackages_12.lld.dev - makeWrapper - ninja - unzip - pkg-config - ] - ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.Foundation - # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818 - ++ lib.optional (!stdenv.hostPlatform.isDarwin) gdb; - - buildInputs = [curl tzdata]; - - cmakeFlags = [ - "-D D_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J${pathConfig};-O;-linker=gold;-defaultlib=phobos2-ldc-lto,druntime-ldc-lto" - "-D CMAKE_BUILD_TYPE=Release" - "-D ALTERNATIVE_MALLOC_O=${mimalloc}/lib/mimalloc.o" - "-D MULTILIB=OFF" - "-D BUILD_LTO_LIBS=ON" - "-D LDC_WITH_LLD=ON" - "-D LDC_INSTALL_LTOPLUGIN=ON" - "-D LDC_INSTALL_LLVM_RUNTIME_LIBS=ON" - "-D BUILD_SHARED_LIBS=ON" - "-D LDC_LINK_MANUALLY=ON" - "-D RT_SUPPORT_SANITIZERS=ON" - "-D CMAKE_INTERPROCEDURAL_OPTIMIZATION_CONFIG=ON" - ]; - - fixNames = lib.optionalString stdenv.hostPlatform.isDarwin '' - fixDarwinDylibNames() { - local flags=() +stdenv.mkDerivation rec { + pname = "ldc"; + inherit version; - for fn in "$@"; do - flags+=(-change "$(basename "$fn")" "$fn") - done + passthru = { + inherit buildStatus; + }; - for fn in "$@"; do - if [ -L "$fn" ]; then continue; fi - echo "$fn: fixing dylib" - install_name_tool -id "$fn" "''${flags[@]}" "$fn" - done - } + src = fetchurl { + url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"; + inherit sha256; + }; - fixDarwinDylibNames $(find "$(pwd)/lib" -name "*.dylib") - export DYLD_LIBRARY_PATH=$(pwd)/lib + # https://issues.dlang.org/show_bug.cgi?id=19553 + hardeningDisable = [ "fortify" ]; + + postUnpack = + '' + patchShebangs . + '' + + '' + rm ldc-${version}-src/tests/d2/dmd-testsuite/fail_compilation/mixin_gc.d + rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/xtest46_gc.d + rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/testptrref_gc.d + + # test depends on current year + rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/ddocYear.d + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + # https://github.com/NixOS/nixpkgs/issues/34817 + rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall ''; - # https://github.com/ldc-developers/ldc/issues/2497#issuecomment-459633746 - additionalExceptions = - lib.optionalString stdenv.hostPlatform.isDarwin - "|druntime-test-shared"; + postPatch = + '' + # Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow + substituteInPlace tests/d2/dmd-testsuite/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash" + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" + ''; - doCheck = buildStatus.check; + nativeBuildInputs = + [ + cmake + hostDCompiler + lit + lit.python + llvmPackages_12.llvm.dev + llvmPackages_12.lld.dev + makeWrapper + ninja + unzip + pkg-config + ] + ++ lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.frameworks.Foundation + # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818 + ++ lib.optional (!stdenv.hostPlatform.isDarwin) gdb; + + buildInputs = [ + curl + tzdata + ]; + + cmakeFlags = [ + "-D D_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J${pathConfig};-O;-linker=gold;-defaultlib=phobos2-ldc-lto,druntime-ldc-lto" + "-D CMAKE_BUILD_TYPE=Release" + "-D ALTERNATIVE_MALLOC_O=${mimalloc}/lib/mimalloc.o" + "-D MULTILIB=OFF" + "-D BUILD_LTO_LIBS=ON" + "-D LDC_WITH_LLD=ON" + "-D LDC_INSTALL_LTOPLUGIN=ON" + "-D LDC_INSTALL_LLVM_RUNTIME_LIBS=ON" + "-D BUILD_SHARED_LIBS=ON" + "-D LDC_LINK_MANUALLY=ON" + "-D RT_SUPPORT_SANITIZERS=ON" + "-D CMAKE_INTERPROCEDURAL_OPTIMIZATION_CONFIG=ON" + ]; + + fixNames = lib.optionalString stdenv.hostPlatform.isDarwin '' + fixDarwinDylibNames() { + local flags=() + + for fn in "$@"; do + flags+=(-change "$(basename "$fn")" "$fn") + done + + for fn in "$@"; do + if [ -L "$fn" ]; then continue; fi + echo "$fn: fixing dylib" + install_name_tool -id "$fn" "''${flags[@]}" "$fn" + done + } + + fixDarwinDylibNames $(find "$(pwd)/lib" -name "*.dylib") + export DYLD_LIBRARY_PATH=$(pwd)/lib + ''; - checkPhase = - ( - lib.optionalString (buildStatus.skippedTests != []) - (lib.concatMapStringsSep "\n" (test: ''rm -v ${test}'') buildStatus.skippedTests) - ) - + '' - # Build default lib test runners - ninja -j$NIX_BUILD_CORES all-test-runners + # https://github.com/ldc-developers/ldc/issues/2497#issuecomment-459633746 + additionalExceptions = lib.optionalString stdenv.hostPlatform.isDarwin "|druntime-test-shared"; - ${fixNames} + doCheck = buildStatus.check; - # Run dmd testsuite - export DMD_TESTSUITE_MAKE_ARGS="-j$NIX_BUILD_CORES DMD=$DMD" - ctest -V -R "dmd-testsuite" + checkPhase = + (lib.optionalString (buildStatus.skippedTests != [ ]) ( + lib.concatMapStringsSep "\n" (test: ''rm -v ${test}'') buildStatus.skippedTests + )) + + '' + # Build default lib test runners + ninja -j$NIX_BUILD_CORES all-test-runners - # Build and run LDC D unittests. - ctest --output-on-failure -R "ldc2-unittest" + ${fixNames} - # Run LIT testsuite. - ctest -V -R "lit-tests" + # Run dmd testsuite + export DMD_TESTSUITE_MAKE_ARGS="-j$NIX_BUILD_CORES DMD=$DMD" + ctest -V -R "dmd-testsuite" - # Run default lib unittests - ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${additionalExceptions}" - ''; + # Build and run LDC D unittests. + ctest --output-on-failure -R "ldc2-unittest" - postInstall = '' - substitute ${ldcConfFile} "$out/etc/ldc2.conf" --subst-var out + # Run LIT testsuite. + ctest -V -R "lit-tests" - wrapProgram $out/bin/ldc2 \ - --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ - --set-default CC "${targetPackages.stdenv.cc}/bin/cc" + # Run default lib unittests + ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${additionalExceptions}" ''; - meta = with lib; { - description = "The LLVM-based D compiler"; - homepage = "https://github.com/ldc-developers/ldc"; - # from https://github.com/ldc-developers/ldc/blob/master/LICENSE - license = with licenses; [bsd3 boost mit ncsa gpl2Plus]; - maintainers = with maintainers; [ThomasMader lionello]; - platforms = ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; - mainProgram = "ldc2"; - }; - } + postInstall = '' + substitute ${ldcConfFile} "$out/etc/ldc2.conf" --subst-var out + + wrapProgram $out/bin/ldc2 \ + --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ + --set-default CC "${targetPackages.stdenv.cc}/bin/cc" + ''; + + meta = with lib; { + description = "The LLVM-based D compiler"; + homepage = "https://github.com/ldc-developers/ldc"; + # from https://github.com/ldc-developers/ldc/blob/master/LICENSE + license = with licenses; [ + bsd3 + boost + mit + ncsa + gpl2Plus + ]; + maintainers = with maintainers; [ + ThomasMader + lionello + ]; + platforms = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + mainProgram = "ldc2"; + }; +} diff --git a/pkgs/ldc/version-catalog.nix b/pkgs/ldc/version-catalog.nix index 765e627e..6305a24f 100644 --- a/pkgs/ldc/version-catalog.nix +++ b/pkgs/ldc/version-catalog.nix @@ -1,29 +1,29 @@ rec { supportedVersions = { - source = builtins.fromJSON ( - builtins.readFile ./supported-source-versions.json - ); + source = builtins.fromJSON (builtins.readFile ./supported-source-versions.json); - binary = builtins.fromJSON ( - builtins.readFile ./supported-binary-versions.json - ); + binary = builtins.fromJSON (builtins.readFile ./supported-binary-versions.json); }; - getSourceVersion = version: - assert builtins.hasAttr version supportedVersions.source; let + getSourceVersion = + version: + assert builtins.hasAttr version supportedVersions.source; + let componentHashes = supportedVersions.source."${version}"; in - import ./generic.nix { - inherit version; - sha256 = componentHashes.src; - }; + import ./generic.nix { + inherit version; + sha256 = componentHashes.src; + }; - getBinaryVersion = version: - assert builtins.hasAttr version supportedVersions.binary; let + getBinaryVersion = + version: + assert builtins.hasAttr version supportedVersions.binary; + let componentHashes = supportedVersions.binary."${version}"; in - import ./binary.nix { - inherit version; - hashes = componentHashes; - }; + import ./binary.nix { + inherit version; + hashes = componentHashes; + }; } diff --git a/repl.nix b/repl.nix new file mode 100644 index 00000000..de474551 --- /dev/null +++ b/repl.nix @@ -0,0 +1,9 @@ +rec { + system = builtins.currentSystem; + flake = builtins.getFlake (builtins.toString ./.); + pkgs = import flake.inputs.nixpkgs { }; + p = flake.packages.${system}; + lp = flake.legacyPackages.${system}; + lib = pkgs.lib; + utils = flake.lib; +} diff --git a/scripts/ci-matrix.sh b/scripts/ci-matrix.sh index 90d1d019..37ec1fae 100755 --- a/scripts/ci-matrix.sh +++ b/scripts/ci-matrix.sh @@ -43,13 +43,13 @@ eval_packages_to_json() { save_gh_ci_matrix() { packages_to_build=$(echo "$packages" | jq -c '. | map(select((.isCached | not) and (.allowedToFail | not)))') matrix='{"include":'"$packages_to_build"'}' - res_path='' + filename='' if [ "${IS_INITIAL:-true}" = "true" ]; then - res_path='matrix-pre.json' + filename='matrix-pre.json' else - res_path='matrix-post.json' + filename='matrix-post.json' fi - echo "$matrix" > "$res_path" + echo "$matrix" > "$result_dir/$filename" echo "matrix=$matrix" >> "${GITHUB_OUTPUT:-${result_dir}/gh-output.env}" } @@ -107,7 +107,7 @@ printTableForCacheStatus() { .[] | "| `\(.package)` | \(.["x86_64-linux"]) | \(.["x86_64-darwin"]) | \(.["aarch64-darwin"]) |" ' echo - } > comment.md + } > "$result_dir/comment.md" } printTableForCacheStatus "$@" diff --git a/shells/ci.nix b/shells/ci.nix index 181a419e..21a23580 100644 --- a/shells/ci.nix +++ b/shells/ci.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: +{ pkgs, ... }: pkgs.mkShellNoCC { packages = with pkgs; [ jq diff --git a/shells/default.nix b/shells/default.nix index 0ee8a5a9..f94051f3 100644 --- a/shells/default.nix +++ b/shells/default.nix @@ -1,22 +1,21 @@ -{pkgs}: +{ pkgs }: with pkgs; - mkShell { - packages = - [ - figlet - nix-eval-jobs - jq - nurl - ldc - dub - dtools - ] - ++ lib.optionals stdenv.hostPlatform.isx86 [ - dmd - ]; +mkShell { + packages = [ + figlet + nix-eval-jobs + jq + nurl + ldc + dub + dtools - shellHook = '' - figlet "Welcome to Dlang Nix" - export DMD=ldmd2 - ''; - } + (writeShellScriptBin "repl" ''nix repl --file "$REPO_ROOT/repl.nix"'') + ] ++ lib.optionals stdenv.hostPlatform.isx86 [ dmd ]; + + shellHook = '' + export REPO_ROOT="$PWD" + figlet "Welcome to Dlang Nix" + export DMD=ldmd2 + ''; +} diff --git a/templates/devshell/flake.nix b/templates/devshell/flake.nix index 8d343a55..11cf18e9 100644 --- a/templates/devshell/flake.nix +++ b/templates/devshell/flake.nix @@ -13,25 +13,28 @@ }; }; - outputs = inputs @ {flake-parts, ...}: - flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["x86_64-linux" "x86_64-darwin" "aarch64-darwin"]; - perSystem = { - inputs', - pkgs, - ... - }: { - devShells.default = pkgs.mkShell { - packages = [ - pkgs.figlet - inputs'.dlang-nix.packages.ldc - inputs'.dlang-nix.packages.dub - ]; + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + perSystem = + { inputs', pkgs, ... }: + { + devShells.default = pkgs.mkShell { + packages = [ + pkgs.figlet + inputs'.dlang-nix.packages.ldc + inputs'.dlang-nix.packages.dub + ]; - shellHook = '' - figlet "Hello, D world!" - ''; + shellHook = '' + figlet "Hello, D world!" + ''; + }; }; - }; }; } diff --git a/templates/macos-aarch64-devshell-with-dmd/flake.nix b/templates/macos-aarch64-devshell-with-dmd/flake.nix index e4602120..c1ef4de3 100644 --- a/templates/macos-aarch64-devshell-with-dmd/flake.nix +++ b/templates/macos-aarch64-devshell-with-dmd/flake.nix @@ -13,25 +13,28 @@ }; }; - outputs = inputs @ {flake-parts, ...}: - flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["x86_64-linux" "x86_64-darwin" "aarch64-darwin"]; - perSystem = { - inputs', - pkgs, - ... - }: { - devShells.default = pkgs.mkShell { - packages = [ - pkgs.figlet - inputs.dlang-nix.packages.x86_64-darwin.dmd - inputs'.dlang-nix.packages.dub - ]; + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + perSystem = + { inputs', pkgs, ... }: + { + devShells.default = pkgs.mkShell { + packages = [ + pkgs.figlet + inputs.dlang-nix.packages.x86_64-darwin.dmd + inputs'.dlang-nix.packages.dub + ]; - shellHook = '' - figlet "Hello, D world!" - ''; + shellHook = '' + figlet "Hello, D world!" + ''; + }; }; - }; }; } diff --git a/templates/pre-flake-devshell/shell.nix b/templates/pre-flake-devshell/shell.nix index 03aadfb6..0f53ce22 100644 --- a/templates/pre-flake-devshell/shell.nix +++ b/templates/pre-flake-devshell/shell.nix @@ -1,21 +1,26 @@ -{pkgs ? import {}}: let - dlang-nix = import (pkgs.fetchFromGitHub { - owner = "PetarKirov"; - repo = "dlang.nix"; - rev = "b9b7ef694329835bec97aa78e93757c3fbde8e13"; - hash = "sha256-zNvuU0DFSfCtQPFQ3rxri2e3mlMzLtJB/qaDsS0i9Gg="; - }); +{ + pkgs ? import { }, +}: +let + dlang-nix = import ( + pkgs.fetchFromGitHub { + owner = "PetarKirov"; + repo = "dlang.nix"; + rev = "b9b7ef694329835bec97aa78e93757c3fbde8e13"; + hash = "sha256-zNvuU0DFSfCtQPFQ3rxri2e3mlMzLtJB/qaDsS0i9Gg="; + } + ); dpkgs = dlang-nix.packages."${pkgs.system}"; in - pkgs.mkShell { - packages = [ - pkgs.figlet - dpkgs.dmd - dpkgs.dub - ]; +pkgs.mkShell { + packages = [ + pkgs.figlet + dpkgs.dmd + dpkgs.dub + ]; - shellHook = '' - figlet "Hello, D world!" - ''; - } + shellHook = '' + figlet "Hello, D world!" + ''; +} diff --git a/templates/shell-with-overlay/shell.nix b/templates/shell-with-overlay/shell.nix index 8571460c..057e43a6 100644 --- a/templates/shell-with-overlay/shell.nix +++ b/templates/shell-with-overlay/shell.nix @@ -5,13 +5,11 @@ let rev = "22f68705314161f9b41e5a8828f6390aec745448"; }; - pkgs = import { - overlays = [(import dlang-nix).overlays.default]; - }; + pkgs = import { overlays = [ (import dlang-nix).overlays.default ]; }; in - pkgs.mkShell { - packages = with pkgs; [ - dmd-2_104_2 - dub - ]; - } +pkgs.mkShell { + packages = with pkgs; [ + dmd-2_104_2 + dub + ]; +}