Re: reader macros for hidden packages

2022-06-26 Thread jgart
On Sun, 26 Jun 2022 16:55:26 +0200 Maxime Devos  wrote:
> jgart schreef op zo 26-06-2022 om 09:43 [-0500]:
> > > Or a new 'define-public-hidden':
> > > 
> > > (define-public-hidden python-httplib2
> > >    (package
> > >  (name "...")
> > >  ...))
> > 
> > I like this idea. You'd implement that as a macro that inserts
> > hidden-package for the user of define-public-hidden?
> 
> Yep.

Cool.

I'll try to write that macro and share it later if I get around to it.

I'm more comfortable currently with define-macro that with define-syntax-rule :(



Re: reader macros for hidden packages

2022-06-26 Thread Maxime Devos
jgart schreef op zo 26-06-2022 om 09:43 [-0500]:
> > Or a new 'define-public-hidden':
> > 
> > (define-public-hidden python-httplib2
> >    (package
> >  (name "...")
> >  ...))
> 
> I like this idea. You'd implement that as a macro that inserts
> hidden-package for the user of define-public-hidden?

Yep.


signature.asc
Description: This is a digitally signed message part


Re: reader macros for hidden packages

2022-06-26 Thread jgart
On Sun, 26 Jun 2022 09:27:15 +0200 Maxime Devos  wrote:
> jgart schreef op za 25-06-2022 om 22:27 [-0500]:
> > Out of curiosity, is it possible to make reader macros like this with guile?
> > 
> > ```
> > @hidden
> > (define-public python-httplib2
> >   (package
> >     (name "python-httplib2")
> > [...]
> > The above would make the package hidden by using `hidden-package`.
> 
> FWIW, read-hash-extend things aren't macros, though that can be worked
> around with some cleverness, see (guix gexp) where #~(...) -> (gexp
> ...) by the read syntax, and 'gexp' is a macro.

I've tried reading that code. Looking to get back to it again soon. gexps
are still somewhat fuzzy for me. Atleast at the implementationn level.

> Also, @hidden does not start with #, 

I was inspired by this common lisp code using cl-syntax-annot:

https://github.com/fukamachi/ningle/blob/a9052827757c54a83c9648175c11530e79295513/context.lisp#L8

>so you can't extend the read
> syntax that wat with read-hash-extend. (I suppose  you could go #hidden
> instead).

Does read-hash-extend allow for more than a single character after the hash # 
symbol?

>From reading the docs it looked like not... I'll spend some more repl time 
>with it.


Just for the sake of hacking. I'm finding excuses to write guile that I
wouldn't normally write and to explore hacking on guix APIs to see what
I can mold them too.

Take this exploration with goops and guix for example:

https://github.com/drewc/druix/blob/ad1c15bd6e20375b83ce398416d0f16de0385ab5/druix/versions.scm#L33


> 
> Or a new 'define-public-hidden':
> 
> (define-public-hidden python-httplib2
>   (package
> (name "...")
> ...))

I like this idea. You'd implement that as a macro that inserts hidden-package 
for the user of define-public-hidden?

> or move the relevant packages upstream?  

Yup, that's the next step. Was just trying to find a way to suppress
warnings until I have time to upstream the relevant packages and to hack
me some guile for fun.

Also, the module system has a
> #:replace, which may be useful to put in the (guixrus packages ...)
> modules such that in case a module imports both the guixrus and guix
> module, the guixrus wins (not 100% sure if that would works).

Thanks for all the advice. It's much appreciated!

all best,

jgart



Rust reprodubility -- .rmeta and shadow-rs

2022-06-26 Thread Maxime Devos
Hi,

There was some mail about irreproducibility in Rust, but I couldn't
find it anymore.  Anyway, I found a potential cause: rust-shadow-rs
embeds timestamps (even though it nominally respects
SOURCE_DATE_EPOCH???) and the ordering of definitions it generates is
based on a hash map (and hence, irreproducible).

The crate id is based on a hash over the source code, so this
irreproducibility can cause build failures if substitutes are used.

By removing the time stamp and sorting the definitions, 'nushell'
successfully built on ci.guix.gnu.org whereas it previously failed to
build on ci.guix.gnu.org but built successfully locally (with
antioxidant), and IIRC the (antioxidated) 'rust-nu-command' is now
reproducible:

Anyway, here the patch I used:

("rust-shadow-rs"
 ,#~((add-after 'unpack 'fixup-source-date-epoch
   (lambda _
 ;; TODO: it nominally supports SOURCE_DATE_EPOCH, yet something 
things go wrong,
 ;; as the shadow.rs still contains the unnormalised time stamp ...
 ;; For now, do a work-around.
 (substitute* '("src/lib.rs" "src/env.rs")
   (("BuildTime::Local\\(Local::now\\(\\)\\)\\.human_format\\(\\)")
(object->string "[timestamp expunged for reproducibility]"))
   (("time\\.human_format\\(\\)")
"\"[timestamp expunged for reproducibility]\".to_string()")
   (("time\\.to_rfc3339_opts\\(SecondsFormat::Secs, true)")
"\"[timestamp expunged for reproducibility]\".to_string()")
   (("time\\.to_rfc2822\\(\\)")
"\"[timestamp expunged for reproducibility]\".to_string()"
 (add-after 'unpack 'more-reproducibility ;; by default, it uses a 
hashmap, leading to an irreproducible ordering in shadow.rs and hence an 
irreproducible .rmeta (TODO: upstream?)
   (lambda _
 (substitute* "src/lib.rs" ; sort
   (("\\(k, v\\) in self\\.map\\.clone\\(\\)")
"(k, v) in 
std::collections::BTreeMap::from_iter(self.map.clone().iter())")
   (("self\\.write_const\\(k, v\\)") "self.write_const(k, 
v.clone())")
   (("self\\.map\\.keys\\(\\)") 
"std::collections::BTreeSet::from_iter(self.map.keys())"))

Maybe that was the cause?

Greetings,
Maxime.


signature.asc
Description: This is a digitally signed message part


Re: reader macros for hidden packages

2022-06-26 Thread Maxime Devos
jgart schreef op za 25-06-2022 om 22:27 [-0500]:
> Out of curiosity, is it possible to make reader macros like this with guile?
> 
> ```
> @hidden
> (define-public python-httplib2
>   (package
>     (name "python-httplib2")
> [...]
> The above would make the package hidden by using `hidden-package`.

FWIW, read-hash-extend things aren't macros, though that can be worked
around with some cleverness, see (guix gexp) where #~(...) -> (gexp
...) by the read syntax, and 'gexp' is a macro.

Also, @hidden does not start with #, so you can't extend the read
syntax that wat with read-hash-extend. (I suppose  you could go #hidden
instead).

However, I cannot recommend this, for read syntax is global (not per
module, like the module system) and there can only be a single read
syntax per first character (so high chance for collisions).

It's also rather magical, and we already have the less magical but no
less concise 'hidden-package', why not:

(define-public python-httplib2
  (hidden-package
(name "...")
...))

Or a new 'define-public-hidden':

(define-public-hidden python-httplib2
  (package
(name "...")
...))

or move the relevant packages upstream?  Also, the module system has a
#:replace, which may be useful to put in the (guixrus packages ...)
modules such that in case a module imports both the guixrus and guix
module, the guixrus wins (not 100% sure if that would works).

Greetings,
Maxime.


signature.asc
Description: This is a digitally signed message part