aboutsummaryrefslogtreecommitdiff
path: root/HACKING
blob: de7bffea84a31a64ab6fb1f4776a8274aaef9cf0 (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
-*- mode: org; coding: utf-8; -*-

#+TITLE: Hacking GNU Guix and Its Incredible Distro

Copyright © 2012, 2013, 2014, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
Copyright © 2015, 2017 Mathieu Lirzin <mthl@gnu.org>
Copyright © 2017 Leo Famulari <leo@famulari.name>
Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

* Contributing

See the manual for useful hacking informations, either by running

  info -f doc/guix.info "Contributing"

or by checking the [[http://www.gnu.org/software/guix/manual/guix.html#Contributing][web copy of the manual]].

* Commit Access

For frequent contributors, having write access to the repository is
convenient.  When you deem it necessary, feel free to ask for it on the
mailing list.  When you get commit access, please make sure to follow the
policy below (discussions of the policy can take place on guix-devel@gnu.org.)

Non-trivial patches should always be posted to guix-patches@gnu.org (trivial
patches include fixing typos, etc.).  This mailing list fills the
patch-tracking database at [[https://bugs.gnu.org/guix-patches]]; see
"Contributing" in the manual for details.

For patches that just add a new package, and a simple one, it’s OK to commit,
if you’re confident (which means you successfully built it in a chroot setup,
and have done a reasonable copyright and license auditing.)  Likewise for
package upgrades, except upgrades that trigger a lot of rebuilds (for example,
upgrading GnuTLS or GLib.)  We have a mailing list for commit notifications
(guix-commits@gnu.org), so people can notice.  Before pushing your changes,
make sure to run ‘git pull --rebase’.

All commits that are pushed to the central repository on Savannah must be
signed with an OpenPGP key, and the public key should be uploaded to your user
account on Savannah and to public key servers, such as
‘pool.sks-keyservers.net’.  To configure Git to automatically sign commits,
run:

  git config commit.gpgsign true
  git config user.signingkey CABBA6EA1DC0FF33

You can prevent yourself from accidentally pushing unsigned commits to
Savannah by using the pre-push Git hook called located at ‘etc/git/pre-push’:

  cp etc/git/pre-push .git/hooks/pre-push

When pushing a commit on behalf of somebody else, please add a Signed-off-by
line at the end of the commit log message (e.g. with ‘git am --signoff’).
This improves tracking of who did what.

For anything else, please post to guix-patches@gnu.org and leave time for a
review, without committing anything.  If you didn’t receive any reply
after two weeks, and if you’re confident, it’s OK to commit.

That last part is subject to being adjusted, allowing individuals to commit
directly on non-controversial changes on parts they’re familiar with.

* Using emacs-debbugs

Bug reports and patches are tracked using debbugs. If you are on emacs, you
can use emacs-debbugs.

List all open bug reports on guix-patches with

C-u M-x debbugs-gnu <RET> <RET> guix-patches <RET> n y
boot-arguments ,multiboot-arguments) (multiboot-modules ,multiboot-modules))) (($ <menu-entry> label device mount-point #f () #f #f () () (? identity chain-loader)) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) (device-mount-point ,mount-point) (chain-loader ,chain-loader))) (_ (report-menu-entry-error entry)))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry> record." (define (sexp->device device-sexp) (match device-sexp (('uuid type uuid-string) (uuid uuid-string type)) (('label label) (file-system-label label)) (_ device-sexp))) (match sexp (('menu-entry ('version 0) ('label label) ('device device) ('device-mount-point mount-point) ('linux linux) ('linux-arguments linux-arguments) ('initrd initrd) _ ...) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) (linux linux) (linux-arguments linux-arguments) (initrd initrd))) (('menu-entry ('version 0) ('label label) ('device device) ('device-mount-point mount-point) ('multiboot-kernel multiboot-kernel) ('multiboot-arguments multiboot-arguments) ('multiboot-modules multiboot-modules) _ ...) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) (multiboot-kernel multiboot-kernel) (multiboot-arguments multiboot-arguments) (multiboot-modules multiboot-modules))) (('menu-entry ('version 0) ('label label) ('device device) ('device-mount-point mount-point) ('chain-loader chain-loader) _ ...) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) (chain-loader chain-loader))))) ;;; ;;; Bootloader record. ;;; ;; The <bootloader> record contains fields expressing how the bootloader ;; should be installed. Every bootloader in gnu/bootloader/ directory ;; has to be described by this record. (define-record-type* <bootloader> bootloader make-bootloader bootloader? (name bootloader-name) (package bootloader-package) (installer bootloader-installer) (disk-image-installer bootloader-disk-image-installer (default #f)) (configuration-file bootloader-configuration-file) (configuration-file-generator bootloader-configuration-file-generator)) ;;; ;;; Bootloader configuration record. ;;; ;; The <bootloader-configuration> record contains bootloader independant ;; configuration used to fill bootloader configuration file. (define-with-syntax-properties (warn-target-field-deprecation (value properties)) (when value (warning (source-properties->location properties) (G_ "the 'target' field is deprecated, please use 'targets' \ instead~%"))) value) (define-record-type* <bootloader-configuration> bootloader-configuration make-bootloader-configuration bootloader-configuration? (bootloader bootloader-configuration-bootloader) ;<bootloader> (targets %bootloader-configuration-targets (default #f)) ;list of strings (target %bootloader-configuration-target ;deprecated (default #f) (sanitize warn-target-field-deprecation)) (menu-entries bootloader-configuration-menu-entries (default '())) ;list of <menu-entry> (default-entry bootloader-configuration-default-entry (default 0)) ;integer (timeout bootloader-configuration-timeout (default 5)) ;seconds as integer (keyboard-layout bootloader-configuration-keyboard-layout (default #f)) ;<keyboard-layout> | #f (theme bootloader-configuration-theme (default #f)) ;bootloader-specific theme (terminal-outputs bootloader-configuration-terminal-outputs (default '(gfxterm))) ;list of symbols (terminal-inputs bootloader-configuration-terminal-inputs (default '())) ;list of symbols (serial-unit bootloader-configuration-serial-unit (default #f)) ;integer | #f (serial-speed bootloader-configuration-serial-speed (default #f)) ;integer | #f (device-tree-support? bootloader-configuration-device-tree-support? (default #t)) ;boolean (extra-initrd bootloader-configuration-extra-initrd (default #f))) ;string | #f (define-deprecated (bootloader-configuration-target config) bootloader-configuration-targets (%bootloader-configuration-target config)) (define (bootloader-configuration-targets config) (or (%bootloader-configuration-targets config) ;; TODO: Remove after the deprecated 'target' field is removed. (list (%bootloader-configuration-target config)) ;; XXX: At least the GRUB installer (see (gnu bootloader grub)) has this ;; peculiar behavior of installing fonts and GRUB modules when DEVICE is #f, ;; hence the default value of '(#f) rather than '(). (list #f))) ;;; ;;; Bootloaders. ;;; (define (bootloader-modules) "Return the list of bootloader modules." (all-modules (map (lambda (entry) `(,entry . "gnu/bootloader")) %load-path) #:warn warn-about-load-error)) (define %bootloaders ;; The list of publically-known bootloaders. (delay (fold-module-public-variables (lambda (obj result) (if (bootloader? obj) (cons obj result) result)) '() (bootloader-modules)))) (define (lookup-bootloader-by-name name) "Return the bootloader called NAME." (or (find (lambda (bootloader) (eq? name (bootloader-name bootloader))) (force %bootloaders)) (leave (G_ "~a: no such bootloader~%") name))) (define (efi-bootloader-profile packages files hooks) "Creates a profile from the lists of PACKAGES and FILES from the store. This profile is meant to be used by the bootloader-installer. FILES is a list of file or directory names from the store, which will be symlinked into the profile. If a directory name ends with '/', then the directory content instead of the directory itself will be symlinked into the profile. FILES may contain file like objects produced by procedures like plain-file, local-file, etc., or package contents produced with file-append. HOOKS lists additional hook functions to modify the profile." (define* (efi-bootloader-profile-hook manifest #:optional system) (define build (with-imported-modules '((guix build utils)) #~(begin (use-modules ((guix build utils) #:select (mkdir-p strip-store-file-name)) ((ice-9 ftw) #:select (scandir)) ((srfi srfi-1) #:select (append-map every remove)) ((srfi srfi-26) #:select (cut))) (define (symlink-to file directory transform) "Creates a symlink to FILE named (TRANSFORM FILE) in DIRECTORY." (symlink file (string-append directory "/" (transform file)))) (define (directory-content directory) "Creates a list of absolute path names inside DIRECTORY." (map (lambda (name) (string-append directory name)) (or (scandir directory (lambda (name) (not (member name '("." ".."))))) '()))) (define name-ends-with-/? (cut string-suffix? "/" <>)) (define (name-is-store-entry? name) "Return #t if NAME is a direct store entry and nothing inside." (not (string-index (strip-store-file-name name) #\/))) (let* ((files '#$files) (directories (filter name-ends-with-/? files)) (names-from-directories (append-map (lambda (directory) (directory-content directory)) directories)) (names (append names-from-directories (remove name-ends-with-/? files)))) (mkdir-p #$output) (if (every file-exists? names) (begin (for-each (lambda (name) (symlink-to name #$output (if (name-is-store-entry? name) strip-store-file-name basename))) names) #t) #f))))) (gexp->derivation "efi-bootloader-profile" build #:system system #:local-build? #t #:substitutable? #f #:properties `((type . profile-hook) (hook . efi-bootloader-profile-hook)))) (profile (content (packages->manifest packages)) (name "efi-bootloader-profile") (hooks (cons efi-bootloader-profile-hook hooks)) (locales? #f) (allow-collisions? #f) (relative-symlinks? #f))) (define* (efi-bootloader-chain final-bootloader #:key (packages '()) (files '()) (hooks '()) installer disk-image-installer) "Define a chain of bootloaders with the FINAL-BOOTLOADER, optional PACKAGES, and optional directories and files from the store given in the list of FILES. The package of the FINAL-BOOTLOADER and all PACKAGES and FILES will be placed in an efi-bootloader-profile, which will be passed to the INSTALLER. FILES may contain file-like objects produced by procedures like plain-file, local-file, etc., or package contents produced with file-append. If a directory name in FILES ends with '/', then the directory content instead of the directory itself will be symlinked into the efi-bootloader-profile. The procedures in the HOOKS list can be used to further modify the bootloader profile. It is possible to pass a single function instead of a list. If the INSTALLER argument is used, then this gexp procedure will be called to install the efi-bootloader-profile. Otherwise the installer of the FINAL-BOOTLOADER will be called. If the DISK-IMAGE-INSTALLER is used, then this gexp procedure will be called to install the efi-bootloader-profile into a disk image. Otherwise the disk-image-installer of the FINAL-BOOTLOADER will be called." (bootloader (inherit final-bootloader) (name "efi-bootloader-chain") (package (efi-bootloader-profile (cons (bootloader-package final-bootloader) packages) files (if (list? hooks) hooks (list hooks)))) (installer (or installer (bootloader-installer final-bootloader))) (disk-image-installer (or disk-image-installer (bootloader-disk-image-installer final-bootloader)))))