Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 98a3c772969e
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 35521e4ea7a5
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Aug 16, 2020

  1. nixos/mpd: Allow to configure a credentialsFile

    Allow to specify a password file to be located outside the store, and be
    read in `ExecStartPre`.
    doronbehar committed Aug 16, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    NeQuissimus Tim Steinbach
    Copy the full SHA
    ccee8dc View commit details

Commits on Sep 10, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    NeQuissimus Tim Steinbach
    Copy the full SHA
    b4756fe View commit details

Commits on Sep 11, 2020

  1. Merge pull request #95599 from doronbehar/module/mpd/passwordFile

    nixos/mpd: Allow to configure a credentialsFile
    doronbehar authored Sep 11, 2020
    1

    Verified

    This commit was signed with the committer’s verified signature.
    NeQuissimus Tim Steinbach
    Copy the full SHA
    35521e4 View commit details
Showing with 30 additions and 1 deletion.
  1. +30 −1 nixos/modules/services/audio/mpd.nix
31 changes: 30 additions & 1 deletion nixos/modules/services/audio/mpd.nix
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ let
cfg = config.services.mpd;

mpdConf = pkgs.writeText "mpd.conf" ''
# This file was automatically generated by NixOS. Edit mpd's configuration
# via NixOS' configuration.nix, as this file will be rewritten upon mpd's
# restart.
music_directory "${cfg.musicDirectory}"
playlist_directory "${cfg.playlistDirectory}"
${lib.optionalString (cfg.dbFile != null) ''
@@ -140,6 +144,18 @@ in {
'';
};

credentialsFile = mkOption {
type = types.path;
description = ''
Path to a file to be merged with the settings during the service startup.
Useful to merge a file which is better kept out of the Nix store
because it contains sensible data like MPD's password. Example may look like this:
<literal>password "myMpdPassword@read,add,control,admin"</literal>
'';
default = "/dev/null";
example = "/var/lib/secrets/mpd.conf";
};

fluidsynth = mkOption {
type = types.bool;
default = false;
@@ -181,7 +197,12 @@ in {

serviceConfig = {
User = "${cfg.user}";
ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${mpdConf}";
ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon /etc/mpd.conf";
ExecStartPre = pkgs.writeScript "mpd-start-pre" ''
#!${pkgs.runtimeShell}
set -euo pipefail
cat ${mpdConf} ${cfg.credentialsFile} > /etc/mpd.conf
'';
Type = "notify";
LimitRTPRIO = 50;
LimitRTTIME = "infinity";
@@ -195,6 +216,14 @@ in {
Restart = "always";
};
};
environment.etc."mpd.conf" = {
mode = "0640";
group = cfg.group;
user = cfg.user;
# To be modified by the service' ExecStartPre
text = ''
'';
};

users.users = optionalAttrs (cfg.user == name) {
${name} = {