unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Replacing polkit by polkit-duktape on core-updates-frozen ?
@ 2021-11-11 18:23 Maxim Cournoyer
  2021-11-11 23:30 ` Thiago Jung Bauermann
  0 siblings, 1 reply; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-11 18:23 UTC (permalink / raw)
  To: guix-devel

Hello Guix!

I've finally merged the core-updates-frozen-batched-changes to
core-updates-frozen.  One of the changes it brought is an updated
(non-grafted) polkit; this polkit now depends on mozjs@78 which itself
depends on rust.

Unfortunately, our rust bootstrap doesn't currently build everywhere;
progress is being made in mrustc to improve the situation as we speak
[0], but in the meantime this rust-dependent polkit will cause problems
on non-x86_64 architectures (it is needed by GTK/GNOME through elogind).

One thing we could do in the meantime is to replace our polkit package
with polkit-duktape, which uses an (unmerged) patch to build polkit
against duktape rather than mozjs [1].  The patch seems to have garnered
some attention recently.  This would enable to build GTK and parts of
GNOME without rust, I believe.

What do you think?

[0]  https://github.com/thepowersgang/mrustc/issues/78#issuecomment-966470873
[1]  https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/35


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-11 18:23 Replacing polkit by polkit-duktape on core-updates-frozen ? Maxim Cournoyer
@ 2021-11-11 23:30 ` Thiago Jung Bauermann
  2021-11-17 11:08   ` Ludovic Courtès
  0 siblings, 1 reply; 13+ messages in thread
From: Thiago Jung Bauermann @ 2021-11-11 23:30 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: guix-devel

Hello Maxim,

Em quinta-feira, 11 de novembro de 2021, às 15:23:37 -03, Maxim Cournoyer 
escreveu:
> Hello Guix!
> 
> I've finally merged the core-updates-frozen-batched-changes to
> core-updates-frozen. 

Hooray!

> One thing we could do in the meantime is to replace our polkit package
> with polkit-duktape, which uses an (unmerged) patch to build polkit
> against duktape rather than mozjs [1].  The patch seems to have garnered
> some attention recently.  This would enable to build GTK and parts of
> GNOME without rust, I believe.

I’d suggest replacing polkit with polkit-duktape only for non-x86_64 
architectures. What do you think?¨

-- 
Thanks,
Thiago




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-11 23:30 ` Thiago Jung Bauermann
@ 2021-11-17 11:08   ` Ludovic Courtès
  2021-11-22  3:35     ` Maxim Cournoyer
  0 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2021-11-17 11:08 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: guix-devel, Maxim Cournoyer

Hi,

Thiago Jung Bauermann <bauermann@kolabnow.com> skribis:

> Em quinta-feira, 11 de novembro de 2021, às 15:23:37 -03, Maxim Cournoyer 
> escreveu:
>> Hello Guix!
>> 
>> I've finally merged the core-updates-frozen-batched-changes to
>> core-updates-frozen. 
>
> Hooray!
>
>> One thing we could do in the meantime is to replace our polkit package
>> with polkit-duktape, which uses an (unmerged) patch to build polkit
>> against duktape rather than mozjs [1].  The patch seems to have garnered
>> some attention recently.  This would enable to build GTK and parts of
>> GNOME without rust, I believe.
>
> I’d suggest replacing polkit with polkit-duktape only for non-x86_64 
> architectures. What do you think?¨

Yes, that seems like the most reasonable option.

Thanks, Maxim!

