diff options
| author | Hilton Chain <hako@ultrarare.space> | 2025-05-03 22:38:28 +0800 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-05-08 14:18:36 +0900 |
| commit | 9d9a6291c4e61f3af71e94e549926bd9905e99db (patch) | |
| tree | 7fe3965851c226e86a8bed54b58f6fc4ef2f2961 /gnu | |
| parent | 2ca8d3828161ec07117cc0a252e09fb22585be76 (diff) | |
services: activation: Continue on exceptions.
* gnu/services.scm (activation-script): Reset environment before loading
activation script. Catch exception and print the error. Warn about failed
activation script.
Change-Id: I89be31433fbb46d0c4a9dc6115ab167910840b6f
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services.scm | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/gnu/services.scm b/gnu/services.scm index 8a4002e0724..af054339fd9 100644 --- a/gnu/services.scm +++ b/gnu/services.scm | |||
| @@ -692,15 +692,31 @@ ACTIVATION-SCRIPT-TYPE." | |||
| 692 | (define (activation-script gexps) | 692 | (define (activation-script gexps) |
| 693 | "Return the system's activation script, which evaluates GEXPS." | 693 | "Return the system's activation script, which evaluates GEXPS." |
| 694 | (define actions | 694 | (define actions |
| 695 | (map (cut program-file "activate-service.scm" <>) gexps)) | 695 | ;; TODO: Instead of importing modules here, let users of activation service |
| 696 | ;; add them explicitly. See <https://issues.guix.gnu.org/76698>. | ||
| 697 | (map (lambda (action) | ||
| 698 | (program-file "activate-service.scm" | ||
| 699 | (with-imported-modules (source-module-closure | ||
| 700 | '((gnu build activation) | ||
| 701 | (guix build utils))) | ||
| 702 | #~(begin | ||
| 703 | (use-modules (gnu build activation) | ||
| 704 | (guix build utils)) | ||
| 705 | #$action)))) | ||
| 706 | gexps)) | ||
| 696 | 707 | ||
| 697 | (program-file "activate.scm" | 708 | (program-file "activate.scm" |
| 698 | (with-imported-modules (source-module-closure | 709 | (with-imported-modules (source-module-closure |
| 699 | '((gnu build activation) | 710 | '((gnu build activation) |
| 700 | (guix build utils))) | 711 | (guix build utils) |
| 712 | (guix diagnostics) | ||
| 713 | (guix i18n))) | ||
| 701 | #~(begin | 714 | #~(begin |
| 702 | (use-modules (gnu build activation) | 715 | (use-modules (gnu build activation) |
| 703 | (guix build utils)) | 716 | (guix build utils) |
| 717 | (guix diagnostics) | ||
| 718 | (guix i18n) | ||
| 719 | (srfi srfi-34)) | ||
| 704 | 720 | ||
| 705 | (mkdir-p "/var/run") | 721 | (mkdir-p "/var/run") |
| 706 | ;; Make sure the user accounting database exists. If it | 722 | ;; Make sure the user accounting database exists. If it |
| @@ -720,7 +736,22 @@ ACTIVATION-SCRIPT-TYPE." | |||
| 720 | 736 | ||
| 721 | ;; Run the services' activation snippets. | 737 | ;; Run the services' activation snippets. |
| 722 | ;; TODO: Use 'load-compiled'. | 738 | ;; TODO: Use 'load-compiled'. |
| 723 | (for-each primitive-load '#$actions))))) | 739 | (for-each (lambda (action) |
| 740 | ;; Don't block activation process when one | ||
| 741 | ;; action fails. | ||
| 742 | (guard (condition | ||
| 743 | (else | ||
| 744 | (format (current-error-port) "~a~%" | ||
| 745 | condition) | ||
| 746 | (warning | ||
| 747 | (G_ "failed to activate '~a'~%") | ||
| 748 | action))) | ||
| 749 | (save-module-excursion | ||
| 750 | (lambda () | ||
| 751 | (set-current-module | ||
| 752 | (make-fresh-user-module)) | ||
| 753 | (primitive-load action))))) | ||
| 754 | '#$actions))))) | ||
| 724 | 755 | ||
| 725 | (define (gexps->activation-gexp gexps) | 756 | (define (gexps->activation-gexp gexps) |
| 726 | "Return a gexp that runs the activation script containing GEXPS." | 757 | "Return a gexp that runs the activation script containing GEXPS." |
