diff --git a/hosts/desktop/.desktop/default.nix b/hosts/desktop/.desktop/default.nix new file mode 100644 index 0000000..3cef266 --- /dev/null +++ b/hosts/desktop/.desktop/default.nix @@ -0,0 +1,14 @@ +{ pkgs, config, ... }: + +let + cfg = config.desktop; +in +{ + imports = [ + ./scripts/desktop.nix + ./scripts/nixi.nix + ./scripts/nixx.nix + ]; + options.desktop = { }; + config = { }; +} diff --git a/hosts/desktop/.desktop/scripts/desktop.nix b/hosts/desktop/.desktop/scripts/desktop.nix new file mode 100644 index 0000000..7706e66 --- /dev/null +++ b/hosts/desktop/.desktop/scripts/desktop.nix @@ -0,0 +1,51 @@ +{ pkgs, ... }: + +let + desktop = pkgs.writeShellScriptBin "desktop" '' + function cat() { + echo $1 | ${pkgs.lolcat}/bin/lolcat + echo "" + } + flakeDir="/home/guz" + + function nix-build() { + local env="$2" + + if [[ "$env" -ne "" ]]; then + cat "Building the $env desktop!" + sudo nixos-rebuild switch --flake "$flakeDir/.nix#desktop@$env" + else + cat "Building the desktop!" + sudo nixos-rebuild switch --flake "$flakeDir/.nix#desktop@default" + fi + } + + # command for switching desktop environments/modes + function desktop-switch() { + local env="$1" + + if [[ "$env" == "--build" ]]; then + nix-build $env $2 + else + cat "Switching to $1 desktop!" + + # this will be used a lot, that's why "test" and --fast is passed + # for building to a new configuration, use nix-build instead + sudo nixos-rebuild test --fast --flake "$flakeDir/.nix#desktop@$env" + fi + } + desktop-switch $1 $2 + + echo "" + cat "Done!" + + echo "Restarting zsh" + exec zsh + ''; +in +{ + home.packages = [ + desktop + ]; +} + diff --git a/hosts/desktop/.desktop/scripts/nixi.nix b/hosts/desktop/.desktop/scripts/nixi.nix new file mode 100644 index 0000000..40a9756 --- /dev/null +++ b/hosts/desktop/.desktop/scripts/nixi.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: + +let + nixi = pkgs.writeShellScriptBin "nixi" '' + # npm-like command for nix + function nix-shell() { + local pkg="$1" + nix shell "nixpkgs#$pkg" + } + nix-shell $1 + ''; +in +{ + home.packages = [ + nixi + ]; +} + + diff --git a/hosts/desktop/.desktop/scripts/nixx.nix b/hosts/desktop/.desktop/scripts/nixx.nix new file mode 100644 index 0000000..f003463 --- /dev/null +++ b/hosts/desktop/.desktop/scripts/nixx.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +let + nixx = pkgs.writeShellScriptBin "nixx" '' + # npx-like command for nix + function nix-run() { + local pkg="$1" + nix run "nixpkgs#$pkg" + } + nix-run $1 + ''; +in +{ + home.packages = [ + nixx + ]; +} diff --git a/hosts/desktop/shared-home.nix b/hosts/desktop/shared-home.nix index eb2f473..5bf6a88 100644 --- a/hosts/desktop/shared-home.nix +++ b/hosts/desktop/shared-home.nix @@ -3,10 +3,11 @@ { imports = [ ../../modules/home-manager/theme.nix - ../../modules/home-manager/config/terminal.nix ../../modules/home-manager/programs/librewolf + ./terminal.nix ./wm.nix ./keybinds.nix + ./.desktop ]; programs.bash = { diff --git a/modules/home-manager/config/terminal.nix b/hosts/desktop/terminal.nix similarity index 65% rename from modules/home-manager/config/terminal.nix rename to hosts/desktop/terminal.nix index 965039b..e9f72bd 100644 --- a/modules/home-manager/config/terminal.nix +++ b/hosts/desktop/terminal.nix @@ -2,12 +2,12 @@ { imports = [ - ../programs/starship.nix - ../programs/tmux.nix - ../programs/wezterm.nix - ../programs/zsh.nix + ../../modules/home-manager/programs/starship.nix + ../../modules/home-manager/programs/tmux.nix + ../../modules/home-manager/programs/wezterm.nix + ../../modules/home-manager/programs/zsh.nix ]; - options = { }; + options.terminal = { }; config = { starship.enable = true; starship.enableZsh = true; diff --git a/modules/home-manager/programs/zsh.nix b/modules/home-manager/programs/zsh.nix index 3c42ff4..9733037 100644 --- a/modules/home-manager/programs/zsh.nix +++ b/modules/home-manager/programs/zsh.nix @@ -4,24 +4,61 @@ let cfg = config.zsh; in { - options.zsh = { - enable = lib.mkEnableOption "Enable Zsh shell"; + options.zsh = with lib; with lib.types; { + enable = mkEnableOption "Enable Zsh shell"; plugins = { - suggestions.enable = lib.mkOption { - type = lib.types.bool; + suggestions.enable = mkOption { + type = bool; default = true; }; - completion.enable = lib.mkOption { - type = lib.types.bool; + completion.enable = mkOption { + type = bool; default = true; }; }; + extraConfig = { + init = mkOption { + type = lines; + default = ""; + }; + beforeComp = mkOption { + type = lines; + default = ""; + }; + first = mkOption { + type = lines; + default = ""; + }; + }; + loginExtra = mkOption { + type = lines; + default = ""; + }; + logoutExtra = mkOption { + type = lines; + default = ""; + }; + variables = mkOption { + type = attrsOf str; + default = { }; + }; }; config = lib.mkIf cfg.enable { - programs.zsh.enable = true; - programs.zsh.oh-my-zsh.enable = true; + programs.zsh = { + enable = true; + oh-my-zsh.enable = true; - programs.zsh.enableAutosuggestions = lib.mkIf (cfg.plugins.suggestions.enable) true; - programs.zsh.enableCompletion = lib.mkIf (cfg.plugins.completion.enable) true; + loginExtra = cfg.loginExtra; + logoutExtra = cfg.logoutExtra; + + initExtra = cfg.extraConfig.init; + initExtraBeforeCompInit = cfg.extraConfig.beforeComp; + initExtraFirst = cfg.extraConfig.first; + + localVariables = cfg.variables; + + enableAutosuggestions = lib.mkIf (cfg.plugins.suggestions.enable) true; + enableCompletion = lib.mkIf (cfg.plugins.completion.enable) true; + }; }; }