I am using termite as my terminal emulator. The termite packages depends on vte-ng, which is a derivation of vte with some additional patches.
Now, I want to source the etc/profile.d/vte.sh script from within my shell’s init file.
Before upgrading to NixOS 20.03, I did it this way:
vte="$( nix eval -f channel:nixos '(with (import <nixpkgs> {}); builtins.toPath vte-ng)' --raw )/etc/profile.d/vte.sh"
if [ -r "$vte" ]; then
TERM=xterm source "$vte"
fi
This is no longer working since vte-ng has been integrated into the termite build and is not available as a separate package (I suppose).
Currently, the path to vte-ng into the nix store is /nix/store/1gr6419lkv34k91brqwgil286v8b7mdx-vte-ng-0.54.2.a. But how can I deduce that info automatically?
I inspected the available information using nix repl, but no dice:
which is the same path I got from my interactive nix repl session. This path does not exist on my system – I suppose that is the build input or output directory which is not fetched when installing termite via nix-env.
nix eval only evaluates the expression (attribute), it will not build it. In order for path to be available, you need to realize the derivation e.g. by using nix-build or build some other derivation that depends on it.
vte="$( nix-build channel:nixos -A termite.vte-ng)/etc/profile.d/vte.sh"
error: unable to download 'https://nixos.org/channels/nixos/nixexprs.tar.xz': HTTP error 404
Using nix-build '<nixpkgs>' -A termite.vte-ng works (ie. it realizes the derivation and prints out the path).
But it is rather slow - takes ~0.6 seconds on each run whereas the nix-store command returns almost immediately (0.03 secs).
I’d go with the nix-store command, but I am still wondering where the difference comes from.
I can see the /nix/store/1gr6419lkv34k91brqwgil286v8b7mdx-vte-ng-0.54.2.a path inside the drv file of termite but cannot retrieve it with a nix expression…
Well, the termite derivation came from a different revision of the channel.
Ideally, you would inline the path into the file to shift the cost to building your system. Adding something like the following to your configuration.nix:
environment.etc = {
"profile.d/vte.sh" = {
source = pkgs.writeScript "vte.sh" ''
vte="${pkgs.termite.vte-ng}/etc/profile.d/vte.sh"
if [ -r "$vte" ]; then
TERM=xterm source "$vte"
fi
'';
};
};
Thank you, that steers me into the right direction…
I ended up adding:
programs.zsh.vteIntegration = true;
to my configuration.nix. But then I noticed that this does not work for me since termite sets TERM=termite and there’s a check for that variable in the sourced script, matching on xterm* | vte*…