GNU bug report logs - #78378
[PATCH 0/2] home: services: Build "files" union allowing dangling symlinks.

Previous Next

Package: guix-patches;

Reported by: Sergey Trofimov <sarg <at> sarg.org.ru>

Date: Sun, 11 May 2025 16:02:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Full log


Message #23 received at 78378 <at> debbugs.gnu.org (full text, mbox):

From: Sergey Trofimov <sarg <at> sarg.org.ru>
To: 78378 <at> debbugs.gnu.org
Cc: Sergey Trofimov <sarg <at> sarg.org.ru>
Subject: [PATCH v1 2/3] gexp: Add symlink-to procedure.
Date: Mon, 19 May 2025 11:50:09 +0200
* guix/gexp.scm (symlink-to): New procedure.
* doc/guix.texi (G-Expressions): Document it.

Change-Id: I7c1ba3a29a4e5350cb4f196185b7171c4750b6b8
---
 doc/guix.texi | 11 +++++++++++
 guix/gexp.scm |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index ef8504bb3e..02f472246a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12692,6 +12692,17 @@ G-Expressions
 This yields an @code{etc} directory containing these two files.
 @end deffn
 
+@deffn {Procedure} symlink-to target
+Return a @code{<computed-file>} that is a symbolic link to target.
+Note, that the target does not need to exist at the build time.  One of
+uses is to put arbitrary symlinks into user's home:
+
+@lisp
+(service home-files-service-type
+  `(("Sync" ,(symlink-to "/storage/Sync"))))
+@end lisp
+@end deffn
+
 @deffn {Procedure} directory-union name things
 Return a directory that is the union of @var{things}, where @var{things} is a list of
 file-like objects denoting directories.  For example:
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 85d049e26a..5cb5e8e4e4 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -119,6 +119,7 @@ (define-module (guix gexp)
             file-union
             directory-union
             references-file
+            symlink-to
 
             imported-files
             imported-modules
@@ -2182,6 +2183,10 @@ (define* (file-union name files #:key guile (dangling-symlinks? #f))
                             files)))))
                  #:guile guile))
 
+(define (symlink-to target)
+  "Return an object that is a symlink to TARGET."
+  (computed-file "link" (gexp (symlink (ungexp target) (ungexp output)))))
+
 (define* (directory-union name things
                           #:key (copy? #f) (quiet? #f)
                           (resolve-collision 'resolve-collision/default))
-- 
2.49.0





This bug report was last modified 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.