From f38f69b0d28f40f901cc55259817f6f20f584d59 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 7 Oct 2021 23:43:05 +0200 Subject: [PATCH] start mopidy and spotifyd --- flake.lock | 8 +- nixos/configs/pepe/configuration.nix | 1 + nixos/configs/pepe/mpd.nix | 162 +++++++++++++++++++++++++++ nixos/configs/porani/syncthing.nix | 2 +- 4 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 nixos/configs/pepe/mpd.nix diff --git a/flake.lock b/flake.lock index cd9f949..a3175c2 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1633267966, - "narHash": "sha256-gFKvZ5AmV/dDTKXVxacPbXe4R0BsFpwtVaQxuIm2nnk=", + "lastModified": 1633422542, + "narHash": "sha256-JYz2PmVogNRO8DhcvXzL/QhZzboTspJz2YSRlnAj8aM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7daf35532d2d8bf5e6f7f962e6cd13a66d01a71d", + "rev": "aff647e2704fa1223994604887bb78276dc57083", "type": "github" }, "original": { @@ -62,7 +62,7 @@ "secrets": { "flake": false, "locked": { - "narHash": "sha256-XRWlSFaGqmeDstMQS46KUOkIks0wLADTiHC09pYVyMc=", + "narHash": "sha256-1myorrO1qwgIHPz2UkU45qZp+X4RdQgJpay93z1VNCM=", "path": "/home/palo/dev/secrets", "type": "path" }, diff --git a/nixos/configs/pepe/configuration.nix b/nixos/configs/pepe/configuration.nix index 5b0371b..9389592 100644 --- a/nixos/configs/pepe/configuration.nix +++ b/nixos/configs/pepe/configuration.nix @@ -13,6 +13,7 @@ #./lan.nix ./dms.nix ./borg.nix + ./mpd.nix ]; diff --git a/nixos/configs/pepe/mpd.nix b/nixos/configs/pepe/mpd.nix new file mode 100644 index 0000000..03765e3 --- /dev/null +++ b/nixos/configs/pepe/mpd.nix @@ -0,0 +1,162 @@ +{ config, lib, pkgs, ... }: + +{ + services.mopidy = { + enable = true; + extensionPackages = with pkgs; [ + #mopidy-spotify + mopidy-iris + mopidy-local + mopidy-mpd + mopidy-podcast + mopidy-youtube + ]; + + configuration = '' + + [mpd] + hostname = :: + + [http] + hostname = 0.0.0.0 + + [local] + enabled = true + media_dir = /media/syncthing/music-library + + [file] + enabled = false + media_dirs = + /media/syncthing/music-library|Penis + + [iris] + country = de + locale = de_DE + + [audio] + output = alsasink + + [stream] + enabled = true + timeout = 5000 + protocols = + http + https + mms + rtmp + rtmps + rtsp + ''; + }; + + users.groups."syncthing".members = [ "mopidy" ]; + + sound.enable = true; + + networking.firewall.allowedTCPPorts = [ + 6680 # mopidy + 6600 # mpd + 1234 # zeroconf + ]; + + users.users."spotifyd" = { + isSystemUser = true; + }; + + sops.secrets.spotify_pass = { + owner = "spotifyd"; + }; + sops.secrets.spotify_user = { + owner = "spotifyd"; + }; + + services.spotifyd.enable = true; + services.spotifyd.config = '' +[global] +# Your Spotify account name. +#username = "yolo" +username_cmd = "cat ${config.sops.secrets.spotify_user.path}" + +# A command that gets executed and can be used to +# retrieve your password. +# The command should return the password on stdout. +# +# This is an alternative to the `password` field. Both +# can't be used simultaneously. +password_cmd = "cat ${config.sops.secrets.spotify_pass.path}" + +# If set to true, `spotifyd` tries to look up your +# password in the system's password storage. +# +# This is an alternative to the `password` field. Both +# can't be used simultaneously. +#use_keyring = true + +# If set to true, `spotifyd` tries to bind to the session dbus +# and expose MPRIS controls. When running headless, without a dbus session, +# then set this to false to avoid binding errors +# +#use_mpris = true + +# The audio backend used to play the your music. To get +# a list of possible backends, run `spotifyd --help`. +backend = "alsa" # use portaudio for macOS [homebrew] + +# The alsa audio device to stream audio to. To get a +# list of valid devices, run `aplay -L`, +#device = "alsa_audio_device" # omit for macOS + +# The alsa control device. By default this is the same +# name as the `device` field. +#control = "alsa_audio_device" # omit for macOS + +# The alsa mixer used by `spotifyd`. +mixer = "PCM" # omit for macOS + +# The volume controller. Each one behaves different to +# volume increases. For possible values, run +# `spotifyd --help`. +volume_controller = "alsa" # use softvol for macOS + +# The name that gets displayed under the connect tab on +# official clients. Spaces are not allowed! +device_name = "Pepe" + +# The audio bitrate. 96, 160 or 320 kbit/s +bitrate = 160 + +# The directory used to cache audio data. This setting can save +# a lot of bandwidth when activated, as it will avoid re-downloading +# audio files when replaying them. +# +# Note: The file path does not get expanded. Environment variables and +# shell placeholders like $HOME or ~ don't work! +#cache_path = "cache_directory" + +# If set to true, audio data does NOT get cached. +no_audio_cache = true + +# Volume on startup between 0 and 100 +# NOTE: This variable's type will change in v0.4, to a number (instead of string) +initial_volume = "90" + +# If set to true, enables volume normalisation between songs. +volume_normalisation = true + +# The normalisation pregain that is applied for each song. +normalisation_pregain = -10 + +# The port `spotifyd` uses to announce its service over the network. +zeroconf_port = 1234 + +# The proxy `spotifyd` will use to connect to spotify. +#proxy = "http://proxy.example.org:8080" + +# The displayed device type in Spotify clients. +# Can be unknown, computer, tablet, smartphone, speaker, t_v, +# a_v_r (Audio/Video Receiver), s_t_b (Set-Top Box), and audio_dongle. +device_type = "computer" +''; + + +} diff --git a/nixos/configs/porani/syncthing.nix b/nixos/configs/porani/syncthing.nix index 3c5ad22..30ec00c 100644 --- a/nixos/configs/porani/syncthing.nix +++ b/nixos/configs/porani/syncthing.nix @@ -54,7 +54,7 @@ after = [ "media.mount" ]; }; - users.groups."syncthing".members = [ "mpd" "syncthing" "kodi" "palo" ]; + users.groups."syncthing".members = [ mpd" "syncthing" "kodi" "palo" ]; backup.dirs = [ "/var/lib/syncthing/finance" ];