https://nixos.org/nixpkgs/manual/#sec-pkg-overrideAttrs documents overrideAttrs
and it can be used with top-level/all-packages.nix
.
so i want to be able to use overrideAttrs in my own nixpkgs overlay!
rec {
frontend = pkgs.callPackage "${nixcloud-frontend}/release.nix" {
inherit nixcloud-editor;
};
AAA = frontend.overrideAttrs (oldAttrs: rec {
API_HOST="wss://";
});
helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
separateDebugInfo = true;
});
}
but the problem is evaluating AAA
won't work:
nix-build nixcloud-pkgs.nix -A AAA
error: attribute ‘overrideAttrs’ missing, at /home/joachim/Desktop/projects/nixcloud/nixcloud-webservices/nixcloud-pkgs.nix:17:9
in contrast, evaluating helloWithDebug
works:
nix-build nixcloud-pkgs.nix -A helloWithDebug
these derivations will be built:
/nix/store/x01q7lfqbwlj08iknph37jxh2bk3il68-hello-2.10.drv
these paths will be fetched (0.69 MiB download, 0.69 MiB unpacked):
/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
in nixpkgs i see:
lib/customisation.nix
used in lib/default.nix
for which i can't say where it is injected yet.
to see the stack i just added breaking code into lib/customisation.nix
:
nix-build -I nixpkgs=../nixpkgs -A tests --show-trace ~/Desktop/projects/nixos/nixpkgs
error: while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/impure.nix:15:1, called from undefined position:
while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/default.nix:20:1, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/impure.nix:64:1:
while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:42:1, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/default.nix:97:10:
while evaluating ‘dfold’ at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:60:27, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:104:4:
while evaluating ‘go’ at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:63:18, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:71:8:
while evaluating the file ‘/home/joachim/Desktop/projects/nixos/nixpkgs/lib/default.nix’:
syntax error, unexpected ID, expecting '.' or '=', at /home/joachim/Desktop/projects/nixos/nixpkgs/lib/customisation.nix:37:3
cat nixcloud-pkgs.nix
{ pkgs ? import <nixpkgs> {}
, nixcloud-backend ? pkgs.stdenv.lib.cleanSource ../nixcloud-backend
, nixcloud-frontend ? pkgs.stdenv.lib.cleanSource ../nixcloud-frontend
, nixcloud-editor ? pkgs.stdenv.lib.cleanSource ../nixcloud-editor
, nixcloud-container ? pkgs.stdenv.lib.cleanSource ../nixcloud-container
, ...
} @ args:
let
nc-backend = nixcloud-backend;
nc-frontend = nixcloud-frontend;
newpkgs = import pkgs.path { overlays = [ (self: super: {
nixcloud-backend = super.callPackage nc-backend { inherit newpkgs; };
nixcloud-frontend = super.callPackage "${nc-frontend}/release.nix" {
inherit nixcloud-editor;
};
} ) ]; };
in newpkgs
nix-build nixcloud-pkgs.nix -A nixcloud-frontend
cat nixcloud-pkgs.nix
{ pkgs ? import <nixpkgs> {}
, nixcloud-backend ? pkgs.stdenv.lib.cleanSource ../nixcloud-backend
, nixcloud-frontend ? pkgs.stdenv.lib.cleanSource ../nixcloud-frontend
, nixcloud-editor ? pkgs.stdenv.lib.cleanSource ../nixcloud-editor
, nixcloud-container ? pkgs.stdenv.lib.cleanSource ../nixcloud-container
, ...
} @ args:
let
nc-backend = nixcloud-backend;
nc-frontend = nixcloud-frontend;
newpkgs = import pkgs.path { overlays = [ (self: super: {
nixcloud-backend = super.callPackage nc-backend { inherit newpkgs; };
nixcloud-frontend = supber.callPackage "${nc-frontend}/release.nix" {
inherit nixcloud-editor;
};
} ) ]; };
in newpkgs.nixcloud-frontend.override (oldAttrs: rec {
API_HOST="wss://....";
})
nix-build nixcloud-pkgs.nix
please see also https://github.com/NixOS/nixpkgs/pull/26321 where this is discussed