NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor
git clone https://git.daemon-sec.xyz/NixDaemon.git
Log | Files | Refs | README

media.nix (3897B)


      1 # modules/home/media.nix — music and video: mpd + rmpc, and mpv.
      2 #
      3 # mpd runs as a user service (starts at login), library ~/Music (the layout
      4 # contract is ~/Music/AGENTS.md), state in ~/.local/share/mpd, PipeWire
      5 # output plus the FIFO rmpc's visualiser reads. It listens on the socket
      6 # $XDG_RUNTIME_DIR/mpd/socket and on 127.0.0.1:6600.
      7 #
      8 # rmpc: the dotfiles' full config (modules/home/rmpc/config.ron: tabs with album art,
      9 # lyrics and cava panes, vim keys, 1-0 tab switching), the Rosé Pine theme
     10 # (modules/home/rmpc/themes/rose-pine.ron) and the LRCLIB lyrics fetcher that runs on
     11 # song change. The Discord presence script was not carried (1.4k lines of
     12 # Python with its own deps; say so if wanted).
     13 #
     14 # mpv: the dotfiles' gpu-next/Vulkan profile with the CfL chroma shader, plus
     15 # uosc (the on-screen UI), thumbfast (seek thumbnails) and mpris (media keys,
     16 # Caelestia's player widget).
     17 { ... }:
     18 {
     19   flake.homeModules.media =
     20   { config, pkgs, ... }:
     21   let
     22     rt = "/run/user/1000";
     23   in
     24   {
     25     services.mpd = {
     26       enable = true;
     27       musicDirectory = "${config.home.homeDirectory}/Music";
     28       playlistDirectory = "${config.xdg.dataHome}/mpd/playlists";
     29       network = {
     30         listenAddress = "${rt}/mpd/socket";
     31         port = 6600;
     32         startWhenNeeded = false;
     33       };
     34       extraConfig = ''
     35         bind_to_address "127.0.0.1"
     36         auto_update     "yes"
     37         restore_paused  "yes"
     38         audio_output {
     39           type "pipewire"
     40           name "PipeWire"
     41         }
     42         audio_output {
     43           type   "fifo"
     44           name   "Visualizer FIFO"
     45           path   "${rt}/mpd/fifo"
     46           format "44100:16:2"
     47         }
     48       '';
     49     };
     50     # the socket's directory, created by systemd before mpd starts
     51     systemd.user.services.mpd.Service.RuntimeDirectory = "mpd";
     52 
     53     programs.rmpc = {
     54       enable = true;
     55       config = builtins.readFile ./rmpc/config.ron;
     56     };
     57     xdg.configFile = {
     58       "rmpc/themes/rose-pine.ron".source = ./rmpc/themes/rose-pine.ron;
     59       "rmpc/scripts/fetch-lyrics" = {
     60         source = ./rmpc/scripts/fetch-lyrics;
     61         executable = true;
     62       };
     63       "mpv/shaders".source = ./mpv/shaders;
     64     };
     65 
     66     programs.mpv = {
     67       enable = true;
     68       scripts = with pkgs.mpvScripts; [ uosc thumbfast mpris ];
     69       config = {
     70         vo = "gpu-next";
     71         gpu-api = "vulkan";
     72         gpu-context = "waylandvk";
     73         profile = "high-quality";
     74         hwdec = "auto";
     75         scale = "ewa_lanczos4sharpest";
     76         glsl-shader = "~~/shaders/CfL_Prediction.glsl";
     77         cscale = "ewa_lanczossharp";
     78         cscale-antiring = 0.65;
     79         dscale = "mitchell";
     80         correct-downscaling = true;
     81         linear-downscaling = true;
     82         sigmoid-upscaling = true;
     83         deband = true;
     84         deband-iterations = 2;
     85         deband-threshold = 32;
     86         deband-range = 12;
     87         deband-grain = 16;
     88         dither = "error-diffusion";
     89         error-diffusion = "burkes";
     90         dither-depth = 8;
     91         temporal-dither = false;
     92         video-sync = "display-resample";
     93         interpolation = true;
     94         tscale = "oversample";
     95         target-colorspace-hint = "auto";
     96         target-colorspace-hint-mode = "target";
     97         target-prim = "bt.709";
     98         target-trc = "srgb";
     99         gamut-mapping-mode = "perceptual";
    100         tone-mapping = "auto";
    101         hdr-compute-peak = true;
    102         contrast = 4;
    103         saturation = 5;
    104         screenshot-format = "png";
    105         screenshot-high-bit-depth = true;
    106         screenshot-tag-colorspace = true;
    107         screenshot-directory = "~/Pictures/mpv";
    108         osc = false; # uosc replaces it
    109         border = false;
    110         save-position-on-quit = true;
    111         keep-open = true;
    112         sub-auto = "fuzzy";
    113         slang = "en,eng";
    114         alang = "ja,jpn,en,eng";
    115         ytdl-format = "bestvideo[height<=?1440]+bestaudio/best";
    116       };
    117     };
    118   }
    119   ;
    120 }