mirror of
https://github.com/RGBCube/ncc
synced 2025-07-28 02:27:44 +00:00
shells: init
This commit is contained in:
parent
4a90dba591
commit
5a699752fd
11 changed files with 99 additions and 55 deletions
|
@ -1,62 +1,20 @@
|
||||||
{ config, lib, pkgs, ... }: let
|
{ 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 {
|
in {
|
||||||
environment = optionalAttrs config.isLinux {
|
shells."0" = package;
|
||||||
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.
|
|
||||||
;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
home-manager.sharedModules = [(homeArgs: let
|
home-manager.sharedModules = [(homeArgs: let
|
||||||
config' = homeArgs.config;
|
config' = homeArgs.config;
|
||||||
in {
|
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 {
|
programs.nushell = enabled {
|
||||||
|
inherit package;
|
||||||
|
|
||||||
configFile.text = readFile ./config.nu;
|
configFile.text = readFile ./config.nu;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = /* nu */ ''
|
||||||
$env.LS_COLORS = open ${pkgs.runCommand "ls_colors.txt" {} ''
|
$env.LS_COLORS = open ${config.environment.ls-colors}
|
||||||
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
|
|
||||||
''}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
environmentVariables = let
|
environmentVariables = let
|
||||||
|
|
16
modules/common/shell/aliases.nix
Normal file
16
modules/common/shell/aliases.nix
Normal 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";
|
||||||
|
};
|
||||||
|
}
|
16
modules/common/shell/carapace.nix
Normal file
16
modules/common/shell/carapace.nix
Normal 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;
|
||||||
|
}];
|
||||||
|
}
|
21
modules/common/shell/default.nix
Normal file
21
modules/common/shell/default.nix
Normal 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.
|
||||||
|
}
|
9
modules/common/shell/direnv.nix
Normal file
9
modules/common/shell/direnv.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ lib, ... }: let
|
||||||
|
inherit (lib) enabled;
|
||||||
|
in {
|
||||||
|
home-manager.sharedModules = [{
|
||||||
|
programs.direnv = enabled {
|
||||||
|
nix-direnv = enabled;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
}
|
9
modules/common/shell/vivid.nix
Normal file
9
modules/common/shell/vivid.nix
Normal 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;
|
||||||
|
}
|
9
modules/common/shell/zoxide.nix
Normal file
9
modules/common/shell/zoxide.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ lib, ... }: let
|
||||||
|
inherit (lib) enabled;
|
||||||
|
in {
|
||||||
|
home-manager.sharedModules = [{
|
||||||
|
programs.zoxide = enabled {
|
||||||
|
options = [ "--cmd cd" ];
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
{ pkgs, ... }: {
|
|
||||||
users.defaultUserShell = pkgs.crash;
|
|
||||||
}
|
|
9
modules/linux/shell/default.nix
Normal file
9
modules/linux/shell/default.nix
Normal 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 ":";
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue