aboutsummaryrefslogtreecommitdiff
path: root/emacs/guix-location.el
blob: 81396b40173649b8706364026bb67f23c1d2dbc4 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;;; guix-location.el --- Package locations

;; Copyright © 2016 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public Location as published by
;; the Free Software Foundation, either version 3 of the Location, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public Location for more details.

;; You should have received a copy of the GNU General Public Location
;; along with this program.  If not, see <http://www.gnu.org/locations/>.

;;; Commentary:

;; This file provides the code to work with locations of Guix packages.

;;; Code:

(require 'cl-lib)
(require 'guix-backend)
(require 'guix-read)
(require 'guix-guile)

(defun guix-package-location (id-or-name)
  "Return location of a package with ID-OR-NAME.
For the meaning of location, see `guix-find-location'."
  (guix-eval-read (guix-make-guile-expression
                   'package-location-string id-or-name)))

;;;###autoload
(defun guix-find-location (location &optional directory)
  "Go to LOCATION of a package.
LOCATION is a string of the form:

  \"FILE:LINE:COLUMN\"

If FILE is relative, it is considered to be relative to
DIRECTORY (`guix-directory' by default).

Interactively, prompt for LOCATION.  With prefix argument, prompt
for DIRECTORY as well."
  (interactive
   (list (guix-read-package-location)
         (guix-read-directory)))
  (cl-multiple-value-bind (file line column)
      (split-string location ":")
    (find-file (expand-file-name file (or directory guix-directory)))
    (when (and line column)
      (let ((line   (string-to-number line))
            (column (string-to-number column)))
        (goto-char (point-min))
        (forward-line (- line 1))
        (move-to-column column)
        (recenter 1)))))

;;;###autoload
(defun guix-edit (id-or-name &optional directory)
  "Edit (go to location of) package with ID-OR-NAME.
See `guix-find-location' for the meaning of package location and
DIRECTORY.
Interactively, with prefix argument, prompt for DIRECTORY."
  (interactive
   (list (guix-read-package-name)
         (guix-read-directory)))
  (let ((loc (guix-package-location id-or-name)))
    (if loc
        (guix-find-location loc directory)
      (message "Couldn't find package location."))))

(provide 'guix-location)

;;; guix-location.el ends here
rg/nix/][Nix]] package manager. * Requirements GNU Guix currently depends on the following packages: - [[https://gnu.org/software/guile/][GNU Guile 2.2.x or 2.0.x]], version 2.0.13 or later - [[https://notabug.org/cwebber/guile-gcrypt][Guile-Gcrypt]] 0.1.0 or later - [[https://www.gnu.org/software/make/][GNU Make]] - [[https://www.gnutls.org][GnuTLS]] compiled with guile support enabled - [[https://notabug.org/civodul/guile-sqlite3][Guile-SQLite3]], version 0.1.0 or later - [[https://gitlab.com/guile-git/guile-git][Guile-Git]] - [[http://www.zlib.net/][zlib]] - optionally [[https://savannah.nongnu.org/projects/guile-json/][Guile-JSON]], for the 'guix import pypi' command Unless `--disable-daemon' was passed, the following packages are needed: - [[https://gnupg.org/][GNU libgcrypt]] - [[https://sqlite.org/][SQLite 3]] - [[https://gcc.gnu.org][GCC's g++]] - optionally [[http://www.bzip.org][libbz2]] When `--disable-daemon' was passed, you instead need the following: - [[https://nixos.org/nix/][Nix]] * Installation See the manual for the installation instructions, either by running info -f doc/guix.info "Installation" or by checking the [[https://www.gnu.org/software/guix/manual/guix.html#Installation][web copy of the manual]]. For information on installation from a Git checkout, please see the section "Building from Git" in the manual. * Installing Guix from Guix You can re-build and re-install Guix using a system that already runs Guix. To do so: - Start a shell with the development environment for Guix: guix environment guix - Re-run the 'configure' script passing it the option '--localstatedir=/somewhere', where '/somewhere' is the 'localstatedir' value of the currently installed Guix (failing to do that would lead the new Guix to consider the store to be empty!). - Run "make", "make check", and "make install". * How It Works Guix does the high-level preparation of a /derivation/. A derivation is the promise of a build; it is stored as a text file under =/gnu/store/xxx.drv=. The (guix derivations) module provides the `derivation' primitive, as well as higher-level wrappers such as `build-expression->derivation'. Guix does remote procedure calls (RPCs) to the Guix or Nix daemon (the =guix-daemon= or =nix-daemon= command), which in turn performs builds and accesses to the Nix store on its behalf. The RPCs are implemented in the (guix store) module. * Installing Guix as non-root The Guix daemon allows software builds to be performed under alternate user accounts, which are normally created specifically for this purpose. For instance, you may have a pool of accounts in the =guixbuild= group, and then you can instruct =guix-daemon= to use them like this: $ guix-daemon --build-users-group=guixbuild However, unless it is run as root, =guix-daemon= cannot switch users. In that case, it falls back to using a setuid-root helper program call =nix-setuid-helper=. That program is not setuid-root by default when you install it; instead you should run a command along these lines (assuming Guix is installed under /usr/local): # chown root.root /usr/local/libexec/nix-setuid-helper # chmod 4755 /usr/local/libexec/nix-setuid-helper * Contact GNU Guix is hosted at https://savannah.gnu.org/projects/guix/. Please email <bug-guix@gnu.org> for bug reports or questions regarding Guix and its distribution; email <gnu-system-discuss@gnu.org> for general issues regarding the GNU system. Join #guix on irc.freenode.net. * Guix & Nix GNU Guix is based on [[https://nixos.org/nix/][the Nix package manager]]. It implements the same package deployment paradigm, and in fact it reuses some of its code. Yet, different engineering decisions were made for Guix, as described below. Nix is really two things: a package build tool, implemented by a library and daemon, and a special-purpose programming language. GNU Guix relies on the former, but uses Scheme as a replacement for the latter. Using Scheme instead of a specific language allows us to get all the features and tooling that come with Guile (compiler, debugger, REPL, Unicode, libraries, etc.) And it means that we have a general-purpose language, on top of which we can have embedded domain-specific languages (EDSLs), such as the one used to define packages. This broadens what can be done in package recipes themselves, and what can be done around them. Technically, Guix makes remote procedure calls to the ‘nix-worker’ daemon to perform operations on the store. At the lowest level, Nix “derivations” represent promises of a build, stored in ‘.drv’ files in the store. Guix produces such derivations, which are then interpreted by the daemon to perform the build. Thus, Guix derivations can use derivations produced by Nix (and vice versa). With Nix and the [[https://nixos.org/nixpkgs][Nixpkgs]] distribution, package composition happens at the Nix language level, but builders are usually written in Bash. Conversely, Guix encourages the use of Scheme for both package composition and builders. Likewise, the core functionality of Nix is written in C++ and Perl; Guix relies on some of the original C++ code, but exposes all the API as Scheme. * Related software - [[https://nixos.org][Nix, Nixpkgs, and NixOS]], functional package manager and associated software distribution, are the inspiration of Guix - [[https://www.gnu.org/software/stow/][GNU Stow]] builds around the idea of one directory per prefix, and a symlink tree to create user environments - [[https://www.pvv.ntnu.no/~arnej/store/storedoc_6.html][STORE]] shares the same idea - [[https://live.gnome.org/OSTree/][GNOME's OSTree]] allows bootable system images to be built from a specified set of packages - The [[https://www.gnu.org/s/gsrc/][GNU Source Release Collection]] (GSRC) is a user-land software distribution; unlike Guix, it relies on core tools available on the host system