Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-diff does not show difference in configureFlags #23

Open
nh2 opened this issue Jan 21, 2020 · 2 comments
Open

nix-diff does not show difference in configureFlags #23

nh2 opened this issue Jan 21, 2020 · 2 comments

Comments

@nh2
Copy link

nh2 commented Jan 21, 2020

For 2 output paths (shortened to program1 and program2):

% nix show-derivation $(nix-store -qd program1) $(nix-store -qd program2) | grep '"configureFlags"'
      "configureFlags": "--ld-option=-Wl,--start-group",
      "configureFlags": "--enable-executable-static --extra-lib-dirs=/nix/store/qjff0igr8lnajcbfzbr4qqj89vjilg98-ncurses-6.1-20190112/lib --extra-lib-dirs=/nix/store/vw1d2ndp76xdx88j7hdhv2jws44abryk-gmp-6.1.2/lib --extra-lib-dirs=/nix/store/f8kj800is9kv2392wjg66gb3rxvdm17a-libffi-3.2.1/lib",

Clearly the two configureFlags are different.

But nix-diff does not show it:

% nix-diff $(nix-store -qd program1) $(nix-store -qd program2)              
- /nix/store/xcsm11hy6i4pzry1gr0b4da3ryqm62xv-program-0.1.0.0.drv:{out}
+ /nix/store/bvqxhbmyyyirifn6rcpi6ihkpwzf596l-program-0.1.0.0.drv:{out}
• The set of input names do not match:
    - Cabal-2.4.1.0
    - gmp-6.1.2
    - libffi-3.2.1
    - ncurses-6.1-20190112
    + openssl-1.1.1d
    + pkg-config-0.29.2
    + postgresql-11.5
• The input named `mylib-1.2.3` differs
  - /nix/store/x5zppd3wmfmbq5hs4j1611rv2nhg21wd-mylib-1.2.3.drv:{out}
  + /nix/store/j7jaf0rzk0a24743rhhkb06aqgzg07sf-mylib-1.2.3.drv:{out}
  • The set of input sources do not match:
      - /nix/store/01db9xwxmlvqf92mg8jjn54ywp3wmcgg-mylib-src
      + /nix/store/gw9f615d7dg96rch8kazb1fwppas1g9d-mylib-src
• The input named `webserverlib-0.1.0.0` differs
  - /nix/store/6slx6ww53q5sa6xxp5b5y5wmmy0mh8qr-webserverlib-0.1.0.0.drv:{out}
  + /nix/store/aidq5xc0dap1mx7pb7m6faqn0r38k27z-webserverlib-0.1.0.0.drv:{out}
  • The set of input sources do not match:
      - /nix/store/ffcqhwc6jnsq5l4pvxpnagbhvj13f2b6-webserverlib
      + /nix/store/fij4ckb7dasw9mbjmrzxlnmzzs2g573p-webserverlib

configureFlags is not mentioned in here.

Am I doing something wrong?

@Gabriella439
Copy link
Owner

Gabriella439 commented Jan 22, 2020

@nh2: This behavior is mostly intended but could be improved with a more intelligent algorithm.

To provide some context, nix-diff will skip printing the environment differences in several cases. For example, if there are any transitive differences in the inputs to a derivation then nix-diff will skip displaying differences to the environment.

The reason for this behavior is that hash changes for transitive dependencies will "pollute" the environment diff, drowning out other legitimate environment changes you might be interested in. For example, at the Nix level your derivation record might have this field:

{ configureFlags = [ … "--extra-lib-dirs=${pkgs.ncurses}/lib" … ];

  …
}

... but if the pkgs.ncurses dependency transitively changes then it will also show up as an (uninteresting) change to the configureFlags environment variable, too.

The way to properly fix this would be to ignore environment changes which can be explained from other known changes already displayed to the user (like changes to the input derivations).

A short-term fix might be to allow users to opt-in to displaying all changes even if it makes things much more noisy. However, I think the default behavior should still be the current behavior, because usually the intended workflow is to surface the most salient differences first and once those differences are eliminated then nix-diff can surface more subtle changes.

@nh2
Copy link
Author

nh2 commented Jan 31, 2020

I think the default behaviour is fine as long as the tool says it, e.g. if it could print

other differences omitted

or

other differences omitted due to different inputs

or even saving a new line

• The set of input names do not match (other differences omitted due to this):

perhaps with a yellow highlight or so, that would already get rid of the surprises.

allow users to opt-in to displaying all changes

That'd also be cool. Then after I one sees other differencences omitted one can give that flag if one is interested in the full difference.

Gabriella439 added a commit that referenced this issue Feb 1, 2020
#23

This now alerts the user when the environment is being skipped and
also adds a new `--environment` flag to force display of the
environment in diffs
Gabriella439 added a commit that referenced this issue Feb 1, 2020
#23

This now alerts the user when the environment is being skipped and
also adds a new `--environment` flag to force display of the
environment in diffs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants