From f544e22cc0f8107eb1308b8fccb483f09f71e27a Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 18 Feb 2022 17:41:01 -0800 Subject: media: reorganize in multiples modules Add two new modules to synchronize videos and musics to the NAS. --- users/fcuny/desktop/default.nix | 2 +- users/fcuny/desktop/media.nix | 35 ------------------------------- users/fcuny/desktop/media/default.nix | 11 ++++++++++ users/fcuny/desktop/media/mpd.nix | 34 ++++++++++++++++++++++++++++++ users/fcuny/desktop/media/music.nix | 7 +++++++ users/fcuny/desktop/media/sync-music.nix | 30 ++++++++++++++++++++++++++ users/fcuny/desktop/media/sync-videos.nix | 29 +++++++++++++++++++++++++ users/fcuny/desktop/media/videos.nix | 7 +++++++ 8 files changed, 119 insertions(+), 36 deletions(-) delete mode 100644 users/fcuny/desktop/media.nix create mode 100644 users/fcuny/desktop/media/default.nix create mode 100644 users/fcuny/desktop/media/mpd.nix create mode 100644 users/fcuny/desktop/media/music.nix create mode 100644 users/fcuny/desktop/media/sync-music.nix create mode 100644 users/fcuny/desktop/media/sync-videos.nix create mode 100644 users/fcuny/desktop/media/videos.nix (limited to 'users') diff --git a/users/fcuny/desktop/default.nix b/users/fcuny/desktop/default.nix index f5e9a4e..990aae4 100644 --- a/users/fcuny/desktop/default.nix +++ b/users/fcuny/desktop/default.nix @@ -5,7 +5,7 @@ ./browser.nix ./emacs.nix ./gtk.nix - ./media.nix + ./media ./sway ./terminal.nix ./trust diff --git a/users/fcuny/desktop/media.nix b/users/fcuny/desktop/media.nix deleted file mode 100644 index 9a2835f..0000000 --- a/users/fcuny/desktop/media.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - home.packages = [ - pkgs.mpd - pkgs.ncmpcpp - pkgs.pavucontrol - ]; - - xdg.configFile."ncmpcpp/config".source = ../configs/ncmpcpp/config; - - services.mpd = { - enable = true; - musicDirectory = config.xdg.userDirs.music; - network.startWhenNeeded = true; - extraConfig = '' - auto_update "yes" - filesystem_charset "UTF-8" - zeroconf_enabled "no" - input { - plugin "curl" - } - audio_output { - type "pipewire" - name "PipeWire Sound Server" - } - audio_output { - type "fifo" - name "visualizer" - path "/tmp/mpd.fifo" - format "44100:16:2" - } - ''; - }; -} diff --git a/users/fcuny/desktop/media/default.nix b/users/fcuny/desktop/media/default.nix new file mode 100644 index 0000000..23c2fae --- /dev/null +++ b/users/fcuny/desktop/media/default.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + imports = [ + ./mpd.nix + ./music.nix + ./sync-music.nix + ./sync-videos.nix + ./videos.nix + ]; +} diff --git a/users/fcuny/desktop/media/mpd.nix b/users/fcuny/desktop/media/mpd.nix new file mode 100644 index 0000000..b46b232 --- /dev/null +++ b/users/fcuny/desktop/media/mpd.nix @@ -0,0 +1,34 @@ +{ config, pkgs, ... }: + +{ + home.packages = [ + pkgs.mpd + pkgs.ncmpcpp + ]; + + xdg.configFile."ncmpcpp/config".source = ../configs/ncmpcpp/config; + + services.mpd = { + enable = true; + musicDirectory = config.xdg.userDirs.music; + network.startWhenNeeded = true; + extraConfig = '' + auto_update "yes" + filesystem_charset "UTF-8" + zeroconf_enabled "no" + input { + plugin "curl" + } + audio_output { + type "pipewire" + name "PipeWire Sound Server" + } + audio_output { + type "fifo" + name "visualizer" + path "/tmp/mpd.fifo" + format "44100:16:2" + } + ''; + }; +} diff --git a/users/fcuny/desktop/media/music.nix b/users/fcuny/desktop/media/music.nix new file mode 100644 index 0000000..ada357a --- /dev/null +++ b/users/fcuny/desktop/media/music.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: + +{ + home.packages = [ + pkgs.pavucontrol + ]; +} diff --git a/users/fcuny/desktop/media/sync-music.nix b/users/fcuny/desktop/media/sync-music.nix new file mode 100644 index 0000000..85e795a --- /dev/null +++ b/users/fcuny/desktop/media/sync-music.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: + +{ + systemd.user.services.sync-music = { + Unit = { + Description = "synchronize my music collection to the NAS"; + Documentation = "man:rsync(1)"; + ConditionFileIsExecutable = "${pkgs.rsync}/bin/rsync"; + ConditionHost = "carmel"; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.rsync}/bin/rysnc -avz -t %h/media/music/ nas.home:/data/music"; + }; + }; + + systemd.user.timers.sync-music = { + Unit = { + Description = "synchronize my music collection to the NAS"; + Documentation = "man:rsync(1)"; + }; + Timer = { + OnBootSec = "120m"; + OnUnitActiveSec = "1d"; + RandomizedDelaySec = "1800"; + Persistent = true; + }; + Install = { WantedBy = [ "timers.target" ]; }; + }; +} diff --git a/users/fcuny/desktop/media/sync-videos.nix b/users/fcuny/desktop/media/sync-videos.nix new file mode 100644 index 0000000..ced319d --- /dev/null +++ b/users/fcuny/desktop/media/sync-videos.nix @@ -0,0 +1,29 @@ +{ config, pkgs, ... }: + +{ + systemd.user.services.sync-videos = { + Unit = { + Description = "synchronize my videos to the NAS"; + Documentation = "man:rsync(1)"; + ConditionFileIsExecutable = "${pkgs.rsync}/bin/rsync"; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.rsync}/bin/rysnc -avz -t %h/media/videos/ nas.home:/data/videos/incoming"; + }; + }; + + systemd.user.timers.sync-videos = { + Unit = { + Description = "synchronize my videos to the NAS"; + Documentation = "man:rsync(1)"; + }; + Timer = { + OnBootSec = "120m"; + OnUnitActiveSec = "1d"; + RandomizedDelaySec = "1800"; + Persistent = true; + }; + Install = { WantedBy = [ "timers.target" ]; }; + }; +} diff --git a/users/fcuny/desktop/media/videos.nix b/users/fcuny/desktop/media/videos.nix new file mode 100644 index 0000000..a4d0709 --- /dev/null +++ b/users/fcuny/desktop/media/videos.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: + +{ + home.packages = [ + pkgs.vlc + ] +} -- cgit 1.4.1