Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm

2022-12-27 Thread Development of GNU Guix and the GNU System distribution.
Mekeor Melire  writes:

>> Perhaps you are thinking about this upside down?
>>
>> emacs has support for guix via `emacs-guix`.
>> Would it not make more sense to make a drop in replacement for
>> `use-package` which is syntactically identical but instead of
>> downloading stuff from the emacs package eco-system it installs it from
>> guix into a special emacs managed profile.
>>
>> Then to use it you would just install the `guix-emacs-use-package`
>> instead of `emacs-use-package`.
>>
>> - Mitchell
>
> That's an interesting idea, thanks for sharing. I think it'd be nice if you 
> shared it not only with me but with the whole mailing-list (guix-devel).

Here is a naive implementation which extends use-package to use guix to
ensure packages.

It turns out `use-package` allows you to customize the ensure function.

This is mostly a plagiarized version of the use-package-ensure-elpa.
It creates a profile in ~/.emacs.d./guix-profile by default and every
package which is marked `:ensure t` will be prompted for install.
Set `use-package-ensure-function` to #'use-package-ensure-guix.

#+BEGIN_SRC emacs-lisp
(require 'use-package)
(require 'use-package-guix)

(setq use-package-ensure-function #'use-package-ensure-guix)
#+END_SRC

This is kind of nice because we can now use the `emacs-guix` interfaces
for managing our `use-package` specifications i.e. updates/removal

It is a bit annoying at first because it prompts for y/n verification
for every package but I think this behavior is desirable.

This is my first emacs package so I'm sure there are many things which
can be improved.

#+BEGIN_SRC emacs-lisp
(require 'guix)
(require 'guix-profiles)
(require 'guix-read)
(require 'guix-ui-package)


(defgroup use-package-guix nil
  "use-package support for guix"
  :group 'use-package-ensure)

(defcustom use-package-profile (concat (getenv "HOME") "/.emacs.d/guix-profile")
  "Location of use-package guix profile"
  :type 'string
  :group 'use-package-guix)

(defun guix-package-installed-p (package)
  (bui-assoc-value package 'installed))

(defun canonicalize-name (package-name)
  "Make sure package name has \"emacs-\" prefix"
  (if (string-match "^emacs-.+" package-name)
  package-name
(concat "emacs-" package-name)))

(defun emacs-package->guix-package (package)
  "Return guix package from package name"
  (car (guix-output-list-get-entries use-package-profile 'name
 (canonicalize-name package

(defun guix-package-id (package)
  (bui-entry-non-void-value package 'id))

(defun guix-install-package (package)
  (if (guix-package-installed-p package)
  t
(guix-process-package-actions
 use-package-profile
 `((install (,(string-to-number (car (split-string (bui-entry-id package) 
":"))) "out"
 (current-buffer)))

(defun guix-installed-packages ()
  (guix-output-list-get-entries use-package-profile 'installed))


(defun use-package-ensure-guix (name args _state  _no-refresh)
  (dolist (ensure args)
(let ((package
   (or (and (eq ensure t)
(use-package-as-symbol name))
   ensure)))
  (when package
(when (consp package)
  (use-package-pin-package (car package) (cdr package))
  (setq package (car package)))

(let ((package (emacs-package->guix-package (use-package-as-string 
package
  (unless (guix-package-installed-p package)
(condition-case-unless-debug err
(progn
  (when (assoc package (bound-and-true-p
package-pinned-packages))
(package-read-all-archive-contents))
  (if (assoc package package-archive-contents)
  (package-install package)
(package-refresh-contents)
(when (assoc package (bound-and-true-p
  package-pinned-packages))
  (package-read-all-archive-contents))
(guix-install-package package))
  t)
  (error
   (display-warning 'use-package
(format "Failed to install %s: %s"
name (error-message-string err))
:error)

;;;###autoload
(add-to-list 'load-path (concat use-package-profile "/share/emacs/site-lisp"))

(provide 'use-package-guix)
#+END_SRC



Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

2022-12-27 Thread bokr
Hi Jgart,

On +2022-12-27 19:23:18 +, jgart wrote:
> > I'm not sure what you mean if it is something beyond what we can do already 
> > with 'guix shell.' Do
> > you mean using a particular hashbang as well? 
> 
> Yes, that is one feature that I was nodding ambiguously at. Sorry
> 
> > guix shell sbcl sbcl-cl-csv unoconv -- sbcl --load myscript.lisp 
> > ~/Downloads/*.xlsx
> 
> That command is too long. What Roswell does is create binaries and installs 
> them in your PATH for your usage like a traditional script that you can call 
> without also having to call the interpreter in your terminal invocation.
> 
> I want to type just the following and have `myscript` be an executable 
> program available in my `guix home` environment:
> 
> > myscript ~/Downloads/*.xlsx

If bash is interpreting your script, could you use alias 
myscript=YOUR_MAGIC_HERE
to get the concise invocations you want?
(which bash BTW? -- from logind, child of that, or via a guix profile, or 
minimal-something ??)
┌──┐
│  help alias  │
├──┤
│ alias: alias [-p] [name[=value] ... ]│
│ Define or display aliases.   │
│  │
│ Without arguments, `alias' prints the list of aliases in the reusable│
│ form `alias NAME=VALUE' on standard output.  │
│  │
│ Otherwise, an alias is defined for each NAME whose VALUE is given.   │
│ A trailing space in VALUE causes the next word to be checked for │
│ alias substitution when the alias is expanded.   │
│  │
│ Options: │
│   -p  print all defined aliases in a reusable format │
│  │
│ Exit Status: │
│ alias returns true unless a NAME is supplied for which no alias has been │
│ defined. │
└──┘

> 
> I want an automated way to prepare the script for that command line user 
> experience. That is the convenience that roswell provides. I agree that is is 
> sweet sugar but I'm lazy and don't want to type long CLI invocations.
>

I think it's possible, the question for me is what language
do you want to code your automation in :)

> Thanks for sharing the above though.
> 
> It's great to see how people are using `guix shell`.
> 
> Given what I said, I might just do what you're suggesting John, because I'm 
> not sure when I'll be able to implement a solution like the roswell one in 
> Guix.
> 
> Thanks for your thoughts on the topic. They are appreciated.
> 
> all best,
> 
> jgart
>
--
Regards,
Bengt Richter



Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

2022-12-27 Thread jgart
> What about something like this?
> 
> --8<---cut here---start->8---
> #!/bin/sh
> #|-*- mode:lisp -*-|#
> #|
> exec guix shell sbcl -- sbcl --script $0 "$@"
> |#
> 
> (format t "test~%")
> --8<---cut here---end--->8---
> 
> This example is pretty similar to the ROS file header which would be
> like.
> 
> --8<---cut here---start->8---
> #!/bin/sh
> #|-*- mode:lisp -*-|#
> #|
> exec ros -Q -- $0 "$@"
> |#
> 
> (format t "test~%")
> --8<---cut here---end--->8---
> 
> Cheers,
> Russell


Yas!

That's it!!!



Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

2022-12-27 Thread jgart
> I'm not sure what you mean if it is something beyond what we can do already 
> with 'guix shell.' Do
> you mean using a particular hashbang as well? 

Yes, that is one feature that I was nodding ambiguously at. Sorry

> guix shell sbcl sbcl-cl-csv unoconv -- sbcl --load myscript.lisp 
> ~/Downloads/*.xlsx

That command is too long. What Roswell does is create binaries and installs 
them in your PATH for your usage like a traditional script that you can call 
without also having to call the interpreter in your terminal invocation.

I want to type just the following and have `myscript` be an executable program 
available in my `guix home` environment:

> myscript ~/Downloads/*.xlsx

I want an automated way to prepare the script for that command line user 
experience. That is the convenience that roswell provides. I agree that is is 
sweet sugar but I'm lazy and don't want to type long CLI invocations.

Thanks for sharing the above though.

It's great to see how people are using `guix shell`.

Given what I said, I might just do what you're suggesting John, because I'm not 
sure when I'll be able to implement a solution like the roswell one in Guix.

Thanks for your thoughts on the topic. They are appreciated.

all best,

jgart



Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm

2022-12-27 Thread Development of GNU Guix and the GNU System distribution.
Right you are, I am quite new to mailing lists and I thought emacs would “do 
the right thing”.

- Mitchell 

> On Dec 27, 2022, at 4:15 AM, Mekeor Melire  wrote:
> 
> 2022-12-26 14:20 mitchellschmeis...@librem.one:
> 
>> Perhaps you are thinking about this upside down?
>> 
>> emacs has support for guix via `emacs-guix`.
>> Would it not make more sense to make a drop in replacement for
>> `use-package` which is syntactically identical but instead of
>> downloading stuff from the emacs package eco-system it installs it from
>> guix into a special emacs managed profile.
>> 
>> Then to use it you would just install the `guix-emacs-use-package`
>> instead of `emacs-use-package`.
>> 
>> - Mitchell
> 
> That's an interesting idea, thanks for sharing. I think it'd be nice if you 
> shared it not only with me but with the whole mailing-list (guix-devel).



Re: Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

2022-12-27 Thread John Kehayias
Hi Guixers/Lispers,

On Tue, Dec 27, 2022 at 06:14 PM, jgart wrote:

> Hi Guixers,
>
> Should Guix support writing CLI Common Lisp scripts? (Think Roswell)
>
>> Although Roswell is a unified interface to Common Lisp implementations, it 
>> also
>> encourages writing scripts with it.
>> A "Roswell script" is an implementation-independent script which can be 
>> invoked from a
>> shell command line, launched by > Roswell and run under standard CL 
>> environment.
>
> Just insert "Guix" wherever you see Roswell mentioned in the above quote.
>
>> * A roswell script can be distributed using quicklisp's infrastructure
>
> Just insert "Guix" wherever you see quicklisp is mentioned in the above quote.
>
>> If you're the author of the library, then consider adding the ros file to 
>> the repository
>> and automatically providing a roswell-installable command-line interface to 
>> it.
>
> Same above, insert Guix.
>
> I think we should make it easier for Lispers to write CLI scripts with Guix.
>
> WDYT
>
> 

I'm not sure what you mean if it is something beyond what we can do already 
with 'guix shell.' Do you mean using a particular hashbang as well? I haven't 
done that but my simplistic usage is quick and easy for me.

For example, I like to have some CL scripts I use for file processing that 
lives as a single .lisp file. To run it I just do:

guix shell sbcl sbcl-cl-csv unoconv -- sbcl --load myscript.lisp 
~/Downloads/*.xlsx

where I can include the compiler/interpreters sbcl, needed library, and an 
external tool that is called by the script for pre-processing. Works great, and 
of course instantly after the first caching. This could be combined with a 
manifest, version/channel pinning, making my script a package in a channel, 
guix.scm file, and so on, to make it more reproducible. But for me this is 
already super handy and easy, just one line.

John




Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

2022-12-27 Thread jgart
Hi Guixers,

Should Guix support writing CLI Common Lisp scripts? (Think Roswell)

> Although Roswell is a unified interface to Common Lisp implementations, it 
> also encourages writing scripts with it.
> A "Roswell script" is an implementation-independent script which can be 
> invoked from a shell command line, launched by > Roswell and run under 
> standard CL environment.

Just insert "Guix" wherever you see Roswell mentioned in the above quote.

> * A roswell script can be distributed using quicklisp's infrastructure

Just insert "Guix" wherever you see quicklisp is mentioned in the above quote.

> If you're the author of the library, then consider adding the ros file to the 
> repository and automatically providing a roswell-installable command-line 
> interface to it.

Same above, insert Guix.

I think we should make it easier for Lispers to write CLI scripts with Guix.

WDYT

https://roswell.github.io/Roswell-as-a-Scripting-Environment.html



build-system-modules

2022-12-27 Thread Development of GNU Guix and the GNU System distribution.


Is there a good reason to have put %gnu-build-system-modules after other
modules when defining %X-build-system-modules ?

I met a packaging error two times when hacking guile or maven packages,
where after using the #:modules flag in arguments, I found myself with
gnu build-system packaging phases instead of guile or maven build-system
modules. When inverting the modules order, I don't have this error
anymore. I would like to invert them, except if there's a reason against
it.

Codelines I'm referring to :

 (define %guile-build-system-modules
   ;; Build-side modules imported by default.
-  `((guix build guile-build-system)
-,@%gnu-build-system-modules))
+  `(,@%gnu-build-system-modules
+(guix build guile-build-system)))


 (define %maven-build-system-modules
   ;; Build-side modules imported by default.
-  `((guix build maven-build-system)
-(guix build maven pom)
-,@%gnu-build-system-modules))
+  `(,@%gnu-build-system-modules
+(guix build maven-build-system)
+(guix build maven pom)))

To reproduce:

Take a guile or maven package, fill the #:modules key in arguments with
respectively '(%guile-build-system-modules) or
'(%maven-build-system-modules), the packaging phases should fail with
gnu-build-system packaging phases.

-- 
Best regards,
Nicolas Graves



Re: u-boot-am335x-boneblack -> u-boot-am335x-evm-boneblack

2022-12-27 Thread Vagrant Cascadian
On 2022-12-26, Maxim Cournoyer wrote:
> Vagrant Cascadian  writes:
>> On 2022-12-22, Maxim Cournoyer wrote:
>>> Vagrant Cascadian  writes:
>> I will take a guess that it was commit
>> c2c1dfdf5760873f1db86d14873f725a105f7feb which removed the "name" bit:
>
> Oh, that explains it, thank you for digging a bit.
>
> The following should return us to the previous name, fixing that
> regression:
>
> --8<---cut here---start->8---
> modified   gnu/bootloader/u-boot.scm
> @@ -144,7 +144,7 @@ (define u-boot-bootloader
>  (define u-boot-beaglebone-black-bootloader
>(bootloader
> (inherit u-boot-bootloader)
> -   (package u-boot-am335x-evm-boneblack)
> +   (package u-boot-am335x-boneblack)
> (disk-image-installer install-beaglebone-black-u-boot)))
>  
>  (define u-boot-allwinner-bootloader
> modified   gnu/packages/bootloaders.scm
> @@ -890,17 +890,23 @@ (define*-public (make-u-boot-package board triplet
>  (define-public u-boot-malta
>(make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
>  
> -(define-public u-boot-am335x-evm-boneblack
> -  (make-u-boot-package
> -   "am335x_evm" "arm-linux-gnueabihf"
> -   ;; Patch out other device trees to build an image small enough to fit
> -   ;; within typical partitioning schemes where the first partition begins at
> -   ;; sector 2048.
> -   #:configs '("CONFIG_OF_LIST=\"am335x-evm am335x-boneblack\"")
> -   #:name-suffix "-boneblack"
> -   #:append-description "This U-Boot is built for the BeagleBone Black, which
> -was removed upstream, adjusted from the am335x_evm build with several device
> -trees removed so that it fits within common partitioning schemes."))
> +(define-public u-boot-am335x-boneblack
> +  (let ((base (make-u-boot-package
> +   "am335x_evm" "arm-linux-gnueabihf"
> +   ;; Patch out other device trees to build an image small enough
> +   ;; to fit within typical partitioning schemes where the first
> +   ;; partition begins at sector 2048.
> +   #:configs '("CONFIG_OF_LIST=\"am335x-evm am335x-boneblack\"")
> +   #:append-description
> +   "This U-Boot is built for the BeagleBone Black, which was
> +removed upstream, adjusted from the am335x_evm build with several device 
> trees
> +removed so that it fits within common partitioning schemes.")))
> +(package
> +  (inherit base)
> +  ;; The name is not derived from the board name on purpose as the config
> +  ;; is modified per the comment above, parting from the default
> +  ;; am335x_evm configuration.
> +  (name "u-boot-am335x-boneblack"
>  
>  (define-public u-boot-am335x-evm
>(make-u-boot-package "am335x_evm" "arm-linux-gnueabihf"))
> --8<---cut here---end--->8---
>
> Does it look good to you?  If so, I'll commit it.

It doesn't look obviously wrong... but there are a lot of whitespace
changes that my lazy eyeballs might not catch... :)

I would like to be able to see the results with "git diff
--ignore-allspace" but it is not formatted in a way I understand how to
actually apply it to git.


live well,
  vagrant


signature.asc
Description: PGP signature


Re: Stratification of GNU Guix into Independent Channels

2022-12-27 Thread Hartmut Goebel

Am 24.12.22 um 04:49 schrieb jgart:

Should GNU Guix be a small core of packages (and services?)?


No. As others already stated, this would complicate things for users. 
Having all available software at on place is a big plus. (For many 
GNU/Linux distros you need to add another ppa for many „standard“ cases. 
IMHO this is disgusting)


--
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |