From 7cc62144b2946796568e0125d1b56839c0b49226 Mon Sep 17 00:00:00 2001 From: John Q Crosscompiler Date: Thu, 26 Jul 2018 09:33:36 -0400 Subject: [PATCH 1/7] systems: Allow detection of powerpc and sparc --- lib/systems/inspect.nix | 1 + lib/systems/parse.nix | 3 +++ pkgs/build-support/bintools-wrapper/default.nix | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index c0c283469fe9..0c70f2a7cd5f 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -16,6 +16,7 @@ rec { isAarch64 = { cpu = { family = "arm"; bits = 64; }; }; isMips = { cpu = { family = "mips"; }; }; isRiscV = { cpu = { family = "riscv"; }; }; + isSparc = { cpu = { family = "sparc"; }; }; isWasm = { cpu = { family = "wasm"; }; }; is32bit = { cpu = { bits = 32; }; }; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index d79947ad3dea..47841a9eba5c 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -93,6 +93,9 @@ rec { riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; }; riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; }; + sparc = { bits = 32; significantByte = bigEndian; family = "sparc"; }; + sparc64 = { bits = 64; significantByte = bigEndian; family = "sparc"; }; + wasm32 = { bits = 32; significantByte = littleEndian; family = "wasm"; }; wasm64 = { bits = 64; significantByte = littleEndian; family = "wasm"; }; }; diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 2739537c25dc..91f9e7c71e35 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -185,6 +185,8 @@ stdenv.mkDerivation { "mips64" = "btsmip"; "mips64el" = "ltsmip"; }.${targetPlatform.parsed.cpu.name} + else if targetPlatform.isPowerPC then "powerpc" + else if targetPlatform.isSparc then "sparc" else throw "unknown emulation for platform: " + targetPlatform.config; in targetPlatform.platform.bfdEmulation or (fmt + sep + arch); From a01a52a2d7e116e059d43d7803be313fb1a825ad Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 26 Jul 2018 15:43:59 +0200 Subject: [PATCH 2/7] eclipse-plugin-spotbugs: 3.1.5 -> 3.1.6 --- pkgs/applications/editors/eclipse/plugins.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/editors/eclipse/plugins.nix b/pkgs/applications/editors/eclipse/plugins.nix index 8b03d93d1838..84371d152493 100644 --- a/pkgs/applications/editors/eclipse/plugins.nix +++ b/pkgs/applications/editors/eclipse/plugins.nix @@ -555,12 +555,12 @@ rec { spotbugs = buildEclipseUpdateSite rec { name = "spotbugs-${version}"; - version = "3.1.5"; + version = "3.1.6"; src = fetchzip { stripRoot = false; url = "https://github.com/spotbugs/spotbugs/releases/download/${version}/eclipsePlugin.zip"; - sha256 = "0fxdirz6ik9rqykm2lcr720apsaqgngr4c7q793rjb9b3bn30c85"; + sha256 = "1qsams12n64slp00nfc9v943sy9bzffzm7anqqaz2hjw64iia7fh"; }; meta = with stdenv.lib; { From 886871538c15681575925a990a3f1b68ed9d5477 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 26 Jul 2018 12:04:16 -0400 Subject: [PATCH 3/7] pythonPackages.rfc7464: Init at 17.7.0 --- .../python-modules/rfc7464/default.nix | 19 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/development/python-modules/rfc7464/default.nix diff --git a/pkgs/development/python-modules/rfc7464/default.nix b/pkgs/development/python-modules/rfc7464/default.nix new file mode 100644 index 000000000000..60a5308d718a --- /dev/null +++ b/pkgs/development/python-modules/rfc7464/default.nix @@ -0,0 +1,19 @@ +{ buildPythonPackage, fetchPypi, lib }: + +buildPythonPackage rec { + pname = "rfc7464"; + version = "17.7.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "1hcn6h38qplfcmq392cs58r01k16k202bqyap4br02376pr4ik7a"; + extension = "zip"; + }; + + meta = with lib; { + homepage = https://github.com/moshez/rfc7464; + description = "RFC 7464 is a proposed standard for streaming JSON documents."; + license = [ licenses.mit ]; + maintainers = with maintainers; [ shlevy ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 176bcae5a942..c85af34cb12a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17923,6 +17923,8 @@ EOF z3 = (toPythonModule (pkgs.z3.override { inherit python; })).python; + + rfc7464 = callPackage ../development/python-modules/rfc7464 { }; }); in fix' (extends overrides packages) From cfbe0ef315af7bd6a015923611a8abb0c8df703b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 26 Jul 2018 19:50:42 +0200 Subject: [PATCH 4/7] gem-config: add zookeeper (#44100) --- pkgs/development/ruby-modules/gem-config/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index 3c355d085760..c79a586e5f3b 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -395,4 +395,8 @@ in ''; }; + zookeeper = attrs: { + buildInputs = stdenv.lib.optionals stdenv.isDarwin [ darwin.cctools ]; + }; + } From 1f47fe8442be601109bc9ccd108e92f15c3c7d9a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 26 Jul 2018 19:51:17 +0200 Subject: [PATCH 5/7] gem-config: add libxml2-ruby (#44099) --- pkgs/development/ruby-modules/gem-config/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index c79a586e5f3b..9d4f5679e26e 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -206,6 +206,13 @@ in buildFlags = [ "--with-system-v8=true" ]; }; + libxml-ruby = attrs: { + buildFlags = [ + "--with-xml2-lib=${libxml2.out}/lib" + "--with-xml2-include=${libxml2.dev}/include/libxml2" + ]; + }; + msgpack = attrs: { buildInputs = [ libmsgpack ]; }; From af108429408b1b220fab4048ff44d674f52fdee6 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Thu, 26 Jul 2018 00:03:51 +0200 Subject: [PATCH 6/7] lib/trivial: unify & improve docstrings - add section headers - unify comment syntax - add examples Tested with: nix-instantiate --strict --eval ./lib/tests/misc.nix --- lib/trivial.nix | 84 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/lib/trivial.nix b/lib/trivial.nix index fac0718a9e73..a36056253d79 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -38,6 +38,8 @@ let in rec { + ## Simple (higher order) functions + /* The identity function For when you need a function that does “nothing”. @@ -59,7 +61,7 @@ rec { ## Named versions corresponding to some builtin operators. - /* Concat two strings */ + /* Concatenate two lists */ concat = x: y: x ++ y; /* boolean “or” */ @@ -93,10 +95,22 @@ rec { */ mergeAttrs = x: y: x // y; - # Flip the order of the arguments of a binary function. + /* Flip the order of the arguments of a binary function. + + Example: + flip concat [1] [2] + => [ 2 1 ] + */ flip = f: a: b: f b a; - # Apply function if argument is non-null + /* Apply function if argument is non-null. + + Example: + mapNullable (x: x+1) null + => null + mapNullable (x: x+1) 22 + => 23 + */ mapNullable = f: a: if isNull a then a else f a; # Pull in some builtins not included elsewhere. @@ -105,20 +119,30 @@ rec { isInt isFloat add sub lessThan seq deepSeq genericClosure; - inherit (lib.strings) fileContents; - release = fileContents ../.version; - versionSuffix = let suffixFile = ../.version-suffix; in - if pathExists suffixFile then fileContents suffixFile else "pre-git"; + ## nixpks version strings - # Return the Nixpkgs version number. + # The current full nixpkgs version number. version = release + versionSuffix; + # The current nixpkgs version number as string. + release = lib.strings.fileContents ../.version; + + # The current nixpkgs version suffix as string. + versionSuffix = + let suffixFile = ../.version-suffix; + in if pathExists suffixFile + then lib.strings.fileContents suffixFile + else "pre-git"; + nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version; # Whether we're being called by nix-shell. inNixShell = builtins.getEnv "IN_NIX_SHELL" != ""; + + ## Integer operations + # Return minimum/maximum of two numbers. min = x: y: if x < y then x else y; max = x: y: if x > y then x else y; @@ -133,6 +157,9 @@ rec { */ mod = base: int: base - (int * (builtins.div base int)); + + ## Comparisons + /* C-style comparisons a < b, compare a b => -1 @@ -162,17 +189,20 @@ rec { cmp "fooa" "a" => -1 # while compare "fooa" "a" => 1 - */ splitByAndCompare = p: yes: no: a: b: if p a then if p b then yes a b else -1 else if p b then 1 else no a b; + /* Reads a JSON file. */ importJSON = path: builtins.fromJSON (builtins.readFile path); + + ## Warnings and asserts + /* See https://github.com/NixOS/nix/issues/749. Eventually we'd like these to expand to Nix builtins that carry metadata so that Nix can filter out the INFO messages without parsing the message string. @@ -188,28 +218,36 @@ rec { warn = msg: builtins.trace "WARNING: ${msg}"; info = msg: builtins.trace "INFO: ${msg}"; - # | Add metadata about expected function arguments to a function. - # The metadata should match the format given by - # builtins.functionArgs, i.e. a set from expected argument to a bool - # representing whether that argument has a default or not. - # setFunctionArgs : (a → b) → Map String Bool → (a → b) - # - # This function is necessary because you can't dynamically create a - # function of the { a, b ? foo, ... }: format, but some facilities - # like callPackage expect to be able to query expected arguments. + + ## Function annotations + + /* Add metadata about expected function arguments to a function. + The metadata should match the format given by + builtins.functionArgs, i.e. a set from expected argument to a bool + representing whether that argument has a default or not. + setFunctionArgs : (a → b) → Map String Bool → (a → b) + + This function is necessary because you can't dynamically create a + function of the { a, b ? foo, ... }: format, but some facilities + like callPackage expect to be able to query expected arguments. + */ setFunctionArgs = f: args: { # TODO: Should we add call-time "type" checking like built in? __functor = self: f; __functionArgs = args; }; - # | Extract the expected function arguments from a function. - # This works both with nix-native { a, b ? foo, ... }: style - # functions and functions with args set with 'setFunctionArgs'. It - # has the same return type and semantics as builtins.functionArgs. - # setFunctionArgs : (a → b) → Map String Bool. + /* Extract the expected function arguments from a function. + This works both with nix-native { a, b ? foo, ... }: style + functions and functions with args set with 'setFunctionArgs'. It + has the same return type and semantics as builtins.functionArgs. + setFunctionArgs : (a → b) → Map String Bool. + */ functionArgs = f: f.__functionArgs or (builtins.functionArgs f); + /* Check whether something is a function or something + annotated with function args. + */ isFunction = f: builtins.isFunction f || (f ? __functor && isFunction (f.__functor f)); } From 62dca7c9ab08ee5cc2043d6d374013b8041a3f21 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Thu, 26 Jul 2018 00:10:53 +0200 Subject: [PATCH 7/7] lib/trivial: move zipIntBits to its own file The amount of implementation detail really should not be the first thing in a prominent file called `trivial.nix`. --- lib/trivial.nix | 48 +++++++++----------------------------------- lib/zip-int-bits.nix | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 lib/zip-int-bits.nix diff --git a/lib/trivial.nix b/lib/trivial.nix index a36056253d79..b75e81eb7352 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -1,41 +1,5 @@ { lib }: -let - zipIntBits = f: x: y: - let - # (intToBits 6) -> [ 0 1 1 ] - intToBits = x: - if x == 0 || x == -1 then - [] - else - let - headbit = if (x / 2) * 2 != x then 1 else 0; # x & 1 - tailbits = if x < 0 then ((x + 1) / 2) - 1 else x / 2; # x >> 1 - in - [headbit] ++ (intToBits tailbits); - # (bitsToInt [ 0 1 1 ] 0) -> 6 - # (bitsToInt [ 0 1 0 ] 1) -> -6 - bitsToInt = l: signum: - if l == [] then - (if signum == 0 then 0 else -1) - else - (builtins.head l) + (2 * (bitsToInt (builtins.tail l) signum)); - - xsignum = if x < 0 then 1 else 0; - ysignum = if y < 0 then 1 else 0; - zipListsWith' = fst: snd: - if fst==[] && snd==[] then - [] - else if fst==[] then - [(f xsignum (builtins.head snd))] ++ (zipListsWith' [] (builtins.tail snd)) - else if snd==[] then - [(f (builtins.head fst) ysignum )] ++ (zipListsWith' (builtins.tail fst) [] ) - else - [(f (builtins.head fst) (builtins.head snd))] ++ (zipListsWith' (builtins.tail fst) (builtins.tail snd)); - in - assert (builtins.isInt x) && (builtins.isInt y); - bitsToInt (zipListsWith' (intToBits x) (intToBits y)) (f xsignum ysignum); -in rec { ## Simple (higher order) functions @@ -71,13 +35,19 @@ rec { and = x: y: x && y; /* bitwise “and” */ - bitAnd = builtins.bitAnd or zipIntBits (a: b: if a==1 && b==1 then 1 else 0); + bitAnd = builtins.bitAnd + or import ./zip-int-bits.nix + (a: b: if a==1 && b==1 then 1 else 0); /* bitwise “or” */ - bitOr = builtins.bitOr or zipIntBits (a: b: if a==1 || b==1 then 1 else 0); + bitOr = builtins.bitOr + or import ./zip-int-bits.nix + (a: b: if a==1 || b==1 then 1 else 0); /* bitwise “xor” */ - bitXor = builtins.bitXor or zipIntBits (a: b: if a!=b then 1 else 0); + bitXor = builtins.bitXor + or import ./zip-int-bits.nix + (a: b: if a!=b then 1 else 0); /* bitwise “not” */ bitNot = builtins.sub (-1); diff --git a/lib/zip-int-bits.nix b/lib/zip-int-bits.nix new file mode 100644 index 000000000000..edbcdfe1e682 --- /dev/null +++ b/lib/zip-int-bits.nix @@ -0,0 +1,39 @@ +/* Helper function to implement a fallback for the bit operators + `bitAnd`, `bitOr` and `bitXOr` on older nix version. + See ./trivial.nix +*/ +f: x: y: + let + # (intToBits 6) -> [ 0 1 1 ] + intToBits = x: + if x == 0 || x == -1 then + [] + else + let + headbit = if (x / 2) * 2 != x then 1 else 0; # x & 1 + tailbits = if x < 0 then ((x + 1) / 2) - 1 else x / 2; # x >> 1 + in + [headbit] ++ (intToBits tailbits); + + # (bitsToInt [ 0 1 1 ] 0) -> 6 + # (bitsToInt [ 0 1 0 ] 1) -> -6 + bitsToInt = l: signum: + if l == [] then + (if signum == 0 then 0 else -1) + else + (builtins.head l) + (2 * (bitsToInt (builtins.tail l) signum)); + + xsignum = if x < 0 then 1 else 0; + ysignum = if y < 0 then 1 else 0; + zipListsWith' = fst: snd: + if fst==[] && snd==[] then + [] + else if fst==[] then + [(f xsignum (builtins.head snd))] ++ (zipListsWith' [] (builtins.tail snd)) + else if snd==[] then + [(f (builtins.head fst) ysignum )] ++ (zipListsWith' (builtins.tail fst) [] ) + else + [(f (builtins.head fst) (builtins.head snd))] ++ (zipListsWith' (builtins.tail fst) (builtins.tail snd)); + in + assert (builtins.isInt x) && (builtins.isInt y); + bitsToInt (zipListsWith' (intToBits x) (intToBits y)) (f xsignum ysignum)