repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
media.nixNix121 lines3.9 KiBraw download
# modules/home/media.nix — music and video: mpd + rmpc, and mpv.
#
# mpd runs as a user service (starts at login), library ~/Music (the layout
# contract is ~/Music/AGENTS.md), state in ~/.local/share/mpd, PipeWire
# output plus the FIFO rmpc's visualiser reads. It listens on the socket
# $XDG_RUNTIME_DIR/mpd/socket and on 127.0.0.1:6600.
#
# rmpc: the dotfiles' full config (modules/home/rmpc/config.ron: tabs with album art,
# lyrics and cava panes, vim keys, 1-0 tab switching), the Rosé Pine theme
# (modules/home/rmpc/themes/rose-pine.ron) and the LRCLIB lyrics fetcher that runs on
# song change. The Discord presence script was not carried (1.4k lines of
# Python with its own deps; say so if wanted).
#
# mpv: the dotfiles' gpu-next/Vulkan profile with the CfL chroma shader, plus
# uosc (the on-screen UI), thumbfast (seek thumbnails) and mpris (media keys,
# Caelestia's player widget).
{ ... }:
let theme = import ../_palette.nix; in
{
  flake.homeModules.media =
  { config, pkgs, ... }:
  let
    rt = "/run/user/1000";
  in
  {
    services.mpd = {
      enable = true;
      musicDirectory = "${config.home.homeDirectory}/Music";
      playlistDirectory = "${config.xdg.dataHome}/mpd/playlists";
      network = {
        listenAddress = "${rt}/mpd/socket";
        port = 6600;
        startWhenNeeded = false;
      };
      extraConfig = ''
        bind_to_address "127.0.0.1"
        auto_update     "yes"
        restore_paused  "yes"
        audio_output {
          type "pipewire"
          name "PipeWire"
        }
        audio_output {
          type   "fifo"
          name   "Visualizer FIFO"
          path   "${rt}/mpd/fifo"
          format "44100:16:2"
        }
      '';
    };
    # the socket's directory, created by systemd before mpd starts
    systemd.user.services.mpd.Service.RuntimeDirectory = "mpd";

    programs.rmpc = {
      enable = true;
      config = builtins.readFile ./rmpc/config.ron;
    };
    xdg.configFile = {
      "rmpc/themes/rose-pine.ron".text = theme.render (builtins.readFile ./rmpc/themes/rose-pine.ron);
      "rmpc/scripts/fetch-lyrics" = {
        source = ./rmpc/scripts/fetch-lyrics;
        executable = true;
      };
      "mpv/shaders".source = ./mpv/shaders;
    };

    programs.mpv = {
      enable = true;
      scripts = with pkgs.mpvScripts; [ uosc thumbfast mpris ];
      config = {
        vo = "gpu-next";
        gpu-api = "vulkan";
        gpu-context = "waylandvk";
        profile = "high-quality";
        hwdec = "auto";
        scale = "ewa_lanczos4sharpest";
        glsl-shader = "~~/shaders/CfL_Prediction.glsl";
        cscale = "ewa_lanczossharp";
        cscale-antiring = 0.65;
        dscale = "mitchell";
        correct-downscaling = true;
        linear-downscaling = true;
        sigmoid-upscaling = true;
        deband = true;
        deband-iterations = 2;
        deband-threshold = 32;
        deband-range = 12;
        deband-grain = 16;
        dither = "error-diffusion";
        error-diffusion = "burkes";
        dither-depth = 8;
        temporal-dither = false;
        video-sync = "display-resample";
        interpolation = true;
        tscale = "oversample";
        target-colorspace-hint = "auto";
        target-colorspace-hint-mode = "target";
        target-prim = "bt.709";
        target-trc = "srgb";
        gamut-mapping-mode = "perceptual";
        tone-mapping = "auto";
        hdr-compute-peak = true;
        contrast = 4;
        saturation = 5;
        screenshot-format = "png";
        screenshot-high-bit-depth = true;
        screenshot-tag-colorspace = true;
        screenshot-directory = "~/Pictures/mpv";
        osc = false; # uosc replaces it
        border = false;
        save-position-on-quit = true;
        keep-open = true;
        sub-auto = "fuzzy";
        slang = "en,eng";
        alang = "ja,jpn,en,eng";
        ytdl-format = "bestvideo[height<=?1440]+bestaudio/best";
      };
    };
  }
  ;
}