Ludo’.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-17 11:08   ` Ludovic Courtès
@ 2021-11-22  3:35     ` Maxim Cournoyer
  2021-11-22 13:30       ` Ludovic Courtès
  0 siblings, 1 reply; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-22  3:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hello,

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

> Hi,
>
> Thiago Jung Bauermann <bauermann@kolabnow.com> skribis:
>
>> Em quinta-feira, 11 de novembro de 2021, às 15:23:37 -03, Maxim Cournoyer 
>> escreveu:
>>> Hello Guix!
>>> 
>>> I've finally merged the core-updates-frozen-batched-changes to
>>> core-updates-frozen. 
>>
>> Hooray!
>>
>>> One thing we could do in the meantime is to replace our polkit package
>>> with polkit-duktape, which uses an (unmerged) patch to build polkit
>>> against duktape rather than mozjs [1].  The patch seems to have garnered
>>> some attention recently.  This would enable to build GTK and parts of
>>> GNOME without rust, I believe.
>>
>> I’d suggest replacing polkit with polkit-duktape only for non-x86_64 
>> architectures. What do you think?¨
>
> Yes, that seems like the most reasonable option.

How do we do this, though?

I tried to make it so that referring to the 'polkit' *variable* would
always expand to something supported (switching between vanilla polkit
and polkit-duktape variant based on the system):

--8<---------------cut here---------------start------------->8---
1 file changed, 38 insertions(+), 27 deletions(-)
gnu/packages/polkit.scm | 65 ++++++++++++++++++++++++++++++++++++++---------------------------

modified   gnu/packages/polkit.scm
@@ -48,7 +48,7 @@ (define-module (gnu packages polkit)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages xml))
 
-(define-public polkit
+(define-public polkit*
   (package
     (name "polkit")
     (version "0.120")
@@ -151,32 +151,43 @@ (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 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-public polkit
+  (if (string-prefix? "x86_64"
+                      (or (%current-system) (%current-target-system)))
+      polkit*
+      polkit-duktape))
 
 (define-public polkit-qt
   (package
--8<---------------cut here---------------end--------------->8---

it builds, and doesn't seem to break things, but:

--8<---------------cut here---------------start------------->8---
$ ./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
--8<---------------cut here---------------end--------------->8---

suggests it isn't working.

Ideas?

Thanks!

Maxim


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-22  3:35     ` Maxim Cournoyer
@ 2021-11-22 13:30       ` Ludovic Courtès
  2021-11-22 20:26         ` Maxim Cournoyer
  2021-11-22 20:41         ` Maxim Cournoyer
  0 siblings, 2 replies; 13+ messages in thread
From: Ludovic Courtès @ 2021-11-22 13:30 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: guix-devel

Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> +;;; 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-public polkit
> +  (if (string-prefix? "x86_64"
> +                      (or (%current-system) (%current-target-system)))
> +      polkit*
> +      polkit-duktape))

This would instead have to be a macro, similar to the ‘pkg-config’
macro, so that (%current-system) is checked at the right time rather
than when loading this module.

However, since the only different between polkit and polkit-duktape
(IIUC) is that an extra patch is applied for the latter, I would instead
suggest adding a conditional build phase that applies the patch on
non-x86_64 systems.

How does that sound?

Ludo’.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-22 13:30       ` Ludovic Courtès
@ 2021-11-22 20:26         ` Maxim Cournoyer
  2021-11-22 20:41         ` Maxim Cournoyer
  1 sibling, 0 replies; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-22 20:26 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludovic,

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

> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> +;;; 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-public polkit
>> +  (if (string-prefix? "x86_64"
>> +                      (or (%current-system) (%current-target-system)))
>> +      polkit*
>> +      polkit-duktape))
>
> This would instead have to be a macro, similar to the ‘pkg-config’
> macro, so that (%current-system) is checked at the right time rather
> than when loading this module.

Thanks for tipping in!

> However, since the only different between polkit and polkit-duktape
> (IIUC) is that an extra patch is applied for the latter, I would instead
> suggest adding a conditional build phase that applies the patch on
> non-x86_64 systems.

I'd still rather keep the distinct package approach, so that x86* users
may still find about polkit-duktape and use it instead of polkit (via
input rewriting) if they so wish.

Thanks,

Maxim


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-22 13:30       ` Ludovic Courtès
  2021-11-22 20:26         ` Maxim Cournoyer
@ 2021-11-22 20:41         ` Maxim Cournoyer
  2021-11-23 17:18           ` Ludovic Courtès
  1 sibling, 1 reply; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-22 20:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hello again,

I've now tried this:

--8<---------------cut here---------------start------------->8---
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.

1 file changed, 44 insertions(+), 27 deletions(-)
gnu/packages/polkit.scm | 71 ++++++++++++++++++++++++++++++++++++++++++++---------------------------

modified   gnu/packages/polkit.scm
@@ -48,7 +48,7 @@ (define-module (gnu packages polkit)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages xml))
 
-(define-public polkit
+(define-public polkit*
   (package
     (name "polkit")
     (version "0.120")
@@ -151,32 +151,49 @@ (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 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-system) (%current-target-system)))))
 
 (define-public polkit-qt
   (package
--8<---------------cut here---------------end--------------->8---

But my "test" fails the same:

--8<---------------cut here---------------start------------->8---
$ ./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
--8<---------------cut here---------------end--------------->8---

I'd have expected to see 'polkit-duktape' as the name of the package in
the output.

Thanks,

Maxim


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-22 20:41         ` Maxim Cournoyer
@ 2021-11-23 17:18           ` Ludovic Courtès
  2021-11-23 20:34             ` Thiago Jung Bauermann
  2021-11-24  4:02             ` Maxim Cournoyer
  0 siblings, 2 replies; 13+ messages in thread
From: Ludovic Courtès @ 2021-11-23 17:18 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: guix-devel

Hi,

Maxim Cournoyer <maxim.cournoyer@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.

HTH!

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

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-23 17:18           ` Ludovic Courtès
@ 2021-11-23 20:34             ` Thiago Jung Bauermann
  2021-11-24  4:11               ` Maxim Cournoyer
  2021-11-24  4:02             ` Maxim Cournoyer
  1 sibling, 1 reply; 13+ messages in thread
From: Thiago Jung Bauermann @ 2021-11-23 20:34 UTC (permalink / raw)
  To: Maxim Cournoyer, Ludovic Courtès; +Cc: guix-devel

Hello,

Em terça-feira, 23 de novembro de 2021, às 14:18:10 -03, Ludovic Courtès 
escreveu:
> > 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.
> 
> HTH!

Sorry, I should have taken a closer look at this patch yesterday. IIUC it’s 
a bug to test (%current-system) before (%current-target-system). That’s 
because the latter is only defined for cross-builds, while the former is 
always defined. So in practice (%current-target-system) will never be 
checked.

This what patch 1 in the series at https://issues.guix.gnu.org/49672 fixes.
Rebasing it and addressing Maxime’s comments is on my todo list.

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

Hooray! I’m currently investigating a problem with lualatex (issue 51252). 
I don’t know whether it’s serious enough to delay the merge.

-- 
Thanks,
Thiago




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-23 17:18           ` Ludovic Courtès
  2021-11-23 20:34             ` Thiago Jung Bauermann
@ 2021-11-24  4:02             ` Maxim Cournoyer
  2021-11-24  8:42               ` Josselin Poiret via Development of GNU Guix and the GNU System distribution.
  1 sibling, 1 reply; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-24  4:02 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]

Hello,

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

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-polkit-Define-polkit-package-variable-based-on-a.patch --]
[-- Type: text/x-patch, Size: 4239 bytes --]

From 48730390fbfa618216c9e8db65643755ff585175 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-23 20:34             ` Thiago Jung Bauermann
@ 2021-11-24  4:11               ` Maxim Cournoyer
  0 siblings, 0 replies; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-24  4:11 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: guix-devel

Hi Thiago,

Thiago Jung Bauermann <bauermann@kolabnow.com> writes:

[...]

> IIUC it’s a bug to test (%current-system) before
> (%current-target-system). That’s because the latter is only defined
> for cross-builds, while the former is always defined. So in practice
> (%current-target-system) will never be checked.

Oh, good catch!  I've fixed it in the patch I just sent in my earlier
reply to Ludovic.

Thank you,

Maxim


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-24  4:02             ` Maxim Cournoyer
@ 2021-11-24  8:42               ` Josselin Poiret via Development of GNU Guix and the GNU System distribution.
  2021-11-24 14:42                 ` Maxim Cournoyer
  0 siblings, 1 reply; 13+ messages in thread
From: Josselin Poiret via Development of GNU Guix and the GNU System distribution. @ 2021-11-24  8:42 UTC (permalink / raw)
  To: Maxim Cournoyer, Ludovic Courtès; +Cc: guix-devel, dev

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

at 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---

Since polkit is now syntax, it needs to be expanded before being
compiled at all its uses, however guile (and our build system) doesn't
automatically recompile all .scm files that use the changed definition.

A simple `rm $(grep --include=\*.go -rl polkit .)` in the root of the
checkout, followed by a `make` did it for me.

As a side note, I'm also investigating that sddm error today.

Best,
Josselin Poiret


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Replacing polkit by polkit-duktape on core-updates-frozen ?
  2021-11-24  8:42               ` Josselin Poiret via Development of GNU Guix and the GNU System distribution.
@ 2021-11-24 14:42                 ` Maxim Cournoyer
  0 siblings, 0 replies; 13+ messages in thread
From: Maxim Cournoyer @ 2021-11-24 14:42 UTC (permalink / raw)
  To: Josselin Poiret; +Cc: guix-devel

Hi Josselin,

Josselin Poiret <dev@jpoiret.xyz> writes:

> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>
> at 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---
>
> Since polkit is now syntax, it needs to be expanded before being
> compiled at all its uses, however guile (and our build system) doesn't
> automatically recompile all .scm files that use the changed definition.

That's the impression I got after realizing the fix.  Is there an open
issue about this shortcoming in Guile?  I think that's where a fix
should go.

> A simple `rm $(grep --include=\*.go -rl polkit .)` in the root of the
> checkout, followed by a `make` did it for me.

Thanks for the tip!

> As a side note, I'm also investigating that sddm error today.

Awesome!

Thank you,

Maxim


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-24 14:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-11 18:23 Replacing polkit by polkit-duktape on core-updates-frozen ? Maxim Cournoyer
2021-11-11 23:30 ` Thiago Jung Bauermann
2021-11-17 11:08   ` Ludovic Courtès
2021-11-22  3:35     ` Maxim Cournoyer
2021-11-22 13:30       ` Ludovic Courtès
2021-11-22 20:26         ` Maxim Cournoyer
2021-11-22 20:41         ` Maxim Cournoyer
2021-11-23 17:18           ` Ludovic Courtès
2021-11-23 20:34             ` Thiago Jung Bauermann
2021-11-24  4:11               ` Maxim Cournoyer
2021-11-24  4:02             ` Maxim Cournoyer
2021-11-24  8:42               ` Josselin Poiret via Development of GNU Guix and the GNU System distribution.
2021-11-24 14:42                 ` Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).