Pip missing for Xonsh

I recently switched to Xonsh and I’m trying to setup direnv.
There is a plugin for direnv but I can’t install it with xpip because it says pip is missing.

/nix/store/wl02plhc6zf84m6x9984l42wnnnbly5m-python3-3.9.6/bin/python3.9: No module named pip

Just adding pip packages doesn’t work.

{ pkgs, ... }:
let
  username = import ../../username.nix;
in
{
  programs.xonsh = {
    enable = true;
    config = ''
      aliases['management-server'] = "mosh ${username}@10.7.89.106 tmux a"
      aliases['nix-generations'] = "sudo nix-env --list-generations --profile /nix/var/nix/profiles/system"
      aliases['rebuild'] = "sudo nixos-rebuild -j auto switch"
      aliases['find-garbage'] = "ls -l /nix/var/nix/gcroots/auto/ | sort"
      aliases['format-module'] = "nixpkgs-fmt **/*.nix"
    '';
  };
  users.users.${username} = {
    shell = pkgs.xonsh;
  };
  environment.systemPackages = with pkgs; [
    python39Packages.pip
  ];
}

In general, pip and friends will just not work in Nix world due to PYTHONNOUSERSITE=true. Package it with Nix and supply it through Nix: nix-configs/direnv.nix at ebe3ec247b44ed13eebaab2a879a0a0788e7db12 · t184256/nix-configs · GitHub

1 Like

Ah okay, thank you.
I discovered yesterday that direnv doesn’t support aliases which just made it far less attractive.
Maybe I can replicate the behaviour and let Xonsh execute nix-shell or nix develop when it finds the corresponding file in a directory.

Great that your config is public, I haven’t seen many Xonsh configs in the wild yet, granted I only use it since a few weeks but still.