How can one exclude xterm from a NixOS install? I’ve included these lines:
services.xserver.excludePackages = with pkgs; [
xterm
];
...
environment.gnome.excludePackages = (with pkgs; [
...
xterm
]);
in my configuration.nix file but xterm is still installed on my system. I want a system that is as minimal as possible while still having GNOME and some apps I want, that is why I want to exclude xterm from my system if possible. My full configs are here.
You can use nix why-depends
to see why something depends on something else. For your case:
nix why-depends --impure --expr 'import <nixpkgs/nixos> { }' system pkgs.xterm
If it’s a dependency of some other package that you’re using, you’d have to rebuild that package to not include that dependency somehow; the details will depend on the package.
1 Like
I ran this command, this was the output:
/nix/store/gkffc2x2mdk2lk07sc0fivf0gg70ncf2-nixos-system-nixos-vbox-25.05beta747653.799ba5bffed0
└───/nix/store/2manxax2w3a0baqnz2id7xy9h6nhbwmm-system-path
└───/nix/store/b83pw3yvsi8z8xsw4ih95bza6pzbdxs1-xterm-396
Sounds to me like it’s just a default package, not that any other package actually depends on it.
Does
nix-instantiate --eval --expr 'builtins.any (x: x.pname or "" == "xterm") (import <nixpkgs/nixos> { }).config.environment.systemPackages'
print true
?
Then something is awry, because it prints false
when I run it on the configuration repository you posted. Either you aren’t currently using exactly that config, or you’re not running these commands in the context of the machine for which you use that config.
That is odd. I am using the configuration. Does it matter that I’ve symlinked my *.nix files from this NixOS-configs repo to appropriate locations in /etc/nixos/
? e.g. configuration.nix is symlinked to /etc/nixos/configuration.nix
.
Although, now I think of it, xterm is sometimes absent from my system but is sometimes present in my system. So it seems this issue is sporadic.
Strange indeed. No, I don’t think the symlinks should make a difference, as long as they point to the location you expect them to.
Sometimes absent, sometimes present would be very surprising! I think there is a big piece of the puzzle missing.
Actually, I just booted up my NixOS 24.11 virtual machine, which is built using the same configuration was my NixOS unstable virtual machine except with different system.stateVersion
and home.stateVersion
, and it does not have xterm installed. My NixOS unstable virtual machine does have xterm installed, however.
Ding ding ding! That’s the problem!
Stop mucking about with stateVersion
. There is an entire paragraph around that setting explaining why you shouldn’t mess with it unless you know what you’re doing, and you have messed with it. "unstable"
is not an allowed value for that setting and it’s causing the nixos/modules/services/x11/desktop-managers/xterm.nix
module to include xterm
because including xterm
was the standard behavior up until 2019-ish, I think, and stateVersion
is how it detects whether you are expecting pre-2019 behavior or post-2019 behavior.
Put it back to "24.11"
for both your VMs and don’t touch it again.
4 Likes
That’s even if I want to install NixOS unstable? I don’t want 24.11 on this virtual machine, I already have a 24.11 VM.
Yes, stateVersion
has nothing to do with what channel you’re using. If you keep your NixOS machine for five years, when you’re running nixos-30.05 stateVersion
should still be "24.11"
.
2 Likes