devshell
devshell copied to clipboard
Installing different versions of node and npm deviates from nix behavior
Describe the bug
With the following flake.nix
{
description = "Node dev";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.devshell.url = "github:numtide/devshell";
outputs = { self, nixpkgs, flake-utils, devshell }:
flake-utils.lib.eachDefaultSystem (system: {
devShell = let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay ];
};
in pkgs.devshell.mkShell {
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
devshell.packages = [ pkgs.nodejs-14_x pkgs.nodePackages.npm ];
};
});
nix develop results into error
error: builder for '/nix/store/yxj3h7c72xygkb9i88w7kqz7nykqf647-devshell-dir.drv' failed with exit code 25;
last 1 log lines:
> error: collision between `/nix/store/x22pf8sm4ym58s2zqhjzqdz649a6yq44-npm-8.3.2/lib/node_modules/npm/README.md' and `/nix/store/p88qhhnrwsi5rxfsz3cgvgs80lkgplp1-nodejs-14.18.3/lib/node_modules/npm/README.md'
For full logs, run 'nix log /nix/store/yxj3h7c72xygkb9i88w7kqz7nykqf647-devshell-dir.drv'.
error: 1 dependencies of derivation '/nix/store/vvswra82ipmcbm3vk4fndvxj98rqcp4m-devshell-env.drv' failed to build
Whereas in regular flake.nix both the packages are installed and gives you a shell with node 14 and npm 8.
I can understand if this is a feature rather than a bug. In that case please let me know what is a workaround.
You can use lib.lowPrio and lib.hiPrio to de/prioritise packages.