with considered harmful in Nix expressionsExpanding slightly on the Nix anti-patterns sub-section, with attrset; ... expression at nix.dev. It points to the NixOS/nix issue #490 with a more detailed discussion.
Both the post and the issue lists the detrimental effects using with but there is only one suggestion:
let lib = something.very.long; in { lib.foo /*etc..*/ }
with to simplify input lists? (Such as buildInputs in nix-shell expressions)That is:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
# ...
];
# ...
}
easy-purescript-nix provides alternatives by using builtins.attrValues:
{ pkgs ? import <nixpkgs> {} }:
let
default = import ./default.nix {};
buildInputs = builtins.attrValues {
inherit (pkgs) gnumake which;
inherit (default) purs pulp purp psc-package dhall-simple spago pscid spago2nix purty zephyr;
};
in
pkgs.mkShell {
buildInputs = buildInputs;
# or
# inherit buildInputs;
}