From 69940d48d23d38b067f3f8382210c20986031022 Mon Sep 17 00:00:00 2001 From: Lukas Wurzinger Date: Mon, 7 Jul 2025 19:28:29 +0200 Subject: [PATCH] init --- .envrc | 1 + .gitignore | 1 + config/mpv.conf | 32 +++++++++++ flake.lock | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++++ package.nix | 21 +++++++ 6 files changed, 259 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 config/mpv.conf create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/config/mpv.conf b/config/mpv.conf new file mode 100644 index 0000000..d648c10 --- /dev/null +++ b/config/mpv.conf @@ -0,0 +1,32 @@ +# --- Playback --- +save-position-on-quit=yes # Resume playback where you left off +rebase-start-time=no # Show correct timestamps when resuming + +# --- Video quality --- +hwdec=auto-safe # Use safe hardware decoding if available +deband=yes # Reduce color banding artifacts +scale=ewa_lanczossharp # High-quality image scaling +cscale=ewa_lanczossharp # High-quality chroma scaling +video-sync=display-resample # Smooth playback with display timing +interpolation=yes # Frame interpolation for smoother motion +tscale=oversample # Best quality interpolation method + +# --- Audio --- +volume=50 # Default volume (0–100%) +volume-max=150 # Allow boosting volume beyond 100% +af=scaletempo # Keep audio pitch constant when speeding/slowing + +# --- Subtitles --- +sub-auto=fuzzy # Auto-load subs with similar name +sub-font-size=36 # Readable subtitle size +sub-border-size=2 # Border for subtitle readability +sub-shadow-offset=1 # Drop shadow for clarity + +# --- User interface --- +osc=yes # Show on-screen controller +cursor-autohide=1000 # Hide mouse cursor during playback +idle=yes # Stay open after playback ends +screenshot-format=png # Save screenshots as PNG + +# --- Streaming (e.g. YouTube) --- +ytdl-format=bestvideo+bestaudio/best # Best quality from YouTube, etc. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..df8d689 --- /dev/null +++ b/flake.lock @@ -0,0 +1,142 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1751413152, + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1750779888, + "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751792365, + "narHash": "sha256-J1kI6oAj25IG4EdVlg2hQz8NZTBNYvIS0l4wpr9KcUo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1fd8bada0b6117e6c7eb54aad5813023eed37ccb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1751159883, + "narHash": "sha256-urW/Ylk9FIfvXfliA1ywh75yszAbiTEVgpPeinFyVZo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "14a40a1d7fb9afa4739275ac642ed7301a9ba1ab", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "hooks": "hooks", + "nixpkgs": "nixpkgs", + "treefmt": "treefmt" + } + }, + "treefmt": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1750931469, + "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..40e0812 --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "A wrapper for mpv"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + treefmt = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + self, + nixpkgs, + flake-parts, + hooks, + treefmt, + }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + hooks.flakeModule + treefmt.flakeModule + ]; + + systems = nixpkgs.lib.systems.flakeExposed; + + perSystem = + { + config, + pkgs, + ... + }: + { + treefmt = { + projectRootFile = "flake.nix"; + + programs.nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + }; + + pre-commit.settings.hooks = { + treefmt.enable = true; + }; + + devShells.default = pkgs.mkShellNoCC { + shellHook = '' + ${config.pre-commit.installationScript} + ''; + }; + + packages.default = pkgs.callPackage ./package.nix { }; + }; + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..f7e9b78 --- /dev/null +++ b/package.nix @@ -0,0 +1,21 @@ +{ + mpv, + symlinkJoin, + makeWrapper, +}: +symlinkJoin { + inherit (mpv) + name + meta + passthru + ; + + paths = [ mpv ]; + + buildInputs = [ makeWrapper ]; + + postBuild = '' + wrapProgram $out/bin/${mpv.meta.mainProgram} \ + --add-flag --config-dir=${./config} + ''; +}