1 # This module defines global configuration for the xonsh.
3 { config, lib, pkgs, ... }:
7 cfg = config.programs.xonsh;
17 enable = lib.mkOption {
20 Whether to configure xonsh as an interactive shell.
22 type = lib.types.bool;
25 package = lib.mkPackageOption pkgs "xonsh" {
26 example = "pkgs.xonsh.override { extraPackages = ps: [ ps.requests ]; }";
29 config = lib.mkOption {
31 description = "Control file to customize your shell behavior.";
32 type = lib.types.lines;
39 config = lib.mkIf cfg.enable {
41 environment.etc."xonsh/xonshrc".text = ''
42 # /etc/xonsh/xonshrc: DO NOT EDIT -- this file has been generated automatically.
45 if not ''${...}.get('__NIXOS_SET_ENVIRONMENT_DONE'):
46 # The NixOS environment and thereby also $PATH
47 # haven't been fully set up at this point. But
48 # `source-bash` below requires `bash` to be on $PATH,
49 # so add an entry with bash's location:
50 $PATH.add('${pkgs.bash}/bin')
52 # Stash xonsh's ls alias, so that we don't get a collision
53 # with Bash's ls alias from environment.shellAliases:
54 _ls_alias = aliases.pop('ls', None)
56 # Source the NixOS environment config.
57 source-bash "${config.system.build.setEnvironment}"
59 # Restore xonsh's ls alias, overriding that from Bash (if any).
60 if _ls_alias is not None:
61 aliases['ls'] = _ls_alias
67 environment.systemPackages = [ cfg.package ];
69 environment.shells = [
70 "/run/current-system/sw/bin/xonsh"
71 "${lib.getExe cfg.package}"