1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-07-15 03:24:06 +02:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Mathieu Othacehe 8d84a9ee71 ci: Add missing include.
* gnu/ci.scm: Add missing include.
2021-06-14 10:13:40 +02:00
Mathieu Othacehe c13ad2b889 ci: Backport package-channels procedure.
* gnu/ci.scm (package-channels): New procedure.
2021-06-14 10:08:49 +02:00
Mathieu Othacehe 7546a1d3c0 ci: Backport sexp->channel procedure.
* gnu/ci.scm (sexp->channel): New procedure.
2021-06-14 09:09:25 +02:00
Mathieu Othacehe 1b0bfb5df1 ci: Update to the last version.
* gnu/ci.scm: Update to the master version.
2021-06-14 09:03:26 +02:00
Maxim Cournoyer 8603bcd582 doc: Remove the guile-lib/htmlprag-fixed package.
This hotfix package is no longer necessary as the ability to parameterize the
way htmlprag tokenizes HTML was added in guile-lib 0.2.7.

* doc/build.scm (guile-lib/htmlprag-fixed): Remove variable.
(html-manual-identifier-index): Replace guile-lib/htmlprag-fixed by guile-lib,
and make set the %strict-tokenizer? parameter to #t.
(syntax-highlighted-html): Likewise.
2021-04-02 11:09:06 +02:00
Holger Peters f350df405f doc: Fix incorrect GUIX_PROFILE value for 'guix pull'.
* doc/guix.texi (Getting Started): Fix invalid GUIX_PROFILE value.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-12-07 15:08:51 +01:00
Ludovic Courtès 91bcb1d043 nls: Update 'fr' translation of the manual. 2020-12-03 16:39:12 +01:00
1837 changed files with 315322 additions and 1510248 deletions
-12
View File
@@ -52,16 +52,11 @@
(eval . (put 'test-equal 'scheme-indent-function 1))
(eval . (put 'test-eq 'scheme-indent-function 1))
(eval . (put 'call-with-input-string 'scheme-indent-function 1))
(eval . (put 'call-with-port 'scheme-indent-function 1))
(eval . (put 'guard 'scheme-indent-function 1))
(eval . (put 'lambda* 'scheme-indent-function 1))
(eval . (put 'substitute* 'scheme-indent-function 1))
(eval . (put 'match-record 'scheme-indent-function 2))
;; 'modify-inputs' and its keywords.
(eval . (put 'modify-inputs 'scheme-indent-function 1))
(eval . (put 'replace 'scheme-indent-function 1))
;; 'modify-phases' and its keywords.
(eval . (put 'modify-phases 'scheme-indent-function 1))
(eval . (put 'replace 'scheme-indent-function 1))
@@ -80,7 +75,6 @@
(eval . (put 'origin 'scheme-indent-function 0))
(eval . (put 'build-system 'scheme-indent-function 0))
(eval . (put 'bag 'scheme-indent-function 0))
(eval . (put 'gexp->derivation 'scheme-indent-function 1))
(eval . (put 'graft 'scheme-indent-function 0))
(eval . (put 'operating-system 'scheme-indent-function 0))
(eval . (put 'file-system 'scheme-indent-function 0))
@@ -125,10 +119,8 @@
(eval . (put 'with-extensions 'scheme-indent-function 1))
(eval . (put 'with-parameters 'scheme-indent-function 1))
(eval . (put 'let-system 'scheme-indent-function 1))
(eval . (put 'with-build-variables 'scheme-indent-function 2))
(eval . (put 'with-database 'scheme-indent-function 2))
(eval . (put 'call-with-database 'scheme-indent-function 1))
(eval . (put 'call-with-transaction 'scheme-indent-function 1))
(eval . (put 'with-statement 'scheme-indent-function 3))
(eval . (put 'call-with-retrying-transaction 'scheme-indent-function 1))
@@ -147,10 +139,6 @@
(eval . (put 'with-paginated-output-port 'scheme-indent-function 1))
(eval . (put 'with-shepherd-action 'scheme-indent-function 3))
(eval . (put 'with-http-server 'scheme-indent-function 1))
;; This notably allows '(' in Paredit to not insert a space when the
;; preceding symbol is one of these.
(eval . (modify-syntax-entry ?~ "'"))
-3
View File
@@ -1,3 +0,0 @@
*.scm diff=scheme
*.scm.in diff=scheme
*.texi diff=texinfo
+2 -9
View File
@@ -1,7 +1,6 @@
*.eps
*.go
*.log
*.mo
*.pdf
*.png
*.tar.xz
@@ -74,10 +73,9 @@
/etc/guix-daemon.service
/etc/guix-publish.conf
/etc/guix-publish.service
/etc/guix-gc.service
/etc/init.d/guix-daemon
/etc/openrc/guix-daemon
/guix-*
/guix-daemon
/guix/config.scm
/libformat.a
/libstore.a
@@ -95,7 +93,6 @@
/nix/config.h
/nix/config.h.in
/po/doc/*.mo
/po/doc/*.pot
/po/guix/*.gmo
/po/guix/*.insert-header
/po/guix/*.mo
@@ -131,9 +128,7 @@
/po/packages/remove-potcdate.sin
/po/packages/stamp-po
/pre-inst-env
/release-*
/scripts/guix
/t-*/
/test-env
/test-tmp
/tests/*.trs
@@ -145,15 +140,13 @@ Makefile
Makefile.in
config.cache
stamp-h[0-9]
.am[0-9]*/
.dirstamp
.deps
tmp
/doc/os-config-lightweight-desktop.texi
/nix/scripts/download
/.tarball-version
/.version
/doc/stamp-*
/doc/stamp-[0-9]
/gnu/packages/bootstrap
/gnu/packages/aux-files/guile-guile-launcher.o
/guile
+50 -14
View File
@@ -6,6 +6,10 @@
(("AD17 A21E F8AE D8F1 CC02 DBD9 F7D5 C9BF 765C 61E3"
(name "andreas"))
("2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5"
(name "ajgrf"))
("306F CB8F 2C01 C25D 29D3 0556 61EF 502E F602 52F2"
(name "alexvong1995"))
("4FB9 9F49 2B12 A365 7997 E664 8246 0C08 2A0E E98F"
(name "alezost"))
("50F3 3E2E 5B0C 3D90 0424 ABE8 9BDC F497 A4BB CC7F"
@@ -14,9 +18,23 @@
(name "apteryx"))
("7F73 0343 F2F0 9F3C 77BF 79D3 2E25 EE8B 6180 2BB3"
(name "arunisaac"))
(;; primary: "3B12 9196 AE30 0C3C 0E90 A26F A715 5567 3271 9948"
"9A2B 401E D001 0650 1584 BAAC 8BC4 F447 6E8A 8E00"
(name "atheia"))
(;; primary: "BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103"
"39B3 3C8D 9448 0D2D DCC2 A498 8B44 A0CD C7B9 56F2"
(name "bandali"))
(;; primary: "34FF 38BC D151 25A6 E340 A0B5 3453 2F9F AFCA 8B8E"
"A3A4 B419 0074 087C A7DE 5698 BC45 CA67 E2F8 D007"
"A0C5 E352 2EF8 EF5C 64CD B7F0 FD73 CAC7 19D3 2566"
(name "bavier"))
("BCF8 F737 2CED 080A 67EB 592D 2A6A D9F4 AAC2 0DF6"
(name "benwoodcroft"))
("45CC 63B8 5258 C9D5 5F34 B239 D37D 0EA7 CECC 3912"
(name "biscuolo"))
("7988 3B9F 7D6A 4DBF 3719 0367 2506 A96C CF63 0B21"
(name "boskovits"))
("E82A C026 95D6 FF02 43CA 1E5C F6C5 2DD1 BA27 CB87"
(name "brettgilio"))
(;; primary: "8929 BBC5 73CD 9206 3DDD 979D 3D36 CAA0 116F 0F99"
"1C9B F005 1A1A 6A44 5257 599A A949 03A1 66A1 8FAE"
(name "bricewge"))
@@ -36,6 +54,8 @@
(name "davexunit"))
("8CCB A7F5 52B9 CBEA E1FB 2915 8328 C747 0FF1 D807" ;FIXME: to be confirmed!
(name "davexunit (2nd)"))
("53C4 1E6E 41AA FE55 335A CA5E 446A 2ED4 D940 BF14"
(name "daviwil"))
("A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351"
(name "efraim"))
(;; primary: "2453 02B1 BAB1 F867 FDCA 96BC 8F3F 861F 82EB 7A9A"
@@ -45,6 +65,8 @@
(name "hoebjo"))
("B943 509D 633E 80DD 27FC 4EED 634A 8DFF D3F6 31DF"
(name "htgoebel"))
("7440 26BA 7CA3 C668 E940 1D53 0B43 1E98 3705 6942"
(name "ipetkov"))
(;; primary: "66A5 6D9C 9A98 BE7F 719A B401 2652 5665 AE72 7D37"
"0325 78A6 8298 94E7 2AA2 66F5 D415 BF25 3B51 5976"
(name "iyzsong"))
@@ -53,25 +75,23 @@
(;; primary: "1BA4 08C5 8BF2 0EA7 3179 635A 865D C0A3 DED9 B5D0"
"E31D 9DDE EBA5 4A14 8A20 4550 DA45 97F9 47B4 1025"
(name "jlicht"))
("8141 6036 E81A 5CF7 8F80 1071 ECFC 8398 8B4E 4B9F"
(name "jonsger"))
("017D 74E2 7F58 5696 3801 781D F663 943E 08D8 092A"
(name "lbraun"))
("CA4F 8CF4 37D7 478F DA05 5FD4 4213 7701 1A37 8446"
(name "lbraun (professional)"))
("ACC2 3BA0 59F7 CCF4 08F0 43AD 442A 84B8 C70E 2F87"
(name "lilyp"))
("83B6 703A DCCA 3B69 4BCE 2DA6 E6A5 EE3C 1946 7A0D"
(name "kkebreau"))
("45E5 75FA 53EA 8BD6 1BCE 0B4E 3ADC 75F0 13D6 78F9"
(name "leungbk"))
(;; primary: "4F71 6F9A 8FA2 C80E F1B5 E1BA 5E35 F231 DE1A C5E0"
"B051 5948 F1E7 D3C1 B980 38A0 2646 FA30 BACA 7F08"
(name "lfam"))
("2AE3 1395 932B E642 FC0E D99C 9BED 6EDA 32E5 B0BC"
(name "lsl88"))
("8887 84C4 1459 ACCB 83E7 E84C 634C 6E89 79FA BEC2"
(name "m1gu3l"))
("CBF5 9755 CBE7 E7EF EF18 3FB1 DD40 9A15 D822 469D"
(name "marusich"))
("BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"
(name "mbakke"))
("D919 0965 CE03 199E AF28 B3BE 7CEF 2984 7562 C516"
(name "mhw"))
("B845 5B7F FAD5 E8E9 5DEF 4296 637B 0B13 8065 B68A"
(name "monego"))
("4008 6A7E 0252 9B60 31FB 8607 8354 7635 3176 9CA6"
(name "mothacehe"))
(;; primary: "F5BC 5534 C36F 0087 B39D 36EF 1C9D C4FE B9DB 7C4B"
@@ -89,10 +109,14 @@
(;; primary: "B68B DF22 73F9 DA0E 63C1 8A32 515B F416 9242 D600"
"C699 ED09 E51B CE89 FD1D A078 AAC7 E891 896B 568A"
(name "pgarlick"))
("CD2D 5EAA A98C CB37 DA91 D6B0 5F58 1664 7F8B E551"
(name "raghavgururajan"))
("3A86 380E 58A8 B942 8D39 60E1 327C 1EF3 8DF5 4C32"
(name "phant0mas"))
("74D6 A930 F44B 9B84 9EA5 5606 C166 AA49 5F7F 189C"
(name "reepca"))
("BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC"
(name "rekado"))
("0154 E1B9 1CC9 D9EF 7764 8DE7 F3A7 27DB 44FC CA36"
(name "rhelling"))
(;; From commit cc51c03ff867d4633505354819c6d88af88bf919 (March 2020).
;; See <https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00070.html>.
"F556 FD94 FB8F 8B87 79E3 6832 CBD0 CD51 38C1 9AFC"
@@ -104,10 +128,22 @@
(;; primary: "D6B0 C593 DA8C 5EDC A44C 7A58 C336 91F7 1188 B004"
"A02C 2D82 0EF4 B25B A6B5 1D90 2AC6 A5EC 1C35 7C59"
(name "samplet"))
("77DD AD2D 97F5 31BB C0F3 C7FD DFB5 EB09 AA62 5423"
(name "sleep_walker"))
("F494 72F4 7A59 00D5 C235 F212 89F9 6D48 08F3 59C7"
(name "snape"))
("9ADE 9ECF 2B19 C180 9C99 5CEA A1F4 CFCC 5283 6BAC"
(name "taylanub"))
;; https://lists.gnu.org/archive/html/guix-devel/2017-03/msg00826.html
(;; primary: "1DD1 681F E285 E07F 11DC 0C59 2E15 A6BC D77D 54FD"
"3D2C DA58 819C 08C2 A649 D43D 5C3B 064C 724A 5726"
(name "thomasd"))
("6580 7361 3BFC C5C7 E2E4 5D45 DC51 8FC8 7F97 16AA"
(name "vagrantc"))
(;; primary: "C955 CC5D C048 7FB1 7966 40A9 199A F6A3 67E9 4ABB"
"7238 7123 8EAC EB63 4548 5857 167F 8EA5 001A FA9C"
(name "wigust"))))
(name "wigust"))
("FF47 8FB2 64DE 32EC 2967 25A3 DDC0 F535 8812 F8F2"
(name "wingo"))))
+4 -12
View File
@@ -15,7 +15,6 @@ Ben Woodcroft <donttrustben@gmail.com>
Ben Woodcroft <donttrustben@gmail.com> <b.woodcroft@uq.edu.au>
Ben Woodcroft <donttrustben@gmail.com> <donttrustben near gmail.com>
Brett Gilio <brettg@gnu.org> <brettg@posteo.net>
Christine Lemmer-Webber <cwebber@dustycloud.org>
Claes Wallin (韋嘉誠) <claes.wallin@greatsinodevelopment.com>
Cyprien Nicolas <cyprien@nicolas.tf> <c.nicolas+gitorious@gmail.com>
Daniel Pimentel <d4n1@d4n1.org> <d4n1@member.fsf.org>
@@ -25,8 +24,8 @@ David Thompson <davet@gnu.org> <dthompson2@worcester.edu>
David Thompson <davet@gnu.org> <dthompson@member.fsf.org>
David Thompson <davet@gnu.org> <dthompson@vistahigherlearning.com>
Deck Pickard <deck.r.pickard@gmail.com> <nebu@kipple>
Eric Bavier <bavier@posteo.net> <ericbavier@gmail.com>
Eric Bavier <bavier@posteo.net> <bavier@member.fsf.org>
Eric Bavier <bavier@member.fsf.org> <ericbavier@gmail.com>
Eric Bavier <bavier@member.fsf.org> <bavier@posteo.net>
Eric Dvorsak <eric@dvorsak.fr> <yenda1@gmail.com>
George Clemmer <myglc2@gmail.com>
ison <ison@airmail.cc> <ison111@protonmail.com>
@@ -39,22 +38,16 @@ Joshua Grant <tadni@riseup.net> <gzg@riseup.net>
Joshua Grant <tadni@riseup.net> <jgrant@parenthetical.io>
Joshua Grant <tadni@riseup.net> <tadnimi@gmail.com>
Joshua Grant <tadni@riseup.net> <youlysses@riseup.net>
Kei Kebreau <kkebreau@posteo.net>
Kei Kebreau <kei@openmailbox.org> <kkebreau@posteo.net>
Leo Famulari <leo@famulari.name> <lfamular@gmail.com>
Liliana Marie Prikler <liliana.prikler@gmail.com>
Liliana Marie Prikler <liliana.prikler@gmail.com> Leo Prikler <leo.prikler@student.tugraz.at>
Ludovic Courtès <ludo@gnu.org> <ludovic.courtes@inria.fr>
Marek Benc <dusxmt@gmx.com> <merkur32@gmail.com>
Marius Bakke <marius@gnu.org> <mbakke@fastmail.com>
Marius Bakke <marius@gnu.org> <m.bakke@warwick.ac.uk>
Marius Bakke <marius@gnu.org> <marius.bakke@usit.uio.no>
Marius Bakke <marius@gnu.org> <mbakke@berlin.guixsd.org>
Marius Bakke <mbakke@fastmail.com> <m.bakke@warwick.ac.uk>
Mathieu Lirzin <mthl@gnu.org> <mthl@openmailbox.org>
Mathieu Lirzin <mthl@gnu.org> <mathieu.lirzin@openmailbox.org>
Mathieu Othacehe <m.othacehe@gmail.com>
Mathieu Othacehe <mathieu.othacehe@parrot.com>
Mathieu Othacehe <othacehe@gnu.org>
Matthew James Kraai <kraai@ftbfs.org>
Nikita Karetnikov <nikita@karetnikov.org> <nikita.karetnikov@gmail.com>
nikita <nikita@n0.is>
nikita <nikita@n0.is> ng0 <ng0@n0.is>
@@ -91,4 +84,3 @@ Thomas Danckaert <thomas.danckaert@gmail.com> <post@thomasdanckaert.be>
Tobias Geerinckx-Rice <me@tobias.gr> <tobias.geerinckx.rice@gmail.com>
Tomáš Čech <sleep_walker@gnu.org> <sleep_walker@suse.cz>
Vincent Legoll <vincent.legoll@gmail.com> <vincent.legoll@idgrilles.fr>
Zheng Junjie <873216071@qq.com> Z572 <873216071@qq.com>
+66 -91
View File
@@ -1,103 +1,78 @@
Important: to avoid polarizing/hurtful discussions in our public spaces, any
matter pertaining to our use of this Code of Conduct should be brought
privately to the Guix maintainers at guix-maintainers@gnu.org. Failure to do
so will be considered as a violation of this Code of Conduct.
Contributor Covenant Code of Conduct
Note: In the sequel, "project" refers to GNU Guix, and "project
maintainer(s)" refers to maintainer(s) of GNU Guix.
Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
Examples of behavior that contributes to creating a positive environment
include:
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others private information, such as a physical or email address,
without their explicit permission
* Publishing others private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
guix-maintainers@gnu.org.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
1. Correction
Community Impact: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
2. Warning
Community Impact: A violation through a single incident or series of
actions.
Consequence: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
3. Temporary Ban
Community Impact: A serious violation of community standards, including
sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
4. Permanent Ban
Community Impact: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the
community.
Attribution
This Code of Conduct is adapted from the Contributor Covenant,
version 2.1, available at
https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
Community Impact Guidelines were inspired by
Mozillas code of conduct enforcement ladder.
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at guix-maintainers@gnu.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the projects leadership.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+107 -208
View File
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
# Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Andreas Enge <andreas@enge.fr>
# Copyright © 2015, 2017 Alex Kost <alezost@gmail.com>
# Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
@@ -14,8 +14,6 @@
# Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
# Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
# Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
# Copyright © 2021 Andrew Tropin <andrew@trop.in>
#
# This file is part of GNU Guix.
#
@@ -41,7 +39,6 @@ do_subst = $(SED) \
-e 's,[@]GUILE[@],$(GUILE),g' \
-e 's,[@]guilemoduledir[@],$(guilemoduledir),g' \
-e 's,[@]guileobjectdir[@],$(guileobjectdir),g' \
-e 's,[@]abs_top_builddir[@],$(abs_top_builddir),g' \
-e 's,[@]localedir[@],$(localedir),g'
scripts/guix: scripts/guix.in Makefile
@@ -81,7 +78,6 @@ MODULES = \
guix/base64.scm \
guix/ci.scm \
guix/cpio.scm \
guix/cpu.scm \
guix/deprecation.scm \
guix/docker.scm \
guix/records.scm \
@@ -97,10 +93,8 @@ MODULES = \
guix/discovery.scm \
guix/android-repo-download.scm \
guix/bzr-download.scm \
guix/extracting-download.scm \
guix/git-download.scm \
guix/hg-download.scm \
guix/hash.scm \
guix/swh.scm \
guix/monads.scm \
guix/monad-repl.scm \
@@ -108,7 +102,6 @@ MODULES = \
guix/profiles.scm \
guix/serialization.scm \
guix/nar.scm \
guix/narinfo.scm \
guix/derivations.scm \
guix/grafts.scm \
guix/repl.scm \
@@ -119,7 +112,6 @@ MODULES = \
guix/channels.scm \
guix/gnu-maintenance.scm \
guix/self.scm \
guix/substitutes.scm \
guix/upstream.scm \
guix/licenses.scm \
guix/lint.scm \
@@ -130,12 +122,10 @@ MODULES = \
guix/cache.scm \
guix/cve.scm \
guix/workers.scm \
guix/ipfs.scm \
guix/build-system.scm \
guix/build-system/android-ndk.scm \
guix/build-system/ant.scm \
guix/build-system/cargo.scm \
guix/build-system/chicken.scm \
guix/build-system/clojure.scm \
guix/build-system/cmake.scm \
guix/build-system/dub.scm \
@@ -144,9 +134,7 @@ MODULES = \
guix/build-system/font.scm \
guix/build-system/go.scm \
guix/build-system/meson.scm \
guix/build-system/mozilla.scm \
guix/build-system/minify.scm \
guix/build-system/minetest.scm \
guix/build-system/asdf.scm \
guix/build-system/copy.scm \
guix/build-system/glib-or-gtk.scm \
@@ -159,7 +147,6 @@ MODULES = \
guix/build-system/node.scm \
guix/build-system/perl.scm \
guix/build-system/python.scm \
guix/build-system/renpy.scm \
guix/build-system/ocaml.scm \
guix/build-system/qt.scm \
guix/build-system/waf.scm \
@@ -188,7 +175,6 @@ MODULES = \
guix/build/download-nar.scm \
guix/build/cargo-build-system.scm \
guix/build/cargo-utils.scm \
guix/build/chicken-build-system.scm \
guix/build/cmake-build-system.scm \
guix/build/dub-build-system.scm \
guix/build/dune-build-system.scm \
@@ -209,14 +195,12 @@ MODULES = \
guix/build/gnu-dist.scm \
guix/build/guile-build-system.scm \
guix/build/maven-build-system.scm \
guix/build/minetest-build-system.scm \
guix/build/node-build-system.scm \
guix/build/perl-build-system.scm \
guix/build/python-build-system.scm \
guix/build/ocaml-build-system.scm \
guix/build/qt-build-system.scm \
guix/build/r-build-system.scm \
guix/build/renpy-build-system.scm \
guix/build/rakudo-build-system.scm \
guix/build/ruby-build-system.scm \
guix/build/scons-build-system.scm \
@@ -227,11 +211,11 @@ MODULES = \
guix/build/linux-module-build-system.scm \
guix/build/store-copy.scm \
guix/build/json.scm \
guix/build/pack.scm \
guix/build/utils.scm \
guix/build/union.scm \
guix/build/profiles.scm \
guix/build/compile.scm \
guix/build/rpath.scm \
guix/build/cvs.scm \
guix/build/svn.scm \
guix/build/syscalls.scm \
@@ -242,7 +226,6 @@ MODULES = \
guix/build/emacs-utils.scm \
guix/build/java-utils.scm \
guix/build/lisp-utils.scm \
guix/build/meson-configuration.scm \
guix/build/maven/java.scm \
guix/build/maven/plugin.scm \
guix/build/maven/pom.scm \
@@ -256,22 +239,19 @@ MODULES = \
guix/import/cpan.scm \
guix/import/cran.scm \
guix/import/crate.scm \
guix/import/egg.scm \
guix/import/elpa.scm \
guix/import/gem.scm \
guix/import/git.scm \
guix/import/github.scm \
guix/import/gnome.scm \
guix/import/gnu.scm \
guix/import/go.scm \
guix/import/hackage.scm \
guix/import/json.scm \
guix/import/kde.scm \
guix/import/launchpad.scm \
guix/import/minetest.scm \
guix/import/opam.scm \
guix/import/print.scm \
guix/import/pypi.scm \
guix/import/snix.scm \
guix/import/stackage.scm \
guix/import/texlive.scm \
guix/import/utils.scm \
@@ -297,30 +277,24 @@ MODULES = \
guix/scripts/refresh.scm \
guix/scripts/repl.scm \
guix/scripts/describe.scm \
guix/scripts/style.scm \
guix/scripts/system.scm \
guix/scripts/system/search.scm \
guix/scripts/system/reconfigure.scm \
guix/scripts/home.scm \
guix/scripts/home/import.scm \
guix/scripts/lint.scm \
guix/scripts/challenge.scm \
guix/scripts/import/crate.scm \
guix/scripts/import/cran.scm \
guix/scripts/import/egg.scm \
guix/scripts/import/elpa.scm \
guix/scripts/import/gem.scm \
guix/scripts/import/gnu.scm \
guix/scripts/import/go.scm \
guix/scripts/import/hackage.scm \
guix/scripts/import/json.scm \
guix/scripts/import/minetest.scm \
guix/scripts/import/nix.scm \
guix/scripts/import/opam.scm \
guix/scripts/import/pypi.scm \
guix/scripts/import/stackage.scm \
guix/scripts/import/texlive.scm \
guix/scripts/environment.scm \
guix/scripts/shell.scm \
guix/scripts/publish.scm \
guix/scripts/edit.scm \
guix/scripts/size.scm \
@@ -345,14 +319,6 @@ MODULES += \
endif HAVE_GUILE_SSH
if HAVE_GUILE_AVAHI
MODULES += \
guix/avahi.scm \
guix/scripts/discover.scm
endif HAVE_GUILE_AVAHI
if BUILD_DAEMON_OFFLOAD
MODULES += \
@@ -379,19 +345,10 @@ dist_noinst_DATA = \
AUX_FILES = \
gnu/packages/aux-files/chromium/master-preferences.json \
gnu/packages/aux-files/emacs/guix-emacs.el \
gnu/packages/aux-files/guix.vim \
gnu/packages/aux-files/linux-libre/5.16-arm.conf \
gnu/packages/aux-files/linux-libre/5.16-arm64.conf \
gnu/packages/aux-files/linux-libre/5.16-i686.conf \
gnu/packages/aux-files/linux-libre/5.16-x86_64.conf \
gnu/packages/aux-files/linux-libre/5.15-arm.conf \
gnu/packages/aux-files/linux-libre/5.15-arm64.conf \
gnu/packages/aux-files/linux-libre/5.15-i686.conf \
gnu/packages/aux-files/linux-libre/5.15-x86_64.conf \
gnu/packages/aux-files/linux-libre/5.10-arm.conf \
gnu/packages/aux-files/linux-libre/5.10-arm64.conf \
gnu/packages/aux-files/linux-libre/5.10-i686.conf \
gnu/packages/aux-files/linux-libre/5.10-x86_64.conf \
gnu/packages/aux-files/linux-libre/5.9-arm.conf \
gnu/packages/aux-files/linux-libre/5.9-arm64.conf \
gnu/packages/aux-files/linux-libre/5.9-i686.conf \
gnu/packages/aux-files/linux-libre/5.9-x86_64.conf \
gnu/packages/aux-files/linux-libre/5.4-arm.conf \
gnu/packages/aux-files/linux-libre/5.4-arm64.conf \
gnu/packages/aux-files/linux-libre/5.4-i686.conf \
@@ -408,9 +365,6 @@ AUX_FILES = \
gnu/packages/aux-files/linux-libre/4.4-i686.conf \
gnu/packages/aux-files/linux-libre/4.4-x86_64.conf \
gnu/packages/aux-files/pack-audit.c \
gnu/packages/aux-files/python/sanity-check.py \
gnu/packages/aux-files/python/sitecustomize.py \
gnu/packages/aux-files/renpy/renpy.in \
gnu/packages/aux-files/run-in-namespace.c
# Templates, examples.
@@ -427,8 +381,6 @@ EXAMPLES = \
GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go)
nobase_dist_guilemodule_DATA = \
guix/d3.v3.js \
guix/graph.js \
guix/store/schema.sql \
$(MODULES) $(MODULES_NOT_COMPILED) $(AUX_FILES) $(EXAMPLES) \
$(MISC_DISTRO_FILES)
@@ -473,7 +425,6 @@ SCM_TESTS = \
tests/debug-link.scm \
tests/derivations.scm \
tests/discovery.scm \
tests/egg.scm \
tests/elpa.scm \
tests/file-systems.scm \
tests/gem.scm \
@@ -486,18 +437,14 @@ SCM_TESTS = \
tests/graph.scm \
tests/gremlin.scm \
tests/hackage.scm \
tests/home-import.scm \
tests/http-client.scm \
tests/import-git.scm \
tests/import-github.scm \
tests/import-utils.scm \
tests/inferior.scm \
tests/lint.scm \
tests/minetest.scm \
tests/modules.scm \
tests/monads.scm \
tests/nar.scm \
tests/networking.scm \
tests/offload.scm \
tests/opam.scm \
tests/openpgp.scm \
tests/packages.scm \
@@ -512,12 +459,10 @@ SCM_TESTS = \
tests/scripts.scm \
tests/search-paths.scm \
tests/services.scm \
tests/services/file-sharing.scm \
tests/services/configuration.scm \
tests/services/linux.scm \
tests/services/telephony.scm \
tests/sets.scm \
tests/size.scm \
tests/snix.scm \
tests/status.scm \
tests/store-database.scm \
tests/store-deduplication.scm \
@@ -527,7 +472,6 @@ SCM_TESTS = \
tests/swh.scm \
tests/syscalls.scm \
tests/system.scm \
tests/style.scm \
tests/texlive.scm \
tests/transformations.scm \
tests/ui.scm \
@@ -537,18 +481,6 @@ SCM_TESTS = \
tests/uuid.scm \
tests/workers.scm
if HAVE_GUILE_LIB
SCM_TESTS += tests/go.scm
else
EXTRA_DIST += tests/go.scm
endif
if BUILD_DAEMON_OFFLOAD
SCM_TESTS += tests/offload.scm
else
EXTRA_DIST += tests/offload.scm
endif
SH_TESTS = \
tests/guix-build.sh \
tests/guix-build-branch.sh \
@@ -563,12 +495,10 @@ SH_TESTS = \
tests/guix-package-aliases.sh \
tests/guix-package-net.sh \
tests/guix-system.sh \
tests/guix-home.sh \
tests/guix-archive.sh \
tests/guix-authenticate.sh \
tests/guix-environment.sh \
tests/guix-environment-container.sh \
tests/guix-shell.sh \
tests/guix-graph.sh \
tests/guix-describe.sh \
tests/guix-repl.sh \
@@ -619,8 +549,7 @@ check-system: $(GOBJECTS)
dist_pkgdata_DATA = \
etc/substitutes/berlin.guix.gnu.org.pub \
etc/substitutes/ci.guix.gnu.org.pub \
etc/substitutes/ci.guix.info.pub \
etc/substitutes/bordeaux.guix.gnu.org.pub
etc/substitutes/ci.guix.info.pub
# Bash completion file.
dist_bashcompletion_DATA = etc/completion/bash/guix \
@@ -644,37 +573,41 @@ EXTRA_DIST += \
.guix-authorizations \
.guix-channel \
scripts/guix.in \
etc/disarchive-manifest.scm \
etc/guix-install.sh \
etc/news.scm \
etc/release-manifest.scm \
etc/source-manifest.scm \
etc/system-tests.scm \
etc/historical-authorizations \
build-aux/build-self.scm \
build-aux/compile-all.scm \
build-aux/hydra/evaluate.scm \
build-aux/hydra/gnu-system.scm \
build-aux/hydra/guix.scm \
build-aux/hydra/guix-modular.scm \
build-aux/cuirass/gnu-system.scm \
build-aux/cuirass/guix-modular.scm \
build-aux/cuirass/hurd-manifest.scm \
build-aux/cuirass/hydra-to-cuirass.scm \
build-aux/check-final-inputs-self-contained.scm \
build-aux/check-channel-news.scm \
build-aux/compile-as-derivation.scm \
build-aux/convert-xref.scm \
build-aux/generate-authors.scm \
build-aux/test-driver.scm \
build-aux/update-guix-package.scm \
build-aux/update-NEWS.scm \
d3.v3.js \
graph.js \
tests/test.drv \
tests/signing-key.pub \
tests/signing-key.sec \
tests/cve-sample.json \
tests/keys/signing-key.pub \
tests/keys/signing-key.sec \
tests/keys/civodul.pub \
tests/keys/rsa.pub \
tests/keys/dsa.pub \
tests/keys/ed25519.pub \
tests/keys/ed25519.sec \
tests/keys/ed25519-2.pub \
tests/keys/ed25519-2.sec \
tests/keys/ed25519-3.pub \
tests/keys/ed25519-3.sec \
tests/civodul.key \
tests/rsa.key \
tests/dsa.key \
tests/ed25519.key \
tests/ed25519.sec \
tests/ed25519bis.key \
tests/ed25519bis.sec \
build-aux/config.rpath \
bootstrap \
doc/build.scm \
@@ -701,60 +634,15 @@ CLEANFILES = \
# the whole thing. Likewise, set 'XDG_CACHE_HOME' to avoid loading possibly
# stale files from ~/.cache/guile/ccache.
%.go: make-go ; @:
make-go: make-core-go make-packages-go make-system-go make-cli-go
# Define a rule to build a subset of the .go files.
define guile-compilation-rule
$(1): $(2)
$(AM_V_at)echo "Compiling Scheme modules..." ; \
unset GUILE_LOAD_COMPILED_PATH ; \
XDG_CACHE_HOME=/nowhere \
host=$(host) srcdir="$(top_srcdir)" \
$(top_builddir)/pre-inst-env \
$(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)" \
--no-auto-compile \
-s "$(top_srcdir)"/build-aux/compile-all.scm \
--total $(words $(MODULES)) \
--completed $(3) \
$$(filter %.scm,$$^)
endef
# Split compilation in several steps, each of which building a subset of
# $(MODULES). The main goal is to reduce peak memory consumption, as reported
# in <https://issues.guix.gnu.org/48963>. Each 'eval' call below creates a
# 'make-*-go' phony target that builds the corresponding subset.
MODULES_CORE = guix.scm $(filter-out guix/scripts/%,$(filter guix/%,$(MODULES)))
MODULES_PACKAGES = $(filter gnu/packages/%,$(MODULES))
MODULES_SYSTEM = gnu.scm $(filter-out gnu/packages/%,$(filter gnu/%,$(MODULES)))
MODULES_CLI = $(filter guix/scripts/%,$(MODULES))
MODULES_PO = guix/build/po.scm
$(eval $(call guile-compilation-rule,make-core-go, \
$(MODULES_CORE) guix/config.scm $(dist_noinst_DATA), \
0))
.PHONY: make-core-go
$(eval $(call guile-compilation-rule,make-packages-go, \
$(MODULES_PACKAGES) make-core-go, \
$(words $(MODULES_CORE))))
.PHONY: make-packages-go
$(eval $(call guile-compilation-rule,make-system-go, \
$(MODULES_SYSTEM) make-packages-go make-core-go, \
$(words $(MODULES_CORE) $(MODULES_PACKAGES))))
.PHONY: make-system-go
$(eval $(call guile-compilation-rule,make-cli-go, \
$(MODULES_CLI) make-system-go make-packages-go make-core-go, \
$(words $(MODULES_CORE) $(MODULES_PACKAGES) $(MODULES_SYSTEM))))
.PHONY: make-cli-go
$(eval $(call guile-compilation-rule,guix/build/po.go, \
$(MODULES_PO), \
0))
make-go: $(MODULES) guix/config.scm $(dist_noinst_DATA)
$(AM_V_at)echo "Compiling Scheme modules..." ; \
unset GUILE_LOAD_COMPILED_PATH ; \
XDG_CACHE_HOME=/nowhere \
host=$(host) srcdir="$(top_srcdir)" \
$(top_builddir)/pre-inst-env \
$(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)" \
--no-auto-compile \
-s "$(top_srcdir)"/build-aux/compile-all.scm $^
SUFFIXES = .go
@@ -818,25 +706,26 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--localstatedir="$$dc_install_base/var" \
--with-libgcrypt-prefix="$(LIBGCRYPT_PREFIX)" \
--with-libgcrypt-libdir="$(LIBGCRYPT_LIBDIR)" \
--with-nix-prefix="$(NIX_PREFIX)" \
--enable-daemon \
ac_cv_guix_test_root="$(GUIX_TEST_ROOT)"
# Name of the 'guix' package shipped in the binary tarball.
GUIX_FOR_BINARY_TARBALL = guix
# The self-contained tarball.
guix-binary.%.tar.xz:
$(AM_V_GEN)GUIX_PACKAGE_PATH= \
tarball=`$(top_builddir)/pre-inst-env guix pack -C xz \
--fallback \
-s "$*" --localstatedir --profile-name=current-guix \
guix` ; \
$(GUIX_FOR_BINARY_TARBALL)` ; \
cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"
# The dependency on doc-pot-update is to generate the .pot files, which are
# not checked in.
dist: doc-pot-update
dist-hook: gen-ChangeLog gen-AUTHORS gen-tarball-version
dist-hook: assert-no-store-file-names
dist-hook: doc-po-update
distcheck-hook: assert-binaries-available assert-final-inputs-self-contained
@@ -889,8 +778,7 @@ SOURCE_TARBALLS = \
$(foreach ext,tar.gz,$(PACKAGE_FULL_TARNAME).$(ext))
# Systems supported by Guix.
SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux armhf-linux aarch64-linux \
powerpc64le-linux
SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux armhf-linux aarch64-linux
# Guix binary tarballs.
BINARY_TARBALLS = \
@@ -917,20 +805,21 @@ system_flags = $(foreach system,$(1),-s $(system))
# The release process works in several phases:
#
# 0. We assume the developer created a 'vX.Y.Z' tag.
# 0. We assume the developer created a 'vX.Y' tag.
# 1. Build the source tarball.
# 2. Update the 'guix' package so that it corresponds to the 'vX.Y.Z' tag.
# 2. Update the 'guix' package so that it corresponds to the 'vX.Y' tag.
# 3. Build the binary tarballs for that 'guix' package.
# 4. Update the 'guix' package again.
# 5. Build the installation and VM images. The images will run 'guix'
# corresponding to 'vX.Y.Z' + 1 commit, and they will install 'vX.Y.Z'.
# 5. Build the installation images. The images will run 'guix'
# corresponding to 'vX.Y' + 1 commit, and they will install 'vX.Y'.
#
# This 'release' target takes care of everything and copies the resulting
# files to $(releasedir).
#
# XXX: Depend on 'dist' rather than 'distcheck' to work around the Gettext
# issue described at <https://savannah.gnu.org/bugs/index.php?51027>.
release: dist-with-updated-version all
release: dist-with-updated-version
cd po; git checkout .
@if ! git diff-index --quiet HEAD; then \
echo "There are uncommitted changes; stopping." >&2 ; \
exit 1 ; \
@@ -938,24 +827,21 @@ release: dist-with-updated-version all
$(MKDIR_P) "$(releasedir)"
rm -f "$(releasedir)"/*
mv $(SOURCE_TARBALLS) "$(releasedir)"
# Bump the Guix package version and build it.
GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT=yes \
$(top_builddir)/pre-inst-env "$(GUILE)" \
$(top_srcdir)/build-aux/update-guix-package.scm \
"`git rev-parse HEAD`" "$(PACKAGE_VERSION)"
git add $(top_srcdir)/gnu/packages/package-management.scm
git commit -m "gnu: guix: Update to $(PACKAGE_VERSION)."
$(top_builddir)/pre-inst-env guix build guix \
$(top_builddir)/pre-inst-env guix build $(GUIX_FOR_BINARY_TARBALL) \
$(call system_flags,$(SUPPORTED_SYSTEMS)) \
-v1 --no-grafts --fallback
# Generate the binary release tarballs.
rm -f $(BINARY_TARBALLS)
$(MAKE) $(BINARY_TARBALLS)
for system in $(SUPPORTED_SYSTEMS) ; do \
mv "guix-binary.$$system.tar.xz" \
"$(releasedir)/guix-binary-$(PACKAGE_VERSION).$$system.tar.xz" ; \
done
# Bump the Guix package version and build it (again).
GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT=yes \
$(top_builddir)/pre-inst-env "$(GUILE)" \
$(top_srcdir)/build-aux/update-guix-package.scm \
@@ -965,33 +851,33 @@ release: dist-with-updated-version all
$(top_builddir)/pre-inst-env guix build guix \
$(call system_flags,$(GUIX_SYSTEM_SUPPORTED_SYSTEMS)) \
-v1 --no-grafts --fallback
# Generate the ISO installation images.
for system in $(GUIX_SYSTEM_SUPPORTED_SYSTEMS) ; do \
image=`$(top_builddir)/pre-inst-env \
guix system image -t iso9660 \
guix system disk-image -t iso9660 \
--label="GUIX_$${system}_$(VERSION)" \
--system=$$system --fallback \
gnu/system/install.scm` ; \
if [ ! -f "$$image" ] ; then \
echo "failed to produce Guix installation image for $$system" >&2 ; \
echo "failed to produced Guix installation image for $$system" >&2 ; \
exit 1 ; \
fi ; \
cp "$$image" "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.tmp" ; \
mv "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.tmp" \
"$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso" ; \
xz < "$$image" > "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.xz.tmp" ; \
mv "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.xz.tmp" \
"$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.xz" ; \
done
# Generate the VM images.
for system in $(GUIX_SYSTEM_VM_SYSTEMS) ; do \
image=`$(top_builddir)/pre-inst-env \
guix system image -t qcow2 $(GUIX_SYSTEM_VM_IMAGE_FLAGS) \
guix system vm-image $(GUIX_SYSTEM_VM_IMAGE_FLAGS) \
--save-provenance \
--system=$$system --fallback \
gnu/system/examples/vm-image.tmpl` ; \
if [ ! -f "$$image" ] ; then \
echo "failed to produce Guix VM image for $$system" >&2 ; \
echo "failed to produced Guix VM image for $$system" >&2 ; \
exit 1 ; \
fi ; \
cp "$$image" "$(releasedir)/$(GUIX_SYSTEM_VM_IMAGE_BASE).$$system.qcow2"; \
xz < "$$image" > "$(releasedir)/$(GUIX_SYSTEM_VM_IMAGE_BASE).$$system.xz.tmp" ; \
mv "$(releasedir)/$(GUIX_SYSTEM_VM_IMAGE_BASE).$$system.xz.tmp" \
"$(releasedir)/$(GUIX_SYSTEM_VM_IMAGE_BASE).$$system.xz" ; \
done
@echo
@echo "Congratulations! All the release files are now in $(releasedir)."
@@ -1028,12 +914,10 @@ assert-no-store-file-names:
exit 1 ; \
fi
# Make sure important substitutes are available. Check only the primary
# server so that '--display-missing' doesn't print two lists.
# Make sure important substitutes are available.
assert-binaries-available: $(GOBJECTS)
$(AM_V_at)$(top_builddir)/pre-inst-env \
guix weather -m "$(top_srcdir)/etc/release-manifest.scm" \
--substitute-urls="https://ci.guix.gnu.org" \
--display-missing
# Make sure the final inputs don't refer to bootstrap tools.
@@ -1046,45 +930,60 @@ check-channel-news: $(GOBJECTS)
$(AM_V_at)$(top_builddir)/pre-inst-env "$(GUILE)" \
"$(top_srcdir)/build-aux/check-channel-news.scm"
# Compute the Cuirass jobs.
cuirass-jobs: $(GOBJECTS)
rm -rf "$@"
$(AM_V_at)$(MKDIR_P) "$@"
# Compute the Hydra jobs and write them in the target file.
hydra-jobs.scm: $(GOBJECTS)
$(AM_V_at)$(MKDIR_P) "`dirname "$@"`"
$(AM_V_GEN)$(top_builddir)/pre-inst-env "$(GUILE)" \
"$(top_srcdir)/build-aux/cuirass/evaluate.scm" "$@"
"$(top_srcdir)/build-aux/hydra/evaluate.scm" \
"$(top_srcdir)/build-aux/hydra/gnu-system.scm" > "$@.tmp"
$(AM_V_at)mv "$@.tmp" "$@"
# Compute the Cuirass jobs and write them in the target file.
cuirass-jobs.scm: $(GOBJECTS)
$(AM_V_at)$(MKDIR_P) "`dirname "$@"`"
$(AM_V_GEN)$(top_builddir)/pre-inst-env "$(GUILE)" \
"$(top_srcdir)/build-aux/hydra/evaluate.scm" \
"$(top_srcdir)/build-aux/cuirass/gnu-system.scm" \
cuirass > "$@.tmp"
$(AM_V_at)mv "$@.tmp" "$@"
.PHONY: gen-ChangeLog gen-AUTHORS gen-tarball-version
.PHONY: assert-no-store-file-names assert-binaries-available
.PHONY: assert-final-inputs-self-contained check-channel-news
.PHONY: clean-go make-go as-derivation authenticate
.PHONY: update-guix-package update-NEWS cuirass-jobs release
.PHONY: update-guix-package update-NEWS release
# Downloading up-to-date PO files.
WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations
# make-download-po-rule DOMAIN DIRECTORY [FILE-NAME-PREFIX]
define make-download-po-rule
# Shallow clone the Git repository behind Weblate and copy files from it if
# they contain at least one translation, and they are well-formed (Scheme
# format only), warn otherwise. Copied files are converted to a canonical
# form.
download-po:
dir=$$(mktemp -d); \
git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations"; \
for domain in po/doc po/guix po/packages; do \
for po in "$$dir/translations/$$domain"/*.po; do \
translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \
target=$$(basename "$$po"); \
target="$$domain/$$target"; \
if msgfmt -c "$$po" && [ "$$translated" != "0" ]; then \
msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \
mv "$$po".tmp "$$target"; \
echo "copied $$target."; \
else \
echo "WARN: $$target ($$translated translated messages) was not added/updated."; \
fi; \
done; \
done; \
rm -rf "$$dir"
download-po.$(1):
if [ -f "$(top_srcdir)/$(2)/LINGUAS" ]; then \
LINGUAS="`grep -v '^[[:blank:]]*#' < $(top_srcdir)/$(2)/LINGUAS`" ; \
else \
LINGUAS="`(cd $(top_srcdir)/$(2); \
for i in *.po; do echo $$$$i; done) | cut -d . -f 2`" ; \
fi ; \
for lang in $$$$LINGUAS; do \
if wget -nv -O "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" \
"https://translationproject.org/latest/$(1)/$$$$lang.po" ; \
then \
mv "$(top_srcdir)/$(2)/$(3)$$$$lang.po"{.tmp,} ; \
else \
rm "$(top_srcdir)/$(2)/$(3)$$$$lang.po.tmp" ; \
fi ; \
done
.PHONY: download-po.$(1)
endef
$(eval $(call make-download-po-rule,guix,po/guix))
$(eval $(call make-download-po-rule,guix-packages,po/packages))
$(eval $(call make-download-po-rule,guix-manual,po/doc,guix-manual.))
download-po: $(foreach domain,guix guix-packages guix-manual,download-po.$(domain))
.PHONY: download-po
## -------------- ##
+1 -163
View File
@@ -2,9 +2,8 @@
#+TITLE: Guix NEWS history of user-visible changes
#+STARTUP: content hidestars
Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
Copyright © 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@@ -12,167 +11,6 @@ Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
Please send Guix bug reports to bug-guix@gnu.org.
* Changes in 1.4.0 (since 1.3.0)
** Package management
*** New guix home command, for home environment management
*** New guix shell command, the successor to guix environment
*** New deb format for the guix pack command
*** New guix import minetest command, to import Minetest extensions
*** guix import texlive rewritten to use the TLPDB as its source
*** guix import elpa now supports the non-GNU ELPA repository
*** guix import pypi can now import a specific version
*** guix import cran can now import a specific version
*** New updater (see guix refresh): generic-git
*** guix graph has a new --max-depth option
*** --with-commit option now accepts strings returned by git describe
** Distribution
*** The installation script can now enable local substitute servers discovery
*** More control over boot-time file system checks and repairs
*** XFS file systems can be created by the installer and mounted by label/UUID
*** New interface for declaring swap space
** Programming interfaces
*** (guix records) now supports “field sanitizers”
** Noteworthy bug fixes
*** Fall back to Software Heritage when cloning a channel
(<https://issues.guix.gnu.org/44187>)
*** --with-patch can be used on packages with non-origin sources
(<https://issues.guix.gnu.org/49697>)
*** Fix pathological profile building performance in the presence of grafts
(<https://issues.guix.gnu.org/49439>)
*** Deduplication phase of the garbage collector is now faster
(<https://issues.guix.gnu.org/24937>)
*** File system flags are validated before system instantiation
(<https://issues.guix.gnu.org/51425>)
* Changes in 1.3.0 (since 1.2.0)
** Package management
*** POWER9 (powerpc64le-linux) is now supported as a technology preview
*** New --export-manifest and --export-channels options of guix package
*** New --profile option for guix environment
*** New --discover option of guix-daemon, for local substitute discovery
*** New --advertise option of guix publish
*** New --with-patch and --with-latest package transformation options
*** guix system image supersedes the disk-image and vm-image sub-commands
*** --verbosity=1 no longer displays download URLs
*** guix publish -C now supports zstd compression via Guile-zstd
*** guix-daemon now supports zstd substitutes, which decompress faster
*** New guix import go command, to import Go packages
*** guix import opam now supports Coq packages and has a --repo option
*** guix import crate now honors semantic versioning (“semver”)
*** guix import nix has been removed
*** New updaters (see guix refresh): sourceforge and generic-html
*** Substitute installation has been optimized
*** guix commands suggest alternative sub-commands or options upon typos
*** Offloading no longer requires guile to be in $PATH on build machines
*** GUIX_EXTENSIONS_PATH is honored when looking for extensions such as GWL
*** New --format option for guix processes
*** guix upgrade can now be passed several regexps
** Distribution
*** The Guix System demonstration VM now supports the SPICE protocol
*** The installation script can now run in a fully automated manner
*** qemu-binfmt-service-type now relies on statically-linked QEMU
*** sysctl-service-type enables Linux protected hardlinks/symlinks by default
*** %base-services now includes a default sysctl-service-type instance
*** Linux Logical Volumne Manager (LVM) now supported, via lvm-device-mapping
*** guix system init has been optimized
*** guix system warns when users/groups appear more than once
*** guix system image -t rock64-raw produces images for Rock64 devices
*** herd discover guix-daemon on turns on substitute server discovery
*** Default initrd now supports bcachefs
*** CUPS service includes brlaser extension by default
*** “lp” group is no longer included in %base-groups
*** New --graph-backend option for guix system {extension,shepherd}-graph
*** New services
agate, cuirass-remote-worker, ipfs, keepalived, laminar, radicale, syncthing,
transmission-daemon, wireguard, xorg-server
*** 2009 new packages
*** 3100 package updates
Noteworthy updates:
emacs 27.2, gcc-toolchain 10.3.0, ghc 8.8.3, glibc 2.31, gnome 3.34.5,
gnupg 2.2.27, go 1.14.15, guile 3.0.5, icecat 78.10.0-guix0-preview1,
icedtea 3.7.0, inkscape 1.0.2, julia 1.5.3, libreoffice 6.4.7.2,
linux-libre 5.11.15, ocaml 4.11.1, octave 6.2.0, openjdk 14.0,
python 3.8.2, racket 8.0, rust 1.51.0, r 4.0.4, sbcl 2.1.3, xfce 4.16.0,
xorg-server 1.20.10
** Programming interfaces
*** New channel-with-substitutes-available procedure in (guix channels)
*** New modules (guix substitutes), (guix narinfo), and (guix avahi)
*** <image> records can be passed to guix system image
*** New (guix ipfs) module to interact with an IPFS gateway
** Noteworthy bug fixes
*** Risk of local privilege escalation via guix-daemon fixed
(<https://issues.guix.gnu.org/47229>, CVE-2021-27851)
*** Setuid programs on Guix System are no longer setgid root
(<https://issues.guix.gnu.org/46395>)
*** Risk of local privilege escalation during reconfigure fixed
(<https://issues.guix.gnu.org/47584>)
*** Grafting recognizes UTF-16 and UTF-32 store references
(<https://issues.guix.gnu.org/33848>)
*** (guix git) honors HTTP/HTTPS proxy settings for Git submodules
(<https://issues.guix.gnu.org/44593>)
*** Fix guix substitute crash when interleaving lzip and gzip
(<https://issues.guix.gnu.org/46967>)
*** Fix GnuTLS memory corruption when used from Guile
(<https://issues.guix.gnu.org/46330>)
*** Update GnuTLS to 3.6.15, addressing a time-dependent test failure
(<https://issues.guix.gnu.org/44559>)
*** Booted system is fully protected from garbage collection
(<https://issues.guix.gnu.org/46767>)
*** Add MSDOS disk label support on UEFI systems
(<https://issues.guix.gnu.org/47889>)
*** Installers kmscon no longer uses up 100% CPU
(<https://issues.guix.gnu.org/39341>)
*** Git checkouts can be updated to the remotes default HEAD
(<https://issues.guix.gnu.org/45187>)
*** guix pull correctly displays early builds and downloads
(<https://issues.guix.gnu.org/41930>)
*** Fix OpenRC init scripts for guix-daemon
(<https://issues.guix.gnu.org/46871>)
*** Activate system when switching generations
(<https://issues.guix.gnu.org/38884>)
*** guix environment -C preserves original mount flags
(<https://issues.guix.gnu.org/46292>)
*** Remove duplicates in profile transactions
(<https://issues.guix.gnu.org/23874>)
*** Fix sound problems with ALSA plugins on foreign distros
(<https://issues.guix.gnu.org/40832>)
** Native language support
*** Updated translations of the manual
The manual is fully translated into French and German, 90% translated into
Spanish, and has preliminary translations into Chinese, Brazilian Portuguese,
and Russian.
*** Update translations of the cookbook
The cookbook is fully translated in French and German and has a preliminary
translation into Korean.
*** Updated translations of messages
This version of Guix is fully translated in French, German, and Slovak; it has
good translation into Brazilian Portuguese and Spanish, and preliminary
translations in a dozen other languages.
*** Translations now hosted on Fedoras Weblate instance
Translations are now handled at
<https://translate.fedoraproject.org/projects/guix/guix/> (thanks, Fedora!).
You can join to help improve translations in your native language of messages,
documentation, package descriptions, and the web site.
* Changes in 1.2.0 (since 1.1.0)
** Package management
+1 -1
View File
@@ -62,7 +62,7 @@ Please email <help-guix@gnu.org> for questions and <bug-guix@gnu.org> for bug
reports; email <gnu-system-discuss@gnu.org> for general issues regarding the
GNU system.
Join #guix on irc.libera.chat.
Join #guix on irc.freenode.net.
* Guix & Nix
+1 -1
View File
@@ -23,7 +23,7 @@ There will be a few 0.x releases by then to give the new features more
exposure and testing.
You're welcome to discuss this road map on guix-devel@gnu.org or #guix on
the Libera Chat IRC network!
Freenode!
* Features scheduled for 1.0
+1 -1
View File
@@ -43,7 +43,7 @@ infrastructure help:
Alen Skondro <askondro@gmail.com>
Jan Synáček <jan.synacek@gmail.com>
Matthias Wachs <wachs@net.in.tum.de>
Christine Lemmer-Webber <cwebber@dustycloud.org>
Christopher Allan Webber <cwebber@dustycloud.org>
Philip Woods <elzairthesorcerer@gmail.com>
GNU Guix also includes non-software works. Thanks to the following
+4 -2
View File
@@ -5,7 +5,8 @@ set -e -x
# Generate stubs for translations.
langs=`find po/doc -type f -name 'guix-manual*.po' \
| sed -e 's,.*/guix-manual\.,,;s,\.po$,,'`
| sed -e 's,guix-manual\.,,' \
| xargs -n 1 -I{} basename {} .po`
for lang in ${langs}; do
if [ ! -e "doc/guix.${lang}.texi" ]; then
echo "@setfilename guix.${lang}.info" > "doc/guix.${lang}.texi"
@@ -15,7 +16,8 @@ for lang in ${langs}; do
fi
done
langs=`find po/doc -type f -name 'guix-cookbook*.po' \
| sed -e 's,.*/guix-cookbook\.,,;s,\.po$,,'`
| sed -e 's,guix-cookbook\.,,' \
| xargs -n 1 -I{} basename {} .po`
for lang in ${langs}; do
if [ ! -e "doc/guix-cookbook.${lang}.texi" ]; then
echo "@setfilename guix-cookbook.${lang}.info" > "doc/guix-cookbook.${lang}.texi"
+54 -97
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -241,16 +241,12 @@ interface (FFI) of Guile.")
(define* (build-program source version
#:optional (guile-version (effective-version))
#:key (pull-version 0) (channel-metadata #f))
#:key (pull-version 0))
"Return a program that computes the derivation to build Guix from SOURCE."
(define select?
;; Select every module but (guix config) and non-Guix modules.
;; Also exclude (guix channels): it is autoloaded by (guix describe), but
;; only for peripheral functionality.
(match-lambda
(('guix 'config) #f)
(('guix 'channels) #f)
(('guix 'build 'download) #f) ;autoloaded by (guix download)
(('guix _ ...) #t)
(('gnu _ ...) #t)
(_ #f)))
@@ -286,7 +282,8 @@ interface (FFI) of Guile.")
#:select? select?))
(gexp->script "compute-guix-derivation"
#~(begin
(use-modules (ice-9 match))
(use-modules (ice-9 match)
(ice-9 threads))
(eval-when (expand load eval)
;; (gnu packages …) modules are going to be looked up
@@ -320,9 +317,23 @@ interface (FFI) of Guile.")
(guix derivations)
(srfi srfi-1))
(define (spin system)
(define spin
(circular-list "-" "\\" "|" "/" "-" "\\" "|" "/"))
(format (current-error-port)
"Computing Guix derivation for '~a'... "
system)
(when (isatty? (current-error-port))
(let loop ((spin spin))
(display (string-append "\b" (car spin))
(current-error-port))
(force-output (current-error-port))
(sleep 1)
(loop (cdr spin)))))
(match (command-line)
((_ source system version protocol-version
build-output)
((_ source system version protocol-version)
;; The current input port normally wraps a file
;; descriptor connected to the daemon, or it is
;; connected to /dev/null. In the former case, reuse
@@ -335,51 +346,22 @@ interface (FFI) of Guile.")
(current-input-port)
"w+0")
#:version proto)
(open-connection)))
(sock (socket AF_UNIX SOCK_STREAM 0)))
;; Connect to BUILD-OUTPUT and send it the raw
;; build output.
(connect sock AF_UNIX build-output)
(open-connection))))
(call-with-new-thread
(lambda ()
(spin system)))
(display
(and=>
;; Silence autoload warnings and the likes.
(parameterize ((current-warning-port
(%make-void-port "w"))
(current-build-output-port sock))
(run-with-store store
(guix-derivation source version
#$guile-version
#:channel-metadata
'#$channel-metadata
#:pull-version
#$pull-version)
#:system system))
(run-with-store store
(guix-derivation source version
#$guile-version
#:pull-version
#$pull-version)
#:system system)
derivation-file-name))))))
#:module-path (list source))))
(define (proxy input output)
"Dump the contents of INPUT to OUTPUT until EOF is reached on INPUT.
Display a spinner when nothing happens."
(define spin
(circular-list "-" "\\" "|" "/" "-" "\\" "|" "/"))
(setvbuf input 'block 16384)
(let loop ((spin spin))
(match (select (list input) '() '() 1)
((() () ())
(when (isatty? (current-error-port))
(display (string-append "\b" (car spin))
(current-error-port))
(force-output (current-error-port)))
(loop (cdr spin)))
(((_) () ())
;; Read from INPUT as much as can be read without blocking.
(let ((bv (get-bytevector-some input)))
(unless (eof-object? bv)
(put-bytevector output bv)
(loop spin)))))))
(define (call-with-clean-environment thunk)
(let ((env (environ)))
(dynamic-wind
@@ -395,9 +377,7 @@ Display a spinner when nothing happens."
;; The procedure below is our return value.
(define* (build source
#:key verbose?
(version (date-version-string)) channel-metadata
system
#:key verbose? (version (date-version-string)) system
(pull-version 0)
;; For the standalone Guix, default to Guile 3.0. For old
@@ -414,7 +394,6 @@ files."
;; Build the build program and then use it as a trampoline to build from
;; SOURCE.
(mlet %store-monad ((build (build-program source version guile-version
#:channel-metadata channel-metadata
#:pull-version pull-version))
(system (if system (return system) (current-system)))
(home -> (getenv "HOME"))
@@ -436,14 +415,7 @@ files."
;; way, we know 'open-pipe*' will not close it on 'exec'. If PORT is
;; not a file port (e.g., it's an SSH channel), then the subprocess's
;; stdin will actually be /dev/null.
(let* ((sock (socket AF_UNIX SOCK_STREAM 0))
(node (let ((file (string-append (or (getenv "TMPDIR") "/tmp")
"/guix-build-output-"
(number->string (getpid)))))
(bind sock AF_UNIX file)
(listen sock 1)
file))
(pipe (with-input-from-port port
(let* ((pipe (with-input-from-port port
(lambda ()
;; Make sure BUILD is not influenced by
;; $GUILE_LOAD_PATH & co.
@@ -459,45 +431,30 @@ files."
(if (file-port? port)
(number->string
(logior major minor))
"none")
node))))))
(format (current-error-port) "Computing Guix derivation for '~a'... "
system)
;; Wait for a connection on SOCK and proxy build output so it can be
;; processed according to the settings currently in effect (build
;; traces, verbosity level, and so on).
(match (accept sock)
((port . _)
(close-port sock)
(delete-file node)
(proxy port (current-build-output-port))))
;; Now that the build output connection was closed, read the result, a
;; derivation file name, from PIPE.
(let ((str (get-string-all pipe))
(status (close-pipe pipe)))
(match str
((? eof-object?)
(error "build program failed" (list build status)))
((? derivation-path? drv)
(mbegin %store-monad
(return (newline (current-error-port)))
((store-lift add-temp-root) drv)
(return (read-derivation-from-file drv))))
("#f"
;; Unsupported PULL-VERSION.
(return #f))
((? string? str)
(raise (condition
(&message
(message (format #f "You found a bug: the program '~a'
"none"))))))
(str (get-string-all pipe))
(status (close-pipe pipe)))
(match str
((? eof-object?)
(error "build program failed" (list build status)))
((? derivation-path? drv)
(mbegin %store-monad
(return (newline (current-error-port)))
((store-lift add-temp-root) drv)
(return (read-derivation-from-file drv))))
("#f"
;; Unsupported PULL-VERSION.
(return #f))
((? string? str)
(raise (condition
(&message
(message (format #f "You found a bug: the program '~a'
failed to compute the derivation for Guix (version: ~s; system: ~s;
host version: ~s; pull-version: ~s).
Please report the COMPLETE output above by email to <~a>.~%"
(derivation->output-path build)
version system %guix-version pull-version
%guix-bug-report-address))))))))))))
Please report it by email to <~a>.~%"
(derivation->output-path build)
version system %guix-version pull-version
%guix-bug-report-address)))))))))))
;; This file is loaded by 'guix pull'; return it the build procedure.
build
@@ -83,4 +83,5 @@ refer to the bootstrap tools."
(set-build-options store #:use-substitutes? #t)
(for-each (cut test-final-inputs store <>)
%cuirass-supported-systems)))
%hydra-supported-systems)))
+24 -31
View File
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -98,36 +98,26 @@ to 'make'."
(exit 1)))
(match (command-line)
((_ "--total" (= string->number grand-total)
"--completed" (= string->number processed)
. files)
;; GRAND-TOTAL is the total number of .scm files in the project; PROCESSED
;; is the total number of .scm files already compiled in previous
;; invocations of this script.
((_ . files)
(catch #t
(lambda ()
(let* ((to-build (filter file-needs-compilation? files))
(processed (+ processed
(- (length files) (length to-build)))))
(compile-files srcdir (getcwd) to-build
#:workers (parallel-job-count*)
#:host host
#:report-load (lambda (file total completed)
(when file
(format #t "[~3d%] LOAD ~a~%"
(% (+ 1 completed
(* 2 processed))
(* 2 grand-total))
file)
(force-output)))
#:report-compilation (lambda (file total completed)
(when file
(format #t "[~3d%] GUILEC ~a~%"
(% (+ total completed 1
(* 2 processed))
(* 2 grand-total))
(scm->go file))
(force-output))))))
(compile-files srcdir (getcwd)
(filter file-needs-compilation? files)
#:workers (parallel-job-count*)
#:host host
#:report-load (lambda (file total completed)
(when file
(format #t "[~3d%] LOAD ~a~%"
(% (+ 1 completed) (* 2 total))
file)
(force-output)))
#:report-compilation (lambda (file total completed)
(when file
(format #t "[~3d%] GUILEC ~a~%"
(% (+ total completed 1)
(* 2 total))
(scm->go file))
(force-output)))))
(lambda _
(primitive-exit 1))
(lambda args
@@ -142,8 +132,11 @@ to 'make'."
(false-if-exception
(module-ref ui 'report-load-error)))))
(if report
(report (or (and=> (current-load-port) port-filename) "?.scm")
args frame)
;; In Guile <= 2.2.5, 'current-load-port' was not exported.
(let ((load-port ((module-ref (resolve-module '(ice-9 ports))
'current-load-port))))
(report (or (and=> load-port port-filename) "?.scm")
args frame))
(begin
(print-exception (current-error-port) frame
(car args) (cdr args))
-105
View File
@@ -1,105 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2021 Mathieu Othacehe <othacehe@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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; This program replicates the behavior of Cuirass's 'evaluate' process.
;;; It displays the evaluated jobs on the standard output.
(use-modules (guix channels)
(guix derivations)
(guix git-download)
(guix inferior)
(guix packages)
(guix store)
(guix ui)
((guix ui) #:select (build-notifier))
(ice-9 match)
(ice-9 threads))
(define %top-srcdir
(and=> (assq-ref (current-source-location) 'filename)
(lambda (file)
(canonicalize-path
(string-append (dirname file) "/../..")))))
(match (command-line)
((command directory)
(let ((real-build-things build-things))
(with-store store
;; Make sure we don't resort to substitutes.
(set-build-options store
#:use-substitutes? #f
#:substitute-urls '())
;; The evaluation of Guix itself requires building a "trampoline"
;; program, and possibly everything it depends on. Thus, allow builds
;; but print a notification.
(with-build-handler (build-notifier #:use-substitutes? #f)
;; Add %TOP-SRCDIR to the store with a proper Git predicate so we
;; work from a clean checkout.
(let ((source (add-to-store store "guix-source" #t
"sha256" %top-srcdir
#:select? (git-predicate %top-srcdir))))
(define instances
(list (checkout->channel-instance source)))
(define channels
(map channel-instance-channel instances))
(define derivation
;; Compute the derivation of Guix for COMMIT.
(run-with-store store
(channel-instances->derivation instances)))
;; TODO: Remove 'show-what-to-build' call when Cuirass' 'evaluate'
;; scripts uses 'with-build-handler'.
(show-what-to-build store (list derivation))
(build-derivations store (list derivation))
;; Evaluate jobs on a per-system basis for two reasons. It speeds
;; up the evaluation speed as the evaluations can be performed
;; concurrently. It also decreases the amount of memory needed per
;; evaluation process.
(n-par-for-each
(/ (current-processor-count) 2)
(lambda (system)
(with-store store
(let ((inferior
(open-inferior (derivation->output-path derivation)))
(channels (map channel-instance->sexp instances)))
(inferior-eval '(use-modules (gnu ci)) inferior)
(let ((jobs
(inferior-eval-with-store
inferior store
`(lambda (store)
(cuirass-jobs store
'((subset . all)
(systems . ,(list system))
(channels . ,channels))))))
(file
(string-append directory "/jobs-" system ".scm")))
(call-with-output-file file
(lambda (port)
(write jobs port)))))))
%cuirass-supported-systems))))))
(x
(format (current-error-port) "Wrong command: ~a~%." x)
(exit 1)))
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -16,11 +16,10 @@
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;; Translate cross-references in a translated .texi manual.
;;;
;;; This file defines build jobs for the Cuirass continuation integration
;;; tool.
;;;
(use-modules (guix build po)
(ice-9 match))
(match (command-line)
((program texi pofile)
(translate-cross-references texi pofile)))
(include "../hydra/gnu-system.scm")
(include "hydra-to-cuirass.scm")
+6
View File
@@ -0,0 +1,6 @@
;;;
;;; This file defines Cuirass build jobs to build Guix itself.
;;;
(include "../hydra/guix-modular.scm")
(include "hydra-to-cuirass.scm")
+47
View File
@@ -0,0 +1,47 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file defines the conversion of Hydra build jobs to Cuirass build
;;; jobs. It is meant to be included in other files.
;;;
(use-modules ((guix licenses)
#:select (license? license-name license-uri license-comment)))
(define (cuirass-jobs store arguments)
"Return Cuirass jobs."
(map hydra-job->cuirass-job (hydra-jobs store arguments)))
(define (hydra-job->cuirass-job hydra-job)
(let ((name (car hydra-job))
(job ((cdr hydra-job))))
(lambda _ (acons #:job-name (symbol->string name)
(map symbol-alist-entry->keyword-alist-entry job)))))
(define (symbol-alist-entry->keyword-alist-entry entry)
(cons (symbol->keyword (car entry)) (entry->sexp-entry (cdr entry))))
(define (entry->sexp-entry o)
(match o
((? license?) `((name . (license-name o))
(uri . ,(license-uri o))
(comment . ,(license-comment o))))
((lst ...)
(map entry->sexp-entry lst))
(_ o)))
+131
View File
@@ -0,0 +1,131 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; This program replicates the behavior of Hydra's 'hydra-eval-guile-job'.
;;; It evaluates the Hydra job defined by the program passed as its first
;;; arguments and outputs an sexp of the jobs on standard output.
(use-modules (guix store)
(guix git-download)
((guix build utils) #:select (with-directory-excursion))
((guix ui) #:select (build-notifier))
(srfi srfi-19)
(ice-9 match)
(ice-9 pretty-print)
(ice-9 format))
(define %top-srcdir
(and=> (assq-ref (current-source-location) 'filename)
(lambda (file)
(canonicalize-path
(string-append (dirname file) "/../..")))))
(define %user-module
;; Hydra user module.
(let ((m (make-module)))
(beautify-user-module! m)
m))
(define (call-with-time thunk kont)
"Call THUNK and pass KONT the elapsed time followed by THUNK's return
values."
(let* ((start (current-time time-monotonic))
(result (call-with-values thunk list))
(end (current-time time-monotonic)))
(apply kont (time-difference end start) result)))
(define (call-with-time-display thunk)
"Call THUNK and write to the current output port its duration."
(call-with-time thunk
(lambda (time . results)
(format #t "~,3f seconds~%"
(+ (time-second time)
(/ (time-nanosecond time) 1e9)))
(apply values results))))
(define (assert-valid-job job thing)
"Raise an error if THING is not an alist with a valid 'derivation' entry.
Otherwise return THING."
(unless (and (list? thing)
(and=> (assoc-ref thing 'derivation)
(lambda (value)
(and (string? value)
(string-suffix? ".drv" value)))))
(error "job did not produce a valid alist" job thing))
thing)
;; Without further ado...
(match (command-line)
((command file cuirass? ...)
;; Load FILE, a Scheme file that defines Hydra jobs.
(let ((port (current-output-port))
(real-build-things build-things))
(with-store store
;; Make sure we don't resort to substitutes.
(set-build-options store
#:use-substitutes? #f
#:substitute-urls '())
;; The evaluation of Guix itself requires building a "trampoline"
;; program, and possibly everything it depends on. Thus, allow builds
;; but print a notification.
(with-build-handler (build-notifier #:use-substitutes? #f)
;; Add %TOP-SRCDIR to the store with a proper Git predicate so we work
;; from a clean checkout
(let ((source (add-to-store store "guix-source" #t
"sha256" %top-srcdir
#:select? (git-predicate %top-srcdir))))
(with-directory-excursion source
(save-module-excursion
(lambda ()
(set-current-module %user-module)
(format (current-error-port)
"loading '~a' relative to '~a'...~%"
file source)
(primitive-load file))))
;; Call the entry point of FILE and print the resulting job sexp.
(pretty-print
(match ((module-ref %user-module
(if (equal? cuirass? "cuirass")
'cuirass-jobs
'hydra-jobs))
store `((guix
. ((file-name . ,source)))))
(((names . thunks) ...)
(map (lambda (job thunk)
(format (current-error-port) "evaluating '~a'... " job)
(force-output (current-error-port))
(cons job
(assert-valid-job job
(call-with-time-display thunk))))
names thunks)))
port))))))
((command _ ...)
(format (current-error-port) "Usage: ~a FILE [cuirass]
Evaluate the Hydra or Cuirass jobs defined in FILE.~%"
command)
(exit 1)))
;;; Local Variables:
;;; eval: (put 'call-with-time 'scheme-indent-function 1)
;;; End:
+88
View File
@@ -0,0 +1,88 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2018, 2019 Clément Lassieur <clement@lassieur.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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file defines build jobs for the Hydra continuation integration
;;; tool.
;;;
(use-modules (guix inferior) (guix channels)
(guix)
(guix ui)
(srfi srfi-1)
(ice-9 match))
;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
;; port to the bit bucket, let us write to the error port instead.
(setvbuf (current-error-port) 'line)
(set-current-output-port (current-error-port))
(define (find-current-checkout arguments)
"Find the first checkout of ARGUMENTS that provided the current file.
Return #f if no such checkout is found."
(let ((current-root
(canonicalize-path
(string-append (dirname (current-filename)) "/../.."))))
(find (lambda (argument)
(and=> (assq-ref argument 'file-name)
(lambda (name)
(string=? name current-root)))) arguments)))
(define (hydra-jobs store arguments)
"Return a list of jobs where each job is a NAME/THUNK pair."
(define checkout
(find-current-checkout arguments))
(define commit
(assq-ref checkout 'revision))
(define source
(assq-ref checkout 'file-name))
(define instance
(checkout->channel-instance source #:commit commit))
(define derivation
;; Compute the derivation of Guix for COMMIT.
(run-with-store store
(channel-instances->derivation (list instance))))
;; TODO: Remove 'show-what-to-build' call when Cuirass' 'evaluate' scripts
;; uses 'with-build-handler'.
(show-what-to-build store (list derivation))
(build-derivations store (list derivation))
;; Open an inferior for the just-built Guix.
(let ((inferior (open-inferior (derivation->output-path derivation))))
(inferior-eval '(use-modules (gnu ci) (ice-9 match)) inferior)
(map (match-lambda
((name . fields)
;; Hydra expects a thunk, so here it is.
(cons name (lambda () fields))))
(inferior-eval-with-store
inferior store
`(lambda (store)
(map (match-lambda
((name . thunk)
(cons name (thunk))))
(hydra-jobs store '((superior-guix-checkout . ,checkout)
,@arguments))))))))
+91
View File
@@ -0,0 +1,91 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018, 2020 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file defines a continuous integration job to build the same modular
;;; Guix as 'guix pull', which is defined in (guix self).
;;;
(use-modules (guix store)
(guix config)
(guix utils)
((guix packages) #:select (%hydra-supported-systems))
(guix derivations)
(guix monads)
((guix licenses) #:prefix license:)
(srfi srfi-1)
(ice-9 match))
;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
;; port to the bit bucket, let us write to the error port instead.
(setvbuf (current-error-port) 'line)
(set-current-output-port (current-error-port))
(define* (build-job store source version system)
"Return a Hydra job a list building the modular Guix derivation from SOURCE
for SYSTEM. Use VERSION as the version identifier."
(lambda ()
(define build
(primitive-load (string-append source "/build-aux/build-self.scm")))
(let ((drv (run-with-store store
(build source #:version version #:system system
#:pull-version 1
#:guile-version "2.2"))))
`((derivation . ,(derivation-file-name drv)) ;the latest 2.2.x
(log . ,(log-file store (derivation-file-name drv)))
(outputs . ,(filter-map (lambda (res)
(match res
((name . path)
`(,name . ,path))))
(derivation->output-paths drv)))
(nix-name . ,(derivation-name drv))
(system . ,(derivation-system drv))
(description . "Modular Guix")
(long-description
. "This is the modular Guix package as produced by 'guix pull'.")
(license . ,license:gpl3+)
(home-page . ,%guix-home-page-url)
(maintainers . (,%guix-bug-report-address))))))
(define (hydra-jobs store arguments)
"Return Hydra jobs."
(define systems
(match (assoc-ref arguments 'systems)
(#f %hydra-supported-systems)
((lst ...) lst)
((? string? str) (call-with-input-string str read))))
(define guix-checkout
(or (assq-ref arguments 'guix) ;Hydra on hydra
(assq-ref arguments 'guix-modular))) ;Cuirass on berlin
(define version
(or (assq-ref guix-checkout 'revision)
"0.unknown"))
(let ((file (assq-ref guix-checkout 'file-name)))
(format (current-error-port) "using checkout ~s (~s; arguments: ~s)~%"
guix-checkout file arguments)
(map (lambda (system)
(let ((name (string->symbol
(string-append "guix." system))))
`(,name
. ,(build-job store file version system))))
systems)))
+106
View File
@@ -0,0 +1,106 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file defines build jobs of Guix itself for the Hydra continuation
;;; integration tool.
;;;
;; Attempt to use our very own Guix modules.
(eval-when (expand load eval)
;; Ignore any available .go, and force recompilation. This is because our
;; checkout in the store has mtime set to the epoch, and thus .go files look
;; newer, even though they may not correspond.
(set! %fresh-auto-compile #t)
;; Display which files are loaded.
(set! %load-verbosely #t)
(and=> (assoc-ref (current-source-location) 'filename)
(lambda (file)
(let ((dir (string-append (dirname file) "/../..")))
(format (current-error-port) "prepending ~s to the load path~%"
dir)
(set! %load-path (cons dir %load-path))))))
(use-modules (guix store)
(guix packages)
(guix utils)
(guix grafts)
(guix derivations)
(guix build-system gnu)
(gnu packages package-management)
(srfi srfi-1)
(srfi srfi-26)
(ice-9 match))
;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
;; port to the bit bucket, let us write to the error port instead.
(setvbuf (current-error-port) _IOLBF)
(set-current-output-port (current-error-port))
(define* (package->alist store package system
#:optional (package-derivation package-derivation))
"Convert PACKAGE to an alist suitable for Hydra."
`((derivation . ,(derivation-file-name
(parameterize ((%graft? #f))
(package-derivation store package system
#:graft? #f))))
(description . ,(package-synopsis package))
(long-description . ,(package-description package))
(license . ,(package-license package))
(home-page . ,(package-home-page package))
(maintainers . ("bug-guix@gnu.org"))))
(define (hydra-jobs store arguments)
"Return Hydra jobs."
(define systems
(match (filter-map (match-lambda
(('system . value)
value)
(_ #f))
arguments)
((lst ..1)
lst)
(_
(list (%current-system)))))
(define guix-checkout
(assq-ref arguments 'guix))
(let ((file (assq-ref guix-checkout 'file-name)))
(format (current-error-port) "using checkout ~s (~s)~%"
guix-checkout file)
`((tarball . ,(cute package->alist store
(dist-package guix file)
(%current-system)))
,@(map (lambda (system)
(let ((name (string->symbol
(string-append "guix." system))))
`(,name
. ,(cute package->alist store
(package
(inherit guix)
(version "latest")
(source file))
system))))
%hydra-supported-systems))))
Executable → Regular
+42 -142
View File
@@ -1,12 +1,8 @@
#!/bin/sh
exec guile --no-auto-compile -e main -s "$0" "$@"
!#
;;;; test-driver.scm - Guile test driver for Automake testsuite harness
(define script-version "2021-02-02.05") ;UTC
(define script-version "2017-03-22.13") ;UTC
;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This program is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
@@ -28,12 +24,8 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
;;;
;;;; Code:
(use-modules (ice-9 format)
(ice-9 getopt-long)
(use-modules (ice-9 getopt-long)
(ice-9 pretty-print)
(ice-9 regex)
(srfi srfi-1)
(srfi srfi-19)
(srfi srfi-26)
(srfi srfi-64))
@@ -41,30 +33,18 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
(display "Usage:
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--select=REGEXP] [--exclude=REGEXP] [--errors-only={yes|no}]
[--enable-hard-errors={yes|no}] [--brief={yes|no}}]
[--show-duration={yes|no}] [--]
[--enable-hard-errors={yes|no}] [--brief={yes|no}}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name' option is mandatory. The '--select' and '--exclude' options
allow selecting or excluding individual test cases via a regexp, respectively.
The '--errors-only' option can be set to \"yes\" to limit the logged test case
metadata to only those test cases that failed. When set to \"yes\", the
'--brief' option disables printing the individual test case result to the
console. When '--show-duration' is set to \"yes\", the time elapsed per test
case is shown.\n"))
The '--test-name', '--log-file' and '--trs-file' options are mandatory.\n"))
(define %options
'((test-name (value #t))
(log-file (value #t))
(trs-file (value #t))
(select (value #t))
(exclude (value #t))
(errors-only (value #t))
(color-tests (value #t))
(expect-failure (value #t)) ;XXX: not implemented yet
(enable-hard-errors (value #t)) ;not implemented in SRFI-64
(brief (value #t))
(show-duration (value #t))
(help (single-char #\h) (value #f))
(version (single-char #\V) (value #f))))
@@ -95,81 +75,46 @@ case is shown.\n"))
"") ;no color
result)))
;;;
;;; SRFI 64 custom test runner.
;;;
(define* (test-runner-gnu test-name #:key color? brief? errors-only?
show-duration?
(out-port (current-output-port))
(trs-port (%make-void-port "w"))
select exclude)
(define* (test-runner-gnu test-name #:key color? brief? out-port trs-port)
"Return an custom SRFI-64 test runner. TEST-NAME is a string specifying the
file name of the current the test. COLOR? specifies whether to use colors.
When BRIEF? is true, the individual test cases results are masked and only the
summary is shown. ERRORS-ONLY? reduces the amount of test case metadata
logged to only that of the failed test cases. OUT-PORT and TRS-PORT must be
output ports. OUT-PORT defaults to the current output port, while TRS-PORT
defaults to a void port, which means no TRS output is logged. SELECT and
EXCLUDE may take a regular expression to select or exclude individual test
cases based on their names."
(define test-cases-start-time (make-hash-table))
file name of the current the test. COLOR? specifies whether to use colors,
and BRIEF?, well, you know. OUT-PORT and TRS-PORT must be output ports. The
current output port is supposed to be redirected to a '.log' file."
(define (test-on-test-begin-gnu runner)
;; Procedure called at the start of an individual test case, before the
;; test expression (and expected value) are evaluated.
(let ((test-case-name (test-runner-test-name runner))
(start-time (current-time time-monotonic)))
(hash-set! test-cases-start-time test-case-name start-time)))
(define (test-skipped? runner)
(eq? 'skip (test-result-kind runner)))
(define (test-failed? runner)
(not (or (test-passed? runner)
(test-skipped? runner))))
(let ((result (cute assq-ref (test-result-alist runner) <>)))
(format #t "test-name: ~A~%" (result 'test-name))
(format #t "location: ~A~%"
(string-append (result 'source-file) ":"
(number->string (result 'source-line))))
(test-display "source" (result 'source-form) #:pretty? #t)))
(define (test-on-test-end-gnu runner)
;; Procedure called at the end of an individual test case, when the result
;; of the test is available.
(let* ((results (test-result-alist runner))
(result? (cut assq <> results))
(result (cut assq-ref results <>))
(test-case-name (test-runner-test-name runner))
(start (hash-ref test-cases-start-time test-case-name))
(end (current-time time-monotonic))
(time-elapsed (time-difference end start))
(time-elapsed-seconds (+ (time-second time-elapsed)
(* 1e-9 (time-nanosecond time-elapsed)))))
(unless (or brief? (and errors-only? (test-skipped? runner)))
(result (cut assq-ref results <>)))
(unless brief?
;; Display the result of each test case on the console.
(format out-port "~a: ~a - ~a ~@[[~,3fs]~]~%"
(format out-port "~A: ~A - ~A~%"
(result->string (test-result-kind runner) #:colorize? color?)
test-name test-case-name
(and show-duration? time-elapsed-seconds)))
(unless (and errors-only? (not (test-failed? runner)))
(format #t "test-name: ~A~%" (result 'test-name))
(format #t "location: ~A~%"
(string-append (result 'source-file) ":"
(number->string (result 'source-line))))
(test-display "source" (result 'source-form) #:pretty? #t)
(when (result? 'expected-value)
(test-display "expected-value" (result 'expected-value)))
(when (result? 'expected-error)
(test-display "expected-error" (result 'expected-error) #:pretty? #t))
(when (result? 'actual-value)
(test-display "actual-value" (result 'actual-value)))
(when (result? 'actual-error)
(test-display "actual-error" (result 'actual-error) #:pretty? #t))
(format #t "result: ~a~%" (result->string (result 'result-kind)))
(newline))
(format trs-port ":test-result: ~A ~A [~,3fs]~%"
test-name (test-runner-test-name runner)))
(when (result? 'expected-value)
(test-display "expected-value" (result 'expected-value)))
(when (result? 'expected-error)
(test-display "expected-error" (result 'expected-error) #:pretty? #t))
(when (result? 'actual-value)
(test-display "actual-value" (result 'actual-value)))
(when (result? 'actual-error)
(test-display "actual-error" (result 'actual-error) #:pretty? #t))
(format #t "result: ~a~%" (result->string (result 'result-kind)))
(newline)
(format trs-port ":test-result: ~A ~A~%"
(result->string (test-result-kind runner))
(test-runner-test-name runner) time-elapsed-seconds)))
(test-runner-test-name runner))))
(define (test-on-group-end-gnu runner)
;; Procedure called by a 'test-end', including at the end of a test-group.
@@ -199,34 +144,6 @@ cases based on their names."
(test-runner-on-bad-end-name! runner test-on-bad-end-name-simple)
runner))
;;;
;;; SRFI 64 test specifiers.
;;;
(define (test-match-name* regexp)
"Return a test specifier that matches a test name against REGEXP."
(lambda (runner)
(string-match regexp (test-runner-test-name runner))))
(define (test-match-name*/negated regexp)
"Return a negated test specifier version of test-match-name*."
(lambda (runner)
(not (string-match regexp (test-runner-test-name runner)))))
;;; XXX: test-match-all is a syntax, which isn't convenient to use with a list
;;; of test specifiers computed at run time. Copy this SRFI 64 internal
;;; definition here, which is the procedural equivalent of 'test-match-all'.
(define (%test-match-all . pred-list)
(lambda (runner)
(let ((result #t))
(let loop ((l pred-list))
(if (null? l)
result
(begin
(if (not ((car l) runner))
(set! result #f))
(loop (cdr l))))))))
;;;
;;; Entry point.
@@ -237,39 +154,22 @@ cases based on their names."
(option (cut option-ref opts <> <>)))
(cond
((option 'help #f) (show-help))
((option 'version #f) (format #t "test-driver.scm ~A~%" script-version))
((option 'version #f) (format #t "test-driver.scm ~A" script-version))
(else
(let* ((log (and=> (option 'log-file #f) (cut open-file <> "w0")))
(trs (and=> (option 'trs-file #f) (cut open-file <> "wl")))
(out (duplicate-port (current-output-port) "wl"))
(test-name (option 'test-name #f))
(select (option 'select #f))
(exclude (option 'exclude #f))
(test-specifiers (filter-map
identity
(list (and=> select test-match-name*)
(and=> exclude test-match-name*/negated))))
(test-specifier (apply %test-match-all test-specifiers))
(color-tests (if (assoc 'color-tests opts)
(option->boolean opts 'color-tests)
#t)))
(when log
(redirect-port log (current-output-port))
(redirect-port log (current-warning-port))
(redirect-port log (current-error-port)))
(let ((log (open-file (option 'log-file "") "w0"))
(trs (open-file (option 'trs-file "") "wl"))
(out (duplicate-port (current-output-port) "wl")))
(redirect-port log (current-output-port))
(redirect-port log (current-warning-port))
(redirect-port log (current-error-port))
(test-with-runner
(test-runner-gnu test-name
#:color? color-tests
(test-runner-gnu (option 'test-name #f)
#:color? (option->boolean opts 'color-tests)
#:brief? (option->boolean opts 'brief)
#:errors-only? (option->boolean opts 'errors-only)
#:show-duration? (option->boolean
opts 'show-duration)
#:out-port out #:trs-port trs)
(test-apply test-specifier
(lambda _
(load-from-path test-name))))
(and=> log close-port)
(and=> trs close-port)
(load-from-path (option 'test-name #f)))
(close-port log)
(close-port trs)
(close-port out))))
(exit 0)))
+8 -5
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -73,9 +73,9 @@ then
# Copy the keys so that the secret key has the right permissions (the
# daemon errors out when this is not the case.)
mkdir -p "$GUIX_CONFIGURATION_DIRECTORY"
cp "@abs_top_srcdir@/tests/keys/signing-key.sec" \
"@abs_top_srcdir@/tests/keys/signing-key.pub" \
"$GUIX_CONFIGURATION_DIRECTORY"
cp "@abs_top_srcdir@/tests/signing-key.sec" \
"@abs_top_srcdir@/tests/signing-key.pub" \
"$GUIX_CONFIGURATION_DIRECTORY"
chmod 400 "$GUIX_CONFIGURATION_DIRECTORY/signing-key.sec"
fi
@@ -91,11 +91,14 @@ then
# Place for the substituter's cache.
XDG_CACHE_HOME="$GUIX_STATE_DIRECTORY/cache-$$"
# For the (guix import snix) tests.
NIXPKGS="@NIXPKGS@"
export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \
GUIX_LOG_DIRECTORY GUIX_STATE_DIRECTORY GUIX_DATABASE_DIRECTORY \
GUIX_BINARY_SUBSTITUTE_URL \
GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES \
GUIX_CONFIGURATION_DIRECTORY XDG_CACHE_HOME
GUIX_CONFIGURATION_DIRECTORY XDG_CACHE_HOME NIXPKGS
# Launch the daemon without chroot support because is may be
# unavailable, for instance if we're not running as root.
+6 -12
View File
@@ -95,7 +95,7 @@ paragraph."
(with-atomic-file-replacement news-file
(lambda (input output)
(rewrite-org-section input output
(make-regexp "^(\\*+).*new packages")
(make-regexp "^(\\*+) (.*) new packages")
(lambda (match port)
(let ((stars (match:substring match 1)))
(format port
@@ -141,7 +141,7 @@ paragraph."
(with-atomic-file-replacement news-file
(lambda (input output)
(rewrite-org-section input output
(make-regexp "^(\\*+).*package updates")
(make-regexp "^(\\*+) (.*) package updates")
(lambda (match port)
(let ((stars (match:substring match 1))
(lst (map (match-lambda
@@ -166,22 +166,16 @@ paragraph."
(string-append data-directory "/packages-"
version ".txt"))
(define (package<? p1 p2)
(string<? (package-full-name p1) (package-full-name p2)))
(let-values (((previous-version new-version)
(call-with-input-file news-file NEWS->versions)))
(format (current-error-port) "Updating NEWS for ~a to ~a...~%"
previous-version new-version)
(let* ((old (call-with-input-file (package-file previous-version)
read))
(all-packages/sorted (sort (fold-packages (lambda (p r)
(cons p r))
'())
package<?))
(new (map (lambda (p)
(cons (package-name p) (package-version p)))
all-packages/sorted)))
(new (fold-packages (lambda (p r)
(alist-cons (package-name p) (package-version p)
r))
'())))
(call-with-output-file (package-file new-version)
(lambda (port)
(pretty-print new port)))
+14 -2
View File
@@ -13,7 +13,7 @@ if test "x$guix_build_daemon" = "xyes"; then
GUIX_ASSERT_CXX11
AC_PROG_RANLIB
AC_CONFIG_HEADERS([nix/config.h])
AC_CONFIG_HEADER([nix/config.h])
dnl Use 64-bit file system calls so that we can support files > 2 GiB.
AC_SYS_LARGEFILE
@@ -34,6 +34,7 @@ if test "x$guix_build_daemon" = "xyes"; then
dnl Look for SQLite, a required dependency.
PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19])
AC_DEFINE([NIX_VERSION], ["0.0.0"], [Fake Nix version number.])
AC_DEFINE_UNQUOTED([SYSTEM], ["$guix_system"],
[Guix host system type--i.e., platform and OS kernel tuple.])
@@ -94,6 +95,17 @@ if test "x$guix_build_daemon" = "xyes"; then
AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \
statvfs nanosleep strsignal statx])
dnl Check whether the store optimiser can optimise symlinks.
AC_MSG_CHECKING([whether it is possible to create a link to a symlink])
ln -s bla tmp_link
if ln tmp_link tmp_link2 2> /dev/null; then
AC_MSG_RESULT(yes)
AC_DEFINE(CAN_LINK_SYMLINK, 1, [Whether link() works on symlinks.])
else
AC_MSG_RESULT(no)
fi
rm -f tmp_link tmp_link2
dnl Check for <locale>.
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS([locale])
@@ -106,7 +118,7 @@ if test "x$guix_build_daemon" = "xyes"; then
dnl Determine the appropriate default list of substitute URLs (GnuTLS
dnl is required so we can default to 'https'.)
guix_substitute_urls="https://ci.guix.gnu.org https://bordeaux.guix.gnu.org"
guix_substitute_urls="https://ci.guix.gnu.org"
AC_MSG_CHECKING([for default substitute URLs])
AC_MSG_RESULT([$guix_substitute_urls])
+45 -27
View File
@@ -1,14 +1,14 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_PREREQ(2.68)
AC_INIT([GNU Guix],
[m4_esyscmd([build-aux/git-version-gen .tarball-version])],
[bug-guix@gnu.org], [guix],
[https://www.gnu.org/software/guix/])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.14 gnu tar-ustar silent-rules subdir-objects \
AM_INIT_AUTOMAKE([1.14 gnu silent-rules subdir-objects \
color-tests parallel-tests -Woverride -Wno-portability])
# Enable silent rules by default.
@@ -21,44 +21,43 @@ dnl For the C++ code. This must be used early.
AC_USE_SYSTEM_EXTENSIONS
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.19.1])
AM_GNU_GETTEXT_VERSION([0.18.1])
GUIX_SYSTEM_TYPE
GUIX_ASSERT_SUPPORTED_SYSTEM
GUIX_CHANNEL_METADATA
AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = "xyes"])
AC_ARG_WITH(store-dir,
AS_HELP_STRING([--with-store-dir=PATH],
AC_HELP_STRING([--with-store-dir=PATH],
[file name of the store (defaults to /gnu/store)]),
[storedir="$withval"],
[storedir="/gnu/store"])
AC_SUBST(storedir)
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir=DIR],
AC_HELP_STRING([--with-bash-completion-dir=DIR],
[name of the Bash completion directory]),
[bashcompletiondir="$withval"],
[bashcompletiondir='${sysconfdir}/bash_completion.d'])
AC_SUBST([bashcompletiondir])
AC_ARG_WITH([zsh-completion-dir],
AS_HELP_STRING([--with-zsh-completion-dir=DIR],
AC_HELP_STRING([--with-zsh-completion-dir=DIR],
[name of the Zsh completion directory]),
[zshcompletiondir="$withval"],
[zshcompletiondir='${datadir}/zsh/site-functions'])
AC_SUBST([zshcompletiondir])
AC_ARG_WITH([fish-completion-dir],
AS_HELP_STRING([--with-fish-completion-dir=DIR],
AC_HELP_STRING([--with-fish-completion-dir=DIR],
[name of the Fish completion directory]),
[fishcompletiondir="$withval"],
[fishcompletiondir='${datadir}/fish/vendor_completions.d'])
AC_SUBST([fishcompletiondir])
AC_ARG_WITH([selinux-policy-dir],
AS_HELP_STRING([--with-selinux-policy-dir=DIR],
AC_HELP_STRING([--with-selinux-policy-dir=DIR],
[name of the SELinux policy directory]),
[selinux_policydir="$withval"],
[selinux_policydir='${datadir}/selinux/'])
@@ -96,14 +95,15 @@ m4_pattern_forbid([^GUIX_])
dnl Search for 'guile' and 'guild'. This macro defines
dnl 'GUILE_EFFECTIVE_VERSION'.
GUILE_PKG([3.0])
GUILE_PKG([3.0 2.2])
GUILE_PROGS
if test "x$GUILD" = "x"; then
AC_MSG_ERROR(['guild' binary not found; please check your Guile installation.])
fi
dnl (guix ui), notably, requires 'default-optimization-level' added in 3.0.3.
PKG_CHECK_MODULES([GUILE], [guile-3.0 >= 3.0.3])
if test "x$GUILE_EFFECTIVE_VERSION" = "x2.2"; then
PKG_CHECK_MODULES([GUILE], [guile-2.2 >= 2.2.3])
fi
dnl Get CFLAGS and LDFLAGS for libguile.
GUILE_FLAGS
@@ -149,17 +149,10 @@ if test "x$guix_cv_have_recent_guile_git" != "xyes"; then
AC_MSG_ERROR([A recent Guile-Git could not be found; please install it.])
fi
dnl Check for the optional Guile-Lib.
GUILE_MODULE_EXPORTS([have_guile_lib], [(htmlprag)], [%strict-tokenizer?])
AM_CONDITIONAL([HAVE_GUILE_LIB], [test "x$have_guile_lib" = "xyes"])
AM_COND_IF(HAVE_GUILE_LIB,,
[AC_MSG_WARN([The Guile-Lib requirement was not satisfied (>= 0.2.7);
Some features such as the Go importer will not be usable.])])
dnl Check for Guile-zlib.
GUIX_CHECK_GUILE_ZLIB
if test "x$guix_cv_have_recent_guile_zlib" != "xyes"; then
AC_MSG_ERROR([A recent Guile-zlib could not be found; please install it.])
GUILE_MODULE_AVAILABLE([have_guile_zlib], [(zlib)])
if test "x$have_guile_zlib" != "xyes"; then
AC_MSG_ERROR([Guile-zlib is missing; please install it.])
fi
dnl Check for Guile-lzlib.
@@ -168,11 +161,6 @@ if test "x$have_guile_lzlib" != "xyes"; then
AC_MSG_ERROR([Guile-lzlib is missing; please install it.])
fi
dnl Check for Guile-Avahi.
GUILE_MODULE_AVAILABLE([have_guile_avahi], [(avahi)])
AM_CONDITIONAL([HAVE_GUILE_AVAHI],
[test "x$have_guile_avahi" = "xyes"])
dnl Guile-newt is used by the graphical installer.
GUILE_MODULE_AVAILABLE([have_guile_newt], [(newt)])
@@ -201,6 +189,36 @@ AC_SUBST([GZIP])
AC_SUBST([BZIP2])
AC_SUBST([XZ])
AC_ARG_WITH([nix-prefix],
[AS_HELP_STRING([--with-nix-prefix=DIR],
[search for Nix in DIR (for testing purposes and '--disable-daemon' builds)])],
[case "$withval" in
yes|no) ;;
*)
NIX_PREFIX="$withval"
PATH="$NIX_PREFIX/bin:$PATH"; export PATH
AC_SUBST([NIX_PREFIX])
;;
esac],
[])
AC_ARG_WITH([nixpkgs],
[AS_HELP_STRING([--with-nixpkgs=DIR],
[search for Nixpkgs in DIR (for testing purposes only)])],
[case "$withval" in
yes|no) AC_MSG_ERROR([Please use `--with-nixpkgs=DIR'.]);;
*) NIXPKGS="$withval";;
esac],
[])
AC_MSG_CHECKING([for Nixpkgs source tree])
if test -f "$NIXPKGS/default.nix"; then
AC_MSG_RESULT([$NIXPKGS])
AC_SUBST([NIXPKGS])
else
AC_MSG_RESULT([not found])
fi
LIBGCRYPT_LIBDIR="no"
LIBGCRYPT_PREFIX="no"
View File
+196 -392
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
;;;
;;; This file is part of GNU Guix.
@@ -63,9 +63,9 @@
"guix"))
(define %languages
;; The cookbook is not translated in the same languages as the manual
;; The cookbook is currently only translated into German.
(if (string=? %manual "guix-cookbook")
'("de" "en" "fr" "sk")
'("de" "en")
'("de" "en" "es" "fr" "ru" "zh_CN")))
(define (texinfo-manual-images source)
@@ -439,7 +439,6 @@ its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
("rarr" "→")
("hellip" "…")
("rsquo" "")
("nbsp" " ")
(e (pk 'unknown-entity e) (primitive-exit 2))))
(define (concatenate-snippets pieces)
@@ -600,175 +599,6 @@ its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
(computed-file name build))
(define* (stylized-html source input
#:key
(languages %languages)
(manual %manual)
(manual-css-url "/static/base/css/manual.css"))
"Process all the HTML files in INPUT; add them MANUAL-CSS-URL as a <style>
link, and add a menu to choose among LANGUAGES. Use the Guix PO files found
in SOURCE."
(define build
(with-extensions (list guile-lib)
(with-imported-modules `((guix build utils)
((localization)
=> ,(localization-helper-module
source languages)))
#~(begin
(use-modules (htmlprag)
(localization)
(guix build utils)
(srfi srfi-1)
(ice-9 match)
(ice-9 threads))
(define* (menu-dropdown #:key (label "Item") (url "#") (items '()))
;; Return an SHTML <li> element representing a dropdown for the
;; navbar. LABEL is the text of the dropdown menu, and ITEMS is
;; the list of items in this menu.
(define id "visible-dropdown")
`(li
(@ (class "navbar-menu-item dropdown dropdown-btn"))
(input (@ (class "navbar-menu-hidden-input")
(type "radio")
(name "dropdown")
(id ,id)))
(label (@ (for ,id)) ,label)
(label (@ (for "all-dropdowns-hidden")) ,label)
(div
(@ (class "navbar-submenu")
(id "navbar-submenu"))
(div (@ (class "navbar-submenu-triangle"))
" ")
(ul ,@items))))
(define (menu-item label url)
;; Return an SHTML <li> element for a menu item with the given
;; LABEL and URL.
`(li (a (@ (class "navbar-menu-item")
(href ,url))
,label)))
(define* (navigation-bar menus #:key split-node?)
;; Return the navigation bar showing all of MENUS.
`(header (@ (class "navbar"))
(h1 (a (@ (class "branding")
(href ,(if split-node? ".." "#")))))
(nav (@ (class "navbar-menu"))
(input (@ (class "navbar-menu-hidden-input")
(type "radio")
(name "dropdown")
(id "all-dropdowns-hidden")))
(ul ,@menus))
;; This is the button that shows up on small screen in
;; lieu of the drop-down button.
(a (@ (class "navbar-menu-btn")
(href ,(if split-node? "../.." ".."))))))
(define* (base-language-url code manual
#:key split-node?)
;; Return the base URL of MANUAL for language CODE.
(if split-node?
(string-append "../../" (normalize code) "/html_node")
(string-append "../" (normalize code) "/" manual
(if (string=? code "en")
""
(string-append "." code))
".html")))
(define (language-menu-items file)
;; Return the language menu items to be inserted in FILE.
(define split-node?
(string-contains file "/html_node/"))
(append
(map (lambda (code)
(menu-item (language-code->native-name code)
(base-language-url code #$manual
#:split-node?
split-node?)))
'#$%languages)
(list
(menu-item "⊕"
(if (string=? #$manual "guix-cookbook")
"https://translate.fedoraproject.org/projects/guix/documentation-cookbook/"
"https://translate.fedoraproject.org/projects/guix/documentation-manual/")))))
(define (stylized-html sxml file)
;; Return SXML, which was read from FILE, with additional
;; styling.
(define split-node?
(string-contains file "/html_node/"))
(let loop ((sxml sxml))
(match sxml
(('*TOP* decl body ...)
`(*TOP* ,decl ,@(map loop body)))
(('head elements ...)
;; Add reference to our own manual CSS, which provides
;; support for the language menu.
`(head ,@elements
(link (@ (rel "stylesheet")
(type "text/css")
(href #$manual-css-url)))))
(('body ('@ attributes ...) elements ...)
`(body (@ ,@attributes)
,(navigation-bar
;; TODO: Add "Contribute" menu, to report
;; errors, etc.
(list (menu-dropdown
#:label
`(img (@ (alt "Language")
(src "/static/base/img/language-picker.svg")))
#:items
(language-menu-items file)))
#:split-node? split-node?)
,@elements))
((tag ('@ attributes ...) body ...)
`(,tag (@ ,@attributes) ,@(map loop body)))
((tag body ...)
`(,tag ,@(map loop body)))
((? string? str)
str))))
(define (process-html file)
;; Parse FILE and add links to translations. Install the result
;; to #$output.
(format (current-error-port) "processing ~a...~%" file)
(let* ((shtml (parameterize ((%strict-tokenizer? #t))
(call-with-input-file file html->shtml)))
(processed (stylized-html shtml file))
(base (string-drop file (string-length #$input)))
(target (string-append #$output base)))
(mkdir-p (dirname target))
(call-with-output-file target
(lambda (port)
(write-shtml-as-html processed port)))))
;; Install a UTF-8 locale so we can process UTF-8 files.
(setenv "GUIX_LOCPATH"
#+(file-append glibc-utf8-locales "/lib/locale"))
(setlocale LC_ALL "en_US.utf8")
(setenv "LC_ALL" "en_US.utf8")
(setvbuf (current-error-port) 'line)
(n-par-for-each (parallel-job-count)
(lambda (file)
(if (string-suffix? ".html" file)
(process-html file)
;; Copy FILE as is to #$output.
(let* ((base (string-drop file (string-length #$input)))
(target (string-append #$output base)))
(mkdir-p (dirname target))
(if (eq? 'symlink (stat:type (lstat file)))
(symlink (readlink file) target)
(copy-file file target)))))
(find-files #$input))))))
(computed-file "stylized-html-manual" build))
(define* (html-manual source #:key (languages %languages)
(version "0.0")
(manual %manual)
@@ -859,11 +689,9 @@ makeinfo OPTIONS."
(filter (compose file-exists? language->texi-file-name)
'#$languages)))))
(let* ((name (string-append manual "-html-manual"))
(manual* (computed-file name build #:local-build? #f)))
(syntax-highlighted-html (stylized-html source manual*
#:languages languages
#:manual manual)
(let* ((name (string-append manual "-html-manual"))
(manual (computed-file name build)))
(syntax-highlighted-html manual
#:mono-node-indexes mono-node-indexes
#:split-node-indexes split-node-indexes
#:name (string-append name "-highlighted"))))
@@ -886,7 +714,7 @@ makeinfo OPTIONS."
;; accented letters.
;;
;; (define texlive
;; (texlive-updmap.cfg (list texlive-tex-texinfo
;; (texlive-union (list texlive-tex-texinfo
;; texlive-generic-epsf
;; texlive-fonts-ec)))
@@ -966,8 +794,7 @@ PDF for language '~a'!~%~%"
opts))))
'#$languages))))
(computed-file (string-append manual "-pdf-manual") build
#:local-build? #f))
(computed-file (string-append manual "-pdf-manual") build))
(define (guix-manual-text-domain source languages)
"Return the PO files for LANGUAGES of the 'guix-manual' text domain taken
@@ -996,104 +823,6 @@ from SOURCE."
(computed-file "guix-manual-po" build))
(define* (localization-helper-module source
#:optional (languages %languages))
"Return a file-like object for use as the (localization) module. SOURCE
must be the Guix top-level source directory, from which PO files are taken."
(define content
(with-extensions (list guile-json-3)
#~(begin
(define-module (localization)
#:use-module (json)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:export (normalize
with-language
translate
language-code->name
language-code->native-name
seconds->string))
(define (normalize language) ;XXX: deduplicate
;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
(string-map (match-lambda
(#\_ #\-)
(chr chr))
(string-downcase language)))
(define-syntax-rule (with-language language exp ...)
(let ((lang (getenv "LANGUAGE")))
(dynamic-wind
(lambda ()
(setenv "LANGUAGE" language)
(setlocale LC_MESSAGES))
(lambda () exp ...)
(lambda ()
(if lang
(setenv "LANGUAGE" lang)
(unsetenv "LANGUAGE"))
(setlocale LC_MESSAGES)))))
;; (put 'with-language 'scheme-indent-function 1)
(define* (translate str language
#:key (domain "guix-manual"))
(define exp
`(begin
(bindtextdomain "guix-manual"
#+(guix-manual-text-domain
source
languages))
(bindtextdomain "iso_639-3" ;language names
#+(file-append iso-codes
"/share/locale"))
(setenv "LANGUAGE" ,language)
(write (gettext ,str ,domain))))
;; Since the 'gettext' function caches msgid translations,
;; regardless of $LANGUAGE, we have to spawn a new process each
;; time we want to translate to a different language. Bah!
(let* ((pipe (open-pipe* OPEN_READ
#+(file-append guile-3.0
"/bin/guile")
"-c" (object->string exp)))
(str (read pipe)))
(close-pipe pipe)
str))
(define %iso639-languages
(vector->list
(assoc-ref (call-with-input-file
#+(file-append iso-codes
"/share/iso-codes/json/iso_639-3.json")
json->scm)
"639-3")))
(define (language-code->name code)
"Return the full name of a language from its ISO-639-3 code."
(let ((code (match (string-index code #\_)
(#f code)
(index (string-take code index)))))
(any (lambda (language)
(and (string=? (or (assoc-ref language "alpha_2")
(assoc-ref language "alpha_3"))
code)
(assoc-ref language "name")))
%iso639-languages)))
(define (language-code->native-name code)
"Return the name of language CODE in that language."
(translate (language-code->name code) code
#:domain "iso_639-3"))
(define (seconds->string seconds language)
(let* ((time (make-time time-utc 0 seconds))
(date (time-utc->date time)))
(with-language language (date->string date "~e ~B ~Y")))))))
(scheme-file "localization.scm" content))
(define* (html-manual-indexes source
#:key (languages %languages)
(version "0.0")
@@ -1103,132 +832,207 @@ must be the Guix top-level source directory, from which PO files are taken."
"GNU Guix Cookbook"))
(date 1))
(define build
(with-imported-modules `((guix build utils)
((localization)
=> ,(localization-helper-module
source languages)))
#~(begin
(use-modules (guix build utils)
(localization)
(sxml simple)
(srfi srfi-1))
(with-extensions (list guile-json-3)
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils)
(json)
(ice-9 match)
(ice-9 popen)
(sxml simple)
(srfi srfi-1)
(srfi srfi-19))
(define (guix-url path)
(string-append #$%web-site-url path))
(define (normalize language) ;XXX: deduplicate
;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
(string-map (match-lambda
(#\_ #\-)
(chr chr))
(string-downcase language)))
(define (sxml-index language title body)
;; FIXME: Avoid duplicating styling info from guix-artwork.git.
`(html (@ (lang ,language))
(head
(title ,(string-append title " — GNU Guix"))
(meta (@ (charset "UTF-8")))
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
;; Menu prefetch.
(link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
;; Base CSS.
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
(define-syntax-rule (with-language language exp ...)
(let ((lang (getenv "LANGUAGE")))
(dynamic-wind
(lambda ()
(setenv "LANGUAGE" language)
(setlocale LC_MESSAGES))
(lambda () exp ...)
(lambda ()
(if lang
(setenv "LANGUAGE" lang)
(unsetenv "LANGUAGE"))
(setlocale LC_MESSAGES)))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
(body
(header (@ (class "navbar"))
(h1 (a (@ (class "branding")
(href #$%web-site-url)))
(span (@ (class "a11y-offset"))
"Guix"))
(nav (@ (class "menu"))))
(nav (@ (class "breadcrumbs"))
(a (@ (class "crumb")
(href #$%web-site-url))
"Home"))
,body
(footer))))
;; (put 'with-language 'scheme-indent-function 1)
(define* (translate str language
#:key (domain "guix-manual"))
(define exp
`(begin
(bindtextdomain "guix-manual"
#+(guix-manual-text-domain
source
languages))
(bindtextdomain "iso_639-3" ;language names
#+(file-append iso-codes
"/share/locale"))
(write (gettext ,str ,domain))))
(define (language-index language)
(define title
(translate #$title language))
(with-language language
;; Since the 'gettext' function caches msgid translations,
;; regardless of $LANGUAGE, we have to spawn a new process each
;; time we want to translate to a different language. Bah!
(let* ((pipe (open-pipe* OPEN_READ
#+(file-append guile-2.2
"/bin/guile")
"-c" (object->string exp)))
(str (read pipe)))
(close-pipe pipe)
str)))
(sxml-index
language title
`(main
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(p (@ (class "post-metadata centered-text"))
#$version " — "
,(seconds->string #$date language))
(define (seconds->string seconds language)
(let* ((time (make-time time-utc 0 seconds))
(date (time-utc->date time)))
(with-language language (date->string date "~e ~B ~Y"))))
(div
(ul
(li (a (@ (href "html_node"))
"HTML, with a separate page per node"))
(li (a (@ (href
,(string-append
#$manual
(if (string=? language
"en")
""
(string-append "."
language))
".html")))
"HTML, entirely on one page"))
,@(if (member language '("ru" "zh_CN"))
'()
`((li (a (@ (href ,(string-append
#$manual
(if (string=? language "en")
""
(string-append "."
language))
".pdf"))))
"PDF")))))))))
(define (guix-url path)
(string-append #$%web-site-url path))
(define (top-level-index languages)
(define title #$title)
(sxml-index
"en" title
`(main
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(div
"This document is available in the following
(define (sxml-index language title body)
;; FIXME: Avoid duplicating styling info from guix-artwork.git.
`(html (@ (lang ,language))
(head
(title ,(string-append title " — GNU Guix"))
(meta (@ (charset "UTF-8")))
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
;; Menu prefetch.
(link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
;; Base CSS.
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
(link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
(body
(header (@ (class "navbar"))
(h1 (a (@ (class "branding")
(href #$%web-site-url)))
(span (@ (class "a11y-offset"))
"Guix"))
(nav (@ (class "menu"))))
(nav (@ (class "breadcrumbs"))
(a (@ (class "crumb")
(href #$%web-site-url))
"Home"))
,body
(footer))))
(define (language-index language)
(define title
(translate #$title language))
(sxml-index
language title
`(main
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(p (@ (class "post-metadata centered-text"))
#$version " — "
,(seconds->string #$date language))
(div
(ul
(li (a (@ (href "html_node"))
"HTML, with one page per node"))
(li (a (@ (href
,(string-append
#$manual
(if (string=? language
"en")
""
(string-append "."
language))
".html")))
"HTML, entirely on one page"))
,@(if (member language '("ru" "zh_CN"))
'()
`((li (a (@ (href ,(string-append
#$manual
(if (string=? language "en")
""
(string-append "."
language))
".pdf"))))
"PDF")))))))))
(define %iso639-languages
(vector->list
(assoc-ref (call-with-input-file
#+(file-append iso-codes
"/share/iso-codes/json/iso_639-3.json")
json->scm)
"639-3")))
(define (language-code->name code)
"Return the full name of a language from its ISO-639-3 code."
(let ((code (match (string-index code #\_)
(#f code)
(index (string-take code index)))))
(any (lambda (language)
(and (string=? (or (assoc-ref language "alpha_2")
(assoc-ref language "alpha_3"))
code)
(assoc-ref language "name")))
%iso639-languages)))
(define (top-level-index languages)
(define title #$title)
(sxml-index
"en" title
`(main
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(div
"This document is available in the following
languages:\n"
(ul
,@(map (lambda (language)
`(li (a (@ (href ,(normalize language)))
,(language-code->native-name language))))
languages)))))))
(ul
,@(map (lambda (language)
`(li (a (@ (href ,(normalize language)))
,(translate
(language-code->name language)
language
#:domain "iso_639-3"))))
languages)))))))
(define (write-html file sxml)
(call-with-output-file file
(lambda (port)
(display "<!DOCTYPE html>\n" port)
(sxml->xml sxml port))))
(define (write-html file sxml)
(call-with-output-file file
(lambda (port)
(display "<!DOCTYPE html>\n" port)
(sxml->xml sxml port))))
(setenv "GUIX_LOCPATH"
#+(file-append glibc-utf8-locales "/lib/locale"))
(setenv "LC_ALL" "en_US.utf8")
(setlocale LC_ALL "en_US.utf8")
(setenv "GUIX_LOCPATH"
#+(file-append glibc-utf8-locales "/lib/locale"))
(setenv "LC_ALL" "en_US.utf8")
(setlocale LC_ALL "en_US.utf8")
(for-each (lambda (language)
(define directory
(string-append #$output "/"
(normalize language)))
(for-each (lambda (language)
(define directory
(string-append #$output "/"
(normalize language)))
(mkdir-p directory)
(write-html (string-append directory "/index.html")
(language-index language)))
'#$languages)
(mkdir-p directory)
(write-html (string-append directory "/index.html")
(language-index language)))
'#$languages)
(write-html (string-append #$output "/index.html")
(top-level-index '#$languages)))))
(write-html (string-append #$output "/index.html")
(top-level-index '#$languages))))))
(computed-file "html-indexes" build))
+90 -678
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -6,7 +6,8 @@
;; Augment the package definition of GDB with the build tools
;; needed when developing GDB (and which are not needed when
;; simply installing it.)
(package
(inherit gdb)
(native-inputs (modify-inputs (package-native-inputs gdb)
(prepend autoconf-2.64 automake texinfo))))
(package (inherit gdb)
(native-inputs `(("autoconf" ,autoconf-2.64)
("automake" ,automake)
("texinfo" ,texinfo)
,@(package-native-inputs gdb))))
+89 -349
View File
@@ -7,9 +7,6 @@
@settitle GNU Guix Cookbook
@c %**end of header
@c Onion service for ci.guix.gnu.org.
@set SUBSTITUTE-TOR-URL https://4zwzi66wwdaalbhgnix55ea3ab4pvvw66ll2ow53kjub6se4q2bclcyd.onion
@copying
Copyright @copyright{} 2019 Ricardo Wurmus@*
Copyright @copyright{} 2019 Efraim Flashner@*
@@ -19,8 +16,7 @@ Copyright @copyright{} 2020 Matthew Brooks@*
Copyright @copyright{} 2020 Marcin Karpezo@*
Copyright @copyright{} 2020 Brice Waegeneire@*
Copyright @copyright{} 2020 André Batista@*
Copyright @copyright{} 2020 Christine Lemmer-Webber@*
Copyright @copyright{} 2021 Joshua Branson@*
Copyright @copyright{} 2020 Christopher Lemmer Webber
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -60,12 +56,9 @@ its API, and related concepts.
@c TRANSLATORS: You can replace the following paragraph with information on
@c how to join your own translation team and how to report issues with the
@c translation.
This manual is also available in French (@pxref{Top,,, guix-cookbook.fr,
Livre de recettes de GNU Guix}) and German (@pxref{Top,,,
guix-cookbook.de, GNU-Guix-Kochbuch}). If you would like to translate
this document in your native language, consider joining
@uref{https://translate.fedoraproject.org/projects/guix/documentation-cookbook,
Weblate} (@pxref{Translating Guix,,, guix, GNU Guix reference manual}).
If you would like to translate this document in your native language, consider
joining the @uref{https://translationproject.org/domain/guix-cookbook.html,
Translation Project}.
@menu
* Scheme tutorials:: Meet your new favorite language!
@@ -91,8 +84,8 @@ Packaging
System Configuration
* Auto-Login to a Specific TTY:: Automatically Login a User to a Specific TTY
* Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System.
* Customizing the Kernel:: Creating and using a custom Linux kernel
@end detailmenu
@end menu
@@ -596,7 +589,7 @@ packages.
Guix makes it possible to streamline the process by adding as many ``package
declaration directories'' as you want.
Create a directory, say @file{~/guix-packages} and add it to the @samp{GUIX_PACKAGE_PATH}
Create a directory, say @file{~./guix-packages} and add it to the @samp{GUIX_PACKAGE_PATH}
environment variable:
@example
@@ -798,8 +791,10 @@ another, more sophisticated package (slightly modified from the source):
"17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3"))
(patches (search-patches "libgit2-mtime-0.patch"))
(modules '((guix build utils)))
;; Remove bundled software.
(snippet '(delete-file-recursively "deps"))))
(snippet '(begin
;; Remove bundled software.
(delete-file-recursively "deps")
#true))))
(build-system cmake-build-system)
(outputs '("out" "debug"))
(arguments
@@ -813,19 +808,23 @@ another, more sophisticated package (slightly modified from the source):
(("#!/bin/sh") (string-append "#!" (which "sh"))))
(substitute* "tests/clar/fs.h"
(("/bin/cp") (which "cp"))
(("/bin/rm") (which "rm")))))
(("/bin/rm") (which "rm")))
#true))
;; Run checks more verbosely.
(replace 'check
(lambda _ (invoke "./libgit2_clar" "-v" "-Q")))
(add-after 'unpack 'make-files-writable-for-tests
(lambda _ (for-each make-file-writable (find-files "." ".*")))))))
(inputs
(list libssh2 http-parser python-wrapper))
`(("libssh2" ,libssh2)
("http-parser" ,http-parser)
("python" ,python-wrapper)))
(native-inputs
(list pkg-config))
`(("pkg-config" ,pkg-config)))
(propagated-inputs
;; These two libraries are in 'Requires.private' in libgit2.pc.
(list openssl zlib))
`(("openssl" ,openssl)
("zlib" ,zlib)))
(home-page "https://libgit2.github.com/")
(synopsis "Library providing Git core methods")
(description
@@ -889,6 +888,22 @@ Snippets might need additional Guile modules which can be imported from the
@subsubsection Inputs
First, a syntactic comment: See the quasi-quote / comma syntax?
@lisp
(native-inputs
`(("pkg-config" ,pkg-config)))
@end lisp
is equivalent to
@lisp
(native-inputs
(list (list "pkg-config" pkg-config)))
@end lisp
You'll mostly see the former because it's shorter.
There are 3 different input types. In short:
@table @asis
@@ -922,24 +937,6 @@ It also matters when a substitute is available, in which case only the @emph{inp
and @emph{propagated inputs} will be fetched: the @emph{native inputs} are not required to
install a package from a substitute.
@quotation Note
You may see here and there snippets where package inputs are written
quite differently, like so:
@lisp
;; The "old style" for inputs.
(inputs
`(("libssh2" ,libssh2)
("http-parser" ,http-parser)
("python" ,python-wrapper)))
@end lisp
This is the ``old style'', where each input in the list is explicitly
given a label (a string). It is still supported but we recommend using
the style above instead. @xref{package Reference,,, guix, GNU Guix
Reference Manual}, for more info.
@end quotation
@subsubsection Outputs
Just like how a package can have multiple inputs, it can also produce multiple
@@ -1225,7 +1222,10 @@ $ guix import cran --recursive walrus
"1nk2glcvy4hyksl5ipq2mz8jy4fss90hx6cq98m3w96kzjni6jjj"))))
(build-system r-build-system)
(propagated-inputs
(list r-ggplot2 r-jmvcore r-r6 r-wrs2))
`(("r-ggplot2" ,r-ggplot2)
("r-jmvcore" ,r-jmvcore)
("r-r6" ,r-r6)
("r-wrs2" ,r-wrs2)))
(home-page "https://github.com/jamovi/walrus")
(synopsis "Robust Statistical Methods")
(description
@@ -1284,7 +1284,8 @@ noticed that a significant number of them have a @code{inherit} field:
(sha256
(base32
"17fpahgh5dyckgz7rwqvzgnhx53cx9kr2xw0szprc6bnqy977fi8"))))
(native-inputs (list `(,gtk+ "bin")))))
(native-inputs
`(("gtk-encode-symbolic-svg" ,gtk+ "bin")))))
@end lisp
All unspecified fields are inherited from the parent package. This is very
@@ -1351,9 +1352,7 @@ chapter is to demonstrate some advanced configuration concepts.
reference.
@menu
* Auto-Login to a Specific TTY:: Automatically Login a User to a Specific TTY
* Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System.
* Guix System Image API:: Customizing images to target specific platforms.
* Connecting to Wireguard VPN:: Connecting to a Wireguard VPN.
* Customizing a Window Manager:: Handle customization of a Window manager on Guix System.
* Running Guix on a Linode Server:: Running Guix on a Linode Server
@@ -1362,51 +1361,6 @@ reference.
* Setting up NGINX with Lua:: Configuring NGINX web-server to load Lua modules.
@end menu
@node Auto-Login to a Specific TTY
@section Auto-Login to a Specific TTY
While the Guix manual explains auto-login one user to @emph{all} TTYs (
@pxref{auto-login to TTY,,, guix, GNU Guix Reference Manual}), some
might prefer a situation, in which one user is logged into one TTY with
the other TTYs either configured to login different users or no one at
all. Note that one can auto-login one user to any TTY, but it is
usually advisable to avoid @code{tty1}, which, by default, is used to
log warnings and errors.
Here is how one might set up auto login for one user to one tty:
@lisp
(define (auto-login-to-tty config tty user)
(if (string=? tty (mingetty-configuration-tty config))
(mingetty-configuration
(inherit config)
(auto-login user))
config))
(define %my-services
(modify-services %base-services
;; @dots{}
(mingetty-service-type config =>
(auto-login-to-tty
config "tty3" "alice"))))
(operating-system
;; @dots{}
(services %my-services))
@end lisp
One could also @code{compose} (@pxref{Higher-Order Functions,,, guile,
The Guile Reference Manual}) @code{auto-login-to-tty} to login multiple
users to multiple ttys.
Finally, here is a note of caution. Setting up auto login to a TTY,
means that anyone can turn on your computer and run commands as your
regular user.
However, if you have an encrypted root partition, and thus already need
to enter a passphrase when the system boots, auto-login might be a
convenient option.
@node Customizing the Kernel
@section Customizing the Kernel
@@ -1433,34 +1387,37 @@ The @code{linux-libre} kernel package definition is actually a procedure which
creates a package.
@lisp
(define* (make-linux-libre* version gnu-revision source supported-systems
#:key
(extra-version #f)
;; A function that takes an arch and a variant.
;; See kernel-config for an example.
(configuration-file #f)
(defconfig "defconfig")
(extra-options %default-extra-linux-options))
(define* (make-linux-libre version hash supported-systems
#:key
;; A function that takes an arch and a variant.
;; See kernel-config for an example.
(extra-version #false)
(configuration-file #false)
(defconfig "defconfig")
(extra-options %default-extra-linux-options)
(patches (list %boot-logo-patch)))
...)
@end lisp
The current @code{linux-libre} package is for the 5.15.x series, and is
The current @code{linux-libre} package is for the 5.1.x series, and is
declared like this:
@lisp
(define-public linux-libre-5.15
(make-linux-libre* linux-libre-5.15-version
linux-libre-5.15-gnu-revision
linux-libre-5.15-source
'("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux")
#:configuration-file kernel-config))
(define-public linux-libre
(make-linux-libre %linux-libre-version
%linux-libre-hash
'("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
#:patches %linux-libre-5.1-patches
#:configuration-file kernel-config))
@end lisp
Any keys which are not assigned values inherit their default value from the
@code{make-linux-libre} definition. When comparing the two snippets above,
notice the code comment that refers to @code{#:configuration-file}. Because of
this, it is not actually easy to include a custom kernel configuration from the
definition, but don't worry, there are other ways to work with what we do have.
you may notice that the code comment in the first doesn't actually refer to
the @code{#:extra-version} keyword; it is actually for
@code{#:configuration-file}. Because of this, it is not actually easy to
include a custom kernel configuration from the definition, but don't worry,
there are other ways to work with what we do have.
There are two ways to create a kernel with a custom kernel configuration. The
first is to provide a standard @file{.config} file during the build process by
@@ -1560,15 +1517,14 @@ custom kernel:
(@@@@ (gnu packages linux) %default-extra-linux-options)))
(define-public linux-libre-macbook41
;; XXX: Access the internal 'make-linux-libre*' procedure, which is
;; XXX: Access the internal 'make-linux-libre' procedure, which is
;; private and unexported, and is liable to change in the future.
((@@@@ (gnu packages linux) make-linux-libre*)
(@@@@ (gnu packages linux) linux-libre-version)
(@@@@ (gnu packages linux) linux-libre-gnu-revision)
(@@@@ (gnu packages linux) linux-libre-source)
'("x86_64-linux")
#:extra-version "macbook41"
#:extra-options %macbook41-config-options))
((@@@@ (gnu packages linux) make-linux-libre) (@@@@ (gnu packages linux) %linux-libre-version)
(@@@@ (gnu packages linux) %linux-libre-hash)
'("x86_64-linux")
#:extra-version "macbook41"
#:patches (@@@@ (gnu packages linux) %linux-libre-5.1-patches)
#:extra-options %macbook41-config-options))
@end lisp
In the above example @code{%file-systems} is a collection of flags enabling
@@ -1645,217 +1601,6 @@ likely that you'll need to modify the initrd on a machine using a custom
kernel, since certain modules which are expected to be built may not be
available for inclusion into the initrd.
@node Guix System Image API
@section Guix System Image API
Historically, Guix System is centered around an @code{operating-system}
structure. This structure contains various fields ranging from the
bootloader and kernel declaration to the services to install.
Depending on the target machine, that can go from a standard
@code{x86_64} machine to a small ARM single board computer such as the
Pine64, the image constraints can vary a lot. The hardware
manufacturers will impose different image formats with various partition
sizes and offsets.
To create images suitable for all those machines, a new abstraction is
necessary: that's the goal of the @code{image} record. This record
contains all the required information to be transformed into a
standalone image, that can be directly booted on any target machine.
@lisp
(define-record-type* <image>
image make-image
image?
(name image-name ;symbol
(default #f))
(format image-format) ;symbol
(target image-target
(default #f))
(size image-size ;size in bytes as integer
(default 'guess))
(operating-system image-operating-system ;<operating-system>
(default #f))
(partitions image-partitions ;list of <partition>
(default '()))
(compression? image-compression? ;boolean
(default #t))
(volatile-root? image-volatile-root? ;boolean
(default #t))
(substitutable? image-substitutable? ;boolean
(default #t)))
@end lisp
This record contains the operating-system to instantiate. The
@code{format} field defines the image type and can be @code{efi-raw},
@code{qcow2} or @code{iso9660} for instance. In the future, it could be
extended to @code{docker} or other image types.
A new directory in the Guix sources is dedicated to images definition. For now
there are four files:
@itemize @bullet
@item @file{gnu/system/images/hurd.scm}
@item @file{gnu/system/images/pine64.scm}
@item @file{gnu/system/images/novena.scm}
@item @file{gnu/system/images/pinebook-pro.scm}
@end itemize
Let's have a look to @file{pine64.scm}. It contains the
@code{pine64-barebones-os} variable which is a minimal definition of an
operating-system dedicated to the @b{Pine A64 LTS} board.
@lisp
(define pine64-barebones-os
(operating-system
(host-name "vignemale")
(timezone "Europe/Paris")
(locale "en_US.utf8")
(bootloader (bootloader-configuration
(bootloader u-boot-pine64-lts-bootloader)
(targets '("/dev/vda"))))
(initrd-modules '())
(kernel linux-libre-arm64-generic)
(file-systems (cons (file-system
(device (file-system-label "my-root"))
(mount-point "/")
(type "ext4"))
%base-file-systems))
(services (cons (service agetty-service-type
(agetty-configuration
(extra-options '("-L")) ; no carrier detect
(baud-rate "115200")
(term "vt100")
(tty "ttyS0")))
%base-services))))
@end lisp
The @code{kernel} and @code{bootloader} fields are pointing to packages
dedicated to this board.
Right below, the @code{pine64-image-type} variable is also defined.
@lisp
(define pine64-image-type
(image-type
(name 'pine64-raw)
(constructor (cut image-with-os arm64-disk-image <>))))
@end lisp
It's using a record we haven't talked about yet, the @code{image-type} record,
defined this way:
@lisp
(define-record-type* <image-type>
image-type make-image-type
image-type?
(name image-type-name) ;symbol
(constructor image-type-constructor)) ;<operating-system> -> <image>
@end lisp
The main purpose of this record is to associate a name to a procedure
transforming an @code{operating-system} to an image. To understand why
it is necessary, let's have a look to the command producing an image
from an @code{operating-system} configuration file:
@example
guix system image my-os.scm
@end example
This command expects an @code{operating-system} configuration but how
should we indicate that we want an image targeting a Pine64 board? We
need to provide an extra information, the @code{image-type}, by passing
the @code{--image-type} or @code{-t} flag, this way:
@example
guix system image --image-type=pine64-raw my-os.scm
@end example
This @code{image-type} parameter points to the @code{pine64-image-type}
defined above. Hence, the @code{operating-system} declared in
@code{my-os.scm} will be applied the @code{(cut image-with-os
arm64-disk-image <>)} procedure to turn it into an image.
The resulting image looks like:
@lisp
(image
(format 'disk-image)
(target "aarch64-linux-gnu")
(operating-system my-os)
(partitions
(list (partition
(inherit root-partition)
(offset root-offset)))))
@end lisp
which is the aggregation of the @code{operating-system} defined in
@code{my-os.scm} to the @code{arm64-disk-image} record.
But enough Scheme madness. What does this image API bring to the Guix user?
One can run:
@example
mathieu@@cervin:~$ guix system --list-image-types
The available image types are:
- pinebook-pro-raw
- pine64-raw
- novena-raw
- hurd-raw
- hurd-qcow2
- qcow2
- uncompressed-iso9660
- efi-raw
- arm64-raw
- arm32-raw
- iso9660
@end example
and by writing an @code{operating-system} file based on
@code{pine64-barebones-os}, you can customize your image to your
preferences in a file (@file{my-pine-os.scm}) like this:
@lisp
(use-modules (gnu services linux)
(gnu system images pine64))
(let ((base-os pine64-barebones-os))
(operating-system
(inherit base-os)
(timezone "America/Indiana/Indianapolis")
(services
(cons
(service earlyoom-service-type
(earlyoom-configuration
(prefer-regexp "icecat|chromium")))
(operating-system-user-services base-os)))))
@end lisp
run:
@example
guix system image --image-type=pine64-raw my-pine-os.scm
@end example
or,
@example
guix system image --image-type=hurd-raw my-hurd-os.scm
@end example
to get an image that can be written directly to a hard drive and booted
from.
Without changing anything to @code{my-hurd-os.scm}, calling:
@example
guix system image --image-type=hurd-qcow2 my-hurd-os.scm
@end example
will instead produce a Hurd QEMU image.
@node Connecting to Wireguard VPN
@section Connecting to Wireguard VPN
@@ -2045,12 +1790,10 @@ Copy into it the output of:
cat ~/.ssh/<username>_rsa.pub
@end example
Power the Linode down.
In the Linode's Storage tab, resize the Debian disk to be smaller.
30 GB free space is recommended. Then click "Add a disk", and fill
out the form with the following:
Power the Linode down. In the Linode's Disks/Configurations tab, resize
the Debian disk to be smaller. 30 GB is recommended.
In the Linode settings, "Add a disk", with the following:
@itemize @bullet
@item
Label: "Guix"
@@ -2062,9 +1805,9 @@ Filesystem: ext4
Set it to the remaining size
@end itemize
In the Configurations tab, press "Edit" on the default Debian profile.
Under "Block Device Assignment" click "Add a Device". It should be
@file{/dev/sdc} and you can select the "Guix" disk. Save Changes.
On the "configuration" field that comes with the default image, press
"..." and select "Edit", then on that menu add to @file{/dev/sdc} the "Guix"
label.
Now "Add a Configuration", with the following:
@itemize @bullet
@@ -2090,8 +1833,8 @@ Root device: @file{/dev/sda}
Turn off all the filesystem/boot helpers
@end itemize
Now power it back up, booting with the Debian configuration. Once it's
running, ssh to your server via @code{ssh
Now power it back up, picking the Debian configuration. Once it's
booted up, ssh in your server via @code{ssh
root@@@var{<your-server-IP-here>}}. (You can find your server IP address in
your Linode Summary section.) Now you can run the "install guix from
@pxref{Binary Installation,,, guix, GNU Guix}" steps:
@@ -2180,20 +1923,19 @@ Replace the following fields in the above configuration:
@end lisp
The last line in the above example lets you log into the server as root
and set the initial root password (see the note at the end of this
recipe about root login). After you have done this, you may
and set the initial root password. After you have done this, you may
delete that line from your configuration and reconfigure to prevent root
login.
Copy your ssh public key (eg: @file{~/.ssh/id_rsa.pub}) as
@file{@var{<your-username-here>}_rsa.pub} and put
Save your ssh public key (eg: @file{~/.ssh/id_rsa.pub}) as
@file{@var{<your-username-here>}_rsa.pub} and your
@file{guix-config.scm} in the same directory. In a new terminal run
these commands.
@example
sftp root@@<remote server ip address>
put /path/to/files/<username>_rsa.pub .
put /path/to/files/guix-config.scm .
put /home/<username>/ssh/id_rsa.pub .
put /path/to/linode/guix-config.scm .
@end example
In your first terminal, mount the guix drive:
@@ -2203,9 +1945,9 @@ mkdir /mnt/guix
mount /dev/sdc /mnt/guix
@end example
Due to the way we set up the bootloader section of the guix-config.scm,
only the grub configuration file will be installed. So, we need to copy
over some of the other GRUB stuff already installed on the Debian system:
Due to the way we set things up above, we do not install GRUB
completely. Instead we install only our grub configuration file. So we
need to copy over some of the other GRUB stuff that is already there:
@example
mkdir -p /mnt/guix/boot/grub
@@ -2258,7 +2000,7 @@ still need to set your root and user password initially by clicking on
the ``Launch Console'' option in your linode. Choose the ``Glish''
instead of ``Weblish''. Now you should be able to ssh into the machine.
Hooray! At this point you can shut down the server, delete the
Horray! At this point you can shut down the server, delete the
Debian disk, and resize the Guix to the rest of the size.
Congratulations!
@@ -2357,8 +2099,7 @@ follow:
config => (guix-configuration
(inherit config)
;; ci.guix.gnu.org's Onion service
(substitute-urls
"@value{SUBSTITUTE-TOR-URL}")
(substitute-urls "https://bp7o7ckwlewr4slm.onion")
(http-proxy "http://localhost:9250")))))))
@end lisp
@@ -2376,8 +2117,7 @@ want to get a substitute from the Tor tunnel run:
@example
sudo herd set-http-proxy guix-daemon http://localhost:9250
guix build \
--substitute-urls=@value{SUBSTITUTE-TOR-URL} @dots{}
guix build --substitute-urls=https://bp7o7ckwlewr4slm.onion …
@end example
@node Setting up NGINX with Lua
@@ -2505,7 +2245,7 @@ section on @ref{Reproducible profiles}.
@item
Easier upgrades and maintenance: Multiple profiles make it easy to keep
package listings at hand and make upgrades completely frictionless.
package listings at hand and make upgrades completely friction-less.
@end itemize
Concretely, here follows some typical profiles:
+1422 -8401
View File
File diff suppressed because it is too large Load Diff
-24
View File
@@ -1,24 +0,0 @@
(use-modules (gnu home)
(gnu home services)
(gnu home services shells)
(gnu services)
(gnu packages admin)
(guix gexp))
(home-environment
(packages (list htop))
(services
(list
(service home-bash-service-type
(home-bash-configuration
(guix-defaults? #t)
(bash-profile '("\
export HISTFILE=$XDG_CACHE_HOME/.bash_history"))))
(simple-service 'test-config
home-files-service-type
(list `("config/test.conf"
,(plain-file "tmp-file.txt"
"the content of ~/.config/test.conf")))))))
+25 -51
View File
@@ -1,9 +1,9 @@
# htmlxref.cnf - reference file for free Texinfo manuals on the web.
# Modified by Ludovic Courtès <ludo@gnu.org> for the GNU Guix manual.
htmlxrefversion=2021-09-24.23; # UTC
htmlxrefversion=2020-01-11.22; # UTC
# Copyright 2010-2020 Free Software Foundation, Inc.
# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2019, 2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
@@ -110,10 +110,6 @@ cpio node ${GS}/cpio/manual/html_node/
cssc node ${GS}/cssc/manual/
CUIRASS = ${GS}/guix/cuirass/manual
cuirass mono ${CUIRASS}/cuirass.html
cuirass node ${CUIRASS}/html_node/
CVS = ${GS}/trans-coord/manual
cvs mono ${CVS}/cvs/cvs.html
cvs node ${CVS}/cvs/html_node/
@@ -122,8 +118,6 @@ ddd mono ${GS}/ddd/manual/html_mono/ddd.html
ddrescue mono ${GS}/ddrescue/manual/ddrescue_manual.html
dejagnu node ${GS}/dejagnu/manual/
DICO = https://puszcza.gnu.org.ua/software/dico/manual
dico mono ${DICO}/dico.html
dico chapter ${DICO}/html_chapter/
@@ -133,9 +127,6 @@ dico node ${DICO}/html_node/
diffutils mono ${GS}/diffutils/manual/diffutils
diffutils node ${GS}/diffutils/manual/html_node/
dmd mono ${GS}/dmd/manual/dmd
dmd node ${GS}/dmd/manual/html_node/
ed mono ${GS}/ed/manual/ed_manual.html
EMACS = ${GS}/emacs/manual
@@ -190,9 +181,6 @@ emacs node ${EMACS}/html_node/emacs/
idlwave mono ${EMACS}/html_mono/idlwave.html
idlwave node ${EMACS}/html_node/idlwave/
#
info mono ${EMACS}/html_mono/info.html
info node ${EMACS}/html_node/info/
#
message mono ${EMACS}/html_mono/message.html
message node ${EMACS}/html_node/message/
#
@@ -271,7 +259,7 @@ gcc node ${GCC}/gcc/
gcj node ${GCC}/gcj/
gfortran node ${GCC}/gfortran/
gnat_rm node ${GCC}/gnat_rm/
gnat_ugn node ${GCC}/gnat_ugn/
gnat_ugn_unw node ${GCC}/gnat_ugn_unw/
libgomp node ${GCC}/libgomp/
libstdc++ node ${GCC}/libstdc++/
#
@@ -300,11 +288,6 @@ gettext node ${GS}/gettext/manual/html_node/
gforth node https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/
# Also found at:
# https://mirrors.edge.kernel.org/pub/software/scm/git/docs/user-manual.html
# https://git.github.io/htmldocs/user-manual.html
git mono https://git-scm.com/docs/user-manual
global mono ${GS}/global/manual/global.html
gmediaserver node ${GS}/gmediaserver/manual/
@@ -352,8 +335,8 @@ GNUSTANDARDS = ${G}/prep
standards mono ${GNUSTANDARDS}/standards/standards.html
standards node ${GNUSTANDARDS}/standards/html_node/
gnutls mono ${GS}/gnutls/manual/gnutls.html
gnutls node ${GS}/gnutls/manual/html_node/
gnutls mono http://gnutls.org/manual/gnutls.html
gnutls node http://gnutls.org/manual/html_node/
gnutls-guile mono http://gnutls.org/manual/gnutls-guile.html
gnutls-guile node http://gnutls.org/manual/gnutls-guile/
@@ -414,27 +397,18 @@ guile-gtk node ${GS}/guile-gtk/docs/guile-gtk/
guile-rpc mono ${GS}/guile-rpc/manual/guile-rpc.html
guile-rpc node ${GS}/guile-rpc/manual/html_node/
GUIX = ${GS}/guix/manual
guix.de mono ${GUIX}/de/guix.de.html
guix.de node ${GUIX}/de/html_node/
guix.es mono ${GUIX}/es/guix.es.html
guix.es node ${GUIX}/es/html_node/
guix.fr mono ${GUIX}/fr/guix.fr.html
guix.fr node ${GUIX}/fr/html_node/
guix.ru mono ${GUIX}/ru/guix.ru.html
guix.ru node ${GUIX}/ru/html_node/
guix.zh_CN mono ${GUIX}/zh-cn/guix.zh_CN.html
guix.zh_CN node ${GUIX}/zh-cn/html_node/
guix mono ${GUIX}/en/guix.html
guix node ${GUIX}/en/html_node/
GUIX_COOKBOOK = ${GS}/guix/cookbook
guix-cookbook.de mono ${GUIX_COOKBOOK}/de/guix-cookbook.html
guix-cookbook.de node ${GUIX_COOKBOOK}/de/html_node/
guix-cookbook.fr mono ${GUIX_COOKBOOK}/fr/guix-cookbook.html
guix-cookbook.fr node ${GUIX_COOKBOOK}/fr/html_node/
guix-cookbook mono ${GUIX_COOKBOOK}/en/guix-cookbook.html
guix-cookbook node ${GUIX_COOKBOOK}/en/html_node/
guix.de mono ${GS}/guix/manual/de/guix.html
guix.de node ${GS}/guix/manual/de/html_node/
guix.es mono ${GS}/guix/manual/es/guix.html
guix.es node ${GS}/guix/manual/es/html_node/
guix.fr mono ${GS}/guix/manual/fr/guix.html
guix.fr node ${GS}/guix/manual/fr/html_node/
guix.ru mono ${GS}/guix/manual/ru/guix.html
guix.ru node ${GS}/guix/manual/ru/html_node/
guix.zh_CN mono ${GS}/guix/manual/zh-cn/guix.html
guix.zh_CN node ${GS}/guix/manual/zh-cn/html_node/
guix mono ${GS}/guix/manual/en/guix.html
guix node ${GS}/guix/manual/en/html_node/
gv mono ${GS}/gv/manual/gv.html
gv node ${GS}/gv/manual/html_node/
@@ -529,21 +503,18 @@ mcron node ${GS}/mcron/manual/html_node/
mdk mono ${GS}/mdk/manual/mdk.html
mdk node ${GS}/mdk/manual/html_node/
METAEXCHANGE = https://ftp.gwdg.de/pub/gnu2/iwfmdh/doc/texinfo
METAEXCHANGE = http://ftp.gwdg.de/pub/gnu2/iwfmdh/doc/texinfo
iwf_mh node ${METAEXCHANGE}/iwf_mh.html
scantest node ${METAEXCHANGE}/scantest.html
mes mono ${GS}/mes/manual/mes.html
mes node ${GS}/mes/manual/html_node/
MIT_SCHEME = ${GS}/mit-scheme/documentation/stable
mit-scheme-ref mono ${MIT_SCHEME}/mit-scheme-ref.html
MIT_SCHEME = ${GS}/mit-scheme/documentation
mit-scheme-ref node ${MIT_SCHEME}/mit-scheme-ref/
mit-scheme-user mono ${MIT_SCHEME}/mit-scheme-user.html
mit-scheme-user node ${MIT_SCHEME}/mit-scheme-user/
sos mono ${MIT_SCHEME}/mit-scheme-sos.html
sos node ${MIT_SCHEME}/mit-scheme-sos/
mit-scheme-imail mono ${MIT_SCHEME}/mit-scheme-imail.html
mit-scheme-imail node ${MIT_SCHEME}/mit-scheme-imail/
moe mono ${GS}/moe/manual/moe_manual.html
@@ -601,7 +572,7 @@ R = https://cran.r-project.org/doc/manuals
rcs mono ${GS}/rcs/manual/rcs.html
rcs node ${GS}/rcs/manual/html_node/
READLINE = https://tiswww.cwru.edu/php/chet/readline
READLINE = http://cnswww.cns.cwru.edu/php/chet/readline
readline mono ${READLINE}/readline.html
rluserman mono ${READLINE}/rluserman.html
history mono ${READLINE}/history.html
@@ -658,7 +629,7 @@ swbis mono ${GS}/swbis/manual.html
tar mono ${GS}/tar/manual/tar.html
tar chapter ${GS}/tar/manual/html_chapter/
tar section ${GS}/tar/manual/html_section/
tar node ${GS}/tar/manual/html_node/
tar node ${GS}/autoconf/manual/html_node/
teseq mono ${GS}/teseq/teseq.html
teseq node ${GS}/teseq/html_node/
@@ -666,6 +637,9 @@ teseq node ${GS}/teseq/html_node/
TEXINFO = ${GS}/texinfo/manual
texinfo mono ${TEXINFO}/texinfo/texinfo.html
texinfo node ${TEXINFO}/texinfo/html_node/
#
info mono ${TEXINFO}/info/info.html
info node ${TEXINFO}/info/html_node/
#
info-stnd mono ${TEXINFO}/info-stnd/info-stnd.html
info-stnd node ${TEXINFO}/info-stnd/html_node/
+40 -44
View File
@@ -4,7 +4,7 @@
# Copyright © 2013 Andreas Enge <andreas@enge.fr>
# Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
# Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2018, 2021 Julien Lepiller <julien@lepiller.eu>
# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
#
# This file is part of GNU Guix.
#
@@ -21,40 +21,14 @@
# You should have received a copy of the GNU General Public License
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
# If adding a language, update the following variables, and info_TEXINFOS.
MANUAL_LANGUAGES = de es fa fi fr it ko pt_BR ru sk zh_CN
COOKBOOK_LANGUAGES = de es fa fi fr ko pt_BR ru sk uk zh_Hans
# Arg1: A list of languages codes.
# Arg2: The file name stem.
lang_to_texinfo = $(foreach lang,$(1),%D%/$(2).$(lang).texi)
# Automake does not understand GNU Make non-standard extensions,
# unfortunately, so we cannot use the above patsubst-based function here.
info_TEXINFOS = %D%/guix.texi \
%D%/guix.de.texi \
%D%/guix.es.texi \
%D%/guix.fa.texi \
%D%/guix.fi.texi \
%D%/guix.fr.texi \
%D%/guix.it.texi \
%D%/guix.ko.texi \
%D%/guix.pt_BR.texi \
%D%/guix.ru.texi \
%D%/guix.sk.texi \
%D%/guix.zh_CN.texi \
%D%/guix-cookbook.texi \
%D%/guix-cookbook.de.texi \
%D%/guix-cookbook.es.texi \
%D%/guix-cookbook.fa.texi \
%D%/guix-cookbook.fi.texi \
%D%/guix-cookbook.fr.texi \
%D%/guix-cookbook.ko.texi \
%D%/guix-cookbook.pt_BR.texi \
%D%/guix-cookbook.ru.texi \
%D%/guix-cookbook.sk.texi \
%D%/guix-cookbook.uk.texi \
%D%/guix-cookbook.zh_Hans.texi
%D%/guix-cookbook.de.texi
%C%_guix_TEXINFOS = \
%D%/contributing.texi \
@@ -85,13 +59,20 @@ EXTRA_DIST += \
OS_CONFIG_EXAMPLES_TEXI = \
%D%/os-config-bare-bones.texi \
%D%/os-config-desktop.texi \
%D%/os-config-lightweight-desktop.texi \
%D%/he-config-bare-bones.scm
%D%/os-config-lightweight-desktop.texi
TRANSLATED_INFO = \
$(call lang_to_texinfo,$(MANUAL_LANGUAGES),guix) \
$(call lang_to_texinfo,$(MANUAL_LANGUAGES),contributing) \
$(call lang_to_texinfo,$(COOKBOOK_LANGUAGES),guix-cookbook)
TRANSLATED_INFO = \
%D%/guix.de.texi \
%D%/guix.es.texi \
%D%/guix.fr.texi \
%D%/guix.ru.texi \
%D%/guix.zh_CN.texi \
%D%/contributing.de.texi \
%D%/contributing.es.texi \
%D%/contributing.fr.texi \
%D%/contributing.ru.texi \
%D%/contributing.zh_CN.texi \
%D%/guix-cookbook.de.texi
# Bundle this file so that makeinfo finds it in out-of-source-tree builds.
BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
@@ -103,31 +84,46 @@ PO4A_PARAMS += -k 0 # produce an output even if the translation is not complete
PO4A_PARAMS += -f texinfo # texinfo format
# When a change to guix.texi occurs, it is not translated immediately.
# Because @pxref and @xref commands are references to sections by name, they
# Because @pxref and @xref commands are reference to a section by name, they
# should be translated. If a modification adds a reference to a section, this
# reference is not translated, which means it references a section that does not
# exist.
# This command loops through the translated files looking for references. For
# each of these references, it tries to find the translation and replaces the
# reference name, even in untranslated strings.
# The last sed is a multiline sed because some references span multiple lines.
define xref_command
$(top_srcdir)/pre-inst-env $(GUILE) --no-auto-compile \
"$(top_srcdir)/build-aux/convert-xref.scm" \
$@.tmp $<
cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
if [ -n "$$e" ]; then \
line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
((line++)) ;\
if [ "$$line" != "1" ]; then \
translation=$$(head -n "$$line" "$<" | tail -1 | grep msgstr | sed 's|msgstr "\(.*\)"|\1|') ;\
if [ "$$translation" != "" ]; then \
sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n ]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
fi ;\
fi ;\
fi ;\
done
endef
$(srcdir)/%D%/guix.%.texi: po/doc/guix-manual.%.po $(srcdir)/%D%/contributing.%.texi guix/build/po.go
$(srcdir)/%D%/guix.%.texi: po/doc/guix-manual.%.po $(srcdir)/%D%/contributing.%.texi
-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
-sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-$(AM_V_POXREF)$(xref_command)
-mv "$@.tmp" "$@"
$(srcdir)/%D%/guix-cookbook.%.texi: po/doc/guix-cookbook.%.po guix/build/po.go
$(srcdir)/%D%/guix-cookbook.%.texi: po/doc/guix-cookbook.%.po
-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix-cookbook.texi" -p "$<" -l "$@.tmp"
-sed -i "s|guix-cookbook\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-$(AM_V_POXREF)$(xref_command)
-mv "$@.tmp" "$@"
$(srcdir)/%D%/contributing.%.texi: po/doc/guix-manual.%.po guix/build/po.go
$(srcdir)/%D%/contributing.%.texi: po/doc/guix-manual.%.po
-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$<" -l "$@.tmp"
-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-$(AM_V_POXREF)$(xref_command)
-mv "$@.tmp" "$@"
%D%/os-config-%.texi: gnu/system/examples/%.tmpl
+61 -220
View File
@@ -3,9 +3,7 @@
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,51 +28,12 @@
(import (sxml xpath)
(srfi srfi-1)
(srfi srfi-2)
(srfi srfi-9)
(srfi srfi-11)
(srfi srfi-26)
(ice-9 format)
(ice-9 popen)
(ice-9 match)
(ice-9 rdelim)
(ice-9 regex)
(ice-9 textual-ports)
(guix gexp))
(define* (break-string str #:optional (max-line-length 70))
"Break the string STR into lines that are no longer than MAX-LINE-LENGTH.
Return a single string."
(define (restore-line words)
(string-join (reverse words) " "))
(if (<= (string-length str) max-line-length)
str
(let ((words+lengths (map (lambda (word)
(cons word (string-length word)))
(string-tokenize str))))
(match (fold (match-lambda*
(((word . length)
(count current lines))
(let ((new-count (+ count length 1)))
(if (< new-count max-line-length)
(list new-count
(cons word current)
lines)
(list length
(list word)
(cons (restore-line current) lines))))))
'(0 () ())
words+lengths)
((_ last-words lines)
(string-join (reverse (cons (restore-line last-words) lines))
"\n"))))))
(define* (break-string-with-newlines str #:optional (max-line-length 70))
"Break the lines of string STR into lines that are no longer than
MAX-LINE-LENGTH. Return a single string."
(string-join (map (cut break-string <> max-line-length)
(string-split str #\newline))
"\n"))
(ice-9 textual-ports))
(define (read-excursion port)
"Read an expression from PORT and reset the port position before returning
@@ -104,8 +63,7 @@ LINE-NO in PORT."
(make-hunk file-name
old-line-number
new-line-number
diff-lines
definition?)
diff)
hunk?
(file-name hunk-file-name)
;; Line number before the change
@@ -113,45 +71,38 @@ LINE-NO in PORT."
;; Line number after the change
(new-line-number hunk-new-line-number)
;; The full diff to be used with "git apply --cached"
(diff-lines hunk-diff-lines)
;; Does this hunk add a definition?
(definition? hunk-definition?))
(diff hunk-diff))
(define* (hunk->patch hunk #:optional (port (current-output-port)))
(let ((file-name (hunk-file-name hunk)))
(format port
"diff --git a/~a b/~a~%--- a/~a~%+++ b/~a~%~a"
file-name file-name file-name file-name
(string-join (hunk-diff-lines hunk) ""))))
(hunk-diff hunk))))
(define (diff-info)
"Read the diff and return a list of <hunk> values."
(let ((port (open-pipe* OPEN_READ
"git" "diff-files"
"git" "diff"
"--no-prefix"
;; Only include one context line to avoid lumping in
;; new definitions with changes to existing
;; definitions.
"--unified=1"
"gnu")))
;; Do not include any context lines. This makes it
;; easier to find the S-expression surrounding the
;; change.
"--unified=0")))
(define (extract-line-number line-tag)
(abs (string->number
(car (string-split line-tag #\,)))))
(define (read-hunk)
(let loop ((lines '())
(definition? #false))
(let ((line (read-line port 'concat)))
(cond
((eof-object? line)
(values (reverse lines) definition?))
((or (string-prefix? "@@ " line)
(string-prefix? "diff --git" line))
(unget-string port line)
(values (reverse lines) definition?))
(else
(loop (cons line lines)
(or definition?
(string-prefix? "+(define" line))))))))
(reverse
(let loop ((lines '()))
(let ((line (read-line port 'concat)))
(cond
((eof-object? line) lines)
((or (string-prefix? "@@ " line)
(string-prefix? "diff --git" line))
(unget-string port line)
lines)
(else (loop (cons line lines))))))))
(define info
(let loop ((acc '())
(file-name #f))
@@ -165,42 +116,29 @@ LINE-NO in PORT."
((string-prefix? "@@ " line)
(match (string-split line #\space)
((_ old-start new-start . _)
(let-values
(((diff-lines definition?) (read-hunk)))
(loop (cons (make-hunk file-name
(extract-line-number old-start)
(extract-line-number new-start)
(cons (string-append line "\n")
diff-lines)
definition?) acc)
file-name)))))
(loop (cons (make-hunk file-name
(extract-line-number old-start)
(extract-line-number new-start)
(string-join (cons* line "\n"
(read-hunk)) ""))
acc)
file-name))))
(else (loop acc file-name))))))
(close-pipe port)
info))
(define (lines-to-first-change hunk)
"Return the number of diff lines until the first change."
(1- (count (lambda (line)
((negate char-set-contains?)
(char-set #\+ #\-)
(string-ref line 0)))
(hunk-diff-lines hunk))))
(define (old-sexp hunk)
"Using the diff information in HUNK return the unmodified S-expression
corresponding to the top-level definition containing the staged changes."
;; TODO: We can't seek with a pipe port...
(let* ((port (open-pipe* OPEN_READ
"git" "cat-file" "-p" (string-append
"HEAD:"
(hunk-file-name hunk))))
"git" "show" (string-append "HEAD:"
(hunk-file-name hunk))))
(contents (get-string-all port)))
(close-pipe port)
(call-with-input-string contents
(lambda (port)
(surrounding-sexp port
(+ (lines-to-first-change hunk)
(hunk-old-line-number hunk)))))))
(surrounding-sexp port (hunk-old-line-number hunk))))))
(define (new-sexp hunk)
"Using the diff information in HUNK return the modified S-expression
@@ -208,19 +146,13 @@ corresponding to the top-level definition containing the staged changes."
(call-with-input-file (hunk-file-name hunk)
(lambda (port)
(surrounding-sexp port
(+ (lines-to-first-change hunk)
(hunk-new-line-number hunk))))))
(hunk-new-line-number hunk)))))
(define* (change-commit-message file-name old new #:optional (port (current-output-port)))
(define* (commit-message file-name old new #:optional (port (current-output-port)))
"Print ChangeLog commit message for changes between OLD and NEW."
(define (get-values expr field)
(match ((sxpath `(// ,field quasiquote *)) expr)
(()
;; New-style plain lists
(match ((sxpath `(// ,field list *)) expr)
((inner) inner)
(_ '())))
;; Old-style labelled inputs
(() '())
((first . rest)
(map cadadr first))))
(define (listify items)
@@ -247,62 +179,20 @@ corresponding to the top-level definition containing the staged changes."
(added (lset-difference equal? new-values old-values)))
(format port
"[~a]: ~a~%" field
(break-string
(match (list (map symbol->string removed)
(map symbol->string added))
((() added)
(format #f "Add ~a."
(listify added)))
((removed ())
(format #f "Remove ~a."
(listify removed)))
((removed added)
(format #f "Remove ~a; add ~a."
(listify removed)
(listify added))))))))))
(match (list (map symbol->string removed)
(map symbol->string added))
((() added)
(format #f "Add ~a."
(listify added)))
((removed ())
(format #f "Remove ~a."
(listify removed)))
((removed added)
(format #f "Remove ~a; add ~a."
(listify removed)
(listify added)))))))))
'(inputs propagated-inputs native-inputs)))
(define* (add-commit-message file-name variable-name #:optional (port (current-output-port)))
"Print ChangeLog commit message for a change to FILE-NAME adding a definition."
(format port
"gnu: Add ~a.~%~%* ~a (~a): New variable.~%"
variable-name file-name variable-name))
(define* (custom-commit-message file-name variable-name message changelog
#:optional (port (current-output-port)))
"Print custom commit message for a change to VARIABLE-NAME in FILE-NAME, using
MESSAGE as the commit message and CHANGELOG as the body of the ChangeLog
entry. If CHANGELOG is #f, the commit message is reused. If CHANGELOG already
contains ': ', no colon is inserted between the location and body of the
ChangeLog entry."
(define (trim msg)
(string-trim-right (string-trim-both msg) (char-set #\.)))
(define (changelog-has-location? changelog)
(->bool (string-match "^[[:graph:]]+:[[:blank:]]" changelog)))
(let* ((message (trim message))
(changelog (if changelog (trim changelog) message))
(message/f (format #f "gnu: ~a: ~a." variable-name message))
(changelog/f (if (changelog-has-location? changelog)
(format #f "* ~a (~a)~a."
file-name variable-name changelog)
(format #f "* ~a (~a): ~a."
file-name variable-name changelog))))
(format port
"~a~%~%~a~%"
(break-string-with-newlines message/f 72)
(break-string-with-newlines changelog/f 72))))
(define (add-copyright-line line)
"Add the copyright line on LINE to the previous commit."
(let ((author (match:substring
(string-match "^\\+;;; Copyright ©[^[:alpha:]]+(.*)$" line)
1)))
(format
(current-output-port) "Amend and add copyright line for ~a~%" author)
(system* "git" "commit" "--amend" "--no-edit")))
(define (group-hunks-by-sexp hunks)
"Return a list of pairs associating all hunks with the S-expression they are
modifying."
@@ -328,54 +218,14 @@ modifying."
(cons* new (old-sexp (first hunks)) hunks)))
(group-hunks-by-sexp hunks)))
(define %delay 1000)
(define (main . args)
(define* (change-commit-message* file-name old new #:rest rest)
(let ((changelog #f))
(match args
((or (message changelog) (message))
(apply custom-commit-message
file-name (second old) message changelog rest))
(_
(apply change-commit-message file-name old new rest)))))
(match (diff-info)
(()
(display "Nothing to be done.\n" (current-error-port)))
(display "Nothing to be done." (current-error-port)))
(hunks
(let-values
(((definitions changes)
(partition hunk-definition? hunks)))
;; Additions.
(for-each (lambda (hunk)
(and-let*
((define-line (find (cut string-prefix? "+(define" <>)
(hunk-diff-lines hunk)))
(variable-name (and=> (string-tokenize define-line) second)))
(add-commit-message (hunk-file-name hunk) variable-name)
(let ((port (open-pipe* OPEN_WRITE
"git" "apply"
"--cached"
"--unidiff-zero")))
(hunk->patch hunk port)
(unless (eqv? 0 (status:exit-val (close-pipe port)))
(error "Cannot apply")))
(let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-")))
(add-commit-message (hunk-file-name hunk)
variable-name port)
(usleep %delay)
(unless (eqv? 0 (status:exit-val (close-pipe port)))
(error "Cannot commit"))))
(usleep %delay))
definitions)
;; Changes.
(for-each (match-lambda
((new old . hunks)
(for-each (lambda (hunk)
(for-each (match-lambda
((new old . hunks)
(for-each (lambda (hunk)
(let ((port (open-pipe* OPEN_WRITE
"git" "apply"
"--cached"
@@ -383,27 +233,18 @@ modifying."
(hunk->patch hunk port)
(unless (eqv? 0 (status:exit-val (close-pipe port)))
(error "Cannot apply")))
(usleep %delay))
(sleep 1))
hunks)
(define copyright-line
(any (lambda (line) (and=> (string-prefix? "+;;; Copyright ©" line)
(const line)))
(hunk-diff-lines (first hunks))))
(cond
(copyright-line
(add-copyright-line copyright-line))
(else
(let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-")))
(change-commit-message* (hunk-file-name (first hunks))
old new)
(change-commit-message* (hunk-file-name (first hunks))
old new
port)
(usleep %delay)
(commit-message (hunk-file-name (first hunks))
old new
(current-output-port))
(let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-")))
(commit-message (hunk-file-name (first hunks))
old new
port)
(sleep 1)
(unless (eqv? 0 (status:exit-val (close-pipe port)))
(error "Cannot commit")))))))
;; XXX: we recompute the hunks here because previous
;; insertions lead to offsets.
(new+old+hunks (diff-info)))))))
(error "Cannot commit")))))
(new+old+hunks hunks)))))
(apply main (cdr (command-line)))
(main)
+73 -138
View File
@@ -1,6 +1,5 @@
# GNU Guix --- Functional package management for GNU
# Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2021 Tobias Geerinck-Rice <me@tobias.gr>
# Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -28,12 +27,11 @@ _guix_complete_command ()
if [ -z "$_guix_commands" ]
then
# Cache the list of commands to speed things up.
_guix_commands="$(${COMP_WORDS[0]} --help 2> /dev/null \
_guix_commands="$(guix --help 2> /dev/null \
| grep '^ ' \
| sed '-es/^ *\([a-z-]\+\).*$/\1/g')"
fi
COMPREPLY+=($(compgen -W "$_guix_commands" -- "$word_at_point"))
COMPREPLY=($(compgen -W "$_guix_commands" -- "$word_at_point"))
}
_guix_complete_subcommand ()
@@ -42,7 +40,7 @@ _guix_complete_subcommand ()
local subcommands="$(${COMP_WORDS[0]} $command --help 2> /dev/null \
| grep '^ [a-z]' \
| sed -e's/^ \+\([a-z-]\+\).*$/\1/g')"
COMPREPLY+=($(compgen -W "$subcommands" -- "${COMP_WORDS[$COMP_CWORD]}"))
COMPREPLY=($(compgen -W "$subcommands" -- "${COMP_WORDS[$COMP_CWORD]}"))
}
_guix_complete_available_package ()
@@ -55,7 +53,7 @@ _guix_complete_available_package ()
_guix_available_packages="$(${COMP_WORDS[0]} package -A 2> /dev/null \
| cut -f1)"
fi
COMPREPLY+=($(compgen -W "$_guix_available_packages" -- "$prefix"))
COMPREPLY=($(compgen -W "$_guix_available_packages" -- "$prefix"))
}
_guix_complete_installed_package ()
@@ -65,40 +63,36 @@ _guix_complete_installed_package ()
local prefix="$1"
local packages="$(${COMP_WORDS[0]} package -I "^$prefix" 2> /dev/null \
| cut -f1)"
COMPREPLY+=($(compgen -W "$packages" -- "$prefix"))
COMPREPLY=($(compgen -W "$packages" -- "$prefix"))
}
_guix_complete_option ()
{
local command="${COMP_WORDS[$1]}"
local subcommand="${COMP_WORDS[$(($1 + 1))]}"
if [ $1 -eq 0 ]
then
command=""
subcommand=""
elif _guix_is_option "$subcommand"
then
subcommand=""
fi
local options="$(${COMP_WORDS[0]} $command $subcommand --help 2> /dev/null \
local subcommand
case "${COMP_WORDS[2]}" in
-*) subcommand="";;
[a-z]*) subcommand="${COMP_WORDS[2]}";;
esac
local options="$(${COMP_WORDS[0]} ${COMP_WORDS[1]} $subcommand --help 2> /dev/null \
| grep '^ \+-' \
| sed -e's/^.*--\([a-zA-Z0-9_-]\+\)\(=\?\).*/--\1\2/g')"
compopt -o nospace
COMPREPLY+=($(compgen -W "$options" -- "$2"))
COMPREPLY=($(compgen -W "$options" -- "${COMP_WORDS[${#COMP_WORDS[*]} - 1]}"))
}
_guix_is_option ()
_guix_is_command ()
{
case "$1" in
-*)
true
;;
*)
false
;;
esac
local word
local result="false"
for word in ${COMP_WORDS[*]}
do
if [ "$word" = "$1" ]
then
result=true
break
fi
done
$result
}
_guix_is_removing ()
@@ -117,24 +111,6 @@ _guix_is_removing ()
$result
}
_guix_is_dash_f ()
{
[ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-f" ] \
|| { case "${COMP_WORDS[$COMP_CWORD]}" in
--file=*|--install-from-file=*) true;;
*) false;;
esac }
}
_guix_is_dash_l ()
{
[ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-l" ] \
|| { case "${COMP_WORDS[$COMP_CWORD]}" in
--load=*) true;;
*) false;;
esac }
}
_guix_is_dash_L ()
{
[ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-L" ] \
@@ -178,22 +154,10 @@ _guix_complete_file ()
COMPREPLY=()
}
_guix_complete_available_package_or_store_file ()
{
_guix_complete_available_package "$@"
# The current _guix_complete_file implementation doesn't compose (append to
# COMPREPLY), so we suggest file names only if no package names matched.
if [[ -z "$COMPREPLY" ]]
then
_guix_complete_file # TODO: restrict to store files
fi
}
_guix_complete_pid ()
{
local pids="$(cd /proc; echo [0-9]*)"
COMPREPLY+=($(compgen -W "$pids" -- "$1"))
COMPREPLY=($(compgen -W "$pids" -- "$1"))
}
_guix_complete ()
@@ -201,46 +165,24 @@ _guix_complete ()
local word_count=${#COMP_WORDS[*]}
local word_at_point="${COMP_WORDS[$COMP_CWORD]}"
# Find the innermost command at point, e.g. "build" in the case of
# "guix time-machine OPTIONS -- build<Tab>" -- but "time-machine" if
# point is moved before "build".
local command_index=0
local command
local word_index=0
local word
local expect_command="true"
while [[ $((++word_index)) -le COMP_CWORD ]]
do
word="${COMP_WORDS[$word_index]}"
if $expect_command
then
command_index=$word_index
command="$word"
expect_command="false"
continue
fi
if [[ "$word" = "--" ]]
then
case "$command" in
environment|shell)
break
;;
time-machine)
expect_command="true"
;;
esac
fi
done
if [ "$COMP_CWORD" -gt 1 ]
then
case "$word_at_point" in
-*)
_guix_complete_option "$word_at_point"
return
;;
esac
fi
case $COMP_CWORD in
$command_index)
1)
_guix_complete_command
_guix_complete_option 0 "$word_at_point"
;;
*)
if [[ "$command" = "package" ]]
if _guix_is_command "package"
then
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p || _guix_is_dash_f
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
then
_guix_complete_file
elif _guix_is_removing
@@ -249,7 +191,7 @@ _guix_complete ()
else
_guix_complete_available_package "$word_at_point"
fi
elif [[ "$command" = "install" ]]
elif _guix_is_command "install"
then
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
then
@@ -257,7 +199,7 @@ _guix_complete ()
else
_guix_complete_available_package "$word_at_point"
fi
elif [[ "$command" = "upgrade" || "$command" = "remove" ]]
elif _guix_is_command "remove"
then
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
then
@@ -265,84 +207,77 @@ _guix_complete ()
else
_guix_complete_installed_package "$word_at_point"
fi
elif [[ "$command" = "build" ]]
then
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_f
elif _guix_is_command "upgrade"
then
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
then
_guix_complete_file
else
_guix_complete_available_package_or_store_file "$word_at_point"
_guix_complete_installed_package "$word_at_point"
fi
elif _guix_is_command "build"
then
if _guix_is_dash_L || _guix_is_dash_m
then
_guix_complete_file
else
_guix_complete_available_package "$word_at_point"
fi
elif [[ "$command" = "environment" || "$command" = "shell" ]]
elif _guix_is_command "environment"
then
if _guix_is_dash_f && [[ "$command" = "shell" ]]
then
# The otherwise identical guix environment lacks the -f option.
_guix_complete_file
elif _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p || _guix_is_dash_l
then
_guix_complete_file
elif _guix_is_option "$word_at_point"
then
_guix_complete_option "$command_index" "$word_at_point"
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
then
_guix_complete_file
else
_guix_complete_available_package "$word_at_point"
fi
elif [[ "$command" = "download" || "$command" = "gc" || "$command" = "hash" ]]
elif _guix_is_command "download"
then
_guix_complete_file
elif [[ "$command" = "size" ]]
_guix_complete_file
elif _guix_is_command "system"
then
_guix_complete_available_package_or_store_file "$word_at_point"
elif [[ "$command" = "system" || "$command" = "home" ]]
then
case $((COMP_CWORD - command_index)) in
1) _guix_complete_subcommand;;
case $COMP_CWORD in
2) _guix_complete_subcommand;;
*) _guix_complete_file;; # TODO: restrict to *.scm
esac
elif [[ "$command" = "pull" ]]
elif _guix_is_command "pull"
then
if _guix_is_dash_C || _guix_is_dash_p
then
_guix_complete_file
fi
elif [[ "$command" = "time-machine" ]]
elif _guix_is_command "time-machine"
then
if _guix_is_dash_C
then
_guix_complete_file
else
_guix_complete_option "$command_index" "$word_at_point"
_guix_complete_command
fi
elif [[ "$command" = "container" ]]
elif _guix_is_command "container"
then
case $((COMP_CWORD - command_index)) in
1) _guix_complete_subcommand;;
2) _guix_complete_pid "$word_at_point";;
case $COMP_CWORD in
2) _guix_complete_subcommand;;
3) _guix_complete_pid "$word_at_point";;
*) _guix_complete_file;;
esac
elif [[ "$command" = "import" ]]
elif _guix_is_command "import"
then
_guix_complete_subcommand
elif [[ "$command" = "weather" ]]
elif _guix_is_command "hash" || _guix_is_command "gc"
then
_guix_complete_file
elif _guix_is_command "weather"
then
if _guix_is_dash_m
then
_guix_complete_file
else
_guix_complete_available_package "$word_at_point"
fi
else
_guix_complete_available_package "$word_at_point"
fi
;;
esac
if [[ -z "$COMPREPLY" && COMP_CWORD -gt command_index ]] &&
_guix_is_option "$word_at_point"
then
_guix_complete_option "$command_index" "$word_at_point"
fi
}
complete -F _guix_complete guix
+6 -3
View File
@@ -133,7 +133,7 @@ complete -f -c guix -n '__fish_guix_using_command pull' -l url -d 'download the
complete -f -c guix -n '__fish_guix_using_command pull' -l bootstrap -d 'use the bootstrap Guile to build the new Guix'
#### system
set -l remotecommands reconfigure roll-back switch-generation list-generations build container vm image init extension-graph shepherd-graph load-path keep-failed keep-going dry-run fallback no-substitutes substitutes-urls no-grafts no-offload max-silent-time timeout verbosity rounds cores max-jobs derivation on-error image-size no-grub share expose full-boot
set -l remotecommands reconfigure roll-back switch-generation list-generations build container vm vm-image disk-image init extension-graph shepherd-graph load-path keep-failed keep-going dry-run fallback no-substitutes substitutes-urls no-grafts no-offload max-silent-time timeout verbosity rounds cores max-jobs derivation on-error image-size no-grub share expose full-boot
complete -f -c guix -n '__fish_guix_needs_command' -a system -d 'Build the operating system declared in FILE according to ACTION.'
complete -f -c guix -n '__fish_guix_using_command system' -l reconfigure -d 'switch to a new operating system configuration'
complete -f -c guix -n '__fish_guix_using_command system' -l roll-back -d 'switch to the previous operating system configuration'
@@ -142,7 +142,8 @@ complete -f -c guix -n '__fish_guix_using_command system' -l list-generations -d
complete -f -c guix -n '__fish_guix_using_command system' -l build -d 'build the operating system without installing anything'
complete -f -c guix -n '__fish_guix_using_command system' -l container -d 'build a container that shares the host\'s store'
complete -f -c guix -n '__fish_guix_using_command system' -l vm -d 'build a virtual machine image that shares the host\'s store'
complete -f -c guix -n '__fish_guix_using_command system' -l image -d 'build a disk image, suitable for a USB stick'
complete -f -c guix -n '__fish_guix_using_command system' -l vm-image -d 'build a freestanding virtual machine image'
complete -f -c guix -n '__fish_guix_using_command system' -l disk-image -d 'build a disk image, suitable for a USB stick'
complete -f -c guix -n '__fish_guix_using_command system' -l init -d 'initialize a root file system to run GNU'
complete -f -c guix -n '__fish_guix_using_command system' -l extension-graph -d 'emit the service extension graph in Dot format'
complete -f -c guix -n '__fish_guix_using_command system' -l shepherd-graph -d 'emit the graph of shepherd services in Dot format'
@@ -166,7 +167,7 @@ complete -f -c guix -n '__fish_guix_using_command system' -s M -d 'allow at most
complete -f -c guix -n '__fish_guix_using_command system' -a "--max-jobs=" -d 'allow at most N build jobs'
complete -f -c guix -n '__fish_guix_using_command system' -s d -l derivation -d 'return the derivation of the given system'
complete -f -c guix -n '__fish_guix_using_command system' -a "--on-error=" -d 'apply STRATEGY when an error occurs while reading FILE'
complete -f -c guix -n '__fish_guix_using_command system' -a "--image-size=" -d 'for \'image\', produce an image of SIZE'
complete -f -c guix -n '__fish_guix_using_command system' -a "--image-size=" -d 'for \'vm-image\', produce an image of SIZE'
complete -f -c guix -n '__fish_guix_using_command system' -l no-grub -d 'for \'init\', do not install GRUB'
complete -f -c guix -n '__fish_guix_using_command system' -a "--share=" -d 'for \'vm\', share host file system according to SPEC'
complete -f -c guix -n '__fish_guix_using_command system' -a "--expose=" -d 'for \'vm\', expose host file system according to SPEC'
@@ -322,6 +323,8 @@ complete -f -c guix -n '__fish_guix_needs_command' -a import -d 'Run IMPORTER wi
##### import gnu
complete -f -c guix -n '__fish_guix_using_command import; and not __fish_seen_subcommand_from $remotecommands' -a gnu -d 'Return a package declaration template for PACKAGE, a GNU package.'
complete -f -c guix -n '__fish_guix_using_command import; and __fish_seen_subcommand_from gnu' -a "--key-download=" -d 'handle missing OpenPGP keys according to POLICY: "always", "never", and "interactive", which is also used when "key-download" is not specified.'
##### import nix
complete -f -c guix -n '__fish_guix_using_command import; and not __fish_seen_subcommand_from $remotecommands' -a nix -d 'Import and convert the Nix expression ATTRIBUTE of NIXPKGS.'
##### import pypi
complete -f -c guix -n '__fish_guix_using_command import; and not __fish_seen_subcommand_from $remotecommands' -a pypi -d 'Import and convert the PyPI package for PACKAGE-NAME.'
##### import cpan
+102 -309
View File
@@ -2,8 +2,6 @@
#
# GNU Guix --- Functional package management for GNU
# Copyright © 2016 Eric Le Bihan <eric.le.bihan.dev@free.fr>
# Copyright © 2021 Noah Evans <noah@nevans.me>
# Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
#
# This file is part of GNU Guix.
#
@@ -58,7 +56,6 @@ _guix_list_available_packages()
if ( [[ ${+_guix_available_packages} -eq 0 ]] || _cache_invalid GUIX_AVAILABLE_PACKAGES ) \
&& ! _retrieve_cache GUIX_AVAILABLE_PACKAGES; then
_guix_available_packages=(${${(f)"$(guix package -A | cut -f1)"}})
_guix_available_packages=("${_guix_available_packages[@]// /}")
_store_cache GUIX_AVAILABLE_PACKAGES _guix_available_packages
fi
}
@@ -71,24 +68,21 @@ _guix_list_installed_packages()
(( $+functions[_guix_build] )) || _guix_build()
{
_arguments \
{-e,--expression=}'[build the package or derivation EXPR evaluates to]:EXPR' \
{-f,--file=}'[build the package or derivation that the code within FILE evaluates to]:FILE:_files' \
{-m,--manifest=}'[build the packages that the manifest given in FILE evaluates to]:FILE:_files' \
{-S,--source}'[build the packages source derivations]' \
'--sources=[build source derivations]:TYPE:(package all transitive)' \
{-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
'--expression=[build the package matching EXPR]:EXPR' \
'--file=[build the package matching code evaluated from FILE]:FILE:_files' \
'--source[build the packages source derivations]' \
'--sources=[build source derivations]:TYPE:(all package transitive)' \
'--system=[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
'--target=[cross-build for TRIPLET (e.g. "armel-linux-gnu")]:TRIPLET' \
{-d,--derivations}'[return the derivation paths of the given packages]' \
'--derivations[return the derivation paths of the given packages]' \
'--check[rebuild items to check for non-determinism issues]' \
'--repair[repair the specified items]' \
{-r,--root=}'[make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
{-q,--quiet}'[do not show the build log]' \
'--root=[symlink result to FILE and register it as GC root]:FILE:_files' \
'--quiet[do not show the build log]' \
'--log-file[return the log file names for the given derivations]' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -\' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--load-path=[prepend DIR to the package module search path]:DIR:_dirs' \
'--keep-failed[keep build tree of failed builds]' \
'--keep-going[keep going when some of the derivations fail]' \
'--dry-run[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
@@ -96,12 +90,12 @@ _guix_list_installed_packages()
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--verbosity=[use the given verbosity LEVEL]:LEVEL' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
'--help-transform[list package transformation options not shown here]' \
{-V,--version}'[display version information and exit]' \
'--cores=[allow the use of up to N CPU cores for the build]:N' \
'--max-jobs=[allow at most N build jobs]:N' \
'--with-source=[use SOURCE when building the corresponding package]:SOURCE' \
'--with-input=[replace dependency PACKAGE by REPLACEMENT]:PACKAGE=REPLACEMENT' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
@@ -113,10 +107,7 @@ _guix_list_installed_packages()
(( $+functions[_guix_challenge] )) || _guix_challenge()
{
_arguments \
'--substitute-urls=[compare build results with those at URLS]:URLS:_urls' \
'--diff=[show differences according to MODE]:MODE' \
{-v,--verbose}'[show details about successful comparisons]' \
{-V,--version}'[display version information and exit]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URL:_urls' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
@@ -135,11 +126,7 @@ _guix_list_installed_packages()
(( $+functions[_guix_download] )) || _guix_download()
{
_arguments \
{-f,--format=}'[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
{-H,--hash=}'[use the given hash ALGORITHM]:ALGORITHM' \
'--no-check-certificate[do not validate the certificate of HTTPS servers ]' \
{-o,--output=}'[download to FILE]:FILE:_files' \
{-V,--version}'[display version information and exit]' \
'--format=[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
'1:URL:_urls'
}
@@ -152,29 +139,21 @@ _guix_list_installed_packages()
(( $+functions[_guix_environment] )) || _guix_environment()
{
_arguments \
{-e,--expression=}'[create environment for the package that EXPR evaluates to]:EXPR' \
{-l,--load=}'[create environment for the package that the code within FILE evaluates to]:FILE:_files' \
{-m,--manifest=}'[create environment with the manifest from FILE]:FILE:_files' \
{-p,--profile=}'[create environment from profile at PATH]:PATH:_files -/' \
'--ad-hoc[include all specified packages in the environment instead of only their inputs]' \
'--expression=[create environment for the package evaluated from EXPR]:EXPR' \
'--load=[create environment for the package evaluated from FILE]:FILE:_files' \
'--ad-hoc[include all specified packages, not only their inputs]' \
'--pure[unset existing environment variables]' \
{-E,--preserve=}'[preserve environment variables that match REGEXP]:REGEXP' \
'--search-paths[display needed environment variable definitions]' \
{-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
{-r,--root=}'[make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
{-C,--container}'[run command within an isolated container]' \
{-N,--network}'[allow containers to access the network]' \
{-P,--link-profile}'[link environment profile to ~/.guix-profile within an isolated container]' \
{-u,--user=}'[instead of copying the name and home of the current user into an isolated container, use the name USER with home directory /home/USER]:USER:_users' \
'--no-cwd[do not share current working directory with an isolated container]' \
'--share=[for containers, share writable host file system according to SPEC]:SPEC' \
'--expose=[for containers, expose read-only host file system according to SPEC]:SPEC' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
'--system=[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
'--container[run command within an isolated container]' \
'--network[allow containers to access the network]' \
'--share=[share writable host file system according to SPEC]:SPEC' \
'--expose=[expose read-only host file system according to SPEC]:SPEC' \
'--bootstrap[use bootstrap binaries to build the environment]' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--load-path=[prepend DIR to the package module search path]:DIR:_dirs' \
'--keep-failed[keep build tree of failed builds]' \
'--keep-going[keep going when some of the derivations fail]' \
'--dry-run[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
@@ -182,12 +161,10 @@ _guix_list_installed_packages()
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--verbosity=[use the given verbosity LEVEL]:LEVEL' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
'--help-transform[list package transformation options not shown here]' \
{-V,--version}'[display version information and exit]' \
'--cores=[allow the use of up to N CPU cores for the build]:N' \
'--max-jobs=[allow at most N build jobs]:N' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
@@ -200,39 +177,27 @@ _guix_list_installed_packages()
(( $+functions[_guix_gc] )) || _guix_gc()
{
_arguments \
{-C,--collect-garbage=}'[collect at least MIN bytes of garbage]:MIN' \
{-F,--free-space=}'[attempt to reach FREE available space in the store]:FREE' \
{-d,--delete-generations=}'[delete profile generations matching PATTERN]:PATTERN' \
{-D,--delete}'[attempt to delete PATHS]' \
'--list-roots[list the users GC roots]' \
'--list-busy[list store items used by running processes]' \
'--collect-garbage=[collect at least MIN bytes of garbage]:MIN' \
'--free-space=[attempt to reach FREE available space in the store]:FREE' \
'--delete[attempt to delete PATHS]' \
'--optimize[optimize the store by deduplicating identical files]' \
'--list-dead[list dead paths]' \
'--list-live[list live paths]' \
'--references[list the references of PATHS]' \
{-R,--requisites}'[list the requisites of PATHS]' \
'--requisites[list the requisites of PATHS]' \
'--referrers[list the referrers of PATHS]' \
'--derivers[list the derivers of PATHS]' \
'--verify=[verify the integrity of the store]:OPTS:(contents repair)' \
'--list-failures[list cached build failures]' \
'--clear-failures[remove PATHS from the set of cached failures]' \
{-V,--version}'[display version information and exit]:V' \
'1:PATH:_files -/'
'1:PATH:_dirs'
}
(( $+functions[_guix_graph] )) || _guix_graph()
{
_arguments \
{-b,--backend=}'[produce a graph with the given backend TYPE]:TYPE:->types' \
'--list-backends[list the available graph backends]' \
{-t,--type=}'[represent nodes of the given TYPE]:TYPE:->types' \
'--type=[represent nodes of the given TYPE]:TYPE:->types' \
'--list-types[list the available graph types]' \
'--path[display the shortest path between the given nodes]' \
{-e,--expression=}'[consider the package EXPR evaluates to]:EXPR' \
{-s,--system=}'[consider the graph for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
'--help-transform[list package transformation options not shown here]' \
{-V,--version}'[display version information and exit]' \
'--expression=[consider the package EXPR evaluates to]:EXPR' \
'1:PACKAGE:->packages'
case "$state" in
@@ -251,18 +216,14 @@ _guix_list_installed_packages()
(( $+functions[_guix_hash] )) || _guix_hash()
{
_arguments \
{-x,--exclude-vcs}'[exclude version control directories]' \
{-H,--hash=}'[use the given hash ALGORITHM]:ALGORITHM' \
{-f,--format=}'[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
{-r,--recursive}'[compute the hash on FILE recursively]' \
{-V,--version}'[display version information and exit]' \
'--format=[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
'--recursive[compute the hash on FILE recursively]'\
'1:FILE:_files'
}
(( $+functions[_guix_import] )) || _guix_import()
{
_arguments \
{-V,--version}'[display version information and exit]' \
'1:IMPORTER:->importer' \
'*:args:'
@@ -275,12 +236,8 @@ _guix_list_installed_packages()
(( $+functions[_guix_lint] )) || _guix_lint()
{
_arguments \
{-c,--checkers=}'[only run the specified checkers]:CHECKERS:->checkers' \
{-x,--exclude=}'[exclude the specified checkers]:CHECKERSS:->checkers' \
{-n,--no-network}'[only run checkers that do not access the network]' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-l,--list-checkers}'[display the list of available lint checkers]' \
{-V,--version}'[display version information and exit]' \
'--checkers=[only run the specified checkers]:CHECKERS:->checkers' \
'--list-checkers[display the list of available lint checkers]' \
'1:PACKAGE:->packages'
case "$state" in
@@ -298,32 +255,29 @@ _guix_list_installed_packages()
(( $+functions[_guix_package] )) || _guix_package()
{
_arguments \
{-i,--install}'[install one or more packages]: :->install' \
{-e,--install-from-expression=}'[install the package EXP evaluates to]:EXP' \
{-f,--install-from-file=}'[install the package evaluated from FILE]:FILE:_files' \
{-r,--remove}'[remove one or more packages]: :->remove' \
{-u,--upgrade=}'[upgrade all the installed packages matching REGEXP]:REGEXP' \
{-m,--manifest=}'[create a new profile generation from FILE]:FILE:_files' \
'--install[install one or more packages]: :->install' \
'--install-from-expression=[install the package EXP evaluates to]:EXP' \
'--install-from-file=[install the package evaluated from FILE]:FILE:_files' \
'--remove[remove one or more packages]: :->remove' \
'--upgrade=[upgrade all the installed packages matching REGEXP]:REGEXP' \
'--manifest=[create a new profile generation from FILE]:FILE:_files' \
'--do-not-upgrade=[do not upgrade any packages matching REGEXP]:REGEXP' \
'--roll-back[roll back to the previous generation]' \
'--search-paths=[display needed environment variable definitions]:KINDS' \
{-l,--list-generations=}'[list generations matching PATTERN]:PATTERN' \
{-d,--delete-generations=}'[delete generations matching PATTERN]:PATTERN' \
{-S,--switch-generation=}'[switch to a generation matching PATTERN]:PATTERN' \
'--export-manifest[print a manifest for the chosen profile]' \
'--export-channels[print channels for the chosen profile]' \
{-p,--profile}'[use PROFILE instead of the default profile]:PROFILE:_files -/' \
'--list-profiles[list the profiles]' \
'--allow-collisions[do not treat collisions in the profile as an error]' \
'--list-generations=[list generations matching PATTERN]:PATTERN' \
'--delete-generations=[delete generations matching PATTERN]:PATTERN' \
'--switch-generation=[switch to a generation matching PATTERN]:PATTERN' \
'--profile=[use PROFILE instead of the default profile]:PROFILE' \
'--bootstrap[use the bootstrap Guile to build the profile]' \
{-s,--search=}'[search in synopsis and description using REGEXP]:REGEXP' \
{-I,--list-installed=}'[list installed packages matching REGEXP]:REGEXP' \
{-A,--list-available=}'[list available packages matching REGEXP]:REGEXP' \
'--verbose[produce verbose output]' \
'--search=[search in synopsis and description using REGEXP]:REGEXP' \
'--list-installed=[list installed packages matching REGEXP]:REGEXP' \
'--list-available=[list available packages matching REGEXP]:REGEXP' \
'--show=[show details about a package]: :->show' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--load-path=[prepend DIR to the package module search path]:DIR:_dirs' \
'--keep-failed[keep build tree of failed builds]' \
'--keep-going[keep going when some of the derivations fail]' \
'--dry-run[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
@@ -331,13 +285,12 @@ _guix_list_installed_packages()
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--verbosity=[use the given verbosity LEVEL]:LEVEL' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]' \
'--help-transform[list package transformation options not shown here]' \
{-v,--verbosity=}'[use the given verbosity LEVEL]' \
{-V,--version}'[display version information and exit]'
'--cores=[allow the use of up to N CPU cores for the build]:N' \
'--max-jobs=[allow at most N build jobs]:N' \
'--with-source=[use SOURCE when building the corresponding package]:SOURCE' \
'--with-input=[replace dependency PACKAGE by REPLACEMENT]:PACKAGE=REPLACEMENT'
case "$state" in
install|show)
@@ -351,165 +304,37 @@ _guix_list_installed_packages()
esac
}
(( $+functions[_guix_install] )) || _guix_install()
{
_arguments \
{-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
'--no-grafts[do not graft packages]' \
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
'--help-transform[list package transformation options not shown here]' \
{-V,--version}'[display version information and exit]' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
_guix_list_available_packages
compadd -a -- _guix_available_packages
fi
}
(( $+functions[_guix_remove] )) || _guix_remove()
{
_arguments \
{-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
'--no-grafts[do not graft packages]' \
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
{-V,--version}'[display version information and exit]' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
_guix_list_installed_packages
compadd -a -- _guix_installed_packages
fi
}
(( $+functions[_guix_upgrade] )) || _guix_upgrade()
{
_arguments \
{-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
'--do-not-upgrade=[do not upgrade any packages matching REGEXP]:REGEXP' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
'--no-grafts[do not graft packages]' \
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
'--help-transform[list package transformation options not shown here]' \
{-V,--version}'[display version information and exit]' \
'*:regexp'
}
(( $+functions[_guix_publish] )) || _guix_publish()
{
_arguments \
{-p,--port=}'[listen on PORT]:PORT' \
'--listen=[listen on the network interface for HOST]:HOST_hosts' \
{-u,--user=}'[change privileges to USER as soon as possible]:USER_users' \
{-a,--advertise}'[advertise on the local network]' \
{-C,--compression=}'[compress archives with METHOD at LEVEL]:METHOD' \
{-c,--cache=}'[cache published items to DIRECTORY]:DIRECTORY:_files -/' \
'--cache-bypass-threshold=[serve store items below SIZE even when not cached]:SIZE' \
'--workers=[use N workers to bake items]:N' \
'--port=[listen on PORT]:PORT:' \
'--listen=[listen on the network interface for HOST]:HOST:_hosts' \
'--user=[change privileges to USER as soon as possible]:USER:_users' \
'--compression=[compress archives at LEVEL]:LEVEL' \
'--ttl=[announce narinfos can be cached for TTL seconds]:TTL' \
'--negative-ttl=[announce missing narinfos can be cached for TTL seconds]:TTL' \
'--nar-path=[use PATH as the prefix for nar URLs]:PATH' \
'--public-key=[use FILE as the public key for signatures]:FILE:_files' \
'--private-key=[use FILE as the private key for signatures]:FILE:_files' \
{-r,--repl=}'[spawn REPL server on PORT]:PORT' \
{-V,--version}'[display version information and exit]' \
'--repl=[spawn REPL server on PORT]:PORT'
}
(( $+functions[_guix_pull] )) || _guix_pull()
{
_arguments \
{-C,--channels=}'[deploy the channels defined in FILE]:FILE:_files' \
'--url=[download from the Git repository at URL]:URL:_urls' \
'--commit=[download the specified COMMIT]:COMMIT' \
'--branch=[download the tip of the specified BRANCH]:BRANCH' \
'--allow-downgrades[allow downgrades to earlier channel revisions]' \
'--disable-authentication[disable channel authentication]' \
{-N,--news}'[display news compared to the previous generation]' \
{-l,--list-generations=}'[list generations matching PATTERN]:PATTERN' \
'--roll-back[roll back to the previous generation]' \
{-d,--delete-generations=}'[delete generations matching PATTERN]:PATTERN' \
{-S,--switch-generation=}'[switch to a generation matching PATTERN]:PATTERN' \
{-p,--profile=}'[use PROFILE instead of ~/.config/guix/current]:PROFILE:_files -/' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
{-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
'--bootstrap[use the bootstrap Guile to build the new Guix]' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
'--no-grafts[do not graft packages]' \
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
{-V,--version}'[display version information and exit]'
'--verbose[produce verbose output]' \
'--url=[download the Guix tarball from URL]:URL:_urls' \
'--bootstrap[use the bootstrap Guile to build the new Guix]'
}
(( $+functions[_guix_refresh] )) || _guix_refresh()
{
_arguments \
{-e,--expression=}'[consider the package EXPR evaluates to]:EXPR' \
{-u,--update}'[update source files in place]' \
{-s,--select=}'[select all the packages in SUBSET, one of]:SUBSET:(core non-core)' \
{-m,--manifest=}'[select all the packages from the manifest in FILE]:FILE:_files' \
{-t,--type=}'[restrict to updates from the specified updaters]:UPDATER:-.updaters' \
{-L,--list-updaters}'[list available updaters and exit]' \
{-l,--list-dependent}'[list top-level dependent packages that would need to be rebuilt as a result of upgrading PACKAGE...]' \
{-r,--recursive}'[check the PACKAGE and its inputs for upgrades]' \
'--list-transitive[list all the packages that PACKAGE depends on]' \
'--keyring=[use FILE as the keyring of upstream OpenPGP keys]:FILE:_files' \
'--key-server=[use HOST as the OpenPGP key server]:HOST_hosts' \
'--expression=[consider the package EXPR evaluates to]:EXPR' \
'--update[update source files in place]' \
'--select=[select all the packages in SUBSET]:SUBSET:(core non-core)' \
'--type=[restrict to updates from the specified updaters]:UPDATER:->updaters' \
'--list-updaters[list available updaters and exit]' \
'--list-dependent[list top-level dependent packages]' \
'--key-server=[use HOST as the OpenPGP key server]:HOST:_hosts' \
'--gpg=[use COMMAND as the GnuPG 2.x command]:COMMAND' \
'--key-download=[handle missing OpenPGP keys according to POLICY:]:POLICY:(always interactive never)' \
'--load-path=[prepend DIR to the package module search path]:DIR:_files -/' \
{-V,--version}'[display version information and exit]' \
'--key-download=[policy to handle missing OpenPGP keys]:POLICY:(always interactive never)' \
'*:package:->packages'
case "$state" in
@@ -527,12 +352,9 @@ _guix_list_installed_packages()
(( $+functions[_guix_size] )) || _guix_size()
{
_arguments \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
{-s,--system=}'[consider packages for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
'--sort=[sort according to KEY]:KEY:(closure self)' \
{-m,--map-file=}'[write to FILE a graphical map of disk usage]:FILE:_files' \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-V,--version}'[display version information and exit]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URL:_urls' \
'-system=[consider packages for SYSTEM--e.g., "i686-linux"]:SYSTEM' \
'--map-file=[write to FILE a graphical map of disk usage]:FILE:_files' \
'*:package:->packages'
if [[ "$state" = packages ]]; then
@@ -544,42 +366,28 @@ _guix_list_installed_packages()
(( $+functions[_guix_system] )) || _guix_system()
{
_arguments \
{-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
{-K,--keep-failed}'[keep build tree of failed builds]' \
{-k,--keep-going}'[keep going when some of the derivations fail]' \
{-n,--dry-run}'[do not build the derivations]' \
'--load-path=[prepend DIR to the package module search path]:DIR:_dirs' \
'--keep-failed[keep build tree of failed builds]' \
'--keep-going[keep going when some of the derivations fail]' \
'--dry-run[do not build the derivations]' \
'--fallback[fall back to building when the substituter fails]' \
'--no-substitutes[build instead of resorting to pre-built substitutes]' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
'--substitute-urls=[fetch substitute from URLS if they are authorized]:URL:_urls' \
'--no-grafts[do not graft packages]' \
'--no-offload[do not attempt to offload builds]' \
'--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
'--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
'--verbosity=[use the given verbosity LEVEL]:LEVEL' \
'--rounds=[build N times in a row to detect non-determinism]:N' \
{-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
{-M,--max-jobs=}'[allow at most N build jobs]:N' \
'--debug=[produce debugging output at LEVEL]:LEVEL' \
{-d,--derivation}'[return the derivation of the given system]' \
{-e,--expression=}'[consider the operating-system EXPR evaluates to instead of reading FILE, when applicable]:EXPR' \
'--allow-downgrades[for reconfigure, allow downgrades to earlier channel revisions]' \
'--on-error=[apply STRATEGY when an error occurs while reading FILE]:STRATEGY:(nothing-special backtrace debug)' \
'--list-image-types[list available image types]' \
{-t,--image-type=}'[for image, produce an image of TYPE]:TYPE' \
'--image-size=[for image, produce an image of SIZE]:SIZE' \
'--no-bootloader[for init, do not install a bootloader]' \
'--volatile[for image, make the root file system volatile]' \
'--label=[for image, label disk image with LABEL]:LABEL' \
'--save-provenance[save provenance information]' \
'--share=[for vm and container, share host file system with read/write access according to SPEC]:SPEC' \
'--expose=[for vm and container, expose host file system directory as read-only according to SPEC]:SPEC' \
{-N,--network}'[for container, allow containers to access the network]' \
{-r,--root=}'[for vm, image, container and build, make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
'--full-boot[for vm, make a full boot sequence]' \
'--skip-checks[skip file system and initrd module safety checks]' \
'--target=[cross-build for TRIPLET (e.g. "armel-linux-gnu")]:TRIPLET' \
{-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
'--graph-backend=[use BACKEND for extension-graphs and shepherd-graph]:BACKEND' \
{-V,--version}'[display version information and exit]' \
'--cores=[allow the use of up to N CPU cores for the build]:N' \
'--max-jobs=[allow at most N build jobs]:N' \
'--derivation[return the derivation of the given system]' \
'--on-error=[apply STRATEGY when an error occurs while reading FILE]:STRATEGY' \
'--image-size=[for "vm-image", produce an image of SIZE]:SIZE' \
'--no-grub[for "init", do not install GRUB]' \
'--share=[for "vm", share host file system according to SPEC]:SPEC' \
'--expose=[for "vm", expose host file system according to SPEC]:SPEC' \
'--full-boot[for "vm", make a full boot sequence]' \
'1:action:->actions' \
'*:file:_files'
@@ -597,35 +405,20 @@ _guix_list_installed_packages()
"build:Build a given package"
"challenge:Challenge the substitutes for a package"
"container:Build and manipulate Linux containers"
"copy:Copy store items remotely over SSH"
"deploy:Deploy operating systems on a set of machines"
"describe:Describe the channel revisions currently used"
"download:Download the file at given URL and add it to the store"
"edit:Edit the definitions of a package"
"environment:Build an environment with a package and its dependencies"
"gc:Invoke the garbage collector"
"git:Operate on Git repositories"
"graph:Emit a DOT representation of the dependencies of a package"
"hash:Return the cryptographic hash of a file"
"import:Run an importer"
"install:Install packages"
"lint:Run a set of checkers on a package"
"offload:Set up and operate build offloading"
"pack:Create application bundles"
"package:Install, remove, or upgrade packages"
"processes:List currently running sessions"
"publish:Publish /gnu/store over HTTP."
"pull:Download and deploy the latest version of Guix"
"refresh:Update package definitions to match the latest version"
"remove:Remove packages"
"repl:Read-eval-print loop (REPL) for interactive programming"
"search:Search for packages"
"show:Show information about packages"
"size:Report the size of a package and its dependencies"
"system:Build the operating system"
"time-machine:Run commands from a different revision"
"upgrade:Upgrade packages"
"weather:Report on the availability of pre-built package binaries"
)
if (( CURRENT == 1 )); then
-112
View File
@@ -1,112 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; This file returns a manifest that builds a directory containing Disarchive
;;; metadata for all the tarballs packages refer to.
(use-modules (srfi srfi-1) (ice-9 match)
(guix packages) (guix gexp) (guix profiles)
(guix base16)
(gnu packages))
(include "source-manifest.scm")
(define (tarball-origin? origin)
(match (origin-actual-file-name origin)
(#f #f)
((? string? file)
;; As of version 0.2.1, Disarchive can only deal with raw tarballs and
;; gzip-compressed tarballs.
(and (origin-hash origin)
(or (string-suffix? ".tar.gz" file)
(string-suffix? ".tgz" file)
(string-suffix? ".tar" file))))))
(define (origin->disarchive origin)
"Return a directory containing Disarchive metadata for ORIGIN, a tarball, or
an empty directory if ORIGIN could not be disassembled."
(define file-name
(let ((hash (origin-hash origin)))
(string-append (symbol->string (content-hash-algorithm hash))
"/"
(bytevector->base16-string
(content-hash-value hash)))))
(define disarchive
(specification->package "disarchive"))
(define build
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils)
(srfi srfi-34))
(define tarball
#+(upstream-origin origin))
(define file-name
(string-append #$output "/" #$file-name))
(define profile
#+(profile (content (packages->manifest (list disarchive)))))
(mkdir-p (dirname file-name))
(setenv "PATH" (string-append profile "/bin"))
(setenv "GUILE_LOAD_PATH"
(string-append profile "/share/guile/site/"
(effective-version)))
(setenv "GUILE_LOAD_COMPILED_PATH"
(string-append profile "/lib/guile/" (effective-version)
"/site-ccache"))
(guard (c ((invoke-error? c)
;; Sometimes Disarchive fails with "could not find Gzip
;; compressor". When that happens, produce an empty
;; directory instead of failing.
(report-invoke-error c)
(delete-file file-name)))
(with-output-to-file file-name
(lambda ()
;; Disarchive records the tarball name in its output. Thus,
;; strip the hash from TARBALL.
(let ((short-name (strip-store-file-name tarball)))
(symlink tarball short-name)
(invoke "disarchive" "disassemble" short-name))))))))
(computed-file (match (origin-actual-file-name origin)
((? string? str) (string-append str ".dis"))
(#f "anonymous-tarball.dis"))
build))
(define (disarchive-collection origins)
"Return a directory containing all the Disarchive metadata for ORIGINS."
(directory-union "disarchive-collection"
(filter-map (lambda (origin)
(and (tarball-origin? origin)
(origin->disarchive origin)))
origins)
#:copy? #t))
;; The manifest containing Disarchive data.
(let ((origins (all-origins)))
(manifest
(list (manifest-entry
(name "disarchive-collection")
(version (number->string (length origins)))
(item (disarchive-collection origins))))))
-5
View File
@@ -1,5 +0,0 @@
[diff "scheme"]
xfuncname = "^(\\(define.*)$"
[diff "texinfo"]
xfuncname = "^@node[[:space:]]+([^,]+).*$"
+10 -23
View File
@@ -20,26 +20,13 @@
#
# <local ref> <local sha1> <remote ref> <remote sha1>
# This is the "empty hash" used by Git when pushing a branch deletion.
z40=0000000000000000000000000000000000000000
while read local_ref local_hash remote_ref remote_hash
do
# When deleting a remote branch, no commits are pushed to the remote, and
# thus there are no signatures to be verified.
if [ "$local_hash" != $z40 ]
then
# Only use the hook when pushing to Savannah.
case "$2" in
*.gnu.org*)
exec make authenticate check-channel-news
exit 127
;;
*)
exit 0
;;
esac
fi
done
exit 0
# Only use the hook when pushing to Savannah.
case "$2" in
*.gnu.org*)
exec make authenticate check-channel-news
exit 127
;;
*)
exit 0
;;
esac
+9 -39
View File
@@ -131,16 +131,14 @@
(lnk_file (create rename setattr unlink)))
(allow guix_daemon_t
tmp_t
(file (link
rename create execute execute_no_trans write
unlink setattr map relabelto relabelfrom)))
(file (link rename create execute execute_no_trans write unlink setattr map relabelto)))
(allow guix_daemon_t
tmp_t
(fifo_file (open read write create getattr ioctl setattr unlink)))
(allow guix_daemon_t
tmp_t
(dir (create rename
rmdir relabelto relabelfrom reparent
rmdir relabelto
add_name remove_name
open read write
getattr setattr
@@ -167,9 +165,7 @@
(process (fork execmem setrlimit setpgid setsched)))
(allow guix_daemon_t
guix_daemon_exec_t
(file (execute
execute_no_trans read write open entrypoint map
getattr link unlink)))
(file (execute execute_no_trans read open entrypoint map)))
;; TODO: unknown
(allow guix_daemon_t
@@ -268,7 +264,6 @@
link unlink
map
rename
append
open read write relabelfrom)))
(allow guix_daemon_t
guix_store_content_t
@@ -282,7 +277,7 @@
(fifo_file (create getattr open read unlink write)))
(allow guix_daemon_t
guix_store_content_t
(sock_file (create getattr setattr unlink write)))
(sock_file (create getattr unlink write)))
;; Access to configuration files and directories
(allow guix_daemon_t
@@ -301,7 +296,7 @@
open read write)))
(allow guix_daemon_t
guix_daemon_conf_t
(lnk_file (create getattr rename unlink read)))
(lnk_file (create getattr rename unlink)))
(allow guix_daemon_t net_conf_t
(file (getattr open read)))
(allow guix_daemon_t net_conf_t
@@ -328,9 +323,6 @@
(allow guix_daemon_t
cache_home_t
(dir (search)))
(allow guix_daemon_t
cache_home_t
(lnk_file (getattr read)))
;; self upgrades
(allow guix_daemon_t
@@ -338,12 +330,12 @@
(dir (add_name write)))
(allow guix_daemon_t
self
(netlink_route_socket (bind create getattr nlmsg_read read write getopt)))
(netlink_route_socket (bind create getattr nlmsg_read read write)))
;; Socket operations
(allow guix_daemon_t
guix_daemon_socket_t
(sock_file (unlink write)))
(sock_file (unlink)))
(allow guix_daemon_t
init_t
(fd (use)))
@@ -355,7 +347,7 @@
(unix_stream_socket (listen)))
(allow guix_daemon_t
guix_daemon_conf_t
(sock_file (create unlink write)))
(sock_file (create unlink)))
(allow guix_daemon_t
self
(unix_stream_socket (create
@@ -370,7 +362,7 @@
(tcp_socket (name_bind name_connect accept listen)))
(allow guix_daemon_t
self
(udp_socket (connect getattr bind getopt setopt read write)))
(udp_socket (connect getattr bind getopt setopt)))
(allow guix_daemon_t
self
(fifo_file (write read)))
@@ -380,14 +372,7 @@
(allow guix_daemon_t
self
(unix_stream_socket (connectto)))
(allow guix_daemon_t
self
(unix_dgram_socket (create bind connect sendto read write)))
;; For some esoteric build jobs (i.e. running PostgreSQL, etc).
(allow guix_daemon_t
self
(capability (kill)))
(allow guix_daemon_t
node_t
(tcp_socket (node_bind)))
@@ -397,21 +382,6 @@
(allow guix_daemon_t
port_t
(tcp_socket (name_connect)))
(allow guix_daemon_t
tmpfs_t
(file (map read write link getattr)))
(allow guix_daemon_t
usermodehelper_t
(file (read)))
(allow guix_daemon_t
hugetlbfs_t
(file (map read write)))
(allow guix_daemon_t
proc_net_t
(file (read)))
(allow guix_daemon_t
postgresql_port_t
(tcp_socket (name_connect name_bind)))
(allow guix_daemon_t
rtp_media_port_t
(udp_socket (name_bind)))
+1 -1
View File
@@ -7,4 +7,4 @@ start on runlevel [2345]
stop on runlevel [016]
exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild --discover=no
exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild
+1 -2
View File
@@ -6,8 +6,7 @@
Description=Build daemon for GNU Guix
[Service]
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
--build-users-group=guixbuild --discover=no
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild
Environment='GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale' LC_ALL=en_US.utf8
RemainAfterExit=yes
StandardOutput=syslog
-20
View File
@@ -1,20 +0,0 @@
# This is a "service unit file" for the systemd init system to perform a
# one-shot 'guix gc' operation. It is meant to be triggered by a timer.
# Drop it in /etc/systemd/system or similar together with 'guix-gc.timer'
# to set it up.
[Unit]
Description=Discard unused Guix store items
[Service]
Type=oneshot
# Customize the 'guix gc' arguments to fit your needs.
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix gc -d 1m -F 10G
PrivateDevices=yes
PrivateNetwork=yes
PrivateUsers=no
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
MemoryDenyWriteExecute=yes
SystemCallFilter=@default @file-system @basic-io @system-service
-15
View File
@@ -1,15 +0,0 @@
# This is a "timer unit file" for the systemd init system to trigger
# 'guix-gc.service' periodically. Drop it in /etc/systemd/system or similar
# together with 'guix-gc.service' to set it up.
[Unit]
Description=Discard unused Guix store items
[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true
RandomizedDelaySec=6000
[Install]
WantedBy=timers.target
+93 -152
View File
@@ -7,9 +7,6 @@
# Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
# Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
# Copyright © 2020 Daniel Brooks <db48x@db48x.net>
# Copyright © 2021 Jakub Kądziołka <kuba@kadziolka.net>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
# Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
#
# This file is part of GNU Guix.
#
@@ -65,12 +62,12 @@ INF="[ INFO ] "
DEBUG=0
GNU_URL="https://ftp.gnu.org/gnu/guix/"
#GNU_URL="https://alpha.gnu.org/gnu/guix/"
OPENPGP_SIGNING_KEY_ID="3CE464558A84FDC69DB40CFB090B11993D9AEBB5"
# The following associative array holds set of GPG keys used to sign the
# releases, keyed by their corresponding Savannah user ID.
declare -A GPG_SIGNING_KEYS
GPG_SIGNING_KEYS[15145]=3CE464558A84FDC69DB40CFB090B11993D9AEBB5 # ludo
GPG_SIGNING_KEYS[127547]=27D586A4F8900854329FF09F1260E46482E63562 # maxim
# This script needs to know where root's home directory is. However, we
# cannot simply use the HOME environment variable, since there is no guarantee
# that it points to root's home directory.
ROOT_HOME="$(echo ~root)"
# ------------------------------------------------------------------------------
#+UTILITIES
@@ -92,25 +89,13 @@ _debug()
fi
}
# Return true if user answered yes, false otherwise.
# $1: The prompt question.
prompt_yes_no() {
while true; do
read -rp "$1 " yn
case $yn in
[Yy]*) return 0;;
[Nn]*) return 1;;
*) _msg "Please answer yes or no."
esac
done
}
chk_require()
{ # Check that every required command is available.
declare -a warn
local c
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
for c in "$@"; do
command -v "$c" &>/dev/null || warn+=("$c")
@@ -125,44 +110,29 @@ chk_require()
chk_gpg_keyring()
{ # Check whether the Guix release signing public key is present.
_debug "--- [ ${FUNCNAME[0]} ] ---"
local user_id
local gpg_key_id
local exit_flag
_debug "--- [ $FUNCNAME ] ---"
for user_id in "${!GPG_SIGNING_KEYS[@]}"; do
gpg_key_id=${GPG_SIGNING_KEYS[$user_id]}
# Without --dry-run this command will create a ~/.gnupg owned by root on
# systems where gpg has never been used, causing errors and confusion.
if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then
if prompt_yes_no "${INF}The following OpenPGP public key is \
required to verify the Guix binary signature: $gpg_key_id.
Would you like me to fetch it for you? (yes/no)"; then
wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \
--no-verbose -O- | gpg --import -
else
_err "${ERR}Missing OpenPGP public key ($gpg_key_id).
Fetch it with this command:
wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -O - | \
sudo -i gpg --import -"
exit_flag=yes
fi
fi
done
if [ "$exit_flag" = yes ]; then
# Without --dry-run this command will create a ~/.gnupg owned by root on
# systems where gpg has never been used, causing errors and confusion.
gpg --dry-run --list-keys ${OPENPGP_SIGNING_KEY_ID} >/dev/null 2>&1 || (
_err "${ERR}Missing OpenPGP public key. Fetch it with this command:"
echo " wget 'https://sv.gnu.org/people/viewgpg.php?user_id=15145' -qO - | sudo -i gpg --import -"
exit 1
fi
)
}
chk_term()
{ # Check for ANSI terminal for color printing.
local ansi_term
if [ -t 2 ]; then
if [ "${TERM+set}" = 'set' ]; then
case "$TERM" in
xterm*|rxvt*|urxvt*|linux*|vt*|eterm*|screen*)
ansi_term=true
;;
*)
ansi_term=false
ERR="[ FAIL ] "
PAS="[ PASS ] "
;;
@@ -213,12 +183,9 @@ chk_sys_arch()
aarch64)
local arch=aarch64
;;
armv7l)
local arch=armhf
;;
ppc64le | powerpc64le)
local arch=powerpc64le
;;
armv7l)
local arch=armhf
;;
*)
_err "${ERR}Unsupported CPU type: ${arch}"
exit 1
@@ -249,16 +216,6 @@ chk_sys_nscd()
fi
}
# Configure substitute discovery according to user's preferences.
# $1 is the installed service file to edit.
configure_substitute_discovery() {
if grep -q -- '--discover=no' "$1" && \
prompt_yes_no "Would you like the Guix daemon to automatically \
discover substitute servers on the local network? (yes/no)"; then
sed -i 's/--discover=no/--discover=yes/' "$1"
fi
}
# ------------------------------------------------------------------------------
#+MAIN
@@ -269,14 +226,14 @@ guix_get_bin_list()
local latest_ver
local default_ver
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
# Filter only version and architecture
bin_ver_ls=("$(wget "$gnu_url" --no-verbose -O- \
bin_ver_ls=("$(wget -qO- "$gnu_url" \
| sed -n -e 's/.*guix-binary-\([0-9.]*[a-z0-9]*\)\..*.tar.xz.*/\1/p' \
| sort -Vu)")
latest_ver="$(echo "${bin_ver_ls[0]}" \
latest_ver="$(echo "$bin_ver_ls" \
| grep -oE "([0-9]{1,2}\.){2}[0-9]{1,2}[a-z0-9]*" \
| tail -n1)"
@@ -290,7 +247,7 @@ guix_get_bin_list()
fi
# Use default to download according to the list and local ARCH_OS.
BIN_VER="${default_ver}"
BIN_VER="$default_ver"
}
guix_get_bin()
@@ -298,25 +255,25 @@ guix_get_bin()
local url="$1"
local bin_ver="$2"
local dl_path="$3"
local wget_args=()
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
_msg "${INF}Downloading Guix release archive"
wget --help | grep -q '\--show-progress' \
&& wget_args=("--no-verbose" "--show-progress")
wget --help | grep -q '\--show-progress' && \
_PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT=""
wget $_PROGRESS_OPT -P "$dl_path" "${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig"
if wget "${wget_args[@]}" -P "$dl_path" \
"${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig"; then
_msg "${PAS}download completed."
if [[ "$?" -eq 0 ]]; then
_msg "${PAS}download completed."
else
_err "${ERR}could not download ${url}/${bin_ver}.tar.xz."
exit 1
fi
pushd "${dl_path}" >/dev/null
if gpg --verify "${bin_ver}.tar.xz.sig" >/dev/null 2>&1; then
pushd $dl_path >/dev/null
gpg --verify "${bin_ver}.tar.xz.sig" >/dev/null 2>&1
if [[ "$?" -eq 0 ]]; then
_msg "${PAS}Signature is valid."
popd >/dev/null
else
@@ -330,57 +287,53 @@ sys_create_store()
local pkg="$1"
local tmp_path="$2"
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
cd "$tmp_path"
tar --extract \
--file "$pkg" &&
_msg "${PAS}unpacked archive"
if [[ -e "/var/guix" || -e "/gnu" ]]; then
_err "${ERR}A previous Guix installation was found. Refusing to overwrite."
exit 1
else
_msg "${INF}Installing /var/guix and /gnu..."
mv "${tmp_path}/var/guix" /var/
mv "${tmp_path}/gnu" /
fi
cd "$tmp_path"
tar --extract --file "$pkg" && _msg "${PAS}unpacked archive"
_msg "${INF}Installing /var/guix and /gnu..."
mv "${tmp_path}/var/guix" /var/
mv "${tmp_path}/gnu" /
_msg "${INF}Linking the root user's profile"
mkdir -p ~root/.config/guix
mkdir -p "${ROOT_HOME}/.config/guix"
ln -sf /var/guix/profiles/per-user/root/current-guix \
~root/.config/guix/current
"${ROOT_HOME}/.config/guix/current"
GUIX_PROFILE=~root/.config/guix/current
# shellcheck disable=SC1090
GUIX_PROFILE="${ROOT_HOME}/.config/guix/current"
source "${GUIX_PROFILE}/etc/profile"
_msg "${PAS}activated root profile at ${GUIX_PROFILE}"
_msg "${PAS}activated root profile at ${ROOT_HOME}/.config/guix/current"
}
sys_create_build_user()
{ # Create the group and user accounts for build users.
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
if getent group guixbuild > /dev/null; then
if [ $(getent group guixbuild) ]; then
_msg "${INF}group guixbuild exists"
else
groupadd --system guixbuild
_msg "${PAS}group <guixbuild> created"
fi
if getent group kvm > /dev/null; then
_msg "${INF}group kvm exists and build users will be added to it"
local KVMGROUP=,kvm
fi
for i in $(seq -w 1 10); do
if id "guixbuilder${i}" &>/dev/null; then
_msg "${INF}user is already in the system, reset"
usermod -g guixbuild -G guixbuild${KVMGROUP} \
usermod -g guixbuild -G guixbuild \
-d /var/empty -s "$(which nologin)" \
-c "Guix build user $i" \
"guixbuilder${i}";
else
useradd -g guixbuild -G guixbuild${KVMGROUP} \
useradd -g guixbuild -G guixbuild \
-d /var/empty -s "$(which nologin)" \
-c "Guix build user $i" --system \
"guixbuilder${i}";
@@ -396,7 +349,7 @@ sys_enable_guix_daemon()
local local_bin
local var_guix
_debug "--- [ ${FUNCNAME[0]} ] ---"
_debug "--- [ $FUNCNAME ] ---"
info_path="/usr/local/share/info"
local_bin="/usr/local/bin"
@@ -405,9 +358,8 @@ sys_enable_guix_daemon()
case "$INIT_SYS" in
upstart)
{ initctl reload-configuration;
cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
cp "${ROOT_HOME}/.config/guix/current/lib/upstart/system/guix-daemon.conf" \
/etc/init/ &&
configure_substitute_discovery /etc/init/guix-daemon.conf &&
start guix-daemon; } &&
_msg "${PAS}enabled Guix daemon via upstart"
;;
@@ -415,30 +367,27 @@ sys_enable_guix_daemon()
{ # systemd .mount units must be named after the target directory.
# Here we assume a hard-coded name of /gnu/store.
# XXX Work around <https://issues.guix.gnu.org/41356> until next release.
if [ -f ~root/.config/guix/current/lib/systemd/system/gnu-store.mount ]; then
cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
if [ -f "${ROOT_HOME}/.config/guix/current/lib/systemd/system/gnu-store.mount" ]; then
cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/gnu-store.mount" \
/etc/systemd/system/;
chmod 664 /etc/systemd/system/gnu-store.mount;
systemctl daemon-reload &&
systemctl enable gnu-store.mount;
fi
cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/guix-daemon.service" \
/etc/systemd/system/;
chmod 664 /etc/systemd/system/guix-daemon.service;
# Work around <https://bugs.gnu.org/36074>, present in 1.0.1.
sed -i /etc/systemd/system/guix-daemon.service \
-e "s/GUIX_LOCPATH='/'GUIX_LOCPATH=/";
# Work around <https://bugs.gnu.org/36074>, present in 1.0.1.
sed -i /etc/systemd/system/guix-daemon.service \
-e "s/GUIX_LOCPATH='/'GUIX_LOCPATH=/";
# Work around <https://bugs.gnu.org/35671>, present in 1.0.1.
if ! grep en_US /etc/systemd/system/guix-daemon.service >/dev/null;
then sed -i /etc/systemd/system/guix-daemon.service \
-e 's/^Environment=\(.*\)$/Environment=\1 LC_ALL=en_US.UTF-8';
fi;
configure_substitute_discovery \
/etc/systemd/system/guix-daemon.service
# Work around <https://bugs.gnu.org/35671>, present in 1.0.1.
if ! grep en_US /etc/systemd/system/guix-daemon.service >/dev/null;
then sed -i /etc/systemd/system/guix-daemon.service \
-e 's/^Environment=\(.*\)$/Environment=\1 LC_ALL=en_US.UTF-8';
fi;
systemctl daemon-reload &&
systemctl enable guix-daemon &&
@@ -447,12 +396,10 @@ sys_enable_guix_daemon()
;;
sysv-init)
{ mkdir -p /etc/init.d;
cp ~root/.config/guix/current/etc/init.d/guix-daemon \
cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \
/etc/init.d/guix-daemon;
chmod 775 /etc/init.d/guix-daemon;
configure_substitute_discovery /etc/init.d/guix-daemon
update-rc.d guix-daemon defaults &&
update-rc.d guix-daemon enable &&
service guix-daemon start; } &&
@@ -460,19 +407,17 @@ sys_enable_guix_daemon()
;;
openrc)
{ mkdir -p /etc/init.d;
cp ~root/.config/guix/current/etc/openrc/guix-daemon \
cp "${ROOT_HOME}/.config/guix/current/etc/openrc/guix-daemon" \
/etc/init.d/guix-daemon;
chmod 775 /etc/init.d/guix-daemon;
configure_substitute_discovery /etc/init.d/guix-daemon
rc-update add guix-daemon default &&
rc-service guix-daemon start; } &&
_msg "${PAS}enabled Guix daemon via OpenRC"
;;
NA|*)
_msg "${ERR}unsupported init system; run the daemon manually:"
echo " ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
echo " ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
;;
esac
@@ -482,42 +427,47 @@ sys_enable_guix_daemon()
ln -sf "${var_guix}/bin/guix" "$local_bin"
[ -e "$info_path" ] || mkdir -p "$info_path"
for i in "${var_guix}"/share/info/*; do
for i in ${var_guix}/share/info/*; do
ln -sf "$i" "$info_path"
done
}
sys_authorize_build_farms()
{ # authorize the public key of the build farm
if prompt_yes_no "Permit downloading pre-built package binaries from the \
project's build farm? (yes/no)"; then
guix archive --authorize \
< ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub \
&& _msg "${PAS}Authorized public key for ci.guix.gnu.org"
else
_msg "${INF}Skipped authorizing build farm public keys"
fi
while true; do
read -p "Permit downloading pre-built package binaries from the project's build farm? (yes/no) " yn
case $yn in
[Yy]*) guix archive --authorize < "${ROOT_HOME}/.config/guix/current/share/guix/ci.guix.gnu.org.pub" &&
_msg "${PAS}Authorized public key for ci.guix.gnu.org";
break;;
[Nn]*) _msg "${INF}Skipped authorizing build farm public keys"
break;;
*) _msg "Please answer yes or no.";
esac
done
}
sys_create_init_profile()
{ # Define for better desktop integration
{ # Create /etc/profile.d/guix.sh for better desktop integration
# This will not take effect until the next shell or desktop session!
[ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case
cat <<"EOF" > /etc/profile.d/guix.sh
# _GUIX_PROFILE: `guix pull` profile
_GUIX_PROFILE="$HOME/.config/guix/current"
export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
# Export INFOPATH so that the updated info pages can be found
# and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info
# When INFOPATH is unset, add a trailing colon so that Emacs
# searches 'Info-default-directory-list'.
export INFOPATH="$_GUIX_PROFILE/share/info:$INFOPATH"
if [ -L $_GUIX_PROFILE ]; then
export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
# Export INFOPATH so that the updated info pages can be found
# and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info
# When INFOPATH is unset, add a trailing colon so that Emacs
# searches 'Info-default-directory-list'.
export INFOPATH="$_GUIX_PROFILE/share/info:$INFOPATH"
fi
# GUIX_PROFILE: User's default profile
GUIX_PROFILE="$HOME/.guix-profile"
[ -L $GUIX_PROFILE ] || return
GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
export GUIX_LOCPATH
export GUIX_PROFILE GUIX_LOCPATH
[ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile"
@@ -574,7 +524,7 @@ This script installs GNU Guix on your system
https://www.gnu.org/software/guix/
EOF
echo -n "Press return to continue..."
read -r
read -r ANSWER
}
main()
@@ -596,19 +546,10 @@ main()
umask 0022
tmp_path="$(mktemp -t -d guix.XXX)"
if [ -z "${GUIX_BINARY_FILE_NAME}" ]; then
guix_get_bin_list "${GNU_URL}"
guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
GUIX_BINARY_FILE_NAME=${BIN_VER}.tar.xz
else
if ! [[ $GUIX_BINARY_FILE_NAME =~ $ARCH_OS ]]; then
_err "$ARCH_OS not in ${GUIX_BINARY_FILE_NAME}; aborting"
fi
_msg "${INF}Using manually provided binary ${GUIX_BINARY_FILE_NAME}"
GUIX_BINARY_FILE_NAME=$(realpath "$GUIX_BINARY_FILE_NAME")
fi
guix_get_bin_list "${GNU_URL}"
guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
sys_create_store "${GUIX_BINARY_FILE_NAME}" "${tmp_path}"
sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
sys_create_build_user
sys_enable_guix_daemon
sys_authorize_build_farms
-3
View File
@@ -4,9 +4,6 @@
[Unit]
Description=Publish the GNU Guix store
Requires=guix-daemon.service
PartOf=guix-daemon.service
After=guix-daemon.service
[Service]
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix publish --user=nobody --port=8181
+117
View File
@@ -0,0 +1,117 @@
:;exec emacs --batch --quick --load="$0" --funcall=main "$@"
;;; 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>
;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;; 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))
(defun main ()
(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
+1 -1
View File
@@ -36,7 +36,7 @@ start)
-E LC_ALL=en_US.utf8 \
-p "/var/run/guix-daemon.pid" \
@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
--build-users-group=guixbuild --discover=no
--build-users-group=guixbuild
fi
;;
stop)
+18 -1533
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -20,7 +20,7 @@
export GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale
export LC_ALL=en_US.utf8
command="@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon"
command_args="--build-users-group=guixbuild --discover=no"
command_args="--build-users-group=guixbuild"
command_background="yes"
pidfile="/var/run/guix-daemon.pid"
+7 -29
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -49,14 +49,6 @@ TARGET."
'("bootstrap-tarballs" "gcc-toolchain" "nss-certs"
"openssh" "emacs" "vim" "python" "guile" "guix")))
(define %base-packages/armhf
;; XXX: Relax requirements for armhf-linux for lack of enough build power.
(map (lambda (package)
(if (string=? (package-name package) "emacs")
(specification->package "emacs-no-x")
package))
%base-packages))
(define %base-packages/hurd
;; XXX: For now we are less demanding of "i586-gnu".
(map specification->package
@@ -108,30 +100,16 @@ TARGET."
(manifest
(append-map (lambda (system)
(map (cut package->manifest-entry* <> system)
(cond ((string=? system "i586-gnu")
%base-packages/hurd)
((string=? system "armhf-linux")
;; FIXME: Drop special case when ci.guix.gnu.org
;; has more ARMv7 build power.
%base-packages/armhf)
((string=? system "powerpc64le-linux")
;; FIXME: Drop 'bootstrap-tarballs' until
;; <https://bugs.gnu.org/48055> is fixed.
(drop %base-packages 1))
(else
%base-packages))))
%cuirass-supported-systems)))
(if (string=? system "i586-gnu")
%base-packages/hurd
%base-packages)))
%hydra-supported-systems)))
(define %system-manifest
(manifest
(append-map (lambda (system)
;; Some of %SYSTEM-PACKAGES are currently unsupported on some
;; systems--e.g., GNOME on non-x86_64, due to Rust. Filter
;; them out.
(filter-map (lambda (package)
(and (supported-package? package system)
(package->manifest-entry* package system)))
%system-packages))
(map (cut package->manifest-entry* <> system)
%system-packages))
'("x86_64-linux" "i686-linux")))) ;Guix System
(define %cross-manifest
+1 -3
View File
@@ -19,9 +19,7 @@
(t "(string-append \\"https://\\" version \\".tar.gz\\")"))}$0)
${1:$(cond ((equal yas-text "git-fetch")
"(file-name (git-file-name name version))")
((equal yas-text "hg-fetch")
"(file-name (hg-file-name name version))")
((member yas-text '("svn-fetch" "cvs-fetch" "bzr-fetch"))
((member yas-text '("svn-fetch" "hg-fetch" "cvs-fetch" "bzr-fetch"))
"(file-name (string-append name \\"-\\" version \\"-checkout\\"))")
(t ""))}
(sha256
-10
View File
@@ -11,30 +11,20 @@
"ant-build-system"
"asdf-build-system"
"cargo-build-system"
"clojure-build-system"
"cmake-build-system"
"copy-build-system"
"dub-build-system"
"dune-build-system"
"emacs-build-system"
"font-build-system"
"glib-or-gtk-build-system"
"gnu-build-system"
"go-build-system"
"guile-build-system"
"haskell-build-system"
"julia-build-system"
"linux-module-build-system"
"maven-build-system"
"meson-build-system"
"minify-build-system"
"node-build-system"
"ocaml-build-system"
"perl-build-system"
"python-build-system"
"qt-build-system"
"r-build-system"
"rakudo-build-system"
"ruby-build-system"
"scons-build-system"
"texlive-build-system"
@@ -1,15 +0,0 @@
# -*- mode: snippet -*-
# name: guix-commit-message-add-cl-package
# key: addcl
# condition: git-commit-mode
# --
gnu: Add ${1:`(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(beginning-of-buffer)
(when (search-forward "+(define-public " nil 'noerror)
(replace-regexp-in-string
"^sbcl-" ""
(thing-at-point 'sexp 'no-properties))))`}.
* `(car (magit-staged-files))` (cl-${1:$(replace-regexp-in-string "^cl-" "" yas-text)}, ecl-$1, sbcl-$1): New variables.
@@ -6,8 +6,8 @@
gnu: Add ${1:`(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(when (re-search-forward "\\+(define-public \\(\\S-+\\)" nil 'noerror)
(match-string-no-properties 1)))`}.
(beginning-of-buffer)
(when (search-forward "(define-public " nil 'noerror)
(thing-at-point 'sexp 'no-properties)))`}.
* `(car (magit-staged-files))` ($1): New variable.
@@ -7,12 +7,12 @@
gnu: ${1:`(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror)
(match-string-no-properties 1)))`}: Update to ${2:`(with-temp-buffer
(beginning-of-buffer)
(when (search-forward "(define-public " nil 'noerror)
(thing-at-point 'sexp 'no-properties)))`}: Update to ${2:`(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(beginning-of-buffer)
(search-forward "name" nil 'noerror)
(search-forward "+" nil 'noerror) ; first change
(when (and (search-forward "version " nil 'noerror)
-66
View File
@@ -1,66 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; This file returns a manifest containing origins of all the packages. The
;;; main purpose is to allow continuous integration services to keep upstream
;;; source code around. It can also be passed to 'guix weather -m'.
(use-modules (srfi srfi-1) (srfi srfi-26)
(ice-9 match) (ice-9 vlist)
(guix packages) (guix profiles)
(gnu packages))
(define (all-packages)
"Return the list of all the packages, public or private, omitting only
superseded packages."
(fold-packages (lambda (package lst)
(match (package-replacement package)
(#f (cons package lst))
(replacement
(append (list replacement package) lst))))
'()
#:select? (negate package-superseded)))
(define (upstream-origin source)
"Return SOURCE without any patches or snippet."
(origin (inherit source)
(snippet #f) (patches '())))
(define (all-origins)
"Return the list of origins referred to by all the packages."
(let loop ((packages (all-packages))
(origins '())
(visited vlist-null))
(match packages
((head . tail)
(let ((new (remove (cut vhash-assq <> visited)
(package-direct-sources head))))
(loop tail (append new origins)
(fold (cut vhash-consq <> #t <>)
visited new))))
(()
origins))))
;; Return a manifest containing all the origins.
(manifest (map (lambda (origin)
(manifest-entry
(name (or (origin-actual-file-name origin)
"origin"))
(version "0")
(item (upstream-origin origin))))
(all-origins)))
@@ -1,6 +0,0 @@
(public-key
(ecc
(curve Ed25519)
(q #7D602902D3A2DBB83F8A0FB98602A754C5493B0B778C8D1DD4E0F41DE14DE34F#)
)
)
+5 -155
View File
@@ -2,7 +2,7 @@
;;; Copyright © 2017 David Craven <david@craven.ch>
;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2019, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -22,13 +22,8 @@
(define-module (gnu bootloader)
#:use-module (guix discovery)
#:use-module (guix gexp)
#:use-module (guix profiles)
#:use-module (guix records)
#:use-module (guix deprecation)
#:use-module ((guix ui) #:select (warn-about-load-error))
#:use-module (guix diagnostics)
#:use-module (guix i18n)
#:use-module (guix ui)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (menu-entry
@@ -58,8 +53,7 @@
bootloader-configuration
bootloader-configuration?
bootloader-configuration-bootloader
bootloader-configuration-target ;deprecated
bootloader-configuration-targets
bootloader-configuration-target
bootloader-configuration-menu-entries
bootloader-configuration-default-entry
bootloader-configuration-timeout
@@ -72,9 +66,7 @@
bootloader-configuration-additional-configuration
%bootloaders
lookup-bootloader-by-name
efi-bootloader-chain))
lookup-bootloader-by-name))
;;;
@@ -183,22 +175,12 @@ 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 ;list of strings
(target bootloader-configuration-target ;string
(default #f))
(target %bootloader-configuration-target ;deprecated
(default #f) (sanitize warn-target-field-deprecation))
(menu-entries bootloader-configuration-menu-entries ;list of <menu-entry>
(default '()))
(default-entry bootloader-configuration-default-entry ;integer
@@ -218,19 +200,6 @@ instead~%")))
(serial-speed bootloader-configuration-serial-speed ;integer | #f
(default #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.
@@ -258,122 +227,3 @@ instead~%")))
(eq? name (bootloader-name bootloader)))
(force %bootloaders))
(leave (G_ "~a: no such bootloader~%") name)))
(define (efi-bootloader-profile files bootloader-package hooks)
"Creates a profile with BOOTLOADER-PACKAGE and a directory collection/ with
links to additional FILES from the store. This collection 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 collection/ directory. If a directory name ends with '/',
then the directory content instead of the directory itself will be symlinked
into the collection/ directory.
FILES may contain file like objects produced by functions like plain-file,
local-file, etc., or package contents produced with file-append.
HOOKS lists additional hook functions to modify the profile."
(define (bootloader-collection manifest)
(define build
(with-imported-modules '((guix build utils)
(ice-9 ftw)
(srfi srfi-1)
(srfi srfi-26))
#~(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* ((collection (string-append #$output "/collection"))
(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 collection)
(if (every file-exists? names)
(begin
(for-each (lambda (name)
(symlink-to name collection
(if (name-is-store-entry? name)
strip-store-file-name
basename)))
names)
#t)
#f)))))
(gexp->derivation "bootloader-collection"
build
#:local-build? #t
#:substitutable? #f
#:properties
`((type . profile-hook)
(hook . bootloader-collection))))
(profile (content (packages->manifest (list bootloader-package)))
(name "bootloader-profile")
(hooks (append (list bootloader-collection) hooks))
(locales? #f)
(allow-collisions? #f)
(relative-symlinks? #f)))
(define* (efi-bootloader-chain files
final-bootloader
#:key
(hooks '())
installer)
"Define a bootloader chain with FINAL-BOOTLOADER as the final bootloader and
certain directories and files from the store given in the list of FILES.
FILES may contain file like objects produced by functions like plain-file,
local-file, etc., or package contents produced with file-append. They will be
collected inside a directory collection/ inside a generated bootloader profile,
which will be passed to the INSTALLER.
If a directory name in FILES ends with '/', then the directory content instead
of the directory itself will be symlinked into the collection/ directory.
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 function will be called to install
the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called."
(let* ((final-installer (or installer
(bootloader-installer final-bootloader)))
(profile (efi-bootloader-profile files
(bootloader-package final-bootloader)
(if (list? hooks)
hooks
(list hooks)))))
(bootloader
(inherit final-bootloader)
(package profile)
(installer
#~(lambda (bootloader target mount-point)
(#$final-installer bootloader target mount-point)
(copy-recursively
(string-append bootloader "/collection")
(string-append mount-point target)
#:follow-symlinks? #t
#:log (%make-void-port "w")))))))
+62 -82
View File
@@ -4,7 +4,7 @@
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
;;; Copyright © 2019 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
;;;
@@ -168,14 +168,15 @@ STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POINT is
its mount point; these are used to determine where the background image and
fonts must be searched for. STORE-DIRECTORY-PREFIX is a directory prefix to
prepend to any store file name."
(define (setup-gfxterm config)
(define (setup-gfxterm config font-file)
(if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
#~(format #f "
if loadfont unicode; then
if loadfont ~a; then
set gfxmode=~a
insmod all_video
insmod gfxterm
fi~%"
#+font-file
#$(string-join
(grub-theme-gfxmode (bootloader-theme config))
";"))
@@ -187,6 +188,13 @@ fi~%"
(string-append (symbol->string (assoc-ref colors 'fg)) "/"
(symbol->string (assoc-ref colors 'bg)))))
(define font-file
(let* ((bootloader (bootloader-configuration-bootloader config))
(grub (bootloader-package bootloader)))
(normalize-file (file-append grub "/share/grub/unicode.pf2")
store-mount-point
store-directory-prefix)))
(define image
(normalize-file (grub-background-image config)
store-mount-point
@@ -208,8 +216,8 @@ else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi~%"
#$(grub-root-search store-device image)
#$(setup-gfxterm config)
#$(grub-root-search store-device font-file)
#$(setup-gfxterm config font-file)
#$(grub-setup-io config)
#$image
@@ -264,38 +272,36 @@ is a string that can be inserted in grub.cfg."
at_keyboard usb_keyboard))
(io (string-append
;; UNIT and SPEED are arguments to the same GRUB command
;; ("serial"), so we process them together.
(if (or unit speed)
(string-append
"serial"
(if unit
;; COM ports 1 through 4
(if (and (exact-integer? unit) (<= unit 3) (>= unit 0))
(string-append " --unit=" (number->string unit))
#f)
"")
(if speed
(if (exact-integer? speed)
(string-append " --speed=" (number->string speed))
#f)
"")
"\n")
"")
(if (null? inputs)
""
(string-append
"terminal_output "
(symbols->string
(map
(lambda (output)
(if (memq output valid-outputs) output #f)) outputs)) "\n"
(if (null? inputs)
""
(string-append
"terminal_input "
(symbols->string
(map
(lambda (input)
(if (memq input valid-inputs) input #f)) inputs))
"\n"))
"terminal_output "
(symbols->string
(map
(lambda (output)
(if (memq output valid-outputs) output #f)) outputs)))))
(map
(lambda (input)
(if (memq input valid-inputs) input #f)) inputs)) "\n"))
;; UNIT and SPEED are arguments to the same GRUB command
;; ("serial"), so we process them together.
(if (or unit speed)
(string-append
"serial"
(if unit
;; COM ports 1 through 4
(if (and (exact-integer? unit) (<= unit 3) (>= unit 0))
(string-append " --unit=" (number->string unit))
#f)
"")
(if speed
(if (exact-integer? speed)
(string-append " --speed=" (number->string speed))
#f)
""))
""))))
(format #f "~a" io)))
(define (grub-root-search device file)
@@ -353,14 +359,11 @@ code."
(locale #f)
(system (%current-system))
(old-entries '())
(store-crypto-devices '())
store-directory-prefix)
"Return the GRUB configuration file corresponding to CONFIG, a
<bootloader-configuration> object, and where the store is available at
STORE-FS, a <file-system> object. OLD-ENTRIES is taken to be a list of menu
entries corresponding to old generations of the system.
STORE-CRYPTO-DEVICES contain the UUIDs of the encrypted units that must
be unlocked to access the store contents.
STORE-DIRECTORY-PREFIX may be used to specify a store prefix, as is required
when booting a root file system on a Btrfs subvolume."
(define all-entries
@@ -408,20 +411,6 @@ menuentry ~s {
(string-join (map string-join '#$modules)
"\n module " 'prefix))))))
(define (crypto-devices)
(define (crypto-device->cryptomount dev)
(if (uuid? dev)
#~(format port "cryptomount -u ~a~%"
;; cryptomount only accepts UUID without the hypen.
#$(string-delete #\- (uuid->string dev)))
;; Other type of devices aren't implemented.
#~()))
(let ((devices (map crypto-device->cryptomount store-crypto-devices))
(modules #~(format port "insmod luks~%insmod luks2~%")))
(if (null? devices)
devices
(cons modules devices))))
(define (sugar)
(let* ((entry (first all-entries))
(device (menu-entry-device entry))
@@ -485,7 +474,6 @@ keymap ~a~%" #$keymap))))
"# This file was generated from your Guix configuration. Any changes
# will be lost upon reconfiguration.
")
#$@(crypto-devices)
#$(sugar)
#$locale-config
#$keyboard-layout-config
@@ -538,13 +526,9 @@ fi~%"))))
(invoke/quiet grub "--no-floppy" "--target=i386-pc"
"--boot-directory" install-dir
device))
;; When creating a disk-image, only install a font and GRUB modules.
(let* ((fonts (string-append install-dir "/grub/fonts")))
(mkdir-p fonts)
(copy-file (string-append bootloader "/share/grub/unicode.pf2")
(string-append fonts "/unicode.pf2"))
(copy-recursively (string-append bootloader "/lib/")
install-dir))))))
;; When creating a disk-image, only install GRUB modules.
(copy-recursively (string-append bootloader "/lib/")
install-dir)))))
(define install-grub-disk-image
#~(lambda (bootloader root-index image)
@@ -589,24 +573,21 @@ fi~%"))))
(define install-grub-efi
#~(lambda (bootloader efi-dir mount-point)
;; There is nothing useful to do when called in the context of a disk
;; image generation.
(when efi-dir
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
;; system whose root is mounted at MOUNT-POINT.
(let ((grub-install (string-append bootloader "/sbin/grub-install"))
(install-dir (string-append mount-point "/boot"))
;; When installing Guix, it's common to mount EFI-DIR below
;; MOUNT-POINT rather than /boot/efi on the live image.
(target-esp (if (file-exists? (string-append mount-point efi-dir))
(string-append mount-point efi-dir)
efi-dir)))
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
;; root partition.
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
(invoke/quiet grub-install "--boot-directory" install-dir
"--bootloader-id=Guix"
"--efi-directory" target-esp)))))
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
;; system whose root is mounted at MOUNT-POINT.
(let ((grub-install (string-append bootloader "/sbin/grub-install"))
(install-dir (string-append mount-point "/boot"))
;; When installing Guix, it's common to mount EFI-DIR below
;; MOUNT-POINT rather than /boot/efi on the live image.
(target-esp (if (file-exists? (string-append mount-point efi-dir))
(string-append mount-point efi-dir)
efi-dir)))
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
;; root partition.
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
(invoke/quiet grub-install "--boot-directory" install-dir
"--bootloader-id=Guix"
"--efi-directory" target-esp))))
(define (install-grub-efi-netboot subdir)
"Define a grub-efi-netboot bootloader installer for installation in SUBDIR,
@@ -648,12 +629,11 @@ below the directory TARGET for the system whose root is mounted at MOUNT-POINT.
MOUNT-POINT is the last argument in 'guix system init /etc/config.scm mnt/point'
or '/' for other 'guix system' commands.
Where TARGET comes from the targets argument given to the
bootloader-configuration in:
TARGET is the target argument given to the bootloader-configuration in
(operating-system
(bootloader (bootloader-configuration
(targets '(\"/boot\"))
(target \"/boot\")
))
)
@@ -668,7 +648,7 @@ relatively form MOUNT-POINT/TARGET/SUBDIR/grub.cfg to
MOUNT-POINT/boot/grub/grub.cfg, and the second symlink points relatively from
MOUNT-POINT/TARGET/%store-prefix to MOUNT-POINT/%store-prefix.
It is important to note that these symlinks need to be relative, as the absolute
It is important to note that these symlinks need to be relativ, as the absolute
paths on the TFTP server side are unknown.
It is also important to note that both symlinks will point outside the TFTP root
+3 -3
View File
@@ -73,8 +73,8 @@
(define install-allwinner64-u-boot
#~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/u-boot-sunxi-with-spl.bin"))
(u-boot (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
(let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device spl (stat:size (stat spl))
image (* 8 1024))
(write-file-on-device u-boot (stat:size (stat u-boot))
@@ -91,7 +91,7 @@
(define install-puma-rk3399-u-boot
#~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/idbloader.img"))
(let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device spl (stat:size (stat spl))
image (* 64 512))
+2 -6
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -490,11 +490,7 @@ new UIDs."
(uid id)
(directory directory)
(gid (if (number? group) group (group-id group)))
;; Users might change their name to something
;; other than what the sysadmin chose, with
;; 'chfn'. Thus consider it "stateful".
(real-name (if (and previous (not system?))
(real-name (if previous
(password-entry-real-name previous)
real-name))
+19 -89
View File
@@ -1,13 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org>
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -26,7 +19,6 @@
(define-module (gnu build activation)
#:use-module (gnu system accounts)
#:use-module (gnu system setuid)
#:use-module (gnu build accounts)
#:use-module (gnu build linux-boot)
#:use-module (guix build utils)
@@ -45,8 +37,7 @@
activate-modprobe
activate-firmware
activate-ptrace-attach
activate-current-system
mkdir-p/perms))
activate-current-system))
;;; Commentary:
;;;
@@ -64,54 +55,12 @@
(define (dot-or-dot-dot? file)
(member file '("." "..")))
;; Based upon mkdir-p from (guix build utils)
(define (verify-not-symbolic dir)
"Verify DIR or its ancestors aren't symbolic links."
(define absolute?
(string-prefix? "/" dir))
(define not-slash
(char-set-complement (char-set #\/)))
(define (verify-component file)
(unless (eq? 'directory (stat:type (lstat file)))
(error "file name component is not a directory" dir)))
(let loop ((components (string-tokenize dir not-slash))
(root (if absolute?
""
".")))
(match components
((head tail ...)
(let ((file (string-append root "/" head)))
(catch 'system-error
(lambda ()
(verify-component file)
(loop tail file))
(lambda args
(if (= ENOENT (system-error-errno args))
#t
(apply throw args))))))
(() #t))))
;; TODO: the TOCTTOU race can be addressed once guile has bindings
;; for fstatat, openat and friends.
(define (mkdir-p/perms directory owner bits)
"Create the directory DIRECTORY and all its ancestors.
Verify no component of DIRECTORY is a symbolic link.
Warning: this is currently suspect to a TOCTTOU race!"
(verify-not-symbolic directory)
(mkdir-p directory)
(chown directory (passwd:uid owner) (passwd:gid owner))
(chmod directory bits))
(define* (copy-account-skeletons home
#:key
(directory %skeleton-directory)
uid gid)
"Copy the account skeletons from DIRECTORY to HOME. When UID is an integer,
make it the owner of all the files created except the home directory; likewise
for GID."
make it the owner of all the files created; likewise for GID."
(define (set-owner file)
(when (or uid gid)
(chown file (or uid -1) (or gid -1))))
@@ -119,6 +68,7 @@ for GID."
(let ((files (scandir directory (negate dot-or-dot-dot?)
string<?)))
(mkdir-p home)
(set-owner home)
(for-each (lambda (file)
(let ((target (string-append home "/" file)))
(copy-recursively (string-append directory "/" file)
@@ -218,15 +168,10 @@ they already exist."
(uid (passwd:uid pw))
(gid (passwd:gid pw)))
(mkdir-p home)
(chown home uid gid)
(chmod home #o700)
(copy-account-skeletons home
#:uid uid #:gid gid)
;; It is important 'chown' be called after
;; 'copy-account-skeletons'. Otherwise, a malicious user with
;; good timing could create a symlink in HOME that would be
;; dereferenced by 'copy-account-skeletons'.
(chown home uid gid))))))
#:uid uid #:gid gid))))))
(for-each ensure-user-home users))
@@ -282,17 +227,14 @@ they already exist."
"/run/setuid-programs")
(define (activate-setuid-programs programs)
"Turn PROGRAMS, a list of file setuid-programs record, into setuid programs
stored under %SETUID-DIRECTORY."
(define (make-setuid-program program setuid? setgid? uid gid)
"Turn PROGRAMS, a list of file names, into setuid programs stored under
%SETUID-DIRECTORY."
(define (make-setuid-program prog)
(let ((target (string-append %setuid-directory
"/" (basename program)))
(mode (+ #o0555 ; base permissions
(if setuid? #o4000 0) ; setuid bit
(if setgid? #o2000 0)))) ; setgid bit
(copy-file program target)
(chown target uid gid)
(chmod target mode)))
"/" (basename prog))))
(copy-file prog target)
(chown target 0 0)
(chmod target #o6555)))
(format #t "setting up setuid programs in '~a'...~%"
%setuid-directory)
@@ -308,27 +250,15 @@ stored under %SETUID-DIRECTORY."
(for-each (lambda (program)
(catch 'system-error
(lambda ()
(let* ((program-name (setuid-program-program program))
(setuid? (setuid-program-setuid? program))
(setgid? (setuid-program-setgid? program))
(user (setuid-program-user program))
(group (setuid-program-group program))
(uid (match user
((? string?) (passwd:uid (getpwnam user)))
((? integer?) user)))
(gid (match group
((? string?) (group:gid (getgrnam group)))
((? integer?) group))))
(make-setuid-program program-name setuid? setgid? uid gid)))
(make-setuid-program program))
(lambda args
;; If we fail to create a setuid program, better keep going
;; so that we don't leave %SETUID-DIRECTORY empty or
;; half-populated. This can happen if PROGRAMS contains
;; incorrect file names: <https://bugs.gnu.org/38800>.
(format (current-error-port)
"warning: failed to make ~s setuid/setgid: ~a~%"
(setuid-program-program program)
(strerror (system-error-errno args))))))
"warning: failed to make '~a' setuid-root: ~a~%"
program (strerror (system-error-errno args))))))
programs))
(define (activate-special-files special-files)
@@ -389,8 +319,8 @@ improvement."
"/run/current-system")
(define (boot-time-system)
"Return the 'gnu.system' argument passed on the kernel command line."
(find-long-option "gnu.system" (if (string-contains %host-type "linux-gnu")
"Return the '--system' argument passed on the kernel command line."
(find-long-option "--system" (if (string-contains %host-type "linux-gnu")
(linux-command-line)
(command-line))))
-1
View File
@@ -94,7 +94,6 @@ load the Grub bootloader located in the 'Guix_image' root partition."
;; (not eliminate it).
(format port
"insmod part_msdos~@
insmod part_gpt~@
search --set=root --label Guix_image~@
configfile /boot/grub/grub.cfg~%")))
(install-efi grub-efi grub-config esp)
-165
View File
@@ -1,165 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Marius Bakke <marius@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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu build chromium-extension)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (gnu packages chromium)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages tls)
#:use-module (gnu packages xorg)
#:use-module (guix build-system trivial)
#:export (make-chromium-extension))
;;; Commentary:
;;;
;;; Tools to deal with Chromium extensions.
;;;
;;; Code:
(define (make-signing-key seed)
"Return a derivation for a deterministic PKCS #8 private key using SEED."
(computed-file
(string-append seed "-signing-key.pem")
(with-extensions (list guile-gcrypt)
#~(begin
(use-modules (gcrypt base16) (gcrypt hash) (ice-9 iconv))
(let* ((sha256sum (bytevector->base16-string
(sha256 (string->bytevector #$seed "UTF-8"))))
;; certtool.c wants a 56 byte seed for a 2048 bit key.
(key-size 2048)
(normalized-seed (string-take sha256sum 56)))
(system* #$(file-append gnutls "/bin/certtool")
"--generate-privkey"
"--key-type=rsa"
"--pkcs8"
;; Use the provable FIPS-PUB186-4 algorithm for
;; deterministic results.
"--provable"
"--password="
"--no-text"
(string-append "--bits=" (number->string key-size))
(string-append "--seed=" normalized-seed)
"--outfile" #$output))))
#:local-build? #t))
(define* (make-crx signing-key package #:optional (package-output "out"))
"Create a signed \".crx\" file from the unpacked Chromium extension residing
in PACKAGE-OUTPUT of PACKAGE. The extension will be signed with SIGNING-KEY."
(define name (package-name package))
(define version (package-version package))
(computed-file
(string-append name "-" version ".crx")
(with-imported-modules '((guix build utils))
#~(begin
;; This is not great. We pull Xorg and Chromium just to Zip and
;; sign an extension. This should be implemented with something
;; lighter. (TODO: where is the CRXv3 documentation..?)
(use-modules (guix build utils))
(let ((chromium #$(file-append ungoogled-chromium "/bin/chromium"))
(xvfb #$(file-append xorg-server "/bin/Xvfb"))
(packdir (string-append (getcwd) "/extension")))
(mkdir packdir)
(copy-recursively (ungexp package package-output) packdir
;; Ensure consistent file modification times.
#:keep-mtime? #t)
(system (string-append xvfb " :1 &"))
(setenv "DISPLAY" ":1")
(sleep 2) ;give Xorg some time to initialize...
(invoke chromium
"--user-data-dir=chromium-profile"
(string-append "--pack-extension=" packdir)
(string-append "--pack-extension-key=" #$signing-key))
(copy-file (string-append packdir ".crx") #$output))))
#:local-build? #t))
(define (crx->chromium-json crx version)
"Return a derivation that creates a Chromium JSON settings file for the
extension given as CRX. VERSION is used to signify the CRX version, and
must match the version listed in the extension manifest.json."
;; See chrome/browser/extensions/external_provider_impl.cc and
;; extensions/common/extension.h for documentation on the JSON format.
(computed-file "extension.json"
#~(call-with-output-file #$output
(lambda (port)
(format port "{
\"external_crx\": \"~a\",
\"external_version\": \"~a\"
}
"
#$crx #$version)))
#:local-build? #t))
(define (signing-key->public-der key)
"Return a derivation for a file containing the public key of KEY in DER
format."
(computed-file "der"
#~(system* #$(file-append gnutls "/bin/certtool")
"--load-privkey" #$key
"--pubkey-info"
"--outfile" #$output
"--outder")
#:local-build? #t))
(define (file-sha256sum file)
(with-extensions (list guile-gcrypt)
#~(begin
(use-modules (gcrypt base16) (gcrypt hash))
(bytevector->base16-string (file-sha256 #$file)))))
(define* (make-chromium-extension pkg #:optional (pkg-output "out"))
"Create a Chromium extension from package PKG and return a package that,
when installed, will make the extension contained in PKG available as a
Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use."
(let* ((name (package-name pkg))
(version (package-version pkg))
(private-key (make-signing-key name))
(public-key (signing-key->public-der private-key))
(checksum (file-sha256sum public-key))
(crx (make-crx private-key pkg pkg-output))
(json (crx->chromium-json crx version)))
(package
(inherit pkg)
(name (string-append name "-chromium"))
(source #f)
(native-inputs '())
(inputs '())
(propagated-inputs '())
(outputs '("out"))
(build-system trivial-build-system)
(arguments
(list #:modules '((guix build utils))
#:builder
#~(begin
(use-modules (guix build utils))
(define (base16-char->chromium-base16 char)
;; Translate CHAR, a hexadecimal character, to a Chromium-style
;; representation using the letters a-p (where a=0, p=15).
(string-ref "abcdefghijklmnop"
(string-index "0123456789abcdef" char)))
(let ((file-name (string-map base16-char->chromium-base16
(string-take #$checksum 32)))
(extension-directory
(string-append #$output
"/share/chromium/extensions")))
(mkdir-p extension-directory)
(symlink #$json (string-append extension-directory "/"
file-name ".json")))))))))
+103 -363
View File
@@ -1,9 +1,9 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 20192021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 David C. Trudgian <dave@trudgian.net>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
@@ -29,8 +29,6 @@
#:use-module (guix build bournish)
#:use-module ((guix build syscalls)
#:hide (file-system-type))
#:use-module (guix diagnostics)
#:use-module (guix i18n)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors)
#:use-module (ice-9 match)
@@ -56,9 +54,7 @@
mount-flags->bit-mask
check-file-system
mount-file-system
swap-space->flags-bit-mask))
mount-file-system))
;;; Commentary:
;;;
@@ -170,23 +166,14 @@ if DEVICE does not contain an ext2 file system."
(sub-bytevector sblock 104 16))
(define (ext2-superblock-volume-name sblock)
"Return the volume name of ext2 superblock SBLOCK as a string of at most 16
characters, or #f if SBLOCK has no volume name."
"Return the volume name of SBLOCK as a string of at most 16 characters, or
#f if SBLOCK has no volume name."
(null-terminated-latin1->string (sub-bytevector sblock 120 16)))
(define (check-ext2-file-system device force? repair)
"Return the health of an unmounted ext2 file system on DEVICE. If FORCE? is
true, check the file system even if it's marked as clean. If REPAIR is false,
do not write to the file system to fix errors. If it's #t, fix all
errors. Otherwise, fix only those considered safe to repair automatically."
(define (check-ext2-file-system device)
"Return the health of an ext2 file system on DEVICE."
(match (status:exit-val
(apply system* `("e2fsck" "-v" "-C" "0"
,@(if force? '("-f") '())
,@(match repair
(#f '("-n"))
(#t '("-y"))
(_ '("-p")))
,device)))
(system* "e2fsck" "-v" "-p" "-C" "0" device))
(0 'pass)
(1 'errors-corrected)
(2 'reboot-required)
@@ -232,99 +219,6 @@ if DEVICE does not contain an linux-swap file system."
(null-terminated-latin1->string
(sub-bytevector sblock (+ 1024 4 4 4 16) 16)))
(define (swap-space->flags-bit-mask swap)
"Return the number suitable for the 'flags' argument of 'mount'
that corresponds to the swap-space SWAP."
(define prio-flag
(let ((p (swap-space-priority swap))
(max (ash SWAP_FLAG_PRIO_MASK (- SWAP_FLAG_PRIO_SHIFT))))
(if p
(logior SWAP_FLAG_PREFER
(ash (cond
((< p 0)
(begin (warning
(G_ "Given swap priority ~a is
negative, defaulting to 0.~%") p)
0))
((> p max)
(begin (warning
(G_ "Limiting swap priority ~a to
~a.~%")
p max)
max))
(else p))
SWAP_FLAG_PRIO_SHIFT))
0)))
(define delayed-flag
(if (swap-space-discard? swap)
SWAP_FLAG_DISCARD
0))
(logior prio-flag delayed-flag))
;;;
;;; Bcachefs file systems.
;;;
;; <https://evilpiepirate.org/git/bcachefs-tools.git/tree/libbcachefs/bcachefs_format.h>
(define-syntax %bcachefs-endianness
;; Endianness of bcachefs file systems.
(identifier-syntax (endianness little)))
(define (bcachefs-superblock? sblock)
"Return #t when SBLOCK is an bcachefs superblock."
(bytevector=? (sub-bytevector sblock 24 16)
#vu8(#xc6 #x85 #x73 #xf6 #x4e #x1a #x45 #xca
#x82 #x65 #xf5 #x7f #x48 #xba #x6d #x81)))
(define (read-bcachefs-superblock device)
"Return the raw contents of DEVICE's bcachefs superblock as a bytevector, or #f
if DEVICE does not contain a bcachefs file system."
;; Field offsets & lengths, in bytes. There are more (and the superblock is
;; extensible) but we need only some basic information here:
;; 0 16 bch_csum
;; 16 8 version
;; 24 16 magic
;; 40 16 uuid ← internal: you probably don't want this one
;; 56 16 user_uuid ← external: user-visible one by which to mount
;; 72 32 label
;; Assume a sane file system: ignore the back-up superblock & checksums.
(read-superblock device 4096 104 bcachefs-superblock?))
(define (bcachefs-superblock-external-uuid sblock)
"Return the external UUID of bcachefs superblock SBLOCK as a 16-byte
bytevector."
(sub-bytevector sblock 56 16))
(define (bcachefs-superblock-volume-name sblock)
"Return the volume name of bcachefs superblock SBLOCK as a string of at most
32 characters, or #f if SBLOCK has no volume name."
(null-terminated-latin1->string (sub-bytevector sblock 72 32)))
(define (check-bcachefs-file-system device force? repair)
"Return the health of an unmounted bcachefs file system on DEVICE. If FORCE?
is true, check the file system even if it's marked as clean. If REPAIR is
false, do not write to the file system to fix errors. If it's #t, fix all
errors. Otherwise, fix only those considered safe to repair automatically."
(let ((ignored-bits (logior 2)) ; DEVICE was mounted read-only
(status
;; A number, or #f on abnormal termination (e.g., assertion failure).
(status:exit-val
(apply system* `("bcachefs" "fsck" "-v"
,@(if force? '("-f") '())
,@(match repair
(#f '("-n"))
(#t '("-y"))
(_ '("-p")))
;; Make each multi-device member a separate argument.
,@(string-split device #\:))))))
(match (and=> status (cut logand <> (lognot ignored-bits)))
(0 'pass)
(1 'errors-corrected)
(_ 'fatal-error))))
;;;
;;; Btrfs file systems.
@@ -351,33 +245,16 @@ if DEVICE does not contain a btrfs file system."
(sub-bytevector sblock 32 16))
(define (btrfs-superblock-volume-name sblock)
"Return the volume name of btrfs superblock SBLOCK as a string of at most 256
characters, or #f if SBLOCK has no volume name."
"Return the volume name of SBLOCK as a string of at most 256 characters, or
#f if SBLOCK has no volume name."
(null-terminated-latin1->string (sub-bytevector sblock 299 256)))
(define (check-btrfs-file-system device force? repair)
"Return the health of an unmounted btrfs file system on DEVICE. If FORCE? is
false, return 'PASS unconditionally as btrfs claims no need for off-line checks.
When FORCE? is true, do perform a real check. This is not recommended! See
@uref{https://bugzilla.redhat.com/show_bug.cgi?id=625967#c8}. If REPAIR is
false, do not write to DEVICE. If it's #t, fix any errors found. Otherwise,
fix only those considered safe to repair automatically."
(if force?
(match (status:exit-val
(apply system* `("btrfs" "check" "--progress"
;; Btrfs's --force is not relevant to us here.
,@(match repair
;; Upstream considers ALL repairs dangerous
;; and will warn the user at run time.
(#t '("--repair"))
(_ '("--readonly" ; a no-op for clarity
;; A 466G file system with 180G used is
;; enough to kill btrfs with 6G of RAM.
"--mode" "lowmem")))
,device)))
(0 'pass)
(_ 'fatal-error))
'pass))
(define (check-btrfs-file-system device)
"Return the health of a btrfs file system on DEVICE."
(match (status:exit-val
(system* "btrfs" "device" "scan"))
(0 'pass)
(_ 'fatal-error)))
;;;
@@ -401,22 +278,15 @@ fix only those considered safe to repair automatically."
(sub-bytevector sblock 67 4))
(define (fat32-superblock-volume-name sblock)
"Return the volume name of fat superblock SBLOCK as a string of at most 11
characters, or #f if SBLOCK has no volume name. The volume name is a latin1
string. Trailing spaces are trimmed."
"Return the volume name of SBLOCK as a string of at most 11 characters, or
#f if SBLOCK has no volume name. The volume name is a latin1 string.
Trailing spaces are trimmed."
(string-trim-right (latin1->string (sub-bytevector sblock 71 11) (lambda (c) #f)) #\space))
(define (check-fat-file-system device force? repair)
"Return the health of an unmounted FAT file system on DEVICE. FORCE? is
ignored: a full file system scan is always performed. If REPAIR is false, do
not write to the file system to fix errors. Otherwise, automatically fix them
using the least destructive approach."
(define (check-fat-file-system device)
"Return the health of a fat file system on DEVICE."
(match (status:exit-val
(apply system* `("fsck.vfat" "-v"
,@(match repair
(#f '("-n"))
(_ '("-a"))) ; no 'safe/#t distinction
,device)))
(system* "fsck.vfat" "-v" "-a" device))
(0 'pass)
(1 'errors-corrected)
(_ 'fatal-error)))
@@ -441,9 +311,9 @@ using the least destructive approach."
(sub-bytevector sblock 39 4))
(define (fat16-superblock-volume-name sblock)
"Return the volume name of fat superblock SBLOCK as a string of at most 11
characters, or #f if SBLOCK has no volume name. The volume name is a latin1
string. Trailing spaces are trimmed."
"Return the volume name of SBLOCK as a string of at most 11 characters, or
#f if SBLOCK has no volume name. The volume name is a latin1 string.
Trailing spaces are trimmed."
(string-trim-right (latin1->string (sub-bytevector sblock 43 11)
(lambda (c) #f))
#\space))
@@ -502,8 +372,8 @@ SBLOCK as a bytevector. If that's not set, returns the creation time."
(sub-bytevector time 0 16))) ; strips GMT offset.
(define (iso9660-superblock-volume-name sblock)
"Return the volume name of iso9660 superblock SBLOCK as a string. The volume
name is an ASCII string. Trailing spaces are trimmed."
"Return the volume name of SBLOCK as a string. The volume name is an ASCII
string. Trailing spaces are trimmed."
;; Note: Valid characters are of the set "[0-9][A-Z]_" (ECMA-119 Appendix A)
(string-trim-right (latin1->string (sub-bytevector sblock 40 32)
(lambda (c) #f)) #\space))
@@ -534,32 +404,14 @@ if DEVICE does not contain a JFS file system."
(sub-bytevector sblock 136 16))
(define (jfs-superblock-volume-name sblock)
"Return the volume name of JFS superblock SBLOCK as a string of at most 16
characters, or #f if SBLOCK has no volume name."
"Return the volume name of SBLOCK as a string of at most 16 characters, or
#f if SBLOCK has no volume name."
(null-terminated-latin1->string (sub-bytevector sblock 152 16)))
(define (check-jfs-file-system device force? repair)
"Return the health of an unmounted JFS file system on DEVICE. If FORCE? is
true, check the file system even if it's marked as clean. If REPAIR is false,
do not write to the file system to fix errors, and replay the transaction log
only if FORCE? is true. Otherwise, replay the transaction log before checking
and automatically fix found errors."
(define (check-jfs-file-system device)
"Return the health of a JFS file system on DEVICE."
(match (status:exit-val
(apply system*
`("jfs_fsck" "-v"
;; The LEVEL logic is convoluted. To quote fsck/xchkdsk.c
;; (-p, -a, and -r are aliases in every way):
;; “If -f was chosen, have it override [-p] by [forcing] a
;; check regardless of the outcome after the log is
;; replayed”.
;; “If -n is specified by itself, don't replay the journal.
;; If -n is specified with [-p], replay the journal but
;; don't make any other changes”.
,@(if force? '("-f") '())
,@(match repair
(#f '("-n"))
(_ '("-p"))) ; no 'safe/#t distinction
,device)))
(system* "jfs_fsck" "-p" "-v" device))
(0 'pass)
(1 'errors-corrected)
(2 'reboot-required)
@@ -604,28 +456,18 @@ if DEVICE does not contain an F2FS file system."
16))
(define (f2fs-superblock-volume-name sblock)
"Return the volume name of F2FS superblock SBLOCK as a string of at most 512
characters, or #f if SBLOCK has no volume name."
"Return the volume name of SBLOCK as a string of at most 512 characters, or
#f if SBLOCK has no volume name."
(null-terminated-utf16->string
(sub-bytevector sblock (- (+ #x470 12) #x400) 512)
%f2fs-endianness))
(define (check-f2fs-file-system device force? repair)
"Return the health of an unmuounted F2FS file system on DEVICE. If FORCE? is
true, check the file system even if it's marked as clean. If either FORCE? or
REPAIR are true, automatically fix found errors."
;; There's no -n equivalent (--dry-run does not disable writes).
;; -y is an alias of -f. The man page is bad: read main.c.
(when (and force? (not repair))
(format (current-error-port)
"warning: forced check of F2FS ~a implies repairing any errors~%"
device))
(define (check-f2fs-file-system device)
"Return the health of a F2FS file system on DEVICE."
(match (status:exit-val
(apply system* `("fsck.f2fs"
,@(if force? '("-f") '())
,@(if repair '("-p") '("--dry-run"))
,device)))
;; 0 and -1 are the only two possibilities according to the man page.
(system* "fsck.f2fs" "-p" device))
;; 0 and -1 are the only two possibilities
;; (according to the manpage)
(0 'pass)
(_ 'fatal-error)))
@@ -703,81 +545,13 @@ if DEVICE does not contain a NTFS file system."
;; in the BOOT SECTOR like the UUID, but in the MASTER FILE TABLE, which seems
;; way harder to access.
(define (check-ntfs-file-system device force? repair)
"Return the health of an unmounted NTFS file system on DEVICE. FORCE? is
ignored: a full check is always performed. Repair is not possible: if REPAIR is
true and the volume has been repaired by an external tool, clear the volume
dirty flag to indicate that it's now safe to mount."
(define (check-ntfs-file-system device)
"Return the health of a NTFS file system on DEVICE."
(match (status:exit-val
(apply system* `("ntfsfix"
,@(if repair '("--clear-dirty") '("--no-action"))
,device)))
(system* "ntfsfix" device))
(0 'pass)
(_ 'fatal-error)))
;;;
;;; XFS file systems.
;;;
;; <https://git.kernel.org/pub/scm/fs/xfs/xfs-documentation.git/tree/design/XFS_Filesystem_Structure/allocation_groups.asciidoc>
(define-syntax %xfs-endianness
;; Endianness of XFS file systems.
(identifier-syntax (endianness big)))
(define (xfs-superblock? sblock)
"Return #t when SBLOCK is an XFS superblock."
(bytevector=? (sub-bytevector sblock 0 4)
(string->utf8 "XFSB")))
(define (read-xfs-superblock device)
"Return the raw contents of DEVICE's XFS superblock as a bytevector, or #f
if DEVICE does not contain an XFS file system."
(read-superblock device 0 120 xfs-superblock?))
(define (xfs-superblock-uuid sblock)
"Return the UUID of XFS superblock SBLOCK as a 16-byte bytevector."
(sub-bytevector sblock 32 16))
(define (xfs-superblock-volume-name sblock)
"Return the volume name of XFS superblock SBLOCK as a string of at most 12
characters, or #f if SBLOCK has no volume name."
(null-terminated-latin1->string (sub-bytevector sblock 108 12)))
(define (check-xfs-file-system device force? repair)
"Return the health of an unmounted XFS file system on DEVICE. If FORCE? is
false, return 'PASS unconditionally as XFS claims no need for off-line checks.
When FORCE? is true, do perform a thorough check. If REPAIR is false, do not
write to DEVICE. If it's #t, replay the log, check, and fix any errors found.
Otherwise, only replay the log, and check without attempting further repairs."
(define (xfs_repair)
(status:exit-val
(apply system* `("xfs_repair" "-Pv"
,@(match repair
(#t '("-e"))
(_ '("-n"))) ; will miss some errors
,device))))
(if force?
;; xfs_repair fails with exit status 2 if the log is dirty, which is
;; likely in situations where you're running xfs_repair. Only the kernel
;; can replay the log by {,un}mounting it cleanly.
(match (let ((status (xfs_repair)))
(if (and repair (eq? 2 status))
(let ((target "/replay-XFS-log"))
;; The kernel helpfully prints a Mounting…’ notice for us.
(mkdir target)
(mount device target "xfs")
(umount target)
(rmdir target)
(xfs_repair))
status))
(0 'pass)
(4 'errors-corrected)
(_ 'fatal-error))
'pass))
;;;
;;; Partition lookup.
@@ -816,13 +590,16 @@ Otherwise, only replay the log, and check without attempting further repairs."
(loop parts))))))))))
(define (ENOENT-safe proc)
"Wrap the one-argument PROC such that ENOENT, EIO, and ENOMEDIUM errors are
caught and lead to a warning and #f as the result."
"Wrap the one-argument PROC such that ENOENT errors are caught and lead to a
warning and #f as the result."
(lambda (device)
(catch 'system-error
(lambda ()
(proc device))
(lambda args
;; When running on the hand-made /dev,
;; 'disk-partitions' could return partitions for which
;; we have no /dev node. Handle that gracefully.
(let ((errno (system-error-errno args)))
(cond ((= ENOENT errno)
(format (current-error-port)
@@ -840,10 +617,11 @@ caught and lead to a warning and #f as the result."
(define (partition-field-reader read field)
"Return a procedure that takes a device and returns the value of a FIELD in
the partition superblock or #f."
(lambda (device)
(let ((sblock (read device)))
(and sblock
(field sblock)))))
(let ((read (ENOENT-safe read)))
(lambda (device)
(let ((sblock (read device)))
(and sblock
(field sblock))))))
(define (read-partition-field device partition-field-readers)
"Returns the value of a FIELD in the partition superblock of DEVICE or #f. It
@@ -860,8 +638,6 @@ partition field reader that returned a value."
ext2-superblock-volume-name)
(partition-field-reader read-linux-swap-superblock
linux-swap-superblock-volume-name)
(partition-field-reader read-bcachefs-superblock
bcachefs-superblock-volume-name)
(partition-field-reader read-btrfs-superblock
btrfs-superblock-volume-name)
(partition-field-reader read-fat32-superblock
@@ -871,9 +647,7 @@ partition field reader that returned a value."
(partition-field-reader read-jfs-superblock
jfs-superblock-volume-name)
(partition-field-reader read-f2fs-superblock
f2fs-superblock-volume-name)
(partition-field-reader read-xfs-superblock
xfs-superblock-volume-name)))
f2fs-superblock-volume-name)))
(define %partition-uuid-readers
(list (partition-field-reader read-iso9660-superblock
@@ -882,8 +656,6 @@ partition field reader that returned a value."
ext2-superblock-uuid)
(partition-field-reader read-linux-swap-superblock
linux-swap-superblock-uuid)
(partition-field-reader read-bcachefs-superblock
bcachefs-superblock-external-uuid)
(partition-field-reader read-btrfs-superblock
btrfs-superblock-uuid)
(partition-field-reader read-fat32-superblock
@@ -895,9 +667,7 @@ partition field reader that returned a value."
(partition-field-reader read-f2fs-superblock
f2fs-superblock-uuid)
(partition-field-reader read-ntfs-superblock
ntfs-superblock-uuid)
(partition-field-reader read-xfs-superblock
xfs-superblock-uuid)))
ntfs-superblock-uuid)))
(define read-partition-label
(cut read-partition-field <> %partition-label-readers))
@@ -914,14 +684,11 @@ partition field reader that returned a value."
(define (partition-predicate reader =)
"Return a predicate that returns true if the FIELD of partition header that
was READ is = to the given value."
;; When running on the hand-made /dev, 'disk-partitions' could return
;; partitions for which we have no /dev node. Handle that gracefully.
(let ((reader (ENOENT-safe reader)))
(lambda (expected)
(lambda (device)
(let ((actual (reader device)))
(and actual
(= actual expected)))))))
(lambda (expected)
(lambda (device)
(let ((actual (reader device)))
(and actual
(= actual expected))))))
(define partition-label-predicate
(partition-predicate read-partition-label string=?))
@@ -991,61 +758,47 @@ containing ':/')."
(uuid-bytevector spec)
uuid->string))))
(define (check-file-system device type force? repair)
"Check an unmounted TYPE file system on DEVICE. Do nothing but warn if it is
mounted. If FORCE? is true, check even when considered unnecessary. If REPAIR
is false, try not to write to DEVICE at all. If it's #t, try to fix all errors
found. Otherwise, fix only those considered safe to repair automatically. Not
all TYPEs support all values or combinations of FORCE? and REPAIR. Don't throw
an exception in such cases but perform the nearest sane action."
(define (check-file-system device type)
"Run a file system check of TYPE on DEVICE."
(define check-procedure
(cond
((string-prefix? "ext" type) check-ext2-file-system)
((string-prefix? "bcachefs" type) check-bcachefs-file-system)
((string-prefix? "btrfs" type) check-btrfs-file-system)
((string-suffix? "fat" type) check-fat-file-system)
((string-prefix? "jfs" type) check-jfs-file-system)
((string-prefix? "f2fs" type) check-f2fs-file-system)
((string-prefix? "ntfs" type) check-ntfs-file-system)
((string-prefix? "nfs" type) (const 'pass))
((string-prefix? "xfs" type) check-xfs-file-system)
(else #f)))
(if check-procedure
(let ((mount (find (lambda (mount)
(string=? device (mount-source mount)))
(mounts))))
(if mount
(format (current-error-port)
"Refusing to check ~a file system already mounted at ~a~%"
device (mount-point mount))
(match (check-procedure device force? repair)
('pass
#t)
('errors-corrected
(format (current-error-port)
"File system check corrected errors on ~a; continuing~%"
device))
('reboot-required
(format (current-error-port)
"File system check corrected errors on ~a; rebooting~%"
device)
(sleep 3)
(reboot))
('fatal-error
(format (current-error-port) "File system check on ~a failed~%"
device)
(match (check-procedure device)
('pass
#t)
('errors-corrected
(format (current-error-port)
"File system check corrected errors on ~a; continuing~%"
device))
('reboot-required
(format (current-error-port)
"File system check corrected errors on ~a; rebooting~%"
device)
(sleep 3)
(reboot))
('fatal-error
(format (current-error-port) "File system check on ~a failed~%"
device)
;; Spawn a REPL only if someone might interact with it.
(when (isatty? (current-input-port))
(format (current-error-port) "Spawning Bourne-like REPL.~%")
;; Spawn a REPL only if someone would be able to interact with it.
(when (isatty? (current-input-port))
(format (current-error-port) "Spawning Bourne-like REPL.~%")
;; 'current-output-port' is typically connected to /dev/klog
;; (in PID 1), but here we want to make sure we talk directly
;; to the user.
(with-output-to-file "/dev/console"
(lambda ()
(start-repl %bournish-language))))))))
;; 'current-output-port' is typically connected to /dev/klog (in
;; PID 1), but here we want to make sure we talk directly to the
;; user.
(with-output-to-file "/dev/console"
(lambda ()
(start-repl %bournish-language))))))
(format (current-error-port)
"No file system check procedure for ~a; skipping~%"
device)))
@@ -1074,11 +827,7 @@ corresponds to the symbols listed in FLAGS."
(()
0))))
(define* (mount-file-system fs #:key (root "/root")
(check? (file-system-check? fs))
(skip-check-if-clean?
(file-system-skip-check-if-clean? fs))
(repair (file-system-repair fs)))
(define* (mount-file-system fs #:key (root "/root"))
"Mount the file system described by FS, a <file-system> object, under ROOT."
(define (mount-nfs source mount-point type flags options)
@@ -1101,23 +850,14 @@ corresponds to the symbols listed in FLAGS."
(if options
(string-append "," options)
"")))))
(let* ((type (file-system-type fs))
(source (canonicalize-device-spec (file-system-device fs)))
(target (string-append root "/"
(file-system-mount-point fs)))
(flags (logior (mount-flags->bit-mask (file-system-flags fs))
;; For bind mounts, preserve the original flags such
;; as MS_NOSUID, etc. Failing to do that, the
;; MS_REMOUNT call below fails with EPERM.
;; See <https://bugs.gnu.org/46292>
(if (memq 'bind-mount (file-system-flags fs))
(statfs-flags->mount-flags
(file-system-mount-flags (statfs source)))
0)))
(options (file-system-options fs)))
(when check?
(check-file-system source type (not skip-check-if-clean?) repair))
(let ((type (file-system-type fs))
(options (file-system-options fs))
(source (canonicalize-device-spec (file-system-device fs)))
(mount-point (string-append root "/"
(file-system-mount-point fs)))
(flags (mount-flags->bit-mask (file-system-flags fs))))
(when (file-system-check? fs)
(check-file-system source type))
(catch 'system-error
(lambda ()
@@ -1126,24 +866,24 @@ corresponds to the symbols listed in FLAGS."
;; needed.
(if (and (= MS_BIND (logand flags MS_BIND))
(not (file-is-directory? source)))
(unless (file-exists? target)
(mkdir-p (dirname target))
(call-with-output-file target (const #t)))
(mkdir-p target))
(unless (file-exists? mount-point)
(mkdir-p (dirname mount-point))
(call-with-output-file mount-point (const #t)))
(mkdir-p mount-point))
(cond
((string-prefix? "nfs" type)
(mount-nfs source target type flags options))
(mount-nfs source mount-point type flags options))
(else
(mount source target type flags options)))
(mount source mount-point type flags options)))
;; For read-only bind mounts, an extra remount is needed, as per
;; <http://lwn.net/Articles/281157/>, which still applies to Linux
;; 4.0.
(when (and (= MS_BIND (logand flags MS_BIND))
(= MS_RDONLY (logand flags MS_RDONLY)))
(let ((flags (logior MS_REMOUNT flags)))
(mount source target type flags options))))
(let ((flags (logior MS_BIND MS_REMOUNT MS_RDONLY)))
(mount source mount-point type flags #f))))
(lambda args
(or (file-system-mount-may-fail? fs)
(apply throw args))))))
+14 -10
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -185,9 +185,13 @@ set."
("servers/crash-suspend" ("/hurd/crash" "--suspend"))
("servers/password" ("/hurd/password"))
("servers/socket/1" ("/hurd/pflocal"))
;; /servers/socket/2 and /26 are created by 'static-networking-service'.
;; XXX: Spawn pfinet without arguments on these nodes so that a DHCP
;; client has someone to talk to?
("servers/socket/2" ("/hurd/pfinet"
"--interface" "eth0"
"--address"
"10.0.2.15" ;the default QEMU guest IP
"--netmask" "255.255.255.0"
"--gateway" "10.0.2.2"
"--ipv6" "/servers/socket/16"))
("proc" ("/hurd/procfs" "--stat-mode=444"))))
(define devices
@@ -254,7 +258,7 @@ set."
"This procedure is meant to be called from an early RC script.
Install the relevant passive translators on the first boot. Then, run system
activation by using the kernel command-line options 'gnu.system' and 'gnu.load';
activation by using the kernel command-line options '--system' and '--load';
starting the Shepherd.
XXX TODO: see linux-boot.scm:boot-system.
@@ -265,14 +269,14 @@ XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM
"
(display "Welcome, this is GNU's early boot Guile.\n")
(display "Use 'gnu.repl' for an initrd REPL.\n\n")
(display "Use '--repl' for an initrd REPL.\n\n")
(call-with-error-handling
(lambda ()
(let* ((args (command-line))
(system (find-long-option "gnu.system" args))
(to-load (find-long-option "gnu.load" args)))
(system (find-long-option "--system" args))
(to-load (find-long-option "--load" args)))
(format #t "Setting-up essential translators...\n")
(setenv "PATH" (string-append system "/profile/bin"))
@@ -286,7 +290,7 @@ XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM
(unless (zero? (system* "/hurd/mach-defpager"))
(format #t "FAILED...Good luck!\n"))
(cond ((member "gnu.repl" args)
(cond ((member "--repl" args)
(format #t "Starting repl...\n")
(start-repl))
(to-load
@@ -298,7 +302,7 @@ XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM
(sleep 2)
(reboot))
(else
(display "no boot file passed via 'gnu.load'\n")
(display "no boot file passed via '--load'\n")
(display "entering a warm and cozy REPL\n")
(start-repl)))))
#:on-error on-error))
+24 -39
View File
@@ -1,9 +1,9 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Christine Lemmer-Webber <cwebber@dustycloud.org>
;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -61,11 +61,9 @@
(inexact->exact (ceiling (/ size 1024)))))
(define (estimate-partition-size root)
"Given the ROOT directory, evaluate and return its size. As this doesn't
take the partition metadata size into account, take a 25% margin. As this in
turn doesn't take any constant overhead into account, force a 1-MiB minimum."
(max (ash 1 20)
(* 1.25 (file-size root))))
"Given the ROOT directory, evalute and return its size. As this doesn't
take the partition metadata size into account, take a 25% margin."
(* 1.25 (file-size root)))
(define* (make-ext-image partition target root
#:key
@@ -142,17 +140,23 @@ given CONFIG file."
(define* (register-closure prefix closure
#:key
(deduplicate? #t) (reset-timestamps? #t)
(schema (sql-schema))
(wal-mode? #t))
"Register CLOSURE in PREFIX, where PREFIX is the directory name of the
target store and CLOSURE is the name of a file containing a reference graph as
produced by #:references-graphs. Pass WAL-MODE? to call-with-database."
produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is
true, reset timestamps on store files and, if DEDUPLICATE? is true,
deduplicates files common to CLOSURE and the rest of PREFIX. Pass WAL-MODE?
to call-with-database."
(let ((items (call-with-input-file closure read-reference-graph)))
(parameterize ((sql-schema schema))
(with-database (store-database-file #:prefix prefix) db
#:wal-mode? wal-mode?
(register-items db items
#:prefix prefix
#:deduplicate? deduplicate?
#:reset-timestamps? reset-timestamps?
#:registration-time %epoch)))))
(define* (initialize-efi-partition root
@@ -168,7 +172,6 @@ produced by #:references-graphs. Pass WAL-MODE? to call-with-database."
bootcfg-location
bootloader-package
bootloader-installer
(copy-closures? #t)
(deduplicate? #t)
references-graphs
(register-closures? #t)
@@ -179,50 +182,32 @@ produced by #:references-graphs. Pass WAL-MODE? to call-with-database."
"Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION to
install the bootloader configuration.
If COPY-CLOSURES? is true, copy all of REFERENCES-GRAPHS to the partition. If
REGISTER-CLOSURES? is true, register REFERENCES-GRAPHS in the store. If
If REGISTER-CLOSURES? is true, register REFERENCES-GRAPHS in the store. If
DEDUPLICATE? is true, then also deduplicate files common to CLOSURES and the
rest of the store when registering the closures. SYSTEM-DIRECTORY is the name
of the directory of the 'system' derivation. Pass WAL-MODE? to
register-closure."
(define root-store
(string-append root (%store-directory)))
(define tmp-store ".tmp-store")
(populate-root-file-system system-directory root)
(when copy-closures?
(populate-store references-graphs root
#:deduplicate? deduplicate?))
(populate-store references-graphs root)
;; Populate /dev.
(when make-device-nodes
(make-device-nodes root))
(when register-closures?
(unless copy-closures?
;; XXX: 'register-closure' wants to palpate the things it registers, so
;; create a symlink to the store.
(rename-file root-store tmp-store)
(symlink (%store-directory) root-store))
(for-each (lambda (closure)
(register-closure root closure
(register-closure root
closure
#:reset-timestamps? #t
#:deduplicate? deduplicate?
#:wal-mode? wal-mode?))
references-graphs)
references-graphs))
(unless copy-closures?
(delete-file root-store)
(rename-file tmp-store root-store)))
;; There's no point installing a bootloader if we do not populate the store.
(when copy-closures?
(when bootloader-installer
(display "installing bootloader...\n")
(bootloader-installer bootloader-package #f root))
(when bootcfg
(install-boot-config bootcfg bootcfg-location root))))
(when bootloader-installer
(display "installing bootloader...\n")
(bootloader-installer bootloader-package #f root))
(when bootcfg
(install-boot-config bootcfg bootcfg-location root)))
(define* (make-iso9660-image xorriso grub-mkrescue-environment
grub bootcfg system-directory root target
+1 -2
View File
@@ -214,8 +214,7 @@ This is used to create the self-contained tarballs with 'guix pack'."
(symlink old (scope new)))
;; Populate the store.
(populate-store (list closure) directory
#:deduplicate? #f)
(populate-store (list closure) directory)
(when database
(install-database-and-gc-roots directory database profile
-587
View File
@@ -1,587 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@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 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;;
;;; This module contains helpers used as part of the jami-service-type
;;; definition.
;;;
;;; Code:
(define-module (gnu build jami-service)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (ice-9 peg)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 regex)
#:use-module (rnrs io ports)
#:autoload (shepherd service) (fork+exec-command)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (account-fingerprint?
account-details->recutil
get-accounts
get-usernames
set-account-details
add-account
account->username
username->account
username->contacts
enable-account
disable-account
add-contact
remove-contact
set-all-moderators
set-moderator
username->all-moderators?
username->moderators
dbus-available-services
dbus-service-available?
%send-dbus-binary
%send-dbus-bus
%send-dbus-user
%send-dbus-group
%send-dbus-debug
send-dbus
with-retries))
;;;
;;; Utilities.
;;;
(define-syntax-rule (with-retries n delay body ...)
"Retry the code in BODY up to N times until it doesn't raise an exception
nor return #f, else raise an error. A delay of DELAY seconds is inserted
before each retry."
(let loop ((attempts 0))
(catch #t
(lambda ()
(let ((result (begin body ...)))
(if (not result)
(error "failed attempt" attempts)
result)))
(lambda args
(if (< attempts n)
(begin
(sleep delay) ;else wait and retry
(loop (+ 1 attempts)))
(error "maximum number of retry attempts reached"
body ... args))))))
(define (alist->list alist)
"Flatten ALIST into a list."
(append-map (match-lambda
(() '())
((key . value)
(list key value)))
alist))
(define account-fingerprint-rx (make-regexp "[0-9A-Fa-f]{40}"))
(define (account-fingerprint? val)
"A Jami account fingerprint is 40 characters long and only contains
hexadecimal characters."
(and (string? val)
(regexp-exec account-fingerprint-rx val)))
;;;
;;; D-Bus reply parser.
;;;
(define (parse-dbus-reply reply)
"Return the parse tree of REPLY, a string returned by the 'dbus-send'
command."
;; Refer to 'man 1 dbus-send' for the grammar reference. Note that the
;; format of the replies doesn't match the format of the input, which is the
;; one documented, but it gives an idea. For an even better reference, see
;; the `print_iter' procedure of the 'dbus-print-message.c' file from the
;; 'dbus' package sources.
(define-peg-string-patterns
"contents <- header (item / container (item / container*)?)
item <-- WS type WS value NL
container <- array / dict / variant
array <-- array-start (item / container)* array-end
dict <-- array-start dict-entry* array-end
dict-entry <-- dict-entry-start item item dict-entry-end
variant <-- variant-start item
type <-- 'string' / 'int16' / 'uint16' / 'int32' / 'uint32' / 'int64' /
'uint64' / 'double' / 'byte' / 'boolean' / 'objpath'
value <-- (!NL .)* NL
header < (!NL .)* NL
variant-start < WS 'variant'
array-start < WS 'array [' NL
array-end < WS ']' NL
dict-entry-start < WS 'dict entry(' NL
dict-entry-end < WS ')' NL
DQ < '\"'
WS < ' '*
NL < '\n'*")
(peg:tree (match-pattern contents reply)))
(define (strip-quotes text)
"Strip the leading and trailing double quotes (\") characters from TEXT."
(let* ((text* (if (string-prefix? "\"" text)
(string-drop text 1)
text))
(text** (if (string-suffix? "\"" text*)
(string-drop-right text* 1)
text*)))
text**))
(define (deserialize-item item)
"Return the value described by the ITEM parse tree as a Guile object."
;; Strings are printed wrapped in double quotes (see the print_iter
;; procedure in dbus-print-message.c).
(match item
(('item ('type "string") ('value value))
(strip-quotes value))
(('item ('type "boolean") ('value value))
(if (string=? "true" value)
#t
#f))
(('item _ ('value value))
value)))
(define (serialize-boolean bool)
"Return the serialized format expected by dbus-send for BOOL."
(format #f "boolean:~:[false~;true~]" bool))
(define (dict->alist dict-parse-tree)
"Translate a dict parse tree to an alist."
(define (tuples->alist tuples)
(map (lambda (x) (apply cons x)) tuples))
(match dict-parse-tree
('dict
'())
(('dict ('dict-entry keys values) ...)
(let ((keys* (map deserialize-item keys))
(values* (map deserialize-item values)))
(tuples->alist (zip keys* values*))))))
(define (array->list array-parse-tree)
"Translate an array parse tree to a list."
(match array-parse-tree
('array
'())
(('array items ...)
(map deserialize-item items))))
;;;
;;; Low-level, D-Bus-related procedures.
;;;
;;; The following parameters are used in the jami-service-type service
;;; definition to conveniently customize the behavior of the send-dbus helper,
;;; even when called indirectly.
(define %send-dbus-binary (make-parameter "dbus-send"))
(define %send-dbus-bus (make-parameter #f))
(define %send-dbus-user (make-parameter #f))
(define %send-dbus-group (make-parameter #f))
(define %send-dbus-debug (make-parameter #f))
(define* (send-dbus #:key service path interface method
bus
dbus-send
user group
timeout
arguments)
"Return the response of DBUS-SEND, else raise an error. Unless explicitly
provided, DBUS-SEND takes the value of the %SEND-DBUS-BINARY parameter. BUS
can be used to specify the bus address, such as 'unix:path=/var/run/jami/bus'.
Alternatively, the %SEND-DBUS-BUS parameter can be used. ARGUMENTS can be
used to pass input values to a D-Bus method call. TIMEOUT is the amount of
time to wait for a reply in milliseconds before giving up with an error. USER
and GROUP allow choosing under which user/group the DBUS-SEND command is
executed. Alternatively, the %SEND-DBUS-USER and %SEND-DBUS-GROUP parameters
can be used instead."
(let* ((command `(,(if dbus-send
dbus-send
(%send-dbus-binary))
,@(if (or bus (%send-dbus-bus))
(list (string-append "--bus="
(or bus (%send-dbus-bus))))
'())
"--print-reply"
,@(if timeout
(list (format #f "--reply-timeout=~d" timeout))
'())
,(string-append "--dest=" service) ;e.g., cx.ring.Ring
,path ;e.g., /cx/ring/Ring/ConfigurationManager
,(string-append interface "." method)
,@(or arguments '())))
(temp-port (mkstemp! (string-copy "/tmp/dbus-send-output-XXXXXXX")))
(temp-file (port-filename temp-port)))
(dynamic-wind
(lambda ()
(let* ((uid (or (and=> (or user (%send-dbus-user))
(compose passwd:uid getpwnam)) -1))
(gid (or (and=> (or group (%send-dbus-group))
(compose group:gid getgrnam)) -1)))
(chown temp-port uid gid)))
(lambda ()
(let ((pid (fork+exec-command command
#:user (or user (%send-dbus-user))
#:group (or group (%send-dbus-group))
#:log-file temp-file)))
(match (waitpid pid)
((_ . status)
(let ((exit-status (status:exit-val status))
(output (call-with-port temp-port get-string-all)))
(if (= 0 exit-status)
output
(error "the send-dbus command exited with: "
command exit-status output)))))))
(lambda ()
(false-if-exception (delete-file temp-file))))))
(define (parse-account-ids reply)
"Return the Jami account IDs from REPLY, which is assumed to be the output
of the Jami D-Bus `getAccountList' method."
(array->list (parse-dbus-reply reply)))
(define (parse-account-details reply)
"Parse REPLY, which is assumed to be the output of the Jami D-Bus
`getAccountDetails' method, and return its content as an alist."
(dict->alist (parse-dbus-reply reply)))
(define (parse-contacts reply)
"Parse REPLY, which is assumed to be the output of the Jamid D-Bus
`getContacts' method, and return its content as an alist."
(match (parse-dbus-reply reply)
('array
'())
(('array dicts ...)
(map dict->alist dicts))))
;;;
;;; Higher-level, D-Bus-related procedures.
;;;
(define (validate-fingerprint fingerprint)
"Validate that fingerprint is 40 characters long."
(unless (account-fingerprint? fingerprint)
(error "Account fingerprint is not valid:" fingerprint)))
(define (dbus-available-services)
"Return the list of available (acquired) D-Bus services."
(let ((reply (parse-dbus-reply
(send-dbus #:service "org.freedesktop.DBus"
#:path "/org/freedesktop/DBus"
#:interface "org.freedesktop.DBus"
#:method "ListNames"))))
;; Remove entries such as ":1.7".
(remove (cut string-prefix? ":" <>)
(array->list reply))))
(define (dbus-service-available? service)
"Predicate to check for the D-Bus SERVICE availability."
(member service (dbus-available-services)))
(define* (send-dbus/configuration-manager #:key method arguments timeout)
"Query the Jami D-Bus ConfigurationManager service."
(send-dbus #:service "cx.ring.Ring"
#:path "/cx/ring/Ring/ConfigurationManager"
#:interface "cx.ring.Ring.ConfigurationManager"
#:method method
#:arguments arguments
#:timeout timeout))
;;; The following methods are for internal use; they make use of the account
;;; ID, an implementation detail of Jami the user should not need to be
;;; concerned with.
(define (get-account-ids)
"Return the available Jami account identifiers (IDs). Account IDs are an
implementation detail used to identify the accounts in Jami."
(parse-account-ids
(send-dbus/configuration-manager #:method "getAccountList")))
(define (id->account-details id)
"Retrieve the account data associated with the given account ID."
(parse-account-details
(send-dbus/configuration-manager
#:method "getAccountDetails"
#:arguments (list (string-append "string:" id)))))
(define (id->volatile-account-details id)
"Retrieve the account data associated with the given account ID."
(parse-account-details
(send-dbus/configuration-manager
#:method "getVolatileAccountDetails"
#:arguments (list (string-append "string:" id)))))
(define (id->account id)
"Retrieve the complete account data associated with the given account ID."
(append (id->volatile-account-details id)
(id->account-details id)))
(define %username-to-id-cache #f)
(define (invalidate-username-to-id-cache!)
(set! %username-to-id-cache #f))
(define (username->id username)
"Return the first account ID corresponding to USERNAME."
(unless (assoc-ref %username-to-id-cache username)
(set! %username-to-id-cache
(append-map
(lambda (id)
(let* ((account (id->account id))
(username (assoc-ref account "Account.username"))
(registered-name (assoc-ref account
"Account.registeredName")))
`(,@(if username
(list (cons username id))
'())
,@(if registered-name
(list (cons registered-name id))
'()))))
(get-account-ids))))
(or (assoc-ref %username-to-id-cache username)
(let ((message (format #f "Could not retrieve a local account ID\
for ~:[username~;fingerprint~]" (account-fingerprint? username))))
(error message username))))
(define (account->username account)
"Return USERNAME, the registered username associated with ACCOUNT, else its
public key fingerprint."
(or (assoc-ref account "Account.registeredName")
(assoc-ref account "Account.username")))
(define (id->username id)
"Return USERNAME, the registered username associated with ID, else its
public key fingerprint, else #f."
(account->username (id->account id)))
(define (get-accounts)
"Return the list of all accounts, as a list of alists."
(map id->account (get-account-ids)))
(define (get-usernames)
"Return the list of the usernames associated with the present accounts."
(map account->username (get-accounts)))
(define (username->account username)
"Return the first account associated with USERNAME, else #f.
USERNAME can be either the account 40 characters public key fingerprint or a
registered username."
(find (lambda (account)
(member username
(list (assoc-ref account "Account.username")
(assoc-ref account "Account.registeredName"))))
(get-accounts)))
(define (add-account archive)
"Import the Jami account ARCHIVE and return its account ID. The archive
should *not* be encrypted with a password. Return the username associated
with the account."
(invalidate-username-to-id-cache!)
(let ((reply (send-dbus/configuration-manager
#:method "addAccount"
#:arguments (list (string-append
"dict:string:string:Account.archivePath,"
archive
",Account.type,RING")))))
;; The account information takes some time to be populated.
(let ((id (deserialize-item (parse-dbus-reply reply))))
(with-retries 20 1
(let ((username (id->username id)))
(if (string-null? username)
#f
username))))))
(define (remove-account username)
"Delete the Jami account associated with USERNAME, the account 40 characters
fingerprint or a registered username."
(let ((id (username->id username)))
(send-dbus/configuration-manager
#:method "removeAccount"
#:arguments (list (string-append "string:" id))))
(invalidate-username-to-id-cache!))
(define* (username->contacts username)
"Return the contacts associated with the account of USERNAME as two values;
the first one being the regular contacts and the second one the banned
contacts. USERNAME can be either the account 40 characters public key
fingerprint or a registered username. The contacts returned are represented
using their 40 characters fingerprint."
(let* ((id (username->id username))
(reply (send-dbus/configuration-manager
#:method "getContacts"
#:arguments (list (string-append "string:" id))))
(all-contacts (parse-contacts reply))
(banned? (lambda (contact)
(and=> (assoc-ref contact "banned")
(cut string=? "true" <>))))
(banned (filter banned? all-contacts))
(not-banned (filter (negate banned?) all-contacts))
(fingerprint (cut assoc-ref <> "id")))
(values (map fingerprint not-banned)
(map fingerprint banned))))
(define* (remove-contact contact username #:key ban?)
"Remove CONTACT, the 40 characters public key fingerprint of a contact, from
the account associated with USERNAME (either a fingerprint or a registered
username). When BAN? is true, also mark the contact as banned."
(validate-fingerprint contact)
(let ((id (username->id username)))
(send-dbus/configuration-manager
#:method "removeContact"
#:arguments (list (string-append "string:" id)
(string-append "string:" contact)
(serialize-boolean ban?)))))
(define (add-contact contact username)
"Add CONTACT, the 40 characters public key fingerprint of a contact, to the
account of USERNAME (either a fingerprint or a registered username)."
(validate-fingerprint contact)
(let ((id (username->id username)))
(send-dbus/configuration-manager
#:method "addContact"
#:arguments (list (string-append "string:" id)
(string-append "string:" contact)))))
(define* (set-account-details details username #:key timeout)
"Set DETAILS, an alist containing the key value pairs to set for the account
of USERNAME, a registered username or account fingerprint. The value of the
parameters not provided are unchanged. TIMEOUT is a value in milliseconds to
pass to the `send-dbus/configuration-manager' procedure."
(let* ((id (username->id username))
(current-details (id->account-details id))
(updated-details (map (match-lambda
((key . value)
(or (and=> (assoc-ref details key)
(cut cons key <>))
(cons key value))))
current-details))
;; dbus-send does not permit sending null strings (it throws a
;; "malformed dictionary" error). Luckily they seem to have the
;; semantic of "default account value" in Jami; so simply drop them.
(updated-details* (remove (match-lambda
((_ . value)
(string-null? value)))
updated-details)))
(send-dbus/configuration-manager
#:timeout timeout
#:method "setAccountDetails"
#:arguments
(list (string-append "string:" id)
(string-append "dict:string:string:"
(string-join (alist->list updated-details*)
","))))))
(define (set-all-moderators enabled? username)
"Set the 'AllModerators' property to enabled? for the account of USERNAME, a
registered username or account fingerprint."
(let ((id (username->id username)))
(send-dbus/configuration-manager
#:method "setAllModerators"
#:arguments
(list (string-append "string:" id)
(serialize-boolean enabled?)))))
(define (username->all-moderators? username)
"Return the 'AllModerators' property for the account of USERNAME, a
registered username or account fingerprint."
(let* ((id (username->id username))
(reply (send-dbus/configuration-manager
#:method "isAllModerators"
#:arguments
(list (string-append "string:" id)))))
(deserialize-item (parse-dbus-reply reply))))
(define (username->moderators username)
"Return the moderators for the account of USERNAME, a registered username or
account fingerprint."
(let* ((id (username->id username))
(reply (send-dbus/configuration-manager
#:method "getDefaultModerators"
#:arguments
(list (string-append "string:" id)))))
(array->list (parse-dbus-reply reply))))
(define (set-moderator contact enabled? username)
"Set the moderator flag to ENABLED? for CONTACT, the 40 characters public
key fingerprint of a contact for the account of USERNAME, a registered
username or account fingerprint."
(validate-fingerprint contact)
(let* ((id (username->id username)))
(send-dbus/configuration-manager #:method "setDefaultModerator"
#:arguments
(list (string-append "string:" id)
(string-append "string:" contact)
(serialize-boolean enabled?)))))
(define (disable-account username)
"Disable the account known by USERNAME, a registered username or account
fingerprint."
(set-account-details '(("Account.enable" . "false")) username
;; Waiting for the reply on this command takes a very
;; long time that trips the default D-Bus timeout value
;; (25 s), for some reason.
#:timeout 60000))
(define (enable-account username)
"Enable the account known by USERNAME, a registered username or account
fingerprint."
(set-account-details '(("Account.enable" . "true")) username))
;;;
;;; Presentation procedures.
;;;
(define (.->_ text)
"Map each period character to underscore characters."
(string-map (match-lambda
(#\. #\_)
(c c))
text))
(define (account-details->recutil account-details)
"Serialize the account-details alist into a recutil string. Period
characters in the keys are normalized to underscore to meet Recutils' format
requirements."
(define (pair->recutil-property pair)
(match pair
((key . value)
(string-append (.->_ key) ": " value))))
(define sorted-account-details
;; Have the account username, display name and alias appear first, for
;; convenience.
(let ((first-items '("Account.username"
"Account.displayName"
"Account.alias")))
(append (map (cut assoc <> account-details) first-items)
(fold alist-delete account-details first-items))))
(string-join (map pair->recutil-property sorted-account-details) "\n"))
;; Local Variables:
;; eval: (put 'with-retries 'scheme-indent-function 2)
;; End:
+48 -158
View File
@@ -1,9 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017, 20192021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2020, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -26,7 +24,6 @@
#:autoload (system repl repl) (start-repl)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
@@ -46,6 +43,7 @@
make-static-device-nodes
configure-qemu-networking
device-number
boot-system))
;;; Commentary:
@@ -94,7 +92,7 @@
get-string-all)))
(define (find-long-option option arguments)
"Find OPTION among ARGUMENTS, where OPTION is something like \"gnu.load\".
"Find OPTION among ARGUMENTS, where OPTION is something like \"--load\".
Return the value associated with OPTION, or #f on failure."
(let ((opt (string-append option "=")))
(and=> (find (cut string-prefix? opt <>)
@@ -112,53 +110,6 @@ OPTION doesn't appear in ARGUMENTS."
(substring arg (+ 1 (string-index arg #\=)))))
arguments)))
(define (resume-if-hibernated device)
"Resume from hibernation if possible. This is safe ONLY if no on-disk file
systems have been mounted; calling it later risks severe file system corruption!
See <Documentation/swsusp.txt> in the kernel source directory. This is the
caller's responsibility, as is catching exceptions if resumption was supposed to
happen but didn't.
Resume only from DEVICE if it's a string. If it's #f, use the kernel's default
hibernation device (CONFIG_PM_STD_PARTITION). Never return if resumption
succeeds. Return nothing otherwise. The kernel logs any details to dmesg."
(define (string->major:minor string)
"Return a string with MAJOR:MINOR numbers of the device specified by STRING"
;; The "resume=" kernel command-line option always provides a string, which
;; can represent a device, a UUID, or a label. Check for all three.
(let* ((spec (cond ((string-prefix? "/" string) string)
((uuid string) => identity)
(else (file-system-label string))))
;; XXX The kernel's swsusp_resume_can_resume() waits if resumewait
;; is found on the command line; our canonicalize-device-spec gives
;; up after 20 seconds. We could emulate the former by looping…
(device (canonicalize-device-spec spec))
(rdev (stat:rdev (stat device))))
(let-values (((major minor) (device-number->major+minor rdev)))
(format #f "~a:~a" major minor))))
;; Write the resume DEVICE to this magic file, using the MAJOR:MINOR device
;; numbers if possible. The kernel will immediately try to resume from it.
(let ((resume "/sys/power/resume"))
(when (file-exists? resume) ; this kernel supports hibernation
;; Honour the kernel's default device (only) if none other was given.
(let ((major:minor (if device
(or (false-if-exception (string->major:minor
device))
;; We can't parse it. Maybe the kernel can.
device)
(let ((default (call-with-input-file resume
read-line)))
;; Don't waste time echoing 0:0 to /sys.
(if (string=? "0:0" default)
#f
default)))))
(when major:minor
(call-with-output-file resume ; may throw an Invalid argument
(cut display major:minor <>))))))) ; may never return
(define* (make-disk-device-nodes base major #:optional (minor 0))
"Make the block device nodes around BASE (something like \"/root/dev/sda\")
with the given MAJOR number, starting with MINOR."
@@ -386,8 +337,17 @@ networking values.) Return #t if INTERFACE is up, #f otherwise."
(set-network-interface-address sock interface address)
(set-network-interface-flags sock interface (logior flags IFF_UP))
;; Hello! We used to create /etc/resolv.conf here, with "nameserver
;; 10.0.2.3\n". However, with Linux-libre 3.16, we're getting ENOSPC.
;; And since it's actually unnecessary, it's gone.
(logand (network-interface-flags sock interface) IFF_UP)))
(define (device-number major minor)
"Return the device number for the device with MAJOR and MINOR, for use as
the last argument of `mknod'."
(+ (* major 256) minor))
(define (pidof program)
"Return the PID of the first presumed instance of PROGRAM."
(let ((program (basename program)))
@@ -398,18 +358,11 @@ networking values.) Return #t if INTERFACE is up, #f otherwise."
(filter-map string->number (scandir "/proc")))))
(define* (mount-root-file-system root type
#:key volatile-root? (flags 0) options
check? skip-check-if-clean? repair)
#:key volatile-root? (flags 0) options)
"Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT? is
true, mount ROOT read-only and make it an overlay with a writable tmpfs using
the kernel built-in overlayfs. FLAGS and OPTIONS indicates the options to use
to mount ROOT, and behave the same as for the `mount' procedure.
If CHECK? is true, first run ROOT's fsck tool (if any) non-interactively.
If SKIP-CHECK-IF-CLEAN? is true, ask fsck to return immediately if ROOT is
marked as clean. If REPAIR is true, fsck may write to ROOT to perform repairs.
If REPAIR is also 'PREEN, ask fsck to perform only those repairs that it
considers safe."
to mount ROOT, and behave the same as for the `mount' procedure."
(if volatile-root?
(begin
@@ -430,8 +383,7 @@ considers safe."
(mount "none" "/root" "overlay" 0
"lowerdir=/real-root,upperdir=/rw-root/upper,workdir=/rw-root/work"))
(begin
(when check?
(check-file-system root type (not skip-check-if-clean?) repair))
(check-file-system root type)
(mount root "/root" type flags options)))
;; Make sure /root/etc/mtab is a symlink to /proc/self/mounts.
@@ -500,12 +452,10 @@ LINUX-MODULE-DIRECTORY, then installing KEYMAP-FILE with 'loadkeys' (if
KEYMAP-FILE is true), then setting up QEMU guest networking if
QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems
specified in MOUNTS, and finally booting into the new root if any. The initrd
supports the kernel command-line options 'gnu.load' and 'gnu.repl'. It also
honors a subset of the Linux kernel command-line parameters such as
'fsck.mode', 'resume', 'rootdelay', rootflags and rootfstype.
supports kernel command-line options '--load', '--root', and '--repl'.
Mount the root file system, specified by the 'root' command-line argument, if
any.
Mount the root file system, specified by the '--root' command-line argument,
if any.
MOUNTS must be a list of <file-system> objects.
@@ -518,86 +468,45 @@ upon error."
(string=? (file-system-mount-point fs) "/"))
(define (device-string->file-system-device device-string)
;; The "root=SPEC" kernel command-line option always provides a string,
;; but the string can represent a device, an nfs-root, a UUID, or a label.
;; So check for all four.
;; The "--root=SPEC" kernel command-line option always provides a
;; string, but the string can represent a device, an nfs-root, a UUID, or a
;; label. So check for all four.
(cond ((string-prefix? "/" device-string) device-string)
((string-contains device-string ":/") device-string) ; nfs-root
((uuid device-string) => identity)
(else (file-system-label device-string))))
(display "Welcome, this is GNU's early boot Guile.\n")
(display "Use 'gnu.repl' for an initrd REPL.\n\n")
(display "Use '--repl' for an initrd REPL.\n\n")
(call-with-error-handling
(lambda ()
(mount-essential-file-systems)
(let* ((args (linux-command-line))
(to-load (find-long-option "gnu.load" args))
;; If present, root on the kernel command line takes precedence
;; over the device field of the root <file-system> record.
(root-device (and=> (find-long-option "root" args)
device-string->file-system-device))
(rootfstype (find-long-option "rootfstype" args))
(rootflags (find-long-option "rootflags" args))
(root-fs* (find root-mount-point? mounts))
(fsck.mode (find-long-option "fsck.mode" args)))
(to-load (find-long-option "--load" args))
(root-fs (find root-mount-point? mounts))
(root-fs-type (or (and=> root-fs file-system-type)
"ext4"))
(root-fs-device (and=> root-fs file-system-device))
(root-fs-flags (mount-flags->bit-mask
(or (and=> root-fs file-system-flags)
'())))
(root-options (if root-fs
(file-system-options root-fs)
#f))
;; --root takes precedence over the 'device' field of the root
;; <file-system> record.
(root-device (or (and=> (find-long-option "--root" args)
device-string->file-system-device)
root-fs-device)))
(unless (or root-fs* (and root-device rootfstype))
(error "no root file system or 'root' and 'rootfstype' parameters"))
;; If present, root on the kernel command line takes precedence over
;; the device field of the root <file-system> record; likewise for
;; the 'rootfstype' and 'rootflags' arguments.
(define root-fs
(if root-fs*
(file-system
(inherit root-fs*)
(device (or root-device (file-system-device root-fs*)))
(type (or rootfstype (file-system-type root-fs*)))
(options (or rootflags (file-system-options root-fs*))))
(file-system
(device root-device)
(mount-point "/")
(type rootfstype)
(options rootflags))))
(define (check? fs)
(match fsck.mode
("skip" #f)
("force" #t)
(_ (file-system-check? fs)))) ; assume "auto"
(define (skip-check-if-clean? fs)
(match fsck.mode
("force" #f)
(_ (file-system-skip-check-if-clean? fs))))
(define (repair fs)
(let ((arg (find-long-option "fsck.repair" args)))
(if arg
(match arg
("no" #f)
("yes" #t)
(_ 'preen))
(file-system-repair fs))))
(when (member "gnu.repl" args)
(when (member "--repl" args)
(start-repl))
(display "loading kernel modules...\n")
(load-linux-modules-from-directory linux-modules
linux-module-directory)
(unless (or (member "hibernate=noresume" args)
;; Also handle the equivalent old-style argument.
;; See Documentation/admin-guide/kernel-parameters.txt.
(member "noresume" args))
;; Try to resume immediately after loading (storage) modules
;; but before any on-disk file systems have been mounted.
(false-if-exception ; failure is not fatal
(resume-if-hibernated (find-long-option "resume" args))))
(when keymap-file
(let ((status (system* "loadkeys" keymap-file)))
(unless (zero? status)
@@ -611,15 +520,6 @@ upon error."
(unless (configure-qemu-networking)
(display "network interface is DOWN\n")))
;; A big ugly hammer, to be used only for debugging and in desperate
;; situations where no proper device synchonisation is possible.
(let ((root-delay (and=> (find-long-option "rootdelay" args)
string->number)))
(when root-delay
(format #t "Pausing for rootdelay=~a seconds before mounting \
the root file system...\n" root-delay)
(sleep root-delay)))
;; Prepare the real root file system under /root.
(unless (file-exists? "/root")
(mkdir "/root"))
@@ -633,26 +533,16 @@ the root file system...\n" root-delay)
(setenv "EXT2FS_NO_MTAB_OK" "1")
;; Mount the root file system.
(mount-root-file-system (canonicalize-device-spec
(file-system-device root-fs))
(file-system-type root-fs)
#:volatile-root? volatile-root?
#:flags (mount-flags->bit-mask
(file-system-flags root-fs))
#:options (file-system-options root-fs)
#:check? (check? root-fs)
#:skip-check-if-clean?
(skip-check-if-clean? root-fs)
#:repair (repair root-fs))
(if root-device
(mount-root-file-system (canonicalize-device-spec root-device)
root-fs-type
#:volatile-root? volatile-root?
#:flags root-fs-flags
#:options root-options)
(mount "none" "/root" "tmpfs"))
;; Mount the specified non-root file systems.
(for-each (lambda (fs)
(mount-file-system fs
#:check? (check? fs)
#:skip-check-if-clean?
(skip-check-if-clean? fs)
#:repair (repair fs)))
;; Mount the specified file systems.
(for-each mount-file-system
(remove root-mount-point? mounts))
(setenv "EXT2FS_NO_MTAB_OK" #f)
@@ -670,7 +560,7 @@ the root file system...\n" root-delay)
(sleep 2)
(reboot))
(begin
(display "no boot file passed via 'gnu.load'\n")
(display "no boot file passed via '--load'\n")
(display "entering a warm and cozy REPL\n")
(start-repl)))))
#:on-error on-error))
+1 -2
View File
@@ -52,7 +52,7 @@ exists."
(file-exists? "/proc/self/setgroups"))
(define %namespaces
'(cgroup mnt pid ipc uts user net))
'(mnt pid ipc uts user net))
(define (call-with-clean-exit thunk)
"Apply THUNK, but exit with a status code of 1 if it fails."
@@ -210,7 +210,6 @@ corresponds to the symbols in NAMESPACES."
;; Use the same flags as fork(3) in addition to the namespace flags.
(apply logior SIGCHLD
(map (match-lambda
('cgroup CLONE_NEWCGROUP)
('mnt CLONE_NEWNS)
('uts CLONE_NEWUTS)
('ipc CLONE_NEWIPC)
+10 -6
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013, 2014, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -39,9 +39,8 @@
#:key
(compress? #t)
(gzip "gzip"))
"Write a cpio archive containing DIRECTORY to file OUTPUT, with reset
timestamps in the archive. When COMPRESS? is true, compress it using GZIP.
On success, return OUTPUT."
"Write a cpio archive containing DIRECTORY to file OUTPUT. When
COMPRESS? is true, compress it using GZIP. On success, return OUTPUT."
;; Note: as per `ramfs-rootfs-initramfs.txt', always add directory entries
;; before the files that are inside of it: "The Linux kernel cpio
@@ -127,8 +126,7 @@ REFERENCES-GRAPHS."
(mkdir "contents")
;; Copy the closures of all the items referenced in REFERENCES-GRAPHS.
(populate-store references-graphs "contents"
#:deduplicate? #f)
(populate-store references-graphs "contents")
(with-directory-excursion "contents"
;; Make '/init'.
@@ -143,6 +141,12 @@ REFERENCES-GRAPHS."
(symlink (string-append guile "/bin/guile") "proc/self/exe")
(readlink "proc/self/exe")
;; Reset the timestamps of all the files that will make it in the initrd.
(for-each (lambda (file)
(unless (eq? 'symlink (stat:type (lstat file)))
(utime file 0 0 0 0)))
(find-files "." ".*"))
(write-cpio-archive output "." #:gzip gzip))
;; Make sure directories are writable so we can delete files.
+4 -6
View File
@@ -354,13 +354,11 @@ appears in BLACK-LIST are not loaded."
(close-fdes fd)
#t)
(lambda args
;; If this module was already loaded and we're in modprobe style, ignore
;; the error.
(when fd (close-fdes fd))
(let ((errno (system-error-errno args)))
(or (and recursive? ; we're operating in modprobe style
(member errno
(list EEXIST ; already loaded
EINVAL))) ; unsupported by hardware
(apply throw args))))))))
(or (and recursive? (= EEXIST (system-error-errno args)))
(apply throw args)))))))
(define (load-linux-modules-from-directory modules directory)
"Load MODULES and their dependencies from DIRECTORY, a directory containing
+2 -82
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -20,11 +20,9 @@
(define-module (gnu build marionette)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-64)
#:use-module (rnrs io ports)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 regex)
#:export (marionette?
make-marionette
marionette-eval
@@ -35,10 +33,7 @@
marionette-screen-text
wait-for-screen-text
%qwerty-us-keystrokes
marionette-type
system-test-runner
qemu-command))
marionette-type))
;;; Commentary:
;;;
@@ -363,79 +358,4 @@ to actual keystrokes."
(for-each (cut marionette-control <> marionette)
(string->keystroke-commands str keystrokes)))
;;;
;;; Test helper.
;;;
(define* (system-test-runner #:optional log-directory)
"Return a SRFI-64 test runner that calls 'exit' upon 'test-end'. When
LOG-DIRECTORY is specified, create log file within it."
(let ((runner (test-runner-simple)))
;; Log to a file under LOG-DIRECTORY.
(test-runner-on-group-begin! runner
(let ((on-begin (test-runner-on-group-begin runner)))
(lambda (runner suite-name count)
(when log-directory
(catch 'system-error
(lambda ()
(mkdir log-directory))
(lambda args
(unless (= (system-error-errno args) EEXIST)
(apply throw args))))
(set! test-log-to-file
(string-append log-directory "/" suite-name ".log")))
(on-begin runner suite-name count))))
;; The default behavior on 'test-end' is to only write a line if the test
;; failed. Arrange to also write a line on success.
(test-runner-on-test-end! runner
(let ((on-end (test-runner-on-test-end runner)))
(lambda (runner)
(let* ((kind (test-result-ref runner 'result-kind))
(results (test-result-alist runner))
(test-name (assq-ref results 'test-name)))
(unless (memq kind '(fail xpass))
(format (current-output-port) "~a: ~a~%"
(string-upcase (symbol->string kind))
test-name)))
(on-end runner))))
;; On 'test-end', display test results and exit with zero if and only if
;; there were no test failures.
(test-runner-on-final! runner
(lambda (runner)
(let ((success? (= (test-runner-fail-count runner) 0)))
(test-on-final-simple runner)
(when (not success?)
(let* ((log-port (test-runner-aux-value runner))
(log-file (port-filename log-port)))
(format (current-error-port)
"\nTests failed, dumping log file '~a'.\n\n"
log-file)
;; At this point LOG-PORT is not closed yet; flush it.
(force-output log-port)
;; Brute force to avoid dependency on (guix build utils) for
;; 'dump-port'.
(let ((content (call-with-input-file log-file
get-bytevector-all)))
(put-bytevector (current-error-port) content))))
(exit success?))))
runner))
(define* (qemu-command #:optional (system %host-type))
"Return the default name of the QEMU command for SYSTEM."
(let ((cpu (substring system 0
(string-index system #\-))))
(string-append "qemu-system-"
(cond
((string-match "^i[3456]86$" cpu) "i386")
((string-match "armhf" cpu) "arm")
(else cpu)))))
;;; marionette.scm ends here
+1 -16
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -111,15 +111,6 @@ wait for at most HANDSHAKE-TIMEOUT seconds for handshake to complete. Return
(close-port sock)
#f))))
(define (delete-file* file)
"Ensure FILE does not exist."
(catch 'system-error
(lambda ()
(delete-file file))
(lambda args
(unless (= ENOENT (system-error-errno args))
(apply throw args)))))
(define (secret-service-receive-secrets port)
"Listen to local PORT and wait for a secret service client to send secrets.
Write them to the file system. Return the list of files installed on success,
@@ -179,12 +170,6 @@ and #f otherwise."
(log "installing file '~a' (~a bytes)...~%"
file size)
(mkdir-p (dirname file))
;; It could be that FILE already exists, for instance
;; because it has been created by a service's activation
;; snippet (e.g., SSH host keys). Delete it.
(delete-file* file)
(call-with-output-file file
(lambda (output)
(dump port output size)
+8 -6
View File
@@ -24,12 +24,6 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
;; XXX: Lazy-bind the Shepherd to avoid a compile-time dependency.
#:autoload (shepherd service) (fork+exec-command
read-pid-file
exec-command
%precious-signals)
#:autoload (shepherd system) (unblock-signals)
#:export (make-forkexec-constructor/container
fork+exec-command/container))
@@ -98,6 +92,14 @@
(file-exists? (file-system-mapping-source mapping)))
mappings)))))
;; XXX: Lazy-bind the Shepherd to avoid a compile-time dependency.
(module-autoload! (current-module)
'(shepherd service)
'(fork+exec-command read-pid-file exec-command
%precious-signals))
(module-autoload! (current-module)
'(shepherd system) '(unblock-signals))
(define* (read-pid-file/container pid pid-file #:key (max-delay 5))
"Read PID-FILE in the container namespaces of PID, which exists in a
separate mount and PID name space. Return the \"outer\" PID. "
+506
View File
@@ -0,0 +1,506 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu build vm)
#:use-module (guix build utils)
#:use-module (guix build store-copy)
#:use-module (guix build syscalls)
#:use-module (guix store database)
#:use-module (gnu build bootloader)
#:use-module (gnu build linux-boot)
#:use-module (gnu build install)
#:use-module (gnu system uuid)
#:use-module (guix records)
#:use-module ((guix combinators) #:select (fold2))
#:use-module (ice-9 format)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (ice-9 popen)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-26)
#:export (qemu-command
load-in-linux-vm
format-partition
partition
partition?
partition-device
partition-size
partition-file-system
partition-label
partition-flags
partition-initializer
estimated-partition-size
root-partition-initializer
initialize-partition-table
initialize-hard-disk))
;;; Commentary:
;;;
;;; This module provides supporting code to run virtual machines and build
;;; virtual machine images using QEMU.
;;;
;;; Code:
(define* (qemu-command #:optional (system %host-type))
"Return the default name of the QEMU command for SYSTEM."
(let ((cpu (substring system 0
(string-index system #\-))))
(string-append "qemu-system-"
(cond
((string-match "^i[3456]86$" cpu) "i386")
((string-match "armhf" cpu) "arm")
(else cpu)))))
(define* (load-in-linux-vm builder
#:key
output
(qemu (qemu-command)) (memory-size 512)
linux initrd
make-disk-image?
single-file-output?
(disk-image-size (* 100 (expt 2 20)))
(disk-image-format "qcow2")
(references-graphs '()))
"Run BUILDER, a Scheme file, into a VM running LINUX with INITRD, and copy
the result to OUTPUT. If SINGLE-FILE-OUTPUT? is true, copy a single file from
/xchg to OUTPUT. Otherwise, copy the contents of /xchg to a new directory
OUTPUT.
When MAKE-DISK-IMAGE? is true, OUTPUT will contain a VM image of
DISK-IMAGE-SIZE bytes resulting from the execution of BUILDER, which may
access it via /dev/hda.
REFERENCES-GRAPHS can specify a list of reference-graph files as produced by
the #:references-graphs parameter of 'derivation'."
(define target-arm32?
(string-prefix? "arm-" %host-type))
(define target-aarch64?
(string-prefix? "aarch64-" %host-type))
(define target-arm?
(or target-arm32? target-aarch64?))
(define arch-specific-flags
`(;; On ARM, a machine has to be specified. Use "virt" machine to avoid
;; hardware limits imposed by other machines.
,@(if target-arm?
'("-M" "virt")
'())
;; On ARM32, if the kernel is built without LPAE support, ECAM conflicts
;; with VIRT_PCIE_MMIO causing PCI devices not to show up. Disable
;; explicitely highmem to fix it.
;; See: https://bugs.launchpad.net/qemu/+bug/1790975.
,@(if target-arm32?
'("-machine" "highmem=off")
'())
;; Only enable kvm if we see /dev/kvm exists. This allows users without
;; hardware virtualization to still use these commands. KVM support is
;; still buggy on some ARM boards. Do not use it even if available.
,@(if (and (file-exists? "/dev/kvm")
(not target-arm?))
'("-enable-kvm")
'())
;; Pass "panic=1" so that the guest dies upon error.
"-append"
,(string-append "panic=1 --load=" builder
;; The serial port name differs between emulated
;; architectures/machines.
" console="
(if target-arm? "ttyAMA0" "ttyS0"))))
(when make-disk-image?
(format #t "creating ~a image of ~,2f MiB...~%"
disk-image-format (/ disk-image-size (expt 2 20)))
(force-output)
(invoke "qemu-img" "create" "-f" disk-image-format output
(number->string disk-image-size)))
(mkdir "xchg")
(mkdir "tmp")
(match references-graphs
((graph-files ...)
;; Copy the reference-graph files under xchg/ so EXP can access it.
(map (lambda (file)
(copy-file file (string-append "xchg/" file)))
graph-files))
(_ #f))
(apply invoke qemu "-nographic" "-no-reboot"
;; CPU "max" behaves as "host" when KVM is enabled, and like a system
;; CPU with the maximum possible feature set otherwise.
"-cpu" "max"
"-m" (number->string memory-size)
"-nic" "user,model=virtio-net-pci"
"-object" "rng-random,filename=/dev/urandom,id=guixsd-vm-rng"
"-device" "virtio-rng-pci,rng=guixsd-vm-rng"
"-virtfs"
(string-append "local,id=store_dev,path="
(%store-directory)
",security_model=none,mount_tag=store")
"-virtfs"
(string-append "local,id=xchg_dev,path=xchg"
",security_model=none,mount_tag=xchg")
"-virtfs"
;; Some programs require more space in /tmp than is normally
;; available in the guest. Accommodate such programs by sharing a
;; temporary directory.
(string-append "local,id=tmp_dev,path=tmp"
",security_model=none,mount_tag=tmp")
"-kernel" linux
"-initrd" initrd
(append
(if make-disk-image?
`("-device" "virtio-blk,drive=myhd"
"-drive" ,(string-append "if=none,file=" output
",format=" disk-image-format
",id=myhd"))
'())
arch-specific-flags))
(unless (file-exists? "xchg/.exit-status")
(error "VM did not produce an exit code"))
(match (call-with-input-file "xchg/.exit-status" read)
(0 #t)
(status (error "guest VM code exited with a non-zero status" status)))
(delete-file "xchg/.exit-status")
;; When MAKE-DISK-IMAGE? is true, the image is in OUTPUT already.
(unless make-disk-image?
(if single-file-output?
(let ((graph? (lambda (name stat)
(member (basename name) references-graphs))))
(match (find-files "xchg" (negate graph?))
((result)
(copy-file result output))
(x
(error "did not find a single result file" x))))
(begin
(mkdir output)
(copy-recursively "xchg" output)))))
(define* (register-closure prefix closure
#:key
(deduplicate? #t) (reset-timestamps? #t)
(schema (sql-schema)))
"Register CLOSURE in PREFIX, where PREFIX is the directory name of the
target store and CLOSURE is the name of a file containing a reference graph as
produced by #:references-graphs.. As a side effect, if RESET-TIMESTAMPS? is
true, reset timestamps on store files and, if DEDUPLICATE? is true,
deduplicates files common to CLOSURE and the rest of PREFIX."
(let ((items (call-with-input-file closure read-reference-graph)))
(parameterize ((sql-schema schema))
(with-database (store-database-file #:prefix prefix) db
(register-items db items
#:prefix prefix
#:deduplicate? deduplicate?
#:reset-timestamps? reset-timestamps?
#:registration-time %epoch)))))
;;;
;;; Partitions.
;;;
(define-record-type* <partition> partition make-partition
partition?
(device partition-device (default #f))
(size partition-size)
(file-system partition-file-system (default "ext4"))
(file-system-options partition-file-system-options ;passed to 'mkfs.FS'
(default '()))
(label partition-label (default #f))
(uuid partition-uuid (default #f))
(flags partition-flags (default '()))
(initializer partition-initializer (default (const #t))))
(define (estimated-partition-size graphs)
"Return the estimated size of a partition that can store the store items
given by GRAPHS, a list of file names produced by #:references-graphs."
;; Simply add a 25% overhead.
(round (* 1.25 (closure-size graphs))))
(define* (initialize-partition-table device partitions
#:key
(label-type "msdos")
(offset (expt 2 20)))
"Create on DEVICE a partition table of type LABEL-TYPE, containing the given
PARTITIONS (a list of <partition> objects), starting at OFFSET bytes. On
success, return PARTITIONS with their 'device' field changed to reflect their
actual /dev name based on DEVICE."
(define (partition-options part offset index)
(cons* "mkpart" "primary" "ext2"
(format #f "~aB" offset)
(format #f "~aB" (+ offset (partition-size part)))
(append-map (lambda (flag)
(list "set" (number->string index)
(symbol->string flag) "on"))
(partition-flags part))))
(define (options partitions offset)
(let loop ((partitions partitions)
(offset offset)
(index 1)
(result '()))
(match partitions
(()
(concatenate (reverse result)))
((head tail ...)
(loop tail
;; Leave one sector (512B) between partitions to placate
;; Parted.
(+ offset 512 (partition-size head))
(+ 1 index)
(cons (partition-options head offset index)
result))))))
(format #t "creating partition table with ~a partitions (~a)...\n"
(length partitions)
(string-join (map (compose (cut string-append <> " MiB")
number->string
(lambda (size)
(round (/ size (expt 2. 20))))
partition-size)
partitions)
", "))
(apply invoke "parted" "--script"
device "mklabel" label-type
(options partitions offset))
;; Set the 'device' field of each partition.
(reverse
(fold2 (lambda (part result index)
(values (cons (partition
(inherit part)
(device (string-append device
(number->string index))))
result)
(+ 1 index)))
'()
1
partitions)))
(define MS_BIND 4096) ; <sys/mounts.h> again!
(define* (create-ext-file-system partition type
#:key label uuid (options '()))
"Create an ext-family file system of TYPE on PARTITION. If LABEL is true,
use that as the volume name. If UUID is true, use it as the partition UUID."
(format #t "creating ~a partition... ~@[label: ~s~] ~@[uuid: ~s~]\n"
type label (and uuid (uuid->string uuid)))
(apply invoke (string-append "mkfs." type)
"-F" partition
`(,@(if label
`("-L" ,label)
'())
,@(if uuid
`("-U" ,(uuid->string uuid))
'())
,@options)))
(define* (create-fat-file-system partition
#:key label uuid (options '()))
"Create a FAT file system on PARTITION. The number of File Allocation Tables
will be determined based on file system size. If LABEL is true, use that as the
volume name."
;; FIXME: UUID is ignored!
(format #t "creating FAT partition...\n")
(apply invoke "mkfs.fat" partition
(append (if label `("-n" ,label) '()) options)))
(define* (format-partition partition type
#:key label uuid (options '()))
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
volume name. Options is a list of command-line options passed to 'mkfs.FS'."
(cond ((string-prefix? "ext" type)
(create-ext-file-system partition type #:label label #:uuid uuid
#:options options))
((or (string-prefix? "fat" type) (string= "vfat" type))
(create-fat-file-system partition #:label label #:uuid uuid
#:options options))
(else (error "Unsupported file system."))))
(define (initialize-partition partition)
"Format PARTITION, a <partition> object with a non-#f 'device' field, mount
it, run its initializer, and unmount it."
(let ((target "/fs"))
(format-partition (partition-device partition)
(partition-file-system partition)
#:label (partition-label partition)
#:uuid (partition-uuid partition)
#:options (partition-file-system-options partition))
(mkdir-p target)
(mount (partition-device partition) target
(partition-file-system partition))
((partition-initializer partition) target)
(umount target)
partition))
(define* (root-partition-initializer #:key (closures '())
copy-closures?
(register-closures? #t)
system-directory
(deduplicate? #t)
(make-device-nodes
make-essential-device-nodes)
(extra-directives '()))
"Return a procedure to initialize a root partition.
If REGISTER-CLOSURES? is true, register all of CLOSURES in the partition's
store. If DEDUPLICATE? is true, then also deduplicate files common to
CLOSURES and the rest of the store when registering the closures. If
COPY-CLOSURES? is true, copy all of CLOSURES to the partition.
SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation.
EXTRA-DIRECTIVES is an optional list of directives to populate the root file
system that is passed to 'populate-root-file-system'."
(lambda (target)
(define target-store
(string-append target (%store-directory)))
(when copy-closures?
;; Populate the store.
(populate-store (map (cut string-append "/xchg/" <>) closures)
target))
;; Populate /dev.
(make-device-nodes target)
;; Optionally, register the inputs in the image's store.
(when register-closures?
(unless copy-closures?
;; XXX: 'register-closure' wants to palpate the things it registers, so
;; bind-mount the store on the target.
(mkdir-p target-store)
(mount (%store-directory) target-store "" MS_BIND))
(display "registering closures...\n")
(for-each (lambda (closure)
(register-closure target
(string-append "/xchg/" closure)
#:reset-timestamps? copy-closures?
#:deduplicate? deduplicate?))
closures)
(unless copy-closures?
(umount target-store)))
;; Add the non-store directories and files.
(display "populating...\n")
(populate-root-file-system system-directory target
#:extras extra-directives)
;; 'register-closure' resets timestamps and everything, so no need to do it
;; once more in that case.
(unless register-closures?
;; 'reset-timestamps' also resets file permissions; do that everywhere
;; except on /dev so that /dev/null remains writable, etc.
(for-each (lambda (directory)
(reset-timestamps (string-append target "/" directory)))
(scandir target
(match-lambda
((or "." ".." "dev") #f)
(_ #t))))
(reset-timestamps (string-append target "/dev")
#:preserve-permissions? #t))))
(define (register-bootcfg-root target bootcfg)
"On file system TARGET, register BOOTCFG as a GC root."
(let ((directory (string-append target "/var/guix/gcroots")))
(mkdir-p directory)
(symlink bootcfg (string-append directory "/bootcfg"))))
(define* (initialize-hard-disk device
#:key
bootloader-package
bootcfg
bootcfg-location
bootloader-installer
(grub-efi #f)
(partitions '()))
"Initialize DEVICE as a disk containing all the <partition> objects listed
in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
Each partition is initialized by calling its 'initializer' procedure,
passing it a directory name where it is mounted."
(define (partition-bootable? partition)
"Return the first partition found with the boot flag set."
(member 'boot (partition-flags partition)))
(define (partition-esp? partition)
"Return the first EFI System Partition."
(member 'esp (partition-flags partition)))
(let* ((partitions (initialize-partition-table device partitions))
(root (find partition-bootable? partitions))
(esp (find partition-esp? partitions))
(target "/fs"))
(unless root
(error "no bootable partition specified" partitions))
(for-each initialize-partition partitions)
(display "mounting root partition...\n")
(mkdir-p target)
(mount (partition-device root) target (partition-file-system root))
(install-boot-config bootcfg bootcfg-location target)
(when bootloader-installer
(display "installing bootloader...\n")
(bootloader-installer bootloader-package device target))
(when esp
;; Mount the ESP somewhere and install GRUB UEFI image.
(let ((mount-point (string-append target "/boot/efi")))
(display "mounting EFI system partition...\n")
(mkdir-p mount-point)
(mount (partition-device esp) mount-point
(partition-file-system esp))
(display "creating EFI firmware image...")
(install-efi-loader grub-efi mount-point)
(display "done.\n")
(umount mount-point)))
;; Register BOOTCFG as a GC root.
(register-bootcfg-root target bootcfg)
(umount target)))
;;; vm.scm ends here
+95 -99
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012-2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2018, 2019 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
@@ -28,7 +28,6 @@
#:use-module (guix grafts)
#:use-module (guix profiles)
#:use-module (guix packages)
#:autoload (guix transformations) (tunable-package? tuned-package)
#:use-module (guix channels)
#:use-module (guix config)
#:use-module (guix derivations)
@@ -38,7 +37,8 @@
#:use-module (guix ui)
#:use-module ((guix licenses)
#:select (gpl3+ license? license-name))
#:use-module ((guix utils) #:select (%current-system))
#:use-module ((guix utils) #:select (%current-system
location-file))
#:use-module ((guix scripts system) #:select (read-operating-system))
#:use-module ((guix scripts pack)
#:select (lookup-compressor self-contained-tarball))
@@ -60,9 +60,7 @@
#:use-module (gnu system vm)
#:use-module (gnu system install)
#:use-module (gnu system images hurd)
#:use-module (gnu system images novena)
#:use-module (gnu system images pine64)
#:use-module (gnu system images pinebook-pro)
#:use-module (gnu tests)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
@@ -83,10 +81,60 @@
;;;
;;; Code:
;; Backport from (guix channels) module.
(define* (sexp->channel sexp #:optional (name 'channel))
"Read SEXP, a provenance sexp as created by 'channel-instance->sexp'; use
NAME as the channel name if SEXP does not specify it. Return #f if the sexp
does not have the expected structure."
(match sexp
(('repository ('version 0)
('url url)
('branch branch)
('commit commit)
rest ...)
;; Historically channel sexps did not include the channel name. It's OK
;; for channels created by 'channel-instances->manifest' because the
;; entry name is the channel name, but it was missing for entries created
;; by 'manifest-entry-with-provenance'.
(channel (name (match (assq 'name rest)
(#f name)
(('name name) name)))
(url url)
(branch branch)
(commit commit)
(introduction
(match (assq 'introduction rest)
(#f #f)
(('introduction intro)
(sexp->channel-introduction intro))))))
(_ #f)))
;; Backport from (guix describe) module.
(define (package-channels package)
"Return the list of channels providing PACKAGE or an empty list if it could
not be determined."
(match (and=> (package-location package) location-file)
(#f '())
(file
(let ((file (if (string-prefix? "/" file)
file
(search-path %load-path file))))
(if (and file
(string-prefix? (%store-prefix) file))
(filter-map
(lambda (entry)
(let ((item (manifest-entry-item entry)))
(and (or (string-prefix? item file)
(string=? "guix" (manifest-entry-name entry)))
(manifest-entry-channel entry))))
(current-profile-entries))
'())))))
(define* (derivation->job name drv
#:key
(max-silent-time 3600)
(timeout (* 5 3600)))
(timeout 3600))
"Return a Cuirass job called NAME and describing DRV.
MAX-SILENT-TIME and TIMEOUT are build options passed to the daemon when
@@ -108,9 +156,9 @@ building the derivation."
(#:timeout . ,timeout)))
(define* (package-job store job-name package system
#:key cross? target (suffix ""))
#:key cross? target)
"Return a job called JOB-NAME that builds PACKAGE on SYSTEM."
(let ((job-name (string-append job-name "." system suffix)))
(let ((job-name (string-append job-name "." system)))
(parameterize ((%graft? #f))
(let* ((drv (if cross?
(package-cross-derivation store package target system
@@ -130,7 +178,7 @@ building the derivation."
(define (package-cross-job store job-name package target system)
"Return a job called TARGET.JOB-NAME that cross-builds PACKAGE for TARGET on
SYSTEM."
(let ((name (string-append target "." job-name)))
(let ((name (string-append target "." job-name "." system)))
(package-job store name package system
#:cross? #t
#:target target)))
@@ -139,9 +187,9 @@ SYSTEM."
;; Note: Don't put the '-final' package variants because (1) that's
;; implicit, and (2) they cannot be cross-built (due to the explicit input
;; chain.)
(list gcc-8 gcc-9 gcc-10 gcc-11 glibc binutils
(list gcc-7 gcc-8 gcc-9 gcc-10 glibc binutils
gmp mpfr mpc coreutils findutils diffutils patch sed grep
gawk gnu-gettext hello guile-2.2 guile-3.0 zlib gzip xz guix
gawk gnu-gettext hello guile-2.0 guile-2.2 zlib gzip xz
%bootstrap-binaries-tarball
%binutils-bootstrap-tarball
(%glibc-bootstrap-tarball)
@@ -149,19 +197,6 @@ SYSTEM."
%guile-bootstrap-tarball
%bootstrap-tarballs))
(define (commencement-packages system)
"Return the list of bootstrap packages from the commencement module for
SYSTEM."
;; Only include packages supported on SYSTEM. For example, the Mes
;; bootstrap graph is currently not supported on ARM so it should be
;; excluded.
(filter (lambda (obj)
(and (package? obj)
(supported-package? obj system)))
(module-map (lambda (sym var)
(variable-ref var))
(resolve-module '(gnu packages commencement)))))
(define (packages-to-cross-build target)
"Return the list of packages to cross-build for TARGET."
;; Don't cross-build the bootstrap tarballs for MinGW.
@@ -247,9 +282,7 @@ SYSTEM."
(define %guix-system-images
(list hurd-barebones-qcow2-image
pine64-barebones-raw-image
pinebook-pro-barebones-raw-image
novena-barebones-raw-image))
pine64-barebones-raw-image))
(define (hours hours)
(* 3600 hours))
@@ -302,16 +335,20 @@ otherwise use the IMAGE name."
(define channel-build-system
;; Build system used to "convert" a channel instance to a package.
(let* ((build (lambda* (name inputs
#:key source commit system
#:allow-other-keys)
(mlet* %store-monad ((source (if (string? source)
(return source)
(lower-object source)))
(instance
-> (checkout->channel-instance
source #:commit commit)))
(channel-instances->derivation (list instance)))))
(let* ((build (lambda* (store name inputs
#:key source commit system
#:allow-other-keys)
(run-with-store store
;; SOURCE can be a lowerable object such as <local-file>
;; or a file name. Adjust accordingly.
(mlet* %store-monad ((source (if (string? source)
(return source)
(lower-object source)))
(instance
-> (checkout->channel-instance
source #:commit commit)))
(channel-instances->derivation (list instance)))
#:system system)))
(lower (lambda* (name #:key system source commit
#:allow-other-keys)
(bag
@@ -396,39 +433,21 @@ otherwise use the IMAGE name."
(((_ inputs _ ...) ...)
inputs))))
(%final-inputs)))))
(lambda* (store package system #:key (suffix ""))
(lambda (store package system)
"Return a job for PACKAGE on SYSTEM, or #f if this combination is not
valid. Append SUFFIX to the job name."
valid."
(cond ((member package base-packages)
(package-job store (string-append "base." (job-name package))
package system #:suffix suffix))
package system))
((supported-package? package system)
(let ((drv (package-derivation store package system
#:graft? #f)))
(and (substitutable-derivation? drv)
(package-job store (job-name package)
package system #:suffix suffix))))
package system))))
(else
#f)))))
(define %x86-64-micro-architectures
;; Micro-architectures for which we build tuned variants.
'("westmere" "ivybridge" "haswell" "skylake" "skylake-avx512"))
(define (tuned-package-jobs store package system)
"Return a list of jobs for PACKAGE tuned for SYSTEM's micro-architectures."
(filter-map (lambda (micro-architecture)
(define suffix
(string-append "." micro-architecture))
(package->job store
(tuned-package package micro-architecture)
system
#:suffix suffix))
(match system
("x86_64-linux" %x86-64-micro-architectures)
(_ '()))))
(define (all-packages)
"Return the list of packages to build."
(define (adjust package result)
@@ -462,40 +481,19 @@ valid. Append SUFFIX to the job name."
(map channel-url channels)))
arguments))
(define (manifests->jobs store manifests)
"Return the list of jobs for the entries in MANIFESTS, a list of file
names."
(define (manifests->packages store manifests)
"Return the list of packages found in MANIFESTS."
(define (load-manifest manifest)
(save-module-excursion
(lambda ()
(set-current-module (make-user-module '((guix profiles) (gnu))))
(primitive-load manifest))))
(define (manifest-entry-job-name entry)
(string-append (manifest-entry-name entry) "-"
(manifest-entry-version entry)))
(define (manifest-entry->job entry)
(let* ((obj (manifest-entry-item entry))
(drv (parameterize ((%graft? #f))
(run-with-store store
(lower-object obj))))
(max-silent-time (or (and (package? obj)
(assoc-ref (package-properties obj)
'max-silent-time))
3600))
(timeout (or (and (package? obj)
(assoc-ref (package-properties obj) 'timeout))
(* 5 3600))))
(derivation->job (manifest-entry-job-name entry) drv
#:max-silent-time max-silent-time
#:timeout timeout)))
(map manifest-entry->job
(delete-duplicates
(append-map (compose manifest-entries load-manifest)
manifests)
manifest-entry=?)))
(delete-duplicates!
(map manifest-entry-item
(append-map (compose manifest-entries
load-manifest)
manifests))))
(define (arguments->systems arguments)
"Return the systems list from ARGUMENTS."
@@ -546,16 +544,10 @@ names."
('all
;; Build everything, including replacements.
(let ((all (all-packages))
(jobs (lambda (package)
(match (package->job store package system)
(#f '())
(main-job
(cons main-job
(if (tunable-package? package)
(tuned-package-jobs store package system)
'())))))))
(job (lambda (package)
(package->job store package system))))
(append
(append-map jobs all)
(filter-map job all)
(cross-jobs store system))))
('core
;; Build core packages only.
@@ -563,7 +555,7 @@ names."
(map (lambda (package)
(package-job store (job-name package)
package system))
(append (commencement-packages system) %core-packages))
%core-packages)
(cross-jobs store system)))
('guix
;; Build Guix modules only.
@@ -614,8 +606,12 @@ names."
packages)))
(('manifests . rest)
;; Build packages in the list of manifests.
(let ((manifests (arguments->manifests rest channels)))
(manifests->jobs store manifests)))
(let* ((manifests (arguments->manifests rest channels))
(packages (manifests->packages store manifests)))
(map (lambda (package)
(package-job store (job-name package)
package system))
packages)))
(else
(error "unknown subset" subset))))
systems)))
-116
View File
@@ -1,116 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home)
#:use-module (gnu home services)
#:use-module (gnu home services symlink-manager)
#:use-module (gnu home services shells)
#:use-module (gnu home services xdg)
#:use-module (gnu home services fontutils)
#:use-module (gnu services)
#:use-module (guix records)
#:use-module (guix diagnostics)
#:use-module (guix gexp)
#:use-module (guix store)
#:export (home-environment
home-environment?
this-home-environment
home-environment-derivation
home-environment-user-services
home-environment-essential-services
home-environment-services
home-environment-location
home-environment-with-provenance))
;;; Comment:
;;;
;;; This module provides a <home-environment> record for managing
;;; per-user packages and configuration files in the similar way as
;;; <operating-system> do for system packages and configuration files.
;;;
;;; Code:
(define-record-type* <home-environment> home-environment
make-home-environment
home-environment?
this-home-environment
(packages home-environment-packages ; list of (PACKAGE OUTPUT...)
(default '()))
(essential-services home-environment-essential-services ; list of services
(thunked)
(default (home-environment-default-essential-services
this-home-environment)))
(services home-environment-user-services
(default '()))
(location home-environment-location ; <location>
(default (and=> (current-source-location)
source-properties->location))
(innate)))
(define (home-environment-default-essential-services he)
"Return the list of essential services for home environment."
(list
(service home-run-on-first-login-service-type)
(service home-activation-service-type)
(service home-environment-variables-service-type)
(service home-symlink-manager-service-type)
(service home-fontconfig-service-type)
(service home-xdg-base-directories-service-type)
(service home-shell-profile-service-type)
(service home-service-type)
(service home-profile-service-type (home-environment-packages he))))
(define* (home-environment-services he)
"Return all the services of home environment."
(instantiate-missing-services
(append (home-environment-user-services he)
(home-environment-essential-services he))))
(define* (home-environment-derivation he)
"Return a derivation that builds OS."
(let* ((services (home-environment-services he))
(home (fold-services services
#:target-type home-service-type)))
(service-value home)))
(define* (home-environment-with-provenance he config-file)
"Return a variant of HE that stores its own provenance information,
including CONFIG-FILE, if available. This is achieved by adding an instance
of HOME-PROVENANCE-SERVICE-TYPE to its services."
(home-environment
(inherit he)
(services (cons (service home-provenance-service-type config-file)
(home-environment-user-services he)))))
(define-gexp-compiler (home-environment-compiler (he <home-environment>)
system target)
((store-lift
(lambda (store)
(run-with-store store (home-environment-derivation he)
#:system system
#:target target)))))
-582
View File
@@ -1,582 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services)
#:use-module (gnu services)
#:use-module ((gnu packages package-management) #:select (guix))
#:use-module (guix channels)
#:use-module (guix monads)
#:use-module (guix store)
#:use-module (guix gexp)
#:use-module (guix profiles)
#:use-module (guix sets)
#:use-module (guix ui)
#:use-module (guix discovery)
#:use-module (guix diagnostics)
#:use-module (guix i18n)
#:use-module (guix modules)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (home-service-type
home-profile-service-type
home-environment-variables-service-type
home-files-service-type
home-xdg-configuration-files-service-type
home-run-on-first-login-service-type
home-activation-service-type
home-run-on-change-service-type
home-provenance-service-type
home-files-directory
xdg-configuration-files-directory
fold-home-service-types
home-provenance
%initialize-gettext)
#:re-export (service
service-type
service-extension))
;;; Comment:
;;;
;;; This module is similar to (gnu system services) module, but
;;; provides Home Services, which are supposed to be used for building
;;; home-environment.
;;;
;;; Home Services use the same extension as System Services. Consult
;;; (gnu system services) module or manual for more information.
;;;
;;; home-service-type is a root of home services DAG.
;;;
;;; home-profile-service-type is almost the same as profile-service-type, at least
;;; for now.
;;;
;;; home-environment-variables-service-type generates a @file{setup-environment}
;;; shell script, which is expected to be sourced by login shell or other program,
;;; which starts early and spawns all other processes. Home services for shells
;;; automatically add code for sourcing this file, if person do not use those home
;;; services they have to source this script manually in their's shell *profile
;;; file (details described in the manual).
;;;
;;; home-files-service-type is similar to etc-service-type, but doesn't extend
;;; home-activation, because deploy mechanism for config files is pluggable
;;; and can be different for different home environments: The default one is
;;; called symlink-manager, which creates links for various dotfiles and xdg
;;; configuration files to store, but is possible to implement alternative
;;; approaches like read-only home from Julien's guix-home-manager.
;;;
;;; home-run-on-first-login-service-type provides an @file{on-first-login} guile
;;; script, which runs provided gexps once, when user makes first login. It can
;;; be used to start user's Shepherd and maybe some other process. It relies on
;;; assumption that /run/user/$UID will be created on login by some login
;;; manager (elogind for example).
;;;
;;; home-activation-service-type provides an @file{activate} guile script, which
;;; do three main things:
;;;
;;; - Sets environment variables to the values declared in
;;; @file{setup-environment} shell script. It's necessary, because user can set
;;; for example XDG_CONFIG_HOME and it should be respected by activation gexp of
;;; symlink-manager.
;;;
;;; - Sets GUIX_NEW_HOME and possibly GUIX_OLD_HOME vars to paths in the store.
;;; Later those variables can be used by activation gexps, for example by
;;; symlink-manager or run-on-change services.
;;;
;;; - Run all activation gexps provided by other home services.
;;;
;;; home-run-on-change-service-type allows to trigger actions during
;;; activation if file or directory specified by pattern is changed.
;;;
;;; Code:
(define (home-derivation entries mextensions)
"Return as a monadic value the derivation of the 'home'
directory containing the given entries."
(mlet %store-monad ((extensions (mapm/accumulate-builds identity
mextensions)))
(lower-object
(file-union "home" (append entries (concatenate extensions))))))
(define home-service-type
;; This is the ultimate service type, the root of the home service
;; DAG. The service of this type is extended by monadic name/item
;; pairs. These items end up in the "home-environment directory" as
;; returned by 'home-environment-derivation'.
(service-type (name 'home)
(extensions '())
(compose identity)
(extend home-derivation)
(default-value '())
(description
"Build the home environment top-level directory,
which in turn refers to everything the home environment needs: its
packages, configuration files, activation script, and so on.")))
(define (packages->profile-entry packages)
"Return a system entry for the profile containing PACKAGES."
;; XXX: 'mlet' is needed here for one reason: to get the proper
;; '%current-target' and '%current-target-system' bindings when
;; 'packages->manifest' is called, and thus when the 'package-inputs'
;; etc. procedures are called on PACKAGES. That way, conditionals in those
;; inputs see the "correct" value of these two parameters. See
;; <https://issues.guix.gnu.org/44952>.
(mlet %store-monad ((_ (current-target-system)))
(return `(("profile" ,(profile
(content (packages->manifest
(map identity
;;(options->transformation transformations)
(delete-duplicates packages eq?))))))))))
;; MAYBE: Add a list of transformations for packages. It's better to
;; place it in home-profile-service-type to affect all profile
;; packages and prevent conflicts, when other packages relies on
;; non-transformed version of package.
(define home-profile-service-type
(service-type (name 'home-profile)
(extensions
(list (service-extension home-service-type
packages->profile-entry)))
(compose concatenate)
(extend append)
(description
"This is the @dfn{home profile} and can be found in
@file{~/.guix-home/profile}. It contains packages and
configuration files that the user has declared in their
@code{home-environment} record.")))
(define (environment-variables->setup-environment-script vars)
"Return a file that can be sourced by a POSIX compliant shell which
initializes the environment. The file will source the home
environment profile, set some default environment variables, and set
environment variables provided in @code{vars}. @code{vars} is a list
of pairs (@code{(key . value)}), @code{key} is a string and
@code{value} is a string or gexp.
If value is @code{#f} variable will be omitted.
If value is @code{#t} variable will be just exported.
For any other, value variable will be set to the @code{value} and
exported."
(define (warn-about-duplicate-defenitions)
(fold
(lambda (x acc)
(when (equal? (car x) (car acc))
(warning
(G_ "duplicate definition for `~a' environment variable ~%") (car x)))
x)
(cons "" "")
(sort vars (lambda (a b)
(string<? (car a) (car b))))))
(warn-about-duplicate-defenitions)
(with-monad
%store-monad
(return
`(("setup-environment"
;; TODO: It's necessary to source ~/.guix-profile too
;; on foreign distros
,(apply mixed-text-file "setup-environment"
"\
HOME_ENVIRONMENT=$HOME/.guix-home
GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
PROFILE_FILE=\"$HOME_ENVIRONMENT/profile/etc/profile\"
[ -f $PROFILE_FILE ] && . $PROFILE_FILE
case $XDG_DATA_DIRS in
*$HOME_ENVIRONMENT/profile/share*) ;;
*) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
esac
case $MANPATH in
*$HOME_ENVIRONMENT/profile/share/man*) ;;
*) export MANPATH=$HOME_ENVIRONMENT/profile/share/man:$MANPATH
esac
case $INFOPATH in
*$HOME_ENVIRONMENT/profile/share/info*) ;;
*) export INFOPATH=$HOME_ENVIRONMENT/profile/share/info:$INFOPATH ;;
esac
case $XDG_CONFIG_DIRS in
*$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
*) export XDG_CONFIG_DIRS=$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFIG_DIRS ;;
esac
case $XCURSOR_PATH in
*$HOME_ENVIRONMENT/profile/share/icons*) ;;
*) export XCURSOR_PATH=$HOME_ENVIRONMENT/profile/share/icons:$XCURSOR_PATH ;;
esac
"
(append-map
(match-lambda
((key . #f)
'())
((key . #t)
(list "export " key "\n"))
((key . value)
(list "export " key "=" value "\n")))
vars)))))))
(define home-environment-variables-service-type
(service-type (name 'home-environment-variables)
(extensions
(list (service-extension
home-service-type
environment-variables->setup-environment-script)))
(compose concatenate)
(extend append)
(default-value '())
(description "Set the environment variables.")))
(define (files->files-directory files)
"Return a @code{files} directory that contains FILES."
(define (assert-no-duplicates files)
(let loop ((files files)
(seen (set)))
(match files
(() #t)
(((file _) rest ...)
(when (set-contains? seen file)
(raise (formatted-message (G_ "duplicate '~a' entry for files/")
file)))
(loop rest (set-insert file seen))))))
;; Detect duplicates early instead of letting them through, eventually
;; leading to a build failure of "files.drv".
(assert-no-duplicates files)
(file-union "files" files))
;; Used by symlink-manager
(define home-files-directory "files")
(define (files-entry files)
"Return an entry for the @file{~/.guix-home/files}
directory containing FILES."
(with-monad %store-monad
(return `((,home-files-directory ,(files->files-directory files))))))
(define home-files-service-type
(service-type (name 'home-files)
(extensions
(list (service-extension home-service-type
files-entry)))
(compose concatenate)
(extend append)
(default-value '())
(description "Files that will be put in
@file{~~/.guix-home/files}, and further processed during activation.")))
(define xdg-configuration-files-directory "config")
(define (xdg-configuration-files files)
"Add config/ prefix to each file-path in FILES."
(map (match-lambda
((file-path . rest)
(cons (string-append xdg-configuration-files-directory "/" file-path)
rest)))
files))
(define home-xdg-configuration-files-service-type
(service-type (name 'home-files)
(extensions
(list (service-extension home-files-service-type
xdg-configuration-files)))
(compose concatenate)
(extend append)
(default-value '())
(description "Files that will be put in
@file{~~/.guix-home/files/config}, and further processed during activation.")))
(define %initialize-gettext
#~(begin
(bindtextdomain %gettext-domain
(string-append #$guix "/share/locale"))
(textdomain %gettext-domain)))
(define (compute-on-first-login-script _ gexps)
(program-file
"on-first-login"
(with-imported-modules (source-module-closure '((guix i18n)))
#~(begin
(use-modules (guix i18n))
#$%initialize-gettext
(let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
(format #f "/run/user/~a" (getuid))))
(flag-file-path (string-append
xdg-runtime-dir "/on-first-login-executed"))
(touch (lambda (file-name)
(call-with-output-file file-name (const #t)))))
;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
;; allows to launch on-first-login script on first login only
;; after complete logout/reboot.
(if (file-exists? xdg-runtime-dir)
(unless (file-exists? flag-file-path)
(begin #$@gexps (touch flag-file-path)))
;; TRANSLATORS: 'on-first-login' is the name of a service and
;; shouldn't be translated
(display (G_ "XDG_RUNTIME_DIR doesn't exists, on-first-login script
won't execute anything. You can check if xdg runtime directory exists,
XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
script by running '$HOME/.guix-home/on-first-login'"))))))))
(define (on-first-login-script-entry on-first-login)
"Return, as a monadic value, an entry for the on-first-login script
in the home environment directory."
(with-monad %store-monad
(return `(("on-first-login" ,on-first-login)))))
(define home-run-on-first-login-service-type
(service-type (name 'home-run-on-first-login)
(extensions
(list (service-extension
home-service-type
on-first-login-script-entry)))
(compose identity)
(extend compute-on-first-login-script)
(default-value #f)
(description "Run gexps on first user login. Can be
extended with one gexp.")))
(define (compute-activation-script init-gexp gexps)
(gexp->script
"activate"
#~(let* ((he-init-file (lambda (he) (string-append he "/setup-environment")))
(he-path (string-append (getenv "HOME") "/.guix-home"))
(new-home-env (getenv "GUIX_NEW_HOME"))
(new-home (or new-home-env
;; Path of the activation file if called interactively
(dirname (car (command-line)))))
(old-home-env (getenv "GUIX_OLD_HOME"))
(old-home (or old-home-env
(if (file-exists? (he-init-file he-path))
(readlink he-path)
#f))))
(if (file-exists? (he-init-file new-home))
(let* ((port ((@ (ice-9 popen) open-input-pipe)
(format #f "source ~a && env -0"
(he-init-file new-home))))
(result ((@ (ice-9 rdelim) read-delimited) "" port))
(vars (map (lambda (x)
(let ((si (string-index x #\=)))
(cons (string-take x si)
(string-drop x (1+ si)))))
((@ (srfi srfi-1) remove)
string-null?
(string-split result #\nul)))))
(close-port port)
(map (lambda (x) (setenv (car x) (cdr x))) vars)
(setenv "GUIX_NEW_HOME" new-home)
(setenv "GUIX_OLD_HOME" old-home)
#$@gexps
;; Do not unset env variable if it was set outside.
(unless new-home-env (setenv "GUIX_NEW_HOME" #f))
(unless old-home-env (setenv "GUIX_OLD_HOME" #f)))
(format #t "\
Activation script was either called or loaded by file from this directory:
~a
It doesn't seem that home environment is somewhere around.
Make sure that you call ./activate by symlink from -home store item.\n"
new-home)))))
(define (activation-script-entry m-activation)
"Return, as a monadic value, an entry for the activation script
in the home environment directory."
(mlet %store-monad ((activation m-activation))
(return `(("activate" ,activation)))))
(define home-activation-service-type
(service-type (name 'home-activation)
(extensions
(list (service-extension
home-service-type
activation-script-entry)))
(compose identity)
(extend compute-activation-script)
(default-value #f)
(description "Run gexps to activate the current
generation of home environment and update the state of the home
directory. @command{activate} script automatically called during
reconfiguration or generation switching. This service can be extended
with one gexp, but many times, and all gexps must be idempotent.")))
;;;
;;; On-change.
;;;
(define (compute-on-change-gexp eval-gexps? pattern-gexp-tuples)
(with-imported-modules (source-module-closure '((guix i18n)))
#~(begin
(use-modules (guix i18n))
#$%initialize-gettext
(define (equal-regulars? file1 file2)
"Check if FILE1 and FILE2 are bit for bit identical."
(let* ((cmp-binary #$(file-append
(@ (gnu packages base) diffutils) "/bin/cmp"))
(stats1 (lstat file1))
(stats2 (lstat file2)))
(cond
((= (stat:ino stats1) (stat:ino stats2)) #t)
((not (= (stat:size stats1) (stat:size stats2))) #f)
(else (= (system* cmp-binary file1 file2) 0)))))
(define (equal-symlinks? symlink1 symlink2)
"Check if SYMLINK1 and SYMLINK2 are pointing to the same target."
(string=? (readlink symlink1) (readlink symlink2)))
(define (equal-directories? dir1 dir2)
"Check if DIR1 and DIR2 have the same content."
(define (ordinary-file file)
(not (or (string=? file ".")
(string=? file ".."))))
(let* ((files1 (scandir dir1 ordinary-file))
(files2 (scandir dir2 ordinary-file)))
(if (equal? files1 files2)
(map (lambda (file)
(equal-files?
(string-append dir1 "/" file)
(string-append dir2 "/" file)))
files1)
#f)))
(define (equal-files? file1 file2)
"Compares files, symlinks or directories of the same type."
(case (file-type file1)
((directory) (equal-directories? file1 file2))
((symlink) (equal-symlinks? file1 file2))
((regular) (equal-regulars? file1 file2))
(else
(display "The file type is unsupported by on-change service.\n")
#f)))
(define (file-type file)
(stat:type (lstat file)))
(define (something-changed? file1 file2)
(cond
((and (not (file-exists? file1))
(not (file-exists? file2))) #f)
((or (not (file-exists? file1))
(not (file-exists? file2))) #t)
((not (eq? (file-type file1) (file-type file2))) #t)
(else
(not (equal-files? file1 file2)))))
(define expressions-to-eval
(map
(lambda (x)
(let* ((file1 (string-append
(or (getenv "GUIX_OLD_HOME")
"/gnu/store/non-existing-generation")
"/" (car x)))
(file2 (string-append (getenv "GUIX_NEW_HOME") "/" (car x)))
(_ (format #t (G_ "Comparing ~a and\n~10t~a...") file1 file2))
(any-changes? (something-changed? file1 file2))
(_ (format #t (G_ " done (~a)\n")
(if any-changes? "changed" "same"))))
(if any-changes? (cadr x) "")))
'#$pattern-gexp-tuples))
(if #$eval-gexps?
(begin
;;; TRANSLATORS: 'on-change' is the name of a service type, it
;;; probably shouldn't be translated.
(display (G_ "Evaluating on-change gexps.\n\n"))
(for-each primitive-eval expressions-to-eval)
(display (G_ "On-change gexps evaluation finished.\n\n")))
(display "\
On-change gexps won't be evaluated; evaluation has been disabled in the
service configuration")))))
(define home-run-on-change-service-type
(service-type (name 'home-run-on-change)
(extensions
(list (service-extension
home-activation-service-type
identity)))
(compose concatenate)
(extend compute-on-change-gexp)
(default-value #t)
(description "\
G-expressions to run if the specified files have changed since the
last generation. The extension should be a list of lists where the
first element is the pattern for file or directory that expected to be
changed, and the second element is the G-expression to be evaluated.")))
;;;
;;; Provenance tracking.
;;;
(define home-provenance-service-type
(service-type
(name 'home-provenance)
(extensions
(list (service-extension
home-service-type
(service-extension-compute
(first (service-type-extensions provenance-service-type))))))
(default-value #f) ;the HE config file
(description "\
Store provenance information about the home environment in the home
environment itself: the channels used when building the home
environment, and its configuration file, when available.")))
(define sexp->home-provenance sexp->system-provenance)
(define home-provenance system-provenance)
;;;
;;; Searching
;;;
(define (parent-directory directory)
"Get the parent directory of DIRECTORY"
(string-join (drop-right (string-split directory #\/) 1) "/"))
(define %guix-home-root-directory
;; Absolute file name of the module hierarchy.
(parent-directory
(dirname (dirname (search-path %load-path "gnu/home/services.scm")))))
(define %service-type-path
;; Search path for service types.
(make-parameter `((,%guix-home-root-directory . "gnu/home/services"))))
(define (all-home-service-modules)
"Return the default set of `home service' modules."
(cons (resolve-interface '(gnu home services))
(all-modules (%service-type-path)
#:warn warn-about-load-error)))
(define* (fold-home-service-types proc seed)
(fold-service-types proc seed (all-home-service-modules)))
-174
View File
@@ -1,174 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services desktop)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (gnu services configuration)
#:autoload (gnu packages xdisorg) (redshift)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (home-redshift-configuration
home-redshift-configuration?
home-redshift-service-type))
;;;
;;; Redshift.
;;;
(define (serialize-integer field value)
(string-append (match field
('daytime-temperature "temp-day")
('nighttime-temperature "temp-night")
('daytime-brightness "brightness-day")
('nighttime-brightness "brightness-night")
('latitude "lat")
('longitude "lon")
(_ (symbol->string field)))
"=" (number->string value) "\n"))
(define (serialize-symbol field value)
(string-append (symbol->string field)
"=" (symbol->string value) "\n"))
(define (serialize-string field value)
(string-append (symbol->string field)
"=" value "\n"))
(define serialize-inexact-number serialize-integer)
(define (inexact-number? n)
(and (number? n) (inexact? n)))
(define-maybe inexact-number)
(define-maybe string)
(define (serialize-raw-configuration-string field value)
value)
(define raw-configuration-string? string?)
(define-configuration home-redshift-configuration
(redshift
(file-like redshift)
"Redshift package to use.")
(location-provider
(symbol 'geoclue2)
"Geolocation provider---@code{'manual} or @code{'geoclue2}.
In the former case, you must also specify the @code{latitude} and
@code{longitude} fields so Redshift can determine daytime at your place. In
the latter case, the Geoclue system service must be running; it will be
queried for location information.")
(adjustment-method
(symbol 'randr)
"Color adjustment method.")
;; Default values from redshift(1).
(daytime-temperature
(integer 6500)
"Daytime color temperature (kelvins).")
(nighttime-temperature
(integer 4500)
"Nighttime color temperature (kelvins).")
(daytime-brightness
(maybe-inexact-number 'disabled)
"Daytime screen brightness, between 0.1 and 1.0.")
(nighttime-brightness
(maybe-inexact-number 'disabled)
"Nighttime screen brightness, between 0.1 and 1.0.")
(latitude
(maybe-inexact-number 'disabled)
"Latitude, when @code{location-provider} is @code{'manual}.")
(longitude
(maybe-inexact-number 'disabled)
"Longitude, when @code{location-provider} is @code{'manual}.")
(dawn-time
(maybe-string 'disabled)
"Custom time for the transition from night to day in the
morning---@code{\"HH:MM\"} format. When specified, solar elevation is not
used to determine the daytime/nighttime period.")
(dusk-time
(maybe-string 'disabled)
"Likewise, custom time for the transition from day to night in the
evening.")
(extra-content
(raw-configuration-string "")
"Extra content appended as-is to the Redshift configuration file. Run
@command{man redshift} for more information about the configuration file
format."))
(define (serialize-redshift-configuration config)
(define location-fields
'(latitude longitude))
(define (location-field? field)
(memq (configuration-field-name field) location-fields))
(define (secondary-field? field)
(or (location-field? field)
(memq (configuration-field-name field)
'(redshift extra-content))))
#~(string-append
"[redshift]\n"
#$(serialize-configuration config
(remove secondary-field?
home-redshift-configuration-fields))
#$(home-redshift-configuration-extra-content config)
"\n[manual]\n"
#$(serialize-configuration config
(filter location-field?
home-redshift-configuration-fields))))
(define (redshift-shepherd-service config)
(define config-file
(computed-file "redshift.conf"
#~(call-with-output-file #$output
(lambda (port)
(display #$(serialize-redshift-configuration config)
port)))))
(list (shepherd-service
(documentation "Redshift program.")
(provision '(redshift))
;; FIXME: This fails to start if Home is first activated from a
;; non-X11 session.
(start #~(make-forkexec-constructor
(list #$(file-append redshift "/bin/redshift")
"-c" #$config-file)))
(stop #~(make-kill-destructor)))))
(define home-redshift-service-type
(service-type
(name 'home-redshift)
(extensions (list (service-extension home-shepherd-service-type
redshift-shepherd-service)))
(default-value (home-redshift-configuration))
(description
"Run Redshift, a program that adjusts the color temperature of display
according to time of day.")))
-65
View File
@@ -1,65 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services fontutils)
#:use-module (gnu home services)
#:use-module (gnu packages fontutils)
#:use-module (guix gexp)
#:export (home-fontconfig-service-type))
;;; Commentary:
;;;
;;; Services related to fonts. home-fontconfig service provides
;;; fontconfig configuration, which allows fc-* utilities to find
;;; fonts in Guix Home's profile and regenerates font cache on
;;; activation.
;;;
;;; Code:
(define (add-fontconfig-config-file he-symlink-path)
`(("fontconfig/fonts.conf"
,(mixed-text-file
"fonts.conf"
"<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.guix-home/profile/share/fonts</dir>
</fontconfig>"))))
(define (regenerate-font-cache-gexp _)
`(("profile/share/fonts"
,#~(system* #$(file-append fontconfig "/bin/fc-cache") "-fv"))))
(define home-fontconfig-service-type
(service-type (name 'home-fontconfig)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
add-fontconfig-config-file)
(service-extension
home-run-on-change-service-type
regenerate-font-cache-gexp)
(service-extension
home-profile-service-type
(const (list fontconfig)))))
(default-value #f)
(description
"Provides configuration file for fontconfig and make
fc-* utilities aware of font packages installed in Guix Home's profile.")))
-115
View File
@@ -1,115 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services mcron)
#:use-module (gnu packages guile-xyz)
#:use-module (gnu home services)
#:use-module (gnu services shepherd)
#:use-module (gnu home services shepherd)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (home-mcron-configuration
home-mcron-service-type))
;;; Commentary:
;;
;; Service for the GNU mcron cron job manager.
;;
;; Example configuration, the first job runs mbsync once every ten
;; minutes, the second one writes "Mcron service" to ~/mcron-file once
;; every minute.
;;
;; (service home-mcron-service-type
;; (home-mcron-configuration
;; (jobs (list #~(job '(next-minute
;; (range 0 60 10))
;; (lambda ()
;; (system* "mbsync" "--all")))
;; #~(job next-minute-from
;; (lambda ()
;; (call-with-output-file (string-append (getenv "HOME")
;; "/mcron-file")
;; (lambda (port)
;; (display "Mcron service" port)))))))))
;;
;;; Code:
(define-record-type* <home-mcron-configuration> home-mcron-configuration
make-home-mcron-configuration
home-mcron-configuration?
(package home-mcron-configuration-package ; package
(default mcron))
(jobs home-mcron-configuration-jobs ; list of jobs
(default '())))
(define job-files (@@ (gnu services mcron) job-files))
(define shepherd-schedule-action
(@@ (gnu services mcron) shepherd-schedule-action))
(define home-mcron-shepherd-services
(match-lambda
(($ <home-mcron-configuration> mcron '()) ; no jobs to run
'())
(($ <home-mcron-configuration> mcron jobs)
(let ((files (job-files mcron jobs)))
(list (shepherd-service
(documentation "User cron jobs.")
(provision '(mcron))
(modules `((srfi srfi-1)
(srfi srfi-26)
(ice-9 popen) ; for the 'schedule' action
(ice-9 rdelim)
(ice-9 match)
,@%default-modules))
(start #~(make-forkexec-constructor
(list #$(file-append mcron "/bin/mcron") #$@files)
#:log-file (string-append
(or (getenv "XDG_LOG_HOME")
(format #f "~a/.local/var/log"
(getenv "HOME")))
"/mcron.log")))
(stop #~(make-kill-destructor))
(actions
(list (shepherd-schedule-action mcron files)))))))))
(define home-mcron-profile (compose list home-mcron-configuration-package))
(define (home-mcron-extend config jobs)
(home-mcron-configuration
(inherit config)
(jobs (append (home-mcron-configuration-jobs config)
jobs))))
(define home-mcron-service-type
(service-type (name 'home-mcron)
(extensions
(list (service-extension
home-shepherd-service-type
home-mcron-shepherd-services)
(service-extension
home-profile-service-type
home-mcron-profile)))
(compose concatenate)
(extend home-mcron-extend)
(default-value (home-mcron-configuration))
(description
"Install and configure the GNU mcron cron job manager.")))
-699
View File
@@ -1,699 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services shells)
#:use-module (gnu services configuration)
#:use-module (gnu home services utils)
#:use-module (gnu home services)
#:use-module (gnu packages shells)
#:use-module (gnu packages bash)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:export (home-shell-profile-service-type
home-shell-profile-configuration
home-bash-service-type
home-bash-configuration
home-bash-extension
home-zsh-service-type
home-zsh-configuration
home-zsh-extension
home-fish-service-type
home-fish-configuration
home-fish-extension))
;;; Commentary:
;;;
;;; This module contains shell related services like Zsh.
;;;
;;; Code:
;;;
;;; Shell profile.
;;;
(define path? string?)
(define (serialize-path field-name val) val)
(define-configuration home-shell-profile-configuration
(profile
(text-config '())
"\
@code{home-shell-profile} is instantiated automatically by
@code{home-environment}, DO NOT create this service manually, it can
only be extended.
@code{profile} is a list of file-like objects, which will go to
@file{~/.profile}. By default @file{~/.profile} contains the
initialization code, which have to be evaluated by login shell to make
home-environment's profile available to the user, but other commands
can be added to the file if it is really necessary.
In most cases shell's configuration files are preferred places for
user's customizations. Extend home-shell-profile service only if you
really know what you do."))
(define (add-shell-profile-file config)
`(("profile"
,(mixed-text-file
"shell-profile"
"\
HOME_ENVIRONMENT=$HOME/.guix-home
. $HOME_ENVIRONMENT/setup-environment
$HOME_ENVIRONMENT/on-first-login\n"
(serialize-configuration
config
(filter-configuration-fields
home-shell-profile-configuration-fields '(profile)))))))
(define (add-profile-extensions config extensions)
(home-shell-profile-configuration
(inherit config)
(profile
(append (home-shell-profile-configuration-profile config)
extensions))))
(define home-shell-profile-service-type
(service-type (name 'home-shell-profile)
(extensions
(list (service-extension
home-files-service-type
add-shell-profile-file)))
(compose concatenate)
(extend add-profile-extensions)
(default-value (home-shell-profile-configuration))
(description "Create @file{~/.profile}, which is used
for environment initialization of POSIX compliant login shells. This
service type can be extended with a list of file-like objects.")))
(define (serialize-boolean field-name val) "")
(define (serialize-posix-env-vars field-name val)
#~(string-append
#$@(map
(match-lambda
((key . #f)
"")
((key . #t)
#~(string-append "export " #$key "\n"))
((key . value)
#~(string-append "export " #$key "=" #$value "\n")))
val)))
;;;
;;; Zsh.
;;;
(define-configuration home-zsh-configuration
(package
(package zsh)
"The Zsh package to use.")
(xdg-flavor?
(boolean #t)
"Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes
@file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}.
Shell startup process will continue with
@file{$XDG_CONFIG_HOME/zsh/.zshenv}.")
(environment-variables
(alist '())
"Association list of environment variables to set for the Zsh session."
serialize-posix-env-vars)
(zshenv
(text-config '())
"List of file-like objects, which will be added to @file{.zshenv}.
Used for setting user's shell environment variables. Must not contain
commands assuming the presence of tty or producing output. Will be
read always. Will be read before any other file in @env{ZDOTDIR}.")
(zprofile
(text-config '())
"List of file-like objects, which will be added to @file{.zprofile}.
Used for executing user's commands at start of login shell (In most
cases the shell started on tty just after login). Will be read before
@file{.zlogin}.")
(zshrc
(text-config '())
"List of file-like objects, which will be added to @file{.zshrc}.
Used for executing user's commands at start of interactive shell (The
shell for interactive usage started by typing @code{zsh} or by
terminal app or any other program).")
(zlogin
(text-config '())
"List of file-like objects, which will be added to @file{.zlogin}.
Used for executing user's commands at the end of starting process of
login shell.")
(zlogout
(text-config '())
"List of file-like objects, which will be added to @file{.zlogout}.
Used for executing user's commands at the exit of login shell. It
won't be read in some cases (if the shell terminates by exec'ing
another process for example)."))
(define (zsh-filter-fields field)
(filter-configuration-fields home-zsh-configuration-fields (list field)))
(define (zsh-serialize-field config field)
(serialize-configuration config (zsh-filter-fields field)))
(define* (zsh-field-not-empty? config field)
(let ((file-name (symbol->string field))
(field-obj (car (zsh-filter-fields field))))
(not (null? ((configuration-field-getter field-obj) config)))))
(define (zsh-file-zshenv config)
(mixed-text-file
"zshenv"
(zsh-serialize-field config 'zshenv)
(zsh-serialize-field config 'environment-variables)))
(define (zsh-file-zprofile config)
(mixed-text-file
"zprofile"
"\
# Setups system and user profiles and related variables
source /etc/profile
# Setups home environment profile
source ~/.profile
# It's only necessary if zsh is a login shell, otherwise profiles will
# be already sourced by bash
"
(zsh-serialize-field config 'zprofile)))
(define (zsh-file-by-field config field)
(match field
('zshenv (zsh-file-zshenv config))
('zprofile (zsh-file-zprofile config))
(e (mixed-text-file
(symbol->string field)
(zsh-serialize-field config field)))))
(define (zsh-get-configuration-files config)
`(("zprofile" ,(zsh-file-by-field config 'zprofile)) ;; Always non-empty
,@(if (and (zsh-field-not-empty? config 'zshenv)
(zsh-field-not-empty? config 'environment-variables))
`(("zshenv" ,(zsh-file-by-field config 'zshenv))) '())
,@(if (zsh-field-not-empty? config 'zshrc)
`(("zshrc" ,(zsh-file-by-field config 'zshrc))) '())
,@(if (zsh-field-not-empty? config 'zlogin)
`(("zlogin" ,(zsh-file-by-field config 'zlogin))) '())
,@(if (zsh-field-not-empty? config 'zlogout)
`(("zlogout" ,(zsh-file-by-field config 'zlogout))) '())))
(define (zsh-home-files config)
(define zshenv-auxiliary-file
(mixed-text-file
"zshenv-auxiliary"
"export ZDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n"
"[[ -f $ZDOTDIR/.zshenv ]] && source $ZDOTDIR/.zshenv\n"))
(if (home-zsh-configuration-xdg-flavor? config)
`(("zshenv" ,zshenv-auxiliary-file))
(zsh-get-configuration-files config)))
(define (zsh-xdg-configuration-files config)
(if (home-zsh-configuration-xdg-flavor? config)
(map
(lambda (lst)
(cons (string-append "zsh/." (car lst))
(cdr lst)))
(zsh-get-configuration-files config))
'()))
(define (add-zsh-packages config)
(list (home-zsh-configuration-package config)))
(define-configuration/no-serialization home-zsh-extension
(environment-variables
(alist '())
"Association list of environment variables to set.")
(zshrc
(text-config '())
"List of file-like objects.")
(zshenv
(text-config '())
"List of file-like objects.")
(zprofile
(text-config '())
"List of file-like objects.")
(zlogin
(text-config '())
"List of file-like objects.")
(zlogout
(text-config '())
"List of file-like objects."))
(define (home-zsh-extensions original-config extension-configs)
(home-zsh-configuration
(inherit original-config)
(environment-variables
(append (home-zsh-configuration-environment-variables original-config)
(append-map
home-zsh-extension-environment-variables extension-configs)))
(zshrc
(append (home-zsh-configuration-zshrc original-config)
(append-map
home-zsh-extension-zshrc extension-configs)))
(zshenv
(append (home-zsh-configuration-zshenv original-config)
(append-map
home-zsh-extension-zshenv extension-configs)))
(zprofile
(append (home-zsh-configuration-zprofile original-config)
(append-map
home-zsh-extension-zprofile extension-configs)))
(zlogin
(append (home-zsh-configuration-zlogin original-config)
(append-map
home-zsh-extension-zlogin extension-configs)))
(zlogout
(append (home-zsh-configuration-zlogout original-config)
(append-map
home-zsh-extension-zlogout extension-configs)))))
(define home-zsh-service-type
(service-type (name 'home-zsh)
(extensions
(list (service-extension
home-files-service-type
zsh-home-files)
(service-extension
home-xdg-configuration-files-service-type
zsh-xdg-configuration-files)
(service-extension
home-profile-service-type
add-zsh-packages)))
(compose identity)
(extend home-zsh-extensions)
(default-value (home-zsh-configuration))
(description "Install and configure Zsh.")))
;;;
;;; Bash.
;;;
(define (bash-serialize-aliases field-name val)
#~(string-append
#$@(map
(match-lambda
((key . #f)
"")
((key . #t)
#~(string-append "alias " #$key "\n"))
((key . value)
#~(string-append "alias " #$key "=\"" #$value "\"\n")))
val)))
(define-configuration home-bash-configuration
(package
(package bash)
"The Bash package to use.")
(guix-defaults?
(boolean #t)
"Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
@command{ls} to the top of the @file{.bashrc} file.")
(environment-variables
(alist '())
"Association list of environment variables to set for the Bash session. The
rules for the @code{home-environment-variables-service-type} apply
here (@pxref{Essential Home Services}). The contents of this field will be
added after the contents of the @code{bash-profile} field."
serialize-posix-env-vars)
(aliases
(alist '())
"Association list of aliases to set for the Bash session. The aliases will be
defined after the contents of the @code{bashrc} field has been put in the
@file{.bashrc} file. The alias will automatically be quoted, so something line
this:
@lisp
'((\"ls\" . \"ls -alF\"))
@end lisp
turns into
@example
alias ls=\"ls -alF\"
@end example"
bash-serialize-aliases)
(bash-profile
(text-config '())
"List of file-like objects, which will be added to @file{.bash_profile}.
Used for executing user's commands at start of login shell (In most
cases the shell started on tty just after login). @file{.bash_login}
won't be ever read, because @file{.bash_profile} always present.")
(bashrc
(text-config '())
"List of file-like objects, which will be added to @file{.bashrc}.
Used for executing user's commands at start of interactive shell (The
shell for interactive usage started by typing @code{bash} or by
terminal app or any other program).")
(bash-logout
(text-config '())
"List of file-like objects, which will be added to @file{.bash_logout}.
Used for executing user's commands at the exit of login shell. It
won't be read in some cases (if the shell terminates by exec'ing
another process for example)."))
;; TODO: Use value from (gnu system shadow)
(define guix-bashrc
"\
# Bash initialization for interactive non-login shells and
# for remote shells (info \"(bash) Bash Startup Files\").
# Export 'SHELL' to child processes. Programs such as 'screen'
# honor it and otherwise use /bin/sh.
export SHELL
if [[ $- != *i* ]]
then
# We are being invoked from a non-interactive shell. If this
# is an SSH session (as in \"ssh host command\"), source
# /etc/profile so we get PATH and other essential variables.
[[ -n \"$SSH_CLIENT\" ]] && source /etc/profile
# Don't do anything else.
return
fi
# Source the system-wide file.
if [[ -e /etc/bashrc ]]; then
source /etc/bashrc
fi
# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n \"$GUIX_ENVIRONMENT\" ]
then
PS1='\\u@\\h \\w [env]\\$ '
else
PS1='\\u@\\h \\w\\$ '
fi
alias ls='ls -p --color=auto'
alias ll='ls -l'
alias grep='grep --color=auto'\n")
(define (add-bash-configuration config)
(define (filter-fields field)
(filter-configuration-fields home-bash-configuration-fields
(list field)))
(define (serialize-field field)
(serialize-configuration
config
(filter-fields field)))
(define* (file-if-not-empty field #:optional (extra-content #f))
(let ((file-name (symbol->string field))
(field-obj (car (filter-fields field))))
(if (or extra-content
(not (null? ((configuration-field-getter field-obj) config))))
`(,(object->snake-case-string file-name)
,(apply mixed-text-file
(object->snake-case-string file-name)
(append (or extra-content '())
(list (serialize-field field)))))
'())))
(filter
(compose not null?)
`(("bash_profile"
,(mixed-text-file
"bash_profile"
"\
# Setups system and user profiles and related variables
# /etc/profile will be sourced by bash automatically
# Setups home environment profile
if [ -f ~/.profile ]; then source ~/.profile; fi
# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
"
(serialize-field 'bash-profile)
(serialize-field 'environment-variables)))
,@(list (file-if-not-empty
'bashrc
(if (home-bash-configuration-guix-defaults? config)
(list (serialize-field 'aliases) guix-bashrc)
(list (serialize-field 'aliases))))
(file-if-not-empty 'bash-logout)))))
(define (add-bash-packages config)
(list (home-bash-configuration-package config)))
(define-configuration/no-serialization home-bash-extension
(environment-variables
(alist '())
"Additional environment variables to set. These will be combined with the
environment variables from other extensions and the base service to form one
coherent block of environment variables.")
(aliases
(alist '())
"Additional aliases to set. These will be combined with the aliases from
other extensions and the base service.")
(bash-profile
(text-config '())
"Additional text blocks to add to @file{.bash_profile}, which will be combined
with text blocks from other extensions and the base service.")
(bashrc
(text-config '())
"Additional text blocks to add to @file{.bashrc}, which will be combined
with text blocks from other extensions and the base service.")
(bash-logout
(text-config '())
"Additional text blocks to add to @file{.bash_logout}, which will be combined
with text blocks from other extensions and the base service."))
(define (home-bash-extensions original-config extension-configs)
(match original-config
(($ <home-bash-configuration> _ _ _ environment-variables aliases
bash-profile bashrc bash-logout)
(home-bash-configuration
(inherit original-config)
(environment-variables
(append environment-variables
(append-map
home-bash-extension-environment-variables extension-configs)))
(aliases
(append aliases
(append-map
home-bash-extension-aliases extension-configs)))
(bash-profile
(append bash-profile
(append-map
home-bash-extension-bash-profile extension-configs)))
(bashrc
(append bashrc
(append-map
home-bash-extension-bashrc extension-configs)))
(bash-logout
(append bash-logout
(append-map
home-bash-extension-bash-logout extension-configs)))))))
(define home-bash-service-type
(service-type (name 'home-bash)
(extensions
(list (service-extension
home-files-service-type
add-bash-configuration)
(service-extension
home-profile-service-type
add-bash-packages)))
(compose identity)
(extend home-bash-extensions)
(default-value (home-bash-configuration))
(description "Install and configure GNU Bash.")))
;;;
;;; Fish.
;;;
(define (serialize-fish-aliases field-name val)
#~(string-append
#$@(map (match-lambda
((key . value)
#~(string-append "alias " #$key " \"" #$value "\"\n"))
(_ ""))
val)))
(define (serialize-fish-abbreviations field-name val)
#~(string-append
#$@(map (match-lambda
((key . value)
#~(string-append "abbr --add " #$key " " #$value "\n"))
(_ ""))
val)))
(define (serialize-fish-env-vars field-name val)
#~(string-append
#$@(map (match-lambda
((key . #f)
"")
((key . #t)
#~(string-append "set " #$key "\n"))
((key . value)
#~(string-append "set " #$key " " #$value "\n")))
val)))
(define-configuration home-fish-configuration
(package
(package fish)
"The Fish package to use.")
(config
(text-config '())
"List of file-like objects, which will be added to
@file{$XDG_CONFIG_HOME/fish/config.fish}.")
(environment-variables
(alist '())
"Association list of environment variables to set in Fish."
serialize-fish-env-vars)
(aliases
(alist '())
"Association list of aliases for Fish, both the key and the value
should be a string. An alias is just a simple function that wraps a
command, If you want something more akin to @dfn{aliases} in POSIX
shells, see the @code{abbreviations} field."
serialize-fish-aliases)
(abbreviations
(alist '())
"Association list of abbreviations for Fish. These are words that,
when typed in the shell, will automatically expand to the full text."
serialize-fish-abbreviations))
(define (fish-files-service config)
`(("config/fish/config.fish"
,(mixed-text-file
"fish-config.fish"
#~(string-append "\
# if we haven't sourced the login config, do it
status --is-login; and not set -q __fish_login_config_sourced
and begin
set --prepend fish_function_path "
#$fish-foreign-env
"/share/fish/functions
fenv source $HOME/.profile
set -e fish_function_path[1]
set -g __fish_login_config_sourced 1
end\n\n")
(serialize-configuration
config
home-fish-configuration-fields)))))
(define (fish-profile-service config)
(list (home-fish-configuration-package config)))
(define-configuration/no-serialization home-fish-extension
(config
(text-config '())
"List of file-like objects for extending the Fish initialization file.")
(environment-variables
(alist '())
"Association list of environment variables to set.")
(aliases
(alist '())
"Association list of Fish aliases.")
(abbreviations
(alist '())
"Association list of Fish abbreviations."))
(define (home-fish-extensions original-config extension-configs)
(home-fish-configuration
(inherit original-config)
(config
(append (home-fish-configuration-config original-config)
(append-map
home-fish-extension-config extension-configs)))
(environment-variables
(append (home-fish-configuration-environment-variables original-config)
(append-map
home-fish-extension-environment-variables extension-configs)))
(aliases
(append (home-fish-configuration-aliases original-config)
(append-map
home-fish-extension-aliases extension-configs)))
(abbreviations
(append (home-fish-configuration-abbreviations original-config)
(append-map
home-fish-extension-abbreviations extension-configs)))))
;; TODO: Support for generating completion files
;; TODO: Support for installing plugins
(define home-fish-service-type
(service-type (name 'home-fish)
(extensions
(list (service-extension
home-files-service-type
fish-files-service)
(service-extension
home-profile-service-type
fish-profile-service)))
(compose identity)
(extend home-fish-extensions)
(default-value (home-fish-configuration))
(description "\
Install and configure Fish, the friendly interactive shell.")))
(define (generate-home-shell-profile-documentation)
(generate-documentation
`((home-shell-profile-configuration
,home-shell-profile-configuration-fields))
'home-shell-profile-configuration))
(define (generate-home-bash-documentation)
(string-append
(generate-documentation
`((home-bash-configuration
,home-bash-configuration-fields))
'home-bash-configuration)
"\n\n"
(generate-documentation
`((home-bash-extension
,home-bash-extension-fields))
'home-bash-extension)))
(define (generate-home-zsh-documentation)
(generate-documentation
`((home-zsh-configuration
,home-zsh-configuration-fields))
'home-zsh-configuration))
(define (generate-home-fish-documentation)
(string-append
(generate-documentation
`((home-fish-configuration
,home-fish-configuration-fields))
'home-fish-configuration)
"\n\n"
(generate-documentation
`((home-fish-extension
,home-fish-extension-fields))
'home-fish-extension)))
-149
View File
@@ -1,149 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services shepherd)
#:use-module (gnu home services)
#:use-module (gnu packages admin)
#:use-module (gnu services shepherd)
#:use-module (guix sets)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:export (home-shepherd-service-type
home-shepherd-configuration
home-shepherd-configuration?
home-shepherd-configuration-shepherd
home-shepherd-configuration-auto-start?
home-shepherd-configuration-services)
#:re-export (shepherd-service
shepherd-service?
shepherd-service-documentation
shepherd-service-provision
shepherd-service-canonical-name
shepherd-service-requirement
shepherd-service-one-shot?
shepherd-service-respawn?
shepherd-service-start
shepherd-service-stop
shepherd-service-auto-start?
shepherd-service-modules
shepherd-action))
(define-record-type* <home-shepherd-configuration>
home-shepherd-configuration make-home-shepherd-configuration
home-shepherd-configuration?
(shepherd home-shepherd-configuration-shepherd
(default shepherd)) ; package
(auto-start? home-shepherd-configuration-auto-start?
(default #t))
(services home-shepherd-configuration-services
(default '())))
(define (home-shepherd-configuration-file services shepherd)
"Return the shepherd configuration file for SERVICES. SHEPHERD is used
as shepherd package."
(assert-valid-graph services)
(let ((files (map shepherd-service-file services))
;; TODO: Add compilation of services, it can improve start
;; time.
;; (scm->go (cute scm->go <> shepherd))
)
(define config
#~(begin
(use-modules (srfi srfi-34)
(system repl error-handling))
(apply
register-services
(map
(lambda (file) (load file))
'#$files))
(action 'root 'daemonize)
(format #t "Starting services...~%")
(for-each
(lambda (service) (start service))
'#$(append-map shepherd-service-provision
(filter shepherd-service-auto-start?
services)))
(newline)))
(scheme-file "shepherd.conf" config)))
(define (launch-shepherd-gexp config)
(let* ((shepherd (home-shepherd-configuration-shepherd config))
(services (home-shepherd-configuration-services config)))
(if (home-shepherd-configuration-auto-start? config)
(with-imported-modules '((guix build utils))
#~(let ((log-dir (or (getenv "XDG_LOG_HOME")
(format #f "~a/.local/var/log" (getenv "HOME")))))
((@ (guix build utils) mkdir-p) log-dir)
(system*
#$(file-append shepherd "/bin/shepherd")
"--logfile"
(string-append
log-dir
"/shepherd.log")
"--config"
#$(home-shepherd-configuration-file services shepherd))))
#~"")))
(define (reload-configuration-gexp config)
(let* ((shepherd (home-shepherd-configuration-shepherd config))
(services (home-shepherd-configuration-services config)))
#~(system*
#$(file-append shepherd "/bin/herd")
"load" "root"
#$(home-shepherd-configuration-file services shepherd))))
(define (ensure-shepherd-gexp config)
#~(if (file-exists?
(string-append
(or (getenv "XDG_RUNTIME_DIR")
(format #f "/run/user/~a" (getuid)))
"/shepherd/socket"))
#$(reload-configuration-gexp config)
#$(launch-shepherd-gexp config)))
(define-public home-shepherd-service-type
(service-type (name 'home-shepherd)
(extensions
(list (service-extension
home-run-on-first-login-service-type
launch-shepherd-gexp)
(service-extension
home-activation-service-type
ensure-shepherd-gexp)
(service-extension
home-profile-service-type
(lambda (config)
`(,(home-shepherd-configuration-shepherd config))))))
(compose concatenate)
(extend
(lambda (config extra-services)
(home-shepherd-configuration
(inherit config)
(services
(append (home-shepherd-configuration-services config)
extra-services)))))
(default-value (home-shepherd-configuration))
(description "Configure and install userland Shepherd.")))
-232
View File
@@ -1,232 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2022 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services symlink-manager)
#:use-module (gnu home services)
#:use-module (guix gexp)
#:use-module (guix modules)
#:export (home-symlink-manager-service-type))
;;; Comment:
;;;
;;; symlink-manager cares about xdg configurations and other files: it backs
;;; up files created by user, removes symlinks and directories created by a
;;; previous generation, and creates new directories and symlinks to files
;;; according to the content of directories (created by home-files-service) of
;;; the current home environment generation.
;;;
;;; Code:
(define (update-symlinks-script)
(program-file
"update-symlinks"
(with-imported-modules (source-module-closure
'((guix build utils)
(guix i18n)))
#~(begin
(use-modules (ice-9 ftw)
(ice-9 match)
(srfi srfi-1)
(guix i18n)
(guix build utils))
(define home-directory
(getenv "HOME"))
(define xdg-config-home
(or (getenv "XDG_CONFIG_HOME")
(string-append (getenv "HOME") "/.config")))
(define backup-directory
(string-append home-directory "/" (number->string (current-time))
"-guix-home-legacy-configs-backup"))
(define (preprocess-file file)
"If file is in XDG-CONFIGURATION-FILES-DIRECTORY use
subdirectory from XDG_CONFIG_HOME to generate a target path."
(if (string-prefix? #$xdg-configuration-files-directory file)
(string-append
(substring xdg-config-home
(1+ (string-length home-directory)))
(substring file
(string-length #$xdg-configuration-files-directory)))
(string-append "." file)))
(define (target-file file)
;; Return the target of FILE, a config file name sans leading dot
;; such as "config/fontconfig/fonts.conf" or "bashrc".
(string-append home-directory "/" (preprocess-file file)))
(define (symlink-to-store? file)
(catch 'system-error
(lambda ()
(store-file-name? (readlink file)))
(lambda args
(if (= EINVAL (system-error-errno args))
#f
(apply throw args)))))
(define (backup-file file)
(define backup
(string-append backup-directory "/" (preprocess-file file)))
(mkdir-p backup-directory)
(format #t (G_ "Backing up ~a...") (target-file file))
(mkdir-p (dirname backup))
(rename-file (target-file file) backup)
(display (G_ " done\n")))
(define (cleanup-symlinks home-generation)
;; Delete from $HOME files that originate in HOME-GENERATION, the
;; store item containing a home generation.
(define config-file-directory
;; Note: Trailing slash is needed because "files" is a symlink.
(string-append home-generation "/" #$home-files-directory "/"))
(define (strip file)
(string-drop file
(+ 1 (string-length config-file-directory))))
(format #t (G_ "Cleaning up symlinks from previous home at ~a.~%")
home-generation)
(newline)
(file-system-fold
(const #t)
(lambda (file stat _) ;leaf
(let ((file (target-file (strip file))))
(when (file-exists? file)
;; DO NOT remove the file if it is no longer a symlink to
;; the store, it will be backed up later during
;; create-symlinks phase.
(if (symlink-to-store? file)
(begin
(format #t (G_ "Removing ~a...") file)
(delete-file file)
(display (G_ " done\n")))
(format
#t
(G_ "Skipping ~a (not a symlink to store)... done\n")
file)))))
(const #t) ;down
(lambda (directory stat _) ;up
(unless (string=? directory config-file-directory)
(let ((directory (target-file (strip directory))))
(catch 'system-error
(lambda ()
(rmdir directory)
(format #t (G_ "Removed ~a.\n") directory))
(lambda args
(let ((errno (system-error-errno args)))
(cond
((= ENOTEMPTY errno)
(format
#t
(G_ "Skipping ~a (not an empty directory)... done\n")
directory))
((= ENOTDIR errno) #t)
(else
(apply throw args)))))))))
(const #t) ;skip
(const #t) ;error
#t ;init
config-file-directory
lstat)
(display (G_ "Cleanup finished.\n\n")))
(define (create-symlinks home-generation)
;; Create in $HOME symlinks for the files in HOME-GENERATION.
(define config-file-directory
;; Note: Trailing slash is needed because "files" is a symlink.
(string-append home-generation "/" #$home-files-directory "/"))
(define (strip file)
(string-drop file
(+ 1 (string-length config-file-directory))))
(define (source-file file)
(readlink (string-append config-file-directory file)))
(file-system-fold
(const #t) ;enter?
(lambda (file stat result) ;leaf
(let ((source (source-file (strip file)))
(target (target-file (strip file))))
(when (file-exists? target)
(backup-file (strip file)))
(format #t (G_ "Symlinking ~a -> ~a...")
target source)
(symlink source target)
(display (G_ " done\n"))))
(lambda (directory stat result) ;down
(unless (string=? directory config-file-directory)
(let ((target (target-file (strip directory))))
(when (and (file-exists? target)
(not (file-is-directory? target)))
(backup-file (strip directory)))
(catch 'system-error
(lambda ()
(mkdir target))
(lambda args
(let ((errno (system-error-errno args)))
(unless (= EEXIST errno)
(format #t (G_ "failed to create directory ~a: ~s~%")
target (strerror errno))
(apply throw args))))))))
(const #t) ;up
(const #t) ;skip
(const #t) ;error
#t ;init
config-file-directory))
#$%initialize-gettext
(let* ((home (string-append home-directory "/.guix-home"))
(pivot (string-append home ".new"))
(new-home (getenv "GUIX_NEW_HOME"))
(old-home (getenv "GUIX_OLD_HOME")))
(when old-home
(cleanup-symlinks old-home))
(create-symlinks new-home)
(symlink new-home pivot)
(rename-file pivot home)
(display (G_" done\nFinished updating symlinks.\n\n")))))))
(define (update-symlinks-gexp _)
#~(primitive-load #$(update-symlinks-script)))
(define home-symlink-manager-service-type
(service-type (name 'home-symlink-manager)
(extensions
(list
(service-extension
home-activation-service-type
update-symlinks-gexp)))
(default-value #f)
(description "Provide an @code{update-symlinks}
script, which creates symlinks to configuration files and directories
on every activation. If an existing file would be overwritten by a
symlink, backs up that file first.")))
-105
View File
@@ -1,105 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services utils)
#:use-module (ice-9 string-fun)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (maybe-object->string
object->snake-case-string
object->camel-case-string
list->human-readable-list))
(define (maybe-object->string object)
"Like @code{object->string} but don't do anything if OBJECT already is
a string."
(if (string? object)
object
(object->string object)))
;; Snake case: <https://en.wikipedia.org/wiki/Snake_case>
(define* (object->snake-case-string object #:optional (style 'lower))
"Convert the object OBJECT to the equivalent string in ``snake
case''. STYLE can be three `@code{lower}', `@code{upper}', or
`@code{capitalize}', defaults to `@code{lower}'.
@example
(object->snake-case-string 'variable-name 'upper)
@result{} \"VARIABLE_NAME\" @end example"
(if (not (member style '(lower upper capitalize)))
(error 'invalid-style (format #f "~a is not a valid style" style))
(let ((stringified (maybe-object->string object)))
(string-replace-substring
(cond
((equal? style 'lower) stringified)
((equal? style 'upper) (string-upcase stringified))
(else (string-capitalize stringified)))
"-" "_"))))
(define* (object->camel-case-string object #:optional (style 'lower))
"Convert the object OBJECT to the equivalent string in ``camel case''.
STYLE can be three `@code{lower}', `@code{upper}', defaults to
`@code{lower}'.
@example
(object->camel-case-string 'variable-name 'upper)
@result{} \"VariableName\"
@end example"
(if (not (member style '(lower upper)))
(error 'invalid-style (format #f "~a is not a valid style" style))
(let ((stringified (maybe-object->string object)))
(cond
((eq? style 'upper)
(string-concatenate
(map string-capitalize
(string-split stringified (cut eqv? <> #\-)))))
((eq? style 'lower)
(let ((splitted-string (string-split stringified (cut eqv? <> #\-))))
(string-concatenate
(cons (first splitted-string)
(map string-capitalize
(cdr splitted-string))))))))))
(define* (list->human-readable-list lst
#:key
(cumulative? #f)
(proc identity))
"Turn a list LST into a sequence of terms readable by humans.
If CUMULATIVE? is @code{#t}, use ``and'', otherwise use ``or'' before
the last term.
PROC is a procedure to apply to each of the elements of a list before
turning them into a single human readable string.
@example
(list->human-readable-list '(1 4 9) #:cumulative? #t #:proc sqrt)
@result{} \"1, 2, and 3\"
@end example
yields:"
(let* ((word (if cumulative? "and " "or "))
(init (append (drop-right lst 1))))
(format #f "~a" (string-append
(string-join
(map (compose maybe-object->string proc) init)
", " 'suffix)
word
(maybe-object->string (proc (last lst)))))))
-480
View File
@@ -1,480 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu home services xdg)
#:use-module (gnu services configuration)
#:use-module (gnu home services)
#:use-module (gnu packages freedesktop)
#:use-module (gnu home services utils)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (guix i18n)
#:use-module (guix diagnostics)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (rnrs enums)
#:export (home-xdg-base-directories-service-type
home-xdg-base-directories-configuration
home-xdg-base-directories-configuration?
home-xdg-user-directories-service-type
home-xdg-user-directories-configuration
home-xdg-user-directories-configuration?
xdg-desktop-action
xdg-desktop-entry
home-xdg-mime-applications-service-type
home-xdg-mime-applications-configuration))
;;; Commentary:
;;
;; This module contains services related to XDG directories and
;; applications.
;;
;; - XDG base directories
;; - XDG user directories
;; - XDG MIME applications
;;
;;; Code:
;;;
;;; XDG base directories.
;;;
(define (serialize-path field-name val) "")
(define path? string?)
(define-configuration home-xdg-base-directories-configuration
(cache-home
(path "$HOME/.cache")
"Base directory for programs to store user-specific non-essential
(cached) data. Files in this directory can be deleted anytime without
loss of important data.")
(config-home
(path "$HOME/.config")
"Base directory for programs to store configuration files.
Some programs store here log or state files, but it's not desired,
this directory should contain static configurations.")
(data-home
(path "$HOME/.local/share")
"Base directory for programs to store architecture independent
read-only shared data, analogus to @file{/usr/share}, but for user.")
(runtime-dir
(path "${XDG_RUNTIME_DIR:-/run/user/$UID}")
"Base directory for programs to store user-specific runtime files,
like sockets.")
(log-home
(path "$HOME/.local/var/log")
"Base directory for programs to store log files, analogus to
@file{/var/log}, but for user. It is not a part of XDG Base Directory
Specification, but helps to make implementation of home services more
consistent.")
(state-home
(path "$HOME/.local/var/lib")
"Base directory for programs to store state files, like databases,
analogus to @file{/var/lib}, but for user. It is not a part of XDG
Base Directory Specification, but helps to make implementation of home
services more consistent."))
(define (home-xdg-base-directories-environment-variables-service config)
(map
(lambda (field)
(cons (format
#f "XDG_~a"
(object->snake-case-string (configuration-field-name field) 'upper))
((configuration-field-getter field) config)))
home-xdg-base-directories-configuration-fields))
(define (ensure-xdg-base-dirs-on-activation config)
#~(map (lambda (xdg-base-dir-variable)
((@@ (guix build utils) mkdir-p)
(getenv
xdg-base-dir-variable)))
'#$(map (lambda (field)
(format
#f "XDG_~a"
(object->snake-case-string
(configuration-field-name field) 'upper)))
home-xdg-base-directories-configuration-fields)))
(define (last-extension-or-cfg config extensions)
"Picks configuration value from last provided extension. If there
are no extensions use configuration instead."
(or (and (not (null? extensions)) (last extensions)) config))
(define home-xdg-base-directories-service-type
(service-type (name 'home-xdg-base-directories)
(extensions
(list (service-extension
home-environment-variables-service-type
home-xdg-base-directories-environment-variables-service)
(service-extension
home-activation-service-type
ensure-xdg-base-dirs-on-activation)))
(default-value (home-xdg-base-directories-configuration))
(compose identity)
(extend last-extension-or-cfg)
(description "Configure XDG base directories. This
service introduces two additional variables @env{XDG_STATE_HOME},
@env{XDG_LOG_HOME}. They are not a part of XDG specification, at
least yet, but are convenient to have, it improves the consistency
between different home services. The services of this service-type is
instantiated by default, to provide non-default value, extend the
service-type (using @code{simple-service} for example).")))
(define (generate-home-xdg-base-directories-documentation)
(generate-documentation
`((home-xdg-base-directories-configuration
,home-xdg-base-directories-configuration-fields))
'home-xdg-base-directories-configuration))
;;;
;;; XDG user directories.
;;;
(define (serialize-string field-name val)
;; The path has to be quoted
(format #f "XDG_~a_DIR=\"~a\"\n"
(object->snake-case-string field-name 'upper) val))
(define-configuration home-xdg-user-directories-configuration
(desktop
(string "$HOME/Desktop")
"Default ``desktop'' directory, this is what you see on your
desktop when using a desktop environment,
e.g. GNOME (@pxref{XWindow,,,guix.info}).")
(documents
(string "$HOME/Documents")
"Default directory to put documents like PDFs.")
(download
(string "$HOME/Downloads")
"Default directory downloaded files, this is where your Web-broser
will put downloaded files in.")
(music
(string "$HOME/Music")
"Default directory for audio files.")
(pictures
(string "$HOME/Pictures")
"Default directory for pictures and images.")
(publicshare
(string "$HOME/Public")
"Default directory for shared files, which can be accessed by other
users on local machine or via network.")
(templates
(string "$HOME/Templates")
"Default directory for templates. They can be used by graphical
file manager or other apps for creating new files with some
pre-populated content.")
(videos
(string "$HOME/Videos")
"Default directory for videos."))
(define (home-xdg-user-directories-files-service config)
`(("user-dirs.conf"
,(mixed-text-file
"user-dirs.conf"
"enabled=False\n"))
("user-dirs.dirs"
,(mixed-text-file
"user-dirs.dirs"
(serialize-configuration
config
home-xdg-user-directories-configuration-fields)))))
(define (home-xdg-user-directories-activation-service config)
(let ((dirs (map (lambda (field)
((configuration-field-getter field) config))
home-xdg-user-directories-configuration-fields)))
#~(let ((ensure-dir
(lambda (path)
(mkdir-p
((@@ (ice-9 string-fun) string-replace-substring)
path "$HOME" (getenv "HOME"))))))
(display "Creating XDG user directories...")
(map ensure-dir '#$dirs)
(display " done\n"))))
(define home-xdg-user-directories-service-type
(service-type (name 'home-xdg-user-directories)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
home-xdg-user-directories-files-service)
(service-extension
home-activation-service-type
home-xdg-user-directories-activation-service)))
(default-value (home-xdg-user-directories-configuration))
(description "Configure XDG user directories. To
disable a directory, point it to the $HOME.")))
(define (generate-home-xdg-user-directories-documentation)
(generate-documentation
`((home-xdg-user-directories-configuration
,home-xdg-user-directories-configuration-fields))
'home-xdg-user-directories-configuration))
;;;
;;; XDG MIME applications.
;;;
;; Example config
;;
;; (home-xdg-mime-applications-configuration
;; (added '((x-scheme-handler/magnet . torrent.desktop)))
;; (default '((inode/directory . file.desktop)))
;; (removed '((inode/directory . thunar.desktop)))
;; (desktop-entries
;; (list (xdg-desktop-entry
;; (file "file")
;; (name "File manager")
;; (type 'application)
;; (config
;; '((exec . "emacsclient -c -a emacs %u"))))
;; (xdg-desktop-entry
;; (file "text")
;; (name "Text editor")
;; (type 'application)
;; (config
;; '((exec . "emacsclient -c -a emacs %u")))
;; (actions
;; (list (xdg-desktop-action
;; (action 'create)
;; (name "Create an action")
;; (config
;; '((exec . "echo hi"))))))))))
;; See
;; <https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html>
;; <https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html>
(define (serialize-alist field-name val)
(define (serialize-mimelist-entry key val)
(let ((val (cond
((list? val)
(string-join (map maybe-object->string val) ";"))
((or (string? val) (symbol? val))
val)
(else (raise (formatted-message
(G_ "\
The value of an XDG MIME entry must be a list, string or symbol, was given ~a")
val))))))
(format #f "~a=~a\n" key val)))
(define (merge-duplicates alist acc)
"Merge values that have the same key.
@example
(merge-duplicates '((key1 . value1)
(key2 . value2)
(key1 . value3)
(key1 . value4)) '())
@result{} ((key1 . (value4 value3 value1)) (key2 . value2))
@end example"
(cond
((null? alist) acc)
(else (let* ((head (first alist))
(tail (cdr alist))
(key (first head))
(value (cdr head))
(duplicate? (assoc key acc))
(ensure-list (lambda (x)
(if (list? x) x (list x)))))
(if duplicate?
;; XXX: This will change the order of things,
;; though, it shouldn't be a problem for XDG MIME.
(merge-duplicates
tail
(alist-cons key
(cons value (ensure-list (cdr duplicate?)))
(alist-delete key acc)))
(merge-duplicates tail (cons head acc)))))))
(string-append (if (equal? field-name 'default)
"\n[Default Applications]\n"
(format #f "\n[~a Associations]\n"
(string-capitalize (symbol->string field-name))))
(generic-serialize-alist string-append
serialize-mimelist-entry
(merge-duplicates val '()))))
(define xdg-desktop-types (make-enumeration
'(application
link
directory)))
(define (xdg-desktop-type? type)
(unless (enum-set-member? type xdg-desktop-types)
(raise (formatted-message
(G_ "XDG desktop type must be of of ~a, was given: ~a")
(list->human-readable-list (enum-set->list xdg-desktop-types))
type))))
;; TODO: Add proper docs for this
;; XXX: 'define-configuration' require that fields have a default
;; value.
(define-record-type* <xdg-desktop-action>
xdg-desktop-action make-xdg-desktop-action
xdg-desktop-action?
(action xdg-desktop-action-action) ; symbol
(name xdg-desktop-action-name) ; string
(config xdg-desktop-action-config ; alist
(default '())))
(define-record-type* <xdg-desktop-entry>
xdg-desktop-entry make-xdg-desktop-entry
xdg-desktop-entry?
;; ".desktop" will automatically be added
(file xdg-desktop-entry-file) ; string
(name xdg-desktop-entry-name) ; string
(type xdg-desktop-entry-type) ; xdg-desktop-type
(config xdg-desktop-entry-config ; alist
(default '()))
(actions xdg-desktop-entry-actions ; list of <xdg-desktop-action>
(default '())))
(define desktop-entries? (list-of xdg-desktop-entry?))
(define (serialize-desktop-entries field-name val) "")
(define (serialize-xdg-desktop-entry entry)
"Return a tuple of the file name for ENTRY and the serialized
configuration."
(define (format-config key val)
(let ((val (cond
((list? val)
(string-join (map maybe-object->string val) ";"))
((boolean? val)
(if val "true" "false"))
(else val)))
(key (string-capitalize (maybe-object->string key))))
(list (if (string-suffix? key "?")
(string-drop-right key (- (string-length key) 1))
key)
"=" val "\n")))
(define (serialize-alist config)
(generic-serialize-alist append format-config config))
(define (serialize-xdg-desktop-action action)
(match action
(($ <xdg-desktop-action> action name config)
`(,(format #f "[Desktop Action ~a]\n"
(string-capitalize (maybe-object->string action)))
,(format #f "Name=~a\n" name)
,@(serialize-alist config)))))
(match entry
(($ <xdg-desktop-entry> file name type config actions)
(list (if (string-suffix? file ".desktop")
file
(string-append file ".desktop"))
`("[Desktop Entry]\n"
,(format #f "Name=~a\n" name)
,(format #f "Type=~a\n"
(string-capitalize (symbol->string type)))
,@(serialize-alist config)
,@(append-map serialize-xdg-desktop-action actions))))))
(define-configuration home-xdg-mime-applications-configuration
(added
(alist '())
"An association list of MIME types and desktop entries which indicate
that the application should used to open the specified MIME type. The
value has to be string, symbol, or list of strings or symbols, this
applies to the `@code{default}', and `@code{removed}' fields as well.")
(default
(alist '())
"An association list of MIME types and desktop entries which indicate
that the application should be the default for opening the specified
MIME type.")
(removed
(alist '())
"An association list of MIME types and desktop entries which indicate
that the application cannot open the specified MIME type.")
(desktop-entries
(desktop-entries '())
"A list of XDG desktop entries to create. See
@code{xdg-desktop-entry}."))
(define (home-xdg-mime-applications-files config)
(define (add-xdg-desktop-entry-file entry)
(let ((file (first entry))
(config (second entry)))
(list (format #f "local/share/applications/~a" file)
(apply mixed-text-file
(format #f "xdg-desktop-~a-entry" file)
config))))
(map (compose add-xdg-desktop-entry-file serialize-xdg-desktop-entry)
(home-xdg-mime-applications-configuration-desktop-entries config)))
(define (home-xdg-mime-applications-xdg-files config)
`(("mimeapps.list"
,(mixed-text-file
"xdg-mime-appplications"
(serialize-configuration
config
home-xdg-mime-applications-configuration-fields)))))
(define (home-xdg-mime-applications-extension old-config extension-configs)
(define (extract-fields config)
;; return '(added default removed desktop-entries)
(list (home-xdg-mime-applications-configuration-added config)
(home-xdg-mime-applications-configuration-default config)
(home-xdg-mime-applications-configuration-removed config)
(home-xdg-mime-applications-configuration-desktop-entries config)))
(define (append-configs elem acc)
(list (append (first elem) (first acc))
(append (second elem) (second acc))
(append (third elem) (third acc))
(append (fourth elem) (fourth acc))))
;; TODO: Implement procedure to check for duplicates without
;; sacrificing performance.
;;
;; Combine all the alists from 'added', 'default' and 'removed'
;; into one big alist.
(let ((folded-configs (fold append-configs
(extract-fields old-config)
(map extract-fields extension-configs))))
(home-xdg-mime-applications-configuration
(added (first folded-configs))
(default (second folded-configs))
(removed (third folded-configs))
(desktop-entries (fourth folded-configs)))))
(define home-xdg-mime-applications-service-type
(service-type (name 'home-xdg-mime-applications)
(extensions
(list (service-extension
home-files-service-type
home-xdg-mime-applications-files)
(service-extension
home-xdg-configuration-files-service-type
home-xdg-mime-applications-xdg-files)))
(compose identity)
(extend home-xdg-mime-applications-extension)
(default-value (home-xdg-mime-applications-configuration))
(description
"Configure XDG MIME applications, and XDG desktop entries.")))
+3 -20
View File
@@ -17,7 +17,6 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu image)
#:use-module (gnu platform)
#:use-module (guix records)
#:export (partition
partition?
@@ -32,18 +31,14 @@
partition-initializer
image
image?
image-name
image-format
image-platform
image-target
image-size
image-operating-system
image-partition-table-type
image-partitions
image-compression?
image-volatile-root?
image-shared-store?
image-shared-network?
image-substitutable?
image-type
@@ -51,8 +46,7 @@
image-type-name
image-type-constructor
os->image
os+platform->image))
os->image))
;;;
@@ -83,24 +77,18 @@
(name image-name ;symbol
(default #f))
(format image-format) ;symbol
(platform image-platform ;<platform>
(target image-target
(default #f))
(size image-size ;size in bytes as integer
(default 'guess))
(operating-system image-operating-system ;<operating-system>
(default #f))
(partition-table-type image-partition-table-type ; 'mbr or 'gpt
(default 'mbr))
(partitions image-partitions ;list of <partition>
(default '()))
(compression? image-compression? ;boolean
(default #t))
(volatile-root? image-volatile-root? ;boolean
(default #t))
(shared-store? image-shared-store? ;boolean
(default #f))
(shared-network? image-shared-network? ;boolean
(default #f))
(substitutable? image-substitutable? ;boolean
(default #t)))
@@ -123,8 +111,3 @@
(define* (os->image os #:key type)
(let ((constructor (image-type-constructor type)))
(constructor os)))
(define* (os+platform->image os platform #:key type)
(image
(inherit (os->image os #:type type))
(platform platform)))
+38 -67
View File
@@ -33,7 +33,6 @@
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages connman)
#:use-module (gnu packages cryptsetup)
#:use-module (gnu packages disk)
@@ -43,10 +42,8 @@
#:autoload (gnu packages gnupg) (guile-gcrypt)
#:use-module (gnu packages iso-codes)
#:use-module (gnu packages linux)
#:use-module (gnu packages nano)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages package-management)
#:use-module (gnu packages tls)
#:use-module (gnu packages xorg)
#:use-module (gnu system locale)
#:use-module (ice-9 match)
@@ -190,7 +187,7 @@ selected keymap."
(lambda (models layouts)
((installer-keymap-page current-installer)
layouts '#$context)))))
(and result (#$apply-keymap result))
(#$apply-keymap result)
result)))
(define (installer-steps)
@@ -269,13 +266,6 @@ selected keymap."
(compute (lambda _
((installer-network-page current-installer)))))
;; Ask whether to enable substitute server discovery.
(installer-step
(id 'substitutes)
(description (G_ "Substitute server discovery"))
(compute (lambda _
((installer-substitutes-page current-installer)))))
;; Prompt for users (name, group and home directory).
(installer-step
(id 'user)
@@ -333,13 +323,10 @@ selected keymap."
btrfs-progs
jfsutils ;jfs_mkfs
ntfs-3g ;mkfs.ntfs
xfsprogs ;mkfs.xfs
kbd ;chvt
guix ;guix system init call
util-linux ;mkwap
nano
shadow
tar ;dump
gzip ;dump
coreutils)))
(with-output-to-port (%make-void-port "w")
(lambda ()
@@ -356,8 +343,7 @@ selected keymap."
;; packages …), etc. modules.
(with-extensions (list guile-gcrypt guile-newt
guile-parted guile-bytestructures
guile-json-3 guile-git guile-webutils
guix gnutls)
guile-json-3 guile-git guix)
(with-imported-modules `(,@(source-module-closure
`(,@modules
(gnu services herd)
@@ -368,7 +354,6 @@ selected keymap."
(use-modules (gnu installer record)
(gnu installer keymap)
(gnu installer steps)
(gnu installer dump)
(gnu installer final)
(gnu installer hostname)
(gnu installer locale)
@@ -385,8 +370,7 @@ selected keymap."
(guix build utils)
((system repl debug)
#:select (terminal-width))
(ice-9 match)
(ice-9 textual-ports))
(ice-9 match))
;; Initialize gettext support so that installers can use
;; (guix i18n) module.
@@ -414,56 +398,43 @@ selected keymap."
;; verbose.
(terminal-width 200)
(define current-installer newt-installer)
(define steps (#$steps current-installer))
(let* ((current-installer newt-installer)
(steps (#$steps current-installer)))
((installer-init current-installer))
(dynamic-wind
(installer-init current-installer)
(lambda ()
(parameterize
((run-command-in-installer
(installer-run-command current-installer)))
(catch #t
(lambda ()
(define results
(run-installer-steps
#:rewind-strategy 'menu
#:menu-proc (installer-menu-page current-installer)
#:steps steps))
(catch #t
(lambda ()
(define results
(run-installer-steps
#:rewind-strategy 'menu
#:menu-proc (installer-menu-page current-installer)
#:steps steps))
(match (result-step results 'final)
('success
;; We did it! Let's reboot!
(sync)
(stop-service 'root))
(_
;; The installation failed, exit so that it is
;; restarted by login.
#f)))
(const #f)
(lambda (key . args)
(installer-log-line "crashing due to uncaught exception: ~s ~s"
key args)
(define dump-dir
(prepare-dump key args #:result %current-result))
(define action
((installer-exit-error current-installer)
(get-string-all
(open-input-file
(string-append dump-dir "/installer-backtrace")))))
(match action
('dump
(let* ((dump-files
((installer-dump-page current-installer)
dump-dir))
(dump-archive
(make-dump dump-dir dump-files)))
((installer-report-page current-installer)
dump-archive)))
(_ #f))
(exit 1)))))
(match (result-step results 'final)
('success
;; We did it! Let's reboot!
(sync)
(stop-service 'root))
(_
;; The installation failed, exit so that it is restarted
;; by login.
#f)))
(const #f)
(lambda (key . args)
(syslog "crashing due to uncaught exception: ~s ~s~%"
key args)
(let ((error-file "/tmp/last-installer-error"))
(call-with-output-file error-file
(lambda (port)
(display-backtrace (make-stack #t) port)
(print-exception port
(stack-ref (make-stack #t) 1)
key args)))
((installer-exit-error current-installer)
error-file key args))
(primitive-exit 1)))
(installer-exit current-installer))))))
((installer-exit current-installer)))))))
(program-file
"installer"
+1 -1
View File
@@ -287,7 +287,7 @@ list so that each keys of a given technology are gathered in a separate list."
(define (connman-online?)
(let ((state (connman-state)))
(memq state '(ready online))))
(eq? state 'online)))
(define (connman-connect-with-auth service password-proc)
"Connect to the given SERVICE with the password returned by calling
-118
View File
@@ -1,118 +0,0 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Mathieu Othacehe <othacehe@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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu installer dump)
#:use-module (gnu installer utils)
#:use-module (guix build utils)
#:use-module (srfi srfi-11)
#:use-module (ice-9 iconv)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 textual-ports)
#:use-module (web client)
#:use-module (web http)
#:use-module (web response)
#:use-module (webutils multipart)
#:export (prepare-dump
make-dump
send-dump-report))
;; The installer crash dump type.
(define %dump-type "installer-dump")
(define (result->list result)
"Return the alist for the given RESULT."
(hash-map->list (lambda (k v)
(cons k v))
result))
(define* (prepare-dump key args #:key result)
"Create a crash dump directory. KEY and ARGS represent the thrown error.
RESULT is the installer result hash table. Returns the created directory path."
(define now (localtime (current-time)))
(define dump-dir
(format #f "/tmp/dump.~a"
(strftime "%F.%H.%M.%S" now)))
(mkdir-p dump-dir)
(with-directory-excursion dump-dir
;; backtrace
(call-with-output-file "installer-backtrace"
(lambda (port)
(display-backtrace (make-stack #t) port)
(print-exception port
(stack-ref (make-stack #t) 1)
key args)))
;; installer result
(call-with-output-file "installer-result"
(lambda (port)
(write (result->list result) port)))
;; syslog
(copy-file "/var/log/messages" "syslog")
;; dmesg
(let ((pipe (open-pipe* OPEN_READ "dmesg")))
(call-with-output-file "dmesg"
(lambda (port)
(dump-port pipe port)
(close-pipe pipe)))))
dump-dir)
(define* (make-dump dump-dir file-choices)
"Create a crash dump archive from DUMP-DIR containing FILE-CHOICES.
Returns the archive path."
(define output (string-append (basename dump-dir) ".tar.gz"))
(with-directory-excursion (dirname dump-dir)
(apply system* "tar" "-zcf" output
(map (lambda (f)
(string-append (basename dump-dir) "/" f))
file-choices)))
(canonicalize-path (string-append (dirname dump-dir) "/" output)))
(define* (send-dump-report dump
#:key
(url "https://dump.guix.gnu.org"))
"Turn the DUMP archive into a multipart body and send it to the Guix crash
dump server at URL."
(define (match-boundary kont)
(match-lambda
(('boundary . (? string? b))
(kont b))
(x #f)))
(define (response->string response)
(bytevector->string
(read-response-body response)
"UTF-8"))
(let-values (((body boundary)
(call-with-input-file dump
(lambda (port)
(format-multipart-body
`((,%dump-type . ,port)))))))
(false-if-exception
(response->string
(http-post
(string-append url "/upload")
#:keep-alive? #t
#:streaming? #t
#:headers `((content-type
. (multipart/form-data
(boundary . ,boundary))))
#:body body)))))
+44 -32
View File
@@ -85,9 +85,8 @@ USERS."
(uid (if root? 0 #f))
(home-directory
(user-home-directory user))
(password (crypt
(secret-content (user-password user))
(salt)))
(password (crypt (user-password user)
(salt)))
;; We need a string here, not a file-like, hence
;; this choice.
@@ -106,6 +105,36 @@ USERS."
(write-passwd password (string-append etc "/passwd"))
(write-shadow shadow (string-append etc "/shadow")))
(define* (kill-cow-users cow-path #:key (spare '("udevd")))
"Kill all processes that have references to the given COW-PATH in their
'maps' file. The process whose names are in SPARE list are spared."
(define %not-nul
(char-set-complement (char-set #\nul)))
(let ((pids
(filter-map (lambda (pid)
(false-if-exception
(call-with-input-file
(string-append "/proc/" pid "/maps")
(lambda (port)
(and (string-contains (get-string-all port)
cow-path)
(string->number pid))))))
(scandir "/proc" string->number))))
(for-each (lambda (pid)
;; cmdline does not always exist.
(false-if-exception
(call-with-input-file
(string-append "/proc/" (number->string pid) "/cmdline")
(lambda (port)
(match (string-tokenize (read-string port) %not-nul)
((argv0 _ ...)
(unless (member (basename argv0) spare)
(syslog "Killing process ~a (~a)~%" pid argv0)
(kill pid SIGKILL)))
(_ #f))))))
pids)))
(define (call-with-mnt-container thunk)
"This is a variant of call-with-container. Run THUNK in a new container
process, within a separate MNT namespace. The container is not jailed so that
@@ -120,28 +149,6 @@ it can interact with the rest of the system."
(match (waitpid pid)
((_ . status) status))))
(define (install-locale locale)
"Install the given LOCALE or the en_US.utf8 locale as a fallback."
(let ((supported? (false-if-exception
(setlocale LC_ALL locale))))
(if supported?
(begin
(installer-log-line "install supported locale ~a." locale)
(setenv "LC_ALL" locale))
(begin
;; If the selected locale is not supported, install a default UTF-8
;; locale. This is required to copy some files with UTF-8
;; characters, in the nss-certs package notably. Set LANGUAGE
;; anyways, to have translated messages if possible.
(installer-log-line "~a locale is not supported, installing \
en_US.utf8 locale instead." locale)
(setlocale LC_ALL "en_US.utf8")
(setenv "LC_ALL" "en_US.utf8")
(setenv "LANGUAGE"
(string-take locale
(or (string-index locale #\_)
(string-length locale))))))))
(define* (install-system locale #:key (users '()))
"Create /etc/shadow and /etc/passwd on the installation target for USERS.
Start COW-STORE service on target directory and launch guix install command in
@@ -192,10 +199,6 @@ or #f. Return #t on success and #f on failure."
(lambda ()
(dynamic-wind
(lambda ()
;; Install the locale before mounting the cow-store, otherwise
;; the loaded cow-store locale files will prevent umounting.
(install-locale locale)
;; Save the database, so that it can be restored once the
;; cow-store is umounted.
(copy-file database-file saved-database)
@@ -209,9 +212,18 @@ or #f. Return #t on success and #f on failure."
(setvbuf (current-output-port) 'none)
(setvbuf (current-error-port) 'none)
(setenv "PATH" "/run/current-system/profile/bin/")
(set! ret (run-command install-command)))
;; If there are any connected clients, assume that we are running
;; installation tests. In that case, dump the standard and error
;; outputs to syslog.
(set! ret
(if (not (null? (current-clients)))
(with-output-to-file "/dev/console"
(lambda ()
(with-error-to-file "/dev/console"
(lambda ()
(run-command install-command
#:locale locale)))))
(run-command install-command #:locale locale))))
(lambda ()
;; Restart guix-daemon so that it does no keep the MNT namespace
;; alive.
+6 -11
View File
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2021 Mathieu Othacehe <othacehe@gnu.org>
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
@@ -79,11 +79,6 @@
"Parse FILE and return two values, the list of supported X11-KEYMAP-MODEL
and X11-KEYMAP-LAYOUT records. FILE is an XML file from the X Keyboard
Configuration Database, describing possible XKB configurations."
(define maybe-empty
(match-lambda
((x) x)
(#f "")))
(define (model m)
(sxml-match m
[(model
@@ -113,7 +108,7 @@ Configuration Database, describing possible XKB configurations."
. ,rest-variant))
(x11-keymap-variant
(name name)
(description (maybe-empty
(description (car
(assoc-ref rest-variant 'description))))]))
(define (layout l)
@@ -125,9 +120,9 @@ Configuration Database, describing possible XKB configurations."
(variantList ,[variant -> v] ...))
(x11-keymap-layout
(name name)
(synopsis (maybe-empty
(synopsis (car
(assoc-ref rest-layout 'shortDescription)))
(description (maybe-empty
(description (car
(assoc-ref rest-layout 'description)))
(variants (list v ...)))]
[(layout
@@ -136,9 +131,9 @@ Configuration Database, describing possible XKB configurations."
. ,rest-layout))
(x11-keymap-layout
(name name)
(synopsis (maybe-empty
(synopsis (car
(assoc-ref rest-layout 'shortDescription)))
(description (maybe-empty
(description (car
(assoc-ref rest-layout 'description)))
(variants '()))]))

Some files were not shown because too many files have changed in this diff Show More