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

Package setup hooks are not run in an overriden derivation for added buildInputs #17732

Closed
michalrus opened this issue Aug 14, 2016 · 5 comments

Comments

@michalrus
Copy link
Member

Issue description

E.g. when glib and gsettings_desktop_schemas are added to buildInputs, the GSETTINGS_SCHEMAS_PATH should be exported and visible in derivation’s build phases. Or when perl is added, PERL5LIB should be exported etc.

And this works. However, when these are added to buildInputs using overrideDerivation, these setup hooks seem to not be run, and their variables are not exported.

Steps to reproduce

let
  old = pkgs.stdenv.mkDerivation {
    name = "blah";
    unpackPhase = "echo dummy";
    buildInputs = with pkgs; [ perl ];
    installPhase = "touch $out ; export | grep -Ev 'installPhase=|preFixup=' | grep PERL5LIB";
  };
  new = pkgs.stdenv.lib.overrideDerivation old (oldAttrs: {
    buildInputs = with pkgs; [ glib gsettings_desktop_schemas ];
    preFixup = "export | grep -Ev 'installPhase=|preFixup=' | grep GSETTINGS_SCHEMAS_PATH";
  });
in new

Now, when building new, both PERL5LIB and GSETTINGS_SCHEMAS_PATH should be output (the first one twice).

The build fails, as GSETTINGS_SCHEMAS_PATH is not exported at all. Move glib and gsettings_desktop_schemas not old’s buildInputs and it is.

  1. Output with glib gsettings_desktop_schemas added to old’s buildInputs:

    installing
    declare -x PERL5LIB="/nix/store/xlqafmhfnzwg0c77ns8m41k2vn1frqz3-perl-5.22.2/lib/perl5/site_perl"
    post-installation fixup
    declare -x GSETTINGS_SCHEMAS_PATH="/nix/store/mn24ynlx0ir0mjz54vq68kqa4prxkhr8-gsettings-desktop-schemas-3.20.0/share/gsettings-schemas/gsettings-desktop-schemas-3.20.0"
    
  2. Output with glib gsettings_desktop_schemas added to new’s buildInputs:

    installing
    declare -x PERL5LIB="/nix/store/xlqafmhfnzwg0c77ns8m41k2vn1frqz3-perl-5.22.2/lib/perl5/site_perl"
    post-installation fixup
    builder for ‘/nix/store/l23244h76bn2ngz93zxbhn80631iq47c-blah.drv’ failed with exit code 1
    

Technical details

  • System: 16.09pre88185.52a875f (Flounder)
  • Nix version: nix-env (Nix) 1.11.2
  • Nixpkgs version: "16.09pre88185.52a875f"
@abbradar
Copy link
Member

I think I remember something ugly about namings of buildInputs. Try adding those to nativeBuildInputs in overrideDerivation and see what happens.

@michalrus
Copy link
Member Author

Adding glib gsettings_desktop_schemas to nativeBuildInputs instead, did not cause exporting GSETTINGS_SCHEMAS_PATH. Furthermore, even PERL5LIB disappared from the output⸮ Wicked. 😃

@abbradar
Copy link
Member

{ pkgs ? import <nixpkgs> {} }:
let
  old = pkgs.stdenv.mkDerivation {
    name = "blah";
    unpackPhase = "echo dummy";
    buildInputs = with pkgs; [ perl ];
    installPhase = "touch $out ; export | grep -Ev 'installPhase=|preFixup=' | grep PERL5LIB";
  };
  new = pkgs.stdenv.lib.overrideDerivation old (oldAttrs: {
    nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ glib gsettings_desktop_schemas ]);
    preFixup = "export | grep -Ev 'installPhase=|preFixup=' | grep GSETTINGS_SCHEMAS_PATH";
  });
in new
these derivations will be built:
  /nix/store/vhkj8wcv4g704xmka7ksjw9bhdfyqihx-blah.drv
building path(s) ‘/nix/store/jd00n1dj46q5affvwngc64wpd1miila9-blah’
unpacking sources
dummy
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
glibPreInstallPhase
installing
declare -x PERL5LIB="/nix/store/xlqafmhfnzwg0c77ns8m41k2vn1frqz3-perl-5.22.2/lib/perl5/site_perl"
glibPreFixupPhase
post-installation fixup
declare -x GSETTINGS_SCHEMAS_PATH="/nix/store/mn24ynlx0ir0mjz54vq68kqa4prxkhr8-gsettings-desktop-schemas-3.20.0/share/gsettings-schemas/gsettings-desktop-schemas-3.20.0"
shrinking RPATHs of ELF executables and libraries in /nix/store/jd00n1dj46q5affvwngc64wpd1miila9-blah
patching script interpreter paths in /nix/store/jd00n1dj46q5affvwngc64wpd1miila9-blah
/nix/store/jd00n1dj46q5affvwngc64wpd1miila9-blah

That's because of an awful wart in our stdenv where buildInputs are actually named nativeBuildInputs internally and vice versa. When you use overrideDerivation you override a raw derivation after all pre-processing and changes -- so, with internals exposed. See #4855.

@michalrus
Copy link
Member Author

Oh, I see… 😲 Thank you for investigating this.

@domenkozar
Copy link
Member

Yes, see #4855

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

3 participants