From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id wMJoGWpLVWTjCgEASxT56A (envelope-from ) for ; Fri, 05 May 2023 20:31:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yCknGWpLVWQaXgEA9RJhRA (envelope-from ) for ; Fri, 05 May 2023 20:31:06 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 340AC120B8 for ; Fri, 5 May 2023 20:31:06 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pv0C4-0005Fy-IF; Fri, 05 May 2023 14:30:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pv0C0-0005DQ-Eu for bug-guix@gnu.org; Fri, 05 May 2023 14:30:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pv0C0-00063G-4R for bug-guix@gnu.org; Fri, 05 May 2023 14:30:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pv0C0-0003Bu-0q for bug-guix@gnu.org; Fri, 05 May 2023 14:30:08 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63082: [PATCH v3 14/16] services: mpd: Provision a default cache directory and set HOME. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 May 2023 18:30:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63082 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63082@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 63082-submit@debbugs.gnu.org id=B63082.168331139212097 (code B ref 63082); Fri, 05 May 2023 18:30:07 +0000 Received: (at 63082) by debbugs.gnu.org; 5 May 2023 18:29:52 +0000 Received: from localhost ([127.0.0.1]:57508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0Bj-00038p-3u for submit@debbugs.gnu.org; Fri, 05 May 2023 14:29:51 -0400 Received: from mail-qt1-f178.google.com ([209.85.160.178]:45200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0Bg-00037P-FL for 63082@debbugs.gnu.org; Fri, 05 May 2023 14:29:48 -0400 Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-3ef3ce7085bso9430781cf.2 for <63082@debbugs.gnu.org>; Fri, 05 May 2023 11:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683311383; x=1685903383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PlCVUb+LXCPSVLdyUVzBoMZuuUfoq++1L5oZS4gLL38=; b=BzbDB+puQXeTzpuCnZgRjJGd8BXwHNWKjKBoWMRhli1JC5Qbc5Zo3BNjH4J9QOSFHJ u3dOrczrVmjHYnoocUkJjlKnqtvHDw3w8/nzCWf+DClxcf2q8kkgEBH2fPwBBf5R7Y4h tosZWnLMVZPtQLaRZC3nPoscExgENooNitYxTnoCBjlj8guaCGXri+xFxw4fX4neBZMV opqQfQhucnCL9K6BbhWXCzm7R3okaLZ4BDBRFxTfiYMBWnpO5fbg54RbXOeJXae2+WO7 QXDGXcTWQrHHbWCukuV9Nzn8AOutP3mmUFFN+GU4euJs3tO1sN09q3cOeHuwcrG1I4+1 L1KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683311383; x=1685903383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlCVUb+LXCPSVLdyUVzBoMZuuUfoq++1L5oZS4gLL38=; b=KcH9uGeRSn7qFQ6vpOE27yWDBJuLw4mDGACneD6J1q5ezBVTwBC3SgWKDt1FGWQmky xrpNfiNoKEyHL422U+Jjp9yd05csNIz4tDjZW+i+T+vbKJhajT94vJ/Vfot25jTPrJbA bBSyIMrsOKlEylUr4033qg5boKXT5rxym1cEX01Cnp+t2+OprX7RKS23UxagxmTbzriZ hT9ONdWGyK3JLzuVsV9WH0c5/Eyp7U71rlKtv4hMbOcHLGgRWjjgm+Rn9em3JXvKpmBi R4L8K2duLdTcOYKKrWS9x6GvIdsXXDoZq0Svw0JxYQzK01dtfv+z8P2qvVRwuAFHz6NQ oUUQ== X-Gm-Message-State: AC+VfDwwunBP2h2qjBjN0WKbyMf3Dpolbc4YeTrvCFP9K0Clv4ax4eYq HNEbc+wIy9BqAE7pbAAymhyMm1iZk98= X-Google-Smtp-Source: ACHHUZ7fBvWhptQ3pisBDtNJUoBAcNARve+G1RT/Kk2pWGkVAgQGsaYljxqpHSzkVSwauujhLKA7rg== X-Received: by 2002:a05:622a:c5:b0:3ef:380a:d7bc with SMTP id p5-20020a05622a00c500b003ef380ad7bcmr4234060qtw.54.1683311382926; Fri, 05 May 2023 11:29:42 -0700 (PDT) Received: from localhost.localdomain (dsl-205-236-230-162.b2b2c.ca. [205.236.230.162]) by smtp.gmail.com with ESMTPSA id c1-20020ac81e81000000b003e97fe68511sm834399qtm.3.2023.05.05.11.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 11:29:42 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 5 May 2023 14:29:09 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683311466; a=rsa-sha256; cv=none; b=UdTjeC7jGJeGpYplXNmkoMBK/A47oOoQdTgbqnTzwmr2bliDpCNxODfqMdIxTZ//fQSp73 tuBiid8Wt7XaG4F+aUrAq0V9pq3rcbTevsD1P1L3KLOd5cuYBW3ztaqKjnSCdOePZc0F3s oTRy+OEW45Q23yc2woOM9Jid7kOnx2QwOWXqpUXs8sCr+ih3zXKZZnJuZKumVyFcIG2OHP okI5Q1FYYej4YvuQNXh1q1apyI9zninvbFn9MbeJ9DPIrtlY2BNGlteOQdjWifdMQ8nhs9 CDUR3hygN7VyU9xWT3UJvi9JqnmNnE77xtDo/aA/RPxLpwVt3quUcvPurY7lzw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=BzbDB+pu; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683311466; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PlCVUb+LXCPSVLdyUVzBoMZuuUfoq++1L5oZS4gLL38=; b=tQoUBxF6zpVeNXXfd388BgVTYF8dNR764MZ16eZ9HFU8A2YBq9TlH4XROOd357x8BHarku lUYuRpzmJaoCjk/R92tA1nAvgUmBJpsZKYDx8/uYn5mQirVe5R3kyGZAxb9iN714OzN6Xq eyC/dyPiOPZlSW9hallHxwIAFJ1cX2fKLcYoWQsVZ2jmsE8o5VT8u9h7inK/IesLsoJ+5S jfPQVTGg1cPo7yJO7+yAEEnSdoKSr/5uP4HG17bjb5jKmdctgenPubKqFAicichDI7oqOH lQ0UgMizufqd9IU/gSUPkFys4dScT8zJ4Nw1zJgVaQkb1CamS41vhkaHu07JRw== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=BzbDB+pu; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.30 X-Spam-Score: 6.30 X-Migadu-Queue-Id: 340AC120B8 X-TUID: 491SWoUVf0+G Relates to . * gnu/services/audio.scm (mpd-shepherd-service): Create a default .cache directory. Use mkdir-p/perms and refactor loop. Set the HOME environment variables. --- doc/guix.texi | 3 +- gnu/services/audio.scm | 63 +++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0981aa1568..04744498dd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33633,7 +33633,8 @@ Audio Services The directory to store playlists. @item @code{db-file} (type: maybe-string) -The location of the music database. +The location of the music database. When left unspecified, +@file{~/.cache/db} is used. @item @code{state-file} (type: maybe-string) The location of the file that stores current MPD's state. diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 1e0a8b7f9e..e242f48ba0 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -461,7 +461,8 @@ (define-configuration mpd-configuration (db-file maybe-string - "The location of the music database.") + "The location of the music database. When left unspecified, +@file{~/.cache/db} is used.") (state-file maybe-string @@ -605,32 +606,42 @@ (define (mpd-shepherd-service config) #~(begin (use-modules (gnu build activation)) - (let ((user (getpw #$username))) - - (define (init-directory directory) - (unless (file-exists? directory) - (mkdir-p/perms directory user #o755))) + (let ((home #$(user-account-home-directory user))) + (let ((user (getpw #$username)) + (default-cache-dir (string-append home "/.cache"))) + + (define (init-directory directory) + (unless (file-exists? directory) + (mkdir-p/perms directory user #o755))) + + ;; Define a cache location that can be automatically used + ;; for the database file, in case it hasn't been explicitly + ;; specified. + (for-each + init-directory + (cons default-cache-dir + '#$(map dirname + ;; XXX: Delete the potential "syslog" + ;; log-file value, which is not a directory. + (delete "syslog" + (filter-map maybe-value + (list db-file + log-file + state-file + sticker-file))))))) - (for-each - init-directory - '#$(map dirname - ;; XXX: Delete the potential "syslog" - ;; log-file value, which is not a directory. - (delete "syslog" - (filter-map maybe-value - (list db-file - log-file - state-file - sticker-file)))))) - - (make-forkexec-constructor - (list #$(file-append package "/bin/mpd") "--no-daemon" - #$config-file) - #:environment-variables '#$environment-variables - #:user #$username - #:group #$(user-account-group user) - #:supplementary-groups - '#$(user-account-supplementary-groups user))))) + (make-forkexec-constructor + (list #$(file-append package "/bin/mpd") "--no-daemon" + #$config-file) + #:environment-variables + ;; Set HOME so MPD can infer default paths, such as + ;; for the database file. + (cons (string-append "HOME=" home) + '#$environment-variables) + #:user #$username + #:group #$(user-account-group user) + #:supplementary-groups + '#$(user-account-supplementary-groups user)))))) (stop #~(make-kill-destructor)) (actions (list (shepherd-configuration-action config-file) -- 2.39.2