target / lorri

Your project's nix-env
Apache License 2.0
992 stars 69 forks source link

Lorri misbehaves when the shell has `disallowedReferences` #489

Open michaelpj opened 3 years ago

michaelpj commented 3 years ago

Describe the bug lorri fails in some cases if the shell derivation uses disallowedReferences or disallowedRequisites. This can be useful as a safety guard to avoid e.g. situations where your shell depends on building too much stuff (happened to me at work!).

To Reproduce Steps to reproduce the behavior:

{ pkgs ? (import <nixpkgs> {}) }:
pkgs.mkShell {
  buildInputs = [ pkgs.hello ];
  disallowedReferences = [ pkgs.hello ];
  # so you can nix-build this file and check that it's okay
  nobuildPhase = ''touch $out'';
}

Observe:

Expected behavior lorri does not fail if the normal use of the shell.nix does not fail.

Additional context I'm pretty sure the problem is here: https://github.com/target/lorri/blob/008646abcbae05b1e7d6577857555c596b426769/src/logged-evaluation.nix#L39

This keeps all the drv attributes but messes with the inputs, thus making disallowedReferences and disallowedRequisites do the wrong thing. A simple fix would probably be to just strip those attributes.