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

packageOverrides not applied to replaceStdenv's argument. Breaks ccacheStdenv #62121

Open
Piezoid opened this issue May 27, 2019 · 1 comment

Comments

@Piezoid
Copy link

commented May 27, 2019

Issue description

packageOverrides are not (no longer ?) applied in the pkgs argument of replaceStdenv, making the documentation of ccacheStdenv obsolete or unclear.
It seems that an overlay should be used instead. (#43266)

The inline doc in pkgs/top-level/all-packages.nix says:

Wrapper that works as gcc or g++
It can be used by setting in nixpkgs config like this, for example:
   replaceStdenv = { pkgs }: pkgs.ccacheStdenv;
But if you build in chroot, you should have that path in chroot
If instantiated directly, it will use $HOME/.ccache as the cache directory,
i.e. /homeless-shelter/.ccache using the Nix daemon.
You should specify a different directory using an override in
packageOverrides to set extraConfig.

Example using Nix daemon (i.e. multiuser Nix install or on NixOS):
   packageOverrides = pkgs: {
    ccacheWrapper = pkgs.ccacheWrapper.override {
      extraConfig = ''
        export CCACHE_COMPRESS=1
        export CCACHE_DIR=/nix/var/ccache
        export CCACHE_UMASK=007
      '';
    };
You can use a different directory, but whichever directory you choose
should be owned by user root, group nixbld with permissions 0770.

Steps to reproduce

However with this config.nix:

{
    replaceStdenv = { pkgs }: builtins.trace "###Deref ccacheStdenv###" pkgs.ccacheStdenv;
    packageOverrides = pkgs: {
        ccacheWrapper = builtins.trace "###Deref ccacheWrapper###" (pkgs.ccacheWrapper.override {
            extraConfig = builtins.trace "###Deref extraConfig###" ''
                export CCACHE_DIR=/nix/var/ccache
                export CCACHE_UMASK=007
            '';
        });
    };
}

A build like nix-build -A gnum4 ~/repos/nixpkgs --keep-failed fail with:
ccache: error: Failed to create directory /homeless-shelter/.ccache/tmp: Permission denied
indicating that the extraConfig environment variables failled to apply.

Furthermore, only the trace: ###Deref ccacheStdenv### show up. This demonstrate that my overlayed ccacheWrapper is never evaluated.

Using this overlay ~/.config/nixpkgs/overlays/ccacheWrapper.nix worked:

self: super: {
  ccacheWrapper =super.ccacheWrapper.override {
    extraConfig = ''
      export CCACHE_DIR=/nix/var/ccache
      export CCACHE_UMASK=007
    '';
    };
}
@FRidh

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

That's indeed a bug and should not exist, however, packageOverrides isn't really maintained anymore either since the way forward is overlays.

Talk about deprecating packageOverrides #43266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.