NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.12k stars 1.47k forks source link

nix eval: strictness of evaluation should be same with or without "--raw", probably? #1763

Open dtzWill opened 6 years ago

dtzWill commented 6 years ago

Summary

The --raw flag for nix eval is described as changing whether printed strings are quoted or not, but in practice seems to also control whether deep evaluation is used (like the --strict flag for nix-instantiate).

This means that expressions that cannot be strictly evaluated (see guitarix example below) must also be printed with --raw. This is problematic when raw output is unsuitable (for example, evaluating a set of derivations).

Proposed Solution: Strictness controlled by flag?

If nothing else this is unexpected and perhaps should be controlled using a new --strict flag instead?

'Hello' Example

Raw

$ nix eval -f channel:nixos-17.09 --raw hello
/nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10%

Normal

Recommend having control-C ready before running this one:

$ nix eval -f channel:nixos-17.09 hello
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
trace: `mkStrict' is obsolete; use `mkOverride 0' instead.
trace: `types.list' is deprecated; use `types.listOf' instead
trace: types.optionSet is deprecated; use types.submodule instead
{ __ignoreNulls = true; all = [ { __ignoreNulls = true; all = <CYCLE>; (truncated)

'Guitarix' Example

This is just an example of how this difference can be problematic in practice:

Raw

$ nix eval -f channel:nixos-17.09 --raw guitarix
/nix/store/hqv0dwdz7jcqzc1nd812vnam6fav1lq4-guitarix-0.35.6%

Normal

$ nix eval -f channel:nixos-17.09 guitarix
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
trace: `mkStrict' is obsolete; use `mkOverride 0' instead.
trace: `types.list' is deprecated; use `types.listOf' instead
trace: types.optionSet is deprecated; use types.submodule instead
error: Package ‘python2.7-dosage-2016.03.17’ in /nix/store/9vzyf1g2yaa0yc9iglq58byfnyijdfp7-nixexprs.tar.xz/pkgs/top-level/python-packages.nix:1753 is marked as broken, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

(use '--show-trace' to show detailed location information)
stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

lovesegfault commented 2 years ago

Got bitten by this today