From 396aee7db9fc79f15dc1205abaf87731dc15b4ea Mon Sep 17 00:00:00 2001 From: Matt Nish-Lapidus Date: Mon, 30 Jun 2025 02:12:23 -0400 Subject: [PATCH] refactoring and nushell --- flake.lock | 197 ++++++++++++++---- flake.nix | 11 + hosts/eddie/configuration.nix | 12 +- hosts/eddie/packages.nix | 1 + modules/home/shell-conf.nix | 52 +---- modules/home/shell-conf/fish.nix | 32 +++ modules/home/shell-conf/fish/fish.nix | 30 +++ .../home/shell-conf/fish/functions/lg.fish | 4 - modules/home/shell-conf/nushell.nix | 29 +++ modules/home/shell-conf/nushell/nushell.nix | 25 +++ 10 files changed, 301 insertions(+), 92 deletions(-) create mode 100644 modules/home/shell-conf/fish.nix create mode 100644 modules/home/shell-conf/fish/fish.nix delete mode 100644 modules/home/shell-conf/fish/functions/lg.fish create mode 100644 modules/home/shell-conf/nushell.nix create mode 100644 modules/home/shell-conf/nushell/nushell.nix diff --git a/flake.lock b/flake.lock index ae0d5e4..60bd092 100644 --- a/flake.lock +++ b/flake.lock @@ -23,6 +23,53 @@ "type": "github" } }, + "bash-env-json": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739453597, + "narHash": "sha256-gyqj5r11DOfXd23LT7qwRLEoWvpHUbxbd28QJnlWTaQ=", + "owner": "tesujimath", + "repo": "bash-env-json", + "rev": "0a02cf14cb7ff975c9eab9e77fae3413e61a91af", + "type": "github" + }, + "original": { + "owner": "tesujimath", + "ref": "main", + "repo": "bash-env-json", + "type": "github" + } + }, + "bash-env-nushell": { + "inputs": { + "bash-env-json": [ + "bash-env-json" + ], + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739453743, + "narHash": "sha256-CqcDKfQSKA2MK204KrbR2/hF1DRuY/sE1bO8XOLj+Ww=", + "owner": "tesujimath", + "repo": "bash-env-nushell", + "rev": "4699a7236934140af6b4b181a2f679a80ea16379", + "type": "github" + }, + "original": { + "owner": "tesujimath", + "ref": "main", + "repo": "bash-env-nushell", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -90,11 +137,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1751216990, - "narHash": "sha256-KMcGSznyttkf3C2Gv4LNCPYOfvjj7Qk/Mu2Og2yCsbk=", + "lastModified": 1751250385, + "narHash": "sha256-+jWCrLW15eNsfzppVpPkd7Th7b1Dx+aKQfHPzYxzLWY=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "562e5da816da90627ed5775d4ba6f968bde0ff57", + "rev": "28a7010a46ee17016c9b37be86f4ce4796c47a71", "type": "github" }, "original": { @@ -265,6 +312,24 @@ "inputs": { "systems": "systems" }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", @@ -279,34 +344,16 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_4" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "flake-utils_3": { "inputs": { - "systems": "systems_5" + "systems": "systems_3" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -333,6 +380,42 @@ "type": "github" } }, + "flake-utils_5": { + "inputs": { + "systems": "systems_7" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_6": { + "inputs": { + "systems": "systems_8" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "freetype2": { "flake": false, "locked": { @@ -502,7 +585,7 @@ "pyproject-build-systems": "pyproject-build-systems", "pyproject-nix": "pyproject-nix", "systemd-nix": "systemd-nix", - "systems": "systems_2", + "systems": "systems_4", "uv2nix": "uv2nix" }, "locked": { @@ -653,7 +736,7 @@ "nix-appimage": { "inputs": { "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_3", "nixpkgs": "nixpkgs_4" }, "locked": { @@ -709,7 +792,7 @@ "nixpkgs" ], "nixpkgs-lib": "nixpkgs-lib_3", - "systems": "systems_3" + "systems": "systems_5" }, "locked": { "lastModified": 1748538518, @@ -1036,6 +1119,8 @@ "root": { "inputs": { "affinity-nix": "affinity-nix", + "bash-env-json": "bash-env-json", + "bash-env-nushell": "bash-env-nushell", "disko": "disko", "emacs-lsp-booster": "emacs-lsp-booster", "emacs-overlay": "emacs-overlay", @@ -1180,16 +1265,16 @@ }, "systems_2": { "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default-linux", + "repo": "default", "type": "github" } }, @@ -1210,16 +1295,16 @@ }, "systems_4": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "default-linux", "type": "github" } }, @@ -1253,6 +1338,36 @@ "type": "github" } }, + "systems_7": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_8": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": "nixpkgs_3" @@ -1375,7 +1490,7 @@ }, "wezterm": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_4", "freetype2": "freetype2", "harfbuzz": "harfbuzz", "libpng": "libpng", @@ -1401,7 +1516,7 @@ }, "xwayland-satellite": { "inputs": { - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_5", "nixpkgs": [ "nixpkgs" ], @@ -1456,7 +1571,7 @@ }, "yazi": { "inputs": { - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_6", "nixpkgs": [ "nixpkgs" ], diff --git a/flake.nix b/flake.nix index d2816c0..3157d46 100644 --- a/flake.nix +++ b/flake.nix @@ -73,6 +73,17 @@ url = "github:wez/wezterm?dir=nix"; }; + bash-env-json = { + url = "github:tesujimath/bash-env-json/main"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + bash-env-nushell = { + url = "github:tesujimath/bash-env-nushell/main"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.bash-env-json.follows = "bash-env-json"; + }; + sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hosts/eddie/configuration.nix b/hosts/eddie/configuration.nix index 1db880e..0d06763 100644 --- a/hosts/eddie/configuration.nix +++ b/hosts/eddie/configuration.nix @@ -43,6 +43,11 @@ }); }) + (final: prev: { + bash-env-json = inputs.bash-env-json.packages.x86_64-linux.default; + bash-env-nushell = inputs.bash-env-nushell.packages.x86_64-linux.default; + }) + (final: prev: { manifold = prev.manifold.overrideAttrs (old: { cmakeFlags = [ @@ -344,15 +349,16 @@ programs.java.enable = true; - # enable fish and launch it from bash for interactive shells + # enable alternate shells and launch it from bash for interactive shells programs.fish.enable = true; - environment.pathsToLink = [ "/share/fish" ]; + # environment.pathsToLink = [ "/share/fish" ]; + environment.shells = [ pkgs.nushell ]; programs.bash = { interactiveShellInit = '' if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] then shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + exec ${pkgs.nushell}/bin/nu $LOGIN_OPTION fi ''; }; diff --git a/hosts/eddie/packages.nix b/hosts/eddie/packages.nix index 4238cc3..e9e3a65 100644 --- a/hosts/eddie/packages.nix +++ b/hosts/eddie/packages.nix @@ -35,5 +35,6 @@ gnomeExtensions.appindicator gnome-settings-daemon swayidle + nushell ]; } diff --git a/modules/home/shell-conf.nix b/modules/home/shell-conf.nix index 2b59cf5..f3ac747 100644 --- a/modules/home/shell-conf.nix +++ b/modules/home/shell-conf.nix @@ -1,6 +1,11 @@ -{ pkgs-local, pkgs-stable, inputs, pkgs, ... }: +{ config, lib, pkgs-stable, inputs, pkgs, ... }: { + imports = [ + ./shell-conf/nushell/nushell.nix + ./shell-conf/fish/fish.nix + ]; + home.packages = with pkgs; [ inputs.isd.packages.x86_64-linux.default @@ -87,6 +92,8 @@ fishPlugins.colored-man-pages television + bash-env-json + bash-env-nushell ]; programs = { @@ -95,7 +102,6 @@ }; nix-index = { enable = true; - enableFishIntegration = true; }; direnv = { enable = true; @@ -106,44 +112,10 @@ }; }; }; - nushell = { - enable = true; - }; - fish = { - enable = true; - shellAliases = { - "em" = "emacsclient -n -r"; - "mkdir" = "mkdir -pv"; - "gt" = "gtrash"; - "rm" = "gtrash put"; - }; - - # change fzf variable search to C-M-v - interactiveShellInit = '' - bind --erase \ct - fzf_configure_bindings --variables=\e\cv - ''; - - plugins = [ - { - name = "upto"; - src = pkgs.fetchFromGitHub { - owner = "Markcial"; - repo = "upto"; - rev = "2d1f35453fb55747d50da8c1cb1809840f99a646"; - sha256 = "sha256-Lv2XtP2x9dkIkUUjMBWVpAs/l55Ztu7gIjKYH6ZzK4s="; - }; - } - ]; - }; zoxide = { - enableFishIntegration = true; - enableBashIntegration = true; enable = true; }; starship = { - enableFishIntegration = true; - enableBashIntegration = true; enable = true; }; ripgrep = { @@ -152,13 +124,9 @@ }; ghostty = { enable = true; - # settings = { - # theme = ""; - # }; }; wezterm = { enable = true; - enableBashIntegration = true; package = inputs.wezterm.packages.${pkgs.system}.default; }; bat = { @@ -166,8 +134,6 @@ }; eza = { enable = true; - enableFishIntegration = true; - enableBashIntegration = true; git = true; icons = "auto"; colors = "auto"; @@ -177,8 +143,6 @@ }; fzf = { enable = true; - # enableFishIntegration = false; - # enableBashIntegration = true; }; broot = { enable = true; diff --git a/modules/home/shell-conf/fish.nix b/modules/home/shell-conf/fish.nix new file mode 100644 index 0000000..8112b88 --- /dev/null +++ b/modules/home/shell-conf/fish.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +{ + programs.fish = { + enable = true; + shellAliases = { + "em" = "emacsclient -n -r"; + "mkdir" = "mkdir -pv"; + "gtr" = "gtrash -r"; + "rmr" = "gtrash -r"; + "rm" = "gtrash put"; + "lg" = "lazygit"; + }; + + # change fzf variable search to C-M-v + interactiveShellInit = '' + bind --erase \ct + fzf_configure_bindings --variables=\e\cv + ''; + plugins = [ + { + name = "upto"; + src = pkgs.fetchFromGitHub { + owner = "Markcial"; + repo = "upto"; + rev = "2d1f35453fb55747d50da8c1cb1809840f99a646"; + sha256 = "sha256-Lv2XtP2x9dkIkUUjMBWVpAs/l55Ztu7gIjKYH6ZzK4s="; + }; + } + ]; + }; +} diff --git a/modules/home/shell-conf/fish/fish.nix b/modules/home/shell-conf/fish/fish.nix new file mode 100644 index 0000000..3d60ac9 --- /dev/null +++ b/modules/home/shell-conf/fish/fish.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +{ + programs.fish = { + enable = true; + shellAliases = { + "em" = "emacsclient -n -r"; + "mkdir" = "mkdir -pv"; + "gtr" = "gtrash -r"; + "rm" = "gtrash put"; + }; + + # change fzf variable search to C-M-v + interactiveShellInit = '' + bind --erase \ct + fzf_configure_bindings --variables=\e\cv + ''; + plugins = [ + { + name = "upto"; + src = pkgs.fetchFromGitHub { + owner = "Markcial"; + repo = "upto"; + rev = "2d1f35453fb55747d50da8c1cb1809840f99a646"; + sha256 = "sha256-Lv2XtP2x9dkIkUUjMBWVpAs/l55Ztu7gIjKYH6ZzK4s="; + }; + } + ]; + }; +} diff --git a/modules/home/shell-conf/fish/functions/lg.fish b/modules/home/shell-conf/fish/functions/lg.fish deleted file mode 100644 index 8737a82..0000000 --- a/modules/home/shell-conf/fish/functions/lg.fish +++ /dev/null @@ -1,4 +0,0 @@ -function lg --wraps=lazygit --description 'alias lg=lazygit' - lazygit $argv - -end diff --git a/modules/home/shell-conf/nushell.nix b/modules/home/shell-conf/nushell.nix new file mode 100644 index 0000000..f220896 --- /dev/null +++ b/modules/home/shell-conf/nushell.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +{ + programs.nushell = { + enable = true; + shellAliases = { + "em" = "emacsclient -n -r"; + "gtr" = "gtrash -r"; + "rm" = "gtrash put"; + "rmr" = "gtrash -r"; + "lg" = "lazygit"; + }; + + loginFile.text = '' + ${pkgs.figlet}/bin/figlet -f ($env.HOME)/.local/share/flf/wavy.flf (hostname) + ''; + + environmentVariables = { + ENV_CONVERSIONS.PATH = { + from_string = lib.hm.nushell.mkNushellInline "{|s| $s | split row (char esep) }"; + to_string = lib.hm.nushell.mkNushellInline "{|v| $v | str join (char esep) }"; + }; + }; + + settings = { + show_banner = false; + }; + }; +} diff --git a/modules/home/shell-conf/nushell/nushell.nix b/modules/home/shell-conf/nushell/nushell.nix new file mode 100644 index 0000000..b50dceb --- /dev/null +++ b/modules/home/shell-conf/nushell/nushell.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: + +{ + programs.nushell = { + enable = true; + shellAliases = { + "em" = "emacsclient -n -r"; + "gtr" = "gtrash -r"; + "rm" = "gtrash put"; + }; + + loginFile.text = '' + ${pkgs.figlet}/bin/figlet -f ($env.HOME)/.local/share/flf/wavy.flf (hostname) + ''; + environmentVariables = { + ENV_CONVERSIONS.PATH = { + from_string = lib.hm.nushell.mkNushellInline "{|s| $s | split row (char esep) }"; + to_string = lib.hm.nushell.mkNushellInline "{|v| $v | str join (char esep) }"; + }; + }; + settings = { + show_banner = false; + }; + }; +}