My NixOS and Home Manager configurations
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

nushell config improvements

quasigod d35d3257 e261b0c3

+48 -50
+48 -50
modules/apps/nushell.nix
··· 9 9 users.users.${user.userName}.shell = pkgs.dash; 10 10 }; 11 11 homeManager = 12 - { pkgs, ... }: 12 + { pkgs, lib, ... }: 13 13 { 14 14 # https://discourse.nixos.org/t/nushell-broken-in-nix-develop/76402/2 15 15 xdg.configFile.dashrc.text = '' ··· 45 45 em = "job spawn { emacsclient -c . }"; 46 46 e = "emacsclient -r"; 47 47 }; 48 - extraConfig = '' 49 - $env.config = { 50 - show_banner: false 51 - rm: { 52 - always_trash: true 48 + settings = { 49 + show_banner = false; 50 + rm.always_trash = true; 51 + display_errors = { 52 + exit_code = false; 53 + termination_signal = true; 54 + }; 55 + completions.algorithm = "substring"; 56 + }; 57 + extraConfig = lib.mkAfter '' 58 + if "INSIDE_EMACS" in $env { 59 + $env.EDITOR = "emacsclient -r" 60 + $env.VISUAL = "emacsclient -r" 61 + } 62 + # zoxide poorly handles trailing / 63 + def --env --wrapped __cd_wrapper (...rest: string) { 64 + let trimmed = if ($rest | is-empty) { 65 + $rest 66 + } else { 67 + $rest | update ($rest | length | $in - 1) { |s| 68 + let t = $s | str trim -r -c '/' 69 + if ($t | is-empty) { '/' } else { $t } 70 + } 53 71 } 54 - display_errors: { 55 - exit_code: false 56 - termination_signal: true 57 - } 58 - completions: { 59 - algorithm: "substring" 60 - } 72 + __zoxide_z ...$trimmed 61 73 } 74 + alias cd = __cd_wrapper 62 75 63 - $env.config.keybindings ++= [ 64 - { 65 - name: deleteword 66 - modifier: control 67 - keycode: backspace 68 - mode: [ emacs vi_normal vi_insert ] 69 - event: { edit: BackspaceWord } 76 + # simpler nix shell command when needing many packages 77 + def --wrapped nxs (...input: string) { 78 + let flags = $input | where ($it | str starts-with "-") 79 + let packages = $input | where not ($it | str starts-with "-") 80 + let formatted_packages = $packages | each {|package| 81 + if not ($package | str contains "#") { 82 + return $"nixpkgs#($package)" 83 + } 84 + $package 70 85 } 71 - ] 72 - if "INSIDE_EMACS" in $env { 73 - $env.EDITOR = "emacsclient -r" 74 - $env.VISUAL = "emacsclient -r" 86 + ^nix shell ...$formatted_packages ...$flags 87 + } 88 + ''; 89 + extraLogin = '' 90 + # fix distrobox path order 91 + if "DISTROBOX_ENTER_PATH" in $env { 92 + let fhs = $env.PATH | where {|p| 93 + ($p | str starts-with "/usr/") or ($p == "/bin") or ($p == "/sbin") 94 + } 95 + let rest = $env.PATH | where {|p| 96 + not (($p | str starts-with "/usr/") or ($p == "/bin") or ($p == "/sbin")) 97 + } 98 + $env.PATH = ($fhs | append $rest) 75 99 } 76 100 ''; 77 101 }; ··· 79 103 enable = true; 80 104 enableNushellIntegration = true; 81 105 }; 82 - }; 83 - xdg.configFile = { 84 - "nushell/autoload/nxs.nu".text = '' 85 - # zoxide poorly handles trailing / 86 - def cd --env --wrapped (...rest: string) { 87 - let trimmed = if ($rest | is-empty) { 88 - $rest 89 - } else { 90 - $rest | update ($rest | length | $in - 1) { str trim -r -c '/' } 91 - } 92 - __zoxide_z ...$trimmed 93 - } 94 - 95 - # faster nix shell command when needing many packages 96 - def --wrapped nxs (...input: string) { 97 - let flags = $input | where ($it | str starts-with "-") 98 - let packages = $input | where not ($it | str starts-with "-") 99 - let formatted_packages = $packages | each {|package| 100 - if not ($package | str contains "#") { 101 - return $"nixpkgs#($package)" 102 - } 103 - $package 104 - } 105 - ^nix shell ...$formatted_packages ...$flags 106 - } 107 - ''; 108 106 }; 109 107 }; 110 108 };