~brown121407/guile-imanifest

Interactive Guix manifests.

ccd5a21 Use unless instead of if

7 months ago
7 months ago

#guile-imanifest

Interactive Guix manifests.

This is a library that provides functions to generate Guix manifests interactively. It works by scanning an alist of package categories, to ask the user which package sets would they like to install from it.

The user will be prompted to enter a list of the group names they'll want to use. If they want to use all the groups specified at a prompt, they can just write ALL. If a group has multiple subgroups, a new prompt will be displayed to choose between those as well. If you want to have a group with a bunch of mandatory packages but also subgroups, put the mandatory packages in the _ subgroup.

If a list of packages should be installed only if other packages will be installed, you can use the needs function.

The prompt uses readline, so you have TAB-completion of the available group names at a given time.

#Usage

Declare the package groups in a file and feed it to a Guix command. For example, let's assume that this is manifest.scm:

(use-modules (imanifest))

(define groups
  `((_ . ("curl"
          "file"
          "git"
          "git:send-email"
          "gnupg"
          "gnutls"
          "guile"
          "make"
		  "man-db"
          "man-pages"
          "ncurses"))
    (books . ("sicp"))
    (programming . ((c . ("bear"
                          "gcc-toolchain"
                          "gdb"
                          "make"
                          "pkg-config"
                          "ccls"
                          "cmake"
			  ,(needs '("emacs")
				  '("emacs-ccls"))))
                    (common-lisp . ("sbcl"
				    ,(needs '("emacs")
					    '("emacs-slime"
					      "emacs-slime-company"))))
		    (coq . ("coq"
			    "coq:ide"
			    "proof-general"))
                    (elisp . ("emacs"))
                    (scheme . ((guile . ("guile"
                                         "guile-hall"))
                               (chicken . ("chicken"))))
                    (ocaml . ("opam"
			      ,(needs '("emacs")
				      '("emacs-tuareg"))))
                    (haskell . ("ghc"
                                "ghcid"
                                "cabal-install"
				,(needs '("emacs")
					'("emacs-haskell-mode"
					  "emacs-company-cabal"))))))))
					  

					  
(compute-imanifest groups)

Notice that we declare the package groups then we feed them into compute-imanifest. The _ group will be installed no matter what and the programming group will have the c, common-lisp, coq, elisp, scheme ocaml and haskell subgroups.

To actually make it do stuff, feed manifest.scm into Guix. For example, to spawn an environment for C and OCaml programming, use guix environment --ad-hoc -m manifest.scm and select the programming, and then c and ocaml. emacs-ccls and emacs-tuareg won't be installed unless you add emacs to the manifest.

This is an example of how the output looks:

[seamas@conghaile ~]$ guix environment --ad-hoc -m manifest.scm
To choose everything from a group you can just type `ALL' (no quotes).

Enter a list with the tools you want to set up from the `base' group.
Here are the available tools: (basic books desktop emacs fonts games latex mail office programming vim virtualization).

> programming

Enter a list with the tools you want to set up from the `programming' group.
Here are the available tools: (c common-lisp coq elisp haskell ocaml perl php python raku rust scheme standard-ml).

> c ocaml scheme

Enter a list with the tools you want to set up from the `scheme' group.
Here are the available tools: (chicken guile).

> guile
The following derivation will be built:
   /gnu/store/m4dk1yvczp3hz31q324xkcpv7yj56k50-profile.drv

In this example, the values inside groups are strings with the names of packages, but you can also use package objects directly.