From d56f98b568caf05657281b6b8a6d7bdb8d17df69 Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 18 May 2023 18:30:10 +0200 Subject: [PATCH] refactor: move mime types to respective configs --- home/apps/browsers.nix | 7 +++++++ home/apps/{music.nix => media.nix} | 18 +++++++++++++----- home/apps/vscode.nix | 1 + home/default.nix | 2 +- home/xdg.nix | 24 +++++++----------------- 5 files changed, 29 insertions(+), 23 deletions(-) rename home/apps/{music.nix => media.nix} (85%) diff --git a/home/apps/browsers.nix b/home/apps/browsers.nix index aa80d3b..6befa9d 100644 --- a/home/apps/browsers.nix +++ b/home/apps/browsers.nix @@ -155,4 +155,11 @@ in { }; }; }; + xdg.mimeApps.defaultApplications = { + "text/html" = "firefox.desktop"; + "x-scheme-handler/http" = "firefox.desktop"; + "x-scheme-handler/https" = "firefox.desktop"; + "x-scheme-handler/about" = "firefox.desktop"; + "x-scheme-handler/unknown" = "firefox.desktop"; + }; } diff --git a/home/apps/music.nix b/home/apps/media.nix similarity index 85% rename from home/apps/music.nix rename to home/apps/media.nix index 4ba4f8c..dd8923c 100644 --- a/home/apps/music.nix +++ b/home/apps/media.nix @@ -6,8 +6,17 @@ }: let inherit (pkgs.stdenv.hostPlatform) isLinux; in { + programs.mpv.enable = isLinux; + xdg.mimeApps.defaultApplications = { + "video/mp4" = "mpv.desktop"; + "video/webm" = "mpv.desktop"; + }; + programs.zathura.enable = true; + xdg.mimeApps.defaultApplications."application/pdf" = "zathura.desktop"; + programs.ncmpcpp = { enable = true; + settings."lyrics_directory" = "${config.xdg.dataHome}/ncmpcpp"; bindings = lib.mapAttrsToList (key: command: {inherit key command;}) { @@ -28,10 +37,10 @@ in { }; }; - services = { - mpd.enable = isLinux; + services = lib.mkIf isLinux { + mpd.enable = true; mpd-discord-rpc = { - enable = isLinux; + enable = true; settings = { format = { state = "$artist"; @@ -42,6 +51,7 @@ in { }; }; }; + mpd-mpris.enable = true; }; launchd.agents.mpd = { @@ -74,8 +84,6 @@ in { }; }; - #home.packages = lib.mkIf isLinux [pkgs.cider]; - launchd.agents.discord-applemusic-rich-presence = { enable = true; config = { diff --git a/home/apps/vscode.nix b/home/apps/vscode.nix index b3366b5..08b9c99 100644 --- a/home/apps/vscode.nix +++ b/home/apps/vscode.nix @@ -33,4 +33,5 @@ in { source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/settings.json"; }; }; + xdg.mimeApps.defaultApplications."text/plain" = "code.desktop"; } diff --git a/home/default.nix b/home/default.nix index 2b27cbc..85c579e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -16,7 +16,7 @@ in { ./apps/kubernetes.nix ./apps/macos.nix ./apps/mail.nix - ./apps/music.nix + ./apps/media.nix ./apps/neovim.nix ./apps/newsboat.nix ./apps/rice.nix diff --git a/home/xdg.nix b/home/xdg.nix index 5e5dee6..52c0745 100644 --- a/home/xdg.nix +++ b/home/xdg.nix @@ -10,6 +10,7 @@ inherit (config.home) homeDirectory; in { home = rec { + packages = [pkgs.sccache]; sessionVariables = { AZURE_CONFIG_DIR = "${configHome}/azure"; CARGO_HOME = "${dataHome}/cargo"; @@ -20,11 +21,15 @@ in { GEM_HOME = "${dataHome}/gem"; GEM_SPEC_CACHE = "${cacheHome}/gem"; GOPATH = "${dataHome}/go"; - NPM_CONFIG_USERCONFIG = "${configHome}/npm/npmrc"; NODE_REPL_HISTORY = "${dataHome}/node_repl_history"; + NPM_CONFIG_USERCONFIG = "${configHome}/npm/npmrc"; + RUSTC_WRAPPER = "sccache"; RUSTUP_HOME = "${dataHome}/rustup"; + W3M_DIR = "${dataHome}/w3m"; WINEPREFIX = "${dataHome}/wine"; + XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority"; XCOMPOSECACHE = "${cacheHome}/X11/xcompose"; + XINITRC = "${configHome}/X11/xinitrc"; }; sessionPath = [ "$HOME/.local/bin" @@ -32,12 +37,7 @@ in { "${sessionVariables.GOPATH}/bin" "${sessionVariables.CARGO_HOME}/bin" ]; - packages = [pkgs.sccache]; }; - xdg.configFile."cargo/config".text = '' - [build] - rustc-wrapper = "sccache" - ''; # NOTE: workaround for gpgme on Darwin, since GUI apps aren't aware of $GNUPGHOME programs.gpg.homedir = @@ -53,17 +53,7 @@ in { dataHome = "${homeDirectory}/.local/share"; mimeApps = { enable = isLinux; - defaultApplications = { - "inode/directory" = "thunar.desktop"; - "application/pdf" = "zathura.desktop"; - - "text/plain" = "code.desktop"; - "text/html" = "firefox.desktop"; - "x-scheme-handler/http" = "firefox.desktop"; - "x-scheme-handler/https" = "firefox.desktop"; - "x-scheme-handler/about" = "firefox.desktop"; - "x-scheme-handler/unknown" = "firefox.desktop"; - }; + defaultApplications."inode/directory" = "thunar.desktop"; }; }; }