From 437137b5bae471c167f14d60c79a703c6c9275c1 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 5 May 2024 22:00:46 -0400 Subject: [PATCH] home: added default apps module --- aly.nix | 1 + dustin.nix | 1 + flake.nix | 2 +- homeManagerModules/apps/neovim/default.nix | 1 - homeManagerModules/apps/vsCodium/default.nix | 2 +- homeManagerModules/apps/waybar/default.nix | 2 +- homeManagerModules/desktop/default.nix | 2 +- homeManagerModules/desktop/defaultApps.nix | 115 ++++++++++++++++--- homeManagerModules/desktop/hypr/default.nix | 9 +- homeManagerModules/desktop/river/default.nix | 15 ++- homeManagerModules/desktop/sway/default.nix | 11 +- 11 files changed, 125 insertions(+), 36 deletions(-) diff --git a/aly.nix b/aly.nix index 07490949..c8a90381 100644 --- a/aly.nix +++ b/aly.nix @@ -39,6 +39,7 @@ alyraffauf = { services.syncthing.enable = false; desktop = { + defaultApps.enable = true; hyprland = { enable = true; hyprpaper.randomWallpaper = false; diff --git a/dustin.nix b/dustin.nix index 735832fe..3c545471 100644 --- a/dustin.nix +++ b/dustin.nix @@ -27,6 +27,7 @@ alyraffauf = { desktop = { + defaultApps.enable = true; hyprland = { enable = true; hyprpaper.randomWallpaper = false; diff --git a/flake.nix b/flake.nix index ec827f33..2f71ee44 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,7 @@ }; nixConfig = { - extra-substituters = ["https://nixcache.raffauflabs.com" ]; + extra-substituters = ["https://nixcache.raffauflabs.com"]; extra-trusted-public-keys = [ "nixcache.raffauflabs.com:yFIuJde/izA4aUDI3MZmBLzynEsqVCT1OfCUghOLlt8=" ]; diff --git a/homeManagerModules/apps/neovim/default.nix b/homeManagerModules/apps/neovim/default.nix index 65ce290d..5a63796e 100644 --- a/homeManagerModules/apps/neovim/default.nix +++ b/homeManagerModules/apps/neovim/default.nix @@ -11,7 +11,6 @@ enable = true; viAlias = true; vimAlias = true; - defaultEditor = true; }; }; } diff --git a/homeManagerModules/apps/vsCodium/default.nix b/homeManagerModules/apps/vsCodium/default.nix index 33c66d3e..844d5cfb 100644 --- a/homeManagerModules/apps/vsCodium/default.nix +++ b/homeManagerModules/apps/vsCodium/default.nix @@ -24,7 +24,7 @@ "git.autofetch" = true; "git.confirmSync" = false; "nix.formatterPath" = lib.getExe pkgs.alejandra; - "terminal.external.linuxExec" = lib.getExe pkgs.alacritty; + "terminal.external.linuxExec" = config.alyraffauf.desktop.defaultApps.terminal.exe; "update.mode" = "none"; "window.menuBarVisibility" = "hidden"; "window.zoomPerWindow" = false; diff --git a/homeManagerModules/apps/waybar/default.nix b/homeManagerModules/apps/waybar/default.nix index b2255658..8b83dc44 100644 --- a/homeManagerModules/apps/waybar/default.nix +++ b/homeManagerModules/apps/waybar/default.nix @@ -213,7 +213,7 @@ "tooltip-format-wifi" = "{essid} ({signalStrength}%) {icon}"; "tooltip-format-ethernet" = "{ifname} "; "tooltip-format-disconnected" = "Disconnected"; - "on-click" = "${lib.getExe pkgs.alacritty} --class nmtui -e ${pkgs.networkmanager}/bin/nmtui"; + "on-click" = "${config.alyraffauf.desktop.defaultApps.terminalEditor.exe} --class nmtui -e ${pkgs.networkmanager}/bin/nmtui"; }; "tray" = {"spacing" = 15;}; "custom/logout" = { diff --git a/homeManagerModules/desktop/default.nix b/homeManagerModules/desktop/default.nix index 64a5a5e0..7f65c9b7 100644 --- a/homeManagerModules/desktop/default.nix +++ b/homeManagerModules/desktop/default.nix @@ -4,5 +4,5 @@ pkgs, ... }: { - imports = [./theme.nix ./gnome ./hypr ./sway ./river]; + imports = [./defaultApps.nix ./theme.nix ./gnome ./hypr ./sway ./river]; } diff --git a/homeManagerModules/desktop/defaultApps.nix b/homeManagerModules/desktop/defaultApps.nix index 894c8188..e9d5d849 100644 --- a/homeManagerModules/desktop/defaultApps.nix +++ b/homeManagerModules/desktop/defaultApps.nix @@ -7,10 +7,10 @@ options = { alyraffauf.desktop.defaultApps.enable = lib.mkEnableOption "GTK and Qt themes."; - alyraffauf.desktop.defaultApps.browser = { - name = lib.mkOption { + alyraffauf.desktop.defaultApps.webBrowser = { + exe = lib.mkOption { description = "Default web browser executable name."; - default = "firefox"; + default = lib.getExe config.alyraffauf.desktop.defaultApps.webBrowser.package; type = lib.types.str; }; desktop = lib.mkOption { @@ -20,14 +20,14 @@ }; package = lib.mkOption { description = "Default web browser package."; - default = pkgs.firefox; + default = config.programs.firefox.package; type = lib.types.package; }; }; alyraffauf.desktop.defaultApps.editor = { - name = lib.mkOption { + exe = lib.mkOption { description = "Default editor executable name."; - default = "codium"; + default = lib.getExe config.alyraffauf.desktop.defaultApps.editor.package; type = lib.types.str; }; desktop = lib.mkOption { @@ -37,28 +37,109 @@ }; package = lib.mkOption { description = "Default editor package."; - default = pkgs.vsCodium; + default = config.programs.vscode.package; + type = lib.types.package; + }; + }; + alyraffauf.desktop.defaultApps.terminalEditor = { + exe = lib.mkOption { + description = "Default terminal editor executable name."; + default = lib.getExe config.alyraffauf.desktop.defaultApps.terminalEditor.package; + type = lib.types.str; + }; + desktop = lib.mkOption { + description = "Default terminal editor desktop file name."; + default = "nvim.desktop"; + type = lib.types.str; + }; + package = lib.mkOption { + description = "Default terminal editor package."; + default = config.programs.neovim.package; + type = lib.types.package; + }; + }; + alyraffauf.desktop.defaultApps.terminal = { + exe = lib.mkOption { + description = "Default terminal executable name."; + default = lib.getExe config.alyraffauf.desktop.defaultApps.terminal.package; + type = lib.types.str; + }; + desktop = lib.mkOption { + description = "Default terminal desktop file name."; + default = "alacritty.desktop"; + type = lib.types.str; + }; + package = lib.mkOption { + description = "Default terminal package."; + default = config.programs.alacritty.package; + type = lib.types.package; + }; + }; + alyraffauf.desktop.defaultApps.imageViewer = { + exe = lib.mkOption { + description = "Default image viewer executable name."; + default = lib.getExe config.alyraffauf.desktop.defaultApps.imageViewer.package; + type = lib.types.str; + }; + desktop = lib.mkOption { + description = "Default image viewer desktop file name."; + default = "org.gnome.eog.desktop"; + type = lib.types.str; + }; + package = lib.mkOption { + description = "Default image viewer package."; + default = pkgs.gnome.eog; + type = lib.types.package; + }; + }; + alyraffauf.desktop.defaultApps.pdfEditor = { + exe = lib.mkOption { + description = "Default PDF editor executable name."; + default = lib.getExe config.alyraffauf.desktop.defaultApps.pdfEditor.package; + type = lib.types.str; + }; + desktop = lib.mkOption { + description = "Default PDF Editor desktop file name."; + default = "org.gnome.Evince.desktop"; + type = lib.types.str; + }; + package = lib.mkOption { + description = "Default PDF Editor package."; + default = pkgs.evince; type = lib.types.package; }; }; }; - config = lib.mkIf config.alyraffauf.desktop.theme.enable { + config = lib.mkIf config.alyraffauf.desktop.defaultApps.enable { + home.packages = with pkgs; [ + config.alyraffauf.desktop.defaultApps.pdfEditor.package + config.alyraffauf.desktop.defaultApps.editor.package + config.alyraffauf.desktop.defaultApps.terminalEditor.package + config.alyraffauf.desktop.defaultApps.imageViewer.package + config.alyraffauf.desktop.defaultApps.webBrowser.package + ]; xdg.mimeApps = { enable = true; defaultApplications = { - "application/xhtml+xml" = "firefox.desktop"; - "text/html" = "firefox.desktop"; - "text/xml" = "firefox.desktop"; - "x-scheme-handler/ftp" = "firefox.desktop"; - "x-scheme-handler/http" = "firefox.desktop"; - "x-scheme-handler/https" = "firefox.desktop"; + "application/pdf" = config.alyraffauf.desktop.defaultApps.pdfEditor.desktop; + "application/x-shellscript" = config.alyraffauf.desktop.defaultApps.editor.desktop; + "application/xhtml+xml" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; + "image/jpeg" = config.alyraffauf.desktop.defaultApps.imageViewer.desktop; + "image/png" = config.alyraffauf.desktop.defaultApps.imageViewer.desktop; + "text/html" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; + "text/plain" = config.alyraffauf.desktop.defaultApps.editor.desktop; + "text/x-python" = config.alyraffauf.desktop.defaultApps.editor.desktop; + "text/xml" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; + "x-scheme-handler/ftp" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; + "x-scheme-handler/http" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; + "x-scheme-handler/https" = config.alyraffauf.desktop.defaultApps.webBrowser.desktop; }; }; home.sessionVariables = { - EDITOR = "${lib.getExe pkgs.neovim}"; - BROWSER = "${lib.getExe pkgs.firefox}"; - TERMINAL = "${lib.getExe pkgs.kitty}"; + EDITOR = "${config.alyraffauf.desktop.defaultApps.terminalEditor.exe}"; + BROWSER = "${config.alyraffauf.desktop.defaultApps.webBrowser.exe}"; + TERMINAL = "${config.alyraffauf.desktop.defaultApps.terminal.exe}"; }; }; } diff --git a/homeManagerModules/desktop/hypr/default.nix b/homeManagerModules/desktop/hypr/default.nix index 0d6f3680..13c3e10b 100644 --- a/homeManagerModules/desktop/hypr/default.nix +++ b/homeManagerModules/desktop/hypr/default.nix @@ -29,6 +29,7 @@ hyprshade.enable = lib.mkDefault true; }; theme.enable = lib.mkDefault true; + defaultApps.enable = lib.mkDefault true; }; apps = { # Basic apps needed to run a hyprland desktop. @@ -63,10 +64,10 @@ modifier = "SUPER"; # Default apps - browser = lib.getExe pkgs.firefox; + browser = config.alyraffauf.desktop.defaultApps.webBrowser.exe; fileManager = lib.getExe pkgs.xfce.thunar; - editor = lib.getExe pkgs.vscodium; - terminal = lib.getExe pkgs.alacritty; + editor = config.alyraffauf.desktop.defaultApps.editor.exe; + terminal = config.alyraffauf.desktop.defaultApps.terminal.exe; # Media/hardware commands # brightness = "${lib.getExe pkgs.brightnessctl}"; @@ -114,7 +115,7 @@ hyprnome = lib.getExe pkgs.hyprnome; hyprshade = lib.getExe pkgs.hyprshade; - screenshot = lib.getExe pkgs.hyprshot; + screenshot = lib.getExe pkgs.hyprshot; screenshot_folder = "~/pics/screenshots"; screenshot_screen = "${screenshot} -m output -o ${screenshot_folder}"; screenshot_region = "${screenshot} -m region -o ${screenshot_folder}"; diff --git a/homeManagerModules/desktop/river/default.nix b/homeManagerModules/desktop/river/default.nix index 0456cf22..53d00b9d 100644 --- a/homeManagerModules/desktop/river/default.nix +++ b/homeManagerModules/desktop/river/default.nix @@ -32,8 +32,11 @@ firefox.enable = lib.mkDefault true; kanshi.enable = lib.mkDefault true; }; - desktop.river.randomWallpaper = lib.mkDefault true; - desktop.theme.enable = lib.mkDefault true; + desktop = { + river.randomWallpaper = lib.mkDefault true; + theme.enable = lib.mkDefault true; + defaultApps.enable = lib.mkDefault true; + }; }; programs.swaylock.enable = lib.mkDefault true; @@ -108,10 +111,10 @@ modifier = "Super"; # Default apps - browser = pkgs.firefox + "/bin/firefox"; - fileManager = pkgs.xfce.thunar + "/bin/thunar"; - editor = pkgs.vscodium + "/bin/codium"; - terminal = pkgs.alacritty + "/bin/alacritty"; + browser = config.alyraffauf.desktop.defaultApps.webBrowser.exe; + fileManager = lib.getExe pkgs.xfce.thunar; + editor = config.alyraffauf.desktop.defaultApps.editor.exe; + terminal = config.alyraffauf.desktop.defaultApps.terminal.exe; # River desktop utilities bar = pkgs.waybar + "/bin/waybar"; diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index 9f0b949e..d41707c6 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -27,7 +27,10 @@ waybar.enable = lib.mkDefault true; wlogout.enable = lib.mkDefault true; }; - desktop.theme.enable = lib.mkDefault true; + desktop = { + theme.enable = lib.mkDefault true; + defaultApps.enable = lib.mkDefault true; + }; }; services.cliphist.enable = lib.mkDefault true; @@ -49,10 +52,10 @@ modifier = "Mod4"; # Default apps - browser = lib.getExe pkgs.firefox; + browser = config.alyraffauf.desktop.defaultApps.webBrowser.exe; fileManager = lib.getExe pkgs.xfce.thunar; - editor = lib.getExe pkgs.vscodium; - terminal = lib.getExe pkgs.alacritty; + editor = config.alyraffauf.desktop.defaultApps.editor.exe; + terminal = config.alyraffauf.desktop.defaultApps.terminal.exe; brightness = lib.getExe' pkgs.swayosd "swayosd-client"; brightness_up = "${brightness} --brightness=raise";