Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e5fd4684f468
Choose a base ref
...
head repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b2f6aa631edc
Choose a head ref
  • 9 commits
  • 5 files changed
  • 4 contributors

Commits on Dec 12, 2019

  1. Add pkgs.lib.renderOptions

    This adds a new utility to intelligently convert Nix records to
    command line options to reduce boilerplate for simple use cases and to
    also reduce the likelihood of malformed command lines
    Gabriella439 committed Dec 12, 2019
    Copy the full SHA
    183a997 View commit details

Commits on Dec 14, 2019

  1. Rename renderOptions to encodeGNUCommandLine

    ... as suggested by @edolstra
    Gabriella439 committed Dec 14, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    markuskowa Markus Kowalewski
    Copy the full SHA
    8c6a05c View commit details
  2. Make behavior of encodeGNUCommandLine customizable

    ... based on feedback from @edolstra
    Gabriella439 committed Dec 14, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    markuskowa Markus Kowalewski
    Copy the full SHA
    693096d View commit details

Commits on Dec 15, 2019

  1. Use a more realistic example that exercises all encodings

    ... as suggested by @roberth
    
    This also caught a bug in rendering lists, which this change also fixes
    Gabriella439 committed Dec 15, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    Flakebi Sebastian Neubauer
    Copy the full SHA
    5edd4dd View commit details

Commits on Jan 5, 2020

  1. Factor out a toGNUCommandLine utility

    ... as suggested by @roberth
    Gabriella439 committed Jan 5, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    Flakebi Sebastian Neubauer
    Copy the full SHA
    6d584c2 View commit details
  2. Export toGNUCommandLine

    ... as suggested by @roberth
    
    Co-Authored-By: Robert Hensing <roberth@users.noreply.github.com>
    Gabriella439 and roberth authored Jan 5, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a46679f View commit details

Commits on Jan 14, 2020

  1. onnxruntime: 1.0.0 -> 1.1.0

    Jonathan Ringer committed Jan 14, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e306ee4 View commit details
  2. Merge pull request #75539 from Gabriel439/gabriel/renderOptions

    Add `pkgs.lib.encodeGNUCommandLine`
    roberth authored Jan 14, 2020
    Copy the full SHA
    8da8146 View commit details
  3. Copy the full SHA
    b2f6aa6 View commit details
Showing with 94 additions and 7 deletions.
  1. +56 −0 lib/cli.nix
  2. +2 −0 lib/default.nix
  3. +21 −0 lib/tests/misc.nix
  4. +4 −3 pkgs/development/libraries/libvterm-neovim/default.nix
  5. +11 −4 pkgs/development/libraries/onnxruntime/default.nix
56 changes: 56 additions & 0 deletions lib/cli.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ lib }:

rec {
/* Automatically convert an attribute set to command-line options.
This helps protect against malformed command lines and also to reduce
boilerplate related to command-line construction for simple use cases.
Example:
encodeGNUCommandLine
{ }
{ data = builtins.toJSON { id = 0; };
X = "PUT";
retry = 3;
retry-delay = null;
url = [ "https://example.com/foo" "https://example.com/bar" ];
silent = false;
verbose = true;
};
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'"
*/
encodeGNUCommandLine =
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);

toGNUCommandLine =
{ renderKey ?
key: if builtins.stringLength key == 1 then "-${key}" else "--${key}"

, renderOption ?
key: value:
if value == null
then []
else [ (renderKey key) (builtins.toString value) ]

, renderBool ? key: value: lib.optional value (renderKey key)

, renderList ? key: value: lib.concatMap (renderOption key) value
}:
options:
let
render = key: value:
if builtins.isBool value
then renderBool key value
else if builtins.isList value
then renderList key value
else renderOption key value;

in
builtins.concatLists (lib.mapAttrsToList render options);
}
2 changes: 2 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ let

# misc
asserts = callLibs ./asserts.nix;
cli = callLibs ./cli.nix;
debug = callLibs ./debug.nix;
generators = callLibs ./generators.nix;
misc = callLibs ./deprecated.nix;
@@ -120,6 +121,7 @@ let
isOptionType mkOptionType;
inherit (asserts)
assertMsg assertOneOf;
inherit (cli) encodeGNUCommandLine toGNUCommandLine;
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
21 changes: 21 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
@@ -441,4 +441,25 @@ runTests {
expected = "«foo»";
};

testRenderOptions = {
expr =
encodeGNUCommandLine
{ }
{ data = builtins.toJSON { id = 0; };

X = "PUT";

retry = 3;

retry-delay = null;

url = [ "https://example.com/foo" "https://example.com/bar" ];

silent = false;

verbose = true;
};

expected = "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
};
}
7 changes: 4 additions & 3 deletions pkgs/development/libraries/libvterm-neovim/default.nix
Original file line number Diff line number Diff line change
@@ -6,13 +6,14 @@

stdenv.mkDerivation {
pname = "libvterm-neovim";
version = "2019-10-08";
# Releases are not tagged, look at commit history to find latest release
version = "0.1.3";

src = fetchFromGitHub {
owner = "neovim";
repo = "libvterm";
rev = "7c72294d84ce20da4c27362dbd7fa4b08cfc91da";
sha256 = "111qyxq33x74dwdnqcnzlv9j0n8hxyribd6ppwcsxmyrniyw9qrk";
rev = "65dbda3ed214f036ee799d18b2e693a833a0e591";
sha256 = "0r6yimzbkgrsi9aaxwvxahai2lzgjd1ysblr6m6by5w459853q3n";
};

buildInputs = [ perl ];
15 changes: 11 additions & 4 deletions pkgs/development/libraries/onnxruntime/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{ stdenv, fetchFromGitHub, glibcLocales
, cmake, python3
, cmake, python3, libpng, zlib
}:

stdenv.mkDerivation rec {
pname = "onnxruntime";
version = "1.0.0";
version = "1.1.0";

src = fetchFromGitHub {
owner = "microsoft";
repo = "onnxruntime";
rev = "v${version}";
sha256 = "1d28lzrjnq69yl8j9ncxlsxl0bniacn3hnsr9van10zgp527436v";
sha256 = "1ryf5v2h07c7b42q2p9id88i270ajyz5rlsradp00dy8in6dn2yr";
# TODO: use nix-versions of grpc, onnx, eigen, googletest, etc.
# submodules increase src size and compile times significantly
# not currently feasible due to how integrated cmake build is with git
@@ -25,12 +25,19 @@ stdenv.mkDerivation rec {
python3 # for shared-lib or server
];

buildInputs = [
# technically optional, but highly recommended
libpng
zlib
];

cmakeDir = "../cmake";

cmakeFlags = [
"-Donnxruntime_USE_OPENMP=ON"
"-Donnxruntime_BUILD_SHARED_LIB=ON"
"-Donnxruntime_ENABLE_LTO=ON"
# flip back to ON next release
"-Donnxruntime_ENABLE_LTO=OFF" # https://github.com/microsoft/onnxruntime/issues/2828
];

# ContribOpTest.StringNormalizerTest sets locale to en_US.UTF-8"