From 6c5c7f2b0004bd89a0428a2e9fa68a0e064dc3ab Mon Sep 17 00:00:00 2001 From: xenofem Date: Sun, 23 Apr 2023 02:19:36 -0400 Subject: [PATCH] Revert "move sub-select.json to global config, remove home-manager dependency" This reverts commit 0047c5f9bef20c2228566c3efac3413b9efb11b2. --- flake.nix | 80 +++++++++++++++++++++---------------------- sub-select-path.patch | 13 ------- 2 files changed, 40 insertions(+), 53 deletions(-) delete mode 100644 sub-select-path.patch diff --git a/flake.nix b/flake.nix index 204716e..19ea799 100644 --- a/flake.nix +++ b/flake.nix @@ -9,13 +9,12 @@ outputs = { self, nixpkgs, utils }: let packages = utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - mpvScript = { owner, repo, rev, sha256, scriptName, patches ? [] }: pkgs.stdenvNoCC.mkDerivation { + mpvScript = { owner, repo, rev, sha256, scriptName }: pkgs.stdenvNoCC.mkDerivation { pname = repo; version = builtins.substring 0 6 rev; src = pkgs.fetchFromGitHub { inherit owner repo rev sha256; }; - inherit patches; dontBuild = true; installPhase = '' install -Dm644 ${scriptName} $out/share/mpv/scripts/${scriptName} @@ -29,9 +28,6 @@ rev = "5d2fb7ab73fc0e36d44109e75c9be26bd42084e2"; sha256 = "0dyh2kyvivj81lrkyqhc3czmi9hqjkh7xg8dqjnnr3kh3yn62dpi"; scriptName = "sub-select.lua"; - patches = [ - ./sub-select-path.patch - ]; }; packages.segment-linking = mpvScript { @@ -59,41 +55,45 @@ pkgs.mkvtoolnix ]; - environment.etc."mpv/script-opts/sub-select.json".text = builtins.toJSON [ - { - alang = "j[ap]n?"; - slang = [ "eng?" "und" ]; - blacklist = [ "sign" ]; - condition = "not sub.forced"; - } - { - alang = "eng?"; - slang = "forced"; - } - { - alang = "eng?"; - slang = "eng?"; - whitelist = [ "sign" "song" ]; - } - { - alang = [ "eng?" "no" ]; - slang = "no"; - } - { - alang = "*"; - slang = "eng?"; - condition = "not sub.forced"; - } - { - alang = "*"; - slang = "und"; - condition = "not sub.forced"; - } - { - alang = "*"; - slang = "forced"; - } - ]; + home-manager.sharedModules = [ ({ config, ... }: { + config = lib.mkIf config.programs.mpv.enable { + xdg.configFile."mpv/script-opts/sub-select.json".text = builtins.toJSON [ + { + alang = "j[ap]n?"; + slang = [ "eng?" "und" ]; + blacklist = [ "sign" ]; + condition = "not sub.forced"; + } + { + alang = "eng?"; + slang = "forced"; + } + { + alang = "eng?"; + slang = "eng?"; + whitelist = [ "sign" "song" ]; + } + { + alang = [ "eng?" "no" ]; + slang = "no"; + } + { + alang = "*"; + slang = "eng?"; + condition = "not sub.forced"; + } + { + alang = "*"; + slang = "und"; + condition = "not sub.forced"; + } + { + alang = "*"; + slang = "forced"; + } + ]; + }; + }) ]; }; }; } diff --git a/sub-select-path.patch b/sub-select-path.patch deleted file mode 100644 index 9f6fb92..0000000 --- a/sub-select-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/sub-select.lua b/sub-select.lua -index f61025b..1d8edc8 100644 ---- a/sub-select.lua -+++ b/sub-select.lua -@@ -73,7 +73,7 @@ local function type_check(val, t, required) - end - - local function setup_prefs() -- local file = assert(io.open(mp.command_native({"expand-path", o.config}) .. "/sub-select.json")) -+ local file = assert(io.open(mp.command_native({"expand-path", o.config .. "/sub-select.json"}))) - local json = file:read("*all") - file:close() - prefs = utils.parse_json(json)