Merge master into staging-next
This commit is contained in:
commit
7aa2b0215b
|
@ -180,7 +180,8 @@ checkConfigOutput "true" config.submodule.inner ./declare-submoduleWith-modules.
|
|||
checkConfigOutput "true" config.submodule.outer ./declare-submoduleWith-modules.nix
|
||||
|
||||
## Paths should be allowed as values and work as expected
|
||||
checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
|
||||
# Temporarily disabled until https://github.com/NixOS/nixpkgs/pull/76861
|
||||
#checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
|
||||
|
||||
cat <<EOF
|
||||
====== module tests ======
|
||||
|
|
|
@ -376,16 +376,14 @@ rec {
|
|||
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);
|
||||
|
||||
allModules = defs: modules ++ imap1 (n: { value, file }:
|
||||
if isAttrs value || isFunction value then
|
||||
# Annotate the value with the location of its definition for better error messages
|
||||
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
|
||||
else value
|
||||
# Annotate the value with the location of its definition for better error messages
|
||||
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
|
||||
) defs;
|
||||
|
||||
in
|
||||
mkOptionType rec {
|
||||
name = "submodule";
|
||||
check = x: isAttrs x || isFunction x || path.check x;
|
||||
check = x: isAttrs x || isFunction x;
|
||||
merge = loc: defs:
|
||||
(evalModules {
|
||||
modules = allModules defs;
|
||||
|
|
|
@ -1075,6 +1075,21 @@
|
|||
githubId = 510553;
|
||||
name = "Jos van Bakel";
|
||||
};
|
||||
cab404 = {
|
||||
email = "cab404@mailbox.org";
|
||||
github = "cab404";
|
||||
githubId = 6453661;
|
||||
name = "Vladimir Serov";
|
||||
keys = [
|
||||
# compare with https://keybase.io/cab404
|
||||
{ longkeyid = "1BB96810926F4E715DEF567E6BA7C26C3FDF7BB3";
|
||||
fingerprint = "rsa3072/0xCBDECF658C38079E";
|
||||
}
|
||||
{ longkeyid = "1EBC648C64D6045463013B3EB7EFFC271D55DB8A";
|
||||
fingerprint = "ed25519/0xB7EFFC271D55DB8A";
|
||||
}
|
||||
];
|
||||
};
|
||||
calbrecht = {
|
||||
email = "christian.albrecht@mayflower.de";
|
||||
github = "calbrecht";
|
||||
|
|
|
@ -257,9 +257,9 @@
|
|||
<listitem>
|
||||
<para>
|
||||
A set of sub options <replaceable>o</replaceable>.
|
||||
<replaceable>o</replaceable> can be an attribute set, a function
|
||||
returning an attribute set, or a path to a file containing such a value. Submodules are used in
|
||||
composed types to create modular options. This is equivalent to
|
||||
<replaceable>o</replaceable> can be an attribute set or a function
|
||||
returning an attribute set. Submodules are used in composed types to
|
||||
create modular options. This is equivalent to
|
||||
<literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
|
||||
Submodules are detailed in
|
||||
<xref
|
||||
|
|
|
@ -52,7 +52,7 @@ in
|
|||
};
|
||||
})
|
||||
(mkIf (cfg.showManual && cfgd.enable && cfgd.nixos.enable) {
|
||||
boot.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];
|
||||
console.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];
|
||||
|
||||
systemd.services.nixos-manual = {
|
||||
description = "NixOS Manual";
|
||||
|
|
|
@ -40,7 +40,7 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
boot.extraTTYs = [ cfg.tty ];
|
||||
console.extraTTYs = [ cfg.tty ];
|
||||
|
||||
systemd.services.rogue =
|
||||
{ description = "Rogue dungeon crawling game";
|
||||
|
|
|
@ -198,6 +198,7 @@ in
|
|||
nfs4 = handleTest ./nfs { version = 4; };
|
||||
nghttpx = handleTest ./nghttpx.nix {};
|
||||
nginx = handleTest ./nginx.nix {};
|
||||
nginx-etag = handleTest ./nginx-etag.nix {};
|
||||
nginx-sso = handleTest ./nginx-sso.nix {};
|
||||
nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
|
||||
nixos-generate-config = handleTest ./nixos-generate-config.nix {};
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
import ./make-test-python.nix {
|
||||
name = "nginx-etag";
|
||||
|
||||
nodes = {
|
||||
server = { pkgs, lib, ... }: {
|
||||
networking.firewall.enable = false;
|
||||
services.nginx.enable = true;
|
||||
services.nginx.virtualHosts.server = {
|
||||
root = pkgs.runCommandLocal "testdir" {} ''
|
||||
mkdir "$out"
|
||||
cat > "$out/test.js" <<EOF
|
||||
document.getElementById('foobar').setAttribute('foo', 'bar');
|
||||
EOF
|
||||
cat > "$out/index.html" <<EOF
|
||||
<!DOCTYPE html>
|
||||
<div id="foobar">test</div>
|
||||
<script src="test.js"></script>
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
|
||||
nesting.clone = lib.singleton {
|
||||
services.nginx.virtualHosts.server = {
|
||||
root = lib.mkForce (pkgs.runCommandLocal "testdir2" {} ''
|
||||
mkdir "$out"
|
||||
cat > "$out/test.js" <<EOF
|
||||
document.getElementById('foobar').setAttribute('foo', 'yay');
|
||||
EOF
|
||||
cat > "$out/index.html" <<EOF
|
||||
<!DOCTYPE html>
|
||||
<div id="foobar">test</div>
|
||||
<script src="test.js"></script>
|
||||
EOF
|
||||
'');
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
client = { pkgs, lib, ... }: {
|
||||
virtualisation.memorySize = 512;
|
||||
environment.systemPackages = let
|
||||
testRunner = pkgs.writers.writePython3Bin "test-runner" {
|
||||
libraries = [ pkgs.python3Packages.selenium ];
|
||||
} ''
|
||||
import os
|
||||
import time
|
||||
|
||||
from selenium.webdriver import Firefox
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
|
||||
options = Options()
|
||||
options.add_argument('--headless')
|
||||
driver = Firefox(options=options)
|
||||
|
||||
driver.implicitly_wait(20)
|
||||
driver.get('http://server/')
|
||||
driver.find_element_by_xpath('//div[@foo="bar"]')
|
||||
open('/tmp/passed_stage1', 'w')
|
||||
|
||||
while not os.path.exists('/tmp/proceed'):
|
||||
time.sleep(0.5)
|
||||
|
||||
driver.get('http://server/')
|
||||
driver.find_element_by_xpath('//div[@foo="yay"]')
|
||||
open('/tmp/passed', 'w')
|
||||
'';
|
||||
in [ pkgs.firefox-unwrapped pkgs.geckodriver testRunner ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript = { nodes, ... }: let
|
||||
inherit (nodes.server.config.system.build) toplevel;
|
||||
newSystem = "${toplevel}/fine-tune/child-1";
|
||||
in ''
|
||||
start_all()
|
||||
|
||||
server.wait_for_unit("nginx.service")
|
||||
client.wait_for_unit("multi-user.target")
|
||||
client.execute("test-runner &")
|
||||
client.wait_for_file("/tmp/passed_stage1")
|
||||
|
||||
server.succeed(
|
||||
"${newSystem}/bin/switch-to-configuration test >&2"
|
||||
)
|
||||
client.succeed("touch /tmp/proceed")
|
||||
|
||||
client.wait_for_file("/tmp/passed")
|
||||
'';
|
||||
}
|
|
@ -6,11 +6,11 @@ assert stdenv ? glibc;
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "yoshimi";
|
||||
version = "1.6.0.3";
|
||||
version = "1.6.1";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://sourceforge/yoshimi/${pname}-${version}.tar.bz2";
|
||||
sha256 = "1z2mnmm299ng6jcwa61dzr1ilwa5fjgsggxl2wa5smji6b4npmx7";
|
||||
sha256 = "044k2pcdsb43znc8q63mc4niggpain7wl9s5c4sgsfmrjh0bjapj";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
}:
|
||||
python2.pkgs.buildPythonApplication rec {
|
||||
pname = "chirp-daily";
|
||||
version = "20191123";
|
||||
version = "20191221";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://trac.chirp.danplanet.com/chirp_daily/daily-${version}/${pname}-${version}.tar.gz";
|
||||
sha256 = "11wzk0c9fa3gp185gyd47g3sh7gfallw7qapr6qp913q2zfmif8v";
|
||||
sha256 = "1f4h45cbaq3rssl95xax8gn2bm1slnsbgds479db46czgq6y1qhy";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = with python2.pkgs; [
|
||||
pygtk pyserial libxml2
|
||||
pygtk pyserial libxml2 future
|
||||
];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "bcftools";
|
||||
version = "1.9";
|
||||
version = "1.10.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/samtools/bcftools/releases/download/${version}/${pname}-${version}.tar.bz2";
|
||||
sha256 = "1j3h638i8kgihzyrlnpj82xg1b23sijibys9hvwari3fy7kd0dkg";
|
||||
sha256 = "0b2f6lqhxdlrvfjqxv7a4nzqj68c1j4avn16iqxwwm80kn302wzm";
|
||||
};
|
||||
|
||||
buildInputs = [ htslib zlib bzip2 lzma curl perl python ];
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "gleam";
|
||||
version = "0.5.0";
|
||||
version = "0.6.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "lpil";
|
||||
owner = "gleam-lang";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "17h573fm5b1f71ivyipl76p0vw7injm7j3cbg6plkfizcb1j5m7f";
|
||||
sha256 = "1fvy2j6pw1rwm0rg7555q3qg2069cx2b9lk0nsyc3jxsqp9hbn6i";
|
||||
};
|
||||
|
||||
buildInputs = stdenv.lib.optionals stdenv.isDarwin [ Security ];
|
||||
|
||||
cargoSha256 = "04v1gj5nmmcizyrsg6b87qsfzw2zqi57vf1zlnq8680yc54qdah9";
|
||||
cargoSha256 = "0zfdsnrnxplvi4f92l7sqdp5yk5p738ra64m41izlcilkwj1j3vp";
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A statically typed language for the Erlang VM";
|
||||
|
|
|
@ -63,6 +63,9 @@ stdenv.mkDerivation rec {
|
|||
url = "https://salsa.debian.org/gnome-team/gegl/raw/9b7520b38d87cd8ad4b39bf0b8c62d011da25169/debian/patches/increase_test_timeout.patch";
|
||||
sha256 = "1prc1h1aipjd9db0i1j7nzga4zvk3vl8qsjpz1jzv1wwvz02isly";
|
||||
})
|
||||
|
||||
# Remove gegl:simple / backend-file test that times out frequently
|
||||
./patches/no-simple-backend-file-test.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
diff --git a/tests/simple/meson.build b/tests/simple/meson.build
|
||||
index 2c735d80a..ae4d50f2a 100644
|
||||
--- a/tests/simple/meson.build
|
||||
+++ b/tests/simple/meson.build
|
||||
@@ -1,5 +1,4 @@
|
||||
testnames = [
|
||||
- 'backend-file',
|
||||
'buffer-cast',
|
||||
'buffer-changes',
|
||||
'buffer-extract',
|
|
@ -1,20 +1,25 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, fetchurl
|
||||
, fetchgit
|
||||
, autoreconfHook
|
||||
, optimize ? false # impure hardware optimizations
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gf2x";
|
||||
version = "1.2"; # remember to also update the url
|
||||
version = "1.3.0";
|
||||
|
||||
src = fetchurl {
|
||||
# find link to latest version (with file id) here: https://gforge.inria.fr/projects/gf2x/
|
||||
# Requested a predictable link:
|
||||
# https://gforge.inria.fr/tracker/index.php?func=detail&aid=21704&group_id=1874&atid=6982
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/36934/gf2x-${version}.tar.gz";
|
||||
sha256 = "0d6vh1mxskvv3bxl6byp7gxxw3zzpkldrxnyajhnl05m0gx7yhk1";
|
||||
# upstream has plans to move to gitlab:
|
||||
# https://github.com/NixOS/nixpkgs/pull/45299#issuecomment-564477936
|
||||
src = fetchgit {
|
||||
url = "https://scm.gforge.inria.fr/anonscm/git/gf2x/gf2x.git";
|
||||
rev = "gf2x-${version}";
|
||||
sha256 = "04g5jg0i4vz46b4w2dvbmahwzi3k6b8g515mfw7im1inc78s14id";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook
|
||||
];
|
||||
|
||||
# no actual checks present yet (as of 1.2), but can't hurt trying
|
||||
# for an indirect test, run ntl's test suite
|
||||
doCheck = true;
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "libfilezilla";
|
||||
version = "0.19.1";
|
||||
version = "0.19.3";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://download.filezilla-project.org/${pname}/${pname}-${version}.tar.bz2";
|
||||
sha256 = "0cjscv68nnqivzba94xapx1c970j1jbdbm0h3g2ym9i0hgnyyhha";
|
||||
sha256 = "0fml6whdbfcwc8nfjhvrnidkscv6q2x988zf3alfjl2mdpw4jgd4";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkgconfig ];
|
||||
|
|
|
@ -14,11 +14,11 @@ assert withGf2x -> gf2x != null;
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "ntl";
|
||||
version = "11.4.1";
|
||||
version = "11.4.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://www.shoup.net/ntl/ntl-${version}.tar.gz";
|
||||
sha256 = "03k2hb6yn49d1f9cdig2ci7h5ga0x3nb3li60hh19wdqzg28f1m3";
|
||||
sha256 = "11r3f37psdbjw926kf6bn5bp69aj88f5cchvv1xh2bhrcjdp4r1b";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
|
@ -67,6 +67,8 @@ stdenv.mkDerivation rec {
|
|||
# Upstream contact: maintainer is victorshoup on GitHub. Alternatively the
|
||||
# email listed on the homepage.
|
||||
homepage = http://www.shoup.net/ntl/;
|
||||
# also locally at "${src}/doc/tour-changes.html";
|
||||
changelog = "https://www.shoup.net/ntl/doc/tour-changes.html";
|
||||
maintainers = with maintainers; [ timokau ];
|
||||
license = licenses.gpl2Plus;
|
||||
platforms = platforms.all;
|
||||
|
|
|
@ -18,6 +18,8 @@ buildPythonPackage rec {
|
|||
sha256 = "eb925d8682d70563ccb80e2aca7b3edf84fb0b768cea3edc6846aac7abdc414a";
|
||||
};
|
||||
|
||||
format = "pyproject";
|
||||
|
||||
nativeBuildInputs = [ setuptools_scm ];
|
||||
propagatedBuildInputs = [ pyyaml six ansible ruamel_yaml ];
|
||||
checkInputs = [ nose ];
|
||||
|
@ -31,10 +33,11 @@ buildPythonPackage rec {
|
|||
# give a hint to setuptools_scm on package version
|
||||
preBuild = ''
|
||||
export SETUPTOOLS_SCM_PRETEND_VERSION="v${version}"
|
||||
export HOME=$(mktemp -d)
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
PATH=$out/bin:$PATH HOME=$(mktemp -d) nosetests test
|
||||
PATH=$out/bin:$PATH nosetests test
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, fetchFromGitHub, rustPlatform
|
||||
{ lib, stdenv, fetchFromGitHub, rustPlatform, makeWrapper, perf
|
||||
, Security
|
||||
}:
|
||||
|
||||
|
@ -15,11 +15,19 @@ rustPlatform.buildRustPackage rec {
|
|||
|
||||
cargoSha256 = "0kmw2n4j5bisac0bv3npbwfz2z00ncd6w8ichwaz5hac5mi1a72f";
|
||||
|
||||
buildInputs = stdenv.lib.optionals stdenv.isDarwin [
|
||||
nativeBuildInputs = lib.optionals stdenv.isLinux [ makeWrapper ];
|
||||
buildInputs = lib.optionals stdenv.isDarwin [
|
||||
Security
|
||||
];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
postFixup = lib.optionalString stdenv.isLinux ''
|
||||
wrapProgram $out/bin/cargo-flamegraph \
|
||||
--suffix PATH ':' ${perf}/bin
|
||||
wrapProgram $out/bin/flamegraph \
|
||||
--suffix PATH ':' ${perf}/bin
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3";
|
||||
homepage = https://github.com/ferrous-systems/flamegraph;
|
||||
license = with licenses; [ asl20 /* or */ mit ];
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
pkgs
|
||||
, stdenv
|
||||
, libusb
|
||||
, fetchFromGitHub
|
||||
, lib
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "micronucleus";
|
||||
version = "2.04";
|
||||
|
||||
sourceRoot = "source/commandline";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "micronucleus";
|
||||
repo = "micronucleus";
|
||||
rev = version;
|
||||
sha256 = "14msy9amlbflw5mqrbs57b7bby3nsgx43srr7215zyhfdgsla0in";
|
||||
};
|
||||
|
||||
buildInputs = [ libusb ];
|
||||
makeFlags = stdenv.lib.optionals stdenv.isDarwin [ "CC=cc" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/lib/udev
|
||||
cp micronucleus $out/bin
|
||||
cp 49-micronucleus.rules $out/lib/udev
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Upload tool for micronucleus";
|
||||
homepage = "https://github.com/micronucleus/micronucleus";
|
||||
license = licenses.gpl3;
|
||||
maintainers = [ maintainers.cab404 ];
|
||||
};
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "sysbench";
|
||||
version = "1.0.18";
|
||||
version = "1.0.19";
|
||||
|
||||
nativeBuildInputs = [ autoreconfHook pkgconfig ];
|
||||
buildInputs = [ libmysqlclient libaio ];
|
||||
|
@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
|
|||
owner = "akopytov";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
sha256 = "1r6lkyfp65xqklj1rdfw551srqqyak144agi8x3wjz3wmsbqls19";
|
||||
sha256 = "1zgqb9cr7ld3vw4a3jhq1mlszhcyjlpr0c8q1jcp1d27l9dcvd1w";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
{ lib, poetry2nix, python, fetchFromGitHub, runtimeShell }:
|
||||
|
||||
poetry2nix.mkPoetryApplication {
|
||||
|
||||
inherit python;
|
||||
|
||||
pyproject = ./pyproject.toml;
|
||||
poetrylock = ./poetry.lock;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "sdispater";
|
||||
repo = "poetry";
|
||||
rev = "1.0.0";
|
||||
sha256 = "05xlx9wnlrsjj3i4wawnvxadvqwsdh03401wpgingkbq0c50aimi";
|
||||
};
|
||||
|
||||
# "Vendor" dependencies (for build-system support)
|
||||
postPatch = ''
|
||||
for path in ''${PYTHONPATH//:/ }; do
|
||||
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
|
||||
done
|
||||
'';
|
||||
|
||||
# Poetry is a bit special in that it can't use itself as the `build-system` property in pyproject.toml.
|
||||
# That's why we need to hackily install outputs completely manually.
|
||||
#
|
||||
# For projects using poetry normally overriding the installPhase is not required.
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/${python.libPrefix}/site-packages
|
||||
cp -r poetry $out/lib/${python.libPrefix}/site-packages
|
||||
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/poetry <<EOF
|
||||
#!${runtimeShell}
|
||||
export PYTHONPATH=$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH
|
||||
exec ${python.interpreter} -m poetry "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/poetry
|
||||
|
||||
mkdir -p "$out/share/bash-completion/completions"
|
||||
"$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
|
||||
mkdir -p "$out/share/zsh/vendor-completions"
|
||||
"$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
|
||||
mkdir -p "$out/share/fish/vendor_completions.d"
|
||||
"$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Propagating dependencies leads to issues downstream
|
||||
# We've already patched poetry to prefer "vendored" dependencies
|
||||
postFixup = ''
|
||||
rm $out/nix-support/propagated-build-inputs
|
||||
'';
|
||||
|
||||
# Fails because of impurities (network, git etc etc)
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ adisbladis jakewaksbaum ];
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,118 @@
|
|||
[tool.poetry]
|
||||
name = "poetry"
|
||||
version = "1.0.0"
|
||||
description = "Python dependency management and packaging made easy."
|
||||
authors = [
|
||||
"Sébastien Eustace <sebastien@eustace.io>"
|
||||
]
|
||||
license = "MIT"
|
||||
|
||||
readme = "README.md"
|
||||
|
||||
homepage = "https://python-poetry.org/"
|
||||
repository = "https://github.com/python-poetry/poetry"
|
||||
documentation = "https://python-poetry.org/docs"
|
||||
|
||||
keywords = ["packaging", "dependency", "poetry"]
|
||||
|
||||
classifiers = [
|
||||
"Topic :: Software Development :: Build Tools",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules"
|
||||
]
|
||||
|
||||
# Requirements
|
||||
[tool.poetry.dependencies]
|
||||
python = "~2.7 || ^3.4"
|
||||
cleo = "^0.7.6"
|
||||
clikit = "^0.4.1"
|
||||
requests = "^2.18"
|
||||
cachy = "^0.3.0"
|
||||
requests-toolbelt = "^0.8.0"
|
||||
jsonschema = "^3.1"
|
||||
pyrsistent = "^0.14.2"
|
||||
pyparsing = "^2.2"
|
||||
cachecontrol = { version = "^0.12.4", extras = ["filecache"] }
|
||||
pkginfo = "^1.4"
|
||||
html5lib = "^1.0"
|
||||
shellingham = "^1.1"
|
||||
tomlkit = "^0.5.8"
|
||||
pexpect = "^4.7.0"
|
||||
|
||||
# The typing module is not in the stdlib in Python 2.7 and 3.4
|
||||
typing = { version = "^3.6", python = "~2.7 || ~3.4" }
|
||||
|
||||
# Use pathlib2 for Python 2.7 and 3.4
|
||||
pathlib2 = { version = "^2.3", python = "~2.7 || ~3.4" }
|
||||
# Use glob2 for Python 2.7 and 3.4
|
||||
glob2 = { version = "^0.6", python = "~2.7 || ~3.4" }
|
||||
# Use virtualenv for Python 2.7 since venv does not exist
|
||||
virtualenv = { version = "^16.0", python = "~2.7" }
|
||||
# functools32 is needed for Python 2.7
|
||||
functools32 = { version = "^3.2.3", python = "~2.7" }
|
||||
keyring = [
|
||||
{ version = "^18.0", python = "~2.7 || ~3.4" },
|
||||
{ version = "^19.0", python = "^3.5" }
|
||||
]
|
||||
# Use subprocess32 for Python 2.7 and 3.4
|
||||
subprocess32 = { version = "^3.5", python = "~2.7 || ~3.4" }
|
||||
importlib-metadata = {version = "^0.23", python = "<3.8"}
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^4.1"
|
||||
pytest-cov = "^2.5"
|
||||
mkdocs = { version = "^1.0", python = "~2.7.9 || ^3.4" }
|
||||
pymdown-extensions = "^6.0"
|
||||
pygments = "^2.2"
|
||||
pytest-mock = "^1.9"
|
||||
pygments-github-lexers = "^0.0.5"
|
||||
black = { version = "^19.10b0", python = "^3.6" }
|
||||
pre-commit = "^1.10"
|
||||
tox = "^3.0"
|
||||
pytest-sugar = "^0.9.2"
|
||||
httpretty = "^0.9.6"
|
||||
markdown-include = "^0.5.1"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
poetry = "poetry.console:main"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["intreehooks"]
|
||||
build-backend = "intreehooks:loader"
|
||||
|
||||
[tool.intreehooks]
|
||||
build-backend = "poetry.masonry.api"
|
||||
|
||||
|
||||
[tool.isort]
|
||||
line_length = 88
|
||||
force_single_line = true
|
||||
atomic = true
|
||||
include_trailing_comma = true
|
||||
lines_after_imports = 2
|
||||
lines_between_types = 1
|
||||
multi_line_output = 3
|
||||
use_parentheses = true
|
||||
not_skip = "__init__.py"
|
||||
skip_glob = ["*/setup.py"]
|
||||
filter_files = true
|
||||
|
||||
known_first_party = "poetry"
|
||||
known_third_party = [
|
||||
"cachecontrol",
|
||||
"cachy",
|
||||
"cleo",
|
||||
"clikit",
|
||||
"html5lib",
|
||||
"httpretty",
|
||||
"jsonschema",
|
||||
"keyring",
|
||||
"pexpect",
|
||||
"pkginfo",
|
||||
"pyparsing",
|
||||
"pytest",
|
||||
"requests",
|
||||
"requests_toolbelt",
|
||||
"shellingham",
|
||||
"tomlkit",
|
||||
]
|
|
@ -0,0 +1,6 @@
|
|||
Dont change these files here, they are maintained at https://github.com/nix-community/poetry2nix
|
||||
|
||||
The update procedure is as-follows:
|
||||
1. Send your change to the upstream poetry2nix repository
|
||||
2. Get it approved with tests passing
|
||||
3. Run the update script in pkgs/development/tools/poetry2nix
|
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/env python
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import subprocess
|
||||
import textwrap
|
||||
import argparse
|
||||
import toml
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
argparser = argparse.ArgumentParser(description="Generate overrides for git hashes",)
|
||||
argparser.add_argument(
|
||||
"--lock", default="poetry.lock", help="Path to input poetry.lock",
|
||||
)
|
||||
argparser.add_argument(
|
||||
"--out", default="poetry-git-overlay.nix", help="Output file",
|
||||
)
|
||||
|
||||
|
||||
def fetch_git(pkg):
|
||||
return (
|
||||
pkg["name"],
|
||||
subprocess.run(
|
||||
[
|
||||
"nix-prefetch-git",
|
||||
"--fetch-submodules",
|
||||
"--url",
|
||||
pkg["source"]["url"],
|
||||
"--rev",
|
||||
pkg["source"]["reference"],
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def indent(expr, spaces=2):
|
||||
i = " " * spaces
|
||||
return "\n".join([(i if l != "" else "") + l for l in expr.split("\n")])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = argparser.parse_args()
|
||||
|
||||
with open(args.lock) as lockf:
|
||||
lock = toml.load(lockf)
|
||||
|
||||
pkgs = []
|
||||
for pkg in lock["package"]:
|
||||
if "source" in pkg:
|
||||
pkgs.append(pkg)
|
||||
|
||||
with ThreadPoolExecutor() as e:
|
||||
futures = []
|
||||
|
||||
for pkg in pkgs:
|
||||
futures.append(e.submit(fetch_git, pkg))
|
||||
|
||||
lines = [
|
||||
"{ pkgs }:",
|
||||
"self: super: {",
|
||||
]
|
||||
|
||||
for f in futures:
|
||||
drv_name, p = f.result()
|
||||
if p.returncode != 0:
|
||||
sys.stderr.buffer.write(p.stderr)
|
||||
sys.stderr.buffer.flush()
|
||||
exit(p.returncode)
|
||||
|
||||
meta = json.loads(p.stdout.decode())
|
||||
lines.append(
|
||||
indent(
|
||||
textwrap.dedent(
|
||||
"""
|
||||
%s = super.%s.overrideAttrs (
|
||||
_: {
|
||||
src = pkgs.fetchgit {
|
||||
url = "%s";
|
||||
rev = "%s";
|
||||
sha256 = "%s";
|
||||
};
|
||||
}
|
||||
);"""
|
||||
% (drv_name, drv_name, meta["url"], meta["rev"], meta["sha256"])
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
lines.extend(["", "}", ""])
|
||||
|
||||
expr = "\n".join(lines)
|
||||
|
||||
with open(args.out, "w") as f:
|
||||
f.write(expr)
|
||||
|
||||
print(f"Wrote {args.out}")
|
|
@ -0,0 +1,52 @@
|
|||
{ pkgs ? import <nixpkgs> {}
|
||||
, lib ? pkgs.lib
|
||||
, version
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) python3;
|
||||
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "poetry2nix";
|
||||
inherit version;
|
||||
|
||||
buildInputs = [
|
||||
(python3.withPackages (ps: [ ps.toml ]))
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.makeWrapper
|
||||
];
|
||||
|
||||
src = ./bin;
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
${python3.pkgs.black}/bin/black --quiet --check poetry2nix
|
||||
patchShebangs poetry2nix
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
mv poetry2nix $out/bin
|
||||
|
||||
wrapProgram $out/bin/poetry2nix --prefix PATH ":" ${lib.makeBinPath [
|
||||
pkgs.nix-prefetch-git
|
||||
]}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "https://github.com/nix-community/poetry2nix";
|
||||
description = "CLI to supplement sha256 hashes for git dependencies";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = [ lib.maintainers.adisbladis ];
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
{ pkgs ? import <nixpkgs> {}
|
||||
, lib ? pkgs.lib
|
||||
, poetry ? null
|
||||
, poetryLib ? import ./lib.nix { inherit lib pkgs; }
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (poetryLib) isCompatible readTOML;
|
||||
|
||||
# Poetry2nix version
|
||||
version = "1.1.0";
|
||||
|
||||
/* The default list of poetry2nix override overlays */
|
||||
defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; });
|
||||
|
||||
mkEvalPep508 = import ./pep508.nix {
|
||||
inherit lib;
|
||||
stdenv = pkgs.stdenv;
|
||||
};
|
||||
|
||||
getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn;
|
||||
|
||||
getAttrDefault = attribute: set: default: (
|
||||
if builtins.hasAttr attribute set
|
||||
then builtins.getAttr attribute set
|
||||
else default
|
||||
);
|
||||
|
||||
# Map SPDX identifiers to license names
|
||||
spdxLicenses = lib.listToAttrs (lib.filter (pair: pair.name != null) (builtins.map (v: { name = if lib.hasAttr "spdxId" v then v.spdxId else null; value = v; }) (lib.attrValues lib.licenses)));
|
||||
# Get license by id falling back to input string
|
||||
getLicenseBySpdxId = spdxId: getAttrDefault spdxId spdxLicenses spdxId;
|
||||
|
||||
#
|
||||
# Returns an attrset { python, poetryPackages } for the given lockfile
|
||||
#
|
||||
mkPoetryPython =
|
||||
{ poetrylock
|
||||
, poetryPkg
|
||||
, overrides ? [ defaultPoetryOverrides ]
|
||||
, meta ? {}
|
||||
, python ? pkgs.python3
|
||||
, pwd ? null
|
||||
}@attrs: let
|
||||
lockData = readTOML poetrylock;
|
||||
lockFiles = lib.getAttrFromPath [ "metadata" "files" ] lockData;
|
||||
|
||||
specialAttrs = [ "poetrylock" "overrides" ];
|
||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||
|
||||
evalPep508 = mkEvalPep508 python;
|
||||
|
||||
# Filter packages by their PEP508 markers
|
||||
partitions = let
|
||||
supportsPythonVersion = pkgMeta: if pkgMeta ? marker then (evalPep508 pkgMeta.marker) else true;
|
||||
in
|
||||
lib.partition supportsPythonVersion lockData.package;
|
||||
|
||||
compatible = partitions.right;
|
||||
incompatible = partitions.wrong;
|
||||
|
||||
# Create an overriden version of pythonPackages
|
||||
#
|
||||
# We need to avoid mixing multiple versions of pythonPackages in the same
|
||||
# closure as python can only ever have one version of a dependency
|
||||
baseOverlay = self: super:
|
||||
let
|
||||
getDep = depName: if builtins.hasAttr depName self then self."${depName}" else throw "foo";
|
||||
|
||||
lockPkgs = builtins.listToAttrs (
|
||||
builtins.map (
|
||||
pkgMeta: rec {
|
||||
name = pkgMeta.name;
|
||||
value = self.mkPoetryDep (
|
||||
pkgMeta // {
|
||||
inherit pwd;
|
||||
source = getAttrDefault "source" pkgMeta null;
|
||||
files = lockFiles.${name};
|
||||
pythonPackages = self;
|
||||
}
|
||||
);
|
||||
}
|
||||
) compatible
|
||||
);
|
||||
in
|
||||
lockPkgs;
|
||||
|
||||
overlays = builtins.map getFunctorFn (
|
||||
[
|
||||
(
|
||||
self: super: {
|
||||
mkPoetryDep = self.callPackage ./mk-poetry-dep.nix {
|
||||
inherit pkgs lib python poetryLib;
|
||||
};
|
||||
poetry = poetryPkg;
|
||||
}
|
||||
)
|
||||
# Null out any filtered packages, we don't want python.pkgs from nixpkgs
|
||||
(self: super: builtins.listToAttrs (builtins.map (x: { name = x.name; value = null; }) incompatible))
|
||||
# Create poetry2nix layer
|
||||
baseOverlay
|
||||
] ++ # User provided overrides
|
||||
overrides
|
||||
);
|
||||
|
||||
packageOverrides = lib.foldr lib.composeExtensions (self: super: {}) overlays;
|
||||
|
||||
py = python.override { inherit packageOverrides; self = py; };
|
||||
in
|
||||
{
|
||||
python = py;
|
||||
poetryPackages = map (pkg: py.pkgs.${pkg.name}) compatible;
|
||||
};
|
||||
|
||||
/* Returns a package with a python interpreter and all packages specified in the poetry.lock lock file.
|
||||
|
||||
Example:
|
||||
poetry2nix.mkPoetryEnv { poetrylock = ./poetry.lock; python = python3; }
|
||||
*/
|
||||
mkPoetryEnv =
|
||||
{ poetrylock
|
||||
, overrides ? [ defaultPoetryOverrides ]
|
||||
, meta ? {}
|
||||
, pwd ? null
|
||||
, python ? pkgs.python3
|
||||
}:
|
||||
let
|
||||
poetryPkg = poetry.override { inherit python; };
|
||||
py = mkPoetryPython (
|
||||
{
|
||||
inherit poetryPkg poetrylock overrides meta python pwd;
|
||||
}
|
||||
);
|
||||
in
|
||||
py.python.withPackages (_: py.poetryPackages);
|
||||
|
||||
/* Creates a Python application from pyproject.toml and poetry.lock */
|
||||
mkPoetryApplication =
|
||||
{ src
|
||||
, pyproject
|
||||
, poetrylock
|
||||
, overrides ? [ defaultPoetryOverrides ]
|
||||
, meta ? {}
|
||||
, python ? pkgs.python3
|
||||
, pwd ? null
|
||||
, ...
|
||||
}@attrs: let
|
||||
poetryPkg = poetry.override { inherit python; };
|
||||
|
||||
py = (
|
||||
mkPoetryPython {
|
||||
inherit poetryPkg poetrylock overrides meta python pwd;
|
||||
}
|
||||
).python;
|
||||
|
||||
pyProject = readTOML pyproject;
|
||||
|
||||
specialAttrs = [ "pyproject" "poetrylock" "overrides" ];
|
||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||
|
||||
getDeps = depAttr: let
|
||||
deps = getAttrDefault depAttr pyProject.tool.poetry {};
|
||||
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
||||
in
|
||||
builtins.map (dep: py.pkgs."${dep}") depAttrs;
|
||||
|
||||
getInputs = attr: getAttrDefault attr attrs [];
|
||||
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
|
||||
|
||||
buildSystemPkgs = poetryLib.getBuildSystemPkgs {
|
||||
inherit pyProject;
|
||||
pythonPackages = py.pkgs;
|
||||
};
|
||||
|
||||
in
|
||||
py.pkgs.buildPythonApplication (
|
||||
passedAttrs // {
|
||||
pname = pyProject.tool.poetry.name;
|
||||
version = pyProject.tool.poetry.version;
|
||||
|
||||
format = "pyproject";
|
||||
|
||||
nativeBuildInputs = [ pkgs.yj ];
|
||||
buildInputs = mkInput "buildInputs" buildSystemPkgs;
|
||||
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
|
||||
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
|
||||
|
||||
passthru = {
|
||||
python = py;
|
||||
};
|
||||
|
||||
postPatch = (getAttrDefault "postPatch" passedAttrs "") + ''
|
||||
# Tell poetry not to resolve the path dependencies. Any version is
|
||||
# fine !
|
||||
yj -tj < pyproject.toml | python ${./pyproject-without-path.py} > pyproject.json
|
||||
yj -jt < pyproject.json > pyproject.toml
|
||||
rm pyproject.json
|
||||
'';
|
||||
|
||||
meta = meta // {
|
||||
inherit (pyProject.tool.poetry) description homepage;
|
||||
license = getLicenseBySpdxId (getAttrDefault "license" pyProject.tool.poetry "unknown");
|
||||
};
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
|
||||
cli = import ./cli.nix { inherit pkgs lib version; };
|
||||
|
||||
/* Poetry2nix documentation */
|
||||
doc = pkgs.stdenv.mkDerivation {
|
||||
pname = "poetry2nix-docs";
|
||||
inherit version;
|
||||
|
||||
src = pkgs.runCommandNoCC "poetry2nix-docs-src" {} ''
|
||||
mkdir -p $out
|
||||
cp ${./default.nix} $out/default.nix
|
||||
'';
|
||||
|
||||
buildInputs = [
|
||||
pkgs.nixdoc
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
nixdoc --category poetry2nix --description "Poetry2nix functions" --file ./default.nix > poetry2nix.xml
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp poetry2nix.xml $out/
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
inherit mkPoetryEnv mkPoetryApplication cli doc;
|
||||
|
||||
/*
|
||||
The default list of poetry2nix override overlays
|
||||
|
||||
Can be overriden by calling defaultPoetryOverrides.overrideOverlay which takes an overlay function
|
||||
*/
|
||||
defaultPoetryOverrides = {
|
||||
__functor = defaultPoetryOverrides;
|
||||
overrideOverlay = fn: self: super: let
|
||||
defaultSet = defaultPoetryOverrides self super;
|
||||
customSet = fn self super;
|
||||
in defaultSet // customSet;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
"tar",
|
||||
"tar.bz2",
|
||||
"tar.gz",
|
||||
"tar.lz",
|
||||
"tar.lzma",
|
||||
"tar.xz",
|
||||
"tbz",
|
||||
"tgz",
|
||||
"tlz",
|
||||
"txz",
|
||||
"whl",
|
||||
"zip"
|
||||
]
|
|
@ -0,0 +1,79 @@
|
|||
{ lib, pkgs }:
|
||||
let
|
||||
inherit (import ./semver.nix { inherit lib; }) satisfiesSemver;
|
||||
|
||||
# Returns true if pythonVersion matches with the expression in pythonVersions
|
||||
isCompatible = pythonVersion: pythonVersions:
|
||||
let
|
||||
operators = {
|
||||
"||" = cond1: cond2: cond1 || cond2;
|
||||
"," = cond1: cond2: cond1 && cond2; # , means &&
|
||||
};
|
||||
# split string at "," and "||"
|
||||
tokens = builtins.filter (x: x != "") (builtins.split "(,|\\|\\|)" pythonVersions);
|
||||
combine = acc: v:
|
||||
let
|
||||
isOperator = builtins.typeOf v == "list";
|
||||
operator = if isOperator then (builtins.elemAt v 0) else acc.operator;
|
||||
in
|
||||
if isOperator then (acc // { inherit operator; }) else {
|
||||
inherit operator;
|
||||
state = operators."${operator}" acc.state (satisfiesSemver pythonVersion v);
|
||||
};
|
||||
initial = { operator = ","; state = true; };
|
||||
in
|
||||
(builtins.foldl' combine initial tokens).state;
|
||||
|
||||
readTOML = path: builtins.fromTOML (builtins.readFile path);
|
||||
|
||||
#
|
||||
# Returns the appropriate manylinux dependencies and string representation for the file specified
|
||||
#
|
||||
getManyLinuxDeps = f:
|
||||
let
|
||||
ml = pkgs.pythonManylinuxPackages;
|
||||
in
|
||||
if lib.strings.hasInfix "manylinux1" f then { pkg = [ ml.manylinux1 ]; str = "1"; }
|
||||
else if lib.strings.hasInfix "manylinux2010" f then { pkg = [ ml.manylinux2010 ]; str = "2010"; }
|
||||
else if lib.strings.hasInfix "manylinux2014" f then { pkg = [ ml.manylinux2014 ]; str = "2014"; }
|
||||
else { pkg = []; str = null; };
|
||||
|
||||
# Fetch the artifacts from the PyPI index. Since we get all
|
||||
# info we need from the lock file we don't use nixpkgs' fetchPyPi
|
||||
# as it modifies casing while not providing anything we don't already
|
||||
# have.
|
||||
#
|
||||
# Args:
|
||||
# pname: package name
|
||||
# file: filename including extension
|
||||
# hash: SRI hash
|
||||
# kind: Language implementation and version tag https://www.python.org/dev/peps/pep-0427/#file-name-convention
|
||||
fetchFromPypi = lib.makeOverridable (
|
||||
{ pname, file, hash, kind }:
|
||||
pkgs.fetchurl {
|
||||
url = "https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}";
|
||||
inherit hash;
|
||||
}
|
||||
);
|
||||
|
||||
getBuildSystemPkgs =
|
||||
{ pythonPackages
|
||||
, pyProject
|
||||
}: let
|
||||
buildSystem = lib.getAttrFromPath [ "build-system" "build-backend" ] pyProject;
|
||||
drvAttr = builtins.elemAt (builtins.split "\\.|:" buildSystem) 0;
|
||||
in
|
||||
if buildSystem == "" then [] else (
|
||||
[ pythonPackages.${drvAttr} or (throw "unsupported build system ${buildSystem}") ]
|
||||
);
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
fetchFromPypi
|
||||
getManyLinuxDeps
|
||||
isCompatible
|
||||
readTOML
|
||||
getBuildSystemPkgs
|
||||
;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
{ autoPatchelfHook
|
||||
, pkgs
|
||||
, lib
|
||||
, python
|
||||
, buildPythonPackage
|
||||
, pythonPackages
|
||||
, poetryLib
|
||||
}:
|
||||
{ name
|
||||
, version
|
||||
, files
|
||||
, source
|
||||
, dependencies ? {}
|
||||
, pythonPackages
|
||||
, python-versions
|
||||
, pwd
|
||||
, supportedExtensions ? lib.importJSON ./extensions.json
|
||||
, ...
|
||||
}: let
|
||||
|
||||
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi;
|
||||
|
||||
inherit (import ./pep425.nix {
|
||||
inherit lib python;
|
||||
inherit (pkgs) stdenv;
|
||||
}) selectWheel
|
||||
;
|
||||
|
||||
fileCandidates = let
|
||||
supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")");
|
||||
matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null;
|
||||
hasSupportedExtension = fname: builtins.match supportedRegex fname != null;
|
||||
in
|
||||
builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file) files;
|
||||
|
||||
toPath = s: pwd + "/${s}";
|
||||
|
||||
isSource = source != null;
|
||||
isGit = isSource && source.type == "git";
|
||||
isLocal = isSource && source.type == "directory";
|
||||
|
||||
localDepPath = toPath source.url;
|
||||
pyProject = poetryLib.readTOML (localDepPath + "/pyproject.toml");
|
||||
|
||||
buildSystemPkgs = poetryLib.getBuildSystemPkgs {
|
||||
inherit pythonPackages pyProject;
|
||||
};
|
||||
|
||||
fileInfo = let
|
||||
isBdist = f: lib.strings.hasSuffix "whl" f.file;
|
||||
isSdist = f: ! isBdist f;
|
||||
binaryDist = selectWheel fileCandidates;
|
||||
sourceDist = builtins.filter isSdist fileCandidates;
|
||||
lockFileEntry = if (builtins.length sourceDist) > 0 then builtins.head sourceDist else builtins.head binaryDist;
|
||||
in
|
||||
rec {
|
||||
inherit (lockFileEntry) file hash;
|
||||
name = file;
|
||||
format = if lib.strings.hasSuffix ".whl" name then "wheel" else "setuptools";
|
||||
kind = if format == "setuptools" then "source" else (builtins.elemAt (lib.strings.splitString "-" name) 2);
|
||||
};
|
||||
|
||||
in
|
||||
buildPythonPackage {
|
||||
pname = name;
|
||||
version = version;
|
||||
|
||||
doCheck = false; # We never get development deps
|
||||
dontStrip = true;
|
||||
format = if isLocal then "pyproject" else if isGit then "setuptools" else fileInfo.format;
|
||||
|
||||
nativeBuildInputs = if (!isSource && (getManyLinuxDeps fileInfo.name).str != null) then [ autoPatchelfHook ] else [];
|
||||
buildInputs = if !isSource then (getManyLinuxDeps fileInfo.name).pkg else [];
|
||||
|
||||
propagatedBuildInputs =
|
||||
let
|
||||
# Some dependencies like django gets the attribute name django
|
||||
# but dependencies try to access Django
|
||||
deps = builtins.map (d: lib.toLower d) (builtins.attrNames dependencies);
|
||||
in
|
||||
(builtins.map (n: pythonPackages.${n}) deps) ++ (if isLocal then buildSystemPkgs else []);
|
||||
|
||||
meta = {
|
||||
broken = ! isCompatible python.version python-versions;
|
||||
license = [];
|
||||
};
|
||||
|
||||
# We need to retrieve kind from the interpreter and the filename of the package
|
||||
# Interpreters should declare what wheel types they're compatible with (python type + ABI)
|
||||
# Here we can then choose a file based on that info.
|
||||
src = if isGit then (
|
||||
builtins.fetchGit {
|
||||
inherit (source) url;
|
||||
rev = source.reference;
|
||||
}
|
||||
) else if isLocal then (localDepPath) else fetchFromPypi {
|
||||
pname = name;
|
||||
inherit (fileInfo) file hash kind;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,405 @@
|
|||
{ pkgs ? import <nixpkgs> {}
|
||||
, lib ? pkgs.lib
|
||||
, stdenv ? pkgs.stdenv
|
||||
}:
|
||||
|
||||
self: super:
|
||||
|
||||
let
|
||||
|
||||
addSetupTools = drv: if drv == null then null else drv.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.setuptools_scm
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
getAttrDefault = attribute: set: default:
|
||||
if builtins.hasAttr attribute set
|
||||
then builtins.getAttr attribute set
|
||||
else default;
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
asciimatics = super.asciimatics.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.setuptools_scm
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
av = super.av.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||
pkgs.pkgconfig
|
||||
];
|
||||
buildInputs = old.buildInputs ++ [ pkgs.ffmpeg_4 ];
|
||||
}
|
||||
);
|
||||
|
||||
bcrypt = super.bcrypt.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.libffi ];
|
||||
}
|
||||
);
|
||||
|
||||
cffi = super.cffi.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.libffi ];
|
||||
}
|
||||
);
|
||||
|
||||
cftime = super.cftime.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.cython
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
configparser = addSetupTools super.configparser;
|
||||
|
||||
cbor2 = addSetupTools super.cbor2;
|
||||
|
||||
cryptography = super.cryptography.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.openssl ];
|
||||
}
|
||||
);
|
||||
|
||||
django = (
|
||||
super.django.overrideAttrs (
|
||||
old: {
|
||||
propagatedNativeBuildInputs = (getAttrDefault "propagatedNativeBuildInputs" old [])
|
||||
++ [ pkgs.gettext ];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
django-bakery = super.django-bakery.overrideAttrs (
|
||||
old: {
|
||||
configurePhase = ''
|
||||
if ! test -e LICENSE; then
|
||||
touch LICENSE
|
||||
fi
|
||||
'' + (getAttrDefault "configurePhase" old "");
|
||||
}
|
||||
);
|
||||
|
||||
# Environment markers are not always included (depending on how a dep was defined)
|
||||
enum34 = if self.pythonAtLeast "3.4" then null else super.enum34;
|
||||
|
||||
grandalf = super.grandalf.overrideAttrs (
|
||||
old: {
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py --replace "setup_requires=['pytest-runner',]," "setup_requires=[]," || true
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
horovod = super.horovod.overrideAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.openmpi ];
|
||||
}
|
||||
);
|
||||
|
||||
hypothesis = addSetupTools super.hypothesis;
|
||||
|
||||
importlib-metadata = addSetupTools super.importlib-metadata;
|
||||
|
||||
inflect = super.inflect.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.setuptools_scm
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
jsonschema = addSetupTools super.jsonschema;
|
||||
|
||||
keyring = addSetupTools super.keyring;
|
||||
|
||||
lap = super.lap.overrideAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
self.numpy
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
llvmlite = super.llvmlite.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ];
|
||||
|
||||
# Disable static linking
|
||||
# https://github.com/numba/llvmlite/issues/93
|
||||
postPatch = ''
|
||||
substituteInPlace ffi/Makefile.linux --replace "-static-libstdc++" ""
|
||||
|
||||
substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope"
|
||||
'';
|
||||
|
||||
# Set directory containing llvm-config binary
|
||||
preConfigure = ''
|
||||
export LLVM_CONFIG=${pkgs.llvm}/bin/llvm-config
|
||||
'';
|
||||
|
||||
__impureHostDeps = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "/usr/lib/libm.dylib" ];
|
||||
|
||||
passthru = old.passthru // { llvm = pkgs.llvm; };
|
||||
}
|
||||
);
|
||||
|
||||
lockfile = super.lockfile.overrideAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ];
|
||||
}
|
||||
);
|
||||
|
||||
lxml = super.lxml.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ pkgconfig libxml2.dev libxslt.dev ];
|
||||
buildInputs = with pkgs; old.buildInputs ++ [ libxml2 libxslt ];
|
||||
}
|
||||
);
|
||||
|
||||
markupsafe = super.markupsafe.overrideAttrs (
|
||||
old: {
|
||||
src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; };
|
||||
}
|
||||
);
|
||||
|
||||
matplotlib = super.matplotlib.overrideAttrs (
|
||||
old: {
|
||||
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${pkgs.libcxx}/include/c++/v1";
|
||||
|
||||
XDG_RUNTIME_DIR = "/tmp";
|
||||
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||
pkgs.pkgconfig
|
||||
];
|
||||
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
pkgs.libpng
|
||||
pkgs.freetype
|
||||
];
|
||||
|
||||
inherit (super.matplotlib) patches;
|
||||
}
|
||||
);
|
||||
|
||||
mccabe = super.mccabe.overrideAttrs (
|
||||
old: {
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py --replace "setup_requires=['pytest-runner']," "setup_requires=[]," || true
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
netcdf4 = super.netcdf4.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.cython
|
||||
];
|
||||
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
pkgs.zlib
|
||||
pkgs.netcdf
|
||||
pkgs.hdf5
|
||||
pkgs.curl
|
||||
pkgs.libjpeg
|
||||
];
|
||||
|
||||
# Variables used to configure the build process
|
||||
USE_NCCONFIG = "0";
|
||||
HDF5_DIR = lib.getDev pkgs.hdf5;
|
||||
NETCDF4_DIR = pkgs.netcdf;
|
||||
CURL_DIR = pkgs.curl.dev;
|
||||
JPEG_DIR = pkgs.libjpeg.dev;
|
||||
}
|
||||
);
|
||||
|
||||
numpy = super.numpy.overrideAttrs (
|
||||
old: let
|
||||
blas = pkgs.openblasCompat;
|
||||
blasImplementation = lib.nameFromURL blas.name "-";
|
||||
cfg = pkgs.writeTextFile {
|
||||
name = "site.cfg";
|
||||
text = (
|
||||
lib.generators.toINI {} {
|
||||
${blasImplementation} = {
|
||||
include_dirs = "${blas}/include";
|
||||
library_dirs = "${blas}/lib";
|
||||
} // lib.optionalAttrs (blasImplementation == "mkl") {
|
||||
mkl_libs = "mkl_rt";
|
||||
lapack_libs = "";
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
{
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ];
|
||||
buildInputs = old.buildInputs ++ [ blas ];
|
||||
enableParallelBuilding = true;
|
||||
preBuild = ''
|
||||
ln -s ${cfg} site.cfg
|
||||
'';
|
||||
passthru = old.passthru // {
|
||||
blas = blas;
|
||||
inherit blasImplementation cfg;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
pillow = super.pillow.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = [ pkgs.pkgconfig ] ++ old.nativeBuildInputs;
|
||||
buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ old.buildInputs;
|
||||
}
|
||||
);
|
||||
|
||||
pluggy = addSetupTools super.pluggy;
|
||||
|
||||
psycopg2 = super.psycopg2.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
|
||||
}
|
||||
);
|
||||
|
||||
psycopg2-binary = super.psycopg2-binary.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
|
||||
}
|
||||
);
|
||||
|
||||
py = addSetupTools super.py;
|
||||
|
||||
pyarrow = super.pyarrow.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.cython
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
pycairo = (
|
||||
drv: (
|
||||
drv.overridePythonAttrs (
|
||||
_: {
|
||||
format = "other";
|
||||
}
|
||||
)
|
||||
).overrideAttrs (
|
||||
old: {
|
||||
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||
pkgs.meson
|
||||
pkgs.ninja
|
||||
pkgs.pkgconfig
|
||||
];
|
||||
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
pkgs.cairo
|
||||
pkgs.xlibsWrapper
|
||||
];
|
||||
|
||||
mesonFlags = [ "-Dpython=${if self.isPy3k then "python3" else "python"}" ];
|
||||
}
|
||||
)
|
||||
) super.pycairo;
|
||||
|
||||
pycocotools = super.pycocotools.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.cython
|
||||
self.numpy
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
pygobject = super.pygobject.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
|
||||
buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ];
|
||||
}
|
||||
);
|
||||
|
||||
pyopenssl = super.pyopenssl.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.openssl ];
|
||||
}
|
||||
);
|
||||
|
||||
pytest = addSetupTools super.pytest;
|
||||
|
||||
pytest-mock = addSetupTools super.pytest-mock;
|
||||
|
||||
python-dateutil = addSetupTools super.python-dateutil;
|
||||
|
||||
python-prctl = super.python-prctl.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
self.setuptools_scm
|
||||
pkgs.libcap
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
scaleapi = super.scaleapi.overrideAttrs (
|
||||
old: {
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py --replace "install_requires = ['requests>=2.4.2', 'enum34']" "install_requires = ['requests>=2.4.2']" || true
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
scipy = super.scipy.overrideAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ];
|
||||
setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
|
||||
enableParallelBuilding = true;
|
||||
buildInputs = old.buildInputs ++ [ self.numpy.blas ];
|
||||
preConfigure = ''
|
||||
sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
|
||||
export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
|
||||
'';
|
||||
preBuild = ''
|
||||
ln -s ${self.numpy.cfg} site.cfg
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
shapely = super.shapely.overrideAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ];
|
||||
inherit (super.shapely) patches GEOS_LIBRARY_PATH;
|
||||
}
|
||||
);
|
||||
|
||||
six = addSetupTools super.six;
|
||||
|
||||
urwidtrees = super.urwidtrees.overrideAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
self.urwid
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
# TODO: Figure out getting rid of this hack
|
||||
wheel = (
|
||||
pkgs.python3.pkgs.override {
|
||||
python = self.python;
|
||||
}
|
||||
).wheel.overridePythonAttrs (
|
||||
_: {
|
||||
inherit (super.wheel) pname name version src;
|
||||
}
|
||||
);
|
||||
|
||||
zipp = addSetupTools super.zipp;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
{ lib, stdenv, python, isLinux ? stdenv.isLinux }:
|
||||
|
||||
let
|
||||
inherit (lib.strings) hasSuffix hasInfix splitString removeSuffix;
|
||||
|
||||
# The 'cpxy" as determined by `python.version`
|
||||
#
|
||||
# e.g "2.7.17" -> "cp27"
|
||||
# "3.5.9" -> "cp35"
|
||||
pythonTag =
|
||||
let
|
||||
ver = builtins.splitVersion python.version;
|
||||
major = builtins.elemAt ver 0;
|
||||
minor = builtins.elemAt ver 1;
|
||||
in
|
||||
"cp${major}${minor}";
|
||||
|
||||
abiTag = "${pythonTag}m";
|
||||
|
||||
#
|
||||
# Parses wheel file returning an attribute set
|
||||
#
|
||||
toWheelAttrs = str:
|
||||
let
|
||||
entries = splitString "-" str;
|
||||
p = removeSuffix ".whl" (builtins.elemAt entries 4);
|
||||
in
|
||||
{
|
||||
pkgName = builtins.elemAt entries 0;
|
||||
pkgVer = builtins.elemAt entries 1;
|
||||
pyVer = builtins.elemAt entries 2;
|
||||
abi = builtins.elemAt entries 3;
|
||||
platform = p;
|
||||
};
|
||||
|
||||
#
|
||||
# Builds list of acceptable osx wheel files
|
||||
#
|
||||
# <versions> accepted versions in descending order of preference
|
||||
# <candidates> list of wheel files to select from
|
||||
findBestMatches = versions: candidates:
|
||||
let
|
||||
v = lib.lists.head versions;
|
||||
vs = lib.lists.tail versions;
|
||||
in
|
||||
if (builtins.length versions == 0)
|
||||
then []
|
||||
else (builtins.filter (x: hasInfix v x.file) candidates) ++ (findBestMatches vs candidates);
|
||||
|
||||
# pyver = "cpXX"
|
||||
# x = "cpXX" | "py2" | "py3" | "py2.py3"
|
||||
isPyVersionCompatible = pyver: x:
|
||||
let
|
||||
normalize = y: ''cp${lib.strings.removePrefix "cp" (lib.strings.removePrefix "py" y)}'';
|
||||
isCompat = p: x: lib.strings.hasPrefix (normalize x) p;
|
||||
in
|
||||
lib.lists.any (isCompat pyver) (lib.strings.splitString "." x);
|
||||
|
||||
#
|
||||
# Selects the best matching wheel file from a list of files
|
||||
#
|
||||
selectWheel = files:
|
||||
let
|
||||
filesWithoutSources = (builtins.filter (x: hasSuffix ".whl" x.file) files);
|
||||
|
||||
isPyAbiCompatible = pyabi: x: x == "none" || pyabi == x;
|
||||
|
||||
withPython = ver: abi: x: (isPyVersionCompatible ver x.pyVer) && (isPyAbiCompatible abi x.abi);
|
||||
|
||||
withPlatform = if isLinux
|
||||
then (
|
||||
x: x.platform == "manylinux1_${stdenv.platform.kernelArch}"
|
||||
|| x.platform == "manylinux2010_${stdenv.platform.kernelArch}"
|
||||
|| x.platform == "manylinux2014_${stdenv.platform.kernelArch}"
|
||||
|| x.platform == "any"
|
||||
)
|
||||
else (x: hasInfix "macosx" x.platform || x.platform == "any");
|
||||
|
||||
filterWheel = x:
|
||||
let
|
||||
f = toWheelAttrs x.file;
|
||||
in
|
||||
(withPython pythonTag abiTag f) && (withPlatform f);
|
||||
|
||||
filtered = builtins.filter filterWheel filesWithoutSources;
|
||||
|
||||
choose = files:
|
||||
let
|
||||
osxMatches = [ "10_12" "10_11" "10_10" "10_9" "any" ];
|
||||
linuxMatches = [ "manylinux1_" "manylinux2010_" "manylinux2014_" "any" ];
|
||||
chooseLinux = x: lib.singleton (builtins.head (findBestMatches linuxMatches x));
|
||||
chooseOSX = x: lib.singleton (builtins.head (findBestMatches osxMatches x));
|
||||
in
|
||||
if isLinux
|
||||
then chooseLinux files
|
||||
else chooseOSX files;
|
||||
|
||||
in
|
||||
if (builtins.length filtered == 0)
|
||||
then []
|
||||
else choose (filtered);
|
||||
|
||||
in
|
||||
{
|
||||
inherit selectWheel toWheelAttrs isPyVersionCompatible;
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
{ lib, stdenv }: python:
|
||||
|
||||
let
|
||||
|
||||
# Like builtins.substring but with stop being offset instead of length
|
||||
substr = start: stop: s: builtins.substring start (stop - start) s;
|
||||
|
||||
# Strip leading/trailing whitespace from string
|
||||
stripStr = s: lib.elemAt (builtins.split "^ *" (lib.elemAt (builtins.split " *$" s) 0)) 2;
|
||||
|
||||
findSubExpressionsFun = acc: c: (
|
||||
if c == "(" then (
|
||||
let
|
||||
posNew = acc.pos + 1;
|
||||
isOpen = acc.openP == 0;
|
||||
startPos = if isOpen then posNew else acc.startPos;
|
||||
in
|
||||
acc // {
|
||||
inherit startPos;
|
||||
exprs = acc.exprs ++ [ (substr acc.exprPos (acc.pos - 1) acc.expr) ];
|
||||
pos = posNew;
|
||||
openP = acc.openP + 1;
|
||||
}
|
||||
) else if c == ")" then (
|
||||
let
|
||||
openP = acc.openP - 1;
|
||||
exprs = findSubExpressions (substr acc.startPos acc.pos acc.expr);
|
||||
in
|
||||
acc // {
|
||||
inherit openP;
|
||||
pos = acc.pos + 1;
|
||||
exprs = if openP == 0 then acc.exprs ++ [ exprs ] else acc.exprs;
|
||||
exprPos = if openP == 0 then acc.pos + 1 else acc.exprPos;
|
||||
}
|
||||
) else acc // { pos = acc.pos + 1; }
|
||||
);
|
||||
|
||||
# Make a tree out of expression groups (parens)
|
||||
findSubExpressions = expr: let
|
||||
acc = builtins.foldl' findSubExpressionsFun {
|
||||
exprs = [];
|
||||
expr = expr;
|
||||
pos = 0;
|
||||
openP = 0;
|
||||
exprPos = 0;
|
||||
startPos = 0;
|
||||
} (lib.stringToCharacters expr);
|
||||
tailExpr = (substr acc.exprPos acc.pos expr);
|
||||
tailExprs = if tailExpr != "" then [ tailExpr ] else [];
|
||||
in
|
||||
acc.exprs ++ tailExprs;
|
||||
|
||||
parseExpressions = exprs: let
|
||||
splitCond = (
|
||||
s: builtins.map
|
||||
(x: stripStr (if builtins.typeOf x == "list" then (builtins.elemAt x 0) else x))
|
||||
(builtins.split " (and|or) " (s + " "))
|
||||
);
|
||||
|
||||
mapfn = expr: (
|
||||
if (builtins.match "^ ?$" expr != null) then null # Filter empty
|
||||
else if (builtins.elem expr [ "and" "or" ]) then {
|
||||
type = "bool";
|
||||
value = expr;
|
||||
}
|
||||
else {
|
||||
type = "expr";
|
||||
value = expr;
|
||||
}
|
||||
);
|
||||
|
||||
parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr));
|
||||
|
||||
in
|
||||
builtins.foldl' (
|
||||
acc: v: acc ++ (
|
||||
if builtins.typeOf v == "string" then parse v else [ (parseExpressions v) ]
|
||||
)
|
||||
) [] exprs;
|
||||
|
||||
# Transform individual expressions to structured expressions
|
||||
# This function also performs variable substitution, replacing environment markers with their explicit values
|
||||
transformExpressions = exprs: let
|
||||
variables = {
|
||||
os_name = "posix"; # TODO: Check other platforms
|
||||
sys_platform = (
|
||||
if stdenv.isLinux then "linux"
|
||||
else if stdenv.isDarwin then "darwin"
|
||||
else throw "Unsupported platform"
|
||||
);
|
||||
platform_machine = stdenv.platform.kernelArch;
|
||||
platform_python_implementation = "CPython"; # Only CPython supported for now
|
||||
platform_release = ""; # Field not reproducible
|
||||
platform_system = (
|
||||
if stdenv.isLinux then "Linux"
|
||||
else if stdenv.isDarwin then "Darwin"
|
||||
else throw "Unsupported platform"
|
||||
);
|
||||
platform_version = ""; # Field not reproducible
|
||||
python_version = python.passthru.pythonVersion;
|
||||
python_full_version = python.version;
|
||||
implementation_name = "cpython"; # Only cpython supported for now
|
||||
implementation_version = python.version;
|
||||
extra = "";
|
||||
};
|
||||
|
||||
substituteVar = value: if builtins.hasAttr value variables then (builtins.toJSON variables."${value}") else value;
|
||||
|
||||
processVar = value: builtins.foldl' (acc: v: v acc) value [
|
||||
stripStr
|
||||
substituteVar
|
||||
];
|
||||
|
||||
in
|
||||
if builtins.typeOf exprs == "set" then (
|
||||
if exprs.type == "expr" then (
|
||||
let
|
||||
mVal = ''[a-zA-Z0-9\'"_\. ]+'';
|
||||
mOp = "in|[!=<>]+";
|
||||
e = stripStr exprs.value;
|
||||
m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e);
|
||||
in
|
||||
{
|
||||
type = "expr";
|
||||
value = {
|
||||
op = builtins.elemAt m 1;
|
||||
values = [
|
||||
(processVar (builtins.elemAt m 0))
|
||||
(processVar (builtins.elemAt m 2))
|
||||
];
|
||||
};
|
||||
}
|
||||
) else exprs
|
||||
) else builtins.map transformExpressions exprs;
|
||||
|
||||
# Recursively eval all expressions
|
||||
evalExpressions = exprs: let
|
||||
unmarshal = v: (
|
||||
# TODO: Handle single quoted values
|
||||
if v == "True" then true
|
||||
else if v == "False" then false
|
||||
else builtins.fromJSON v
|
||||
);
|
||||
hasElem = needle: haystack: builtins.elem needle (builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " haystack));
|
||||
# TODO: Implement all operators
|
||||
op = {
|
||||
"<=" = x: y: (unmarshal x) <= (unmarshal y);
|
||||
"<" = x: y: (unmarshal x) < (unmarshal y);
|
||||
"!=" = x: y: x != y;
|
||||
"==" = x: y: x == y;
|
||||
">=" = x: y: (unmarshal x) >= (unmarshal y);
|
||||
">" = x: y: (unmarshal x) > (unmarshal y);
|
||||
"~=" = null;
|
||||
"===" = null;
|
||||
"in" = x: y: let
|
||||
values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y));
|
||||
in
|
||||
builtins.elem (unmarshal x) values;
|
||||
};
|
||||
in
|
||||
if builtins.typeOf exprs == "set" then (
|
||||
if exprs.type == "expr" then (
|
||||
let
|
||||
expr = exprs;
|
||||
result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1);
|
||||
in
|
||||
{
|
||||
type = "value";
|
||||
value = result;
|
||||
}
|
||||
) else exprs
|
||||
) else builtins.map evalExpressions exprs;
|
||||
|
||||
# Now that we have performed an eval all that's left to do is to concat the graph into a single bool
|
||||
reduceExpressions = exprs: let
|
||||
cond = {
|
||||
"and" = x: y: x && y;
|
||||
"or" = x: y: x || y;
|
||||
};
|
||||
reduceExpressionsFun = acc: v: (
|
||||
if builtins.typeOf v == "set" then (
|
||||
if v.type == "value" then (
|
||||
acc // {
|
||||
value = cond."${acc.cond}" acc.value v.value;
|
||||
}
|
||||
) else if v.type == "bool" then (
|
||||
acc // {
|
||||
cond = v.value;
|
||||
}
|
||||
) else throw "Unsupported type"
|
||||
) else if builtins.typeOf v == "list" then (
|
||||
let
|
||||
ret = builtins.foldl' reduceExpressionsFun {
|
||||
value = true;
|
||||
cond = "and";
|
||||
} v;
|
||||
in
|
||||
acc // {
|
||||
value = cond."${acc.cond}" acc.value ret.value;
|
||||
}
|
||||
) else throw "Unsupported type"
|
||||
);
|
||||
in
|
||||
(
|
||||
builtins.foldl' reduceExpressionsFun {
|
||||
value = true;
|
||||
cond = "and";
|
||||
} exprs
|
||||
).value;
|
||||
|
||||
in
|
||||
e: builtins.foldl' (acc: v: v acc) e [
|
||||
findSubExpressions
|
||||
parseExpressions
|
||||
transformExpressions
|
||||
evalExpressions
|
||||
reduceExpressions
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python
|
||||
# Patch out path dependencies from a pyproject.json file
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
data = json.load(sys.stdin)
|
||||
|
||||
for dep in data['tool']['poetry']['dependencies'].values():
|
||||
if isinstance(dep, dict):
|
||||
try:
|
||||
del dep['path'];
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
dep['version'] = '*'
|
||||
|
||||
json.dump(data, sys.stdout, indent=4)
|
|
@ -0,0 +1,80 @@
|
|||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (builtins) elemAt match;
|
||||
|
||||
# Replace a list entry at defined index with set value
|
||||
ireplace = idx: value: list: let
|
||||
inherit (builtins) genList length;
|
||||
in
|
||||
genList (i: if i == idx then value else (elemAt list i)) (length list);
|
||||
|
||||
operators = let
|
||||
matchWildCard = s: match "([^\*])(\.[\*])" s;
|
||||
mkComparison = ret: version: v: builtins.compareVersions version v == ret;
|
||||
mkIdxComparison = idx: version: v: let
|
||||
ver = builtins.splitVersion v;
|
||||
minor = builtins.toString (lib.toInt (elemAt ver idx) + 1);
|
||||
upper = builtins.concatStringsSep "." (ireplace idx minor ver);
|
||||
in
|
||||
operators.">=" version v && operators."<" version upper;
|
||||
dropWildcardPrecision = f: version: constraint: let
|
||||
m = matchWildCard constraint;
|
||||
hasWildcard = m != null;
|
||||
c = if hasWildcard then (elemAt m 0) else constraint;
|
||||
v =
|
||||
if hasWildcard then (builtins.substring 0 (builtins.stringLength c) version)
|
||||
else version;
|
||||
in
|
||||
f v c;
|
||||
in
|
||||
{
|
||||
# Prefix operators
|
||||
"==" = dropWildcardPrecision (mkComparison 0);
|
||||
">" = dropWildcardPrecision (mkComparison 1);
|
||||
"<" = dropWildcardPrecision (mkComparison (-1));
|
||||
"!=" = v: c: ! operators."==" v c;
|
||||
">=" = v: c: operators."==" v c || operators.">" v c;
|
||||
"<=" = v: c: operators."==" v c || operators."<" v c;
|
||||
# Semver specific operators
|
||||
"~" = mkIdxComparison 1; #
|
||||
"^" = mkIdxComparison 0;
|
||||
# Infix operators
|
||||
"-" = version: v: operators.">=" version v.vl && operators."<=" version v.vu;
|
||||
};
|
||||
|
||||
re = {
|
||||
operators = "([=><!~\^]+)";
|
||||
version = "([0-9\.\*x]+)";
|
||||
};
|
||||
|
||||
parseConstraint = constraint: let
|
||||
constraintStr = builtins.replaceStrings [ " " ] [ "" ] constraint;
|
||||
# The common prefix operators
|
||||
mPre = match "${re.operators} *${re.version}" constraintStr;
|
||||
# There is also an infix operator to match ranges
|
||||
mIn = match "${re.version} *(-) *${re.version}" constraintStr;
|
||||
in
|
||||
(
|
||||
if mPre != null then {
|
||||
op = elemAt mPre 0;
|
||||
v = elemAt mPre 1;
|
||||
}
|
||||
# Infix operators are range matches
|
||||
else if mIn != null then {
|
||||
op = elemAt mIn 1;
|
||||
v = {
|
||||
vl = (elemAt mIn 0);
|
||||
vu = (elemAt mIn 2);
|
||||
};
|
||||
}
|
||||
else throw "Constraint \"${constraintStr}\" could not be parsed"
|
||||
);
|
||||
|
||||
satisfiesSemver = version: constraint: let
|
||||
inherit (parseConstraint constraint) op v;
|
||||
in
|
||||
if constraint == "*" then true else operators."${op}" version v;
|
||||
|
||||
in
|
||||
{ inherit satisfiesSemver; }
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
pwd=$(pwd)
|
||||
workdir=$(mktemp -d)
|
||||
|
||||
function cleanup {
|
||||
cd "$pwd"
|
||||
rm -rf $workdir
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
cd "$workdir"
|
||||
|
||||
curl -L -s https://github.com/nix-community/poetry2nix/archive/master.tar.gz | tar -xz
|
||||
mv poetry2nix-master/* .
|
||||
|
||||
mkdir build
|
||||
cp *.nix *.json *.py build/
|
||||
cp -r bin build/
|
||||
rm build/shell.nix build/generate.py build/overlay.nix build/flake.nix
|
||||
|
||||
cat > build/README.md << EOF
|
||||
Dont change these files here, they are maintained at https://github.com/nix-community/poetry2nix
|
||||
|
||||
The update procedure is as-follows:
|
||||
1. Send your change to the upstream poetry2nix repository
|
||||
2. Get it approved with tests passing
|
||||
3. Run the update script in pkgs/development/tools/poetry2nix
|
||||
EOF
|
||||
|
||||
rm -rf "$pwd/poetry2nix"
|
||||
mv build "$pwd/poetry2nix"
|
|
@ -1,16 +1,19 @@
|
|||
{ stdenv, fetchFromGitHub, cmake, SDL2, SDL2_mixer, SDL2_ttf, libsodium, pkg-config }:
|
||||
stdenv.mkDerivation rec {
|
||||
version = "0.5.0";
|
||||
version = "1.0.0";
|
||||
pname = "devilutionx";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "diasurgical";
|
||||
repo = "devilutionX";
|
||||
rev = version;
|
||||
sha256 = "010hxj129zmsynvizk89vm2y29dcxsfi585czh3f03wfr38rxa6b";
|
||||
sha256 = "0lx903gchda4bgr71469yn63rx5ya6xv9j1azx18nrv3sskrphn4";
|
||||
};
|
||||
|
||||
NIX_CFLAGS_COMPILE = "-I${SDL2_ttf}/include/SDL2";
|
||||
NIX_CFLAGS_COMPILE = [
|
||||
"-I${SDL2_ttf}/include/SDL2"
|
||||
''-DTTF_FONT_PATH="${placeholder "out"}/share/fonts/truetype/CharisSILB.ttf"''
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ pkg-config cmake ];
|
||||
buildInputs = [ libsodium SDL2 SDL2_mixer SDL2_ttf ];
|
||||
|
@ -22,8 +25,10 @@ stdenv.mkDerivation rec {
|
|||
mkdir -p $out/Applications
|
||||
mv devilutionx.app $out/Applications
|
||||
'' else ''
|
||||
mkdir -p $out/bin
|
||||
cp devilutionx $out/bin
|
||||
install -Dm755 -t $out/bin devilutionx
|
||||
install -Dt $out/share/fonts/truetype ../Packaging/resources/CharisSILB.ttf
|
||||
|
||||
# TODO: icons and .desktop (see Packages/{debian,fedora}/*)
|
||||
'') + ''
|
||||
|
||||
runHook postInstall
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "hyperrogue";
|
||||
version = "10.5e";
|
||||
version = "11.2d";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zenorogue";
|
||||
repo = "hyperrogue";
|
||||
rev = "v${version}";
|
||||
sha256 = "1sjr26if3xv8xv52app1hkxs0bbgbviagydm4mdwbxjpd6v3d1aa";
|
||||
rev = stdenv.lib.strings.stringAsChars (x: if x == "." then "" else x) "v${version}";
|
||||
sha256 = "0aj4xy5xjdj32l5mk8796ldh9d7h8rx35kgc1vr7acb4fhpppb0f";
|
||||
};
|
||||
|
||||
CPPFLAGS = "-I${SDL.dev}/include/SDL";
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
python3.pkgs.buildPythonApplication rec {
|
||||
pname = "homeassistant-cli";
|
||||
version = "0.7.0";
|
||||
version = "0.8.0";
|
||||
|
||||
src = python3.pkgs.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "a38d4669201ac2afa71b6578a220bf4d6d59131263b278d51ebd1479677f6baf";
|
||||
sha256 = "0qq42b2a0rlrzaxwf3zqks5gzgv0hf4pz4yjjl6ldnizw8fcj40n";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
From f6a978f024d01202f954483423af1b2d5d5159a6 Mon Sep 17 00:00:00 2001
|
||||
From: Yegor Timoshenko <yegortimoshenko@riseup.net>
|
||||
Date: Fri, 28 Sep 2018 03:27:04 +0000
|
||||
Subject: [PATCH] If root is in Nix store, set ETag to its path hash
|
||||
|
||||
---
|
||||
src/http/ngx_http_core_module.c | 56 +++++++++++++++++++++++++++++----
|
||||
1 file changed, 50 insertions(+), 6 deletions(-)
|
||||
This patch makes it possible to serve static content from Nix store paths, by
|
||||
using the hash of the store path for the ETag header.
|
||||
|
||||
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
|
||||
index c57ec00c..b7992de2 100644
|
||||
index cb49ef74..f88dc77c 100644
|
||||
--- a/src/http/ngx_http_core_module.c
|
||||
+++ b/src/http/ngx_http_core_module.c
|
||||
@@ -1583,6 +1583,7 @@ ngx_http_set_etag(ngx_http_request_t *r)
|
||||
|
@ -19,7 +13,7 @@ index c57ec00c..b7992de2 100644
|
|||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
@@ -1598,16 +1599,61 @@ ngx_http_set_etag(ngx_http_request_t *r)
|
||||
@@ -1598,16 +1599,62 @@ ngx_http_set_etag(ngx_http_request_t *r)
|
||||
etag->hash = 1;
|
||||
ngx_str_set(&etag->key, "ETag");
|
||||
|
||||
|
@ -68,6 +62,7 @@ index c57ec00c..b7992de2 100644
|
|||
+ }
|
||||
+
|
||||
+ ngx_memcpy(etag->value.data, ptr1, etag->value.len);
|
||||
+ ngx_http_clear_last_modified(r);
|
||||
+ } else {
|
||||
+ etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
|
||||
+
|
||||
|
@ -87,6 +82,3 @@ index c57ec00c..b7992de2 100644
|
|||
|
||||
r->headers_out.etag = etag;
|
||||
|
||||
--
|
||||
2.19.0
|
||||
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
{ stdenv, rustPlatform, fetchFromGitHub, Security }:
|
||||
{ stdenv, rustPlatform, fetchFromGitHub, Security, openssl, pkg-config }:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "cargo-release";
|
||||
version = "0.12.4";
|
||||
version = "0.13.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "sunng87";
|
||||
repo = "cargo-release";
|
||||
rev = "v${version}";
|
||||
sha256 = "02rx25dd3klprwr1qmn5vn4vz4244amk2ky4nqfmi4vq3ygrhd1c";
|
||||
sha256 = "1w9w43i5br94vg5m4idabh67p4ffsx2lmc2g0ak2k961vl46wr0q";
|
||||
};
|
||||
|
||||
cargoSha256 = "18nbmq8j58jlka1lsrx2y0bhb9l5f3wyvcr1zmmda3hvc3vm7kla";
|
||||
cargoSha256 = "075fvvd4c8f3kz6i6ny835h6jpa3c1v3miwfwwrdyy49a85lzjyj";
|
||||
|
||||
buildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = ''Cargo subcommand "release": everything about releasing a rust crate'';
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "spectre-meltdown-checker";
|
||||
version = "0.42";
|
||||
version = "0.43";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "speed47";
|
||||
repo = "spectre-meltdown-checker";
|
||||
rev = "v${version}";
|
||||
sha256 = "0pppf844i7b72hqnmfvq72w5y7b6dxd16y29l6j84maf22zxbjni";
|
||||
sha256 = "1ys5m1yvm26qjlsjpqqd33lwpb880p0ay289hmifxjjawkqddjgg";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
|
|
|
@ -8688,6 +8688,7 @@ in
|
|||
|
||||
cargo-flamegraph = callPackage ../development/tools/cargo-flamegraph {
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
inherit (linuxPackages) perf;
|
||||
};
|
||||
|
||||
carnix = (callPackage ../build-support/rust/carnix.nix { }).carnix { };
|
||||
|
@ -9305,7 +9306,14 @@ in
|
|||
svg2tikz = python27Packages.svg2tikz;
|
||||
|
||||
pew = callPackage ../development/tools/pew {};
|
||||
poetry = with python3Packages; toPythonApplication poetry;
|
||||
|
||||
poetry = callPackage ../development/tools/poetry {
|
||||
python = python3;
|
||||
};
|
||||
poetry2nix = callPackage ../development/tools/poetry2nix/poetry2nix {
|
||||
inherit pkgs lib;
|
||||
};
|
||||
|
||||
pipenv = callPackage ../development/tools/pipenv {};
|
||||
|
||||
pipewire = callPackage ../development/libraries/pipewire {};
|
||||
|
@ -13224,6 +13232,8 @@ in
|
|||
|
||||
microsoft_gsl = callPackage ../development/libraries/microsoft_gsl { };
|
||||
|
||||
micronucleus = callPackage ../development/tools/misc/micronucleus { };
|
||||
|
||||
mimalloc = callPackage ../development/libraries/mimalloc { };
|
||||
|
||||
minizip = callPackage ../development/libraries/minizip { };
|
||||
|
|
Loading…
Reference in New Issue