From 5f4fdf1c09ed387e257c6df7c74bda9597ae1d0f Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Thu, 19 Dec 2024 11:11:07 -0500 Subject: [PATCH] home/defaultApps: add forceMimeAssociations option --- homeManagerModules/defaultApps.nix | 21 +++++++++++---------- homeManagerModules/options.nix | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/homeManagerModules/defaultApps.nix b/homeManagerModules/defaultApps.nix index d7d82322..6bba8b55 100644 --- a/homeManagerModules/defaultApps.nix +++ b/homeManagerModules/defaultApps.nix @@ -42,7 +42,7 @@ in { WebBrowser=${builtins.baseNameOf (lib.getExe cfg.webBrowser)} ''; - mimeApps = { + mimeApps = lib.mkIf cfg.forceMimeAssociations { enable = true; defaultApplications = let @@ -93,15 +93,16 @@ in { NoDisplay = "true"; }; }; - in { - defaultAudioPlayer = mkDefaultEntry "Audio Player" cfg.audioPlayer; - defaultEditor = mkDefaultEntry "Editor" cfg.editor; - defaultFileManager = mkDefaultEntry "File Manager" cfg.fileManager; - defaultImageViewer = mkDefaultEntry "Image Viewer" cfg.imageViewer; - defaultPdfViewer = mkDefaultEntry "PDF Viewer" cfg.pdfViewer; - defaultVideoPlayer = mkDefaultEntry "Video Player" cfg.videoPlayer; - defaultWebBrowser = mkDefaultEntry "Web Browser" cfg.webBrowser; - }; + in + lib.mkIf cfg.forceMimeAssociations { + defaultAudioPlayer = mkDefaultEntry "Audio Player" cfg.audioPlayer; + defaultEditor = mkDefaultEntry "Editor" cfg.editor; + defaultFileManager = mkDefaultEntry "File Manager" cfg.fileManager; + defaultImageViewer = mkDefaultEntry "Image Viewer" cfg.imageViewer; + defaultPdfViewer = mkDefaultEntry "PDF Viewer" cfg.pdfViewer; + defaultVideoPlayer = mkDefaultEntry "Video Player" cfg.videoPlayer; + defaultWebBrowser = mkDefaultEntry "Web Browser" cfg.webBrowser; + }; }; }; } diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index 2cd04f9e..34ad57c9 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -77,6 +77,8 @@ in { defaultApps = { enable = lib.mkEnableOption "Declaratively set default apps and file associations."; + forceMimeAssociations = lib.mkEnableOption "Force mime associations for defaultApps."; + audioPlayer = lib.mkPackageOption pkgs "audio player" {default = ["celluloid"];}; editor = lib.mkPackageOption pkgs "text editor" {default = ["vscodium"];}; fileManager = lib.mkPackageOption pkgs "file manager" {default = ["nemo"];};