-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change idiom for overriding Dhall package version
Before this change, a Dhall package like the Prelude would be encoded as a record with one field per supported version. Then downstream packages would specify which package to override by selecting a different record field. The problem with that approach is that it did not provide an easy way to override a package to a version other than the default ones supplied by Nixpkgs. Normally you would use the `.override` method for this purpose, but the `override` method added by `buildDhall{Directory,GitHub}Package` is clobbered by the `override` method added by `callPackage` in `./pkgs/top-level/dhall-packages.nix`. The solution is to add a separate `.overridePackage` method which is essentially the exact same as `.override`, except that it is no longer clobbered by `callPackage`. This `.overridePackage` method allows one to override the arguments supplied to `buildDhall{Directory,GitHub}Package`, making it easier to specify package versions outside of the ones supported by Nixpkgs.. This also includes a change to only build one (preferred) version of each package (instead of multiple supported versions per package), in order to minimize the maintenance burden for the Dhall package set.
- Loading branch information
1 parent
f9dd8f0
commit 87d5e6f
Showing
7 changed files
with
96 additions
and
144 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,59 +1,11 @@ | ||
{ buildDhallGitHubPackage, lib }: | ||
|
||
let | ||
makePrelude = | ||
version: { rev, sha256 }: | ||
buildDhallGitHubPackage { | ||
name = "Prelude-${version}"; | ||
owner = "dhall-lang"; | ||
repo = "dhall-lang"; | ||
directory = "Prelude"; | ||
file = "package.dhall"; | ||
|
||
inherit rev sha256; | ||
}; | ||
|
||
in | ||
lib.mapAttrs makePrelude { | ||
# Prelude versions older than 7.0.0 use old-style union literals, which are | ||
# no longer supported by the latest version of the standard | ||
"7.0.0" = { | ||
rev = "f0509b403ace4b8a72ebb5fa9c473b9aeabeaf33"; | ||
sha256 = "00ldlvqfh411vnrnc41zfnlvgfanwfd3l8hdia8kni3r8q9qmd71"; | ||
}; | ||
|
||
"8.0.0" = { | ||
rev = "136a3491753fef251b2087031617d1ee1053f285"; | ||
sha256 = "0haxd5dhi5bmg06a0hx1blpivmwrcnndydwagibj3zvch4knyi2q"; | ||
}; | ||
|
||
"9.0.0" = { | ||
rev = "6cbf57c946e7e6576babc23a38320e53ecfa6bee"; | ||
sha256 = "1r06fijszyifq5b4j6libwkm06g8693m9n5c4kq61dvzrjfd2gim"; | ||
}; | ||
|
||
"10.0.0" = { | ||
rev = "ecbf82785cff406bbd162bbabf3df6f817c805e0"; | ||
sha256 = "0gxkr9649jqpykdzqjc98gkwnjry8wp469037brfghyidwsm021m"; | ||
}; | ||
|
||
"11.0.0" = { | ||
rev = "8098184d17c3aecc82674a7b874077a7641be05a"; | ||
sha256 = "0rdvyxq7mvas82wsfzzpk6imzm8ax4q58l522mx0ks69pacpr3yi"; | ||
}; | ||
|
||
"11.1.0" = { | ||
rev = "31e90e1996f6c4cb50e03ccb1f3c45beb4bd278c"; | ||
sha256 = "0rdvyxq7mvas82wsfzzpk6imzm8ax4q58l522mx0ks69pacpr3yi"; | ||
}; | ||
|
||
"12.0.0" = { | ||
rev = "9f248138f69ee5e22192dc3d0417d5c77b189e04"; | ||
sha256 = "1gbr0376sfamp0ibhcbxz4vaxr6ipv42y42p5wyksfhz3ls9x5ph"; | ||
}; | ||
|
||
"13.0.0" = { | ||
rev = "48db9e1ff1f8881fa4310085834fbc19e313ebf0"; | ||
sha256 = "0kg3rzag3irlcldck63rjspls614bc2sbs3zq44h0pzcz9v7z5h9"; | ||
}; | ||
} | ||
{ buildDhallGitHubPackage }: | ||
|
||
buildDhallGitHubPackage { | ||
name = "Prelude-13.0.0"; | ||
owner = "dhall-lang"; | ||
repo = "dhall-lang"; | ||
directory = "Prelude"; | ||
file = "package.dhall"; | ||
rev = "48db9e1ff1f8881fa4310085834fbc19e313ebf0"; | ||
sha256 = "0kg3rzag3irlcldck63rjspls614bc2sbs3zq44h0pzcz9v7z5h9"; | ||
} |
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,10 @@ | ||
{ buildDhallGitHubPackage, lib }: | ||
|
||
let | ||
makeDhallKubernetes = | ||
version: { rev, sha256 }: | ||
buildDhallGitHubPackage { | ||
name = "dhall-kubernetes-${version}"; | ||
owner = "dhall-lang"; | ||
repo = "dhall-kubernetes"; | ||
file = "package.dhall"; | ||
|
||
inherit rev sha256; | ||
}; | ||
|
||
in | ||
lib.mapAttrs makeDhallKubernetes { | ||
# 2.1.0 was the first version to introduce a top-level `package.dhall` file | ||
"2.1.0" = { | ||
rev = "bbfec3d8548b605f1c9628f34029ab4a7d928839"; | ||
sha256 = "10zkigj05khiy6w2sqcm5nw7d47r5k52xq8np8q86h0phy798g96"; | ||
}; | ||
|
||
"3.0.0" = { | ||
rev = "3c6d09a9409977cdde58a091d76a6d20509ca4b0"; | ||
sha256 = "1r4awh770ghsrwabh5ddy3jpmrbigakk0h32542n1kh71w3cdq1h"; | ||
}; | ||
} | ||
{ buildDhallGitHubPackage }: | ||
|
||
buildDhallGitHubPackage { | ||
name = "dhall-kubernetes-3.0.0"; | ||
owner = "dhall-lang"; | ||
repo = "dhall-kubernetes"; | ||
file = "package.dhall"; | ||
rev = "3c6d09a9409977cdde58a091d76a6d20509ca4b0"; | ||
sha256 = "1r4awh770ghsrwabh5ddy3jpmrbigakk0h32542n1kh71w3cdq1h"; | ||
} |
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,51 +1,51 @@ | ||
{ buildDhallGitHubPackage, dhall-kubernetes, lib, Prelude }: | ||
{ buildDhallGitHubPackage, dhall-kubernetes, Prelude }: | ||
|
||
let | ||
makeDhallPackages = | ||
version: { rev, sha256, dependencies }: | ||
buildDhallGitHubPackage { | ||
name = "dhall-packages-${version}"; | ||
owner = "EarnestResearch"; | ||
repo = "dhall-packages"; | ||
file = "package.dhall"; | ||
Prelude_12_0_0 = Prelude.overridePackage { | ||
name = "Prelude-12.0.0"; | ||
rev = "9f248138f69ee5e22192dc3d0417d5c77b189e04"; | ||
sha256 = "1gbr0376sfamp0ibhcbxz4vaxr6ipv42y42p5wyksfhz3ls9x5ph"; | ||
}; | ||
|
||
inherit rev sha256 dependencies; | ||
}; | ||
kubernetes = { | ||
"6a47bd" = dhall-kubernetes.overridePackage { | ||
name = "dhall-kubernetes-6a47bd"; | ||
rev = "6a47bd50c4d3984a13570ea62382a3ad4a9919a4"; | ||
sha256 = "1azqs0x2kia3xw93rfk2mdi8izd7gy9aq6qzbip32gin7dncmfhh"; | ||
}; | ||
|
||
in | ||
lib.mapAttrs makeDhallPackages { | ||
"0.11.1" = | ||
let | ||
k8s_6a47bd = dhall-kubernetes.override { | ||
rev = "6a47bd50c4d3984a13570ea62382a3ad4a9919a4"; | ||
sha256 = "1azqs0x2kia3xw93rfk2mdi8izd7gy9aq6qzbip32gin7dncmfhh"; | ||
}; | ||
|
||
k8s_4ad581 = dhall-kubernetes.override { | ||
rev = "4ad58156b7fdbbb6da0543d8b314df899feca077"; | ||
sha256 = "12fm70qbhcainxia388svsay2cfg9iksc6mss0nvhgxhpypgp8r0"; | ||
}; | ||
"4ad581" = dhall-kubernetes.overridePackage { | ||
name = "dhall-kubernetes-4ad581"; | ||
rev = "4ad58156b7fdbbb6da0543d8b314df899feca077"; | ||
sha256 = "12fm70qbhcainxia388svsay2cfg9iksc6mss0nvhgxhpypgp8r0"; | ||
}; | ||
|
||
k8s_fee24c = dhall-kubernetes.override { | ||
rev = "fee24c0993ba0b20190e2fdb94e386b7fb67252d"; | ||
sha256 = "11d93z8y0jzrb8dl43gqha9z96nxxqkl7cbxpz8hw8ky9x6ggayk"; | ||
}; | ||
"fee24c" = dhall-kubernetes.overridePackage { | ||
name = "dhall-kubernetes-fee24c"; | ||
rev = "fee24c0993ba0b20190e2fdb94e386b7fb67252d"; | ||
sha256 = "11d93z8y0jzrb8dl43gqha9z96nxxqkl7cbxpz8hw8ky9x6ggayk"; | ||
}; | ||
}; | ||
|
||
in | ||
{ rev = "8d228f578fbc7bb16c04a7c9ac8c6c7d2e13d1f7"; | ||
sha256 = "1v4y1x13lxy6cxf8xqc6sb0mc4mrd4frkxih95v9q2wxw4vkw2h7"; | ||
in | ||
buildDhallGitHubPackage { | ||
name = "dhall-packages-0.11.1"; | ||
owner = "EarnestResearch"; | ||
repo = "dhall-packages"; | ||
file = "package.dhall"; | ||
rev = "8d228f578fbc7bb16c04a7c9ac8c6c7d2e13d1f7"; | ||
sha256 = "1v4y1x13lxy6cxf8xqc6sb0mc4mrd4frkxih95v9q2wxw4vkw2h7"; | ||
|
||
dependencies = [ | ||
(k8s_6a47bd.override { file = "1.14/package.dhall"; }) | ||
(k8s_6a47bd.override { file = "1.15/package.dhall"; }) | ||
(k8s_6a47bd.override { file = "1.16/package.dhall"; }) | ||
(k8s_4ad581.override { file = "types.dhall"; }) | ||
(k8s_fee24c.override { file = "types/io.k8s.api.core.v1.ServiceSpec.dhall"; }) | ||
(k8s_fee24c.override { file = "types/io.k8s.api.core.v1.PodTemplateSpec.dhall"; }) | ||
Prelude."12.0.0" | ||
(Prelude."12.0.0".override { file = "JSON/package.dhall"; }) | ||
(Prelude."12.0.0".override { file = "JSON/Type"; }) | ||
(Prelude."12.0.0".override { file = "Map/Type"; }) | ||
]; | ||
}; | ||
dependencies = [ | ||
(kubernetes."6a47bd".overridePackage { file = "1.14/package.dhall"; }) | ||
(kubernetes."6a47bd".overridePackage { file = "1.15/package.dhall"; }) | ||
(kubernetes."6a47bd".overridePackage { file = "1.16/package.dhall"; }) | ||
(kubernetes."4ad581".overridePackage { file = "types.dhall"; }) | ||
(kubernetes."fee24c".overridePackage { file = "types/io.k8s.api.core.v1.ServiceSpec.dhall"; }) | ||
(kubernetes."fee24c".overridePackage { file = "types/io.k8s.api.core.v1.PodTemplateSpec.dhall"; }) | ||
Prelude_12_0_0 | ||
(Prelude_12_0_0.overridePackage { file = "JSON/package.dhall"; }) | ||
(Prelude_12_0_0.overridePackage { file = "JSON/Type"; }) | ||
(Prelude_12_0_0.overridePackage { file = "Map/Type"; }) | ||
]; | ||
} |
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,25 @@ | ||
{ lib }: | ||
|
||
let | ||
# This is essentially the same thing as `lib.makeOverridable`, except storing | ||
# the override method in a method named `overridePackage` so that it's not | ||
# shadowed by the `override` method added by `callPackage` | ||
makePackageOverridable = f: args: | ||
let | ||
result = lib.makeOverridable f args; | ||
|
||
copyArgs = g: lib.setFunctionArgs g (lib.functionArgs f); | ||
|
||
overrideWith = | ||
update: args // (if lib.isFunction update then update args else update); | ||
|
||
overridePackage = | ||
copyArgs (update: makePackageOverridable f (overrideWith update)); | ||
|
||
in | ||
result // { inherit overridePackage; }; | ||
|
||
in | ||
lib // { | ||
inherit makePackageOverridable; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
pkgs/development/interpreters/dhall/build-dhall-github-package.nix
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