Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Nix package expressions (#1246)
- Loading branch information
Showing
14 changed files
with
1,503 additions
and
8 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
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,123 @@ | ||
# A NUR-compatible package specification. | ||
{ pkgs ? import <nixpkgs> {}, useRelease ? true }: | ||
|
||
rec { | ||
# The `lib`, `modules`, and `overlay` names are special | ||
lib = ({ pkgs }: { }) { inherit pkgs; }; # functions | ||
modules = { }; # NixOS modules | ||
overlays = { }; # nixpkgs overlays | ||
|
||
# # development | ||
|
||
# ## development.python-modules | ||
|
||
# use in a shell like | ||
# ```nix | ||
# ((pkgs.python3.override { | ||
# packageOverrides = pythonPackageOverrides; | ||
# }).withPackages (ps: [ ps.telethon ])).env | ||
# ``` | ||
pythonPackageOverrides = self: super: let | ||
defaultTelethonArgs = { inherit useRelease; }; | ||
telethonPkg = v: args: self.callPackage (./nix/telethon + "/${v}.nix") | ||
(defaultTelethonArgs // args); | ||
in rec { | ||
telethon = telethon_1; | ||
telethon-devel = self.callPackage ./nix/telethon/devel.nix { }; | ||
|
||
telethon_1 = telethon_1_9; | ||
telethon_1_9 = telethon_1_9_0; | ||
telethon_1_9_0 = telethonPkg "1.9" { version = "1.9.0"; }; | ||
telethon_1_8 = telethon_1_8_0; | ||
telethon_1_8_0 = telethonPkg "1.8" { version = "1.8.0"; }; | ||
telethon_1_7 = telethon_1_7_7; | ||
telethon_1_7_7 = telethonPkg "1.7" { version = "1.7.7"; }; | ||
telethon_1_7_6 = telethonPkg "1.7" { version = "1.7.6"; }; | ||
telethon_1_7_5 = telethonPkg "1.7" { version = "1.7.5"; }; | ||
telethon_1_7_4 = telethonPkg "1.7" { version = "1.7.4"; }; | ||
telethon_1_7_3 = telethonPkg "1.7" { version = "1.7.3"; }; | ||
telethon_1_7_2 = telethonPkg "1.7" { version = "1.7.2"; }; | ||
telethon_1_7_1 = telethonPkg "1.7" { version = "1.7.1"; }; | ||
telethon_1_7_0 = telethonPkg "1.7" { version = "1.7.0"; }; | ||
telethon_1_6 = telethon_1_6_2; | ||
telethon_1_6_2 = telethonPkg "1.6" { version = "1.6.2"; }; | ||
# 1.6.1.post1: hotpatch that fixed Telethon.egg-info dir perms | ||
telethon_1_6_1 = telethonPkg "1.6" { version = "1.6.1"; }; | ||
telethon_1_6_0 = telethonPkg "1.6" { version = "1.6.0"; }; | ||
telethon_1_5 = telethon_1_5_5; | ||
telethon_1_5_5 = telethonPkg "1.5" { version = "1.5.5"; }; | ||
telethon_1_5_4 = telethonPkg "1.5" { version = "1.5.4"; }; | ||
telethon_1_5_3 = telethonPkg "1.5" { version = "1.5.3"; }; | ||
telethon_1_5_2 = telethonPkg "1.5" { version = "1.5.2"; }; | ||
telethon_1_5_1 = telethonPkg "1.5" { version = "1.5.1"; }; | ||
telethon_1_5_0 = telethonPkg "1.5" { version = "1.5.0"; }; | ||
telethon_1_4 = telethon_1_4_3; | ||
telethon_1_4_3 = telethonPkg "1.4" { version = "1.4.3"; }; | ||
telethon_1_4_2 = telethonPkg "1.4" { version = "1.4.2"; }; | ||
telethon_1_4_1 = telethonPkg "1.4" { version = "1.4.1"; }; | ||
telethon_1_4_0 = telethonPkg "1.4" { version = "1.4.0"; }; | ||
#telethon_1_3_0 | ||
#telethon_1_2_0 | ||
#telethon_1_1_1 | ||
#telethon_1_1_0 | ||
#telethon_1_0_4 | ||
#telethon_1_0_3 | ||
#telethon_1_0_2 | ||
#telethon_1_0_1 | ||
#telethon_1_0_0-rc1 | ||
#telethon_1_0_0 | ||
#telethon_0_19_1 | ||
#telethon_0_19_0 | ||
#telethon_0_18_3 | ||
#telethon_0_18_2 | ||
#telethon_0_18_1 | ||
#telethon_0_18_0 | ||
#telethon_0_17_4 | ||
#telethon_0_17_3 | ||
#telethon_0_17_2 | ||
#telethon_0_17_1 | ||
#telethon_0_17_0 | ||
#telethon_0_16_2 | ||
#telethon_0_16_1 | ||
#telethon_0_16_0 | ||
#telethon_0_15_5 | ||
#telethon_0_15_4 | ||
#telethon_0_15_3 | ||
#telethon_0_15_2 | ||
#telethon_0_15_1 | ||
#telethon_0_15_0 | ||
#telethon_0_14_2 | ||
#telethon_0_14_1 | ||
#telethon_0_14_0 | ||
#telethon_0_13_6 | ||
#telethon_0_13_5 | ||
#telethon_0_13_4 | ||
#telethon_0_13_3 | ||
#telethon_0_13_2 | ||
#telethon_0_13_1 | ||
#telethon_0_13_0 | ||
#telethon_0_12_2 | ||
#telethon_0_12_1 | ||
#telethon_0_12_0 | ||
#telethon_0_11_5 | ||
#telethon_0_11_4 | ||
#telethon_0_11_3 | ||
#telethon_0_11_2 | ||
#telethon_0_11_1 | ||
#telethon_0_11_0 | ||
#telethon_0_10_1 | ||
#telethon_0_10_0 | ||
#telethon_0_9_1 | ||
#telethon_0_9_0 | ||
#telethon_0_8_0 | ||
#telethon_0_7_1 | ||
#telethon_0_7_0 | ||
#telethon_0_6_0 | ||
#telethon_0_5_0 | ||
#telethon_0_4_0 | ||
#telethon_0_3_0 | ||
#telethon_0_2_0 | ||
#telethon_0_1_0 | ||
}; | ||
} | ||
|
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,59 @@ | ||
# This file provides all the buildable and cacheable packages and | ||
# package outputs in you package set. These are what gets built by CI, | ||
# so if you correctly mark packages as | ||
# | ||
# - broken (using `meta.broken`), | ||
# - unfree (using `meta.license.free`), and | ||
# - locally built (using `preferLocalBuild`) | ||
# | ||
# then your CI will be able to build and cache only those packages for | ||
# which this is possible. | ||
|
||
{ pkgs ? import <nixpkgs> {}, enableEnvs ? false }: | ||
|
||
with builtins; | ||
|
||
let | ||
|
||
isReserved = n: n == "lib" || n == "overlays" || n == "modules"; | ||
isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; | ||
isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; | ||
isCacheable = p: !(p.preferLocalBuild or false); | ||
shouldRecurseForDerivations = p: | ||
isAttrs p && p.recurseForDerivations or false; | ||
|
||
nameValuePair = n: v: { name = n; value = v; }; | ||
|
||
concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); | ||
|
||
flattenPkgs = s: | ||
let | ||
f = p: | ||
if shouldRecurseForDerivations p then flattenPkgs p | ||
else if isDerivation p then [p] | ||
else []; | ||
in | ||
concatMap f (attrValues s); | ||
|
||
outputsOf = p: map (o: p.${o}) p.outputs; | ||
|
||
# build & test packages across Python versions | ||
# (withPackages "distributions" are also generated for testing) | ||
nurAttrs = import ./extended.nix { inherit pkgs enableEnvs; }; | ||
|
||
nurPkgs = | ||
flattenPkgs | ||
(listToAttrs | ||
(map (n: nameValuePair n nurAttrs.${n}) | ||
(filter (n: !isReserved n) | ||
(attrNames nurAttrs)))); | ||
|
||
in | ||
|
||
rec { | ||
buildPkgs = filter isBuildable nurPkgs; | ||
cachePkgs = filter isCacheable buildPkgs; | ||
|
||
buildOutputs = concatMap outputsOf buildPkgs; | ||
cacheOutputs = concatMap outputsOf cachePkgs; | ||
} |
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,83 @@ | ||
{ pkgs ? import <nixpkgs> { }, enableEnvs ? true, useRelease ? true }: | ||
|
||
# packages built against all Python versions (along with withPackages | ||
# environments for testing) | ||
|
||
# to use for testing, you'll probably want a variant of: | ||
# ```sh | ||
# nix-shell nix/extended.nix -A telethon-devel-python37 --run "python" | ||
# ``` | ||
|
||
let | ||
inherit (pkgs.lib) attrNames attrValues concatMap head listToAttrs | ||
mapAttrsToList optional optionals tail; | ||
nurAttrs = import ../default.nix { inherit pkgs useRelease; }; | ||
|
||
pyVersions = concatMap (n: optional (pkgs ? ${n}) n) [ | ||
"python3" | ||
"python35" | ||
"python36" | ||
"python37" | ||
# "pypy3" | ||
# "pypy35" | ||
# "pypy36" | ||
# "pypy37" | ||
]; | ||
|
||
pyPkgEnvs = [ | ||
[ "telethon" "telethon" ] | ||
[ "telethon-devel" "telethon-devel" ] | ||
|
||
[ "telethon_1" "telethon_1" ] | ||
[ "telethon_1_9" "telethon_1_9" ] | ||
[ "telethon_1_9_0" "telethon_1_9_0" ] | ||
[ "telethon_1_8" "telethon_1_8" ] | ||
[ "telethon_1_8_0" "telethon_1_8_0" ] | ||
[ "telethon_1_7" "telethon_1_7" ] | ||
[ "telethon_1_7_7" "telethon_1_7_7" ] | ||
[ "telethon_1_7_6" "telethon_1_7_6" ] | ||
[ "telethon_1_7_5" "telethon_1_7_5" ] | ||
[ "telethon_1_7_4" "telethon_1_7_4" ] | ||
[ "telethon_1_7_3" "telethon_1_7_3" ] | ||
[ "telethon_1_7_2" "telethon_1_7_2" ] | ||
[ "telethon_1_7_1" "telethon_1_7_1" ] | ||
[ "telethon_1_7_0" "telethon_1_7_0" ] | ||
[ "telethon_1_6" "telethon_1_6" ] | ||
[ "telethon_1_6_2" "telethon_1_6_2" ] | ||
[ "telethon_1_6_1" "telethon_1_6_1" ] | ||
[ "telethon_1_6_0" "telethon_1_6_0" ] | ||
[ "telethon_1_5" "telethon_1_5" ] | ||
[ "telethon_1_5_5" "telethon_1_5_5" ] | ||
[ "telethon_1_5_4" "telethon_1_5_4" ] | ||
[ "telethon_1_5_3" "telethon_1_5_3" ] | ||
[ "telethon_1_5_2" "telethon_1_5_2" ] | ||
[ "telethon_1_5_1" "telethon_1_5_1" ] | ||
[ "telethon_1_5_0" "telethon_1_5_0" ] | ||
[ "telethon_1_4" "telethon_1_4" ] | ||
[ "telethon_1_4_3" "telethon_1_4_3" ] | ||
# [ "telethon_1_4_2" "telethon_1_4_2" ] | ||
# [ "telethon_1_4_1" "telethon_1_4_1" ] | ||
# [ "telethon_1_4_0" "telethon_1_4_0" ] | ||
]; | ||
|
||
getPkgPair = pkgs: n: let p = pkgs.${n}; in { name = n; value = p; }; | ||
getPkgPairs = pkgs: map (getPkgPair pkgs); | ||
pyPkgPairs = py: | ||
concatMap (d: map (getPkgPair py.pkgs) (tail d)) pyPkgEnvs; | ||
pyPkgEnvPair = pyNm: py: envNm: env: { | ||
name = "${envNm}-env-${pyNm}"; | ||
value = (py.withPackages (ps: map (pn: ps.${pn}) env)).overrideAttrs (o: { | ||
name = "${envNm}-${py.name}-env"; | ||
preferLocalBuild = true; | ||
}); | ||
}; | ||
pyNurPairs = pyNm: py: | ||
map ({ name, value }: { name = "${name}-${pyNm}"; inherit value; }) | ||
(pyPkgPairs py) ++ | ||
optionals enableEnvs | ||
(map (d: pyPkgEnvPair pyNm py (head d) (tail d)) pyPkgEnvs); | ||
in nurAttrs // (listToAttrs (concatMap (py: let | ||
python = pkgs.${py}.override { | ||
packageOverrides = nurAttrs.pythonPackageOverrides; | ||
}; in | ||
pyNurPairs py python) pyVersions)) |
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,18 @@ | ||
# You can use this file as a nixpkgs overlay. This is useful in the | ||
# case where you don't want to add the whole NUR namespace to your | ||
# configuration. | ||
|
||
self: super: | ||
|
||
let | ||
|
||
isReserved = n: n == "lib" || n == "overlays" || n == "modules"; | ||
nameValuePair = n: v: { name = n; value = v; }; | ||
nurAttrs = import ./default.nix { pkgs = super; }; | ||
|
||
in | ||
|
||
builtins.listToAttrs | ||
(map (n: nameValuePair n nurAttrs.${n}) | ||
(builtins.filter (n: !isReserved n) | ||
(builtins.attrNames nurAttrs))) |
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,56 @@ | ||
{ lib, buildPythonPackage, pythonOlder | ||
, fetchFromGitHub ? null, fetchPypi ? null, fetchpatch ? null | ||
, async_generator, pyaes, rsa | ||
, version | ||
, useRelease ? true | ||
}: | ||
|
||
assert useRelease -> fetchPypi != null; | ||
assert !useRelease -> fetchFromGitHub != null && fetchpatch != null; | ||
let | ||
common = import ./common.nix { | ||
inherit lib fetchFromGitHub fetchPypi fetchpatch; | ||
}; | ||
versions = { | ||
"1.4.3" = { | ||
pypiSha256 = "1igslvhd743qy9p4kfs7lg09s8d5vhn9jhzngpv12797569p4lcj"; | ||
sourceSha256 = "19vz0ppk7lq1dmqzf47n6h023i08pqvcwnixvm28vrijykq0z315"; | ||
}; | ||
"1.4.2" = { | ||
pypiSha256 = "1f4ncyfzqj4b6zib0417r01pgnd0hb1p4aiinhlkxkmk7vy5fqfy"; | ||
sourceSha256 = "0rsbz5kqp0d10gasadir3mgalc9aqq4fcv8xa1p7fg263f43rjl4"; | ||
}; | ||
"1.4.1" = { | ||
pypiSha256 = "1n0jhdqflinyamzy5krnww7hc0s7pw9yfck1p7816pdbgir74qsw"; | ||
sourceSha256 = "07q48gw4ry3wf9yzi6kf8lw3b23a0dvk9r8sabpxwrlqy7gnksxx"; | ||
}; | ||
"1.4.0" = { | ||
version = "1.4"; | ||
pypiSha256 = "1g7rznwmj87n9k86zby9i75h570hm84izrv0srhsmxi52pjan1ml"; | ||
sourceSha256 = "14nv86yrj01wmlj5cfg6iq5w03ssl67av1arfy9mq1935mly5nly"; | ||
}; | ||
}; | ||
in buildPythonPackage rec { | ||
pname = "telethon"; | ||
inherit version; | ||
|
||
src = common.fetchTelethon { | ||
inherit useRelease version; | ||
versionData = versions.${version}; | ||
}; | ||
patches = lib.optionals (!useRelease) [ | ||
(if (lib.versionOlder version "1.4.3") then | ||
common.patches.generator-use-pathlib-to-1_4_3 | ||
else | ||
common.patches.generator-use-pathlib-from-1_4_3-to-1_5_0) | ||
common.patches.generator-use-pathlib-open-to-1_5_3 | ||
common.patches.sort-generated-tlobjects-to-1_7_1 | ||
]; | ||
|
||
propagatedBuildInputs = [ async_generator rsa pyaes ]; | ||
|
||
doCheck = false; # No tests available | ||
|
||
disabled = pythonOlder "3.5"; | ||
meta = common.meta; | ||
} |
Oops, something went wrong.