diff --git a/flake.nix b/flake.nix index 4acdd82..209b84c 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ nixosConfigurations = { miku = mkSystem { + bluray = true; hostConfigFile = ./hosts/miku.nix; }; mashu = mkSystem { diff --git a/hosts/miku.nix b/hosts/miku.nix index 14455b9..6eaa563 100644 --- a/hosts/miku.nix +++ b/hosts/miku.nix @@ -43,12 +43,16 @@ gnome-podcasts #psst + handbrake + vlc + # Proprietary stuff (yikes) discord-wrapped discord-app-wrapped spotify-wrapped ]; ptw = { programs = { + bluray.enable = true; mpv = { primaryScreen = "C27F398"; enable = true; diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 836d139..0fc10a1 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -15,6 +15,7 @@ Idea: Make miku.nix, mashu.nix, ... have the following structure { hostConfigFile , architecture ? "x86_64-linux" +, bluray ? false }: let pkgs = inputs.nixpkgs; config = pkgs.lib; @@ -43,7 +44,9 @@ in inputs.nixpkgs.lib.nixosSystem { emacs.overlay (import ../packages) (import ../overlays/simple.nix) - + ] + ++ lib.optional bluray (import ../overlays/bluray.nix) + ++ [ # Always keep sandbox.nix as the last overlay (import ../overlays/sandbox.nix) ]; diff --git a/modules/default.nix b/modules/default.nix index b5034f5..e8f9012 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -23,6 +23,7 @@ ./programs/plasma ./programs/office ./programs/gaming + ./programs/bluray # Services ./services/kanshi diff --git a/modules/programs/bluray/default.nix b/modules/programs/bluray/default.nix new file mode 100644 index 0000000..bf70fe3 --- /dev/null +++ b/modules/programs/bluray/default.nix @@ -0,0 +1,15 @@ +{ pkgs, config, lib, ... }: + +let + cfg = config.ptw.programs.bluray; +in { + options.ptw.programs.bluray = { + enable = lib.mkEnableOption "Enable bluray playback and decoding. Will rebuild a lot of packages"; + }; + + config = lib.mkIf cfg.enable { + nixpkgs.config.overlays = [ + (import ../../../overlays/bluray.nix) + ]; + }; +} diff --git a/modules/programs/mpv/default.nix b/modules/programs/mpv/default.nix index 3da40fd..1a8fdfb 100644 --- a/modules/programs/mpv/default.nix +++ b/modules/programs/mpv/default.nix @@ -1,12 +1,14 @@ { config, lib, pkgs, ... }: let + mkAnime4kShader = shader: "${pkgs.anime4k}/usr/share/shaders/${shader}"; + mkDefaultShader = shader: "${pkgs.mpv-shader-pack}/usr/share/shaders/${shader}"; makeMpvProfile = { shader, additional ? {} }: { - glsl-shaders = "${pkgs.anime4k}/usr/share/shaders/${shader}"; + glsl-shaders = shader; scale = "ewa_lanczossharp"; cscale = "ewa_lanczossharp"; gpu-context = "wayland"; - gpu-api = "opengl"; + gpu-api = "vulkan"; hwdec = "vaapi"; vo = "gpu"; video-sync = "display-resample"; @@ -15,8 +17,7 @@ let } // additional // (if config.ptw.programs.mpv != "" then { # Make mpv pop up on the primary screen screen-name = config.ptw.programs.mpv.primaryScreen; - fs-screen-name = config.ptw.programs.mpv.primaryScreen; - } else {}); + fs-screen-name = config.ptw.programs.mpv.primaryScreen;} else {}); cfg = config.ptw.programs.mpv; in { options.ptw.programs.mpv = { @@ -38,15 +39,22 @@ in { script-opts = "try_ytdl_first=no"; }; defaultProfiles = [ "anime" ]; + scripts = with pkgs; [ mpvScripts_sub-export ]; profiles = { anime = (makeMpvProfile { - shader = "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; + shader = mkAnime4kShader "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; additional = { fullscreen = ""; }; }); - "anime-denoise" = (makeMpvProfile { - shader = "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; + anime-denoise = (makeMpvProfile { + shader = mkAnime4kShader "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; + }); + non-anime = (makeMpvProfile { + shader = mkDefaultShader "FSRCNNX_x2_8-0-4-1.glsl"; + }); + non-anime-strong = (makeMpvProfile { + shader = mkDefaultShader "FSRCNNX_x2_16-0-4-1.glsl"; }); }; }; diff --git a/overlays/bluray.nix b/overlays/bluray.nix new file mode 100644 index 0000000..e9115c2 --- /dev/null +++ b/overlays/bluray.nix @@ -0,0 +1,29 @@ +final: prev: + +let + overrideWithAACS = pkgName: prev."${pkgName}".overrideAttrs (old: { + buildInputs = with prev; old.buildInputs ++ [ libaacs ]; + }); +in { + libbluray = prev.libbluray.override { + withAACS = true; + withBDplus = true; + }; + + mpvUnwrapped = prev.mpvUnwrapped.overrideAttrs (old: { + buildInputs = with prev; old.buildInputs ++ [ libaacs ]; + }); + + vlc = prev.vlc.overrideAttrs (old: { + buildInputs = with prev; old.buildInputs ++ [ libaacs ]; + }); + + handbrake = prev.handbrake.overrideAttrs (old: { + buildInputs = with prev; old.buildInputs ++ [ libaacs ]; + }); + + /* + mpvUnwrapped = overrideWithAACS "mpvUnwrapped"; + handbrake = overrideWithAACS "handbrake"; + */ +} diff --git a/overlays/simple.nix b/overlays/simple.nix index 445cbb1..707b94d 100644 --- a/overlays/simple.nix +++ b/overlays/simple.nix @@ -1,15 +1,6 @@ final: prev: { - /* - mpv = prev.wrapMpv mpv { - # Prevent the need for prefixing mpv with DRI_PRIME=1 - extraMakeWrapperArgs = [ - "--set" "DRI_PRIME" "1" - ]; - }; - */ - gajim = prev.gajim.overrideAttrs (old: { # Enable notification sounds propagatedBuildInputs = old.propagatedBuildInputs ++ [ prev.gsound ]; @@ -68,18 +59,6 @@ final: prev: ]; }); - # TODO: Remove once upstream has a new version tagged - kasts-git = prev.libsForQt5.kasts.overrideAttrs (old: { - src = let - commit = "b39be0118ef6ff587b433af185c584f3d5bcec30"; - in builtins.fetchTarball { - url = "https://invent.kde.org/plasma-mobile/kasts/-/archive/${commit}/kasts-${commit}.tar.gz"; - sha256 = "06myymbwj89357cpg7phha1x8q84mlhcy4f44pdkqmg7lkd5a6df"; - }; - - buildInputs = old.buildInputs ++ [ prev.taglib prev.libsForQt5.qtkeychain ]; - }); - xournalpp-git = prev.xournalpp.overrideAttrs (old: { version = "1.1.1"; src = prev.fetchFromGitHub { diff --git a/packages/default.nix b/packages/default.nix index 06b03b5..640d9b7 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -25,6 +25,7 @@ in { evdev-proxy = prev.callPackage ./tools/virtualisation/evdev-proxy {}; virtiofsd = prev.callPackage ./tools/virtualisation/virtiofsd {}; anime4k = prev.callPackage ./misc/video/anime4k {}; + mpv-shader-pack = prev.callPackage ./misc/video/mpv-shader-pack {}; anime-dl = prev.callPackage ./tools/video/animedl { pySmartDL = pySmartDL; cfscrape = cfscrape; diff --git a/packages/misc/video/anime4k/default.nix b/packages/misc/video/anime4k/default.nix index 4c64508..6d656ce 100644 --- a/packages/misc/video/anime4k/default.nix +++ b/packages/misc/video/anime4k/default.nix @@ -16,10 +16,10 @@ stdenv.mkDerivation rec { ''; meta = with lib; { - description = "A High-Quality Real Time Upscaler for Anime Video "; - homepage = "A High-Quality Real Time Upscaler for Anime Video "; + description = "A High-Quality Real Time Upscaler for Anime Video"; + homepage = "https://bloc97.github.io/Anime4K/"; license = licenses.mit; maintainers = [ ]; - platforms = platforms.linux; + platforms = platforms.all; }; } diff --git a/packages/misc/video/mpv-prescalers/default.nix b/packages/misc/video/mpv-prescalers/default.nix new file mode 100644 index 0000000..9d9c9c2 --- /dev/null +++ b/packages/misc/video/mpv-prescalers/default.nix @@ -0,0 +1,25 @@ +{ stdenv, lib, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "mpv-prescalers"; + version = "20211110"; + + src = fetchFromGitHub { + owner = "bjin"; + repo = "mpv-prescalers"; + rev = "cc02ed95c1fe05b72bc21d41257c4c085e6e409b"; + sha256 = "1gc1ka9i7xzxq58175q5svhvp8vr27hy477r4z4nkhp9q1cqj19d"; + }; + + installPhase = '' + find . -type f -iname '*.hook' -exec install -Dm 644 {} -t $out/usr/share/shaders/ \; + ''; + + meta = with lib; { + description = "prescalers for mpv, as user shaders"; + homepage = "https://github.com/bjin/mpv-prescalers"; + license = licenses.gpl3; + maintainers = [ ]; + platforms = platforms.all; + }; +} diff --git a/packages/misc/video/mpv-shader-pack/default.nix b/packages/misc/video/mpv-shader-pack/default.nix new file mode 100644 index 0000000..982b992 --- /dev/null +++ b/packages/misc/video/mpv-shader-pack/default.nix @@ -0,0 +1,30 @@ +{ stdenv, lib, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "mpv-shader-pack"; + version = "2.0.0"; + + src = fetchFromGitHub { + owner = "iwalton3"; + repo = "default-shader-pack"; + rev = "v${version}"; + sha256 = "10383h2qq35whj3v1vs34yyqiflxjf1vlv2p4l6jrmljwpjpcj4k"; + }; + + buildPhase = '' + # Packaged by the anime4k package + rm shaders/Anime4K_*.glsl + ''; + + installPhase = '' + find ./shaders -type f -exec install -Dm 644 {} -t $out/usr/share/shaders/ \; + ''; + + meta = with lib; { + description = "Preconfigured set of MPV shaders and configurations for MPV Shim media clients."; + homepage = "https://github.com/iwalton3/default-shader-pack"; + license = licenses.gpl3; + maintainers = [ ]; + platforms = platforms.all; + }; +}