guix-cookbook.texi 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix-cookbook.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Cookbook
  7. @c %**end of header
  8. @c Onion service for ci.guix.gnu.org.
  9. @set SUBSTITUTE-TOR-URL https://4zwzi66wwdaalbhgnix55ea3ab4pvvw66ll2ow53kjub6se4q2bclcyd.onion
  10. @copying
  11. Copyright @copyright{} 2019 Ricardo Wurmus@*
  12. Copyright @copyright{} 2019 Efraim Flashner@*
  13. Copyright @copyright{} 2019 Pierre Neidhardt@*
  14. Copyright @copyright{} 2020 Oleg Pykhalov@*
  15. Copyright @copyright{} 2020 Matthew Brooks@*
  16. Copyright @copyright{} 2020 Marcin Karpezo@*
  17. Copyright @copyright{} 2020 Brice Waegeneire@*
  18. Copyright @copyright{} 2020 André Batista@*
  19. Copyright @copyright{} 2020 Christine Lemmer-Webber@*
  20. Copyright @copyright{} 2021 Joshua Branson@*
  21. Permission is granted to copy, distribute and/or modify this document
  22. under the terms of the GNU Free Documentation License, Version 1.3 or
  23. any later version published by the Free Software Foundation; with no
  24. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  25. copy of the license is included in the section entitled ``GNU Free
  26. Documentation License''.
  27. @end copying
  28. @dircategory System administration
  29. @direntry
  30. * Guix cookbook: (guix-cookbook). Tutorials and examples for GNU Guix.
  31. @end direntry
  32. @titlepage
  33. @title GNU Guix Cookbook
  34. @subtitle Tutorials and examples for using the GNU Guix Functional Package Manager
  35. @author The GNU Guix Developers
  36. @page
  37. @vskip 0pt plus 1filll
  38. @insertcopying
  39. @end titlepage
  40. @contents
  41. @c *********************************************************************
  42. @node Top
  43. @top GNU Guix Cookbook
  44. This document presents tutorials and detailed examples for GNU@tie{}Guix, a
  45. functional package management tool written for the GNU system. Please
  46. @pxref{Top,,, guix, GNU Guix reference manual} for details about the system,
  47. its API, and related concepts.
  48. @c TRANSLATORS: You can replace the following paragraph with information on
  49. @c how to join your own translation team and how to report issues with the
  50. @c translation.
  51. This manual is also available in French (@pxref{Top,,, guix-cookbook.fr,
  52. Livre de recettes de GNU Guix}) and German (@pxref{Top,,,
  53. guix-cookbook.de, GNU-Guix-Kochbuch}). If you would like to translate
  54. this document in your native language, consider joining
  55. @uref{https://translate.fedoraproject.org/projects/guix/documentation-cookbook,
  56. Weblate} (@pxref{Translating Guix,,, guix, GNU Guix reference manual}).
  57. @menu
  58. * Scheme tutorials:: Meet your new favorite language!
  59. * Packaging:: Packaging tutorials
  60. * System Configuration:: Customizing the GNU System
  61. * Advanced package management:: Power to the users!
  62. * Environment management:: Control environment
  63. * Acknowledgments:: Thanks!
  64. * GNU Free Documentation License:: The license of this document.
  65. * Concept Index:: Concepts.
  66. @detailmenu
  67. --- The Detailed Node Listing ---
  68. Scheme tutorials
  69. * A Scheme Crash Course:: Learn the basics of Scheme
  70. Packaging
  71. * Packaging Tutorial:: Let's add a package to Guix!
  72. System Configuration
  73. * Auto-Login to a Specific TTY:: Automatically Login a User to a Specific TTY
  74. * Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System.
  75. @end detailmenu
  76. @end menu
  77. @c *********************************************************************
  78. @node Scheme tutorials
  79. @chapter Scheme tutorials
  80. GNU@tie{}Guix is written in the general purpose programming language Scheme,
  81. and many of its features can be accessed and manipulated programmatically.
  82. You can use Scheme to generate package definitions, to modify them, to build
  83. them, to deploy whole operating systems, etc.
  84. Knowing the basics of how to program in Scheme will unlock many of the
  85. advanced features Guix provides --- and you don't even need to be an
  86. experienced programmer to use them!
  87. Let's get started!
  88. @node A Scheme Crash Course
  89. @section A Scheme Crash Course
  90. @cindex Scheme, crash course
  91. Guix uses the Guile implementation of Scheme. To start playing with the
  92. language, install it with @code{guix install guile} and start a
  93. @dfn{REPL}---short for @uref{https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop,
  94. @dfn{read-eval-print loop}}---by running @code{guile} from the command line.
  95. Alternatively you can also run @code{guix environment --ad-hoc guile -- guile}
  96. if you'd rather not have Guile installed in your user profile.
  97. In the following examples, lines show what you would type at the REPL;
  98. lines starting with ``@result{}'' show evaluation results, while lines
  99. starting with ``@print{}'' show things that get printed. @xref{Using Guile
  100. Interactively,,, guile, GNU Guile Reference Manual}, for more details on the
  101. REPL.
  102. @itemize
  103. @item
  104. Scheme syntax boils down to a tree of expressions (or @emph{s-expression} in
  105. Lisp lingo). An expression can be a literal such as numbers and strings, or a
  106. compound which is a parenthesized list of compounds and literals. @code{#true}
  107. and @code{#false} (abbreviated @code{#t} and @code{#f}) stand for the
  108. Booleans ``true'' and ``false'', respectively.
  109. Examples of valid expressions:
  110. @lisp
  111. "Hello World!"
  112. @result{} "Hello World!"
  113. 17
  114. @result{} 17
  115. (display (string-append "Hello " "Guix" "\n"))
  116. @print{} Hello Guix!
  117. @result{} #<unspecified>
  118. @end lisp
  119. @item
  120. This last example is a function call nested in another function call. When a
  121. parenthesized expression is evaluated, the first term is the function and the
  122. rest are the arguments passed to the function. Every function returns the
  123. last evaluated expression as its return value.
  124. @item
  125. Anonymous functions are declared with the @code{lambda} term:
  126. @lisp
  127. (lambda (x) (* x x))
  128. @result{} #<procedure 120e348 at <unknown port>:24:0 (x)>
  129. @end lisp
  130. The above procedure returns the square of its argument. Since everything is
  131. an expression, the @code{lambda} expression returns an anonymous procedure,
  132. which can in turn be applied to an argument:
  133. @lisp
  134. ((lambda (x) (* x x)) 3)
  135. @result{} 9
  136. @end lisp
  137. @item
  138. Anything can be assigned a global name with @code{define}:
  139. @lisp
  140. (define a 3)
  141. (define square (lambda (x) (* x x)))
  142. (square a)
  143. @result{} 9
  144. @end lisp
  145. @item
  146. Procedures can be defined more concisely with the following syntax:
  147. @lisp
  148. (define (square x) (* x x))
  149. @end lisp
  150. @item
  151. A list structure can be created with the @code{list} procedure:
  152. @lisp
  153. (list 2 a 5 7)
  154. @result{} (2 3 5 7)
  155. @end lisp
  156. @item
  157. The @dfn{quote} disables evaluation of a parenthesized expression: the
  158. first term is not called over the other terms (@pxref{Expression Syntax,
  159. quote,, guile, GNU Guile Reference Manual}). Thus it effectively
  160. returns a list of terms.
  161. @lisp
  162. '(display (string-append "Hello " "Guix" "\n"))
  163. @result{} (display (string-append "Hello " "Guix" "\n"))
  164. '(2 a 5 7)
  165. @result{} (2 a 5 7)
  166. @end lisp
  167. @item
  168. The @dfn{quasiquote} disables evaluation of a parenthesized expression
  169. until @dfn{unquote} (a comma) re-enables it. Thus it provides us with
  170. fine-grained control over what is evaluated and what is not.
  171. @lisp
  172. `(2 a 5 7 (2 ,a 5 ,(+ a 4)))
  173. @result{} (2 a 5 7 (2 3 5 7))
  174. @end lisp
  175. Note that the above result is a list of mixed elements: numbers, symbols (here
  176. @code{a}) and the last element is a list itself.
  177. @item
  178. Multiple variables can be named locally with @code{let} (@pxref{Local
  179. Bindings,,, guile, GNU Guile Reference Manual}):
  180. @lisp
  181. (define x 10)
  182. (let ((x 2)
  183. (y 3))
  184. (list x y))
  185. @result{} (2 3)
  186. x
  187. @result{} 10
  188. y
  189. @error{} In procedure module-lookup: Unbound variable: y
  190. @end lisp
  191. Use @code{let*} to allow later variable declarations to refer to earlier
  192. definitions.
  193. @lisp
  194. (let* ((x 2)
  195. (y (* x 3)))
  196. (list x y))
  197. @result{} (2 6)
  198. @end lisp
  199. @item
  200. @dfn{Keywords} are typically used to identify the named parameters of a
  201. procedure. They are prefixed by @code{#:} (hash, colon) followed by
  202. alphanumeric characters: @code{#:like-this}.
  203. @xref{Keywords,,, guile, GNU Guile Reference Manual}.
  204. @item
  205. The percentage @code{%} is typically used for read-only global variables in
  206. the build stage. Note that it is merely a convention, like @code{_} in C.
  207. Scheme treats @code{%} exactly the same as any other letter.
  208. @item
  209. Modules are created with @code{define-module} (@pxref{Creating Guile
  210. Modules,,, guile, GNU Guile Reference Manual}). For instance
  211. @lisp
  212. (define-module (guix build-system ruby)
  213. #:use-module (guix store)
  214. #:export (ruby-build
  215. ruby-build-system))
  216. @end lisp
  217. defines the module @code{guix build-system ruby} which must be located in
  218. @file{guix/build-system/ruby.scm} somewhere in the Guile load path. It
  219. depends on the @code{(guix store)} module and it exports two variables,
  220. @code{ruby-build} and @code{ruby-build-system}.
  221. @end itemize
  222. For a more detailed introduction, check out
  223. @uref{http://www.troubleshooters.com/codecorn/scheme_guile/hello.htm, Scheme
  224. at a Glance}, by Steve Litt.
  225. One of the reference Scheme books is the seminal ``Structure and
  226. Interpretation of Computer Programs'', by Harold Abelson and Gerald Jay
  227. Sussman, with Julie Sussman. You'll find a
  228. @uref{https://mitpress.mit.edu/sites/default/files/sicp/index.html, free copy
  229. online}, together with
  230. @uref{https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/,
  231. videos of the lectures by the authors}. The book is available in Texinfo
  232. format as the @code{sicp} Guix package. Go ahead, run @code{guix install
  233. sicp} and start reading with @code{info sicp} (@pxref{,,, sicp, Structure and Interpretation of Computer Programs}).
  234. An @uref{https://sarabander.github.io/sicp/, unofficial ebook is also
  235. available}.
  236. You'll find more books, tutorials and other resources at
  237. @url{https://schemers.org/}.
  238. @c *********************************************************************
  239. @node Packaging
  240. @chapter Packaging
  241. @cindex packaging
  242. This chapter is dedicated to teaching you how to add packages to the
  243. collection of packages that come with GNU Guix. This involves writing package
  244. definitions in Guile Scheme, organizing them in package modules, and building
  245. them.
  246. @menu
  247. * Packaging Tutorial:: A tutorial on how to add packages to Guix.
  248. @end menu
  249. @node Packaging Tutorial
  250. @section Packaging Tutorial
  251. GNU Guix stands out as the @emph{hackable} package manager, mostly because it
  252. uses @uref{https://www.gnu.org/software/guile/, GNU Guile}, a powerful
  253. high-level programming language, one of the
  254. @uref{https://en.wikipedia.org/wiki/Scheme_%28programming_language%29, Scheme}
  255. dialects from the
  256. @uref{https://en.wikipedia.org/wiki/Lisp_%28programming_language%29, Lisp family}.
  257. Package definitions are also written in Scheme, which empowers Guix in some
  258. very unique ways, unlike most other package managers that use shell scripts or
  259. simple languages.
  260. @itemize
  261. @item
  262. Use functions, structures, macros and all of Scheme expressiveness for your
  263. package definitions.
  264. @item
  265. Inheritance makes it easy to customize a package by inheriting from it and
  266. modifying only what is needed.
  267. @item
  268. Batch processing: the whole package collection can be parsed, filtered and
  269. processed. Building a headless server with all graphical interfaces stripped
  270. out? It's possible. Want to rebuild everything from source using specific
  271. compiler optimization flags? Pass the @code{#:make-flags "..."} argument to
  272. the list of packages. It wouldn't be a stretch to think
  273. @uref{https://wiki.gentoo.org/wiki/USE_flag, Gentoo USE flags} here, but this
  274. goes even further: the changes don't have to be thought out beforehand by the
  275. packager, they can be @emph{programmed} by the user!
  276. @end itemize
  277. The following tutorial covers all the basics around package creation with Guix.
  278. It does not assume much knowledge of the Guix system nor of the Lisp language.
  279. The reader is only expected to be familiar with the command line and to have some
  280. basic programming knowledge.
  281. @node A ``Hello World'' package
  282. @subsection A ``Hello World'' package
  283. The ``Defining Packages'' section of the manual introduces the basics of Guix
  284. packaging (@pxref{Defining Packages,,, guix, GNU Guix Reference Manual}). In
  285. the following section, we will partly go over those basics again.
  286. GNU@tie{}Hello is a dummy project that serves as an idiomatic example for
  287. packaging. It uses the GNU build system (@code{./configure && make && make
  288. install}). Guix already provides a package definition which is a perfect
  289. example to start with. You can look up its declaration with @code{guix edit
  290. hello} from the command line. Let's see how it looks:
  291. @lisp
  292. (define-public hello
  293. (package
  294. (name "hello")
  295. (version "2.10")
  296. (source (origin
  297. (method url-fetch)
  298. (uri (string-append "mirror://gnu/hello/hello-" version
  299. ".tar.gz"))
  300. (sha256
  301. (base32
  302. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  303. (build-system gnu-build-system)
  304. (synopsis "Hello, GNU world: An example GNU package")
  305. (description
  306. "GNU Hello prints the message \"Hello, world!\" and then exits. It
  307. serves as an example of standard GNU coding practices. As such, it supports
  308. command-line arguments, multiple languages, and so on.")
  309. (home-page "https://www.gnu.org/software/hello/")
  310. (license gpl3+)))
  311. @end lisp
  312. As you can see, most of it is rather straightforward. But let's review the
  313. fields together:
  314. @table @samp
  315. @item name
  316. The project name. Using Scheme conventions, we prefer to keep it
  317. lower case, without underscore and using dash-separated words.
  318. @item source
  319. This field contains a description of the source code origin. The
  320. @code{origin} record contains these fields:
  321. @enumerate
  322. @item The method, here @code{url-fetch} to download via HTTP/FTP, but other methods
  323. exist, such as @code{git-fetch} for Git repositories.
  324. @item The URI, which is typically some @code{https://} location for @code{url-fetch}. Here
  325. the special `mirror://gnu` refers to a set of well known locations, all of
  326. which can be used by Guix to fetch the source, should some of them fail.
  327. @item The @code{sha256} checksum of the requested file. This is essential to ensure
  328. the source is not corrupted. Note that Guix works with base32 strings,
  329. hence the call to the @code{base32} function.
  330. @end enumerate
  331. @item build-system
  332. This is where the power of abstraction provided by the Scheme language really
  333. shines: in this case, the @code{gnu-build-system} abstracts away the famous
  334. @code{./configure && make && make install} shell invocations. Other build
  335. systems include the @code{trivial-build-system} which does not do anything and
  336. requires from the packager to program all the build steps, the
  337. @code{python-build-system}, the @code{emacs-build-system}, and many more
  338. (@pxref{Build Systems,,, guix, GNU Guix Reference Manual}).
  339. @item synopsis
  340. It should be a concise summary of what the package does. For many packages a
  341. tagline from the project's home page can be used as the synopsis.
  342. @item description
  343. Same as for the synopsis, it's fine to re-use the project description from the
  344. homepage. Note that Guix uses Texinfo syntax.
  345. @item home-page
  346. Use HTTPS if available.
  347. @item license
  348. See @code{guix/licenses.scm} in the project source for a full list of
  349. available licenses.
  350. @end table
  351. Time to build our first package! Nothing fancy here for now: we will stick to a
  352. dummy @code{my-hello}, a copy of the above declaration.
  353. As with the ritualistic ``Hello World'' taught with most programming languages,
  354. this will possibly be the most ``manual'' approach. We will work out an ideal
  355. setup later; for now we will go the simplest route.
  356. Save the following to a file @file{my-hello.scm}.
  357. @lisp
  358. (use-modules (guix packages)
  359. (guix download)
  360. (guix build-system gnu)
  361. (guix licenses))
  362. (package
  363. (name "my-hello")
  364. (version "2.10")
  365. (source (origin
  366. (method url-fetch)
  367. (uri (string-append "mirror://gnu/hello/hello-" version
  368. ".tar.gz"))
  369. (sha256
  370. (base32
  371. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  372. (build-system gnu-build-system)
  373. (synopsis "Hello, Guix world: An example custom Guix package")
  374. (description
  375. "GNU Hello prints the message \"Hello, world!\" and then exits. It
  376. serves as an example of standard GNU coding practices. As such, it supports
  377. command-line arguments, multiple languages, and so on.")
  378. (home-page "https://www.gnu.org/software/hello/")
  379. (license gpl3+))
  380. @end lisp
  381. We will explain the extra code in a moment.
  382. Feel free to play with the different values of the various fields. If you
  383. change the source, you'll need to update the checksum. Indeed, Guix refuses to
  384. build anything if the given checksum does not match the computed checksum of the
  385. source code. To obtain the correct checksum of the package declaration, we
  386. need to download the source, compute the sha256 checksum and convert it to
  387. base32.
  388. Thankfully, Guix can automate this task for us; all we need is to provide the
  389. URI:
  390. @c TRANSLATORS: This is example shell output.
  391. @example sh
  392. $ guix download mirror://gnu/hello/hello-2.10.tar.gz
  393. Starting download of /tmp/guix-file.JLYgL7
  394. From https://ftpmirror.gnu.org/gnu/hello/hello-2.10.tar.gz...
  395. following redirection to `https://mirror.ibcp.fr/pub/gnu/hello/hello-2.10.tar.gz'...
  396. …10.tar.gz 709KiB 2.5MiB/s 00:00 [##################] 100.0%
  397. /gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz
  398. 0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i
  399. @end example
  400. In this specific case the output tells us which mirror was chosen.
  401. If the result of the above command is not the same as in the above snippet,
  402. update your @code{my-hello} declaration accordingly.
  403. Note that GNU package tarballs come with an OpenPGP signature, so you
  404. should definitely check the signature of this tarball with `gpg` to
  405. authenticate it before going further:
  406. @c TRANSLATORS: This is example shell output.
  407. @example sh
  408. $ guix download mirror://gnu/hello/hello-2.10.tar.gz.sig
  409. Starting download of /tmp/guix-file.03tFfb
  410. From https://ftpmirror.gnu.org/gnu/hello/hello-2.10.tar.gz.sig...
  411. following redirection to `https://ftp.igh.cnrs.fr/pub/gnu/hello/hello-2.10.tar.gz.sig'...
  412. ….tar.gz.sig 819B 1.2MiB/s 00:00 [##################] 100.0%
  413. /gnu/store/rzs8wba9ka7grrmgcpfyxvs58mly0sx6-hello-2.10.tar.gz.sig
  414. 0q0v86n3y38z17rl146gdakw9xc4mcscpk8dscs412j22glrv9jf
  415. $ gpg --verify /gnu/store/rzs8wba9ka7grrmgcpfyxvs58mly0sx6-hello-2.10.tar.gz.sig /gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz
  416. gpg: Signature made Sun 16 Nov 2014 01:08:37 PM CET
  417. gpg: using RSA key A9553245FDE9B739
  418. gpg: Good signature from "Sami Kerola <kerolasa@@iki.fi>" [unknown]
  419. gpg: aka "Sami Kerola (http://www.iki.fi/kerolasa/) <kerolasa@@iki.fi>" [unknown]
  420. gpg: WARNING: This key is not certified with a trusted signature!
  421. gpg: There is no indication that the signature belongs to the owner.
  422. Primary key fingerprint: 8ED3 96E3 7E38 D471 A005 30D3 A955 3245 FDE9 B739
  423. @end example
  424. You can then happily run
  425. @c TRANSLATORS: Do not translate this command
  426. @example sh
  427. $ guix package --install-from-file=my-hello.scm
  428. @end example
  429. You should now have @code{my-hello} in your profile!
  430. @c TRANSLATORS: Do not translate this command
  431. @example sh
  432. $ guix package --list-installed=my-hello
  433. my-hello 2.10 out
  434. /gnu/store/f1db2mfm8syb8qvc357c53slbvf1g9m9-my-hello-2.10
  435. @end example
  436. We've gone as far as we could without any knowledge of Scheme. Before moving
  437. on to more complex packages, now is the right time to brush up on your Scheme
  438. knowledge. @pxref{A Scheme Crash Course} to get up to speed.
  439. @node Setup
  440. @subsection Setup
  441. In the rest of this chapter we will rely on some basic Scheme
  442. programming knowledge. Now let's detail the different possible setups
  443. for working on Guix packages.
  444. There are several ways to set up a Guix packaging environment.
  445. We recommend you work directly on the Guix source checkout since it makes it
  446. easier for everyone to contribute to the project.
  447. But first, let's look at other possibilities.
  448. @node Local file
  449. @subsubsection Local file
  450. This is what we previously did with @samp{my-hello}. With the Scheme basics we've
  451. covered, we are now able to explain the leading chunks. As stated in @code{guix
  452. package --help}:
  453. @example
  454. -f, --install-from-file=FILE
  455. install the package that the code within FILE
  456. evaluates to
  457. @end example
  458. Thus the last expression @emph{must} return a package, which is the case in our
  459. earlier example.
  460. The @code{use-modules} expression tells which of the modules we need in the file.
  461. Modules are a collection of values and procedures. They are commonly called
  462. ``libraries'' or ``packages'' in other programming languages.
  463. @node @samp{GUIX_PACKAGE_PATH}
  464. @subsubsection @samp{GUIX_PACKAGE_PATH}
  465. @emph{Note: Starting from Guix 0.16, the more flexible Guix @dfn{channels} are the
  466. preferred way and supersede @samp{GUIX_PACKAGE_PATH}. See next section.}
  467. It can be tedious to specify the file from the command line instead of simply
  468. calling @code{guix package --install my-hello} as you would do with the official
  469. packages.
  470. Guix makes it possible to streamline the process by adding as many ``package
  471. declaration directories'' as you want.
  472. Create a directory, say @file{~/guix-packages} and add it to the @samp{GUIX_PACKAGE_PATH}
  473. environment variable:
  474. @example
  475. $ mkdir ~/guix-packages
  476. $ export GUIX_PACKAGE_PATH=~/guix-packages
  477. @end example
  478. To add several directories, separate them with a colon (@code{:}).
  479. Our previous @samp{my-hello} needs some adjustments though:
  480. @lisp
  481. (define-module (my-hello)
  482. #:use-module (guix licenses)
  483. #:use-module (guix packages)
  484. #:use-module (guix build-system gnu)
  485. #:use-module (guix download))
  486. (define-public my-hello
  487. (package
  488. (name "my-hello")
  489. (version "2.10")
  490. (source (origin
  491. (method url-fetch)
  492. (uri (string-append "mirror://gnu/hello/hello-" version
  493. ".tar.gz"))
  494. (sha256
  495. (base32
  496. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  497. (build-system gnu-build-system)
  498. (synopsis "Hello, Guix world: An example custom Guix package")
  499. (description
  500. "GNU Hello prints the message \"Hello, world!\" and then exits. It
  501. serves as an example of standard GNU coding practices. As such, it supports
  502. command-line arguments, multiple languages, and so on.")
  503. (home-page "https://www.gnu.org/software/hello/")
  504. (license gpl3+)))
  505. @end lisp
  506. Note that we have assigned the package value to an exported variable name with
  507. @code{define-public}. This is effectively assigning the package to the @code{my-hello}
  508. variable so that it can be referenced, among other as dependency of other
  509. packages.
  510. If you use @code{guix package --install-from-file=my-hello.scm} on the above file, it
  511. will fail because the last expression, @code{define-public}, does not return a
  512. package. If you want to use @code{define-public} in this use-case nonetheless, make
  513. sure the file ends with an evaluation of @code{my-hello}:
  514. @lisp
  515. ; ...
  516. (define-public my-hello
  517. ; ...
  518. )
  519. my-hello
  520. @end lisp
  521. This last example is not very typical.
  522. Now @samp{my-hello} should be part of the package collection like all other official
  523. packages. You can verify this with:
  524. @example
  525. $ guix package --show=my-hello
  526. @end example
  527. @node Guix channels
  528. @subsubsection Guix channels
  529. Guix 0.16 features channels, which is very similar to @samp{GUIX_PACKAGE_PATH} but
  530. provides better integration and provenance tracking. Channels are not
  531. necessarily local, they can be maintained as a public Git repository for
  532. instance. Of course, several channels can be used at the same time.
  533. @xref{Channels,,, guix, GNU Guix Reference Manual} for setup details.
  534. @node Direct checkout hacking
  535. @subsubsection Direct checkout hacking
  536. Working directly on the Guix project is recommended: it reduces the friction
  537. when the time comes to submit your changes upstream to let the community benefit
  538. from your hard work!
  539. Unlike most software distributions, the Guix repository holds in one place both
  540. the tooling (including the package manager) and the package definitions. This
  541. choice was made so that it would give developers the flexibility to modify the
  542. API without breakage by updating all packages at the same time. This reduces
  543. development inertia.
  544. Check out the official @uref{https://git-scm.com/, Git} repository:
  545. @example
  546. $ git clone https://git.savannah.gnu.org/git/guix.git
  547. @end example
  548. In the rest of this article, we use @samp{$GUIX_CHECKOUT} to refer to the location of
  549. the checkout.
  550. Follow the instructions in the manual (@pxref{Contributing,,, guix, GNU Guix
  551. Reference Manual}) to set up the repository environment.
  552. Once ready, you should be able to use the package definitions from the
  553. repository environment.
  554. Feel free to edit package definitions found in @samp{$GUIX_CHECKOUT/gnu/packages}.
  555. The @samp{$GUIX_CHECKOUT/pre-inst-env} script lets you use @samp{guix} over the package
  556. collection of the repository (@pxref{Running Guix Before It Is
  557. Installed,,, guix, GNU Guix Reference Manual}).
  558. @itemize
  559. @item
  560. Search packages, such as Ruby:
  561. @example
  562. $ cd $GUIX_CHECKOUT
  563. $ ./pre-inst-env guix package --list-available=ruby
  564. ruby 1.8.7-p374 out gnu/packages/ruby.scm:119:2
  565. ruby 2.1.6 out gnu/packages/ruby.scm:91:2
  566. ruby 2.2.2 out gnu/packages/ruby.scm:39:2
  567. @end example
  568. @item
  569. Build a package, here Ruby version 2.1:
  570. @example
  571. $ ./pre-inst-env guix build --keep-failed ruby@@2.1
  572. /gnu/store/c13v73jxmj2nir2xjqaz5259zywsa9zi-ruby-2.1.6
  573. @end example
  574. @item
  575. Install it to your user profile:
  576. @example
  577. $ ./pre-inst-env guix package --install ruby@@2.1
  578. @end example
  579. @item
  580. Check for common mistakes:
  581. @example
  582. $ ./pre-inst-env guix lint ruby@@2.1
  583. @end example
  584. @end itemize
  585. Guix strives at maintaining a high packaging standard; when contributing to the
  586. Guix project, remember to
  587. @itemize
  588. @item
  589. follow the coding style (@pxref{Coding Style,,, guix, GNU Guix Reference Manual}),
  590. @item
  591. and review the check list from the manual (@pxref{Submitting Patches,,, guix, GNU Guix Reference Manual}).
  592. @end itemize
  593. Once you are happy with the result, you are welcome to send your contribution to
  594. make it part of Guix. This process is also detailed in the manual. (@pxref{Contributing,,, guix, GNU Guix Reference Manual})
  595. It's a community effort so the more join in, the better Guix becomes!
  596. @node Extended example
  597. @subsection Extended example
  598. The above ``Hello World'' example is as simple as it goes. Packages can be more
  599. complex than that and Guix can handle more advanced scenarios. Let's look at
  600. another, more sophisticated package (slightly modified from the source):
  601. @lisp
  602. (define-module (gnu packages version-control)
  603. #:use-module ((guix licenses) #:prefix license:)
  604. #:use-module (guix utils)
  605. #:use-module (guix packages)
  606. #:use-module (guix git-download)
  607. #:use-module (guix build-system cmake)
  608. #:use-module (gnu packages ssh)
  609. #:use-module (gnu packages web)
  610. #:use-module (gnu packages pkg-config)
  611. #:use-module (gnu packages python)
  612. #:use-module (gnu packages compression)
  613. #:use-module (gnu packages tls))
  614. (define-public my-libgit2
  615. (let ((commit "e98d0a37c93574d2c6107bf7f31140b548c6a7bf")
  616. (revision "1"))
  617. (package
  618. (name "my-libgit2")
  619. (version (git-version "0.26.6" revision commit))
  620. (source (origin
  621. (method git-fetch)
  622. (uri (git-reference
  623. (url "https://github.com/libgit2/libgit2/")
  624. (commit commit)))
  625. (file-name (git-file-name name version))
  626. (sha256
  627. (base32
  628. "17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3"))
  629. (patches (search-patches "libgit2-mtime-0.patch"))
  630. (modules '((guix build utils)))
  631. ;; Remove bundled software.
  632. (snippet '(delete-file-recursively "deps"))))
  633. (build-system cmake-build-system)
  634. (outputs '("out" "debug"))
  635. (arguments
  636. `(#:tests? #true ; Run the test suite (this is the default)
  637. #:configure-flags '("-DUSE_SHA1DC=ON") ; SHA-1 collision detection
  638. #:phases
  639. (modify-phases %standard-phases
  640. (add-after 'unpack 'fix-hardcoded-paths
  641. (lambda _
  642. (substitute* "tests/repo/init.c"
  643. (("#!/bin/sh") (string-append "#!" (which "sh"))))
  644. (substitute* "tests/clar/fs.h"
  645. (("/bin/cp") (which "cp"))
  646. (("/bin/rm") (which "rm")))))
  647. ;; Run checks more verbosely.
  648. (replace 'check
  649. (lambda _ (invoke "./libgit2_clar" "-v" "-Q")))
  650. (add-after 'unpack 'make-files-writable-for-tests
  651. (lambda _ (for-each make-file-writable (find-files "." ".*")))))))
  652. (inputs
  653. (list libssh2 http-parser python-wrapper))
  654. (native-inputs
  655. (list pkg-config))
  656. (propagated-inputs
  657. ;; These two libraries are in 'Requires.private' in libgit2.pc.
  658. (list openssl zlib))
  659. (home-page "https://libgit2.github.com/")
  660. (synopsis "Library providing Git core methods")
  661. (description
  662. "Libgit2 is a portable, pure C implementation of the Git core methods
  663. provided as a re-entrant linkable library with a solid API, allowing you to
  664. write native speed custom Git applications in any language with bindings.")
  665. ;; GPLv2 with linking exception
  666. (license license:gpl2))))
  667. @end lisp
  668. (In those cases were you only want to tweak a few fields from a package
  669. definition, you should rely on inheritance instead of copy-pasting everything.
  670. See below.)
  671. Let's discuss those fields in depth.
  672. @subsubsection @code{git-fetch} method
  673. Unlike the @code{url-fetch} method, @code{git-fetch} expects a @code{git-reference} which takes
  674. a Git repository and a commit. The commit can be any Git reference such as
  675. tags, so if the @code{version} is tagged, then it can be used directly. Sometimes
  676. the tag is prefixed with a @code{v}, in which case you'd use @code{(commit (string-append
  677. "v" version))}.
  678. To ensure that the source code from the Git repository is stored in a
  679. directory with a descriptive name, we use @code{(file-name (git-file-name name
  680. version))}.
  681. The @code{git-version} procedure can be used to derive the
  682. version when packaging programs for a specific commit, following the
  683. Guix contributor guidelines (@pxref{Version Numbers,,, guix, GNU Guix
  684. Reference Manual}).
  685. How does one obtain the @code{sha256} hash that's in there, you ask? By
  686. invoking @command{guix hash} on a checkout of the desired commit, along
  687. these lines:
  688. @example
  689. git clone https://github.com/libgit2/libgit2/
  690. cd libgit2
  691. git checkout v0.26.6
  692. guix hash -rx .
  693. @end example
  694. @command{guix hash -rx} computes a SHA256 hash over the whole directory,
  695. excluding the @file{.git} sub-directory (@pxref{Invoking guix hash,,,
  696. guix, GNU Guix Reference Manual}).
  697. In the future, @command{guix download} will hopefully be able to do
  698. these steps for you, just like it does for regular downloads.
  699. @subsubsection Snippets
  700. Snippets are quoted (i.e. non-evaluated) Scheme code that are a means of patching
  701. the source. They are a Guix-y alternative to the traditional @file{.patch} files.
  702. Because of the quote, the code in only evaluated when passed to the Guix daemon
  703. for building. There can be as many snippets as needed.
  704. Snippets might need additional Guile modules which can be imported from the
  705. @code{modules} field.
  706. @subsubsection Inputs
  707. There are 3 different input types. In short:
  708. @table @asis
  709. @item native-inputs
  710. Required for building but not runtime -- installing a package
  711. through a substitute won't install these inputs.
  712. @item inputs
  713. Installed in the store but not in the profile, as well as being
  714. present at build time.
  715. @item propagated-inputs
  716. Installed in the store and in the profile, as well as
  717. being present at build time.
  718. @end table
  719. @xref{Package Reference,,, guix, GNU Guix Reference Manual} for more details.
  720. The distinction between the various inputs is important: if a dependency can be
  721. handled as an @emph{input} instead of a @emph{propagated input}, it should be done so, or
  722. else it ``pollutes'' the user profile for no good reason.
  723. For instance, a user installing a graphical program that depends on a
  724. command line tool might only be interested in the graphical part, so there is no
  725. need to force the command line tool into the user profile. The dependency is a
  726. concern to the package, not to the user. @emph{Inputs} make it possible to handle
  727. dependencies without bugging the user by adding undesired executable files (or
  728. libraries) to their profile.
  729. Same goes for @emph{native-inputs}: once the program is installed, build-time
  730. dependencies can be safely garbage-collected.
  731. It also matters when a substitute is available, in which case only the @emph{inputs}
  732. and @emph{propagated inputs} will be fetched: the @emph{native inputs} are not required to
  733. install a package from a substitute.
  734. @quotation Note
  735. You may see here and there snippets where package inputs are written
  736. quite differently, like so:
  737. @lisp
  738. ;; The "old style" for inputs.
  739. (inputs
  740. `(("libssh2" ,libssh2)
  741. ("http-parser" ,http-parser)
  742. ("python" ,python-wrapper)))
  743. @end lisp
  744. This is the ``old style'', where each input in the list is explicitly
  745. given a label (a string). It is still supported but we recommend using
  746. the style above instead. @xref{package Reference,,, guix, GNU Guix
  747. Reference Manual}, for more info.
  748. @end quotation
  749. @subsubsection Outputs
  750. Just like how a package can have multiple inputs, it can also produce multiple
  751. outputs.
  752. Each output corresponds to a separate directory in the store.
  753. The user can choose which output to install; this is useful to save space or
  754. to avoid polluting the user profile with unwanted executables or libraries.
  755. Output separation is optional. When the @code{outputs} field is left out, the
  756. default and only output (the complete package) is referred to as @code{"out"}.
  757. Typical separate output names include @code{debug} and @code{doc}.
  758. It's advised to separate outputs only when you've shown it's worth it: if the
  759. output size is significant (compare with @code{guix size}) or in case the package is
  760. modular.
  761. @subsubsection Build system arguments
  762. The @code{arguments} is a keyword-value list used to configure the build process.
  763. The simplest argument @code{#:tests?} can be used to disable the test suite when
  764. building the package. This is mostly useful when the package does not feature
  765. any test suite. It's strongly recommended to keep the test suite on if there is
  766. one.
  767. Another common argument is @code{:make-flags}, which specifies a list of flags to
  768. append when running make, as you would from the command line. For instance, the
  769. following flags
  770. @lisp
  771. #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))
  772. "CC=gcc")
  773. @end lisp
  774. translate into
  775. @example
  776. $ make CC=gcc prefix=/gnu/store/...-<out>
  777. @end example
  778. This sets the C compiler to @code{gcc} and the @code{prefix} variable (the installation
  779. directory in Make parlance) to @code{(assoc-ref %outputs "out")}, which is a build-stage
  780. global variable pointing to the destination directory in the store (something like
  781. @file{/gnu/store/...-my-libgit2-20180408}).
  782. Similarly, it's possible to set the configure flags:
  783. @lisp
  784. #:configure-flags '("-DUSE_SHA1DC=ON")
  785. @end lisp
  786. The @code{%build-inputs} variable is also generated in scope. It's an association
  787. table that maps the input names to their store directories.
  788. The @code{phases} keyword lists the sequential steps of the build system. Typically
  789. phases include @code{unpack}, @code{configure}, @code{build}, @code{install} and @code{check}. To know
  790. more about those phases, you need to work out the appropriate build system
  791. definition in @samp{$GUIX_CHECKOUT/guix/build/gnu-build-system.scm}:
  792. @lisp
  793. (define %standard-phases
  794. ;; Standard build phases, as a list of symbol/procedure pairs.
  795. (let-syntax ((phases (syntax-rules ()
  796. ((_ p ...) `((p . ,p) ...)))))
  797. (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack
  798. bootstrap
  799. patch-usr-bin-file
  800. patch-source-shebangs configure patch-generated-file-shebangs
  801. build check install
  802. patch-shebangs strip
  803. validate-runpath
  804. validate-documentation-location
  805. delete-info-dir-file
  806. patch-dot-desktop-files
  807. install-license-files
  808. reset-gzip-timestamps
  809. compress-documentation)))
  810. @end lisp
  811. Or from the REPL:
  812. @lisp
  813. (add-to-load-path "/path/to/guix/checkout")
  814. ,use (guix build gnu-build-system)
  815. (map first %standard-phases)
  816. @result{} (set-SOURCE-DATE-EPOCH set-paths install-locale unpack bootstrap patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs build check install patch-shebangs strip validate-runpath validate-documentation-location delete-info-dir-file patch-dot-desktop-files install-license-files reset-gzip-timestamps compress-documentation)
  817. @end lisp
  818. If you want to know more about what happens during those phases, consult the
  819. associated procedures.
  820. For instance, as of this writing the definition of @code{unpack} for the GNU build
  821. system is:
  822. @lisp
  823. (define* (unpack #:key source #:allow-other-keys)
  824. "Unpack SOURCE in the working directory, and change directory within the
  825. source. When SOURCE is a directory, copy it in a sub-directory of the current
  826. working directory."
  827. (if (file-is-directory? source)
  828. (begin
  829. (mkdir "source")
  830. (chdir "source")
  831. ;; Preserve timestamps (set to the Epoch) on the copied tree so that
  832. ;; things work deterministically.
  833. (copy-recursively source "."
  834. #:keep-mtime? #true))
  835. (begin
  836. (if (string-suffix? ".zip" source)
  837. (invoke "unzip" source)
  838. (invoke "tar" "xvf" source))
  839. (chdir (first-subdirectory "."))))
  840. #true)
  841. @end lisp
  842. Note the @code{chdir} call: it changes the working directory to where the source was
  843. unpacked.
  844. Thus every phase following the @code{unpack} will use the source as a working
  845. directory, which is why we can directly work on the source files.
  846. That is to say, unless a later phase changes the working directory to something
  847. else.
  848. We modify the list of @code{%standard-phases} of the build system with the
  849. @code{modify-phases} macro as per the list of specified modifications, which may have
  850. the following forms:
  851. @itemize
  852. @item
  853. @code{(add-before @var{phase} @var{new-phase} @var{procedure})}: Run @var{procedure} named @var{new-phase} before @var{phase}.
  854. @item
  855. @code{(add-after @var{phase} @var{new-phase} @var{procedure})}: Same, but afterwards.
  856. @item
  857. @code{(replace @var{phase} @var{procedure})}.
  858. @item
  859. @code{(delete @var{phase})}.
  860. @end itemize
  861. The @var{procedure} supports the keyword arguments @code{inputs} and @code{outputs}. Each
  862. input (whether @emph{native}, @emph{propagated} or not) and output directory is referenced
  863. by their name in those variables. Thus @code{(assoc-ref outputs "out")} is the store
  864. directory of the main output of the package. A phase procedure may look like
  865. this:
  866. @lisp
  867. (lambda* (#:key inputs outputs #:allow-other-keys)
  868. (let ((bash-directory (assoc-ref inputs "bash"))
  869. (output-directory (assoc-ref outputs "out"))
  870. (doc-directory (assoc-ref outputs "doc")))
  871. ;; ...
  872. #true))
  873. @end lisp
  874. The procedure must return @code{#true} on success. It's brittle to rely on the return
  875. value of the last expression used to tweak the phase because there is no
  876. guarantee it would be a @code{#true}. Hence the trailing @code{#true} to ensure the right value
  877. is returned on success.
  878. @subsubsection Code staging
  879. The astute reader may have noticed the quasi-quote and comma syntax in the
  880. argument field. Indeed, the build code in the package declaration should not be
  881. evaluated on the client side, but only when passed to the Guix daemon. This
  882. mechanism of passing code around two running processes is called @uref{https://arxiv.org/abs/1709.00833, code staging}.
  883. @subsubsection Utility functions
  884. When customizing @code{phases}, we often need to write code that mimics the
  885. equivalent system invocations (@code{make}, @code{mkdir}, @code{cp}, etc.)@: commonly used during
  886. regular ``Unix-style'' installations.
  887. Some like @code{chmod} are native to Guile.
  888. @xref{,,, guile, Guile reference manual} for a complete list.
  889. Guix provides additional helper functions which prove especially handy in the
  890. context of package management.
  891. Some of those functions can be found in
  892. @samp{$GUIX_CHECKOUT/guix/guix/build/utils.scm}. Most of them mirror the behaviour
  893. of the traditional Unix system commands:
  894. @table @code
  895. @item which
  896. Like the @samp{which} system command.
  897. @item find-files
  898. Akin to the @samp{find} system command.
  899. @item mkdir-p
  900. Like @samp{mkdir -p}, which creates all parents as needed.
  901. @item install-file
  902. Similar to @samp{install} when installing a file to a (possibly
  903. non-existing) directory. Guile has @code{copy-file} which works
  904. like @samp{cp}.
  905. @item copy-recursively
  906. Like @samp{cp -r}.
  907. @item delete-file-recursively
  908. Like @samp{rm -rf}.
  909. @item invoke
  910. Run an executable. This should be used instead of @code{system*}.
  911. @item with-directory-excursion
  912. Run the body in a different working directory,
  913. then restore the previous working directory.
  914. @item substitute*
  915. A ``@command{sed}-like'' function.
  916. @end table
  917. @xref{Build Utilities,,, guix, GNU Guix Reference Manual}, for more
  918. information on these utilities.
  919. @subsubsection Module prefix
  920. The license in our last example needs a prefix: this is because of how the
  921. @code{license} module was imported in the package, as @code{#:use-module ((guix licenses)
  922. #:prefix license:)}. The Guile module import mechanism
  923. (@pxref{Using Guile Modules,,, guile, Guile reference manual})
  924. gives the user full control over namespacing: this is needed to avoid
  925. clashes between, say, the
  926. @samp{zlib} variable from @samp{licenses.scm} (a @emph{license} value) and the @samp{zlib} variable
  927. from @samp{compression.scm} (a @emph{package} value).
  928. @node Other build systems
  929. @subsection Other build systems
  930. What we've seen so far covers the majority of packages using a build system
  931. other than the @code{trivial-build-system}. The latter does not automate anything
  932. and leaves you to build everything manually. This can be more demanding and we
  933. won't cover it here for now, but thankfully it is rarely necessary to fall back
  934. on this system.
  935. For the other build systems, such as ASDF, Emacs, Perl, Ruby and many more, the
  936. process is very similar to the GNU build system except for a few specialized
  937. arguments.
  938. @xref{Build Systems,,, guix, GNU Guix Reference Manual}, for more
  939. information on build systems, or check the source code in the
  940. @samp{$GUIX_CHECKOUT/guix/build} and
  941. @samp{$GUIX_CHECKOUT/guix/build-system} directories.
  942. @node Programmable and automated package definition
  943. @subsection Programmable and automated package definition
  944. We can't repeat it enough: having a full-fledged programming language at hand
  945. empowers us in ways that reach far beyond traditional package management.
  946. Let's illustrate this with some awesome features of Guix!
  947. @node Recursive importers
  948. @subsubsection Recursive importers
  949. You might find some build systems good enough that there is little to do at all
  950. to write a package, to the point that it becomes repetitive and tedious after a
  951. while. A @emph{raison d'être} of computers is to replace human beings at those
  952. boring tasks. So let's tell Guix to do this for us and create the package
  953. definition of an R package from CRAN (the output is trimmed for conciseness):
  954. @example
  955. $ guix import cran --recursive walrus
  956. (define-public r-mc2d
  957. ; ...
  958. (license gpl2+)))
  959. (define-public r-jmvcore
  960. ; ...
  961. (license gpl2+)))
  962. (define-public r-wrs2
  963. ; ...
  964. (license gpl3)))
  965. (define-public r-walrus
  966. (package
  967. (name "r-walrus")
  968. (version "1.0.3")
  969. (source
  970. (origin
  971. (method url-fetch)
  972. (uri (cran-uri "walrus" version))
  973. (sha256
  974. (base32
  975. "1nk2glcvy4hyksl5ipq2mz8jy4fss90hx6cq98m3w96kzjni6jjj"))))
  976. (build-system r-build-system)
  977. (propagated-inputs
  978. (list r-ggplot2 r-jmvcore r-r6 r-wrs2))
  979. (home-page "https://github.com/jamovi/walrus")
  980. (synopsis "Robust Statistical Methods")
  981. (description
  982. "This package provides a toolbox of common robust statistical
  983. tests, including robust descriptives, robust t-tests, and robust ANOVA.
  984. It is also available as a module for 'jamovi' (see
  985. <https://www.jamovi.org> for more information). Walrus is based on the
  986. WRS2 package by Patrick Mair, which is in turn based on the scripts and
  987. work of Rand Wilcox. These analyses are described in depth in the book
  988. 'Introduction to Robust Estimation & Hypothesis Testing'.")
  989. (license gpl3)))
  990. @end example
  991. The recursive importer won't import packages for which Guix already has package
  992. definitions, except for the very first.
  993. Not all applications can be packaged this way, only those relying on a select
  994. number of supported systems. Read about the full list of importers in
  995. the guix import section of the manual
  996. (@pxref{Invoking guix import,,, guix, GNU Guix Reference Manual}).
  997. @node Automatic update
  998. @subsubsection Automatic update
  999. Guix can be smart enough to check for updates on systems it knows. It can
  1000. report outdated package definitions with
  1001. @example
  1002. $ guix refresh hello
  1003. @end example
  1004. In most cases, updating a package to a newer version requires little more than
  1005. changing the version number and the checksum. Guix can do that automatically as
  1006. well:
  1007. @example
  1008. $ guix refresh hello --update
  1009. @end example
  1010. @node Inheritance
  1011. @subsubsection Inheritance
  1012. If you've started browsing the existing package definitions, you might have
  1013. noticed that a significant number of them have a @code{inherit} field:
  1014. @lisp
  1015. (define-public adwaita-icon-theme
  1016. (package (inherit gnome-icon-theme)
  1017. (name "adwaita-icon-theme")
  1018. (version "3.26.1")
  1019. (source (origin
  1020. (method url-fetch)
  1021. (uri (string-append "mirror://gnome/sources/" name "/"
  1022. (version-major+minor version) "/"
  1023. name "-" version ".tar.xz"))
  1024. (sha256
  1025. (base32
  1026. "17fpahgh5dyckgz7rwqvzgnhx53cx9kr2xw0szprc6bnqy977fi8"))))
  1027. (native-inputs (list `(,gtk+ "bin")))))
  1028. @end lisp
  1029. All unspecified fields are inherited from the parent package. This is very
  1030. convenient to create alternative packages, for instance with different source,
  1031. version or compilation options.
  1032. @node Getting help
  1033. @subsection Getting help
  1034. Sadly, some applications can be tough to package. Sometimes they need a patch to
  1035. work with the non-standard file system hierarchy enforced by the store.
  1036. Sometimes the tests won't run properly. (They can be skipped but this is not
  1037. recommended.) Other times the resulting package won't be reproducible.
  1038. Should you be stuck, unable to figure out how to fix any sort of packaging
  1039. issue, don't hesitate to ask the community for help.
  1040. See the @uref{https://www.gnu.org/software/guix/contact/, Guix homepage} for information on the mailing lists, IRC, etc.
  1041. @node Conclusion
  1042. @subsection Conclusion
  1043. This tutorial was a showcase of the sophisticated package management that Guix
  1044. boasts. At this point we have mostly restricted this introduction to the
  1045. @code{gnu-build-system} which is a core abstraction layer on which more advanced
  1046. abstractions are based.
  1047. Where do we go from here? Next we ought to dissect the innards of the build
  1048. system by removing all abstractions, using the @code{trivial-build-system}: this
  1049. should give us a thorough understanding of the process before investigating some
  1050. more advanced packaging techniques and edge cases.
  1051. Other features worth exploring are the interactive editing and debugging
  1052. capabilities of Guix provided by the Guile REPL@.
  1053. Those fancy features are completely optional and can wait; now is a good time
  1054. to take a well-deserved break. With what we've introduced here you should be
  1055. well armed to package lots of programs. You can get started right away and
  1056. hopefully we will see your contributions soon!
  1057. @node References
  1058. @subsection References
  1059. @itemize
  1060. @item
  1061. The @uref{https://www.gnu.org/software/guix/manual/en/html_node/Defining-Packages.html, package reference in the manual}
  1062. @item
  1063. @uref{https://gitlab.com/pjotrp/guix-notes/blob/master/HACKING.org, Pjotr’s hacking guide to GNU Guix}
  1064. @item
  1065. @uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, ``GNU Guix: Package without a scheme!''}, by Andreas Enge
  1066. @end itemize
  1067. @c *********************************************************************
  1068. @node System Configuration
  1069. @chapter System Configuration
  1070. Guix offers a flexible language for declaratively configuring your Guix
  1071. System. This flexibility can at times be overwhelming. The purpose of this
  1072. chapter is to demonstrate some advanced configuration concepts.
  1073. @pxref{System Configuration,,, guix, GNU Guix Reference Manual} for a complete
  1074. reference.
  1075. @menu
  1076. * Auto-Login to a Specific TTY:: Automatically Login a User to a Specific TTY
  1077. * Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System.
  1078. * Guix System Image API:: Customizing images to target specific platforms.
  1079. * Connecting to Wireguard VPN:: Connecting to a Wireguard VPN.
  1080. * Customizing a Window Manager:: Handle customization of a Window manager on Guix System.
  1081. * Running Guix on a Linode Server:: Running Guix on a Linode Server
  1082. * Setting up a bind mount:: Setting up a bind mount in the file-systems definition.
  1083. * Getting substitutes from Tor:: Configuring Guix daemon to get substitutes through Tor.
  1084. * Setting up NGINX with Lua:: Configuring NGINX web-server to load Lua modules.
  1085. @end menu
  1086. @node Auto-Login to a Specific TTY
  1087. @section Auto-Login to a Specific TTY
  1088. While the Guix manual explains auto-login one user to @emph{all} TTYs (
  1089. @pxref{auto-login to TTY,,, guix, GNU Guix Reference Manual}), some
  1090. might prefer a situation, in which one user is logged into one TTY with
  1091. the other TTYs either configured to login different users or no one at
  1092. all. Note that one can auto-login one user to any TTY, but it is
  1093. usually advisable to avoid @code{tty1}, which, by default, is used to
  1094. log warnings and errors.
  1095. Here is how one might set up auto login for one user to one tty:
  1096. @lisp
  1097. (define (auto-login-to-tty config tty user)
  1098. (if (string=? tty (mingetty-configuration-tty config))
  1099. (mingetty-configuration
  1100. (inherit config)
  1101. (auto-login user))
  1102. config))
  1103. (define %my-services
  1104. (modify-services %base-services
  1105. ;; @dots{}
  1106. (mingetty-service-type config =>
  1107. (auto-login-to-tty
  1108. config "tty3" "alice"))))
  1109. (operating-system
  1110. ;; @dots{}
  1111. (services %my-services))
  1112. @end lisp
  1113. One could also @code{compose} (@pxref{Higher-Order Functions,,, guile,
  1114. The Guile Reference Manual}) @code{auto-login-to-tty} to login multiple
  1115. users to multiple ttys.
  1116. Finally, here is a note of caution. Setting up auto login to a TTY,
  1117. means that anyone can turn on your computer and run commands as your
  1118. regular user.
  1119. However, if you have an encrypted root partition, and thus already need
  1120. to enter a passphrase when the system boots, auto-login might be a
  1121. convenient option.
  1122. @node Customizing the Kernel
  1123. @section Customizing the Kernel
  1124. Guix is, at its core, a source based distribution with substitutes
  1125. (@pxref{Substitutes,,, guix, GNU Guix Reference Manual}), and as such building
  1126. packages from their source code is an expected part of regular package
  1127. installations and upgrades. Given this starting point, it makes sense that
  1128. efforts are made to reduce the amount of time spent compiling packages, and
  1129. recent changes and upgrades to the building and distribution of substitutes
  1130. continues to be a topic of discussion within Guix.
  1131. The kernel, while not requiring an overabundance of RAM to build, does take a
  1132. rather long time on an average machine. The official kernel configuration, as
  1133. is the case with many GNU/Linux distributions, errs on the side of
  1134. inclusiveness, and this is really what causes the build to take such a long
  1135. time when the kernel is built from source.
  1136. The Linux kernel, however, can also just be described as a regular old
  1137. package, and as such can be customized just like any other package. The
  1138. procedure is a little bit different, although this is primarily due to the
  1139. nature of how the package definition is written.
  1140. The @code{linux-libre} kernel package definition is actually a procedure which
  1141. creates a package.
  1142. @lisp
  1143. (define* (make-linux-libre* version gnu-revision source supported-systems
  1144. #:key
  1145. (extra-version #f)
  1146. ;; A function that takes an arch and a variant.
  1147. ;; See kernel-config for an example.
  1148. (configuration-file #f)
  1149. (defconfig "defconfig")
  1150. (extra-options %default-extra-linux-options))
  1151. ...)
  1152. @end lisp
  1153. The current @code{linux-libre} package is for the 5.15.x series, and is
  1154. declared like this:
  1155. @lisp
  1156. (define-public linux-libre-5.15
  1157. (make-linux-libre* linux-libre-5.15-version
  1158. linux-libre-5.15-gnu-revision
  1159. linux-libre-5.15-source
  1160. '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux")
  1161. #:configuration-file kernel-config))
  1162. @end lisp
  1163. Any keys which are not assigned values inherit their default value from the
  1164. @code{make-linux-libre} definition. When comparing the two snippets above,
  1165. notice the code comment that refers to @code{#:configuration-file}. Because of
  1166. this, it is not actually easy to include a custom kernel configuration from the
  1167. definition, but don't worry, there are other ways to work with what we do have.
  1168. There are two ways to create a kernel with a custom kernel configuration. The
  1169. first is to provide a standard @file{.config} file during the build process by
  1170. including an actual @file{.config} file as a native input to our custom
  1171. kernel. The following is a snippet from the custom @code{'configure} phase of
  1172. the @code{make-linux-libre} package definition:
  1173. @lisp
  1174. (let ((build (assoc-ref %standard-phases 'build))
  1175. (config (assoc-ref (or native-inputs inputs) "kconfig")))
  1176. ;; Use a custom kernel configuration file or a default
  1177. ;; configuration file.
  1178. (if config
  1179. (begin
  1180. (copy-file config ".config")
  1181. (chmod ".config" #o666))
  1182. (invoke "make" ,defconfig)))
  1183. @end lisp
  1184. Below is a sample kernel package. The @code{linux-libre} package is nothing
  1185. special and can be inherited from and have its fields overridden like any
  1186. other package:
  1187. @lisp
  1188. (define-public linux-libre/E2140
  1189. (package
  1190. (inherit linux-libre)
  1191. (native-inputs
  1192. `(("kconfig" ,(local-file "E2140.config"))
  1193. ,@@(alist-delete "kconfig"
  1194. (package-native-inputs linux-libre))))))
  1195. @end lisp
  1196. In the same directory as the file defining @code{linux-libre-E2140} is a file
  1197. named @file{E2140.config}, which is an actual kernel configuration file. The
  1198. @code{defconfig} keyword of @code{make-linux-libre} is left blank here, so the
  1199. only kernel configuration in the package is the one which was included in the
  1200. @code{native-inputs} field.
  1201. The second way to create a custom kernel is to pass a new value to the
  1202. @code{extra-options} keyword of the @code{make-linux-libre} procedure. The
  1203. @code{extra-options} keyword works with another function defined right below
  1204. it:
  1205. @lisp
  1206. (define %default-extra-linux-options
  1207. `(;; https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00039.html
  1208. ("CONFIG_DEVPTS_MULTIPLE_INSTANCES" . #true)
  1209. ;; Modules required for initrd:
  1210. ("CONFIG_NET_9P" . m)
  1211. ("CONFIG_NET_9P_VIRTIO" . m)
  1212. ("CONFIG_VIRTIO_BLK" . m)
  1213. ("CONFIG_VIRTIO_NET" . m)
  1214. ("CONFIG_VIRTIO_PCI" . m)
  1215. ("CONFIG_VIRTIO_BALLOON" . m)
  1216. ("CONFIG_VIRTIO_MMIO" . m)
  1217. ("CONFIG_FUSE_FS" . m)
  1218. ("CONFIG_CIFS" . m)
  1219. ("CONFIG_9P_FS" . m)))
  1220. (define (config->string options)
  1221. (string-join (map (match-lambda
  1222. ((option . 'm)
  1223. (string-append option "=m"))
  1224. ((option . #true)
  1225. (string-append option "=y"))
  1226. ((option . #false)
  1227. (string-append option "=n")))
  1228. options)
  1229. "\n"))
  1230. @end lisp
  1231. And in the custom configure script from the `make-linux-libre` package:
  1232. @lisp
  1233. ;; Appending works even when the option wasn't in the
  1234. ;; file. The last one prevails if duplicated.
  1235. (let ((port (open-file ".config" "a"))
  1236. (extra-configuration ,(config->string extra-options)))
  1237. (display extra-configuration port)
  1238. (close-port port))
  1239. (invoke "make" "oldconfig")
  1240. @end lisp
  1241. So by not providing a configuration-file the @file{.config} starts blank, and
  1242. then we write into it the collection of flags that we want. Here's another
  1243. custom kernel:
  1244. @lisp
  1245. (define %macbook41-full-config
  1246. (append %macbook41-config-options
  1247. %file-systems
  1248. %efi-support
  1249. %emulation
  1250. (@@@@ (gnu packages linux) %default-extra-linux-options)))
  1251. (define-public linux-libre-macbook41
  1252. ;; XXX: Access the internal 'make-linux-libre*' procedure, which is
  1253. ;; private and unexported, and is liable to change in the future.
  1254. ((@@@@ (gnu packages linux) make-linux-libre*)
  1255. (@@@@ (gnu packages linux) linux-libre-version)
  1256. (@@@@ (gnu packages linux) linux-libre-gnu-revision)
  1257. (@@@@ (gnu packages linux) linux-libre-source)
  1258. '("x86_64-linux")
  1259. #:extra-version "macbook41"
  1260. #:extra-options %macbook41-config-options))
  1261. @end lisp
  1262. In the above example @code{%file-systems} is a collection of flags enabling
  1263. different file system support, @code{%efi-support} enables EFI support and
  1264. @code{%emulation} enables a x86_64-linux machine to act in 32-bit mode also.
  1265. @code{%default-extra-linux-options} are the ones quoted above, which had to be
  1266. added in since they were replaced in the @code{extra-options} keyword.
  1267. This all sounds like it should be doable, but how does one even know which
  1268. modules are required for a particular system? Two places that can be helpful
  1269. in trying to answer this question is the
  1270. @uref{https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel, Gentoo
  1271. Handbook} and the
  1272. @uref{https://www.kernel.org/doc/html/latest/admin-guide/README.html?highlight=localmodconfig,
  1273. documentation from the kernel itself}. From the kernel documentation, it
  1274. seems that @code{make localmodconfig} is the command we want.
  1275. In order to actually run @code{make localmodconfig} we first need to get and
  1276. unpack the kernel source code:
  1277. @example shell
  1278. tar xf $(guix build linux-libre --source)
  1279. @end example
  1280. Once inside the directory containing the source code run @code{touch .config}
  1281. to create an initial, empty @file{.config} to start with. @code{make
  1282. localmodconfig} works by seeing what you already have in @file{.config} and
  1283. letting you know what you're missing. If the file is blank then you're
  1284. missing everything. The next step is to run:
  1285. @example shell
  1286. guix environment linux-libre -- make localmodconfig
  1287. @end example
  1288. and note the output. Do note that the @file{.config} file is still empty.
  1289. The output generally contains two types of warnings. The first start with
  1290. "WARNING" and can actually be ignored in our case. The second read:
  1291. @example shell
  1292. module pcspkr did not have configs CONFIG_INPUT_PCSPKR
  1293. @end example
  1294. For each of these lines, copy the @code{CONFIG_XXXX_XXXX} portion into the
  1295. @file{.config} in the directory, and append @code{=m}, so in the end it looks
  1296. like this:
  1297. @example shell
  1298. CONFIG_INPUT_PCSPKR=m
  1299. CONFIG_VIRTIO=m
  1300. @end example
  1301. After copying all the configuration options, run @code{make localmodconfig}
  1302. again to make sure that you don't have any output starting with ``module''.
  1303. After all of these machine specific modules there are a couple more left that
  1304. are also needed. @code{CONFIG_MODULES} is necessary so that you can build and
  1305. load modules separately and not have everything built into the kernel.
  1306. @code{CONFIG_BLK_DEV_SD} is required for reading from hard drives. It is
  1307. possible that there are other modules which you will need.
  1308. This post does not aim to be a guide to configuring your own kernel however,
  1309. so if you do decide to build a custom kernel you'll have to seek out other
  1310. guides to create a kernel which is just right for your needs.
  1311. The second way to setup the kernel configuration makes more use of Guix's
  1312. features and allows you to share configuration segments between different
  1313. kernels. For example, all machines using EFI to boot have a number of EFI
  1314. configuration flags that they need. It is likely that all the kernels will
  1315. share a list of file systems to support. By using variables it is easier to
  1316. see at a glance what features are enabled and to make sure you don't have
  1317. features in one kernel but missing in another.
  1318. Left undiscussed however, is Guix's initrd and its customization. It is
  1319. likely that you'll need to modify the initrd on a machine using a custom
  1320. kernel, since certain modules which are expected to be built may not be
  1321. available for inclusion into the initrd.
  1322. @node Guix System Image API
  1323. @section Guix System Image API
  1324. Historically, Guix System is centered around an @code{operating-system}
  1325. structure. This structure contains various fields ranging from the
  1326. bootloader and kernel declaration to the services to install.
  1327. Depending on the target machine, that can go from a standard
  1328. @code{x86_64} machine to a small ARM single board computer such as the
  1329. Pine64, the image constraints can vary a lot. The hardware
  1330. manufacturers will impose different image formats with various partition
  1331. sizes and offsets.
  1332. To create images suitable for all those machines, a new abstraction is
  1333. necessary: that's the goal of the @code{image} record. This record
  1334. contains all the required information to be transformed into a
  1335. standalone image, that can be directly booted on any target machine.
  1336. @lisp
  1337. (define-record-type* <image>
  1338. image make-image
  1339. image?
  1340. (name image-name ;symbol
  1341. (default #f))
  1342. (format image-format) ;symbol
  1343. (target image-target
  1344. (default #f))
  1345. (size image-size ;size in bytes as integer
  1346. (default 'guess))
  1347. (operating-system image-operating-system ;<operating-system>
  1348. (default #f))
  1349. (partitions image-partitions ;list of <partition>
  1350. (default '()))
  1351. (compression? image-compression? ;boolean
  1352. (default #t))
  1353. (volatile-root? image-volatile-root? ;boolean
  1354. (default #t))
  1355. (substitutable? image-substitutable? ;boolean
  1356. (default #t)))
  1357. @end lisp
  1358. This record contains the operating-system to instantiate. The
  1359. @code{format} field defines the image type and can be @code{efi-raw},
  1360. @code{qcow2} or @code{iso9660} for instance. In the future, it could be
  1361. extended to @code{docker} or other image types.
  1362. A new directory in the Guix sources is dedicated to images definition. For now
  1363. there are four files:
  1364. @itemize @bullet
  1365. @item @file{gnu/system/images/hurd.scm}
  1366. @item @file{gnu/system/images/pine64.scm}
  1367. @item @file{gnu/system/images/novena.scm}
  1368. @item @file{gnu/system/images/pinebook-pro.scm}
  1369. @end itemize
  1370. Let's have a look to @file{pine64.scm}. It contains the
  1371. @code{pine64-barebones-os} variable which is a minimal definition of an
  1372. operating-system dedicated to the @b{Pine A64 LTS} board.
  1373. @lisp
  1374. (define pine64-barebones-os
  1375. (operating-system
  1376. (host-name "vignemale")
  1377. (timezone "Europe/Paris")
  1378. (locale "en_US.utf8")
  1379. (bootloader (bootloader-configuration
  1380. (bootloader u-boot-pine64-lts-bootloader)
  1381. (targets '("/dev/vda"))))
  1382. (initrd-modules '())
  1383. (kernel linux-libre-arm64-generic)
  1384. (file-systems (cons (file-system
  1385. (device (file-system-label "my-root"))
  1386. (mount-point "/")
  1387. (type "ext4"))
  1388. %base-file-systems))
  1389. (services (cons (service agetty-service-type
  1390. (agetty-configuration
  1391. (extra-options '("-L")) ; no carrier detect
  1392. (baud-rate "115200")
  1393. (term "vt100")
  1394. (tty "ttyS0")))
  1395. %base-services))))
  1396. @end lisp
  1397. The @code{kernel} and @code{bootloader} fields are pointing to packages
  1398. dedicated to this board.
  1399. Right below, the @code{pine64-image-type} variable is also defined.
  1400. @lisp
  1401. (define pine64-image-type
  1402. (image-type
  1403. (name 'pine64-raw)
  1404. (constructor (cut image-with-os arm64-disk-image <>))))
  1405. @end lisp
  1406. It's using a record we haven't talked about yet, the @code{image-type} record,
  1407. defined this way:
  1408. @lisp
  1409. (define-record-type* <image-type>
  1410. image-type make-image-type
  1411. image-type?
  1412. (name image-type-name) ;symbol
  1413. (constructor image-type-constructor)) ;<operating-system> -> <image>
  1414. @end lisp
  1415. The main purpose of this record is to associate a name to a procedure
  1416. transforming an @code{operating-system} to an image. To understand why
  1417. it is necessary, let's have a look to the command producing an image
  1418. from an @code{operating-system} configuration file:
  1419. @example
  1420. guix system image my-os.scm
  1421. @end example
  1422. This command expects an @code{operating-system} configuration but how
  1423. should we indicate that we want an image targeting a Pine64 board? We
  1424. need to provide an extra information, the @code{image-type}, by passing
  1425. the @code{--image-type} or @code{-t} flag, this way:
  1426. @example
  1427. guix system image --image-type=pine64-raw my-os.scm
  1428. @end example
  1429. This @code{image-type} parameter points to the @code{pine64-image-type}
  1430. defined above. Hence, the @code{operating-system} declared in
  1431. @code{my-os.scm} will be applied the @code{(cut image-with-os
  1432. arm64-disk-image <>)} procedure to turn it into an image.
  1433. The resulting image looks like:
  1434. @lisp
  1435. (image
  1436. (format 'disk-image)
  1437. (target "aarch64-linux-gnu")
  1438. (operating-system my-os)
  1439. (partitions
  1440. (list (partition
  1441. (inherit root-partition)
  1442. (offset root-offset)))))
  1443. @end lisp
  1444. which is the aggregation of the @code{operating-system} defined in
  1445. @code{my-os.scm} to the @code{arm64-disk-image} record.
  1446. But enough Scheme madness. What does this image API bring to the Guix user?
  1447. One can run:
  1448. @example
  1449. mathieu@@cervin:~$ guix system --list-image-types
  1450. The available image types are:
  1451. - pinebook-pro-raw
  1452. - pine64-raw
  1453. - novena-raw
  1454. - hurd-raw
  1455. - hurd-qcow2
  1456. - qcow2
  1457. - uncompressed-iso9660
  1458. - efi-raw
  1459. - arm64-raw
  1460. - arm32-raw
  1461. - iso9660
  1462. @end example
  1463. and by writing an @code{operating-system} file based on
  1464. @code{pine64-barebones-os}, you can customize your image to your
  1465. preferences in a file (@file{my-pine-os.scm}) like this:
  1466. @lisp
  1467. (use-modules (gnu services linux)
  1468. (gnu system images pine64))
  1469. (let ((base-os pine64-barebones-os))
  1470. (operating-system
  1471. (inherit base-os)
  1472. (timezone "America/Indiana/Indianapolis")
  1473. (services
  1474. (cons
  1475. (service earlyoom-service-type
  1476. (earlyoom-configuration
  1477. (prefer-regexp "icecat|chromium")))
  1478. (operating-system-user-services base-os)))))
  1479. @end lisp
  1480. run:
  1481. @example
  1482. guix system image --image-type=pine64-raw my-pine-os.scm
  1483. @end example
  1484. or,
  1485. @example
  1486. guix system image --image-type=hurd-raw my-hurd-os.scm
  1487. @end example
  1488. to get an image that can be written directly to a hard drive and booted
  1489. from.
  1490. Without changing anything to @code{my-hurd-os.scm}, calling:
  1491. @example
  1492. guix system image --image-type=hurd-qcow2 my-hurd-os.scm
  1493. @end example
  1494. will instead produce a Hurd QEMU image.
  1495. @node Connecting to Wireguard VPN
  1496. @section Connecting to Wireguard VPN
  1497. To connect to a Wireguard VPN server you need the kernel module to be
  1498. loaded in memory and a package providing networking tools that support
  1499. it (e.g. @code{wireguard-tools} or @code{network-manager}).
  1500. Here is a configuration example for Linux-Libre < 5.6, where the module
  1501. is out of tree and need to be loaded manually---following revisions of
  1502. the kernel have it built-in and so don't need such configuration:
  1503. @lisp
  1504. (use-modules (gnu))
  1505. (use-service-modules desktop)
  1506. (use-package-modules vpn)
  1507. (operating-system
  1508. ;; …
  1509. (services (cons (simple-service 'wireguard-module
  1510. kernel-module-loader-service-type
  1511. '("wireguard"))
  1512. %desktop-services))
  1513. (packages (cons wireguard-tools %base-packages))
  1514. (kernel-loadable-modules (list wireguard-linux-compat)))
  1515. @end lisp
  1516. After reconfiguring and restarting your system you can either use
  1517. Wireguard tools or NetworkManager to connect to a VPN server.
  1518. @subsection Using Wireguard tools
  1519. To test your Wireguard setup it is convenient to use @command{wg-quick}.
  1520. Just give it a configuration file @command{wg-quick up ./wg0.conf}; or
  1521. put that file in @file{/etc/wireguard} and run @command{wg-quick up wg0}
  1522. instead.
  1523. @quotation Note
  1524. Be warned that the author described this command as a: “[…] very quick
  1525. and dirty bash script […]”.
  1526. @end quotation
  1527. @subsection Using NetworkManager
  1528. Thanks to NetworkManager support for Wireguard we can connect to our VPN
  1529. using @command{nmcli} command. Up to this point this guide assumes that
  1530. you're using Network Manager service provided by
  1531. @code{%desktop-services}. Ortherwise you need to adjust your services
  1532. list to load @code{network-manager-service-type} and reconfigure your
  1533. Guix system.
  1534. To import your VPN configuration execute nmcli import command:
  1535. @example shell
  1536. # nmcli connection import type wireguard file wg0.conf
  1537. Connection 'wg0' (edbee261-aa5a-42db-b032-6c7757c60fde) successfully added
  1538. @end example
  1539. This will create a configuration file in
  1540. @file{/etc/NetworkManager/wg0.nmconnection}. Next connect to the
  1541. Wireguard server:
  1542. @example shell
  1543. $ nmcli connection up wg0
  1544. Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
  1545. @end example
  1546. By default NetworkManager will connect automatically on system boot. To
  1547. change that behaviour you need to edit your config:
  1548. @example shell
  1549. # nmcli connection modify wg0 connection.autoconnect no
  1550. @end example
  1551. For more specific information about NetworkManager and wireguard
  1552. @uref{https://blogs.gnome.org/thaller/2019/03/15/wireguard-in-networkmanager/,see
  1553. this post by thaller}.
  1554. @node Customizing a Window Manager
  1555. @section Customizing a Window Manager
  1556. @cindex wm
  1557. @node StumpWM
  1558. @subsection StumpWM
  1559. @cindex stumpwm
  1560. You could install StumpWM with a Guix system by adding
  1561. @code{stumpwm} and optionally @code{`(,stumpwm "lib")}
  1562. packages to a system configuration file, e.g.@: @file{/etc/config.scm}.
  1563. An example configuration can look like this:
  1564. @lisp
  1565. (use-modules (gnu))
  1566. (use-package-modules wm)
  1567. (operating-system
  1568. ;; …
  1569. (packages (append (list sbcl stumpwm `(,stumpwm "lib"))
  1570. %base-packages)))
  1571. @end lisp
  1572. @cindex stumpwm fonts
  1573. By default StumpWM uses X11 fonts, which could be small or pixelated on
  1574. your system. You could fix this by installing StumpWM contrib Lisp
  1575. module @code{sbcl-ttf-fonts}, adding it to Guix system packages:
  1576. @lisp
  1577. (use-modules (gnu))
  1578. (use-package-modules fonts wm)
  1579. (operating-system
  1580. ;; …
  1581. (packages (append (list sbcl stumpwm `(,stumpwm "lib"))
  1582. sbcl-ttf-fonts font-dejavu %base-packages)))
  1583. @end lisp
  1584. Then you need to add the following code to a StumpWM configuration file
  1585. @file{~/.stumpwm.d/init.lisp}:
  1586. @lisp
  1587. (require :ttf-fonts)
  1588. (setf xft:*font-dirs* '("/run/current-system/profile/share/fonts/"))
  1589. (setf clx-truetype:+font-cache-filename+ (concat (getenv "HOME") "/.fonts/font-cache.sexp"))
  1590. (xft:cache-fonts)
  1591. (set-font (make-instance 'xft:font :family "DejaVu Sans Mono" :subfamily "Book" :size 11))
  1592. @end lisp
  1593. @node Session lock
  1594. @subsection Session lock
  1595. @cindex sessionlock
  1596. Depending on your environment, locking the screen of your session might come built in
  1597. or it might be something you have to set up yourself. If you use a desktop environment
  1598. like GNOME or KDE, it's usually built in. If you use a plain window manager like
  1599. StumpWM or EXWM, you might have to set it up yourself.
  1600. @node Xorg
  1601. @subsubsection Xorg
  1602. If you use Xorg, you can use the utility
  1603. @uref{https://www.mankier.com/1/xss-lock, xss-lock} to lock the screen of your session.
  1604. xss-lock is triggered by DPMS which since Xorg 1.8 is auto-detected and enabled if
  1605. ACPI is also enabled at kernel runtime.
  1606. To use xss-lock, you can simple execute it and put it into the background before
  1607. you start your window manager from e.g. your @file{~/.xsession}:
  1608. @example
  1609. xss-lock -- slock &
  1610. exec stumpwm
  1611. @end example
  1612. In this example, xss-lock uses @code{slock} to do the actual locking of the screen when
  1613. it determines it's appropriate, like when you suspend your device.
  1614. For slock to be allowed to be a screen locker for the graphical session, it needs to
  1615. be made setuid-root so it can authenticate users, and it needs a PAM service. This
  1616. can be achieved by adding the following service to your @file{config.scm}:
  1617. @lisp
  1618. (screen-locker-service slock)
  1619. @end lisp
  1620. If you manually lock your screen, e.g. by directly calling slock when you want to lock
  1621. your screen but not suspend it, it's a good idea to notify xss-lock about this so no
  1622. confusion occurs. This can be done by executing @code{xset s activate} immediately
  1623. before you execute slock.
  1624. @node Running Guix on a Linode Server
  1625. @section Running Guix on a Linode Server
  1626. @cindex linode, Linode
  1627. To run Guix on a server hosted by @uref{https://www.linode.com, Linode},
  1628. start with a recommended Debian server. We recommend using the default
  1629. distro as a way to bootstrap Guix. Create your SSH keys.
  1630. @example
  1631. ssh-keygen
  1632. @end example
  1633. Be sure to add your SSH key for easy login to the remote server.
  1634. This is trivially done via Linode's graphical interface for adding
  1635. SSH keys. Go to your profile and click add SSH Key.
  1636. Copy into it the output of:
  1637. @example
  1638. cat ~/.ssh/<username>_rsa.pub
  1639. @end example
  1640. Power the Linode down.
  1641. In the Linode's Storage tab, resize the Debian disk to be smaller.
  1642. 30 GB free space is recommended. Then click "Add a disk", and fill
  1643. out the form with the following:
  1644. @itemize @bullet
  1645. @item
  1646. Label: "Guix"
  1647. @item
  1648. Filesystem: ext4
  1649. @item
  1650. Set it to the remaining size
  1651. @end itemize
  1652. In the Configurations tab, press "Edit" on the default Debian profile.
  1653. Under "Block Device Assignment" click "Add a Device". It should be
  1654. @file{/dev/sdc} and you can select the "Guix" disk. Save Changes.
  1655. Now "Add a Configuration", with the following:
  1656. @itemize @bullet
  1657. @item
  1658. Label: Guix
  1659. @item
  1660. Kernel:GRUB 2 (it's at the bottom! This step is @b{IMPORTANT!})
  1661. @item
  1662. Block device assignment:
  1663. @item
  1664. @file{/dev/sda}: Guix
  1665. @item
  1666. @file{/dev/sdb}: swap
  1667. @item
  1668. Root device: @file{/dev/sda}
  1669. @item
  1670. Turn off all the filesystem/boot helpers
  1671. @end itemize
  1672. Now power it back up, booting with the Debian configuration. Once it's
  1673. running, ssh to your server via @code{ssh
  1674. root@@@var{<your-server-IP-here>}}. (You can find your server IP address in
  1675. your Linode Summary section.) Now you can run the "install guix from
  1676. @pxref{Binary Installation,,, guix, GNU Guix}" steps:
  1677. @example
  1678. sudo apt-get install gpg
  1679. wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
  1680. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  1681. chmod +x guix-install.sh
  1682. ./guix-install.sh
  1683. guix pull
  1684. @end example
  1685. Now it's time to write out a config for the server. The key information
  1686. is below. Save the resulting file as @file{guix-config.scm}.
  1687. @lisp
  1688. (use-modules (gnu)
  1689. (guix modules))
  1690. (use-service-modules networking
  1691. ssh)
  1692. (use-package-modules admin
  1693. certs
  1694. package-management
  1695. ssh
  1696. tls)
  1697. (operating-system
  1698. (host-name "my-server")
  1699. (timezone "America/New_York")
  1700. (locale "en_US.UTF-8")
  1701. ;; This goofy code will generate the grub.cfg
  1702. ;; without installing the grub bootloader on disk.
  1703. (bootloader (bootloader-configuration
  1704. (bootloader
  1705. (bootloader
  1706. (inherit grub-bootloader)
  1707. (installer #~(const #true))))))
  1708. (file-systems (cons (file-system
  1709. (device "/dev/sda")
  1710. (mount-point "/")
  1711. (type "ext4"))
  1712. %base-file-systems))
  1713. (swap-devices (list "/dev/sdb"))
  1714. (initrd-modules (cons "virtio_scsi" ; Needed to find the disk
  1715. %base-initrd-modules))
  1716. (users (cons (user-account
  1717. (name "janedoe")
  1718. (group "users")
  1719. ;; Adding the account to the "wheel" group
  1720. ;; makes it a sudoer.
  1721. (supplementary-groups '("wheel"))
  1722. (home-directory "/home/janedoe"))
  1723. %base-user-accounts))
  1724. (packages (cons* nss-certs ;for HTTPS access
  1725. openssh-sans-x
  1726. %base-packages))
  1727. (services (cons*
  1728. (service dhcp-client-service-type)
  1729. (service openssh-service-type
  1730. (openssh-configuration
  1731. (openssh openssh-sans-x)
  1732. (password-authentication? #false)
  1733. (authorized-keys
  1734. `(("janedoe" ,(local-file "janedoe_rsa.pub"))
  1735. ("root" ,(local-file "janedoe_rsa.pub"))))))
  1736. %base-services)))
  1737. @end lisp
  1738. Replace the following fields in the above configuration:
  1739. @lisp
  1740. (host-name "my-server") ; replace with your server name
  1741. ; if you chose a linode server outside the U.S., then
  1742. ; use tzselect to find a correct timezone string
  1743. (timezone "America/New_York") ; if needed replace timezone
  1744. (name "janedoe") ; replace with your username
  1745. ("janedoe" ,(local-file "janedoe_rsa.pub")) ; replace with your ssh key
  1746. ("root" ,(local-file "janedoe_rsa.pub")) ; replace with your ssh key
  1747. @end lisp
  1748. The last line in the above example lets you log into the server as root
  1749. and set the initial root password (see the note at the end of this
  1750. recipe about root login). After you have done this, you may
  1751. delete that line from your configuration and reconfigure to prevent root
  1752. login.
  1753. Copy your ssh public key (eg: @file{~/.ssh/id_rsa.pub}) as
  1754. @file{@var{<your-username-here>}_rsa.pub} and put
  1755. @file{guix-config.scm} in the same directory. In a new terminal run
  1756. these commands.
  1757. @example
  1758. sftp root@@<remote server ip address>
  1759. put /path/to/files/<username>_rsa.pub .
  1760. put /path/to/files/guix-config.scm .
  1761. @end example
  1762. In your first terminal, mount the guix drive:
  1763. @example
  1764. mkdir /mnt/guix
  1765. mount /dev/sdc /mnt/guix
  1766. @end example
  1767. Due to the way we set up the bootloader section of the guix-config.scm,
  1768. only the grub configuration file will be installed. So, we need to copy
  1769. over some of the other GRUB stuff already installed on the Debian system:
  1770. @example
  1771. mkdir -p /mnt/guix/boot/grub
  1772. cp -r /boot/grub/* /mnt/guix/boot/grub/
  1773. @end example
  1774. Now initialize the Guix installation:
  1775. @example
  1776. guix system init guix-config.scm /mnt/guix
  1777. @end example
  1778. Ok, power it down!
  1779. Now from the Linode console, select boot and select "Guix".
  1780. Once it boots, you should be able to log in via SSH! (The server config
  1781. will have changed though.) You may encounter an error like:
  1782. @example
  1783. $ ssh root@@<server ip address>
  1784. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1785. @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
  1786. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1787. IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
  1788. Someone could be eavesdropping on you right now (man-in-the-middle attack)!
  1789. It is also possible that a host key has just been changed.
  1790. The fingerprint for the ECDSA key sent by the remote host is
  1791. SHA256:0B+wp33w57AnKQuHCvQP0+ZdKaqYrI/kyU7CfVbS7R4.
  1792. Please contact your system administrator.
  1793. Add correct host key in /home/joshua/.ssh/known_hosts to get rid of this message.
  1794. Offending ECDSA key in /home/joshua/.ssh/known_hosts:3
  1795. ECDSA host key for 198.58.98.76 has changed and you have requested strict checking.
  1796. Host key verification failed.
  1797. @end example
  1798. Either delete @file{~/.ssh/known_hosts} file, or delete the offending line
  1799. starting with your server IP address.
  1800. Be sure to set your password and root's password.
  1801. @example
  1802. ssh root@@<remote ip address>
  1803. passwd ; for the root password
  1804. passwd <username> ; for the user password
  1805. @end example
  1806. You may not be able to run the above commands at this point. If you
  1807. have issues remotely logging into your linode box via SSH, then you may
  1808. still need to set your root and user password initially by clicking on
  1809. the ``Launch Console'' option in your linode. Choose the ``Glish''
  1810. instead of ``Weblish''. Now you should be able to ssh into the machine.
  1811. Hooray! At this point you can shut down the server, delete the
  1812. Debian disk, and resize the Guix to the rest of the size.
  1813. Congratulations!
  1814. By the way, if you save it as a disk image right at this point, you'll
  1815. have an easy time spinning up new Guix images! You may need to
  1816. down-size the Guix image to 6144MB, to save it as an image. Then you
  1817. can resize it again to the max size.
  1818. @node Setting up a bind mount
  1819. @section Setting up a bind mount
  1820. To bind mount a file system, one must first set up some definitions
  1821. before the @code{operating-system} section of the system definition. In
  1822. this example we will bind mount a folder from a spinning disk drive to
  1823. @file{/tmp}, to save wear and tear on the primary SSD, without
  1824. dedicating an entire partition to be mounted as @file{/tmp}.
  1825. First, the source drive that hosts the folder we wish to bind mount
  1826. should be defined, so that the bind mount can depend on it.
  1827. @lisp
  1828. (define source-drive ;; "source-drive" can be named anything you want.
  1829. (file-system
  1830. (device (uuid "UUID goes here"))
  1831. (mount-point "/path-to-spinning-disk-goes-here")
  1832. (type "ext4"))) ;; Make sure to set this to the appropriate type for your drive.
  1833. @end lisp
  1834. The source folder must also be defined, so that guix will know it's not
  1835. a regular block device, but a folder.
  1836. @lisp
  1837. (define (%source-directory) "/path-to-spinning-disk-goes-here/tmp") ;; "source-directory" can be named any valid variable name.
  1838. @end lisp
  1839. Finally, inside the @code{file-systems} definition, we must add the
  1840. mount itself.
  1841. @lisp
  1842. (file-systems (cons*
  1843. ...<other drives omitted for clarity>...
  1844. source-drive ;; Must match the name you gave the source drive in the earlier definition.
  1845. (file-system
  1846. (device (%source-directory)) ;; Make sure "source-directory" matches your earlier definition.
  1847. (mount-point "/tmp")
  1848. (type "none") ;; We are mounting a folder, not a partition, so this type needs to be "none"
  1849. (flags '(bind-mount))
  1850. (dependencies (list source-drive)) ;; Ensure "source-drive" matches what you've named the variable for the drive.
  1851. )
  1852. ...<other drives omitted for clarity>...
  1853. ))
  1854. @end lisp
  1855. @node Getting substitutes from Tor
  1856. @section Getting substitutes from Tor
  1857. Guix daemon can use a HTTP proxy to get substitutes, here we are
  1858. configuring it to get them via Tor.
  1859. @quotation Warning
  1860. @emph{Not all} Guix daemon's traffic will go through Tor! Only
  1861. HTTP/HTTPS will get proxied; FTP, Git protocol, SSH, etc connections
  1862. will still go through the clearnet. Again, this configuration isn't
  1863. foolproof some of your traffic won't get routed by Tor at all. Use it
  1864. at your own risk.
  1865. Also note that the procedure described here applies only to package
  1866. substitution. When you update your guix distribution with
  1867. @command{guix pull}, you still need to use @command{torsocks} if
  1868. you want to route the connection to guix's git repository servers
  1869. through Tor.
  1870. @end quotation
  1871. Guix's substitute server is available as a Onion service, if you want
  1872. to use it to get your substitutes through Tor configure your system as
  1873. follow:
  1874. @lisp
  1875. (use-modules (gnu))
  1876. (use-service-module base networking)
  1877. (operating-system
  1878. (services
  1879. (cons
  1880. (service tor-service-type
  1881. (tor-configuration
  1882. (config-file (plain-file "tor-config"
  1883. "HTTPTunnelPort 127.0.0.1:9250"))))
  1884. (modify-services %base-services
  1885. (guix-service-type
  1886. config => (guix-configuration
  1887. (inherit config)
  1888. ;; ci.guix.gnu.org's Onion service
  1889. (substitute-urls
  1890. "@value{SUBSTITUTE-TOR-URL}")
  1891. (http-proxy "http://localhost:9250")))))))
  1892. @end lisp
  1893. This will keep a tor process running that provides a HTTP CONNECT tunnel
  1894. which will be used by @command{guix-daemon}. The daemon can use other
  1895. protocols than HTTP(S) to get remote resources, request using those
  1896. protocols won't go through Tor since we are only setting a HTTP tunnel
  1897. here. Note that @code{substitutes-urls} is using HTTPS and not HTTP or
  1898. it won't work, that's a limitation of Tor's tunnel; you may want to use
  1899. @command{privoxy} instead to avoid such limitations.
  1900. If you don't want to always get substitutes through Tor but using it just
  1901. some of the times, then skip the @code{guix-configuration}. When you
  1902. want to get a substitute from the Tor tunnel run:
  1903. @example
  1904. sudo herd set-http-proxy guix-daemon http://localhost:9250
  1905. guix build \
  1906. --substitute-urls=@value{SUBSTITUTE-TOR-URL} @dots{}
  1907. @end example
  1908. @node Setting up NGINX with Lua
  1909. @section Setting up NGINX with Lua
  1910. @cindex nginx, lua, openresty, resty
  1911. NGINX could be extended with Lua scripts.
  1912. Guix provides NGINX service with ability to load Lua module and specific
  1913. Lua packages, and reply to requests by evaluating Lua scripts.
  1914. The following example demonstrates system definition with configuration
  1915. to evaluate @file{index.lua} Lua script on HTTP request to
  1916. @uref{http://localhost/hello} endpoint:
  1917. @example
  1918. local shell = require "resty.shell"
  1919. local stdin = ""
  1920. local timeout = 1000 -- ms
  1921. local max_size = 4096 -- byte
  1922. local ok, stdout, stderr, reason, status =
  1923. shell.run([[/run/current-system/profile/bin/ls /tmp]], stdin, timeout, max_size)
  1924. ngx.say(stdout)
  1925. @end example
  1926. @lisp
  1927. (use-modules (gnu))
  1928. (use-service-modules #;… web)
  1929. (use-package-modules #;… lua)
  1930. (operating-system
  1931. ;; …
  1932. (services
  1933. ;; …
  1934. (service nginx-service-type
  1935. (nginx-configuration
  1936. (modules
  1937. (list
  1938. (file-append nginx-lua-module "/etc/nginx/modules/ngx_http_lua_module.so")))
  1939. (lua-package-path (list lua-resty-core
  1940. lua-resty-lrucache
  1941. lua-resty-signal
  1942. lua-tablepool
  1943. lua-resty-shell))
  1944. (lua-package-cpath (list lua-resty-signal))
  1945. (server-blocks
  1946. (list (nginx-server-configuration
  1947. (server-name '("localhost"))
  1948. (listen '("80"))
  1949. (root "/etc")
  1950. (locations (list
  1951. (nginx-location-configuration
  1952. (uri "/hello")
  1953. (body (list #~(format #f "content_by_lua_file ~s;"
  1954. #$(local-file "index.lua"))))))))))))))
  1955. @end lisp
  1956. @c *********************************************************************
  1957. @node Advanced package management
  1958. @chapter Advanced package management
  1959. Guix is a functional package manager that offers many features beyond
  1960. what more traditional package managers can do. To the uninitiated,
  1961. those features might not have obvious use cases at first. The purpose
  1962. of this chapter is to demonstrate some advanced package management
  1963. concepts.
  1964. @pxref{Package Management,,, guix, GNU Guix Reference Manual} for a complete
  1965. reference.
  1966. @menu
  1967. * Guix Profiles in Practice:: Strategies for multiple profiles and manifests.
  1968. @end menu
  1969. @node Guix Profiles in Practice
  1970. @section Guix Profiles in Practice
  1971. Guix provides a very useful feature that may be quite foreign to newcomers:
  1972. @emph{profiles}. They are a way to group package installations together and all users
  1973. on the same system are free to use as many profiles as they want.
  1974. Whether you're a developer or not, you may find that multiple profiles bring you
  1975. great power and flexibility. While they shift the paradigm somewhat compared to
  1976. @emph{traditional package managers}, they are very convenient to use once you've
  1977. understood how to set them up.
  1978. If you are familiar with Python's @samp{virtualenv}, you can think of a profile as a
  1979. kind of universal @samp{virtualenv} that can hold any kind of software whatsoever, not
  1980. just Python software. Furthermore, profiles are self-sufficient: they capture
  1981. all the runtime dependencies which guarantees that all programs within a profile
  1982. will always work at any point in time.
  1983. Multiple profiles have many benefits:
  1984. @itemize
  1985. @item
  1986. Clean semantic separation of the various packages a user needs for different contexts.
  1987. @item
  1988. Multiple profiles can be made available into the environment either on login
  1989. or within a dedicated shell.
  1990. @item
  1991. Profiles can be loaded on demand. For instance, the user can use multiple
  1992. shells, each of them running different profiles.
  1993. @item
  1994. Isolation: Programs from one profile will not use programs from the other, and
  1995. the user can even install different versions of the same programs to the two
  1996. profiles without conflict.
  1997. @item
  1998. Deduplication: Profiles share dependencies that happens to be the exact same.
  1999. This makes multiple profiles storage-efficient.
  2000. @item
  2001. Reproducible: when used with declarative manifests, a profile can be fully
  2002. specified by the Guix commit that was active when it was set up. This means
  2003. that the exact same profile can be
  2004. @uref{https://guix.gnu.org/blog/2018/multi-dimensional-transactions-and-rollbacks-oh-my/,
  2005. set up anywhere and anytime}, with just the commit information. See the
  2006. section on @ref{Reproducible profiles}.
  2007. @item
  2008. Easier upgrades and maintenance: Multiple profiles make it easy to keep
  2009. package listings at hand and make upgrades completely frictionless.
  2010. @end itemize
  2011. Concretely, here follows some typical profiles:
  2012. @itemize
  2013. @item
  2014. The dependencies of a project you are working on.
  2015. @item
  2016. Your favourite programming language libraries.
  2017. @item
  2018. Laptop-specific programs (like @samp{powertop}) that you don't need on a desktop.
  2019. @item
  2020. @TeX{}live (this one can be really useful when you need to install just one
  2021. package for this one document you've just received over email).
  2022. @item
  2023. Games.
  2024. @end itemize
  2025. Let's dive in the set up!
  2026. @node Basic setup with manifests
  2027. @subsection Basic setup with manifests
  2028. A Guix profile can be set up @emph{via} a so-called @emph{manifest specification} that looks like
  2029. this:
  2030. @lisp
  2031. (specifications->manifest
  2032. '("package-1"
  2033. ;; Version 1.3 of package-2.
  2034. "package-2@@1.3"
  2035. ;; The "lib" output of package-3.
  2036. "package-3:lib"
  2037. ; ...
  2038. "package-N"))
  2039. @end lisp
  2040. @pxref{Invoking guix package,,, guix, GNU Guix Reference Manual}, for
  2041. the syntax details.
  2042. We can create a manifest specification per profile and install them this way:
  2043. @example
  2044. GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
  2045. mkdir -p "$GUIX_EXTRA_PROFILES"/my-project # if it does not exist yet
  2046. guix package --manifest=/path/to/guix-my-project-manifest.scm --profile="$GUIX_EXTRA_PROFILES"/my-project/my-project
  2047. @end example
  2048. Here we set an arbitrary variable @samp{GUIX_EXTRA_PROFILES} to point to the directory
  2049. where we will store our profiles in the rest of this article.
  2050. Placing all your profiles in a single directory, with each profile getting its
  2051. own sub-directory, is somewhat cleaner. This way, each sub-directory will
  2052. contain all the symlinks for precisely one profile. Besides, ``looping over
  2053. profiles'' becomes obvious from any programming language (e.g.@: a shell script) by
  2054. simply looping over the sub-directories of @samp{$GUIX_EXTRA_PROFILES}.
  2055. Note that it's also possible to loop over the output of
  2056. @example
  2057. guix package --list-profiles
  2058. @end example
  2059. although you'll probably have to filter out @file{~/.config/guix/current}.
  2060. To enable all profiles on login, add this to your @file{~/.bash_profile} (or similar):
  2061. @example
  2062. for i in $GUIX_EXTRA_PROFILES/*; do
  2063. profile=$i/$(basename "$i")
  2064. if [ -f "$profile"/etc/profile ]; then
  2065. GUIX_PROFILE="$profile"
  2066. . "$GUIX_PROFILE"/etc/profile
  2067. fi
  2068. unset profile
  2069. done
  2070. @end example
  2071. Note to Guix System users: the above reflects how your default profile
  2072. @file{~/.guix-profile} is activated from @file{/etc/profile}, that latter being loaded by
  2073. @file{~/.bashrc} by default.
  2074. You can obviously choose to only enable a subset of them:
  2075. @example
  2076. for i in "$GUIX_EXTRA_PROFILES"/my-project-1 "$GUIX_EXTRA_PROFILES"/my-project-2; do
  2077. profile=$i/$(basename "$i")
  2078. if [ -f "$profile"/etc/profile ]; then
  2079. GUIX_PROFILE="$profile"
  2080. . "$GUIX_PROFILE"/etc/profile
  2081. fi
  2082. unset profile
  2083. done
  2084. @end example
  2085. When a profile is off, it's straightforward to enable it for an individual shell
  2086. without "polluting" the rest of the user session:
  2087. @example
  2088. GUIX_PROFILE="path/to/my-project" ; . "$GUIX_PROFILE"/etc/profile
  2089. @end example
  2090. The key to enabling a profile is to @emph{source} its @samp{etc/profile} file. This file
  2091. contains shell code that exports the right environment variables necessary to
  2092. activate the software contained in the profile. It is built automatically by
  2093. Guix and meant to be sourced.
  2094. It contains the same variables you would get if you ran:
  2095. @example
  2096. guix package --search-paths=prefix --profile=$my_profile"
  2097. @end example
  2098. Once again, see (@pxref{Invoking guix package,,, guix, GNU Guix Reference Manual})
  2099. for the command line options.
  2100. To upgrade a profile, simply install the manifest again:
  2101. @example
  2102. guix package -m /path/to/guix-my-project-manifest.scm -p "$GUIX_EXTRA_PROFILES"/my-project/my-project
  2103. @end example
  2104. To upgrade all profiles, it's easy enough to loop over them. For instance,
  2105. assuming your manifest specifications are stored in
  2106. @file{~/.guix-manifests/guix-$profile-manifest.scm}, with @samp{$profile} being the name
  2107. of the profile (e.g.@: "project1"), you could do the following in Bourne shell:
  2108. @example
  2109. for profile in "$GUIX_EXTRA_PROFILES"/*; do
  2110. guix package --profile="$profile" --manifest="$HOME/.guix-manifests/guix-$profile-manifest.scm"
  2111. done
  2112. @end example
  2113. Each profile has its own generations:
  2114. @example
  2115. guix package -p "$GUIX_EXTRA_PROFILES"/my-project/my-project --list-generations
  2116. @end example
  2117. You can roll-back to any generation of a given profile:
  2118. @example
  2119. guix package -p "$GUIX_EXTRA_PROFILES"/my-project/my-project --switch-generations=17
  2120. @end example
  2121. Finally, if you want to switch to a profile without inheriting from the
  2122. current environment, you can activate it from an empty shell:
  2123. @example
  2124. env -i $(which bash) --login --noprofile --norc
  2125. . my-project/etc/profile
  2126. @end example
  2127. @node Required packages
  2128. @subsection Required packages
  2129. Activating a profile essentially boils down to exporting a bunch of
  2130. environmental variables. This is the role of the @samp{etc/profile} within the
  2131. profile.
  2132. @emph{Note: Only the environmental variables of the packages that consume them will
  2133. be set.}
  2134. For instance, @samp{MANPATH} won't be set if there is no consumer application for man
  2135. pages within the profile. So if you need to transparently access man pages once
  2136. the profile is loaded, you've got two options:
  2137. @itemize
  2138. @item
  2139. Either export the variable manually, e.g.
  2140. @example
  2141. export MANPATH=/path/to/profile$@{MANPATH:+:@}$MANPATH
  2142. @end example
  2143. @item
  2144. Or include @samp{man-db} to the profile manifest.
  2145. @end itemize
  2146. The same is true for @samp{INFOPATH} (you can install @samp{info-reader}),
  2147. @samp{PKG_CONFIG_PATH} (install @samp{pkg-config}), etc.
  2148. @node Default profile
  2149. @subsection Default profile
  2150. What about the default profile that Guix keeps in @file{~/.guix-profile}?
  2151. You can assign it the role you want. Typically you would install the manifest
  2152. of the packages you want to use all the time.
  2153. Alternatively, you could keep it ``manifest-less'' for throw-away packages
  2154. that you would just use for a couple of days.
  2155. This way makes it convenient to run
  2156. @example
  2157. guix install package-foo
  2158. guix upgrade package-bar
  2159. @end example
  2160. without having to specify the path to a profile.
  2161. @node The benefits of manifests
  2162. @subsection The benefits of manifests
  2163. Manifests are a convenient way to keep your package lists around and, say,
  2164. to synchronize them across multiple machines using a version control system.
  2165. A common complaint about manifests is that they can be slow to install when they
  2166. contain large number of packages. This is especially cumbersome when you just
  2167. want get an upgrade for one package within a big manifest.
  2168. This is one more reason to use multiple profiles, which happen to be just
  2169. perfect to break down manifests into multiple sets of semantically connected
  2170. packages. Using multiple, small profiles provides more flexibility and
  2171. usability.
  2172. Manifests come with multiple benefits. In particular, they ease maintenance:
  2173. @itemize
  2174. @item
  2175. When a profile is set up from a manifest, the manifest itself is
  2176. self-sufficient to keep a ``package listing'' around and reinstall the profile
  2177. later or on a different system. For ad-hoc profiles, we would need to
  2178. generate a manifest specification manually and maintain the package versions
  2179. for the packages that don't use the default version.
  2180. @item
  2181. @code{guix package --upgrade} always tries to update the packages that have
  2182. propagated inputs, even if there is nothing to do. Guix manifests remove this
  2183. problem.
  2184. @item
  2185. When partially upgrading a profile, conflicts may arise (due to diverging
  2186. dependencies between the updated and the non-updated packages) and they can be
  2187. annoying to resolve manually. Manifests remove this problem altogether since
  2188. all packages are always upgraded at once.
  2189. @item
  2190. As mentioned above, manifests allow for reproducible profiles, while the
  2191. imperative @code{guix install}, @code{guix upgrade}, etc. do not, since they produce
  2192. different profiles every time even when they hold the same packages. See
  2193. @uref{https://issues.guix.gnu.org/issue/33285, the related discussion on the matter}.
  2194. @item
  2195. Manifest specifications are usable by other @samp{guix} commands. For example, you
  2196. can run @code{guix weather -m manifest.scm} to see how many substitutes are
  2197. available, which can help you decide whether you want to try upgrading today
  2198. or wait a while. Another example: you can run @code{guix pack -m manifest.scm} to
  2199. create a pack containing all the packages in the manifest (and their
  2200. transitive references).
  2201. @item
  2202. Finally, manifests have a Scheme representation, the @samp{<manifest>} record type.
  2203. They can be manipulated in Scheme and passed to the various Guix @uref{https://en.wikipedia.org/wiki/Api, APIs}.
  2204. @end itemize
  2205. It's important to understand that while manifests can be used to declare
  2206. profiles, they are not strictly equivalent: profiles have the side effect that
  2207. they ``pin'' packages in the store, which prevents them from being
  2208. garbage-collected (@pxref{Invoking guix gc,,, guix, GNU Guix Reference Manual})
  2209. and ensures that they will still be available at any point in
  2210. the future.
  2211. Let's take an example:
  2212. @enumerate
  2213. @item
  2214. We have an environment for hacking on a project for which there isn't a Guix
  2215. package yet. We build the environment using a manifest, and then run @code{guix
  2216. environment -m manifest.scm}. So far so good.
  2217. @item
  2218. Many weeks pass and we have run a couple of @code{guix pull} in the mean time.
  2219. Maybe a dependency from our manifest has been updated; or we may have run
  2220. @code{guix gc} and some packages needed by our manifest have been
  2221. garbage-collected.
  2222. @item
  2223. Eventually, we set to work on that project again, so we run @code{guix environment
  2224. -m manifest.scm}. But now we have to wait for Guix to build and install
  2225. stuff!
  2226. @end enumerate
  2227. Ideally, we could spare the rebuild time. And indeed we can, all we need is to
  2228. install the manifest to a profile and use @code{GUIX_PROFILE=/the/profile;
  2229. . "$GUIX_PROFILE"/etc/profile} as explained above: this guarantees that our
  2230. hacking environment will be available at all times.
  2231. @emph{Security warning:} While keeping old profiles around can be convenient, keep in
  2232. mind that outdated packages may not have received the latest security fixes.
  2233. @node Reproducible profiles
  2234. @subsection Reproducible profiles
  2235. To reproduce a profile bit-for-bit, we need two pieces of information:
  2236. @itemize
  2237. @item
  2238. a manifest,
  2239. @item
  2240. a Guix channel specification.
  2241. @end itemize
  2242. Indeed, manifests alone might not be enough: different Guix versions (or
  2243. different channels) can produce different outputs for a given manifest.
  2244. You can output the Guix channel specification with @samp{guix describe
  2245. --format=channels}.
  2246. Save this to a file, say @samp{channel-specs.scm}.
  2247. On another computer, you can use the channel specification file and the manifest
  2248. to reproduce the exact same profile:
  2249. @example
  2250. GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
  2251. GUIX_EXTRA=$HOME/.guix-extra
  2252. mkdir "$GUIX_EXTRA"/my-project
  2253. guix pull --channels=channel-specs.scm --profile "$GUIX_EXTRA/my-project/guix"
  2254. mkdir -p "$GUIX_EXTRA_PROFILES/my-project"
  2255. "$GUIX_EXTRA"/my-project/guix/bin/guix package --manifest=/path/to/guix-my-project-manifest.scm --profile="$GUIX_EXTRA_PROFILES"/my-project/my-project
  2256. @end example
  2257. It's safe to delete the Guix channel profile you've just installed with the
  2258. channel specification, the project profile does not depend on it.
  2259. @c *********************************************************************
  2260. @node Environment management
  2261. @chapter Environment management
  2262. Guix provides multiple tools to manage environment. This chapter
  2263. demonstrate such utilities.
  2264. @menu
  2265. * Guix environment via direnv:: Setup Guix environment with direnv
  2266. @end menu
  2267. @node Guix environment via direnv
  2268. @section Guix environment via direnv
  2269. Guix provides a @samp{direnv} package, which could extend shell after
  2270. directory change. This tool could be used to prepare a pure Guix
  2271. environment.
  2272. The following example provides a shell function for @file{~/.direnvrc}
  2273. file, which could be used from Guix Git repository in
  2274. @file{~/src/guix/.envrc} file to setup a build environment similar to
  2275. described in @pxref{Building from Git,,, guix, GNU Guix Reference
  2276. Manual}.
  2277. Create a @file{~/.direnvrc} with a Bash code:
  2278. @example
  2279. # Thanks <https://github.com/direnv/direnv/issues/73#issuecomment-152284914>
  2280. export_function()
  2281. @{
  2282. local name=$1
  2283. local alias_dir=$PWD/.direnv/aliases
  2284. mkdir -p "$alias_dir"
  2285. PATH_add "$alias_dir"
  2286. local target="$alias_dir/$name"
  2287. if declare -f "$name" >/dev/null; then
  2288. echo "#!$SHELL" > "$target"
  2289. declare -f "$name" >> "$target" 2>/dev/null
  2290. # Notice that we add shell variables to the function trigger.
  2291. echo "$name \$*" >> "$target"
  2292. chmod +x "$target"
  2293. fi
  2294. @}
  2295. use_guix()
  2296. @{
  2297. # Set GitHub token.
  2298. export GUIX_GITHUB_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  2299. # Unset 'GUIX_PACKAGE_PATH'.
  2300. export GUIX_PACKAGE_PATH=""
  2301. # Recreate a garbage collector root.
  2302. gcroots="$HOME/.config/guix/gcroots"
  2303. mkdir -p "$gcroots"
  2304. gcroot="$gcroots/guix"
  2305. if [ -L "$gcroot" ]
  2306. then
  2307. rm -v "$gcroot"
  2308. fi
  2309. # Miscellaneous packages.
  2310. PACKAGES_MAINTENANCE=(
  2311. direnv
  2312. git
  2313. git:send-email
  2314. git-cal
  2315. gnupg
  2316. guile-colorized
  2317. guile-readline
  2318. less
  2319. ncurses
  2320. openssh
  2321. xdot
  2322. )
  2323. # Environment packages.
  2324. PACKAGES=(help2man guile-sqlite3 guile-gcrypt)
  2325. # Thanks <https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html>
  2326. eval "$(guix environment --search-paths --root="$gcroot" --pure guix --ad-hoc $@{PACKAGES[@@]@} $@{PACKAGES_MAINTENANCE[@@]@} "$@@")"
  2327. # Predefine configure flags.
  2328. configure()
  2329. @{
  2330. ./configure --localstatedir=/var --prefix=
  2331. @}
  2332. export_function configure
  2333. # Run make and optionally build something.
  2334. build()
  2335. @{
  2336. make -j 2
  2337. if [ $# -gt 0 ]
  2338. then
  2339. ./pre-inst-env guix build "$@@"
  2340. fi
  2341. @}
  2342. export_function build
  2343. # Predefine push Git command.
  2344. push()
  2345. @{
  2346. git push --set-upstream origin
  2347. @}
  2348. export_function push
  2349. clear # Clean up the screen.
  2350. git-cal --author='Your Name' # Show contributions calendar.
  2351. # Show commands help.
  2352. echo "
  2353. build build a package or just a project if no argument provided
  2354. configure run ./configure with predefined parameters
  2355. push push to upstream Git repository
  2356. "
  2357. @}
  2358. @end example
  2359. Every project containing @file{.envrc} with a string @code{use guix}
  2360. will have predefined environment variables and procedures.
  2361. Run @command{direnv allow} to setup the environment for the first time.
  2362. @c *********************************************************************
  2363. @node Acknowledgments
  2364. @chapter Acknowledgments
  2365. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  2366. which was designed and
  2367. implemented by Eelco Dolstra, with contributions from other people (see
  2368. the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
  2369. management, and promoted unprecedented features, such as transactional
  2370. package upgrades and rollbacks, per-user profiles, and referentially
  2371. transparent build processes. Without this work, Guix would not exist.
  2372. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  2373. an inspiration for Guix.
  2374. GNU@tie{}Guix itself is a collective work with contributions from a
  2375. number of people. See the @file{AUTHORS} file in Guix for more
  2376. information on these fine people. The @file{THANKS} file lists people
  2377. who have helped by reporting bugs, taking care of the infrastructure,
  2378. providing artwork and themes, making suggestions, and more---thank you!
  2379. This document includes adapted sections from articles that have previously
  2380. been published on the Guix blog at @uref{https://guix.gnu.org/blog}.
  2381. @c *********************************************************************
  2382. @node GNU Free Documentation License
  2383. @appendix GNU Free Documentation License
  2384. @cindex license, GNU Free Documentation License
  2385. @include fdl-1.3.texi
  2386. @c *********************************************************************
  2387. @node Concept Index
  2388. @unnumbered Concept Index
  2389. @printindex cp
  2390. @bye
  2391. @c Local Variables:
  2392. @c ispell-local-dictionary: "american";
  2393. @c End: