Hello,

Ludovic Courtès <l...@gnu.org> writes:

> Hi,
>
> Maxim Cournoyer <maxim.courno...@gmail.com> skribis:
>
>> gnu: polkit: Define polkit package variable based on architecture.
>>
>> * gnu/packages/polkit.scm (polkit): Rename to...
>> (polkit*): ... this.
>> (polkit-duktape): Adjust to inherit from polkit*.
>> (polkit-for-system): New procedure.
>> (polkit): New variable.
>
> LGTM!
>
>> But my "test" fails the same:
>>
>> $ ./pre-inst-env guix build --system=aarch64-linux \
>>     -e '(@ (gnu packages polkit) polkit)' -n |& grep polkit
>> /gnu/store/dw11y85xfsb8hcg7w2cw57f1xfs4i74m-polkit-0.120.drv
>> /gnu/store/ric7yf4ra2p14p29fwsh18m1nakciakv-polkit-0.120.tar.xz
>
> That’s expected because here you’re effectively calling
> (%current-system) from the top level, and that’s x86_64.
>
> A good test is to try and build one of its dependents:
>
>   guix build -s aarch64-linux gnome-control-center -n
>
> should list polkit-duktape.

Arf, here's what it throws, after adding the missing polkit export:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build  -s aarch64-linux gnome-control-center -n
guix build: error: gnu/packages/gnome.scm:5299:2: package 
`colord-minimal@1.4.5' has an invalid input: ("polkit" #<syntax-transformer 
polkit>)
--8<---------------cut here---------------end--------------->8---

I don't see how it's different from pkg-config... Ideas?

> Are we done and ready for merging once this patch has been applied to
> ‘core-updates-frozen’?

Mostly, after applying fixes from jpoiret for GDM icons I believe
(thanks!); I'll also have to debug why my GDM-less desktop won't allow
me to login anymore (https://issues.guix.gnu.org/52051).

Thank you!

Maxim

>From 48730390fbfa618216c9e8db65643755ff585175 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.courno...@gmail.com>
Date: Sun, 21 Nov 2021 22:20:35 -0500
Subject: [PATCH] gnu: polkit: Define polkit package variable based on
 architecture.

* gnu/packages/polkit.scm (polkit): Rename to...
(polkit*): ... this.
(polkit-duktape): Adjust to inherit from polkit*.
(polkit-for-system): New procedure.
(polkit): New variable.
---
 gnu/packages/polkit.scm | 76 ++++++++++++++++++++++++++---------------
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/gnu/packages/polkit.scm b/gnu/packages/polkit.scm
index c9edc53cf5..a1bf9786fd 100644
--- a/gnu/packages/polkit.scm
+++ b/gnu/packages/polkit.scm
@@ -29,6 +29,7 @@ (define-module (gnu packages polkit)
   #:use-module ((guix licenses) #:select (lgpl2.0+))
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix memoization)
   #:use-module (guix utils)
   #:use-module (guix build utils)
   #:use-module (guix build-system cmake)
@@ -46,9 +47,10 @@ (define-module (gnu packages polkit)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages qt)
-  #:use-module (gnu packages xml))
+  #:use-module (gnu packages xml)
+  #:export (polkit))
 
-(define-public polkit
+(define-public polkit*
   (package
     (name "polkit")
     (version "0.120")
@@ -151,32 +153,50 @@ (define-public polkit
 ;;; Variant of polkit built with Duktape, a lighter JavaScript engine compared
 ;;; to mozjs.
 (define-public polkit-duktape
-  (package/inherit polkit
-    (name "polkit-duktape")
-    (source
-     (origin
-       (inherit (package-source polkit))
-       (patches
-        (append
-            (search-patches "polkit-use-duktape.patch")
-            (origin-patches (package-source polkit))))))
-    (arguments
-     (substitute-keyword-arguments (package-arguments polkit)
-       ((#:configure-flags flags)
-        `(cons "--with-duktape" ,flags))
-       ((#:phases phases)
-        `(modify-phases ,phases
-           (add-after 'unpack 'force-gnu-build-system-bootstrap
-             (lambda _
-               (delete-file "configure")))))))
-    (native-inputs
-     (append `(("autoconf" ,autoconf)
-               ("automake" ,automake)
-               ("libtool" ,libtool)
-               ("pkg-config" ,pkg-config))
-         (package-native-inputs polkit)))
-    (inputs (alist-replace "mozjs" `(,duktape)
-                           (package-inputs polkit)))))
+  (let ((base polkit*))
+    (package/inherit base
+      (name "polkit-duktape")
+      (source
+       (origin
+         (inherit (package-source base))
+         (patches
+          (append
+              (search-patches "polkit-use-duktape.patch")
+              (origin-patches (package-source base))))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:configure-flags flags)
+          `(cons "--with-duktape" ,flags))
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'unpack 'force-gnu-build-system-bootstrap
+               (lambda _
+                 (delete-file "configure")))))))
+      (native-inputs
+       (append `(("autoconf" ,autoconf)
+                 ("automake" ,automake)
+                 ("libtool" ,libtool)
+                 ("pkg-config" ,pkg-config))
+           (package-native-inputs base)))
+      (inputs (alist-replace "mozjs" `(,duktape)
+                             (package-inputs base))))))
+
+
+(define polkit-for-system
+  (mlambda (system)
+    "Return a polkit package that can be built for SYSTEM; that is, either the
+regular polkit that requires mozjs or its duktape variant."
+    (if (string-prefix? "x86_64" system)
+        polkit*
+        polkit-duktape)))
+
+;;; Define a top level polkit variable that can be built on any of the
+;;; supported platforms.  This is to work around the fact that our
+;;; mrustc-bootstrapped rust toolchain currently only supports the x86_64
+;;; architecture.
+(define-syntax polkit
+  (identifier-syntax (polkit-for-system
+                      (or (%current-target-system) (%current-system)))))
 
 (define-public polkit-qt
   (package
-- 
2.34.0

Reply via email to