* proposal: (define (find-guix-packages list-of-names) ... ) @ 2015-11-12 8:21 Florian Paul Schmidt 2015-11-15 20:35 ` Ludovic Courtès 0 siblings, 1 reply; 9+ messages in thread From: Florian Paul Schmidt @ 2015-11-12 8:21 UTC (permalink / raw) To: guix-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, I found a procedure like this (then at the top of my system config.scm's) to be quite useful: diff --git a/gnu/packages.scm b/gnu/packages.scm index fb27738..63500ab 100644 - --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -228,6 +228,14 @@ decreasing version order." matching) matching))))) +(define (find-guix-packages list-of-names) + (map + car + (map + find-packages-by-name + list-of-names))) + + (define find-newest-available-packages (memoize (lambda () Which could be used in the config like this (for example): ;; Globally-installed packages. (packages (append (find-guix-packages '("htop" "wget" "xmonad" "openssh" "dmenu" "git" "xterm" "emacs")) %base-packages)) and which saves the user from manually entering the use-modules for the module packages at the top of the config. I am aware that is maybe still too simplistic. E.g.: It might be good to check if the name is ambiguous instead of just taking the first result and throw an error in that case. As a typical programmer I am allergic to seemingly redundant and automatable tasks, so I'd love to see something at least similar in spirit in guix. Thoughts? Regards, Flo - -- https://fps.io -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWREv5AAoJEA5f4Coltk8Zd10H+wQTkueXnBzYYpPtVNaXRveE auyz9KXzcBDWw9vBSMnJjup3vG8bLIpniqQBjhTM1s29h60Z4bN/BNBq3Hnmee9s Fec0pRqIL2tcbenP4hIov56nfxjgg7hDp9ZCKZ/VBy5ROGArc4OLiiaMuaZxiB1N ph4uR4JDnm+YAWavv3DOBFn4czFhQSokTmW6uPdq5pgJznqP6FtV/fR281eQO65K 1ZnkCRxYiVwVlm+wfg9dCGORm1hu+qXwwzUkIGJ4F09IIVQUwoItzHjDcOHGs+Db h4ltuNlvX4mUUB8NQO2tC/dWIGCAXX8SBvTJXIEN3wzzG4G6PO84aycU37zVvY4= =7PjJ -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-12 8:21 proposal: (define (find-guix-packages list-of-names) ... ) Florian Paul Schmidt @ 2015-11-15 20:35 ` Ludovic Courtès 2015-11-15 21:25 ` Florian Paul Schmidt 0 siblings, 1 reply; 9+ messages in thread From: Ludovic Courtès @ 2015-11-15 20:35 UTC (permalink / raw) To: Florian Paul Schmidt; +Cc: guix-devel Florian Paul Schmidt <mista.tapas@gmx.net> skribis: > +(define (find-guix-packages list-of-names) > + (map > + car > + (map > + find-packages-by-name > + list-of-names))) [...] > I am aware that is maybe still too simplistic. E.g.: It might be good > to check if the name is ambiguous instead of just taking the first > result and throw an error in that case. Indeed. ;-) > As a typical programmer I am allergic to seemingly redundant and > automatable tasks, so I'd love to see something at least similar in > spirit in guix. I can sympathize with this. I think ‘specification->package’ from (gnu packages) is the procedure you want. Like this: (map specification->package '("guile-2" "gnupg-2.0" "coreutils")) It emits a warning in case the specification is ambiguous. Maybe we could/should use it in the example GuixSD configurations, and at least document it somewhere. WDYT? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-15 20:35 ` Ludovic Courtès @ 2015-11-15 21:25 ` Florian Paul Schmidt 2015-11-16 13:03 ` Ludovic Courtès 0 siblings, 1 reply; 9+ messages in thread From: Florian Paul Schmidt @ 2015-11-15 21:25 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, and thanks for your reply.. On 11/15/2015 09:35 PM, Ludovic Courtès wrote: > I think ‘specification->package’ from (gnu packages) is the > procedure you want. Like this: > > (map specification->package '("guile-2" "gnupg-2.0" "coreutils")) > > It emits a warning in case the specification is ambiguous. > > Maybe we could/should use it in the example GuixSD configurations, > and at least document it somewhere. > > WDYT? Sounds like a plan. Though in this use-case I think I'd prefer an error over a warning. For the simple reason that during system reconfigure a warning might be missed easily. Especially after a guix pull where suddenly a package spec might become ambiguous where it wasn't before and a different package gets chosen. OTOH, maybe that's overdoing it and even with the error instead of a warning there are still some failure modes somewhat similar to this: E.g. Package foo disappears while a quite different package foo appears (possibly in a different module). Quite unlikely but possible. Regards, Flo P.S.: Note though that there are modes like this also for the now common practice of using use-modules in a non-local way at the top of the config file but they are more contrived (and depend on having just the right use-modules calls and packages in the packages list). I'm new to guile (and scheme and guix ;), but maybe there's a way to use use-modules in a more local fashion. Together with the guarantee that the module/package combination is unique (not including version changes which are to be expected during a reconfigure after a guix pull) it would be possible to avoid those kind of surprises if needed. - -- https://fps.io -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWSPg8AAoJEA5f4Coltk8ZgLMH/1XkMnLgM1QDQHwe2BgnVDPw idFQRpSP58hC9fld2mM2PVAygXz1GugGBE/zkGzbOSY2KP68gMmpVo61kLHek1r0 2Xy00h82RTTV97zDpe2z6hNpjWdysYKXIj+DaldE9B7rlY4tbllwOmGiyrm8skj9 +3R8Qx2mAqn312NqtQKgbzyD6v+jTfTyI+9e1MhrZN5Ab8eGO8LhYMdN78fm1qKi kedQhha1FsFGEeA1X5u4qUky9Z5A0glI4afbipOfTHU/Asw2NNeETvuItd297evU N0ovcIKkT/PM1X37IJ2/ZvlJPDeiDk9DVj8RjzGioiUUQ4Rt8fBhtiDjOHVVh1o= =PjFY -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-15 21:25 ` Florian Paul Schmidt @ 2015-11-16 13:03 ` Ludovic Courtès 2015-11-16 19:31 ` Florian Paul Schmidt 0 siblings, 1 reply; 9+ messages in thread From: Ludovic Courtès @ 2015-11-16 13:03 UTC (permalink / raw) To: Florian Paul Schmidt; +Cc: guix-devel Florian Paul Schmidt <mista.tapas@gmx.net> skribis: > Hi, and thanks for your reply.. > > On 11/15/2015 09:35 PM, Ludovic Courtès wrote: > >> I think ‘specification->package’ from (gnu packages) is the >> procedure you want. Like this: >> >> (map specification->package '("guile-2" "gnupg-2.0" "coreutils")) >> >> It emits a warning in case the specification is ambiguous. >> >> Maybe we could/should use it in the example GuixSD configurations, >> and at least document it somewhere. >> >> WDYT? > > Sounds like a plan. Though in this use-case I think I'd prefer an > error over a warning. For the simple reason that during system > reconfigure a warning might be missed easily. Especially after a guix > pull where suddenly a package spec might become ambiguous where it > wasn't before and a different package gets chosen. > > OTOH, maybe that's overdoing it and even with the error instead of a > warning there are still some failure modes somewhat similar to this: > E.g. Package foo disappears while a quite different package foo > appears (possibly in a different module). Quite unlikely but possible. There’s a range of options here: referring to variables by name (this is best, you get an error if you got the name wrong, etc.; downside is you need to know what modules to import), using ‘specification->package’, or using something like what you suggested initially. I’m fine with documenting ‘specification->package’ as an alternate option. Its semantics are exactly the same as when referring to a package by name on the command line (a warning if it’s ambiguous, not an error), which seems reasonable. Thoughts? Ludo’. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-16 13:03 ` Ludovic Courtès @ 2015-11-16 19:31 ` Florian Paul Schmidt 2015-11-16 20:06 ` Ludovic Courtès 0 siblings, 1 reply; 9+ messages in thread From: Florian Paul Schmidt @ 2015-11-16 19:31 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 11/16/2015 02:03 PM, Ludovic Courtès wrote: > Florian Paul Schmidt <mista.tapas@gmx.net> skribis: > > I’m fine with documenting ‘specification->package’ as an alternate > option. Its semantics are exactly the same as when referring to a > package by name on the command line (a warning if it’s ambiguous, > not an error), which seems reasonable. > > Thoughts? > Hi again, sure, I'm fine with just a warning, too. Thought I'd just mention the possible problems that exist. If you want to, I can try and put together a patch for the docs.. Regards, Flo - -- https://fps.io -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWSi8RAAoJEA5f4Coltk8ZFNAH/Aw/7702YYsTfbie82VplpuY s5l4KpXpwk9rBpEaZFCAPzaE4Uj39pREwg87o+5KhrpzoGaNZGs9yQI9ivQtQfN7 8W+gxfBPLdTNyqtn5RyHEOgm6RcwfnmOu5Ci7wzihproXT3tSJ6QtstFaRVUQh+e GoWKAFh0fZQtHL6IQgix6cztoYfWxgBPnx9vctZUE1jLyITQXaF2p/eHhyJjlyB6 BYD9RZwIhAyw8DpFznhFv4Maq6YpeRb4Fo/513VAOO7cCkXbuawgVhtn8cYFY+xL rAy8tP75Tya++7K/tL3bfKaR38PeH9WiWVKxGhYI6rzZeN2w9dyn8oUbYK1m9v8= =2WEf -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-16 19:31 ` Florian Paul Schmidt @ 2015-11-16 20:06 ` Ludovic Courtès 2015-11-20 18:21 ` Florian Paul Schmidt 0 siblings, 1 reply; 9+ messages in thread From: Ludovic Courtès @ 2015-11-16 20:06 UTC (permalink / raw) To: Florian Paul Schmidt; +Cc: guix-devel Florian Paul Schmidt <mista.tapas@gmx.net> skribis: > sure, I'm fine with just a warning, too. Thought I'd just mention the > possible problems that exist. If you want to, I can try and put > together a patch for the docs.. Sure. I think we would need a new section for (gnu packages), maybe “Distribution API” under “GNU Distribution”? It would describe ‘fold-packages’, ‘specification->package’, and so on. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-16 20:06 ` Ludovic Courtès @ 2015-11-20 18:21 ` Florian Paul Schmidt 2015-11-28 15:39 ` Ludovic Courtès 0 siblings, 1 reply; 9+ messages in thread From: Florian Paul Schmidt @ 2015-11-20 18:21 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 1777 bytes --] On Mon, 16 Nov 2015 21:06:00 +0100 ludo@gnu.org (Ludovic Courtès) wrote: > Sure. I think we would need a new section for (gnu packages), maybe > “Distribution API” under “GNU Distribution”? It would describe > ‘fold-packages’, ‘specification->package’, and so on. Let's start smaller :) [I'm still fighting with emacs - I gave it many chances over the years, but we'll never find true happy puppies' love - and a few other things...] --snip diff --git a/doc/guix.texi b/doc/guix.texi index 3b6955c..32bedd7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5482,6 +5482,25 @@ above, such as @code{host-name} and @code{bootloader}, are mandatory. Others, such as @code{packages} and @code{services}, can be omitted, in which case they get a default value. +The attentive reader might have noticed that the @code{tcpdump} package +is defined in the @code{gnu packages admin} module. While it is generally +encouraged to install packages in users' profiles it might be +necessary to install a few more packages in the base system. Maintaining +the list of used modules (and figuring out which are the correct +ones) can become a burden and error prone. But the system configuration +is a lisp program, so we can make use of the power of lisp to automate +this task. The @code{gnu packages} module provides the +@code{specification->package} procedure which can help us here: + +@lisp + ;; Globally-installed packages. + (packages + (append + (map (specification->package + `("tcpdump" "emacs" "htop" "tmux"))) + %base-packages)) +@end lisp + @vindex %base-packages The @code{packages} field lists packages that will be globally visible on the system, for all user --snip [-- Attachment #2: guix.texi.diff --] [-- Type: application/octet-stream, Size: 1263 bytes --] diff --git a/doc/guix.texi b/doc/guix.texi index 3b6955c..32bedd7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5482,6 +5482,25 @@ above, such as @code{host-name} and @code{bootloader}, are mandatory. Others, such as @code{packages} and @code{services}, can be omitted, in which case they get a default value. +The attentive reader might have noticed that the @code{tcpdump} package +is defined in the @code{gnu packages admin} module. While it is generally +encouraged to install packages in users' profiles it might be +necessary to install a few more packages in the base system. Maintaining +the list of used modules (and figuring out which are the correct +ones) can become a burden and error prone. But the system configuration +is a lisp program, so we can make use of the power of lisp to automate +this task. The @code{gnu packages} module provides the +@code{specification->package} procedure which can help us here: + +@lisp + ;; Globally-installed packages. + (packages + (append + (map (specification->package + `("tcpdump" "emacs" "htop" "tmux"))) + %base-packages)) +@end lisp + @vindex %base-packages The @code{packages} field lists packages that will be globally visible on the system, for all user ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-20 18:21 ` Florian Paul Schmidt @ 2015-11-28 15:39 ` Ludovic Courtès 2015-11-29 11:32 ` Florian Paul Schmidt 0 siblings, 1 reply; 9+ messages in thread From: Ludovic Courtès @ 2015-11-28 15:39 UTC (permalink / raw) To: Florian Paul Schmidt; +Cc: guix-devel Florian Paul Schmidt <mista.tapas@gmx.net> skribis: > On Mon, 16 Nov 2015 21:06:00 +0100 > ludo@gnu.org (Ludovic Courtès) wrote: > >> Sure. I think we would need a new section for (gnu packages), maybe >> “Distribution API” under “GNU Distribution”? It would describe >> ‘fold-packages’, ‘specification->package’, and so on. > > Let's start smaller :) I rearranged the text and ended up with something different from your original patch but hopefully as informative in f6c9fb1. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: proposal: (define (find-guix-packages list-of-names) ... ) 2015-11-28 15:39 ` Ludovic Courtès @ 2015-11-29 11:32 ` Florian Paul Schmidt 0 siblings, 0 replies; 9+ messages in thread From: Florian Paul Schmidt @ 2015-11-29 11:32 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 11/28/2015 04:39 PM, Ludovic Courtès wrote: >> Let's start smaller :) > > I rearranged the text and ended up with something different from > your original patch but hopefully as informative in f6c9fb1. And more concise :) Thanks, Flo - -- https://fps.io -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWWuJIAAoJEA5f4Coltk8Z/1EH/j0g117qwChLvfwOpN9pKxuo ogpOn8T4W+jnvwva923cmWB1BmsfMA2P46ONo2EEGjiKwOboaLCylR3J4Pf2HQhe yPztW2DB/H3WsgONDNYDMVR1TXgHIObpf379YpEuj5LWw+RsL5C2rwhZnAXBwZwV 4mnNdxJvQQvp/+ortoYgAYpctSKA/eqCtaUn1s6D8XyEsSxd7cnKmJT02FWaXDxx Q4vXyYRVIjpHNnFC3nPZzvO0dqvhAhX1jyxn6Q6BeuHDOG29XvjzrZPOY2MEFkCc sBRPkn35YwylkXGZIq9zG34RW5VL91J5f7Jt4plDCzpwqW6Fqy0maGxMQXrPsG0= =dD/A -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-11-29 11:32 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-11-12 8:21 proposal: (define (find-guix-packages list-of-names) ... ) Florian Paul Schmidt 2015-11-15 20:35 ` Ludovic Courtès 2015-11-15 21:25 ` Florian Paul Schmidt 2015-11-16 13:03 ` Ludovic Courtès 2015-11-16 19:31 ` Florian Paul Schmidt 2015-11-16 20:06 ` Ludovic Courtès 2015-11-20 18:21 ` Florian Paul Schmidt 2015-11-28 15:39 ` Ludovic Courtès 2015-11-29 11:32 ` Florian Paul Schmidt
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).