]> git.ekhem.eu.org Git - guix.git/commitdiff
[home] Install programs using a service.
authorJakub Czajka <jakub@ekhem.eu.org>
Sat, 4 Jun 2022 19:43:12 +0000 (21:43 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
This commit adds a service-type for installing programs and symlinking
their dotifles.

conf/home/program.scm [new file with mode: 0644]
conf/home/symlink.scm

diff --git a/conf/home/program.scm b/conf/home/program.scm
new file mode 100644 (file)
index 0000000..320e52e
--- /dev/null
@@ -0,0 +1,43 @@
+;; Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+;; License: GPL-3.0 or later.
+;;
+;; program.scm - service for installing programs and symlinking their dotfiles.
+
+(define-module (conf home program)
+  #:use-module (conf home symlink)
+  #:use-module (gnu home services)
+  #:use-module (gnu services configuration)
+  #:use-module (guix packages)
+  #:export (home-program-configuration
+           home-program-service-type))
+
+(define (packages? ps)
+  (or (null? ps)
+      (and (package? (car ps)) (packages? (cdr ps)))))
+
+(define (serialize-packages field-name value)
+  #~(#$@value))
+
+(define-configuration home-program-configuration
+  (packages
+   (packages)
+   "List of packages of the service to install.")
+  (dotfiles
+   (text-config '())
+   "List of dotfiles of the service to symlink."))
+
+(define (install-packages config)
+  (home-program-configuration-packages config))
+
+(define (symlink-dotfiles config)
+  (home-program-configuration-dotfiles config))
+
+(define home-program-service-type
+  (service-type (name 'home-program)
+               (extensions
+                (list
+                 (service-extension home-profile-service-type
+                                    install-packages)
+                 (service-extension home-symlink-service-type
+                                    symlink-dotfiles)))
+               (description "Installs programs and symlinks dotfiles.")))
index 10183f1d4cf9170553ecdf1f2ebd135b69920d9c..2935cf87393a91f852bf0b0d85cb63fd2de34629 100644 (file)
@@ -8,6 +8,7 @@
   #:use-module (gnu services configuration)
   #:use-module (guix gexp)
   #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
   #:export (home-symlink-service-type))
 
 (define (symlink paths)
@@ -26,6 +27,8 @@
                 (extensions
                  (list (service-extension home-files-service-type
                                          symlink)))
+                (compose concatenate)
+                (extend append)
                (default-value '())
                 (description "Copies files to the guix store and symlinks them in
 the home directory. For a @path{a/b/c/d.ext}, creates a @file{d.ext} file in the