mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
home: services: Add readymedia.
* gnu/home/services/upnp.scm: New file. * gnu/local.mk: Register it. * gnu/services/upnp.scm: Export readymedia-activation and readymedia-shepherd-service. (<readymedia-configuration>)[home-service?]: New field. [cache-directory]: Adjust value depending on 'for-home?'. [log-directory]: Ditto. (readymedia-shepherd-service): Adjust 'requirement' and 'start' according to 'home-service?'. (readymedia-activation): Adjust creating 'media-directories' with permissions according to 'home-service?'. * gnu/tests/upnp.scm (%readymedia-configuration-test): Configure port with %readymedia-default-port. * doc/guix.texi (Miscellaneous Home Services): Document Readymedia Service. (Miscellaneous Services): Add cross-reference. Change-Id: I5c48595d84a815d98e03c7f68a716f048903720c Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
1220d1a84e
commit
b1d2483ebe
5 changed files with 138 additions and 14 deletions
|
@ -44990,6 +44990,12 @@ specified in @code{media-directories}. The @code{media-directories}
|
||||||
field is mandatory. All other fields (such as network ports and the
|
field is mandatory. All other fields (such as network ports and the
|
||||||
server name) come with a predefined default and can be omitted.
|
server name) come with a predefined default and can be omitted.
|
||||||
|
|
||||||
|
@quotation Note
|
||||||
|
This service is also available for Guix Home, where it runs directly
|
||||||
|
with your user privileges (@pxref{Miscellaneous Home Services,
|
||||||
|
@code{home-readymedia-service-type}}).
|
||||||
|
@end quotation
|
||||||
|
|
||||||
@c %start of fragment
|
@c %start of fragment
|
||||||
|
|
||||||
@deftp {Data Type} readymedia-configuration
|
@deftp {Data Type} readymedia-configuration
|
||||||
|
@ -51768,6 +51774,8 @@ mouse bindings.
|
||||||
This section lists services somewhat networking-related that you may use
|
This section lists services somewhat networking-related that you may use
|
||||||
with Guix Home.
|
with Guix Home.
|
||||||
|
|
||||||
|
@subheading Syncthing Service
|
||||||
|
|
||||||
@cindex Syncthing, file synchronization service
|
@cindex Syncthing, file synchronization service
|
||||||
@cindex backup service, Syncthing
|
@cindex backup service, Syncthing
|
||||||
The @code{(gnu home services syncthing)} module provides a service to
|
The @code{(gnu home services syncthing)} module provides a service to
|
||||||
|
@ -51870,6 +51878,43 @@ You may specify a custom configuration by providing a
|
||||||
(dicod-configuration @dots{})))
|
(dicod-configuration @dots{})))
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
|
@subheading ReadyMedia Service
|
||||||
|
|
||||||
|
@cindex ReadyMedia, DLNA/UPnP Service
|
||||||
|
The @code{(gnu home services upnp)} module provides a service to set up
|
||||||
|
the @uref{https://minidlna.sourceforge.net/, ReadyMedia} @acronym{DLNA,
|
||||||
|
Digital Living Network Alliance} @acronym{UPnP, Universal Plug and Play}
|
||||||
|
media server.
|
||||||
|
|
||||||
|
@defvar home-readymedia-service-type
|
||||||
|
This is the service type for the @command{minidlnad} daemon; it is the
|
||||||
|
Home counterpart of the @code{readymedia-service-type} system service
|
||||||
|
(@pxref{Miscellaneous Services, @code{readymedia-service-type}}). The value
|
||||||
|
for this service type is a @code{readymedia-configuration}.
|
||||||
|
@end defvar
|
||||||
|
|
||||||
|
The service can be used with a @code{readymedia-configuration} wrapped in
|
||||||
|
@code{for-home} like this:
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(service home-readymedia-service-type
|
||||||
|
(for-home
|
||||||
|
(readymedia-configuration
|
||||||
|
(media-directories
|
||||||
|
(list (readymedia-directory
|
||||||
|
(path "/path/to/media/audio")
|
||||||
|
(types '(A)))
|
||||||
|
(readymedia-directory
|
||||||
|
(path "/path/to/media/video")
|
||||||
|
(types '(V)))
|
||||||
|
(readymedia-directory
|
||||||
|
(path "/path/to/media/misc")))))))
|
||||||
|
@end lisp
|
||||||
|
|
||||||
|
For details about @code{readymedia-configuration}, check out the
|
||||||
|
documentation of the system service (@pxref{Miscellaneous Services,
|
||||||
|
@code{readymedia-service-type}}).
|
||||||
|
|
||||||
@node Invoking guix home
|
@node Invoking guix home
|
||||||
@section Invoking @command{guix home}
|
@section Invoking @command{guix home}
|
||||||
|
|
||||||
|
|
55
gnu/home/services/upnp.scm
Normal file
55
gnu/home/services/upnp.scm
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;; Copyright © 2025 Sughosha <sughosha@disroot.org>
|
||||||
|
;;;
|
||||||
|
;;; This file is part of GNU Guix.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
||||||
|
;;; under the terms of the GNU General Public License as published by
|
||||||
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||||
|
;;; your option) any later version.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
||||||
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;;; GNU General Public License for more details.
|
||||||
|
;;;
|
||||||
|
;;; You should have received a copy of the GNU General Public License
|
||||||
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
(define-module (gnu home services upnp)
|
||||||
|
#:use-module ((gnu build linux-container) #:select (%namespaces))
|
||||||
|
#:use-module (gnu services)
|
||||||
|
#:use-module (gnu home services)
|
||||||
|
;; For the 'home-shepherd-service-type' mapping.
|
||||||
|
#:use-module (gnu home services shepherd)
|
||||||
|
#:use-module (gnu services upnp)
|
||||||
|
#:use-module (guix records)
|
||||||
|
#:export (home-readymedia-service-type)
|
||||||
|
#:re-export (readymedia-configuration
|
||||||
|
readymedia-configuration?
|
||||||
|
readymedia-configuration-readymedia
|
||||||
|
readymedia-configuration-port
|
||||||
|
readymedia-configuration-cache-directory
|
||||||
|
readymedia-configuration-extra-config
|
||||||
|
readymedia-configuration-friendly-name
|
||||||
|
readymedia-configuration-log-directory
|
||||||
|
readymedia-configuration-media-directories
|
||||||
|
readymedia-media-directory
|
||||||
|
readymedia-media-directory?
|
||||||
|
readymedia-media-directory-path
|
||||||
|
readymedia-media-directory-types))
|
||||||
|
|
||||||
|
(define home-readymedia-service-type
|
||||||
|
(service-type
|
||||||
|
(inherit (system->home-service-type readymedia-service-type))
|
||||||
|
;; system->home-service-type does not convert special-files-service-type to
|
||||||
|
;; home-files-service-type, so redefine extensios
|
||||||
|
(extensions
|
||||||
|
(list (service-extension home-shepherd-service-type
|
||||||
|
(compose list readymedia-shepherd-service))
|
||||||
|
(service-extension home-activation-service-type
|
||||||
|
readymedia-activation)))
|
||||||
|
(default-value
|
||||||
|
(for-home
|
||||||
|
(readymedia-configuration
|
||||||
|
(media-directories '()))))))
|
|
@ -124,6 +124,7 @@ GNU_SYSTEM_MODULES = \
|
||||||
%D%/home/services/sway.scm \
|
%D%/home/services/sway.scm \
|
||||||
%D%/home/services/syncthing.scm \
|
%D%/home/services/syncthing.scm \
|
||||||
%D%/home/services/mcron.scm \
|
%D%/home/services/mcron.scm \
|
||||||
|
%D%/home/services/upnp.scm \
|
||||||
%D%/home/services/utils.scm \
|
%D%/home/services/utils.scm \
|
||||||
%D%/home/services/xdg.scm \
|
%D%/home/services/xdg.scm \
|
||||||
%D%/image.scm \
|
%D%/image.scm \
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:export (%readymedia-default-cache-directory
|
#:export (%readymedia-default-cache-directory
|
||||||
%readymedia-default-log-directory
|
%readymedia-default-log-directory
|
||||||
%readymedia-default-port
|
|
||||||
%readymedia-log-file
|
%readymedia-log-file
|
||||||
%readymedia-user-account
|
%readymedia-user-account
|
||||||
%readymedia-user-group
|
%readymedia-user-group
|
||||||
|
@ -50,7 +49,9 @@
|
||||||
readymedia-media-directory-path
|
readymedia-media-directory-path
|
||||||
readymedia-media-directory-types
|
readymedia-media-directory-types
|
||||||
readymedia-media-directory?
|
readymedia-media-directory?
|
||||||
readymedia-service-type))
|
readymedia-service-type
|
||||||
|
readymedia-activation
|
||||||
|
readymedia-shepherd-service))
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -72,14 +73,27 @@
|
||||||
(port readymedia-configuration-port
|
(port readymedia-configuration-port
|
||||||
(default #f))
|
(default #f))
|
||||||
(cache-directory readymedia-configuration-cache-directory
|
(cache-directory readymedia-configuration-cache-directory
|
||||||
(default %readymedia-default-cache-directory))
|
(default (if for-home?
|
||||||
|
(string-append (or (getenv "XDG_CACHE_HOME")
|
||||||
|
(string-append
|
||||||
|
(getenv "HOME") "/.cache"))
|
||||||
|
"/readymedia")
|
||||||
|
%readymedia-default-cache-directory)))
|
||||||
(log-directory readymedia-configuration-log-directory
|
(log-directory readymedia-configuration-log-directory
|
||||||
(default %readymedia-default-log-directory))
|
(default (if for-home?
|
||||||
|
(string-append (or (getenv "XDG_STATE_HOME")
|
||||||
|
(string-append
|
||||||
|
(getenv "HOME")
|
||||||
|
"/.local/state"))
|
||||||
|
"/readymedia")
|
||||||
|
%readymedia-default-log-directory)))
|
||||||
(friendly-name readymedia-configuration-friendly-name
|
(friendly-name readymedia-configuration-friendly-name
|
||||||
(default #f))
|
(default #f))
|
||||||
(media-directories readymedia-configuration-media-directories)
|
(media-directories readymedia-configuration-media-directories)
|
||||||
(extra-config readymedia-configuration-extra-config
|
(extra-config readymedia-configuration-extra-config
|
||||||
(default '())))
|
(default '()))
|
||||||
|
(home-service? syncthing-configuration-home-service?
|
||||||
|
(default for-home?) (innate)))
|
||||||
|
|
||||||
;; READYMEDIA-MEDIA-DIR is a record that indicates the path of a media folder
|
;; READYMEDIA-MEDIA-DIR is a record that indicates the path of a media folder
|
||||||
;; and the types of media included within it. Allowed individual types are the
|
;; and the types of media included within it. Allowed individual types are the
|
||||||
|
@ -96,9 +110,13 @@
|
||||||
(define (readymedia-configuration->config-file config)
|
(define (readymedia-configuration->config-file config)
|
||||||
"Return the ReadyMedia/MiniDLNA configuration file corresponding to CONFIG."
|
"Return the ReadyMedia/MiniDLNA configuration file corresponding to CONFIG."
|
||||||
(match-record config <readymedia-configuration>
|
(match-record config <readymedia-configuration>
|
||||||
(port friendly-name cache-directory log-directory media-directories extra-config)
|
(port friendly-name cache-directory log-directory media-directories
|
||||||
|
extra-config home-service?)
|
||||||
(apply mixed-text-file
|
(apply mixed-text-file
|
||||||
"minidlna.conf"
|
"minidlna.conf"
|
||||||
|
(if home-service?
|
||||||
|
(string-append "user=" (number->string (getuid)) "\n")
|
||||||
|
"")
|
||||||
"db_dir=" cache-directory "\n"
|
"db_dir=" cache-directory "\n"
|
||||||
"log_dir=" log-directory "\n"
|
"log_dir=" log-directory "\n"
|
||||||
(if friendly-name
|
(if friendly-name
|
||||||
|
@ -125,12 +143,12 @@
|
||||||
(define (readymedia-shepherd-service config)
|
(define (readymedia-shepherd-service config)
|
||||||
"Return a least-authority ReadyMedia/MiniDLNA Shepherd service."
|
"Return a least-authority ReadyMedia/MiniDLNA Shepherd service."
|
||||||
(match-record config <readymedia-configuration>
|
(match-record config <readymedia-configuration>
|
||||||
(cache-directory log-directory media-directories)
|
(cache-directory log-directory media-directories home-service?)
|
||||||
(let ((minidlna-conf (readymedia-configuration->config-file config)))
|
(let ((minidlna-conf (readymedia-configuration->config-file config)))
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
(documentation "Run the ReadyMedia/MiniDLNA daemon.")
|
(documentation "Run the ReadyMedia/MiniDLNA daemon.")
|
||||||
(provision '(readymedia))
|
(provision '(readymedia))
|
||||||
(requirement '(networking user-processes))
|
(requirement (if home-service? '() '(networking user-processes)))
|
||||||
(start
|
(start
|
||||||
#~(make-forkexec-constructor
|
#~(make-forkexec-constructor
|
||||||
(list #$(least-authority-wrapper
|
(list #$(least-authority-wrapper
|
||||||
|
@ -159,8 +177,8 @@
|
||||||
#$minidlna-conf
|
#$minidlna-conf
|
||||||
"-S")
|
"-S")
|
||||||
#:log-file #$(string-append log-directory "/" %readymedia-log-file)
|
#:log-file #$(string-append log-directory "/" %readymedia-log-file)
|
||||||
#:user #$%readymedia-user-account
|
#:user #$(if home-service? #f %readymedia-user-account)
|
||||||
#:group #$%readymedia-user-group))
|
#:group #$(if home-service? #f %readymedia-user-group)))
|
||||||
(stop #~(make-kill-destructor))))))
|
(stop #~(make-kill-destructor))))))
|
||||||
|
|
||||||
(define readymedia-accounts
|
(define readymedia-accounts
|
||||||
|
@ -178,7 +196,7 @@
|
||||||
(define (readymedia-activation config)
|
(define (readymedia-activation config)
|
||||||
"Set up directories for ReadyMedia/MiniDLNA."
|
"Set up directories for ReadyMedia/MiniDLNA."
|
||||||
(match-record config <readymedia-configuration>
|
(match-record config <readymedia-configuration>
|
||||||
(cache-directory log-directory media-directories)
|
(cache-directory log-directory media-directories home-service?)
|
||||||
(with-imported-modules (source-module-closure '((gnu build activation)))
|
(with-imported-modules (source-module-closure '((gnu build activation)))
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (gnu build activation))
|
(use-modules (gnu build activation))
|
||||||
|
@ -186,14 +204,18 @@
|
||||||
(for-each (lambda (directory)
|
(for-each (lambda (directory)
|
||||||
(unless (file-exists? directory)
|
(unless (file-exists? directory)
|
||||||
(mkdir-p/perms directory
|
(mkdir-p/perms directory
|
||||||
(getpw #$%readymedia-user-account)
|
(getpw #$(if home-service?
|
||||||
#o775)))
|
#~(getuid)
|
||||||
|
%readymedia-user-account))
|
||||||
|
#$(if home-service? #o755 #o775))))
|
||||||
(list #$@(map readymedia-media-directory-path
|
(list #$@(map readymedia-media-directory-path
|
||||||
media-directories)))
|
media-directories)))
|
||||||
(for-each (lambda (directory)
|
(for-each (lambda (directory)
|
||||||
(unless (file-exists? directory)
|
(unless (file-exists? directory)
|
||||||
(mkdir-p/perms directory
|
(mkdir-p/perms directory
|
||||||
(getpw #$%readymedia-user-account)
|
(getpw #$(if home-service?
|
||||||
|
#~(getuid)
|
||||||
|
%readymedia-user-account))
|
||||||
#o755)))
|
#o755)))
|
||||||
(list #$cache-directory #$log-directory))))))
|
(list #$cache-directory #$log-directory))))))
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
(define %readymedia-media-directory "/media")
|
(define %readymedia-media-directory "/media")
|
||||||
(define %readymedia-configuration-test
|
(define %readymedia-configuration-test
|
||||||
(readymedia-configuration
|
(readymedia-configuration
|
||||||
|
(port %readymedia-default-port)
|
||||||
(media-directories
|
(media-directories
|
||||||
(list (readymedia-media-directory (path %readymedia-media-directory)
|
(list (readymedia-media-directory (path %readymedia-media-directory)
|
||||||
(types '(A V)))))))
|
(types '(A V)))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue