Skip to content

Commit

Permalink
fix(shell:aliases|nu): workaround to support exa aliases option
Browse files Browse the repository at this point in the history
  • Loading branch information
montchr committed Sep 11, 2023
1 parent 6459296 commit 4d1cbd6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions profiles/homeProfiles/shells/nushell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
inherit (config.home) username sessionVariables;
l = flake.inputs.nixpkgs.lib // builtins;

# FIXME: hardcoded
exaCfg = config.programs.exa;

# FIXME: hardcoded -- note also that we can't rely on variable expansion to resolve paths in env.nu
userConfigDir = "~/.config/dotfield/users/${username}/config/nushell";

/*
@partial
replaceVars :: [String] -> (String -> String)
*/
replaceVars = names:
l.replaceStrings
(l.map (v: "$" + v) names)
(l.map (v: "$env.${v}") names);

/*
replaceVars' :: String -> String
*/
replaceVars' = replaceVars commonNames;

commonNames = [
"HOME"
"EDITOR"
Expand All @@ -37,7 +45,7 @@
lib.concatStringsSep "\n"
(lib.mapAttrsToList
(name: value: let
value' = replaceVars commonNames value;
value' = replaceVars' value;
in "$env.${name} = `${value'}`")
attrs);
in {
Expand All @@ -63,4 +71,14 @@ in {
xdg.configFile."nushell/home.nu".source = pkgs.writeText "home.nu" ''
${attrsToEnvDecls sessionVariables}
'';

# FIXME: needs PR to upstream `exa` module for fix to use
# `home.shellAliases`, not shell-specific options
home.shellAliases = lib.mkIf (exaCfg.enable && exaCfg.enableAliases) {
ls = "exa";
ll = "exa -l";
la = "exa -a";
lt = "exa --tree";
lla = "exa -la";
};
}

0 comments on commit 4d1cbd6

Please sign in to comment.