Skip to content
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
base: 919b1f5466dd
Choose a base ref
...
head repository: NixOS/nixpkgs
compare: 59b45d66b23a
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 31, 2021

  1. lib/generators: fix toPretty throwing on (partially applied) builtins

    An high level example case of this problem occuring can be found below:
    
    nix-repl> lib.generators.toPretty {} (lib.concatStringsSep "\n")
    error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42
    
    However this does not happen on other partially applied functions:
    
    nix-repl> lib.generators.toPretty {} (lib.concatMapStringsSep "\n")
    "<function>"
    
    The issue, as it turns out is that while builtins are functions,
    builtins.functionArgs throws if is passed a builtin or a partially
    applied builtin:
    
    nix-repl> lib.generators.toPretty {} builtins.toString
    error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42
    
    nix-repl> lib.generators.toPretty {} (builtins.foldl' (a: b: a + b))
    error: 'functionArgs' requires a function, at /home/lukas/src/nix/nixpkgs/lib/trivial.nix:334:42
    
    I'm pretty sure this qualifies as a nix bug and should be filed
    accordingly, but we can work around it in lib.generators.toPretty by
    using tryEval and falling back to {} which functionArgs _should_ return
    for builtins.
    
    The nix behavior is inconsistent to say the least:
    
    nix-repl> builtins.functionArgs builtins.functionArgs
    error: 'functionArgs' requires a function, at (string):1:1
    
    nix-repl> builtins.typeOf builtins.functionArgs
    "lambda"
    
    builtins.functionArgs (a: 1 + a)
    { }
    
    nix-repl> builtins.typeOf (a: 1 + a)
    "lambda"
    sternenseemann committed Jan 31, 2021
    Copy the full SHA
    d9a7d03 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #111469 from sternenseemann/topretty-fix-currying

    lib/generators: fix toPretty throwing on (partially applied) builtins
    infinisil committed Jan 31, 2021
    Copy the full SHA
    59b45d6 View commit details
    Browse the repository at this point in the history