-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pkgs/dmd): Automate definition of package versions
* Move hashes for each supported version to machine-generated JSON files * Automatically generate derivations per each supported source and binary version
- Loading branch information
1 parent
fd26c1a
commit 12a0ae6
Showing
10 changed files
with
179 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,85 @@ | ||
{inputs, ...}: { | ||
{ | ||
inputs, | ||
lib, | ||
... | ||
}: let | ||
inherit (builtins) attrNames listToAttrs map mapAttrs; | ||
inherit (lib) nameValuePair pipe optionalAttrs; | ||
in { | ||
imports = [inputs.flake-parts.flakeModules.easyOverlay]; | ||
|
||
perSystem = { | ||
self', | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs) callPackage lib darwin hostPlatform; | ||
inherit (pkgs) callPackage hostPlatform; | ||
darwinPkgs = { | ||
inherit (darwin.apple_sdk.frameworks) Foundation; | ||
inherit (pkgs.darwin.apple_sdk.frameworks) Foundation; | ||
}; | ||
|
||
genPkgVersions = pkgName: let | ||
mod = ./. + "/${pkgName}/version-catalog.nix"; | ||
inherit | ||
(import mod) | ||
supportedVersions | ||
getSourceVersion | ||
getBinaryVersion | ||
; | ||
getVersion = type: | ||
if type == "source" | ||
then getSourceVersion | ||
else getBinaryVersion; | ||
in { | ||
flattened = type: let | ||
nameSuffix = | ||
if type == "binary" | ||
then "-binary" | ||
else ""; | ||
in | ||
pipe (attrNames supportedVersions."${type}") [ | ||
( | ||
map ( | ||
version: | ||
nameValuePair | ||
"${pkgName}${nameSuffix}-${version}" | ||
(callPackage (getVersion type version) darwinPkgs) | ||
) | ||
) | ||
listToAttrs | ||
]; | ||
|
||
hierarchical = { | ||
"${pkgName}" = pipe ["source" "binary"] [ | ||
(map (type: | ||
nameValuePair type ( | ||
mapAttrs | ||
(version: _: (callPackage (getVersion type version) darwinPkgs)) | ||
supportedVersions."${type}" | ||
))) | ||
listToAttrs | ||
]; | ||
}; | ||
}; | ||
in { | ||
overlayAttrs = self'.packages; | ||
legacyPackages = | ||
{} | ||
// (genPkgVersions "dmd").hierarchical; | ||
packages = | ||
{ | ||
ldc-binary = callPackage ./ldc/bootstrap.nix {}; | ||
ldc = callPackage ./ldc {}; | ||
|
||
dub = callPackage ./dub {}; | ||
} | ||
// lib.optionalAttrs hostPlatform.isx86 { | ||
dmd-binary = callPackage ./dmd/bootstrap.nix {}; | ||
dmd = callPackage ./dmd darwinPkgs; | ||
}; | ||
// optionalAttrs hostPlatform.isx86 ( | ||
{ | ||
dmd-bootstrap = self'.packages."dmd-binary-2.098.0"; | ||
dmd = self'.packages."dmd-2.100.2"; | ||
} | ||
// (genPkgVersions "dmd").flattened "binary" | ||
// (genPkgVersions "dmd").flattened "source" | ||
); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"2.098.1": { | ||
"dmd": "sha256-61hViU/IBUKHwXO+mt63lo3kBGL4Gtve83Uxi32gwnU=", | ||
"druntime": "sha256-HN/bxmGJHqubiUESZ7Y/4gdUj8ja9WhyLq24IDdZoe0=", | ||
"phobos": "sha256-GMa3k9QWfDiLSx0HH+n6eqgY6Pq0qkmXhbAslTsCH9A=", | ||
"tools": "sha256-+pH7X9YRh0yG0iZoDkC6X50uscb4WKXmk2V+74cMSW8=" | ||
}, | ||
"2.100.2": { | ||
"dmd": "sha256-o4+G3ARXIGObYHtHooYZKr+Al6kHpiwpMIog3i4BlDM=", | ||
"druntime": "sha256-qXvY1ECN4mPwOGgOE1FWwvxoRvlSww3tGLWgBdhzAKo=", | ||
"phobos": "sha256-kTHRaAKG7cAGb4IE/NGHWaZ8t7ZceKj03l6E8wLzJzs=", | ||
"tools": "sha256-2yzdkarbsf0kOXzLaS6bvBFoiYbDulnEHTozmHX3Oc4=" | ||
}, | ||
"2.102.2": { | ||
"dmd": "sha256-der9nb31hJ+K1aJZdzIgs8+eRgVVsH97QnYEnVbKUws=", | ||
"phobos": "sha256-SracmUm2aY/LDCyDqYuVS39pCbwO8UCL3TSB0CVHpHE=", | ||
"tools": "sha256-XM4gUxcarQCOBR8W/o0iWAI54PyLDkH6CsDce22Cnu4=" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
rec { | ||
supportedVersions = { | ||
source = builtins.fromJSON ( | ||
builtins.readFile ./supported-source-versions.json | ||
); | ||
|
||
binary = builtins.fromJSON ( | ||
builtins.readFile ./supported-binary-versions.json | ||
); | ||
}; | ||
|
||
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 {} | ||
)); | ||
|
||
getBinaryVersion = version: | ||
assert builtins.hasAttr version supportedVersions.binary; let | ||
componentHashes = supportedVersions.binary."${version}"; | ||
in | ||
import ./binary.nix { | ||
inherit version; | ||
hashes = componentHashes; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters