From 24f35c4ccd2f3228caf27c602bc2973741bdedd2 Mon Sep 17 00:00:00 2001 From: Bloxx12 Date: Wed, 4 Jun 2025 08:29:51 +0200 Subject: [PATCH] shell: stop fish from having to be built every time Drop the patch to fish source code, instead opting to employ fish's inbuilt share/fish/vendor_conf.d to add custom code to fish. This is both a bit simpler, and makes it so fish does not have to be compiled on every update to it's source / to my configuration. --- packages/shell/default.nix | 38 ++++++++++++++++++------------ packages/shell/fish-on-tmpfs.patch | 10 -------- packages/shell/fishinit.nix | 10 ++++++-- 3 files changed, 31 insertions(+), 27 deletions(-) delete mode 100644 packages/shell/fish-on-tmpfs.patch diff --git a/packages/shell/default.nix b/packages/shell/default.nix index 2fdbabc..6d0faa6 100644 --- a/packages/shell/default.nix +++ b/packages/shell/default.nix @@ -1,34 +1,42 @@ -# This shell setup was inspired by sioodmy. Check out his setup! +# This shell setup was originally inspired by sioodmy. +# Some further cool tricks, like using vendor_conf.d to avoid having +# to build fish myself, are taken from viperml's setup. {pkgs, ...}: let + inherit (pkgs) lib; + inherit (lib.strings) concatStringsSep; + inherit (lib.attrsets) mapAttrsToList; + toml = pkgs.formats.toml {}; starship-config = import ./starship.nix; aliases = import ./aliases.nix {inherit pkgs;}; + vendorConf = "share/fish/vendor_conf.d"; - fishinit = import ./fishinit.nix {inherit pkgs aliasesStr;}; + fishinit = import ./fishinit.nix { + inherit + pkgs + aliasesStr + vendorConf + ; + }; aliasesStr = mapAttrsToList (k: v: "alias ${k}=\"${v}\"") aliases |> concatStringsSep "\n"; packages = import ./packages.nix pkgs; - - # this was taken from viperml, check out his config for this! - custom-fish = pkgs.fish.overrideAttrs (old: { - patches = [./fish-on-tmpfs.patch]; - doCheck = false; - postInstall = - old.postInstall - + '' - echo "source ${fishinit}" >> $out/etc/fish/config.fish - ''; - }); in (pkgs.symlinkJoin { name = "fish"; - paths = [custom-fish] ++ packages; + paths = [pkgs.fish] ++ packages; nativeBuildInputs = [pkgs.makeWrapper]; postBuild = '' - wrapProgram $out/bin/fish --set STARSHIP_CONFIG "${toml.generate "starship.toml" starship-config}" \ + wrapProgram $out/bin/fish \ + --set STARSHIP_CONFIG "${toml.generate "starship.toml" starship-config}" \ + --prefix XDG_DATA_DIRS : "${ + lib.makeSearchPathOutput "out" "share" [ + fishinit + ] + }" ''; }) .overrideAttrs (_: { diff --git a/packages/shell/fish-on-tmpfs.patch b/packages/shell/fish-on-tmpfs.patch deleted file mode 100644 index 1ff7c1b..0000000 --- a/packages/shell/fish-on-tmpfs.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/path.rs -+++ b/src/path.rs -@@ -781,7 +781,7 @@ fn get_cache_directory() -> &'static BaseDirectory { - - fn get_config_directory() -> &'static BaseDirectory { - static DIR: Lazy = -- Lazy::new(|| make_base_directory(L!("XDG_CONFIG_HOME"), L!("/.config/fish"))); -+ Lazy::new(|| make_base_directory(L!("XDG_RUNTIME_DIR"), L!("/.config/fish"))); - &DIR - } diff --git a/packages/shell/fishinit.nix b/packages/shell/fishinit.nix index 69c7c6c..b243b06 100644 --- a/packages/shell/fishinit.nix +++ b/packages/shell/fishinit.nix @@ -1,9 +1,11 @@ { pkgs, aliasesStr, + vendorConf, }: -pkgs.writeText "config.fish" '' - +pkgs.writeTextDir "${vendorConf}/blox_config.fish" +# fish +'' # source ${pkgs.fishPlugins.sponge}/share/zsh-defer/zsh-defer.plugin.zsh ${pkgs.atuin}/bin/atuin init fish | source ${pkgs.zoxide}/bin/zoxide init fish | source @@ -11,6 +13,10 @@ pkgs.writeText "config.fish" '' ${pkgs.direnv}/bin/direnv hook fish | source ${pkgs.pay-respects}/bin/pay-respects fish --alias f --nocnf | source + # I need to source /etc/profile using foreign-env, to get stuff set by nixos, e.g. environment.systemVariables. + # set -p fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d + + # fenv source /etc/profile source ${./config.fish}