unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: swedebugia <swedebugia@riseup.net>
To: guix-devel <guix-devel@gnu.org>
Subject: Article: Playing with Guix REPL from scratch
Date: Tue, 25 Dec 2018 12:47:49 +0100	[thread overview]
Message-ID: <815ec957-58a6-1b17-646a-457217ea7851@riseup.net> (raw)

Hi people

Today I wrote this draft blog post while playing around:

Playing with Guix REPL from scratch

This is a small example of how to quickly get an environment to play 
with Guix in guile.

First setup your environment.

I choose a x86_64 PC and booted up the installer from an usb stick.

This is a nice environment because it already is running GuixSD in a
console and you have are in Guix land with 8500 packages at your
fingertips.

I started by installing a sensible array of packages:

  $ guix package -i emacs-no-x lynx git-minimal guile-readline
guile-colorized emacs-paredit nss-certs

To set this up as intended then run:

  $ export
GUILE_LOAD_PATH=$HOME/.guix-profile/share/guile/site/2.2:/run/current-system/profile/share/guile/site/2.2
  $ export SSL_CERT_DIR=/root/.guix-profile/etc/ssl/certs

Now fire up the guix repl with

  $guix repl

Load e.g. this to start hacking on package records:

(use-modules
	(guix packages)
	(guix import utils)
	(gnu)
	(gnu packages sync))

Now you can start hacking on all packages in sync.scm using Scheme
procedures from (gnu packages) (see the source of this module for
details or guess and press tab)

E.g. (package<TAB><TAB> shows this list of nice procedures availiable:
package
package->cross-derivation
package->definition
package->derivation
package-build-system
package-cross-build-system-error?
package-cross-derivation
package-derivation
package-description
package-direct-inputs
package-direct-sources
package-error-invalid-input
package-error-package
package-error?
package-field-location
package-file
package-full-name
package-grafts
package-home-page
package-input-error?
package-input-rewriting
package-inputs
package-license
package-location
package-maintainers
package-mapping
package-name
package-native-inputs
package-native-search-paths
package-output
package-outputs
package-patched-vulnerabilities
package-propagated-inputs
package-properties
package-search-paths
package-source
package-source-derivation
package-superseded
package-supported-systems
package-synopsis
package-transitive-inputs
package-transitive-native-inputs
package-transitive-native-search-paths
package-transitive-propagated-inputs
package-transitive-sources
package-transitive-supported-systems
package-transitive-target-inputs
package-upstream-name
package-version
package/inherit
package?

In addition to this there are the following origin-record-procedures:

E.g. (origin<TAB><TAB> shows this list
origin
origin->derivation
origin-actual-file-name
origin-file-name
origin-method
origin-modules
origin-patch-flags
origin-patch-guile
origin-patch-inputs
origin-patches
origin-sha256
origin-snippet
origin-uri
origin?

What can we do with this you might ask?

Well how about getting the url of a specific package?

scheme@(guix-user)> (origin-uri (package-source lsyncd))
$4 = "https://github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz"

Fetching it?

scheme@(guix-user)> (url-fetch
		     (origin-uri (package-source lsyncd)) "temp")

Starting download of temp
 From https://github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz...
following redirection to
`https://codeload.github.com/axkibe/lsyncd/tar.gz/release-2.2.2'...
  release-2.2.2.tar.gz                         253KiB/s 00:00 | 80KiB
  transferred
  $3 = "temp"

With fold-packages you can walk through the whole stack of package
records if you would like and count say the number of packages with
the prefix "python-":

scheme@(guile-user)> (define snakes
                        (fold-packages
                             (lambda (package lst)
                               	(if (string-prefix? "python"
                                       (package-name package))
				       (cons package lst)
			     lst))
			'()))

Now we can work on this list. As of writing this we have this many
items in the list:

scheme@(guix-user)> (length snakes)
$5 = 1532

scheme@(guile-user)> (define snakes
                        (fold-packages
                             (lambda (package lst)
                               	(if (string-prefix? "python"
                                       (package-name package))
				       (cons (origin-url package) lst)
			     lst))
			'()))

If you create something worth saving, mount an USB stick or a harddisk
partition and save it there.
-- 
Cheers Swedebugia

             reply	other threads:[~2018-12-25 11:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-25 11:47 swedebugia [this message]
2018-12-25 18:01 ` Article: Playing with Guix REPL from scratch swedebugia
2019-01-05 17:37 ` Ludovic Courtès
2019-01-06  3:24   ` swedebugia
2019-01-06 11:36     ` Pierre Neidhardt
2019-01-08 16:25       ` Ludovic Courtès
2019-01-10  7:46     ` Chris Marusich
2019-01-13 21:52       ` Ludovic Courtès
2019-01-14  9:44         ` Chris Marusich
2019-01-15 22:32           ` Ludovic Courtès
2019-01-23  1:52             ` Chris Marusich
2019-01-23 11:11               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=815ec957-58a6-1b17-646a-457217ea7851@riseup.net \
    --to=swedebugia@riseup.net \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).