guix-channel

A channel for the Guix package manager

git clone https://git.8pit.net/guix-channel.git

 1(define-module (nmeum services system)
 2  #:use-module (nmeum packages desktop)
 3  #:use-module (guix gexp)
 4  #:use-module (gnu services)
 5  #:use-module (gnu services base)
 6  #:use-module (gnu system pam)
 7
 8  #:export (login-xdg-runtime-service-type))
 9
10;; Hack to extract the login-pam-service from (gnu services base).
11(define login-pam-service (@@ (gnu services base) login-pam-service))
12
13;; Utility method for unioning multiple PAM services.
14(define (pam-service-union name lst)
15  (define (%pam-service-union s1 s2)
16    (pam-service (name name)
17                 (account (append (pam-service-account s1)
18                                  (pam-service-account s2)))
19                 (auth (append (pam-service-auth s1)
20                               (pam-service-auth s2)))
21                 (password (append (pam-service-password s1)
22                                   (pam-service-password s2)))
23                 (session (append (pam-service-session s1)
24                                  (pam-service-session s2)))))
25
26  (apply %pam-service-union lst))
27
28;; Custom variant of the login-pam-service procedure from the
29;; `gnu/services/base.scm` file in the Guix repository.
30(define (login-xdg-runtime-pam-service config)
31  (define dumb-dir-pam-service
32    (let* ((module "/lib/security/pam_dumb_runtime_dir.so")
33           (dumb-dir (pam-entry (control "optional")
34                                (module (file-append dumb-runtime-dir module)))))
35      (pam-service (name "dumb-dir")
36                   (session (list dumb-dir)))))
37
38  (list
39    (pam-service-union
40      "login"
41      (append
42        (login-pam-service config)
43        (list dumb-dir-pam-service)))))
44
45;; Provides a custom variant of the login-service-type from the
46;; `gnu/services/base.scm` file.  This custom services supports
47;; the dumb-runtime-dir PAM module to setup a XDG_RUNTIME_DIR.
48;;
49;; TODO: Find a better way to extend the login-service-type
50;;       and propose that upstream.
51(define login-xdg-runtime-service-type
52  (service-type (name 'login)
53                (extensions (list (service-extension pam-root-service-type
54                                   login-xdg-runtime-pam-service)))
55                (default-value (login-configuration))
56                (description
57                 "Custom login service integrated with dumb-runtime-dir.")))