1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-27 18:17:44 +00:00

shells: init

This commit is contained in:
RGBCube 2025-07-19 21:01:54 +03:00
parent 4a90dba591
commit 5a699752fd
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
11 changed files with 99 additions and 55 deletions

View file

@ -1,62 +1,20 @@
{ config, lib, pkgs, ... }: let
inherit (lib) attrNames attrValues concatStringsSep const enabled filter flatten foldl' getExe head last listToAttrs mapAttrs mapAttrsToList match mkIf nameValuePair optionalAttrs readFile removeAttrs replaceStrings splitString;
inherit (lib) attrNames attrValues concatStringsSep const enabled filter flatten foldl' head last listToAttrs mapAttrs mapAttrsToList match nameValuePair readFile removeAttrs replaceStrings splitString;
package = pkgs.nushell;
in {
environment = optionalAttrs config.isLinux {
sessionVariables.SHELLS = getExe pkgs.nushell;
} // {
shells = mkIf config.isDarwin [ pkgs.nushell ];
shellAliases = {
la = "ls --all";
ll = "ls --long";
lla = "ls --long --all";
sl = "ls";
cp = "cp --recursive --verbose --progress";
mk = "mkdir";
mv = "mv --verbose";
rm = "rm --recursive --verbose";
pstree = "pstree -g 3";
tree = "eza --tree --git-ignore --group-directories-first";
};
systemPackages = attrValues {
inherit (pkgs)
carapace # For completions.
fish # For completions.
zsh # For completions.
inshellisense # For completions.
;
};
};
shells."0" = package;
home-manager.sharedModules = [(homeArgs: let
config' = homeArgs.config;
in {
programs.carapace = enabled {
enableNushellIntegration = true;
};
programs.direnv = enabled {
enableNushellIntegration = true;
nix-direnv = enabled;
};
programs.zoxide = enabled {
enableNushellIntegration = true;
options = [ "--cmd cd" ];
};
programs.nushell = enabled {
inherit package;
configFile.text = readFile ./config.nu;
extraConfig = ''
$env.LS_COLORS = open ${pkgs.runCommand "ls_colors.txt" {} ''
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
''}
extraConfig = /* nu */ ''
$env.LS_COLORS = open ${config.environment.ls-colors}
'';
environmentVariables = let

View file

@ -0,0 +1,16 @@
{
environment.shellAliases = {
la = "ls --all";
ll = "ls --long";
lla = "ls --long --all";
sl = "ls";
cp = "cp --recursive --verbose --progress";
mk = "mkdir";
mv = "mv --verbose";
rm = "rm --recursive --verbose";
pstree = "pstree -g 3";
tree = "eza --tree --git-ignore --group-directories-first";
};
}

View file

@ -0,0 +1,16 @@
{ lib, pkgs, ... }: let
inherit (lib) attrValues enabled;
in {
environment.systemPackages = attrValues {
inherit (pkgs)
carapace
fish
zsh
inshellisense
;
};
home-manager.sharedModules = [{
programs.carapace = enabled;
}];
}

View file

@ -0,0 +1,21 @@
{ config, lib, ... }: let
inherit (lib) attrsToList catAttrs mkConst mkIf mkValue sortOn toInt;
in {
options.shells = mkValue {};
options.shellsByPriority = mkConst (config.shells
|> attrsToList
|> sortOn ({ name, ... }: toInt name)
|> catAttrs "value");
config = mkIf config.isDarwin {
environment.shells = config.shellsByPriority;
};
# More at modules/linux/shell/default.nix.
#
# Can't put that here with an optionalAttributes
# becuase of an infinite recursion error, and can't
# do that with a mkIf because the nix-darwin module
# system doesn't have those attributes.
}

View file

@ -0,0 +1,9 @@
{ lib, ... }: let
inherit (lib) enabled;
in {
home-manager.sharedModules = [{
programs.direnv = enabled {
nix-direnv = enabled;
};
}];
}

View file

@ -0,0 +1,9 @@
{ lib, pkgs, ... }: let
inherit (lib) getExe mkConst;
lsColors = pkgs.runCommand "ls_colors.txt" {} ''
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
'';
in {
options.environment.ls-colors = mkConst lsColors;
}

View file

@ -0,0 +1,9 @@
{ lib, ... }: let
inherit (lib) enabled;
in {
home-manager.sharedModules = [{
programs.zoxide = enabled {
options = [ "--cmd cd" ];
};
}];
}

View file

@ -1,3 +0,0 @@
{ pkgs, ... }: {
users.defaultUserShell = pkgs.crash;
}

View file

@ -0,0 +1,9 @@
{ config, lib, pkgs, ... }: let
inherit (lib) concatStringsSep;
in {
users.defaultUserShell = pkgs.crash;
environment.sessionVariables.SHELLS = config.shellsByPriority
|> map (drv: "${drv}${drv.shellPath}")
|> concatStringsSep ":";
}