diff --git a/nixos/shell.nix b/nixos/shell.nix index 80ab914..1f22648 100644 --- a/nixos/shell.nix +++ b/nixos/shell.nix @@ -1,5 +1,46 @@ { config, pkgs, ... }: { + # enable bash completions + # even though we don't use bash as our shell, xonsh uses bash completion scripts + programs.bash.completion.enable = true; + + programs.command-not-found.enable = false; + + users.defaultUserShell = pkgs.xonsh; + programs.xonsh = + let + bashcfg = config.programs.bash; + #xontrib-cd = pkgs.callPackage ../packages/xontribs/xontrib-cd.nix { inherit pkgs; }; + xontrib-clp = pkgs.callPackage ../packages/xontribs/xontrib-clp.nix { inherit pkgs; }; + xontrib-direnv = pkgs.callPackage ../packages/xontribs/xontrib-direnv.nix { inherit pkgs; }; + xontrib-sh = pkgs.callPackage ../packages/xontribs/xontrib-sh.nix { inherit pkgs; }; + in + { + enable = true; + config = '' + $BASH_COMPLETIONS = ('${bashcfg.completion.package}/etc/profile.d/bash_completion.sh') + $UPDATE_OS_ENVIRON = True + $XONTRIB_CLP_ALIAS = 'shutil' + #xontrib load cd + xontrib load clp + xontrib load direnv + xontrib load sh + source-bash ${pkgs.nix-index}/etc/profile.d/command-not-found.sh + tmpfile = $(mktemp) + gh copilot alias -- bash > @(tmpfile) + source-bash @(tmpfile) + ulimit -n 4096 # This is so that Gauntlet is able to be built + ''; + package = pkgs.xonsh.override { + extraPackages = ps: [ + pkgs.python311Packages.rich + xontrib-clp + xontrib-direnv + xontrib-sh + ]; + }; + }; + #TODO: Submit a PR to nixpkgs to add xonsh support to the Starship module # After that, we can remove this import and the disabledModules line disabledModules = [ "programs/starship.nix" ]; @@ -62,111 +103,4 @@ add_newline = false; }; }; - - # enable bash completions - # even though we don't use bash as our shell, xonsh uses bash completion scripts - programs.bash.completion.enable = true; - - programs.command-not-found.enable = false; - - users.defaultUserShell = pkgs.xonsh; - programs.xonsh = - let - bashcfg = config.programs.bash; - in - { - enable = true; - config = '' - $BASH_COMPLETIONS = ('${bashcfg.completion.package}/etc/profile.d/bash_completion.sh') - $UPDATE_OS_ENVIRON = True - $XONTRIB_CLP_ALIAS = 'shutil' - #xontrib load cd - xontrib load clp - xontrib load direnv - xontrib load sh - source-bash ${pkgs.nix-index}/etc/profile.d/command-not-found.sh - tmpfile = $(mktemp) - gh copilot alias -- bash > @(tmpfile) - source-bash @(tmpfile) - ulimit -n 4096 # This is so that Gauntlet is able to be built - ''; - package = pkgs.xonsh.override { - extraPackages = ps: [ - pkgs.python311Packages.rich - # (ps.buildPythonPackage rec { - # name = "xontrib-cd"; - # version = "0.3.1"; - - # src = pkgs.fetchFromGitHub { - # owner = "eugenesvk"; - # repo = name; - # rev = version; - # sha256 = "XxSxjyCg7PeX1v3e2KKicvAPmNeq+qVqbW4fXTwAiic="; - # }; - - # meta = { - # homepage = "https://github.com/eugenesvk/xontrib-cd"; - # description = - # "`cd` to any path without escaping in xonsh shell: `cd ~/[te] st`"; - # license = pkgs.lib.licenses.mit; - # maintainers = [ "cswimr" ]; - # }; - # }) - (ps.buildPythonPackage rec { - name = "xontrib-clp"; - version = "0.1.7"; - - src = pkgs.fetchFromGitHub { - owner = "anki-code"; - repo = name; - rev = version; - sha256 = "1ewWlwG8KY9s6qydErurvP2x+4DIPTFcjSGP1c5y83M="; - }; - - meta = { - homepage = "https://github.com/anki-code/xontrib-clp"; - description = "Copy output to clipboard. Cross-platform."; - license = pkgs.lib.licenses.mit; - maintainers = [ "cswimr" ]; - }; - }) - (ps.buildPythonPackage rec { - name = "xonsh-direnv"; - version = "1.6.5"; - - src = pkgs.fetchFromGitHub { - owner = "74th"; - repo = name; - rev = version; - sha256 = "huBJ7WknVCk+WgZaXHlL+Y1sqsn6TYqMP29/fsUPSyU="; - }; - - meta = { - homepage = "https://github.com/74th/xonsh-direnv"; - description = "xonsh extension for using direnv"; - license = pkgs.lib.licenses.mit; - maintainers = [ "cswimr" ]; - }; - }) - (ps.buildPythonPackage rec { - name = "xontrib-sh"; - version = "0.3.1"; - - src = pkgs.fetchFromGitHub { - owner = "anki-code"; - repo = name; - rev = version; - sha256 = "KL/AxcsvjxqxvjDlf1axitgME3T+iyuW6OFb1foRzN8="; - }; - - meta = { - homepage = "https://github.com/anki-code/xontrib-sh"; - description = "Paste and run commands from bash, zsh, fish, tcsh in xonsh shell."; - license = pkgs.lib.licenses.mit; - maintainers = [ "cswimr" ]; - }; - }) - ]; - }; - }; } diff --git a/packages/xontribs/xontrib-cd.nix b/packages/xontribs/xontrib-cd.nix new file mode 100644 index 0000000..728db42 --- /dev/null +++ b/packages/xontribs/xontrib-cd.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +(pkgs.python3Packages.buildPythonPackage rec { + name = "xontrib-cd"; + version = "0.3.1"; + + src = pkgs.fetchFromGitHub { + owner = "eugenesvk"; + repo = name; + rev = version; + sha256 = "XxSxjyCg7PeX1v3e2KKicvAPmNeq+qVqbW4fXTwAiic="; + }; + + meta = { + homepage = "https://github.com/eugenesvk/xontrib-cd"; + description = "`cd` to any path without escaping in xonsh shell: `cd ~/[te] st`"; + license = pkgs.lib.licenses.mit; + maintainers = [ "cswimr" ]; + }; +}) diff --git a/packages/xontribs/xontrib-clp.nix b/packages/xontribs/xontrib-clp.nix new file mode 100644 index 0000000..5887ed6 --- /dev/null +++ b/packages/xontribs/xontrib-clp.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +(pkgs.python3Packages.buildPythonPackage rec { + name = "xontrib-clp"; + version = "0.1.7"; + + src = pkgs.fetchFromGitHub { + owner = "anki-code"; + repo = name; + rev = version; + sha256 = "1ewWlwG8KY9s6qydErurvP2x+4DIPTFcjSGP1c5y83M="; + }; + + meta = { + homepage = "https://github.com/anki-code/xontrib-clp"; + description = "Copy output to clipboard. Cross-platform."; + license = pkgs.lib.licenses.mit; + maintainers = [ "cswimr" ]; + }; +}) diff --git a/packages/xontribs/xontrib-direnv.nix b/packages/xontribs/xontrib-direnv.nix new file mode 100644 index 0000000..68d49b3 --- /dev/null +++ b/packages/xontribs/xontrib-direnv.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +(pkgs.python3Packages.buildPythonPackage rec { + name = "xonsh-direnv"; + version = "1.6.5"; + + src = pkgs.fetchFromGitHub { + owner = "74th"; + repo = name; + rev = version; + sha256 = "huBJ7WknVCk+WgZaXHlL+Y1sqsn6TYqMP29/fsUPSyU="; + }; + + meta = { + homepage = "https://github.com/74th/xonsh-direnv"; + description = "xonsh extension for using direnv"; + license = pkgs.lib.licenses.mit; + maintainers = [ "cswimr" ]; + }; +}) diff --git a/packages/xontribs/xontrib-sh.nix b/packages/xontribs/xontrib-sh.nix new file mode 100644 index 0000000..9b448b1 --- /dev/null +++ b/packages/xontribs/xontrib-sh.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +(pkgs.python3Packages.buildPythonPackage rec { + name = "xontrib-sh"; + version = "0.3.1"; + + src = pkgs.fetchFromGitHub { + owner = "anki-code"; + repo = name; + rev = version; + sha256 = "KL/AxcsvjxqxvjDlf1axitgME3T+iyuW6OFb1foRzN8="; + }; + + meta = { + homepage = "https://github.com/anki-code/xontrib-sh"; + description = "Paste and run commands from bash, zsh, fish, tcsh in xonsh shell."; + license = pkgs.lib.licenses.mit; + maintainers = [ "cswimr" ]; + }; +})