Compare commits
No commits in common. "4f57f67555e22fa77a7166762fa081130e32b69f" and "d9a2100e69b45852da494560183f204149a18044" have entirely different histories.
4f57f67555
...
d9a2100e69
2 changed files with 1 additions and 163 deletions
|
@ -1,9 +1,6 @@
|
|||
{config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./generic/mpv.nix
|
||||
];
|
||||
config = {
|
||||
services.printing.enable = true;
|
||||
|
||||
|
@ -22,79 +19,10 @@
|
|||
|
||||
environment.systemPackages = with pkgs; [
|
||||
kdePackages.kdeconnect-kde
|
||||
mpv
|
||||
pcmanfm
|
||||
];
|
||||
|
||||
programs.mpv = let
|
||||
fetchMpvScript = {url, hash, scriptName}: pkgs.fetchurl {
|
||||
inherit url hash;
|
||||
name = "mpv-script-${scriptName}";
|
||||
recursiveHash = true;
|
||||
downloadToTemp = true;
|
||||
postFetch = ''
|
||||
mkdir -p $out/share/mpv/scripts
|
||||
mv $downloadedFile $out/share/mpv/scripts/${scriptName}
|
||||
'';
|
||||
passthru.scriptName = scriptName;
|
||||
};
|
||||
in {
|
||||
enable = true;
|
||||
scripts = [
|
||||
pkgs.mpvScripts.sponsorblock
|
||||
pkgs.mpvScripts.mpris
|
||||
] ++ lib.map (script: fetchMpvScript {
|
||||
url = "https://raw.githubusercontent.com/occivink/mpv-scripts/d0390c8e802c2e888ff4a2e1d5e4fb040f855b89/scripts/${script.name}";
|
||||
hash = script.hash;
|
||||
scriptName = script.name;
|
||||
}) [
|
||||
{ name = "crop.lua"; hash = "sha256-/uaTCtV8Aanvnxrt8afBbO4uu2xp8Ec6DxApMb+fg2s="; }
|
||||
{ name = "encode.lua"; hash = "sha256-yK/DV0cpGhl4Uobl7xA1myZiECJpsShrHnsJftBqzAY="; }
|
||||
];
|
||||
settings = {
|
||||
mpv = {
|
||||
keep-open = "yes";
|
||||
volume = "40";
|
||||
osd-fractions = "yes";
|
||||
background = "0.0/1.0";
|
||||
alpha = "yes";
|
||||
};
|
||||
input = lib.mkMerge [
|
||||
# mpv core
|
||||
''
|
||||
Alt+1 set window-scale 0.125
|
||||
Alt+2 set window-scale 0.25
|
||||
Alt+3 set window-scale 0.5
|
||||
Alt+4 set window-scale 1
|
||||
Alt+5 set window-scale 2
|
||||
''
|
||||
# crop.lua
|
||||
''
|
||||
c script-message-to crop start-crop hard
|
||||
alt+c script-message-to crop start-crop soft
|
||||
ctrl+shift+c script-message-to crop start-crop delogo
|
||||
C script-message-to crop toggle-crop hard
|
||||
''
|
||||
# encode.lua
|
||||
''
|
||||
b script-message-to encode encode_default
|
||||
alt+b script-message-to encode set-timestamp encode_default
|
||||
''
|
||||
];
|
||||
script-opts = {
|
||||
"encode_default.conf" = {
|
||||
only_active_tracks = "no";
|
||||
preserve_filters = "yes";
|
||||
append_filder = "";
|
||||
codec = "";
|
||||
output_format = "$f_$n.$x";
|
||||
output_dir = "/tmp";
|
||||
detached = "no";
|
||||
ffmpeg_command = lib.getExe pkgs.ffmpeg;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh.extraConfig = ''
|
||||
X11Forwarding yes
|
||||
'';
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
{config, lib, options, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.mpv;
|
||||
opts = options.programs.mpv;
|
||||
|
||||
toMpvIniString = attrset: lib.pipe attrset [
|
||||
(lib.mapAttrsToList (name: value: "${name}=${value}"))
|
||||
(lib.concatStringsSep "\n")
|
||||
];
|
||||
|
||||
configDir = pkgs.symlinkJoin {
|
||||
name = "mpv-config-dir";
|
||||
paths = lib.optional opts.settings.mpv.isDefined (pkgs.writeTextFile {
|
||||
name = "mpv-config-dir-mpv.conf";
|
||||
destination = "/share/mpv/mpv.conf";
|
||||
text = toMpvIniString cfg.settings.mpv;
|
||||
}) ++ lib.optional opts.settings.input.isDefined (pkgs.writeTextFile {
|
||||
name = "mpv-config-dir-input.conf";
|
||||
destination = "/share/mpv/input.conf";
|
||||
text = cfg.settings.input;
|
||||
}) ++ lib.mapAttrsToList (filename: opts: pkgs.writeTextFile {
|
||||
name = "mpv-config-dir-script-opts-${filename}";
|
||||
destination = "/share/mpv/script-opts/${filename}";
|
||||
text = toMpvIniString opts;
|
||||
}) cfg.settings.script-opts;
|
||||
};
|
||||
|
||||
wrappedMpv = pkgs.wrapMpv cfg.package {
|
||||
youtubeSupport = cfg.youtubeSupport;
|
||||
scripts = cfg.scripts;
|
||||
extraMakeWrapperArgs = lib.optionals (lib.any (x: x) [
|
||||
opts.settings.mpv.isDefined
|
||||
opts.settings.input.isDefined
|
||||
(lib.length (lib.attrNames cfg.settings.script-opts) > 0)
|
||||
]) [
|
||||
"--add-flags" "--config-dir='${configDir}/share/mpv'"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
options.programs.mpv = {
|
||||
enable = lib.mkEnableOption "mpv";
|
||||
package = lib.mkPackageOption pkgs "mpv-unwrapped" {};
|
||||
scripts = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.package;
|
||||
default = [];
|
||||
};
|
||||
youtubeSupport = lib.mkEnableOption "yt-dlp support for mpv" // {
|
||||
default = true;
|
||||
};
|
||||
settings = let
|
||||
mpvini = lib.types.attrsOf lib.types.str;
|
||||
in {
|
||||
script-opts = lib.mkOption {
|
||||
type = lib.types.attrsOf mpvini;
|
||||
default = {};
|
||||
example = {
|
||||
"crop.conf".draw_crosshair = "yes";
|
||||
};
|
||||
description = ''
|
||||
A map of script options for mpv scripts.
|
||||
The key is the filename of the script, and the value is a map of options.
|
||||
'';
|
||||
};
|
||||
input = lib.mkOption {
|
||||
type = lib.types.separatedString "\n";
|
||||
example = ''
|
||||
Alt+1 set window-scale 0.125
|
||||
'';
|
||||
description = ''
|
||||
A list of input commands to be added to the input.conf file.
|
||||
'';
|
||||
};
|
||||
mpv = lib.mkOption {
|
||||
type = mpvini;
|
||||
example = {
|
||||
keep-open = "yes";
|
||||
osd-fractions = "yes";
|
||||
};
|
||||
description = ''
|
||||
A map of mpv options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ wrappedMpv ];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue