all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 357dfd18e689e8c8ad03ec36f3b9c497ba656772 2044 bytes (raw)
name: gnu/packages/patches/perl6-zef.config-interpolation.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
From f9e4306cba875999a44286bd8c585ef9e84a7a88 Mon Sep 17 00:00:00 2001
From: Daniel Sockwell <daniel@codesections.com>
Date: Fri, 30 Sep 2022 17:43:04 -0400
Subject: [PATCH 4/4] Improve support for env vars in config.json

The "StoreDir" and "TempDir" previously allowed for limited
interpolation (limited to $*HOME and $*TMPDIR).  This commit adds
interpolation of $*XDG_DATA_HOME, $*XDG_CONFIG_HOME, and
$*XDG_STATE_HOME with default values from the XDG spec, see
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

It also extends the interpolation for the same values to "DefaultCUR",
which also specifies a path.
---
 lib/Zef/Config.rakumod | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/Zef/Config.rakumod b/lib/Zef/Config.rakumod
index f77c6be..4362b17 100644
--- a/lib/Zef/Config.rakumod
+++ b/lib/Zef/Config.rakumod
@@ -4,8 +4,15 @@ module Zef::Config {
     our sub parse-file($path) {
         my %config = %(Zef::from-json( $path.IO.slurp ));
 
-        for %config.grep(*.key.ends-with('Dir')) {
-            %config{$_.key} = $_.value.subst(/'{$*HOME}' || '$*HOME'/, $*HOME // $*TMPDIR, :g);
+        for %config.grep({.key.ends-with('Dir') || .key eq 'DefaultCUR'}) {
+            my $home = $*HOME // $*TMPDIR;
+            %config{$_.key} = $_.value.subst(/'{$*XDG_DATA_HOME}' || '$*XDG_DATA_HOME'/,
+                                          %*ENV<XDG_DATA_HOME> // "$home/.local/share", :g);
+            %config{$_.key} = $_.value.subst(/'{$*XDG_CONFIG_HOME}' || '$*XDG_CONFIG_HOME'/,
+                                          %*ENV<XDG_CONFIG_HOME> // "$home/.config", :g);
+            %config{$_.key} = $_.value.subst(/'{$*XDG_STATE_HOME}' || '$*XDG_STATE_HOME'/,
+                                          %*ENV<XDG_STATE_HOME> // "$home/.local/bin", :g);
+            %config{$_.key} = $_.value.subst(/'{$*HOME}' || '$*HOME'/, $home, :g);
             %config{$_.key} = $_.value.subst(/'{$*TMPDIR}' || '$*TMPDIR'/, $*TMPDIR, :g);
         }
 
-- 
2.37.3


debug log:

solving 357dfd18e6 ...
found 357dfd18e6 in https://yhetil.org/guix/4f73f996ad1242eed18abb2324412903@codesections.com/

applying [1/1] https://yhetil.org/guix/4f73f996ad1242eed18abb2324412903@codesections.com/
diff --git a/gnu/packages/patches/perl6-zef.config-interpolation.patch b/gnu/packages/patches/perl6-zef.config-interpolation.patch
new file mode 100644
index 0000000000..357dfd18e6

1:31: trailing whitespace.
 
1:45: trailing whitespace.
 
1:46: trailing whitespace.
-- 
Checking patch gnu/packages/patches/perl6-zef.config-interpolation.patch...
1:48: new blank line at EOF.
+
Applied patch gnu/packages/patches/perl6-zef.config-interpolation.patch cleanly.
warning: 4 lines add whitespace errors.

index at:
100644 357dfd18e689e8c8ad03ec36f3b9c497ba656772	gnu/packages/patches/perl6-zef.config-interpolation.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.