From mboxrd@z Thu Jan 1 00:00:00 1970 From: swedebugia Subject: Re: Article: Playing with Guix REPL from scratch Date: Tue, 25 Dec 2018 19:01:33 +0100 Message-ID: References: <815ec957-58a6-1b17-646a-457217ea7851@riseup.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbquz-0000AP-Aa for guix-devel@gnu.org; Tue, 25 Dec 2018 12:55:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbquw-0000Vm-4s for guix-devel@gnu.org; Tue, 25 Dec 2018 12:55:01 -0500 Received: from mx1.riseup.net ([198.252.153.129]:32914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gbquv-0000Ur-Si for guix-devel@gnu.org; Tue, 25 Dec 2018 12:54:58 -0500 Received: from cotinga.riseup.net (cotinga-pn.riseup.net [10.0.1.164]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id E46531A0148 for ; Tue, 25 Dec 2018 09:54:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by cotinga.riseup.net with ESMTPSA id D70DF105ACF for ; Tue, 25 Dec 2018 09:54:55 -0800 (PST) In-Reply-To: <815ec957-58a6-1b17-646a-457217ea7851@riseup.net> Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org On 2018-12-25 12:47, swedebugia wrote: > Hi people >=20 > Today I wrote this draft blog post while playing around: >=20 > Playing with Guix REPL from scratch >=20 > This is a small example of how to quickly get an environment to play=20 > with Guix in guile. >=20 > First setup your environment. >=20 > I choose a x86_64 PC and booted up the installer from an usb stick. >=20 > 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. >=20 > I started by installing a sensible array of packages: >=20 > =C2=A0$ guix package -i emacs-no-x lynx git-minimal guile-readline > guile-colorized emacs-paredit nss-certs >=20 > To set this up as intended then run: >=20 > =C2=A0$ export > GUILE_LOAD_PATH=3D$HOME/.guix-profile/share/guile/site/2.2:/run/current= -system/profile/share/guile/site/2.2=20 >=20 > =C2=A0$ export SSL_CERT_DIR=3D/root/.guix-profile/etc/ssl/certs >=20 > Now fire up the guix repl with >=20 > =C2=A0$guix repl >=20 > Load e.g. this to start hacking on package records: >=20 > (use-modules > =C2=A0=C2=A0=C2=A0=C2=A0(guix packages) > =C2=A0=C2=A0=C2=A0=C2=A0(guix import utils) > =C2=A0=C2=A0=C2=A0=C2=A0(gnu) > =C2=A0=C2=A0=C2=A0=C2=A0(gnu packages sync)) >=20 > 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) >=20 > E.g. (package 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? >=20 > In addition to this there are the following origin-record-procedures: >=20 > E.g. (origin 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? >=20 > What can we do with this you might ask? >=20 > Well how about getting the url of a specific package? >=20 > scheme@(guix-user)> (origin-uri (package-source lsyncd)) > $4 =3D "https://github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz" >=20 > Fetching it? >=20 > scheme@(guix-user)> (url-fetch > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (origin-uri (package-source lsyncd)) "temp") >=20 > 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'... > =C2=A0release-2.2.2.tar.gz=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 253KiB/s 00:00 | 80KiB > =C2=A0transferred > =C2=A0$3 =3D "temp" >=20 > 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-": >=20 > scheme@(guile-user)> (define snakes > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (fold-packag= es > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (lambda (package lst) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (string-prefix? "= python" > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (package-name package)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cons packag= e lst) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 lst)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '()= )) >=20 > Now we can work on this list. As of writing this we have this many > items in the list: >=20 > scheme@(guix-user)> (length snakes) > $5 =3D 1532 >=20 > scheme@(guile-user)> (define snakes > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (fold-packag= es > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (lambda (package lst) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (string-prefix? "= python" > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (package-name package)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cons (origi= n-url package) lst) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 lst)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '()= )) >=20 > If you create something worth saving, mount an USB stick or a harddisk > partition and save it there. FYI: I would like to publish it in the guix blog when it is ready. I=20 published it here just to get comments/review as it is my first post to=20 the blog :-) -- Cheers Swedebugia --=20 Cheers Swedebugia