From 30faa1f2bf7f5d845580338f435cccc984808ef2 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Wed, 17 Apr 2024 09:42:55 +0200 Subject: [PATCH] Modularize the shell config --- hosts/seb-laptop/default.nix | 1 + hosts/seb-laptop/hardware.nix | 2 - modules/home/default.nix | 2 +- modules/home/shell.nix | 70 ------------------------- modules/home/shell/default.nix | 25 +++++++++ modules/home/shell/direnv.nix | 13 +++++ modules/home/shell/enhancedCommands.nix | 24 +++++++++ modules/home/shell/nixAliases.nix | 16 ++++++ modules/home/shell/starship.nix | 23 ++++++++ users/seb/home.nix | 2 +- 10 files changed, 104 insertions(+), 74 deletions(-) delete mode 100644 modules/home/shell.nix create mode 100644 modules/home/shell/default.nix create mode 100644 modules/home/shell/direnv.nix create mode 100644 modules/home/shell/enhancedCommands.nix create mode 100644 modules/home/shell/nixAliases.nix create mode 100644 modules/home/shell/starship.nix diff --git a/hosts/seb-laptop/default.nix b/hosts/seb-laptop/default.nix index 1fd5978..d604704 100644 --- a/hosts/seb-laptop/default.nix +++ b/hosts/seb-laptop/default.nix @@ -34,5 +34,6 @@ boot.kernelPackages = pkgs.linuxPackages_latest; + services.auto-cpufreq.enable = true; hardware.brillo.enable = true; } diff --git a/hosts/seb-laptop/hardware.nix b/hosts/seb-laptop/hardware.nix index 67b3fb8..1555c58 100644 --- a/hosts/seb-laptop/hardware.nix +++ b/hosts/seb-laptop/hardware.nix @@ -18,6 +18,4 @@ boot.kernelModules = ["kvm-amd"]; nixpkgs.hostPlatform = "x86_64-linux"; hardware.cpu.amd.updateMicrocode = true; - - services.auto-cpufreq.enable = true; } diff --git a/modules/home/default.nix b/modules/home/default.nix index b91b325..6f8deaf 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -2,7 +2,7 @@ imports = [ ./de ./vscode.nix - ./shell.nix + ./shell ./ssh-client.nix ./git.nix ./neovim.nix diff --git a/modules/home/shell.nix b/modules/home/shell.nix deleted file mode 100644 index 2219779..0000000 --- a/modules/home/shell.nix +++ /dev/null @@ -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"]; - }; - }) - ]; -} diff --git a/modules/home/shell/default.nix b/modules/home/shell/default.nix new file mode 100644 index 0000000..6340c42 --- /dev/null +++ b/modules/home/shell/default.nix @@ -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; + }; +} diff --git a/modules/home/shell/direnv.nix b/modules/home/shell/direnv.nix new file mode 100644 index 0000000..beb554a --- /dev/null +++ b/modules/home/shell/direnv.nix @@ -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; + }; +} diff --git a/modules/home/shell/enhancedCommands.nix b/modules/home/shell/enhancedCommands.nix new file mode 100644 index 0000000..11adbdd --- /dev/null +++ b/modules/home/shell/enhancedCommands.nix @@ -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"]; + }; + }; +} diff --git a/modules/home/shell/nixAliases.nix b/modules/home/shell/nixAliases.nix new file mode 100644 index 0000000..b25ebfb --- /dev/null +++ b/modules/home/shell/nixAliases.nix @@ -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"; + }; +} diff --git a/modules/home/shell/starship.nix b/modules/home/shell/starship.nix new file mode 100644 index 0000000..ca827fb --- /dev/null +++ b/modules/home/shell/starship.nix @@ -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; + }; + }; + }; +} diff --git a/users/seb/home.nix b/users/seb/home.nix index 4363681..d5e0741 100644 --- a/users/seb/home.nix +++ b/users/seb/home.nix @@ -21,7 +21,7 @@ bash.enable = true; starship.enable = true; nixAliases.enable = true; - improvedCommands.enable = true; + enhancedCommands.enable = true; direnv.enable = true; };