[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Cookbook recipe from "The Repository as a Channel" section does not work
From: |
Nigko Yerden |
Subject: |
Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH |
Date: |
Tue, 13 Aug 2024 17:45:08 +0500 |
User-agent: |
Mozilla Thunderbird |
Hello Guix!,
Consider a minimal test git repository [1] created in line with Cookbook
recommendations [2]. It has the following file structure:
.
├── content
├── .guix-channel
├── guix.scm → .guix/modules/test-repo-package.scm
└── .guix
└── modules
└── test-repo-package.scm
Here 'content' is a text file. '.guix-channel' includes
-----------------begin------------------------------------------------------------
(channel
(version 0)
(directory ".guix/modules"))
-----------------end--------------------------------------------------------------
and '.guix/modules/test-repo-package.scm' provides a package definition:
-----------------begin------------------------------------------------------------
(define-module (test-repo-package)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (guix git-download)
#:use-module (guix build-system copy)
#:use-module (guix licenses))
(define vcs-file?
;; Return true if the given file is under version control.
(or (git-predicate (dirname (dirname (current-source-directory))))
(const #t)))
(define-public test-repo
(package
(name "test-repo")
(version "1.0")
(source (local-file "../.." "test-repo-checkout"
#:recursive? #t
#:select? vcs-file?))
(build-system copy-build-system)
(arguments
(list #:install-plan #~'(("content" "share/"))))
(synopsis "Example: git repo as a package")
(description "Example: git repo as a package")
(home-page "https://example.com")
(license gpl3+)))
test-repo
-----------------end--------------------------------------------------------------
All what this package does is to install 'content' file to
'/gnu/store/..../share/content' path. 'guix build -f guix.scm' command works as
expected. However, if we add the repository to the list of channels in
~/.config/guix/channels.scm file:
-----------------begin------------------------------------------------------------
(list ....
(channel
(name 'test-channel)
(url "https://gitlab.com/anigko/test-channel.git")
(branch "main")))
-----------------end--------------------------------------------------------------
and run 'guix pull', the command 'guix build test-repo' will fail with an error
message "No such file or directory 'content'" unless your GUILE_LOAD_PATH does
not include '~/.config/guix/current/share/guile/site/3.0/' path (this is the
path where a symlink to 'test-repo-package.scm' is installed by 'guix pull').
Normally GUILE_LOAD_PATH does include above-mentioned path. Indeed,
the GUIX System installer injects the following snippet
-----------------begin------------------------------------------------------------
eval "$(guix package --search-paths \
-p $HOME/.config/guix/current \
-p $HOME/.guix-profile \
-p /run/current-system/profile)"
-----------------end--------------------------------------------------------------
into '~/.bash_profile' file, setting many environment variables, and
GUILE_LOAD_PATH
in particular. In this case '(local-file "../.." "test-repo-checkout" ...)'
expression
is run from '~/.config/guix/current/share/guile/site/3.0/test-repo-package.scm'
file,
which is a symlink. But '(local-file "../.." ...)' does not follow this symlink,
and the 'source' field of 'test-repo' package is evaluated to
'~/.config/guix/current/share/guile/site/', which is wrong of course.
Here is a workaround for this behavior. From the definition of 'local-file' in
guix/gexp.scm one can deduce that the executed relevant code is:
(absolute-file-name "../.." (current-source-directory))
Here '(current-source-directory)' evaluates to
'~/.config/guix/current/share/guile/site/3.0/'.
However, if the symlink in '3.0/' directory would not target a file but another
directory,
say 'test-repo', containing a file 'package.scm' with the package definition,
then '(current-source-directory)' will follow the symlink, that is what we want.
The branch 'alt' of [1] provides a realization of the workaround:
.
├── content
├── .guix-channel
├── guix.scm → .guix/modules/test-repo/package.scm
└── .guix
└── modules
└── test-repo
└── package.scm
In comparison with 'test-repo-package.scm' file from 'main' branch, the
'package.scm'
file contains three modifications:
1.
(define-module (test-repo package)
2.
(define vcs-file?
;; Return true if the given file is under version control.
(or (git-predicate (dirname (dirname (dirname (current-source-directory)))))
(const #t)))
3.
(source (local-file "../../.." "test-repo-checkout"
#:recursive? #t
#:select? vcs-file?))
Thus defined repository ensures that 'test-repo' package is built without
errors on
systems with and without properly configured GUILE_LOAD_PATH.
Regards,
Nigko
[1] https://gitlab.com/anigko/test-channel.git
[2]
https://guix.gnu.org/en/cookbook/en/html_node/The-Repository-as-a-Channel.html
- Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH,
Nigko Yerden <=
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/13
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, Nigko Yerden, 2024/08/13
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/13
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, Nigko Yerden, 2024/08/13
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/14
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/14
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/14
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, Nigko Yerden, 2024/08/15
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, pelzflorian (Florian Pelz), 2024/08/18
- Re: Cookbook recipe from "The Repository as a Channel" section does not work for Guix with properly configured GUILE_LOAD_PATH, Nigko Yerden, 2024/08/19