GNU bug report logs -
#70829
[PATCH] guix: gexp: Add assume-source-relative-file-name
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 70829 in the body.
You can then email your comments to 70829 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix <at> cbaines.net, pelzflorian <at> pelzflorian.de, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Wed, 08 May 2024 12:19:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Richard Sent <richard <at> freakingpenguin.com>
:
New bug report received and forwarded. Copy sent to
guix <at> cbaines.net, pelzflorian <at> pelzflorian.de, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
.
(Wed, 08 May 2024 12:19:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests: gexp.scm: Test it.
---
Hi Guix!
In the current local file setup is it is impossible to use
(local-file) with a non-literal source-relative file name. With this
patch, it is possible.
doc/guix.texi | 5 +++++
guix/gexp.scm | 15 ++++++++++++++-
tests/gexp.scm | 6 ++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 221db5c022..1fc7be7cd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12166,6 +12166,11 @@ G-Expressions
(local-file (assume-valid-file-name alice-key-file-path))
@end lisp
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword. When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
gexp-input-native?
assume-valid-file-name
+ assume-source-relative-file-name
local-file
local-file?
local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
warn about it."
file)
+(define-syntax-rule (assume-source-relative-file-name file)
+ "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+ file)
+
(define-syntax local-file
(lambda (s)
"Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
This is the declarative counterpart of the 'interned-file' monadic procedure.
It is implemented as a macro to capture the current source directory where it
appears."
- (syntax-case s (assume-valid-file-name)
+ (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
((_ file rest ...)
(string? (syntax->datum #'file))
;; FILE is a literal, so resolve it relative to the source directory.
#'(%local-file file
(delay (absolute-file-name file (current-source-directory)))
rest ...))
+ ((_ (assume-source-relative-file-name file) rest ...)
+ ;; FILE is not a literal, but the user requested we look it up
+ ;; relative to the current source directory.
+ #'(%local-file file
+ (delay (absolute-file-name file (current-source-directory)))
+ rest ...))
((_ (assume-valid-file-name file) rest ...)
;; FILE is not a literal, so resolve it relative to the current
;; directory. Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
(let ((file (local-file (string-copy "../base32.scm"))))
(local-file-absolute-file-name file)))))
+(test-equal "local-file, non-literal source relative file name"
+ (current-filename)
+ (let ((file (local-file (assume-source-relative-file-name
+ (string-append "gexp" ".scm")))))
+ (local-file-absolute-file-name file)))
+
(test-assert "local-file, relative file name, within gexp"
(let* ((file (search-path %load-path "guix/base32.scm"))
(interned (add-to-store %store "base32.scm" #f "sha256" file)))
base-commit: da41a8f5e85774e2a507d821b5d52e600fb9d1d7
prerequisite-patch-id: 5c8bedc278ab541b86ee4af63042a5893109639e
--
2.41.0
Information forwarded
to
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Wed, 08 May 2024 18:35:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 70829 <at> debbugs.gnu.org (full text, mbox):
doc/guix.texi (G-Expressions): Document the use of assume-valid-file-name with
local-file.
---
Missed a commit that my original revision depended on. I initially
submitted that previous commit to https://qa.guix.gnu.org/issue/70830,
but since both commits change the same guix.texi section on similar
subject matter, I'm resubmitting as a series.
doc/guix.texi | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 1c1e0164e7..221db5c022 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12154,6 +12154,18 @@ G-Expressions
absolute file name and @var{stat} is the result of @code{lstat}; exclude
entries for which @var{select?} does not return true.
+@var{file} can be wrapped in the @code{assume-valid-file-name} syntactic
+keyword. When this is done, there will not be a warning when
+@code{local-file} is used with a non-literal path. The path is still
+looked up relative to the current working directory at run time.
+Wrapping is done like this:
+
+@lisp
+(define alice-key-file-path "alice.pub")
+;; ...
+(local-file (assume-valid-file-name alice-key-file-path))
+@end lisp
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
base-commit: 7b7f299bb493e485c5534b8c554e51d4f3a8c026
--
2.41.0
Information forwarded
to
guix <at> cbaines.net, pelzflorian <at> pelzflorian.de, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Wed, 08 May 2024 18:35:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 70829 <at> debbugs.gnu.org (full text, mbox):
guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests: gexp.scm: Test it.
---
doc/guix.texi | 5 +++++
guix/gexp.scm | 15 ++++++++++++++-
tests/gexp.scm | 6 ++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 221db5c022..1fc7be7cd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12166,6 +12166,11 @@ G-Expressions
(local-file (assume-valid-file-name alice-key-file-path))
@end lisp
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword. When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
gexp-input-native?
assume-valid-file-name
+ assume-source-relative-file-name
local-file
local-file?
local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
warn about it."
file)
+(define-syntax-rule (assume-source-relative-file-name file)
+ "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+ file)
+
(define-syntax local-file
(lambda (s)
"Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
This is the declarative counterpart of the 'interned-file' monadic procedure.
It is implemented as a macro to capture the current source directory where it
appears."
- (syntax-case s (assume-valid-file-name)
+ (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
((_ file rest ...)
(string? (syntax->datum #'file))
;; FILE is a literal, so resolve it relative to the source directory.
#'(%local-file file
(delay (absolute-file-name file (current-source-directory)))
rest ...))
+ ((_ (assume-source-relative-file-name file) rest ...)
+ ;; FILE is not a literal, but the user requested we look it up
+ ;; relative to the current source directory.
+ #'(%local-file file
+ (delay (absolute-file-name file (current-source-directory)))
+ rest ...))
((_ (assume-valid-file-name file) rest ...)
;; FILE is not a literal, so resolve it relative to the current
;; directory. Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
(let ((file (local-file (string-copy "../base32.scm"))))
(local-file-absolute-file-name file)))))
+(test-equal "local-file, non-literal source relative file name"
+ (current-filename)
+ (let ((file (local-file (assume-source-relative-file-name
+ (string-append "gexp" ".scm")))))
+ (local-file-absolute-file-name file)))
+
(test-assert "local-file, relative file name, within gexp"
(let* ((file (search-path %load-path "guix/base32.scm"))
(interned (add-to-store %store "base32.scm" #f "sha256" file)))
--
2.41.0
Information forwarded
to
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Wed, 08 May 2024 18:47:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 70829 <at> debbugs.gnu.org (full text, mbox):
doc/guix.texi (G-Expressions): Document the use of assume-valid-file-name with
local-file.
---
doc/guix.texi | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 1c1e0164e7..221db5c022 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12154,6 +12154,18 @@ G-Expressions
absolute file name and @var{stat} is the result of @code{lstat}; exclude
entries for which @var{select?} does not return true.
+@var{file} can be wrapped in the @code{assume-valid-file-name} syntactic
+keyword. When this is done, there will not be a warning when
+@code{local-file} is used with a non-literal path. The path is still
+looked up relative to the current working directory at run time.
+Wrapping is done like this:
+
+@lisp
+(define alice-key-file-path "alice.pub")
+;; ...
+(local-file (assume-valid-file-name alice-key-file-path))
+@end lisp
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
base-commit: 7b7f299bb493e485c5534b8c554e51d4f3a8c026
--
2.41.0
Information forwarded
to
guix <at> cbaines.net, pelzflorian <at> pelzflorian.de, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Wed, 08 May 2024 18:47:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 70829 <at> debbugs.gnu.org (full text, mbox):
guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests/gexp.scm: Test it.
Change-Id: Ibc24239ad201797c151b01e0b4fec43b07b4a02f
---
Typo in the previous commit message. Sorry for the noise!
doc/guix.texi | 5 +++++
guix/gexp.scm | 15 ++++++++++++++-
tests/gexp.scm | 6 ++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 221db5c022..1fc7be7cd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12166,6 +12166,11 @@ G-Expressions
(local-file (assume-valid-file-name alice-key-file-path))
@end lisp
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword. When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
gexp-input-native?
assume-valid-file-name
+ assume-source-relative-file-name
local-file
local-file?
local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
warn about it."
file)
+(define-syntax-rule (assume-source-relative-file-name file)
+ "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+ file)
+
(define-syntax local-file
(lambda (s)
"Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
This is the declarative counterpart of the 'interned-file' monadic procedure.
It is implemented as a macro to capture the current source directory where it
appears."
- (syntax-case s (assume-valid-file-name)
+ (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
((_ file rest ...)
(string? (syntax->datum #'file))
;; FILE is a literal, so resolve it relative to the source directory.
#'(%local-file file
(delay (absolute-file-name file (current-source-directory)))
rest ...))
+ ((_ (assume-source-relative-file-name file) rest ...)
+ ;; FILE is not a literal, but the user requested we look it up
+ ;; relative to the current source directory.
+ #'(%local-file file
+ (delay (absolute-file-name file (current-source-directory)))
+ rest ...))
((_ (assume-valid-file-name file) rest ...)
;; FILE is not a literal, so resolve it relative to the current
;; directory. Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
(let ((file (local-file (string-copy "../base32.scm"))))
(local-file-absolute-file-name file)))))
+(test-equal "local-file, non-literal source relative file name"
+ (current-filename)
+ (let ((file (local-file (assume-source-relative-file-name
+ (string-append "gexp" ".scm")))))
+ (local-file-absolute-file-name file)))
+
(test-assert "local-file, relative file name, within gexp"
(let* ((file (search-path %load-path "guix/base32.scm"))
(interned (add-to-store %store "base32.scm" #f "sha256" file)))
--
2.41.0
Information forwarded
to
guix <at> cbaines.net, pelzflorian <at> pelzflorian.de, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#70829
; Package
guix-patches
.
(Sun, 02 Jun 2024 20:07:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 70829 <at> debbugs.gnu.org (full text, mbox):
guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests: gexp.scm: Test it.
---
Hi all,
Since #70830 wound up being merged, I'm resubmitting this patch
rebased on master and without the documentation for
assume-valid-file-name.
doc/guix.texi | 5 +++++
guix/gexp.scm | 15 ++++++++++++++-
tests/gexp.scm | 6 ++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 8cc01b2e65..d291da4b98 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12204,6 +12204,11 @@ G-Expressions
(local-file (assume-valid-file-name alice-key-file-path))
@end lisp
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword. When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
This is the declarative counterpart of the @code{interned-file} monadic
procedure (@pxref{The Store Monad, @code{interned-file}}).
@end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
gexp-input-native?
assume-valid-file-name
+ assume-source-relative-file-name
local-file
local-file?
local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
warn about it."
file)
+(define-syntax-rule (assume-source-relative-file-name file)
+ "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+ file)
+
(define-syntax local-file
(lambda (s)
"Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
This is the declarative counterpart of the 'interned-file' monadic procedure.
It is implemented as a macro to capture the current source directory where it
appears."
- (syntax-case s (assume-valid-file-name)
+ (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
((_ file rest ...)
(string? (syntax->datum #'file))
;; FILE is a literal, so resolve it relative to the source directory.
#'(%local-file file
(delay (absolute-file-name file (current-source-directory)))
rest ...))
+ ((_ (assume-source-relative-file-name file) rest ...)
+ ;; FILE is not a literal, but the user requested we look it up
+ ;; relative to the current source directory.
+ #'(%local-file file
+ (delay (absolute-file-name file (current-source-directory)))
+ rest ...))
((_ (assume-valid-file-name file) rest ...)
;; FILE is not a literal, so resolve it relative to the current
;; directory. Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
(let ((file (local-file (string-copy "../base32.scm"))))
(local-file-absolute-file-name file)))))
+(test-equal "local-file, non-literal source relative file name"
+ (current-filename)
+ (let ((file (local-file (assume-source-relative-file-name
+ (string-append "gexp" ".scm")))))
+ (local-file-absolute-file-name file)))
+
(test-assert "local-file, relative file name, within gexp"
(let* ((file (search-path %load-path "guix/base32.scm"))
(interned (add-to-store %store "base32.scm" #f "sha256" file)))
base-commit: 2e53fa5346bf52f6d6d26e035bc905ebd410dabb
--
2.45.1
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Wed, 04 Sep 2024 13:46:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Richard Sent <richard <at> freakingpenguin.com>
:
bug acknowledged by developer.
(Wed, 04 Sep 2024 13:46:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 70829-done <at> debbugs.gnu.org (full text, mbox):
Richard Sent <richard <at> freakingpenguin.com> skribis:
> guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
> (local-file): Use assume-source-relative-file-name to look up a non-literal
> file relative to the current source directory.
> doc/guix.texi (G-expressions): Document it.
> tests: gexp.scm: Test it.
Finally applied; this looks useful, thanks!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 03 Oct 2024 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 161 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.