I have an overriden WordPress package, and I need to get the path to copy it into a local directory. I found that I can get the path with echo $buildInputs | tr " " "\n" | grep wordpress, but it seems like there would be a better and less fragile way to do this. I tried using a writeScript in default.nix, but I get a nix-shell error about not having multiple derivations.
Are you trying to get the Nix store path of your custom wordpress derivation? Derivations have outPath attribute for that. When a derivation is coerced to a string (for example with builtins.toString <drv>) it becomes <drv>.outPath.
I think the easiest way the get the outputPath of your derivation would be adding shellHook attribute to you devShell like
pkgs.mkShell {
buildInputs = [
...
];
shellHook = ''
echo "Nix store path of wordpress: ${wordpress}"
'';
}
This way, when you enter the shell with nix-shell, it will print the Nix store path of the derivation. Or you could use nix-repl
nix-repl> :b wordpress.overrideAttrs( oldAttrs: rec {
version = "5.8.1";
src = fetchurl {
url = "https://wordpress.org/wordpress-${version}.tar.gz";
sha256 = "90ca90c4afa37dadc8a4743b5cb111b20cda5f983ce073c2c0bebdce64fa822a";
};
})
this derivation produced the following outputs:
out -> /nix/store/blvbrdkmhan50h2dhrabr68x8xh9an1x-wordpress-5.8.1