aboutsummaryrefslogtreecommitdiff
path: root/etc/indent-code.el.in
blob: 6102b5d1ab7baaaea2824fdf114c2831480d559c (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!@EMACS@ --script
;;; indent-code.el --- Run Emacs to indent a package definition.

;; Copyright © 2017 Alex Kost <alezost@gmail.com>
;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>

;; 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 License as published by
;; the Free Software Foundation, either version 3 of the License, 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 License for more details.

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

;;; Commentary:

;; This scripts indents the given file or package definition in the specified
;; file using Emacs.

;;; Code:

;; Load Scheme indentation rules from ".dir-locals.el".
(with-temp-buffer
  (scheme-mode)
  (let ((default-directory (file-name-as-directory load-file-name))
        (enable-local-variables :all))
    (hack-dir-local-variables)
    (hack-local-variables-apply)))

;; Add indentation info for Scheme constructs that are not Guix-specific.
;; This is normally provided by Geiser but this file is for people who may not
;; be running Geiser, so we just copy it here (from 'geiser-syntax.el').
(defmacro guix-syntax--scheme-indent (&rest pairs)
  `(progn ,@(mapcar (lambda (p)
                      `(put ',(car p) 'scheme-indent-function ',(cadr p)))
                    pairs)))

(guix-syntax--scheme-indent
 (and-let* 1)
 (case-lambda 0)
 (catch defun)
 (class defun)
 (dynamic-wind 0)
 (guard 1)
 (let*-values 1)
 (let-values 1)
 (let/ec 1)
 (letrec* 1)
 (match 1)
 (match-lambda 0)
 (match-lambda* 0)
 (match-let scheme-let-indent)
 (match-let* 1)
 (match-letrec 1)
 (opt-lambda 1)
 (parameterize 1)
 (parameterize* 1)
 (receive 2)
 (require-extension 0)
 (syntax-case 2)
 (test-approximate 1)
 (test-assert 1)
 (test-eq 1)
 (test-equal 1)
 (test-eqv 1)
 (test-group-with-cleanup 1)
 (test-runner-on-bad-count! 1)
 (test-runner-on-bad-end-name! 1)
 (test-runner-on-final! 1)
 (test-runner-on-group-begin! 1)
 (test-runner-on-group-end! 1)
 (test-runner-on-test-begin! 1)
 (test-runner-on-test-end! 1)
 (test-with-runner 1)
 (unless 1)
 (when 1)
 (while 1)
 (with-exception-handler 1)
 (with-syntax 1))


(pcase command-line-args-left
  (`(,file-name ,package-name)
   ;; Indent the definition of PACKAGE-NAME in FILE-NAME.
   (find-file file-name)
   (goto-char (point-min))
   (if (re-search-forward (concat "^(define\\(-public\\) +"
                                  package-name)
                          nil t)
       (let ((indent-tabs-mode nil))
         (beginning-of-defun)
         (indent-sexp)
         (save-buffer)
         (message "Done!"))
     (error "Package '%s' not found in '%s'"
            package-name file-name)))
  (`(,file-name)
   ;; Indent all of FILE-NAME.
   (find-file file-name)
   (let ((indent-tabs-mode nil))
     (indent-region (point-min) (point-max))
     (save-buffer)
     (message "Done!")))
  (x
   (error "Usage: indent-code.el FILE [PACKAGE]")))

;;; indent-code.el ends here
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 [[http://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 [[http://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 - [[http://nixos.org][Nix, Nixpkgs, and NixOS]], functional package manager and associated software distribution, are the inspiration of Guix - [[http://www.gnu.org/software/stow/][GNU Stow]] builds around the idea of one directory per prefix, and a symlink tree to create user environments - [[http://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 [[http://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