poetry2nix: 1.6.0 -> 1.6.1
This commit is contained in:
parent
c669d2991b
commit
7401afc428
@ -2,10 +2,8 @@
|
|||||||
, lib ? pkgs.lib
|
, lib ? pkgs.lib
|
||||||
, version
|
, version
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs) python3;
|
inherit (pkgs) python3;
|
||||||
|
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
pname = "poetry2nix";
|
pname = "poetry2nix";
|
||||||
|
|||||||
@ -7,7 +7,7 @@ let
|
|||||||
inherit (poetryLib) isCompatible readTOML;
|
inherit (poetryLib) isCompatible readTOML;
|
||||||
|
|
||||||
# Poetry2nix version
|
# Poetry2nix version
|
||||||
version = "1.6.0";
|
version = "1.6.1";
|
||||||
|
|
||||||
/* The default list of poetry2nix override overlays */
|
/* The default list of poetry2nix override overlays */
|
||||||
defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; });
|
defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; });
|
||||||
@ -34,7 +34,8 @@ let
|
|||||||
, overrides ? [ defaultPoetryOverrides ]
|
, overrides ? [ defaultPoetryOverrides ]
|
||||||
, python ? pkgs.python3
|
, python ? pkgs.python3
|
||||||
, pwd ? projectDir
|
, pwd ? projectDir
|
||||||
}@attrs: let
|
}@attrs:
|
||||||
|
let
|
||||||
poetryPkg = poetry.override { inherit python; };
|
poetryPkg = poetry.override { inherit python; };
|
||||||
|
|
||||||
pyProject = readTOML pyproject;
|
pyProject = readTOML pyproject;
|
||||||
@ -44,6 +45,7 @@ let
|
|||||||
specialAttrs = [
|
specialAttrs = [
|
||||||
"overrides"
|
"overrides"
|
||||||
"poetrylock"
|
"poetrylock"
|
||||||
|
"projectDir"
|
||||||
"pwd"
|
"pwd"
|
||||||
];
|
];
|
||||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||||
@ -87,7 +89,8 @@ let
|
|||||||
overlays = builtins.map getFunctorFn (
|
overlays = builtins.map getFunctorFn (
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
self: super: let
|
self: super:
|
||||||
|
let
|
||||||
hooks = self.callPackage ./hooks {};
|
hooks = self.callPackage ./hooks {};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -153,7 +156,8 @@ let
|
|||||||
, python ? pkgs.python3
|
, python ? pkgs.python3
|
||||||
, pwd ? projectDir
|
, pwd ? projectDir
|
||||||
, ...
|
, ...
|
||||||
}@attrs: let
|
}@attrs:
|
||||||
|
let
|
||||||
poetryPython = mkPoetryPackages {
|
poetryPython = mkPoetryPackages {
|
||||||
inherit pyproject poetrylock overrides python pwd;
|
inherit pyproject poetrylock overrides python pwd;
|
||||||
};
|
};
|
||||||
@ -164,19 +168,22 @@ let
|
|||||||
specialAttrs = [
|
specialAttrs = [
|
||||||
"overrides"
|
"overrides"
|
||||||
"poetrylock"
|
"poetrylock"
|
||||||
|
"projectDir"
|
||||||
"pwd"
|
"pwd"
|
||||||
"pyproject"
|
"pyproject"
|
||||||
];
|
];
|
||||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||||
|
|
||||||
# Get dependencies and filter out depending on interpreter version
|
# Get dependencies and filter out depending on interpreter version
|
||||||
getDeps = depAttr: let
|
getDeps = depAttr:
|
||||||
|
let
|
||||||
compat = isCompatible py.pythonVersion;
|
compat = isCompatible py.pythonVersion;
|
||||||
deps = pyProject.tool.poetry.${depAttr} or {};
|
deps = pyProject.tool.poetry.${depAttr} or {};
|
||||||
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
||||||
in
|
in
|
||||||
builtins.map (
|
builtins.map (
|
||||||
dep: let
|
dep:
|
||||||
|
let
|
||||||
pkg = py.pkgs."${dep}";
|
pkg = py.pkgs."${dep}";
|
||||||
constraints = deps.${dep}.python or "";
|
constraints = deps.${dep}.python or "";
|
||||||
isCompat = compat constraints;
|
isCompat = compat constraints;
|
||||||
@ -191,7 +198,6 @@ let
|
|||||||
inherit pyProject;
|
inherit pyProject;
|
||||||
pythonPackages = py.pkgs;
|
pythonPackages = py.pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
py.pkgs.buildPythonApplication (
|
py.pkgs.buildPythonApplication (
|
||||||
passedAttrs // {
|
passedAttrs // {
|
||||||
@ -222,7 +228,6 @@ let
|
|||||||
|
|
||||||
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
|
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
|
||||||
cli = import ./cli.nix { inherit pkgs lib version; };
|
cli = import ./cli.nix { inherit pkgs lib version; };
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit mkPoetryEnv mkPoetryApplication mkPoetryPackages cli version;
|
inherit mkPoetryEnv mkPoetryApplication mkPoetryPackages cli version;
|
||||||
@ -236,7 +241,8 @@ in
|
|||||||
*/
|
*/
|
||||||
defaultPoetryOverrides = {
|
defaultPoetryOverrides = {
|
||||||
__functor = defaultPoetryOverrides;
|
__functor = defaultPoetryOverrides;
|
||||||
overrideOverlay = fn: self: super: let
|
overrideOverlay = fn: self: super:
|
||||||
|
let
|
||||||
defaultSet = defaultPoetryOverrides self super;
|
defaultSet = defaultPoetryOverrides self super;
|
||||||
customSet = fn self super;
|
customSet = fn self super;
|
||||||
in
|
in
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
, makeSetupHook
|
, makeSetupHook
|
||||||
, yj
|
, yj
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
pythonInterpreter = python.pythonForBuild.interpreter;
|
pythonInterpreter = python.pythonForBuild.interpreter;
|
||||||
in
|
in
|
||||||
|
|||||||
@ -9,7 +9,8 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Compare a semver expression with a version
|
# Compare a semver expression with a version
|
||||||
isCompatible = version: let
|
isCompatible = version:
|
||||||
|
let
|
||||||
operators = {
|
operators = {
|
||||||
"||" = cond1: cond2: cond1 || cond2;
|
"||" = cond1: cond2: cond1 || cond2;
|
||||||
"," = cond1: cond2: cond1 && cond2; # , means &&
|
"," = cond1: cond2: cond1 && cond2; # , means &&
|
||||||
@ -88,7 +89,8 @@ let
|
|||||||
getBuildSystemPkgs =
|
getBuildSystemPkgs =
|
||||||
{ pythonPackages
|
{ pythonPackages
|
||||||
, pyProject
|
, pyProject
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
buildSystem = lib.getAttrFromPath [ "build-system" "build-backend" ] pyProject;
|
buildSystem = lib.getAttrFromPath [ "build-system" "build-backend" ] pyProject;
|
||||||
drvAttr = builtins.elemAt (builtins.split "\\.|:" buildSystem) 0;
|
drvAttr = builtins.elemAt (builtins.split "\\.|:" buildSystem) 0;
|
||||||
in
|
in
|
||||||
@ -97,7 +99,8 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Find gitignore files recursively in parent directory stopping with .git
|
# Find gitignore files recursively in parent directory stopping with .git
|
||||||
findGitIgnores = path: let
|
findGitIgnores = path:
|
||||||
|
let
|
||||||
parent = path + "/..";
|
parent = path + "/..";
|
||||||
gitIgnore = path + "/.gitignore";
|
gitIgnore = path + "/.gitignore";
|
||||||
isGitRoot = builtins.pathExists (path + "/.git");
|
isGitRoot = builtins.pathExists (path + "/.git");
|
||||||
@ -113,7 +116,8 @@ let
|
|||||||
- Filters pycache/pyc files
|
- Filters pycache/pyc files
|
||||||
- Uses cleanSourceFilter to filter out .git/.hg, .o/.so, editor backup files & nix result symlinks
|
- Uses cleanSourceFilter to filter out .git/.hg, .o/.so, editor backup files & nix result symlinks
|
||||||
*/
|
*/
|
||||||
cleanPythonSources = { src }: let
|
cleanPythonSources = { src }:
|
||||||
|
let
|
||||||
gitIgnores = findGitIgnores src;
|
gitIgnores = findGitIgnores src;
|
||||||
pycacheFilter = name: type:
|
pycacheFilter = name: type:
|
||||||
(type == "directory" && ! lib.strings.hasInfix "__pycache__" name)
|
(type == "directory" && ! lib.strings.hasInfix "__pycache__" name)
|
||||||
@ -127,7 +131,6 @@ let
|
|||||||
inherit src;
|
inherit src;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit
|
inherit
|
||||||
|
|||||||
@ -22,9 +22,7 @@ pythonPackages.callPackage (
|
|||||||
{ preferWheel ? false
|
{ preferWheel ? false
|
||||||
, ...
|
, ...
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi;
|
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi;
|
||||||
|
|
||||||
inherit (import ./pep425.nix {
|
inherit (import ./pep425.nix {
|
||||||
@ -68,7 +66,6 @@ pythonPackages.callPackage (
|
|||||||
lockFileEntry = builtins.head entries;
|
lockFileEntry = builtins.head entries;
|
||||||
|
|
||||||
_isEgg = isEgg lockFileEntry;
|
_isEgg = isEgg lockFileEntry;
|
||||||
|
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
inherit (lockFileEntry) file hash;
|
inherit (lockFileEntry) file hash;
|
||||||
@ -92,7 +89,6 @@ pythonPackages.callPackage (
|
|||||||
baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm;
|
baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm;
|
||||||
|
|
||||||
format = if isLocal then "pyproject" else if isGit then "setuptools" else fileInfo.format;
|
format = if isLocal then "pyproject" else if isGit then "setuptools" else fileInfo.format;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
buildPythonPackage {
|
buildPythonPackage {
|
||||||
@ -123,7 +119,8 @@ pythonPackages.callPackage (
|
|||||||
compat = isCompatible python.pythonVersion;
|
compat = isCompatible python.pythonVersion;
|
||||||
deps = lib.filterAttrs (n: v: v) (
|
deps = lib.filterAttrs (n: v: v) (
|
||||||
lib.mapAttrs (
|
lib.mapAttrs (
|
||||||
n: v: let
|
n: v:
|
||||||
|
let
|
||||||
constraints = v.python or "";
|
constraints = v.python or "";
|
||||||
in
|
in
|
||||||
compat constraints
|
compat constraints
|
||||||
|
|||||||
@ -195,14 +195,14 @@ self: super:
|
|||||||
);
|
);
|
||||||
|
|
||||||
matplotlib = super.matplotlib.overrideAttrs (
|
matplotlib = super.matplotlib.overrideAttrs (
|
||||||
old: let
|
old:
|
||||||
|
let
|
||||||
enableGhostscript = old.passthru.enableGhostscript or false;
|
enableGhostscript = old.passthru.enableGhostscript or false;
|
||||||
enableGtk3 = old.passthru.enableTk or false;
|
enableGtk3 = old.passthru.enableTk or false;
|
||||||
enableQt = old.passthru.enableQt or false;
|
enableQt = old.passthru.enableQt or false;
|
||||||
enableTk = old.passthru.enableTk or false;
|
enableTk = old.passthru.enableTk or false;
|
||||||
|
|
||||||
inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa;
|
inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa;
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${pkgs.libcxx}/include/c++/v1";
|
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${pkgs.libcxx}/include/c++/v1";
|
||||||
@ -266,7 +266,8 @@ self: super:
|
|||||||
);
|
);
|
||||||
|
|
||||||
numpy = super.numpy.overrideAttrs (
|
numpy = super.numpy.overrideAttrs (
|
||||||
old: let
|
old:
|
||||||
|
let
|
||||||
blas = old.passthru.args.blas or pkgs.openblasCompat;
|
blas = old.passthru.args.blas or pkgs.openblasCompat;
|
||||||
blasImplementation = lib.nameFromURL blas.name "-";
|
blasImplementation = lib.nameFromURL blas.name "-";
|
||||||
cfg = pkgs.writeTextFile {
|
cfg = pkgs.writeTextFile {
|
||||||
@ -306,7 +307,8 @@ self: super:
|
|||||||
);
|
);
|
||||||
|
|
||||||
peewee = super.peewee.overridePythonAttrs (
|
peewee = super.peewee.overridePythonAttrs (
|
||||||
old: let
|
old:
|
||||||
|
let
|
||||||
withPostgres = old.passthru.withPostgres or false;
|
withPostgres = old.passthru.withPostgres or false;
|
||||||
withMysql = old.passthru.withMysql or false;
|
withMysql = old.passthru.withMysql or false;
|
||||||
in
|
in
|
||||||
@ -667,6 +669,7 @@ self: super:
|
|||||||
);
|
);
|
||||||
|
|
||||||
zipp =
|
zipp =
|
||||||
|
(
|
||||||
if lib.versionAtLeast super.zipp.version "2.0.0" then (
|
if lib.versionAtLeast super.zipp.version "2.0.0" then (
|
||||||
super.zipp.overridePythonAttrs (
|
super.zipp.overridePythonAttrs (
|
||||||
old: {
|
old: {
|
||||||
@ -677,6 +680,13 @@ self: super:
|
|||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) else super.zipp;
|
) else super.zipp
|
||||||
|
).overridePythonAttrs (
|
||||||
|
old: {
|
||||||
|
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||||
|
self.toml
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
{ lib, stdenv, python, isLinux ? stdenv.isLinux }:
|
{ lib, stdenv, python, isLinux ? stdenv.isLinux }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib.strings) hasSuffix hasInfix splitString removeSuffix;
|
inherit (lib.strings) hasSuffix hasInfix splitString removeSuffix;
|
||||||
|
|
||||||
@ -94,12 +93,10 @@ let
|
|||||||
if isLinux
|
if isLinux
|
||||||
then chooseLinux files
|
then chooseLinux files
|
||||||
else chooseOSX files;
|
else chooseOSX files;
|
||||||
|
|
||||||
in
|
in
|
||||||
if (builtins.length filtered == 0)
|
if (builtins.length filtered == 0)
|
||||||
then []
|
then []
|
||||||
else choose (filtered);
|
else choose (filtered);
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit selectWheel toWheelAttrs isPyVersionCompatible;
|
inherit selectWheel toWheelAttrs isPyVersionCompatible;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
{ lib, stdenv, poetryLib }: python:
|
{ lib, stdenv, poetryLib }: python:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (poetryLib) ireplace;
|
inherit (poetryLib) ireplace;
|
||||||
|
|
||||||
@ -37,7 +36,8 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Make a tree out of expression groups (parens)
|
# Make a tree out of expression groups (parens)
|
||||||
findSubExpressions = expr: let
|
findSubExpressions = expr:
|
||||||
|
let
|
||||||
acc = builtins.foldl' findSubExpressionsFun {
|
acc = builtins.foldl' findSubExpressionsFun {
|
||||||
exprs = [];
|
exprs = [];
|
||||||
expr = expr;
|
expr = expr;
|
||||||
@ -51,7 +51,8 @@ let
|
|||||||
in
|
in
|
||||||
acc.exprs ++ tailExprs;
|
acc.exprs ++ tailExprs;
|
||||||
|
|
||||||
parseExpressions = exprs: let
|
parseExpressions = exprs:
|
||||||
|
let
|
||||||
splitCond = (
|
splitCond = (
|
||||||
s: builtins.map
|
s: builtins.map
|
||||||
(x: stripStr (if builtins.typeOf x == "list" then (builtins.elemAt x 0) else x))
|
(x: stripStr (if builtins.typeOf x == "list" then (builtins.elemAt x 0) else x))
|
||||||
@ -71,7 +72,6 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr));
|
parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr));
|
||||||
|
|
||||||
in
|
in
|
||||||
builtins.foldl' (
|
builtins.foldl' (
|
||||||
acc: v: acc ++ (
|
acc: v: acc ++ (
|
||||||
@ -81,7 +81,8 @@ let
|
|||||||
|
|
||||||
# Transform individual expressions to structured expressions
|
# Transform individual expressions to structured expressions
|
||||||
# This function also performs variable substitution, replacing environment markers with their explicit values
|
# This function also performs variable substitution, replacing environment markers with their explicit values
|
||||||
transformExpressions = exprs: let
|
transformExpressions = exprs:
|
||||||
|
let
|
||||||
variables = {
|
variables = {
|
||||||
os_name = (
|
os_name = (
|
||||||
if python.pname == "jython" then "java"
|
if python.pname == "jython" then "java"
|
||||||
@ -121,7 +122,6 @@ let
|
|||||||
stripStr
|
stripStr
|
||||||
substituteVar
|
substituteVar
|
||||||
];
|
];
|
||||||
|
|
||||||
in
|
in
|
||||||
if builtins.typeOf exprs == "set" then (
|
if builtins.typeOf exprs == "set" then (
|
||||||
if exprs.type == "expr" then (
|
if exprs.type == "expr" then (
|
||||||
@ -145,7 +145,8 @@ let
|
|||||||
) else builtins.map transformExpressions exprs;
|
) else builtins.map transformExpressions exprs;
|
||||||
|
|
||||||
# Recursively eval all expressions
|
# Recursively eval all expressions
|
||||||
evalExpressions = exprs: let
|
evalExpressions = exprs:
|
||||||
|
let
|
||||||
unmarshal = v: (
|
unmarshal = v: (
|
||||||
# TODO: Handle single quoted values
|
# TODO: Handle single quoted values
|
||||||
if v == "True" then true
|
if v == "True" then true
|
||||||
@ -160,7 +161,8 @@ let
|
|||||||
"==" = x: y: x == y;
|
"==" = x: y: x == y;
|
||||||
">=" = x: y: (unmarshal x) >= (unmarshal y);
|
">=" = x: y: (unmarshal x) >= (unmarshal y);
|
||||||
">" = x: y: (unmarshal x) > (unmarshal y);
|
">" = x: y: (unmarshal x) > (unmarshal y);
|
||||||
"~=" = v: c: let
|
"~=" = v: c:
|
||||||
|
let
|
||||||
parts = builtins.splitVersion c;
|
parts = builtins.splitVersion c;
|
||||||
pruned = lib.take ((builtins.length parts) - 1) parts;
|
pruned = lib.take ((builtins.length parts) - 1) parts;
|
||||||
upper = builtins.toString (
|
upper = builtins.toString (
|
||||||
@ -170,7 +172,8 @@ let
|
|||||||
in
|
in
|
||||||
op.">=" v c && op."<" v upperConstraint;
|
op.">=" v c && op."<" v upperConstraint;
|
||||||
"===" = x: y: x == y;
|
"===" = x: y: x == y;
|
||||||
"in" = x: y: let
|
"in" = x: y:
|
||||||
|
let
|
||||||
values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y));
|
values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y));
|
||||||
in
|
in
|
||||||
builtins.elem (unmarshal x) values;
|
builtins.elem (unmarshal x) values;
|
||||||
@ -190,7 +193,8 @@ let
|
|||||||
) else builtins.map evalExpressions 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
|
# 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
|
reduceExpressions = exprs:
|
||||||
|
let
|
||||||
cond = {
|
cond = {
|
||||||
"and" = x: y: x && y;
|
"and" = x: y: x && y;
|
||||||
"or" = x: y: x || y;
|
"or" = x: y: x || y;
|
||||||
@ -225,7 +229,6 @@ let
|
|||||||
cond = "and";
|
cond = "and";
|
||||||
} exprs
|
} exprs
|
||||||
).value;
|
).value;
|
||||||
|
|
||||||
in
|
in
|
||||||
e: builtins.foldl' (acc: v: v acc) e [
|
e: builtins.foldl' (acc: v: v acc) e [
|
||||||
findSubExpressions
|
findSubExpressions
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
{ lib, ireplace }:
|
{ lib, ireplace }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (builtins) elemAt match;
|
inherit (builtins) elemAt match;
|
||||||
|
|
||||||
operators = let
|
operators = let
|
||||||
matchWildCard = s: match "([^\*])(\.[\*])" s;
|
matchWildCard = s: match "([^\*])(\.[\*])" s;
|
||||||
mkComparison = ret: version: v: builtins.compareVersions version v == ret;
|
mkComparison = ret: version: v: builtins.compareVersions version v == ret;
|
||||||
mkIdxComparison = idx: version: v: let
|
mkIdxComparison = idx: version: v:
|
||||||
|
let
|
||||||
ver = builtins.splitVersion v;
|
ver = builtins.splitVersion v;
|
||||||
minor = builtins.toString (lib.toInt (elemAt ver idx) + 1);
|
minor = builtins.toString (lib.toInt (elemAt ver idx) + 1);
|
||||||
upper = builtins.concatStringsSep "." (ireplace idx minor ver);
|
upper = builtins.concatStringsSep "." (ireplace idx minor ver);
|
||||||
in
|
in
|
||||||
operators.">=" version v && operators."<" version upper;
|
operators.">=" version v && operators."<" version upper;
|
||||||
dropWildcardPrecision = f: version: constraint: let
|
dropWildcardPrecision = f: version: constraint:
|
||||||
|
let
|
||||||
m = matchWildCard constraint;
|
m = matchWildCard constraint;
|
||||||
hasWildcard = m != null;
|
hasWildcard = m != null;
|
||||||
c = if hasWildcard then (elemAt m 0) else constraint;
|
c = if hasWildcard then (elemAt m 0) else constraint;
|
||||||
@ -33,7 +34,8 @@ let
|
|||||||
# Semver specific operators
|
# Semver specific operators
|
||||||
"~" = mkIdxComparison 1;
|
"~" = mkIdxComparison 1;
|
||||||
"^" = mkIdxComparison 0;
|
"^" = mkIdxComparison 0;
|
||||||
"~=" = v: c: let
|
"~=" = v: c:
|
||||||
|
let
|
||||||
# Prune constraint
|
# Prune constraint
|
||||||
parts = builtins.splitVersion c;
|
parts = builtins.splitVersion c;
|
||||||
pruned = lib.take ((builtins.length parts) - 1) parts;
|
pruned = lib.take ((builtins.length parts) - 1) parts;
|
||||||
@ -55,7 +57,8 @@ let
|
|||||||
version = "([0-9\.\*x]+)";
|
version = "([0-9\.\*x]+)";
|
||||||
};
|
};
|
||||||
|
|
||||||
parseConstraint = constraint: let
|
parseConstraint = constraint:
|
||||||
|
let
|
||||||
constraintStr = builtins.replaceStrings [ " " ] [ "" ] constraint;
|
constraintStr = builtins.replaceStrings [ " " ] [ "" ] constraint;
|
||||||
# The common prefix operators
|
# The common prefix operators
|
||||||
mPre = match "${re.operators} *${re.version}" constraintStr;
|
mPre = match "${re.operators} *${re.version}" constraintStr;
|
||||||
@ -78,10 +81,10 @@ let
|
|||||||
else throw "Constraint \"${constraintStr}\" could not be parsed"
|
else throw "Constraint \"${constraintStr}\" could not be parsed"
|
||||||
);
|
);
|
||||||
|
|
||||||
satisfiesSemver = version: constraint: let
|
satisfiesSemver = version: constraint:
|
||||||
|
let
|
||||||
inherit (parseConstraint constraint) op v;
|
inherit (parseConstraint constraint) op v;
|
||||||
in
|
in
|
||||||
if constraint == "*" then true else operators."${op}" version v;
|
if constraint == "*" then true else operators."${op}" version v;
|
||||||
|
|
||||||
in
|
in
|
||||||
{ inherit satisfiesSemver; }
|
{ inherit satisfiesSemver; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user