From d2fc76462e72268ee5b04fe53805efc05c35e139 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 25 Apr 2020 15:20:04 +0200 Subject: services: shepherd: Cross-compilation fix. Fixes . Reported by Jan (janneke) Nieuwenhuizen Fix suggested by Mathieu Othacehe However, still applies; %current-target-system may not be bound. * gnu/services/shepherd.scm (scm->go): Use `with-target' when cross-compiling. --- gnu/services/shepherd.scm | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'gnu/services') 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 ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2018 Carlo Zancanaro +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; ;;; 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 + (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." -- cgit 1.4.1