From patchwork Mon May 19 09:50:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42747 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A7A8E27BC4B; Mon, 19 May 2025 10:51:51 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EF32727BC49 for ; Mon, 19 May 2025 10:51:50 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uGx9N-0003zi-Fa; Mon, 19 May 2025 05:51:13 -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 1uGx9L-0003zJ-VX for guix-patches@gnu.org; Mon, 19 May 2025 05:51:11 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGx9L-0001qM-FF; Mon, 19 May 2025 05:51:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=SrN96xUvUy7tvRb2XELDKg3EjfqqHlsfKZtP1sQeIao=; b=B4/QnOaU0Rg1iHr3x03fRui3QsvnWFHhFxpZ0kMJGGMiAg7Asw3ijLadNJ8KpQhE4t1mABTAQdSTavpB+hIcIOKOB6G9RExiW5G2jUqLO8xN/MnwMk91f8bomH3qpyk5BXPwLUn93K5cjWAMrr4Kg7UOVrFafP9E1EXf3YQ3HJxD/JF+UUR9gknBi8lzbzAm8s6+jqg9NktG9A/4PL4//KNPw/9XqPsQXY7sUB8KDM6fOoxvXFnftoDz80QFpYgyqGe2PfSc0QsXLM2nT7UGwR2VN9QmddSWAlybkx7D8aC93l583yStOC7Rs1nHSTNR8NjOfTcb5ttJmypJTqVUXQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uGx9C-0005m2-HW; Mon, 19 May 2025 05:51:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78378] [PATCH v1 1/3] gexp: Allow file-unions with dangling symlinks. References: In-Reply-To: Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, maxim.cournoyer@gmail.com, ludo@gnu.org, guix@cbaines.net, gabriel@erlikon.ch, dev@jpoiret.xyz, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 19 May 2025 09:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78378 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78378@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Gabriel Wicki , Josselin Poiret , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Gabriel Wicki , Josselin Poiret , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 78378-submit@debbugs.gnu.org id=B78378.174764823922139 (code B ref 78378); Mon, 19 May 2025 09:51:02 +0000 Received: (at 78378) by debbugs.gnu.org; 19 May 2025 09:50:39 +0000 Received: from localhost ([127.0.0.1]:37559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGx8o-0005l0-VT for submit@debbugs.gnu.org; Mon, 19 May 2025 05:50:39 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:54406) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uGx8g-0005k7-NG for 78378@debbugs.gnu.org; Mon, 19 May 2025 05:50:32 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ad55d6aeb07so240860066b.0 for <78378@debbugs.gnu.org>; Mon, 19 May 2025 02:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747648224; x=1748253024; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SrN96xUvUy7tvRb2XELDKg3EjfqqHlsfKZtP1sQeIao=; b=FnT06H3YeX85kQtuOia0zDuKYHAD0i3aFDo3AMmnQlebdUpfx7ZkpehPED3+2hnbQ0 owHopnJn2pQrFILWlnMmKqm7d241JlNJqlBgO7pXS3bPSeu57lHraJXPTqeD7fkCUNA5 lrHGjuE6xwAgQ2ejNrSrR98tu6bZg30X/xdCdtSKde3WqJgtyo7SiqpEN64l+vdgAP/m FEhFAqRAa9GokYoGWUDWou7E/84lKEu5FAOnCsjINAo0yq5rCE99h+27kahThQOXDnjl YeODVctYHkkMeCFmorRY6BbREgfMKUFFU1o4/1VUAe61Pgb+Zy+AyzalzLJjpnBMTXQb h93w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747648224; x=1748253024; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SrN96xUvUy7tvRb2XELDKg3EjfqqHlsfKZtP1sQeIao=; b=XTGzuFQXLiVhDmViyX9Tc2msM7C7jVPnYY5/rqjld/s/0OVUUsX40G9p3epYa3m0vz hXiY7K8TL32jRG3qk9wWK85SkgYlryEY/gQEXliS7gx5IfQGcHk+nsNKjMhK22nfW+tb MAphDlozmRFYxQfvQMt2E+3pzLjDkXxYuAyJ9m4mdcXO+pXjaujQwrJZa4kDa2CLAN8N 8pKaByXMnKPMKILzLz701va2XRJVqOmJIWpa52SpYq5gAz7yMKK4bIXMAvvldTBcg4/J IJkMVMP0JxShwn6GmAYkqbG5u4jiW3ZjHBbpbfnOaHHpUeHuVmPGNwtQC1z9puxb9WId G83Q== X-Gm-Message-State: AOJu0YxDYpSHrg9H9Yd3kH+TktbapGA7o2njGJRpX0xKZgZ2MZsy+z6Y b5m9MFNOCq4nbf1OuOVeooZyS8mZQvYQJkvIcpdGWbuo3y0LCQMEMlvN/qSZkwYeps/OUBJ2lL0 SoNgOL/vdaA== X-Gm-Gg: ASbGncuAi0WufWlHeD/+42b30Q9a4ddJCxMLOXhY5D812KSVo01ItivLdKFAdRNHxa8 DKZDzmHlVmq4T158Fr0o/mB9UDd3Q3iO2Qwq2a2L3A33xYBaaHrZjg+rdL36s4VgViqxpHw4aFC M8q1Abk6qfjOY7hbztwrz7LN7SlE6DfkYgg1iRjNjSIWI9cLbM8xeRvlsD+rry7D4W8BbvdIaOW AaYB/jrlEpbr/b7MbscxNQAcZ6Yonxspo8VL6phmkItMRsk69RxEGo3mvWxbVH2Ssyw637wIN25 Zu3bJgGapmlJ2ZjtsfHMAqQNQyoug1r6rzkKZ5aARNXCbEuyUQ== X-Google-Smtp-Source: AGHT+IGdw84OVaDs15C0JnnNwpA06QyDPlUH+/jLC8xMO0bEphVUXVd/xnIer1Zb1MWS7SxobBrUFA== X-Received: by 2002:a17:907:9803:b0:ad5:3156:2c06 with SMTP id a640c23a62f3a-ad536bdf940mr861699966b.28.1747648223736; Mon, 19 May 2025 02:50:23 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d278adcsm561225266b.84.2025.05.19.02.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 02:50:23 -0700 (PDT) From: Sergey Trofimov Date: Mon, 19 May 2025 11:50:08 +0200 Message-ID: <40e225a93a488b887fc770effe8f856c62620d28.1747647920.git.sarg@sarg.org.ru> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/gexp.scm (file-union): Add #:dangling-symlinks? parameter. Change-Id: I09d44ec785fd7141b02dee2d8dc23ccc499aa933 --- doc/guix.texi | 12 +++++++----- guix/gexp.scm | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) base-commit: 450a361532573a02389530a6a80b7821683ed41b diff --git a/doc/guix.texi b/doc/guix.texi index fd86551787..ef8504bb3e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12673,11 +12673,13 @@ G-Expressions This is the declarative counterpart of @code{text-file*}. @end deffn -@deffn {Procedure} file-union name files -Return a @code{} that builds a directory containing all of @var{files}. -Each item in @var{files} must be a two-element list where the first element is the -file name to use in the new directory, and the second element is a gexp -denoting the target file. Here's an example: +@deffn {Procedure} file-union name files [#:dangling-symlinks? #f] +Return a @code{} that builds a directory containing all +of @var{files}. Each item in @var{files} must be a two-element list +where the first element is the file name to use in the new directory, +and the second element is a gexp denoting the target file. +@code{#:dangling-symlinks?} controls if gexps must lower to an existing +file. Here's an example: @lisp (file-union "etc" diff --git a/guix/gexp.scm b/guix/gexp.scm index 8dd746eee0..85d049e26a 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -2144,7 +2144,7 @@ (define* (mixed-text-file name #:key guile #:rest text) (computed-file name build #:guile guile)) -(define* (file-union name files #:key guile) +(define* (file-union name files #:key guile (dangling-symlinks? #f)) "Return a that builds a directory containing all of FILES. Each item in FILES must be a two-element list where the first element is the file name to use in the new directory, and the second element is a gexp @@ -2170,14 +2170,15 @@ (define* (file-union name files #:key guile) (map (match-lambda ((target source) (gexp - (begin - ;; Stat the source to abort early if it does - ;; not exist. - (stat (ungexp source)) - - (mkdir-p (dirname (ungexp target))) - (symlink (ungexp source) - (ungexp target)))))) + (let ((source (ungexp source)) + (target (ungexp target))) + (unless (or (ungexp dangling-symlinks?) + (stat source #f)) + (error (format #f "~a points to inexistent file or dangling symlink ~a" + target source))) + + (mkdir-p (dirname target)) + (symlink source target))))) files))))) #:guile guile)) From patchwork Mon May 19 09:50:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42748 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E244E27BC4B; Mon, 19 May 2025 10:51:52 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 00C3327BC4E for ; Mon, 19 May 2025 10:51:50 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uGx9K-0003yS-2L; Mon, 19 May 2025 05:51:10 -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 1uGx9I-0003y5-4m for guix-patches@gnu.org; Mon, 19 May 2025 05:51:08 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGx9G-0001po-SA; Mon, 19 May 2025 05:51:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=17spmlx2jvVFmon0wWik5mH70YrXX0bY6FGy2m7lYNs=; b=gXYO8JDeMGhAhicAlw2JHhLGZDZNFUEbGWxUP8cdvqTeA3hP5EyxWbqc8gOuWcb05V6i2cFJuwycGDwAUUZUTFcjgVuCu9EseKCVy+LfFtOPSKLHiAnfGDwN/6Qt5bmX0hN8rd1Xuuu5h0z7NuHM5sEJ37vBgB3SOcgQmObaSxbdJmtU/W+6i5OHGdtEUgKbwW4lhe8QH5IQgPGZMwVAbXkQfnJ7ZrS+pdWxpAtGcU/5PcVXqok7w/TfHTKP96FskyaqijgqAUI+hljU4Fgzxtuct/9ll8idbxskwj5ubuy/bbgMauvG37SZWwEt7XgR+KTLtjS26hA6O9KmQ3rw8g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uGx9D-0005m8-0j; Mon, 19 May 2025 05:51:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78378] [PATCH v1 2/3] gexp: Add symlink-to procedure. Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, maxim.cournoyer@gmail.com, ludo@gnu.org, guix@cbaines.net, gabriel@erlikon.ch, dev@jpoiret.xyz, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 19 May 2025 09:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78378 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78378@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Gabriel Wicki , Josselin Poiret , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Gabriel Wicki , Josselin Poiret , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 78378-submit@debbugs.gnu.org id=B78378.174764824022147 (code B ref 78378); Mon, 19 May 2025 09:51:02 +0000 Received: (at 78378) by debbugs.gnu.org; 19 May 2025 09:50:40 +0000 Received: from localhost ([127.0.0.1]:37561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGx8p-0005l8-Rh for submit@debbugs.gnu.org; Mon, 19 May 2025 05:50:40 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:54749) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uGx8j-0005kI-5i for 78378@debbugs.gnu.org; Mon, 19 May 2025 05:50:33 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5fc8c68dc9fso7903512a12.1 for <78378@debbugs.gnu.org>; Mon, 19 May 2025 02:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747648226; x=1748253026; darn=debbugs.gnu.org; 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=17spmlx2jvVFmon0wWik5mH70YrXX0bY6FGy2m7lYNs=; b=SY0hQL1Ttgz0nsiJb2zr14PC1gcP02/mkGm6iVmc+cT2LBNqZXH5rKS/cxRyZPEDmr 1gE4AMP1plSn5nxjzzgOMju4CLgMluJ3A2cGf8xizf0WbzIeuWz7bAQSnFkocptehlr2 3R5ZlhemaqcrqRAdvLLR/4GPLEaM2woZ1/NDi6x0gG79L7JRxV0BgbaAEBxSNyPSLERa BF9erLnJd29dYM2z1BeEy18lQV2bHzQYspvdZ/aS3vwR1nmHjL0cEW8uleEgGPyWGtoT MIAQdOheGWbNV8Hs2dulxcDyNP1i3EsMNYdvoBSX5FltZNLJWib2Xu9aaMydD2Bmnc7d UhyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747648226; x=1748253026; 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=17spmlx2jvVFmon0wWik5mH70YrXX0bY6FGy2m7lYNs=; b=veLTEmPb6ENJHXBQZRqAFRssBq0yGv9Bz1cLWblAyqoZwrj8EAalSmWqNqKc4/jpWs D2MnG3/VlzKEFNGs015JcA5b9T5yiHFrOn955sSnPLj2Xld9fhk1xA7+8gnSTdVTb8z5 ZlcoEyq7SfOhRlrhWaz9LEvnYNqZwyLsZF71S+riCjD1wSRSzy1d+YgPAtNGw35fF+yI LoSstTPyFOGiEKyTtMeJbtyXDlwoSevTczEvXafAmj4ODeqXpLHQGemJUsJkh8C2+IjN G+oAUQUtlepBIQ7XzTbgFVPwT3Ddg4c5eIy/7ut+/L125VkDECBioNdLRbqfnynaBzXZ wsew== X-Gm-Message-State: AOJu0YxyLU4zGQH1yyDnNHwriNznUigR+50nghQyUdNYAf6OzgFmtNhY IjdJeXraaZRmxD4in906fR+xgWuFLdXQaCPGaZS/KsEX6TKmIZtnl7DjZVYVf80Jp3Alv5i/jgN XasC1sDttgA== X-Gm-Gg: ASbGncvVhNx4i/845UkNGa6X6dQ7+TcNfJxVJI7AYWyzzygy0dD1kCUdr9jvkHn9VZD vM8KPae/pUz3bRL8HzehGNRQ2s0EmkXC80wBLFJognGsauKP3mA4UBg5ImQ7YrhPlHzEMVdk1UW JpbsEcrL7H/0Gh8brXq9lELv9QwVS3KxG/9h1Hes2GyaPCpVNfdsWwUrbFtx5kDeH+RzmQ17v1E UTdzN6THs8LP1vZRRh088XUtfMS2Rk9Ha45leWM2yRHbQUucXYfpl6FapS8AAkOIeJI15Jx4Zq3 xODErf25jRUNKardBef3NEjpxHVJk7AEzFSA2hi5FcWnrQPE3OMuAUxBQbVg X-Google-Smtp-Source: AGHT+IFopxG1dF9ofAs1rFb+SJYtkNtj7keth1htjYw+b90y97ADjahTZjr9YmPg78OQZZm9o5ihsA== X-Received: by 2002:a17:907:1c2a:b0:ad2:40f4:c251 with SMTP id a640c23a62f3a-ad536bdff0bmr986460666b.35.1747648226561; Mon, 19 May 2025 02:50:26 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d4382d7sm560856166b.117.2025.05.19.02.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 02:50:26 -0700 (PDT) From: Sergey Trofimov Date: Mon, 19 May 2025 11:50:09 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: <40e225a93a488b887fc770effe8f856c62620d28.1747647920.git.sarg@sarg.org.ru> References: <40e225a93a488b887fc770effe8f856c62620d28.1747647920.git.sarg@sarg.org.ru> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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{} 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)) From patchwork Mon May 19 09:50:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42749 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7214827BC49; Mon, 19 May 2025 10:51:54 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F3F9627BC4D for ; Mon, 19 May 2025 10:51:50 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uGx9L-0003yv-Ak; Mon, 19 May 2025 05:51:11 -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 1uGx9J-0003yP-RC for guix-patches@gnu.org; Mon, 19 May 2025 05:51:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGx9I-0001q3-QD; Mon, 19 May 2025 05:51:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=lbTmUpMeznC1BlH4SjtP8GdmpGUFySP6Pqj1HcPA1fc=; b=r1dWQG14gjrfXUjusvjhiLMlXvg5pe67hzI6703dpfuUq4TvEYVQNOV/1HCalVUA8/7Wp27F0PyCYzsUUk+S+grD9DLEP2Jd24A+wVfJaGsALS1S2ecsarh1Mh3QzYns3m5wwzQmeM5UaPPz7ZXzZKV1kyYRiedePncFokIOqTOqppMZ95pFExkb94f/Ww7qRSYYUZDgfBMMpozfKgaHcNGCs1NNVvhijOih+8707JpOtXnd4IPyWhjZ0Va813yR4zXBfopUlKd2Ho1OhaB9JFd/Chb9ocCtAUms4BMUl4TGF75fuEjbueDyf2tHxxm8QMNHzLzt+RRsuzLUDl4tGQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uGx9D-0005mE-FP; Mon, 19 May 2025 05:51:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78378] [PATCH v1 3/3] home: services: Build "files" union allowing dangling symlinks. Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, maxim.cournoyer@gmail.com, ludo@gnu.org, andrew@trop.in, hako@ultrarare.space, janneke@gnu.org, tanguy@bioneland.org, guix-patches@gnu.org Resent-Date: Mon, 19 May 2025 09:51:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78378 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78378@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin , Hilton Chain , Janneke Nieuwenhuizen , Tanguy Le Carrour X-Debbugs-Original-Xcc: Sergey Trofimov , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Andrew Tropin , Hilton Chain , Janneke Nieuwenhuizen , Tanguy Le Carrour Received: via spool by 78378-submit@debbugs.gnu.org id=B78378.174764825122176 (code B ref 78378); Mon, 19 May 2025 09:51:03 +0000 Received: (at 78378) by debbugs.gnu.org; 19 May 2025 09:50:51 +0000 Received: from localhost ([127.0.0.1]:37563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGx90-0005lc-F3 for submit@debbugs.gnu.org; Mon, 19 May 2025 05:50:51 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:54406) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uGx8l-0005kQ-6m for 78378@debbugs.gnu.org; Mon, 19 May 2025 05:50:35 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-ad55d6aeb07so240878366b.0 for <78378@debbugs.gnu.org>; Mon, 19 May 2025 02:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747648228; x=1748253028; darn=debbugs.gnu.org; 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=lbTmUpMeznC1BlH4SjtP8GdmpGUFySP6Pqj1HcPA1fc=; b=W755QXwhuvcgnwcaUgUYEEvn8K/ZcPJYV39F4qeCBVGQoqJ31L8rBrAoUaC6a6FmLO BR8kAGYm0lkefw0Ysayz9mTkC8kKDCkNk05PV/q+kCz1cJ3IML7kaQRdK31AKnJwPTkg PKmujui8eLUdbykGubHpsWKSkUWQm1TQkYGka7eZVUXUS0WZmYR+NauahS69OFE4mCX3 0tpHDWQHrziSstokQXXFFTRj/ltNZc6F97DcU3AtiTNQmdf0vAbX9BtkB/e9U1TEdOWk CFhjIKTw+2zFoaUFg79EAFrW4VcjSG3ZPtksbng1gh6pyPJF+eUryzseXKFVOJhiX70U KO3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747648228; x=1748253028; 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=lbTmUpMeznC1BlH4SjtP8GdmpGUFySP6Pqj1HcPA1fc=; b=HyJwuJafnrwq2Bf7snwOmG7y+VP10jckGwblkkNn8f6Kew21jDeVuI26mA4gtIDycA IREK2fJPgLiize1UNwURoPMFh1URKBWeYRukfxCUDK2iWFTuy0GK6y8drApM7aXbYRqB +MO6tVCPznrK6BrHPrqHj+h5AP2u6euzOquUKkQx5Id944YghnGMYIFRqslvYOBp7LxI eaWKqIFN9biNPaUlk9kbAQY63t1gN+u1Pjkx5tepL8avJiaa7np2aUvAU46/raszYxdd THy+bFkPLZ/CywIBC9IiagxzbjcrunWbbTO4jUC7K8og9hwVqOiXQ10NeImYmtNU2D9H R1Kw== X-Gm-Message-State: AOJu0Yw9taOKpD0YxmPmO3X5HnLmTBUDMAny3IhOzTdGojXHb91XSN/G V9v+zeOB0QHIZULenU32d0TM8bbqd7lpFO85L8ShhEcXxols1ZE7jzH8Ih7tAcVjc7r2p2TBCvV hJ7T99BfFsQ== X-Gm-Gg: ASbGncs0/GcGeOYZRdF1tZJfvZdhzPJY3rAKDQYH1ZxASSKztzhxptkIQ9uLjNCA9/7 Uczwu0e+wpa7Z/7CUpT5hYTkt6J2IOpDUiCsQQ9XDEQojm8ii9aGDsr7cxZeVWq5q44euPF6jVq dlb5eiwG+XqX9QN44AcJ2BWtEX/jn6BVZPxljvIF7YuGlyRtMO30Es2hKXn6TG8dnzMjn+AgrQy lskzH/Gt+O5zHHSgdOg623wFgfCUEylMXo2Tf8rbeCt0oBXfoOBE2Dmt2cenElVZKKujBYmLALm d3H1o28p+ESdqJMq87+gldinVBLynWc8BjeLlDJbUmU8VI1pRQ== X-Google-Smtp-Source: AGHT+IEEjp9d5TSx+/lBv8rBnZt6y1NEbL4AHEU12phUK1GOf+GFAZO4aovkqsjcQSXVcAGLk7py0w== X-Received: by 2002:a17:907:e916:b0:ac7:c7cd:ac39 with SMTP id a640c23a62f3a-ad536b82a85mr899881866b.24.1747648228541; Mon, 19 May 2025 02:50:28 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d438384sm571442866b.106.2025.05.19.02.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 02:50:28 -0700 (PDT) From: Sergey Trofimov Date: Mon, 19 May 2025 11:50:10 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: <40e225a93a488b887fc770effe8f856c62620d28.1747647920.git.sarg@sarg.org.ru> References: <40e225a93a488b887fc770effe8f856c62620d28.1747647920.git.sarg@sarg.org.ru> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/home/services.scm (files->files-directory): Build file union without checking for existence of included items. * tests/guix-home.sh: Verify symlinking files out of store works. Change-Id: I94054003f4a6be944252ce7a397cf56f0b979554 --- gnu/home/services.scm | 3 ++- tests/guix-home.sh | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 2342dc5e07..c09e6cdadd 100644 --- a/gnu/home/services.scm +++ b/gnu/home/services.scm @@ -343,7 +343,8 @@ (define (files->files-directory files) ;; leading to a build failure of "files.drv". (assert-no-duplicates files) - (file-union "files" files)) + ;; Allow symlinks to locations out of store + (file-union "files" files #:dangling-symlinks? #t)) ;; Used by symlink-manager (define home-files-directory "files") diff --git a/tests/guix-home.sh b/tests/guix-home.sh index dbfe7dbd48..b8d90196f1 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -73,7 +73,9 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT (list `(".config/test.conf" ,(plain-file "tmp-file.txt" - "the content of ~/.config/test.conf")))) + "the content of ~/.config/test.conf")) + + `("symlink" ,(symlink-to "")))) (service home-bash-service-type (home-bash-configuration @@ -104,6 +106,7 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT "# the content of bashrc-test-config.sh")))))))) EOF + sed -i "s,,$test_directory," home.scm echo -n "# dot-bashrc test file for guix home" > "dot-bashrc" # Check whether the graph commands work as expected. @@ -126,6 +129,7 @@ EOF guix home container home.scm -- cat '~/.config/test.conf' | \ grep "the content of" guix home container home.scm -- test -h '~/.bashrc' + guix home container home.scm -- test -h '~/symlink' test "$(guix home container home.scm -- id -u)" = 1000 guix home container home.scm -- test -f '$HOME/sample/home.scm' && false guix home container home.scm --expose="$PWD=$HOME/sample" -- \ @@ -153,6 +157,8 @@ EOF test -d "${HOME}/.guix-home" test -h "${HOME}/.bash_profile" test -h "${HOME}/.bashrc" + test -h "${HOME}/symlink" + test "$(readlink -f $HOME/symlink)" == "$test_directory" grep 'alias run="guix shell"' "$HOME/.bashrc" grep "alias path='echo \$PATH'" "$HOME/.bashrc" test "$(tail -n 2 "${HOME}/.bashrc")" == "\