Does nix have an issue with packages having a '+' in their name? I cannot seem to get rid of this "gtk+" package:
$ nix-env -q
gtk+-2.24.28
$ nix-env -e gtk+-2.24.28
$ nix-env -q
gtk+-2.24.28
(EDIT: Using Nix 1.11.2)
Could you verify this by creating a minimal reproducible package, let's say pkg-test+, and testing if has the same problem?
Yes, it's reproducible:
$ cat > nix-issue-953.nix << EOF
with (import <nixpkgs> { });
{
package =
stdenv.mkDerivation rec {
name = "pkg-test+-1.0";
buildCommand = ''
mkdir -p "$out"
echo "Is nix-env able to uninstall a package with a + in its name?" > "$out/file"
'';
};
}
EOF
$ nix-build nix-issue-953.nix
these derivations will be built:
/nix/store/zzaaqmb4ncxfsplyz8935a68fsr65ab9-pkg-test+-1.0.drv
building path(s) ‘/nix/store/2dvzz8952kkix8qq9wkvyngg61kk28fh-pkg-test+-1.0’
/nix/store/2dvzz8952kkix8qq9wkvyngg61kk28fh-pkg-test+-1.0
$ cat result/file
Is nix-env able to uninstall a package with a + in its name?
$ nix-env -i ./result
installing ‘pkg-test+-1.0’
building path(s) ‘/nix/store/4xvfvi6znki2cfwm6p2351yf7hkl8m53-user-environment’
created 5092 symlinks in user environment
$ nix-env -e pkg-test+-1.0
building path(s) ‘/nix/store/71f13wwdn7z97psv2fh8fxgms4f7q9b7-user-environment’
created 5092 symlinks in user environment
$ nix-env -q | grep pkg-test
pkg-test+-1.0
$ nix-env -e pkg-test+-1.0
$ nix-env -q | grep pkg-test
pkg-test+-1.0
I find it interesting that the first nix-env -e pkg-test+-1.0 actually rebuilds the user environment. So it does _something_. But the package is still in my env (proof: cat ~/.nix-profile/file
Is nix-env able to uninstall a package with a + in its name?). Doing additional nix-env -e pkg-test+-1.0 does nothing (no output, exit with success).
I thought I'd just check, builtins.parseDrvName has no trouble with the '+':
nix-repl> builtins.parseDrvName "pkg-test+-1.0"
{ name = "pkg-test+"; version = "1.0"; }
A nix-env bug, apparently.
nix-env -e 'gtk\+' works. I don't use all features of regex, I think globs would be enough. Regex could be enabled with a flag?
@joelmo: Thanks, that's it!
Ah, it's actually in the man page of nix-env as well:
gtk\\+
Matches the package name gtk+. The + character must be escaped
using a backslash to prevent it from being interpreted as a
quantifier, and the backslash must be escaped in turn with another
backslash to ensure that the shell passes it on.
Ok, then I'm closing the issue.
Usability problem? Maybe there should be a warning or something?
Most helpful comment
Ah, it's actually in the man page of
nix-envas well: