Commit Graph
2465 Commits
Author SHA1 Message Date
Evgeny Pisemsky 36d403cfd7 scripts: system: Remove unused syntax.
* guix/scripts/system.scm (save-environment-excursion): Remove syntax.
* tests/profiles.scm (with-environment-excursion): Prepare syntax for reuse.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Modified-by: Ludovic Courtès <ludo@gnu.org>
Merges: #10134
2026-07-23 23:45:30 +02:00
Ludovic Courtès 3fbe4aa9f3 weather: Install a timeout on connection establishment.
Previously ‘guix weather’ would wait for the system timeout to be
triggered (typically more than 120s) when establishing a connection to a
substitute server.

* guix/scripts/weather.scm (guix-weather): Parameterize
‘default-connection-establishment-timeout’.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-07-13 17:57:14 +02:00
Reepca Russelstein 57fd857c1e scripts: substitute: Accommodate renaming unwritable directories.
This fixes a regression introduced in 26d7eb8a4a
when running ‘guix-daemon’ without root privileges.

On rootless installations, we must abide by the usual file access rules, which
include the requirement that a directory be writable before it be renamed (the
rationale being that its ".." entry needs to be modified).

* guix/scripts/substitute.scm (rename-file*): New procedure.
(guix-substitute): Use it.
* tests/substitute.scm (directory-nar-sha256): New procedure.
(%narinfo/directory): New variable.
(call-with-narinfo): Add '#:directory?' keyword argument.
(with-directory-narinfo): New syntax.
("substitute, authorized key, directory"): New test case.

Fixes: guix/guix#9686
Change-Id: I9d399dd5f1717b7d02854d97e1100a0a464fac75
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #9702
2026-07-05 11:47:15 +02:00
Ludovic Courtès 48cdb840ac channels: Do not compute cache key from channel name [security fix].
Previously the cache key would be computed by prepending “channels/” to the
channel name.  Thus, a channel defined like this:

  (channel (name (symbol->string "../../../../PWND")) …)

… would lead to the creation of a file in $HOME.

This attack is accessible even with channel files evaluated in a sandbox, and
even if the channel is otherwise marked as trusted.

This change fixes that.

* guix/git-authenticate.scm (repository-cache-key): Deprecate.
(authenticate-repository): Change default value of #:cache-key.
(authenticated-commit-cache-file): Replace dots in KEY with dashes.
* guix/scripts/git/authenticate.scm (guix-git-authenticate): Use ‘commit’ as
the default value of ‘cache-key’.
* guix/channels.scm (maybe-link-old-cache): New procedure.
(authenticate-channel): Remove ‘cache-key’ and #:cache-key argument to
‘authenticate-repository’.  Call ‘maybe-link-old-cache’.

Reported-by: Sergio Pastor Pérez <sergio.pastor-perez@inria.fr>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-07-02 19:42:48 +02:00
Ludovic Courtès 0d28f34607 substitutes: Remove duplicate and unused ‘narinfo-from-file’.
* guix/scripts/substitute.scm (narinfo-from-file): Remove.

Change-Id: Ie287f5a1bf5420426349ed4240e055dac675cb99
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-07-02 19:42:47 +02:00
Reepca Russelstein 26d7eb8a4a scripts: substitute: restored nars only appear after verification.
The hash of a nar is only known once 'download-nar' completes.  By that point
the nar may already have been partially-restored to its destination for some
time.  Additionally, after a hash mismatch is detected, 'guix substitute'
leaves the invalid contents at the specified destination.  This means that
untrusted, attacker-controlled contents are present at what at some point may
have been or at some point may become a valid store path.  It is entirely
possible that a user or program won't check that a given store item is valid
before trying to use it (it may be that 'guix gc' was run while an obscured
reference was held).  Let's protect them in that case by ensuring that
unverified contents are kept elsewhere, in a temporary directory.

While implementing this one such program was discovered: tests/substitute.scm.
It actually incorrectly computes the hashes of the nars it supplies to (guix
scripts substitute), computing the hash of the plain contents instead of the
hash of the nar.  These tests nevertheless passed because they didn't check
what (guix scripts substitute) gave as output, instead only checking that the
expected contents were at the specified destination.

* guix/scripts/substitute.scm (call-with-temporary-directory-in): new
  procedure.
  (guix-substitute): use it to create a temporary directory next to the final
  destination to restore the nar inside of.  Once it is fully restored, if the
  hash matches, move it to the final destination, deleting the file currently
  there if it already exists.
* tests/substitute.scm (plain-file-nar-sha256): new procedure.
  (%narinfo, "substitute, narinfo with several URLS" test): use it.

Change-Id: Ifeb9b4c912f9d9b2e7477d237da04e7d5175ff83
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-07-02 19:42:47 +02:00
Reepca Russelstein fc06ada060 scripts: substitute: restrict where "file://" URIs can be used [security fix].
There are two potential places where file:// URIs could be used in 'guix
substitute':
1. The substitute urls, which are used for fetching narinfos.  These can come
   from the daemon, via daemon option "substitute-urls", from the client, via
   daemon option "untrusted-substitute-urls", or from 'guix discover'.  The
   latter two must not be allowed to provide file:// URIs, since that could be
   used to cause the daemon to read private files, files in /proc or /dev,
   etc, and various parts of those files may show up in the backtrace from
   'guix substitute'.

2. The narinfos themselves, which may offer arbitrarily many URIs to download
   the nar of the store item in question.  These URIs do not need to be
   in the signed portion of the narinfo, so they may be attacker-controlled.
   These should also not be allowed to provide file:// URIs, with the sole
   exception being in the case of the test suite for the sake of simplifying
   the tests.

To accomplish this, we error out of 'guix substitute' if
"untrusted-substitute-urls" includes a file:// URI, and we filter out all
file:// URIs from those provided by 'guix discover'.  We also ignore all
narinfos containing file:// URIs unless '%allow-unsafe-substitute-uris?' is #t.

* guix/scripts/substitute.scm (%allow-unsafe-substitute-uris?,
  %allow-unsafe-narinfo-uris?): new parameters.
  (process-substitution, process-substitution/fallback): honor
  '%allow-unsafe-substitute-uris?'.
  (uri-safe?, narinfo-uris-safe?, assert-safe-uris): new procedures.
  (%default-substitute-urls): use assert-safe-uris for the
  "untrusted-substitute-urls" daemon option.
  (%local-substitute-urls): filter out file:// URIs.
* tests/substitute.scm ("file:// URI prohibited by default"): new test.  Set
  '%allow-unsafe-substitute-uris?' to #t after it finishes.

Change-Id: I34d7e58b5a01c7cc61b52fcd61b547bba2ce4300
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-07-02 19:42:47 +02:00
Reepca Russelstein bb6f47ea77 scripts: pull: pass '#:ensure? #f' to config-directory.
In the test environment it not only doesn't exist, it also cannot be created,
and this causes an exception to be thrown.

* guix/scripts/pull.scm (trusted-channels, channel-list): pass '#:ensure? #f' to
  'config-directory'.

Change-Id: I52d28a9d4a6b4ab974ea7088dcdcc234fadbf5c8
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-06-30 10:57:49 +02:00
Tomas Volf c97e5ba157 import: crate: Make argument for --lockfile required.
The argument is required, not optional, so correct that.

* guix/scripts/import/crate.scm (%options)[lockfile]:
  Mark argument as required.

Merges: https://issues.guix.gnu.org/81279
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
2026-06-25 11:32:54 +09:00
Sergio Pastor Pérez 2949c187f6 pull: Add channel filtering options to the CLI.
* doc/guix.texi (Invoking guix pull): Document channel selection and exclusion
flags.
* etc/news.scm: Add entry.
* guix/scripts/pull.scm (show-help): Add help strings for channel selection
and exclusion flags.
(%options): Handle channel selection and exclusion flags.
(collect-alist-values): New procedure.
(options->channel-transformation): New procedure.
(channel-list): Implement channel selection and exclusion logic.
* guix/scripts/time-machine.scm (show-help): Add help strings for channel
selection and exclusion flags.
(%options): Handle channel selection and exclusion flags.

Change-Id: Ia22c5c38903ed1a2b9a9353ff94b70795820376d
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Modified-by: Ludovic Courtès <ludo@gnu.org>
2026-06-24 15:34:44 +02:00
Maxim Cournoyer 7ee79c9e82 import: npm-binary: Add a '--binary' option.
This changes the default behavior of the 'npm-binary' importer to prefer using
pristine sources from Git when available, along with attempting to build the
package.  It adds a '--binary' option to the importer to preserve the previous
behavior.

* guix/import/git.scm (get-tags): Export.
* guix/import/npm-binary.scm (<repository>): New JSON mapping.
(<package-revision>): Add a repository field.
(npm-package->package-sexp) [#:binary?]: New keyword.  Update doc.
Conditionally splice #:phases argument.
<normalize-git-url, sexpify-git-tag/maybe>: New nested procedures.
(npm-package->package-sexp) [binary?]: Expand origin conditionally to BINARY?.
(npm-binary->guix-package) [#:binary?]: New keyword.
(npm-binary-recursive-import): Likewise.
* guix/import/utils.scm (git->origin) [#:eager?]: New keyword.  Update doc.
* guix/scripts/import/npm-binary.scm (show-help): Document new --binary option.
(guix-import-npm-binary): Honor the new option.

Change-Id: I8e8c1c333faa8f5c96184ada064b63bdf2b4e165
2026-06-24 14:29:03 +09:00
Jani Juhani Sinervo ef10fa31d3 scripts: home: Add missing selection for ensure-home-environment os-home-env-config
* guix/scripts/home.scm: Add missing import of `operating-system-services` for
folding up `guix-home-service-type` in `ensure-home-environment`.

Signed-off-by: Andrew Tropin <andrew@trop.in>
2026-06-23 11:26:10 +07:00
Tomas Volf d11615f609 environment: Allow setting environment variables with -E.
* guix/scripts/environment.scm (show-environment-options-help) [-E]: Document
the change.
* guix/scripts/environment.scm (%options) [-E]: If arg contains =, split it
and store under 'extra-env.
* guix/scripts/environment.scm (launch-environment, launch-environment/fork)
(launch-environment/container): Take and use `environment-variables' keyword argument.
* guix/scripts/environment.scm (guix-environment*): Process 'environment-variables opts.
* guix/profiles.scm (load-profile): Add `environment-variables' keyword argument.
* doc/guix.texi (Invoking guix shell): Document the change.
* tests/guix-environment.sh (GUIX_TEST_ZZZ): Test it.

Change-Id: Ib1db19ef73dda8f561b05731079a96eda076e365
Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Modified-by: Maxim Cournoyer <maxim@guixotic.coop>
2026-06-15 10:48:17 +09:00
Ludovic Courtès 6c03bb1da2 pull, time-machine: Make ‘--allow-untrusted-channels’ equivalent to ‘…=yes’.
Fixes a bug whereby ‘--allow-untrusted-channels’ (without arguments) would
have no effect.

* guix/scripts/pull.scm (%options): In ‘--allow-untrusted-channels’, handle #f
in the same way as "yes".
* guix/scripts/time-machine.scm (%options): Likewise.

Reported-by: Sergio Pastor Pérez <sergio.pastor-perez@inria.fr>
Change-Id: Ibdbf5f570fded420cb93d09411848fb4aa034245
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #9094
2026-06-12 18:31:55 +02:00
Joseph Turner e7686718d4 pull: Ensure space between channel name and channel URL.
Previously, channel names which were 10 characters
or longer would be erroneously joined with its URL.

Merges: https://codeberg.org/guix/guix/pulls/9245
Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
2026-06-13 00:20:35 +09:00
Jani Juhani Sinervo 5a8f5a052a scripts: home: Support extracting home-environment from Guix System service extension.
* guix/scripts/home.scm (process-action): Extract home environments from
`guix-home-service-type' extensions as well as the base service.

Reviewed-by: Andrew Tropin <andrew@trop.in>
Signed-off-by: Andrew Tropin <andrew@trop.in>
2026-06-10 08:45:46 +07:00
Herman Rimm 4514f4cf19 scripts: lint: Add 'whole-file' option with ordering checker.
* guix/scripts/lint.scm (show-help): Describe option.
(%options): Add 'whole-file' option.
(guix-lint): Run checkers on packages defined in files.
* doc/guix.texi (Invoking guix lint): Document option.
* tests/guix-lint.sh: Define unordered package and invoke new option.

Change-Id: I52b48a9a6982d0c4a03416e3d070887c64716485
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #8796
2026-05-29 14:23:28 +02:00
Herman Rimm 1d3d136bb0 guix: Move ‘package-location<?’ to (guix packages).
* guix/scripts/style.scm (package-location<?): Move to…
* guix/packages.scm (package-location<?): … here.

Change-Id: I8ebb37c261a1bb3fa5772177b27fd62a2553e318
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-29 14:23:28 +02:00
Zhu Zihao 59e74d19f3 time-machine: Use accurate word for time travel in command help.
Time travel works in both directions, as mentioned in
info "(guix) Invoking guix time-machine".

* guix/scripts/time-machine.scm (show-help): Amend 'in an older version'
  with 'in a different version'.

Change-Id: I5da267e58e64381de86d6711dcd104592c30ef6c
Merges: https://codeberg.org/guix/guix/pulls/1163
Reviewed-by: Andreas Enge <andreas@enge.fr>
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
2026-05-26 00:23:01 +09:00
Janneke Nieuwenhuizen c62a39174e system: hurd-boot: Prepare for runsystem in Guile.
Fo guile to run, it needs pipe support: without pipe support it aborts at
startup.  Pipe support is currently createn in runsystem by creating a
passive translator

    settrans --create /servers/socket/1 /hurd/pflocal

However, this needs a writable root file-system, and runsystem is started with
a readonly root file-system.

This patch enables running guile early in runsystem, and thus prepares for
replacing the runsystem shell script with a guile program, by embedding the
servers/socket/1 passive translator into the hurd system image using xattr.

* gnu/build/hurd-boot.scm (make-hurd-device-nodes): Change optional root
parameter to keyword #:root.  Add #:hurd keyword parameter.  Use it to
create servers/socket/1 (pipe) and proc passive xattr translators.
* gnu/build/image.scm (initialize-root-partition): Update caller.
* gnu/system/image.scm (with-imported-modules*): Include (ice-9 optargs).
* gnu/system/images/hurd.scm (hurd-initialize-root-partition): Use it to
update caller.
* guix/scripts/system.scm (install): Update caller.

Change-Id: Ib3a672ae78bd969a2a4c0e33db8e38ccf71238ba
Merges: #8609
2026-05-19 18:34:56 +02:00
Ludovic Courtès 584a6de69d pull: Add ‘guix-channel?’ to the set of bindings when loading channel files.
* guix/scripts/pull.scm (%safe-channel-bindings): Add ‘guix-channel?’.

Reported-by: Tomas Volf <~@wolfsden.cz>
Change-Id: I5c1d06f540b85ebf96390ac4eaf10ff45e13123d
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #8562
2026-05-16 00:42:25 +02:00
Ludovic Courtès c9dcd203e5 pull, time-machine: ‘--allow-untrusted-channels’ takes an argument.
* guix/scripts/pull.scm (%default-options): Change ‘require-trusted-channels?’
to ‘require-trusted-channels’.
(show-help, %options): Support optional argument to
‘--allow-untrusted-channels’.
(channel-list): Adjust accordingly.
* guix/scripts/time-machine.scm (show-help, %options)
(%default-options): Likewise.
* tests/guix-time-machine.sh: Add test.
* doc/guix.texi (Invoking guix pull)
(Invoking guix time-machine): Adjust accordingly.

Suggested-by: Reepca Russelstein <reepca@russelstein.xyz>
Change-Id: I342ebbcc7355953487a5c6c8ac85048943a5ac46
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:08 +02:00
Ludovic Courtès f13901f6cb pull, time-machine: Accept content SWHIDs as arguments to ‘--channels’.
* guix/swh.scm (swhid-content-data): New procedure.
(call): Do not close ‘port’ when ‘result’ is the same as ‘port’.
* guix/scripts/pull.scm (swhid-content-data*): New procedure.
(channel-list): Accept ‘file’ as a SWHID.
* tests/guix-time-machine.sh: Add test.
* doc/guix.texi (Invoking guix pull): Document it.
(Invoking guix time-machine): Likewise.

Change-Id: I8145cd8685fe2926b1548d4a2dcd54804d89228a
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:08 +02:00
Ludovic Courtès 4b81a4df19 pull, time-machine: Support transparent download of channel files.
* guix/scripts/pull.scm (%default-options): Add ‘require-trusted-channels?’.
(show-help, %options): Add ‘--allow-untrusted-channels’.
(trusted-channels, equivalent-channels?, check-trusted-channels): New
procedures.
(channel-list)[require-trusted-channels?]: New variable.
[load-channels]: Honor it and call ‘check-trusted-channels’.
* guix/scripts/time-machine.scm (show-help, %options): Add
‘--allow-untrusted-channels’.
(%default-options): Add ‘require-trusted-channels?’.
* tests/guix-time-machine.sh: Add test.
* doc/guix.texi (Invoking guix pull): Update ‘--channels’ documentation and
document ‘allow-untrusted-channels’.
(Invoking guix time-machine): Likewise.
(Channels with Substitutes): Add example of ‘guix pull’ with a URL.

Change-Id: If0bb6acaedf324e35a21c9c7d285f3e423ae49aa
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:08 +02:00
Ludovic Courtès 3deecc2f87 perform-download: Use ‘read/safe’ from (guix ui).
* guix/scripts/perform-download.scm (read/safe): Remove.

Change-Id: I941e1ab299dc1e82b2587ae58fc9f44aa9187653
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:07 +02:00
Ludovic Courtès 36d431c051 pull, time-machine: Evaluate channels in a sandbox by default.
* guix/scripts/pull.scm (%default-options): Add
‘isolated-channel-evaluation?’.
(show-help, %options): Add ‘--unsafe-channel-evaluation’.
(%safe-channel-bindings): New variable.
(channel-list): Honor ‘isolated-channel-evaluation?’.
* guix/scripts/time-machine.scm (show-help, %options): Add
‘--unsafe-channel-evaluation’.
(%default-options): Add ‘isolated-channel-evaluation?’.
* tests/guix-time-machine.sh: Test use of unauthorized bindings in channel
files.
* doc/guix.texi (Invoking guix time-machine): Document
‘--unsafe-channel-evaluation’.
(Invoking guix pull): Likewise.
(Channels with Substitutes): Add index entry for
‘channel-with-substitutes-available’.  Mention that it requires
‘--unsafe-channel-evaluation’.

Change-Id: I75f60dba516f42ef62a9d779cde8e2f0a9d0c140
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:07 +02:00
Ludovic Courtès 94ae360ab4 ui: ‘load*’ takes a list of modules to import.
* guix/ui.scm (load*): Change ‘module’ to ‘imports’.  Define ‘user-module’.
* guix/scripts/build.scm (options->things-to-build): Update to new ‘load*’
calling convention.
* guix/scripts/deploy.scm (load-source-file): Likewise.
* guix/scripts/environment.scm (load-manifest)
(options/resolve-packages): Likewise.
* guix/scripts/home.scm (process-action): Likewise.
(%user-module): Rename to…
(%user-modules): … this, and change to a list of module names.
* guix/scripts/pack.scm (guix-pack): Update ‘load*’ calls.
* guix/scripts/package.scm (load-manifest, %options): Likewise.
* guix/scripts/pull.scm (channel-list): Likewise.
* guix/scripts/refresh.scm (packages-from-manifest): Likewise.
* guix/scripts/system.scm (%user-module): Rename to…
(%user-modules): … this, and change to a list of module names.
(read-operating-system): Adjust accordingly.
(process-action): Likewise.
* guix/scripts/weather.scm (load-manifest): Likewise.
* tests/gexp.scm ("local-file, relative file name, within gexp, compiled"):
Likewise.

Change-Id: Ic838e66719d89de556ac0872c3ce0c8ff6de8790
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-05-10 17:01:07 +02:00
Nicolas Graves 8a505cfd48 style: Add ‘remove-input’ and related styling rules.
* guix/scripts/style.scm (input-matches?, package-list->string,
%field-accessors, remove-from-package-field, transform-package-field):
Add variables.
(%options): Add options --remove-input, --remove-native-input,
--remove-propagated-input, and --parameter.
(guix-style): Implement those options.  To keep ony one autoload, use
specification->package+output rather than specification->package.

* tests/style.scm ("remove-input, single input removed",
"remove-input, one of multiple inputs removed",
"remove-input, middle input removed from list",
"remove-input, non-existent input unchanged",
"remove-input, input with output specifier",
"remove-native-input, single input removed",
"remove-native-input, one of multiple inputs removed",
"remove-native-input, does not affect inputs field",
"remove-propagated-input, single input removed",
"remove-propagated-input, one of multiple inputs removed",
"remove-propagated-input, does not affect other fields",
"remove-input from all three fields independently",
"remove-input, dry-run does not modify file"): New tests.
("url-fetch->git-fetch, preserved field"): Drop the use of %patch-path
and %package-module-path, which are not necessary because of -L.
Change the mocked procedure from specification->package to
specification->package+output, as in the implementation.

* doc/guix.texi (Invoking guix style): Add description for guix style
-S remove-*input rules.

Change-Id: I449c87930310a73ad316b4cb5db72d0906ea495d
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #5862
2026-05-07 17:35:32 +02:00
Danny Milosavljevic 62992295d6 shell: Add --cwd.
* guix/scripts/environment.scm (show-environment-options-help): Document
--cwd.
(%options): Add cwd.
(launch-environment/container): Add cwd parameter.  Implement passing it to
the container.
(guix-environment*): Reject --cwd without --container.
* doc/guix.texi (Invoking guix shell): Document it.
* tests/guix-environment-container.sh: Add tests.
* tests/guix-shell.sh: Add tests.

Fixes: guix/guix# 7825
Change-Id: Iba4ff3d2058e92f504fbcbf688346357ce913213
2026-04-30 02:07:20 +02:00
Johannes Christ 78053b9004 home: Run child as pid 2.
To test, use a sample home configuration and a command such as:

    guix home container home.scm -- sleep 10

Before this commit, hitting `^C` would not have any effect, as `sleep`
does not explicitly register a signal handler for `SIGINT`. With this
commit, `guix home container` forwards the signal to `sleep`, which
then exits.

* guix/scripts/home.scm (spawn-home-container): Instruct
  `eval/container` to not run our child directly as pid 1 in the spawned
  container, as it may not expect to run as an init process.

Change-Id: Ib997a0386d0851978d197fbd2dfb139141d13065
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #8051
2026-04-27 10:03:05 +02:00
Johannes ChristandLudovic Courtès 8538333bed environment: Run child as PID 2.
* guix/scripts/environment.scm (launch-environment/container): Instruct
  `call-with-container` to not run the child as PID 1, which sets up a
  simple signal proxying parent process to properly forward signals such
  as `SIGINT` to the child.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Change-Id: I8d435357f54b092562b461e0913aa58e63ecdbf9
Fixes: #7600
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-04-27 10:03:04 +02:00
Ludovic Courtès 528c6261cd publish: Ignore ‘--advertise’ and warn when listening to localhost.
* guix/scripts/publish.scm (run-publish-server): Write lower-case message.
(localhost?): New procedure.
(guix-publish): Warn when ‘advertise?’ is true but ‘address’ is localhost.
Adjust #:advertise? argument to ‘run-publish-server’ accordingly.

Reported-by: Sergio Pastor Pérez <sergio.pastor-perez@inria.fr>
Change-Id: I7166528d11ead67882326defcf5151af28e4253a
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #7790
2026-04-24 22:58:43 +02:00
jgart 0d11c221b8 guix: scripts: gc: Give better error reporting when attempting to vacuum.
* guix/scripts/gc.scm (%options): Error out when a non-root user tries
to vacuum the database.

Change-Id: Iee7d626c43980640aa91a3ceeb95675016932c55
Signed-off-by: jgart <jgart@dismail.de>
2026-04-15 17:56:23 -04:00
Noé Lopez 1078e42a60 tests: Fix non-deterministic AppImage tests.
The tested AppImages were not actually relocatable and would rely on items
being available on the environment’s store (apart from glibc).

* guix/scripts/pack.scm (wrapped-manifest): New function.
(guix-pack): Extract relocatable manifest to wrapped-manifest.
* tests/pack.scm: Use relocatable profiles in AppImage tests.

Fixes: <https://issues.guix.gnu.org/76850>
Change-Id: Ib3123054913fce903d215dc0629d806e9fceebc7
Reported-by: Reepca Russelstein <reepca@russelstein.xyz>
Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
2026-04-10 18:24:56 -07:00
Noé Lopez 3cbd6bd79c gnu: appimage-type-2-runtime: Update to continuous-1.caf24f9.
The runtime-fuse3 binary was renamed to runtime.

* gnu/packages/appimage.scm (appimage-type2-runtime):
Update to continuous-1.caf24f9.
* guix/scripts/pack.scm (self-contained-appimage):
[runtime-path]: Use new runtime name.

Change-Id: Ibbb1fcb6ca914764c37addb62c8234b49cc93bd5
Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
2026-04-10 18:24:53 -07:00
Nicolas Graves 4cbd5f883d guix: openpgp: Refactor openpgp-fingerprint->bytevector.
Both (guix channel) and (guix git-authenticate) use similar procedures.
To refactor the one in (guix git-authenticate), move the procedure
to (guix openpgp).

* guix/channels.scm: Replace autoloaded import
  openpgp-public-key-fingerprint with openpgp-fingerprint->bytevector.
  (openpgp-fingerprint->bytevector):
  Move function definition from here...
* guix/openpgp.scm (openpgp-fingerprint->bytevector): ...to here.
* guix/git-authenticate.scm (read-authorizations):
  Use openpgp-fingerprint->bytevector.
* guix/scripts/git/authenticate.scm:
  Avoid using the (guix channels) module.
* tests/git-authenticate.scm : Likewise.

Change-Id: Ifd20588fcfaab601990098bd8575ee985e87394a
Reviewed-by: Danny Milosavljevic <dannym@friendly-machines.com>
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
2026-04-10 14:46:59 +09:00
Ludovic Courtès 95ac807edf guix system: Make ‘--save-provenance’ effective for images.
Previously ‘--save-provenance’ would be silently ignored for ‘guix system
image’.

* guix/scripts/system.scm (image-with-provenance): New procedure.
(process-action): In ‘transform’, add case for ‘image?’, and emit a warning in
the default case.

Change-Id: I5020a4b3dacbe7a0820a3c4779b7d86a8133bd60
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #7485
2026-04-04 00:30:52 +02:00
Ludovic Courtès 4c7f4a0c0e style: git-source: Show package name in message.
* guix/scripts/style.scm (url-fetch->git-fetch)[transform-source]: Show
package name in informative message.

Change-Id: I4533dfcd7abf12c2406c981bcb80b3e634d339bc
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #6894
2026-03-10 22:53:55 +01:00
Ludovic Courtès 9adcf86358 style: git-source: Gracefully handle failure to checkout version tag.
Previously, when the version tag could not be cloned, ‘generate-git-source’
would return #f leading ‘guix style’ to crash with a type error.  Now, a
warning about the Git error is printed and ‘guix style’ keeps going.

* guix/scripts/style.scm (transform-to-git-fetch): Wrap ‘match’ clause in
‘catch’ and return #f on ‘git-error’.

Change-Id: If66b1c5f8e0a44155b96f3c54bab7c58aae406f8
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-03-10 22:53:54 +01:00
Ludovic Courtès 78ddf62bfe style: git-source: Handle more URLs.
* guix/import/utils.scm (tarball-url->git-repository-url): New procedure.
* guix/scripts/style.scm (url-fetch->git-fetch)[transform-source]: Add
‘repository-url’ parameter.
Use ‘tarball-url->git-repository-url’ when ‘home-page’ is not a Git URL.
(transform-to-git-fetch): Rename ‘home-page’ to ‘repository-url’.
* tests/import/utils.scm ("tarball-url->git-repository-url, guile"): New test.
* tests/style.scm ("url-fetch->git-fetch, mirror:// URL"): New test.

Change-Id: I4f8ca7c67a58f917d69380678b62c00962b0f9cd
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2026-03-10 22:53:54 +01:00
Efraim Flashner d4e9d74b66 scripts: pack: Use correct Debian architecture for armhf-linux.
Fixes guix/guix#6989.

* guix/scripts/pack.scm (debian-archive): When creating a Debian package
for an armhf-linux machine match our architecture to the closest one of
Debian's supported architectures.

Change-Id: I596db1087c507e61cc31f0808ebd9e39b4956c49
2026-03-09 16:49:48 +02:00
Maxim Cournoyer e122291204 build: Patch the git-lfs hooks shebangs in `git-fetch'.
This reverts commit b6a070d2a3, which patched
git-lfs so its hooks would refer to a 'sh' from the store, but this reference
was at risk of going stale since the hooks are installed and preserved outside
the store.  The shebangs are now patched in the `git-fetch' procedure
directly.

* guix/scripts/perform-download.scm (perform-git-download): Expand comment.
* guix/git-download.scm (bash-package): New variable.
(git-fetch/in-band*): Add #:bash argument.
(git-fetch-builder): Add it to `inputs', so that it gets added to PATH.
* guix/build/git.scm (git-fetch): Substitute /bin/bash in the post-checkout
git-lfs hook shebang.

Fixes: https://codeberg.org/guix/guix/issues/5616
Reported-by: Simon Josefsson <simon@josefsson.org>
Change-Id: Ife81737705bef5d0a1edad307ed77a479af4609e
2026-02-26 09:59:20 +09:00
Christopher Baines 1c230ec96e scripts: substitute: Default to fast decompression.
This changes the behaviour for the first one or few nars the substitute script
downloads, with uncompressed and zstd compressed nars prefered rather than
picking by file size.

* guix/scripts/substitute.scm: (%default-fast-decompression?): Change to #t.
* tests/substitute.scm ("substitute, preferred nar URL is 404, other is 200"):
Adjust test.

Change-Id: I89202f084cd6b9d506bcb3d46f75de690c6986b5
2026-01-28 17:45:33 +00:00
Christopher Baines be84a75c39 substitutes: Add #:keep-alive? keyword argument to download-nar.
To be consistent with other procedures that make network requests.

* guix/substitutes.scm (download-nar): Add #:keep-alive? option.
* guix/scripts/substitute.scm (process-substitution/fallback)
(process-substitution): Call download-nar with #:keep-alive? #t.

Change-Id: I83b27d0c3a0916d058fbbbeb7aa77dbb8a742768
2026-01-28 17:44:57 +00:00
Christopher Baines 53d306ca39 substitutes: Move download-nar from substitutes script to here.
From the substitutes script.  This makes it possible to use download-nar in
the the Guile guix-daemon.

* guix/scripts/substitute.scm (%fetch-timeout): Move down to where it's now
used.
(%random-state, with-timeout, catch-system-error, http-response-error?,
download-nar): Move to…
* guix/substitutes.scm: …here.

Change-Id: I8c09bf4b33cb5c6d042057d4d9adeb36c24c11dc
2026-01-28 17:44:57 +00:00
Christopher Baines 41a20ca0d2 scripts: substitute: Don't enforce cached connections in download-nar.
This is in preparation for moving the download-nar procedure out of the
script.

As well as calling open-connection-for-uri/cached, with-cached-connection adds
a single retry to the expression passed in, in the case of a exception that
suggests there's a problem with the cached connection. This is important
because download-nar/http-fetch doesn't check if a connection used for
multiple requests should be closed (because the servers set the relevant
response header).

To make download-nar more generic, have it take open-connection-for-uri as a
keyword argument, and replicate the with-cached-connection single retry by
closing the port in the case of a network error, and recalling
open-connection-for-uri.  This will work fine in the case when connection
caching is not in use, as well as when open-connection-for-uri/cached is used,
since open-connection-for-uri/cached will open a new connection if the cached
port is closed.

* guix/scripts/substitute.scm (kind-and-args-exception?): Remove and inline
where necessary.
(call-with-cached-connection): Remove procedure.
(with-cached-connection): Remove syntax rule.
(http-response-error?): New procedure.
(download-nar): Add new #:open-connection-for-uri keyword argument and use it,
also replace with-cached-connection.
(process-substitution/fallback,process-substitution): Pass
 #:open-connection-for-uri open-connection-for-uri/cached to download-nar.

Change-Id: I277b1d8dfef79aa1711755b10b9944da7c19157c
2026-01-28 17:44:57 +00:00
Christopher Baines b354ef2df3 http-client: Add network-error? from the substitute script.
Plus remove http-get-error? from network-error? as http-get-error? doesn't
indicate a network error.

* guix/scripts/substitute.scm (process-substitution/fallback)
(process-substitution): Use http-get-error?  with network-error?.
(system-error?, network-error?): Move from here…
* guix/http-client.scm: …to here, and also don't use http-get-error?.

Change-Id: I61ee9e5fbf90ebb76a34aa8b9ec8f5d74f8a3c54
2026-01-28 17:44:56 +00:00
Christopher Baines dce5b6371e scripts: substitute: Extract script specific output from download-nar.
As this moves download-nar in a direction where it could be used outside the
substitute script.

* guix/scripts/substitute.scm (download-nar): Return expected and actual
hashes and move status-port output to guix-substitute.
(process-substitution/fallback): Remove port argument, and move output to port
to guix-substitute.
(process-substitution): Return hashes from download-nar or
process-substitution/fallback, plus the narinfo.
(guix-substitute): Don't pass the reply-port in to process-substitution and
implement the messages to the reply-port here.

Change-Id: Icbddb9a47620b3520cdd2e8095f37a99824c1ce0
2026-01-28 17:44:56 +00:00
Christopher Baines 3e8d419da9 scripts: substitute: Untangle selecting fast vs small compressions.
Pulling the logic up to the script makes this code more portable and not
reliant on setting a global variable.

* guix/scripts/substitute.scm (%prefer-fast-decompression?): Rename to…
(%default-fast-decompression?): this.
(call-with-cpu-usage-monitoring): Use multiple values to return the results
from the thunk as well as the cpu usage.
(display-narinfo-data): Update accordingly.
(download-nar): Add fast-decompression? as a keyword argument, remove
code to set! it and monitor the cpu-usage.
(process-substitution, process-substitution/fallback): Accept and pass through
fast-decompression? to download-nar.
(guix-substitute): Move the cpu usage monitoring and fast decompression
switching logic here.

Change-Id: I4e80b457b55bcda8c0ff4ee224dd94a55e1b24fb
2026-01-28 17:44:56 +00:00
Christopher Baines 392cf48739 http-client: Alter http-fetch to return the response.
Rather than just the port and response-content-length.  I'm looking at using
the response headers within the substitute script to work out when to close
the connection.

* guix/http-client.scm (http-fetch): Return the response as the second value,
rather than the response-content-length.
* guix/build/download-nar.scm (download-nar): Adapt accordingly.
* guix/build/download.scm (url-fetch): Adapt accordingly.
* guix/scripts/substitute.scm (process-substitution): Adapt accordingly.
* guix/scripts/challenge.scm (call-with-nar): Adapt accordingly.

Change-Id: I490ecf7cef1f5ebbf1e6ed026f6a8fc9dacc56be
2026-01-28 17:44:56 +00:00