summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorJan (janneke) Nieuwenhuizen <janneke@gnu.org>2020-04-25 15:20:04 +0200
committerJan Nieuwenhuizen <janneke@gnu.org>2020-04-25 19:34:15 +0200
commitd2fc76462e72268ee5b04fe53805efc05c35e139 (patch)
tree2f7d514f6c4f26104c14ac30093dad5c84105477 /gnu/services
parent6ac6c1d28d8a89d0f9b0f15e7df2a011f24aa091 (diff)
downloadpatches-d2fc76462e72268ee5b04fe53805efc05c35e139.tar
patches-d2fc76462e72268ee5b04fe53805efc05c35e139.tar.gz
services: shepherd: Cross-compilation fix.
Fixes <https://bugs.gnu.org/40839>. Reported by Jan (janneke) Nieuwenhuizen <janneke@gnu.org> Fix suggested by Mathieu Othacehe <m.othacehe@gmail.com> However, <https://bugs.gnu.org/29296> still applies; %current-target-system may not be bound. * gnu/services/shepherd.scm (scm->go): Use `with-target' when cross-compiling.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/shepherd.scm39
1 files changed, 23 insertions, 16 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 2f30c6c907..655a45a936 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +26,7 @@
#:use-module (guix store)
#:use-module (guix records)
#:use-module (guix derivations) ;imported-modules, etc.
+ #:use-module (guix utils)
#:use-module (gnu services)
#:use-module (gnu services herd)
#:use-module (gnu packages admin)
@@ -260,22 +262,27 @@ stored."
(define (scm->go file)
"Compile FILE, which contains code to be loaded by shepherd's config file,
and return the resulting '.go' file."
- (with-extensions (list shepherd)
- (computed-file (string-append (basename (scheme-file-name file) ".scm")
- ".go")
- #~(begin
- (use-modules (system base compile))
-
- ;; Do the same as the Shepherd's 'load-in-user-module'.
- (let ((env (make-fresh-user-module)))
- (module-use! env (resolve-interface '(oop goops)))
- (module-use! env (resolve-interface '(shepherd service)))
- (compile-file #$file #:output-file #$output
- #:env env)))
-
- ;; It's faster to build locally than to download.
- #:options '(#:local-build? #t
- #:substitutable? #f))))
+ ;; FIXME: %current-target-system may not be bound <https://bugs.gnu.org/29296>
+ (let ((target (%current-target-system)))
+ (with-extensions (list shepherd)
+ (computed-file (string-append (basename (scheme-file-name file) ".scm")
+ ".go")
+ #~(begin
+ (use-modules (system base compile)
+ (system base target))
+
+ ;; Do the same as the Shepherd's 'load-in-user-module'.
+ (let ((env (make-fresh-user-module)))
+ (module-use! env (resolve-interface '(oop goops)))
+ (module-use! env (resolve-interface '(shepherd service)))
+ (with-target #$(or target #~%host-type)
+ (lambda _
+ (compile-file #$file #:output-file #$output
+ #:env env)))))
+
+ ;; It's faster to build locally than to download.
+ #:options '(#:local-build? #t
+ #:substitutable? #f)))))
(define (shepherd-configuration-file services)
"Return the shepherd configuration file for SERVICES."