1 # This module defines global configuration for the xonsh.
3 { config, lib, pkgs, ... }:
9 cfg = config.programs.xonsh;
21 description = lib.mdDoc ''
22 Whether to configure xonsh as an interactive shell.
30 defaultText = literalExpression "pkgs.xonsh";
31 example = literalExpression "pkgs.xonsh.override { extraPackages = ps: [ ps.requests ]; }";
32 description = lib.mdDoc ''
39 description = lib.mdDoc "Control file to customize your shell behavior.";
47 config = mkIf cfg.enable {
49 environment.etc."xonsh/xonshrc".text = ''
50 # /etc/xonsh/xonshrc: DO NOT EDIT -- this file has been generated automatically.
53 if not ''${...}.get('__NIXOS_SET_ENVIRONMENT_DONE'):
54 # The NixOS environment and thereby also $PATH
55 # haven't been fully set up at this point. But
56 # `source-bash` below requires `bash` to be on $PATH,
57 # so add an entry with bash's location:
58 $PATH.add('${pkgs.bash}/bin')
60 # Stash xonsh's ls alias, so that we don't get a collision
61 # with Bash's ls alias from environment.shellAliases:
62 _ls_alias = aliases.pop('ls', None)
64 # Source the NixOS environment config.
65 source-bash "${config.system.build.setEnvironment}"
67 # Restore xonsh's ls alias, overriding that from Bash (if any).
68 if _ls_alias is not None:
69 aliases['ls'] = _ls_alias
76 environment.systemPackages = [ cfg.package ];
79 [ "/run/current-system/sw/bin/xonsh"
80 "${cfg.package}/bin/xonsh"