Modularize the shell config

This commit is contained in:
SebastianStork 2024-04-17 09:42:55 +02:00
parent cbebff390c
commit 30faa1f2bf
10 changed files with 104 additions and 74 deletions

View file

@ -34,5 +34,6 @@
boot.kernelPackages = pkgs.linuxPackages_latest;
services.auto-cpufreq.enable = true;
hardware.brillo.enable = true;
}

View file

@ -18,6 +18,4 @@
boot.kernelModules = ["kvm-amd"];
nixpkgs.hostPlatform = "x86_64-linux";
hardware.cpu.amd.updateMicrocode = true;
services.auto-cpufreq.enable = true;
}

View file

@ -2,7 +2,7 @@
imports = [
./de
./vscode.nix
./shell.nix
./shell
./ssh-client.nix
./git.nix
./neovim.nix

View file

@ -1,70 +0,0 @@
{
config,
lib,
...
}: let
cfg = config.myConfig.shell;
in {
options.myConfig.shell = {
bash.enable = lib.mkEnableOption "";
zsh.enable = lib.mkEnableOption "";
starship.enable = lib.mkEnableOption "";
nixAliases.enable = lib.mkEnableOption "";
improvedCommands.enable = lib.mkEnableOption "";
direnv.enable = lib.mkEnableOption "";
};
config = lib.mkMerge [
{
programs.bash.enable = cfg.bash.enable;
programs.zsh.enable = cfg.zsh.enable;
programs.starship = lib.mkIf cfg.starship.enable {
enable = true;
enableBashIntegration = cfg.bash.enable;
enableZshIntegration = cfg.zsh.enable;
settings = {
cmd_duration.disabled = true;
directory = {
truncation_length = 0;
truncation_symbol = "/";
truncate_to_repo = false;
};
};
};
programs.direnv = lib.mkIf cfg.direnv.enable {
enable = true;
nix-direnv.enable = true;
config.global.hide_env_diff = true;
};
home.shellAliases = lib.mkIf cfg.nixAliases.enable {
nr = "sudo -v && nixos-rebuild --flake $FLAKE --use-remote-sudo";
nrs = "nr switch";
nrt = "nr test";
nrb = "nr boot";
nrrb = "nrb && reboot";
nu = "nix flake update";
};
}
(lib.mkIf cfg.improvedCommands.enable {
programs.lsd = {
enable = true;
enableAliases = true;
};
programs.bat.enable = true;
home.shellAliases.cat = "bat -p";
programs.fzf.enable = true;
programs.zoxide = {
enable = true;
options = ["--cmd cd"];
};
})
];
}

View file

@ -0,0 +1,25 @@
{
config,
lib,
...
}: let
cfg = config.myConfig.shell;
in {
imports = [
./starship.nix
./direnv.nix
./enhancedCommands.nix
./nixAliases.nix
];
options.myConfig.shell = {
bash.enable = lib.mkEnableOption "";
zsh.enable = lib.mkEnableOption "";
};
config = {
programs.bash.enable = cfg.bash.enable;
programs.zsh.enable = cfg.zsh.enable;
};
}

View file

@ -0,0 +1,13 @@
{
config,
lib,
...
}: {
options.myConfig.shell.direnv.enable = lib.mkEnableOption "";
config.programs.direnv = lib.mkIf config.myConfig.shell.direnv.enable {
enable = true;
nix-direnv.enable = true;
config.global.hide_env_diff = true;
};
}

View file

@ -0,0 +1,24 @@
{
config,
lib,
...
}: {
options.myConfig.shell.enhancedCommands.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.shell.enhancedCommands.enable {
programs.lsd = {
enable = true;
enableAliases = true;
};
programs.bat.enable = true;
home.shellAliases.cat = "bat -p";
programs.fzf.enable = true;
programs.zoxide = {
enable = true;
options = ["--cmd cd"];
};
};
}

View file

@ -0,0 +1,16 @@
{
config,
lib,
...
}: {
options.myConfig.shell.nixAliases.enable = lib.mkEnableOption "";
config.home.shellAliases = lib.mkIf config.myConfig.shell.nixAliases.enable {
nr = "sudo -v && nixos-rebuild --flake $FLAKE --use-remote-sudo";
nrs = "nr switch";
nrt = "nr test";
nrb = "nr boot";
nrrb = "nrb && reboot";
nu = "nix flake update";
};
}

View file

@ -0,0 +1,23 @@
{
config,
lib,
...
}: {
options.myConfig.shell.starship.enable = lib.mkEnableOption "";
config.programs.starship = lib.mkIf config.myConfig.shell.starship.enable {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
settings = {
cmd_duration.disabled = true;
directory = {
truncation_length = 0;
truncation_symbol = "/";
truncate_to_repo = false;
};
};
};
}

View file

@ -21,7 +21,7 @@
bash.enable = true;
starship.enable = true;
nixAliases.enable = true;
improvedCommands.enable = true;
enhancedCommands.enable = true;
direnv.enable = true;
};