guix.texi 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=15145
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER ci.guix.gnu.org
  16. @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER}
  17. @copying
  18. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
  19. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  20. Copyright @copyright{} 2013 Nikita Karetnikov@*
  21. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  22. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  23. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  24. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  25. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020 Leo Famulari@*
  26. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@*
  27. Copyright @copyright{} 2016 Ben Woodcroft@*
  28. Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Efraim Flashner@*
  30. Copyright @copyright{} 2016 John Darrington@*
  31. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  32. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Julien Lepiller@*
  34. Copyright @copyright{} 2016 Alex ter Weele@*
  35. Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
  36. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  37. Copyright @copyright{} 2017, 2018, 2020 Mathieu Othacehe@*
  38. Copyright @copyright{} 2017 Federico Beffa@*
  39. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  40. Copyright @copyright{} 2017 Thomas Danckaert@*
  41. Copyright @copyright{} 2017 humanitiesNerd@*
  42. Copyright @copyright{} 2017 Christopher Allan Webber@*
  43. Copyright @copyright{} 2017, 2018, 2019, 2020 Marius Bakke@*
  44. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  45. Copyright @copyright{} 2017, 2019, 2020 Maxim Cournoyer@*
  46. Copyright @copyright{} 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice@*
  47. Copyright @copyright{} 2017 George Clemmer@*
  48. Copyright @copyright{} 2017 Andy Wingo@*
  49. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  50. Copyright @copyright{} 2017 nee@*
  51. Copyright @copyright{} 2018 Rutger Helling@*
  52. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  53. Copyright @copyright{} 2018 Mike Gerwitz@*
  54. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  55. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  56. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  57. Copyright @copyright{} 2018 Laura Lazzati@*
  58. Copyright @copyright{} 2018 Alex Vong@*
  59. Copyright @copyright{} 2019 Josh Holland@*
  60. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  61. Copyright @copyright{} 2019 Ivan Petkov@*
  62. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  63. Copyright @copyright{} 2019 Kyle Andrews@*
  64. Copyright @copyright{} 2019 Alex Griffin@*
  65. Copyright @copyright{} 2019, 2020 Guillaume Le Vaillant@*
  66. Copyright @copyright{} 2020 Leo Prikler@*
  67. Copyright @copyright{} 2019, 2020 Simon Tournier@*
  68. Copyright @copyright{} 2020 Wiktor Żelazny@*
  69. Copyright @copyright{} 2020 Damien Cassou@*
  70. Copyright @copyright{} 2020 Jakub Kądziołka@*
  71. Copyright @copyright{} 2020 Jack Hill@*
  72. Copyright @copyright{} 2020 Naga Malleswari@*
  73. Copyright @copyright{} 2020 Brice Waegeneire@*
  74. Copyright @copyright{} 2020 R Veera Kumar@*
  75. Copyright @copyright{} 2020 Pierre Langlois@*
  76. Copyright @copyright{} 2020 pinoaffe@*
  77. Copyright @copyright{} 2020 André Batista@*
  78. Copyright @copyright{} 2020 Alexandru-Sergiu Marton@*
  79. Copyright @copyright{} 2020 raingloom@*
  80. Copyright @copyright{} 2020 Daniel Brooks@*
  81. Copyright @copyright{} 2020 John Soo@*
  82. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  83. Permission is granted to copy, distribute and/or modify this document
  84. under the terms of the GNU Free Documentation License, Version 1.3 or
  85. any later version published by the Free Software Foundation; with no
  86. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  87. copy of the license is included in the section entitled ``GNU Free
  88. Documentation License''.
  89. @end copying
  90. @dircategory System administration
  91. @direntry
  92. * Guix: (guix). Manage installed software and system configuration.
  93. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  94. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  95. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  96. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  97. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  98. @end direntry
  99. @dircategory Software development
  100. @direntry
  101. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  102. * guix build: (guix)Invoking guix build. Building packages.
  103. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  104. @end direntry
  105. @titlepage
  106. @title GNU Guix Reference Manual
  107. @subtitle Using the GNU Guix Functional Package Manager
  108. @author The GNU Guix Developers
  109. @page
  110. @vskip 0pt plus 1filll
  111. Edition @value{EDITION} @*
  112. @value{UPDATED} @*
  113. @insertcopying
  114. @end titlepage
  115. @contents
  116. @c *********************************************************************
  117. @node Top
  118. @top GNU Guix
  119. This document describes GNU Guix version @value{VERSION}, a functional
  120. package management tool written for the GNU system.
  121. @c TRANSLATORS: You can replace the following paragraph with information on
  122. @c how to join your own translation team and how to report issues with the
  123. @c translation.
  124. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  125. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  126. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  127. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  128. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  129. would like to translate it in your native language, consider joining
  130. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  131. Weblate}.
  132. @menu
  133. * Introduction:: What is Guix about?
  134. * Installation:: Installing Guix.
  135. * System Installation:: Installing the whole operating system.
  136. * Getting Started:: Your first steps.
  137. * Package Management:: Package installation, upgrade, etc.
  138. * Channels:: Customizing the package collection.
  139. * Development:: Guix-aided software development.
  140. * Programming Interface:: Using Guix in Scheme.
  141. * Utilities:: Package management commands.
  142. * System Configuration:: Configuring the operating system.
  143. * Documentation:: Browsing software user manuals.
  144. * Installing Debugging Files:: Feeding the debugger.
  145. * Security Updates:: Deploying security fixes quickly.
  146. * Bootstrapping:: GNU/Linux built from scratch.
  147. * Porting:: Targeting another platform or kernel.
  148. * Contributing:: Your help needed!
  149. * Acknowledgments:: Thanks!
  150. * GNU Free Documentation License:: The license of this manual.
  151. * Concept Index:: Concepts.
  152. * Programming Index:: Data types, functions, and variables.
  153. @detailmenu
  154. --- The Detailed Node Listing ---
  155. Introduction
  156. * Managing Software the Guix Way:: What's special.
  157. * GNU Distribution:: The packages and tools.
  158. Installation
  159. * Binary Installation:: Getting Guix running in no time!
  160. * Requirements:: Software needed to build and run Guix.
  161. * Running the Test Suite:: Testing Guix.
  162. * Setting Up the Daemon:: Preparing the build daemon's environment.
  163. * Invoking guix-daemon:: Running the build daemon.
  164. * Application Setup:: Application-specific setup.
  165. * Upgrading Guix:: Upgrading Guix and its build daemon.
  166. Setting Up the Daemon
  167. * Build Environment Setup:: Preparing the isolated build environment.
  168. * Daemon Offload Setup:: Offloading builds to remote machines.
  169. * SELinux Support:: Using an SELinux policy for the daemon.
  170. System Installation
  171. * Limitations:: What you can expect.
  172. * Hardware Considerations:: Supported hardware.
  173. * USB Stick and DVD Installation:: Preparing the installation medium.
  174. * Preparing for Installation:: Networking, partitioning, etc.
  175. * Guided Graphical Installation:: Easy graphical installation.
  176. * Manual Installation:: Manual installation for wizards.
  177. * After System Installation:: When installation succeeded.
  178. * Installing Guix in a VM:: Guix System playground.
  179. * Building the Installation Image:: How this comes to be.
  180. Manual Installation
  181. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  182. * Proceeding with the Installation:: Installing.
  183. Package Management
  184. * Features:: How Guix will make your life brighter.
  185. * Invoking guix package:: Package installation, removal, etc.
  186. * Substitutes:: Downloading pre-built binaries.
  187. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  188. * Invoking guix gc:: Running the garbage collector.
  189. * Invoking guix pull:: Fetching the latest Guix and distribution.
  190. * Invoking guix time-machine:: Running an older revision of Guix.
  191. * Inferiors:: Interacting with another revision of Guix.
  192. * Invoking guix describe:: Display information about your Guix revision.
  193. * Invoking guix archive:: Exporting and importing store files.
  194. Substitutes
  195. * Official Substitute Server:: One particular source of substitutes.
  196. * Substitute Server Authorization:: How to enable or disable substitutes.
  197. * Getting Substitutes from Other Servers:: Substitute diversity.
  198. * Substitute Authentication:: How Guix verifies substitutes.
  199. * Proxy Settings:: How to get substitutes via proxy.
  200. * Substitution Failure:: What happens when substitution fails.
  201. * On Trusting Binaries:: How can you trust that binary blob?
  202. Channels
  203. * Specifying Additional Channels:: Extending the package collection.
  204. * Using a Custom Guix Channel:: Using a customized Guix.
  205. * Replicating Guix:: Running the @emph{exact same} Guix.
  206. * Channel Authentication:: How Guix verifies what it fetches.
  207. * Creating a Channel:: How to write your custom channel.
  208. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  209. * Declaring Channel Dependencies:: How to depend on other channels.
  210. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  211. * Primary URL:: Distinguishing mirror to original.
  212. * Writing Channel News:: Communicating information to channel's users.
  213. Development
  214. * Invoking guix environment:: Setting up development environments.
  215. * Invoking guix pack:: Creating software bundles.
  216. * The GCC toolchain:: Working with languages supported by GCC.
  217. * Invoking guix git authenticate:: Authenticating Git repositories.
  218. Programming Interface
  219. * Package Modules:: Packages from the programmer's viewpoint.
  220. * Defining Packages:: Defining new packages.
  221. * Defining Package Variants:: Customizing packages.
  222. * Build Systems:: Specifying how packages are built.
  223. * Build Phases:: Phases of the build process of a package.
  224. * Build Utilities:: Helpers for your package definitions and more.
  225. * The Store:: Manipulating the package store.
  226. * Derivations:: Low-level interface to package derivations.
  227. * The Store Monad:: Purely functional interface to the store.
  228. * G-Expressions:: Manipulating build expressions.
  229. * Invoking guix repl:: Programming Guix in Guile.
  230. Defining Packages
  231. * package Reference:: The package data type.
  232. * origin Reference:: The origin data type.
  233. Utilities
  234. * Invoking guix build:: Building packages from the command line.
  235. * Invoking guix edit:: Editing package definitions.
  236. * Invoking guix download:: Downloading a file and printing its hash.
  237. * Invoking guix hash:: Computing the cryptographic hash of a file.
  238. * Invoking guix import:: Importing package definitions.
  239. * Invoking guix refresh:: Updating package definitions.
  240. * Invoking guix lint:: Finding errors in package definitions.
  241. * Invoking guix size:: Profiling disk usage.
  242. * Invoking guix graph:: Visualizing the graph of packages.
  243. * Invoking guix publish:: Sharing substitutes.
  244. * Invoking guix challenge:: Challenging substitute servers.
  245. * Invoking guix copy:: Copying to and from a remote store.
  246. * Invoking guix container:: Process isolation.
  247. * Invoking guix weather:: Assessing substitute availability.
  248. * Invoking guix processes:: Listing client processes.
  249. Invoking @command{guix build}
  250. * Common Build Options:: Build options for most commands.
  251. * Package Transformation Options:: Creating variants of packages.
  252. * Additional Build Options:: Options specific to 'guix build'.
  253. * Debugging Build Failures:: Real life packaging experience.
  254. System Configuration
  255. * Using the Configuration System:: Customizing your GNU system.
  256. * operating-system Reference:: Detail of operating-system declarations.
  257. * File Systems:: Configuring file system mounts.
  258. * Mapped Devices:: Block device extra processing.
  259. * User Accounts:: Specifying user accounts.
  260. * Keyboard Layout:: How the system interprets key strokes.
  261. * Locales:: Language and cultural convention settings.
  262. * Services:: Specifying system services.
  263. * Setuid Programs:: Programs running with root privileges.
  264. * X.509 Certificates:: Authenticating HTTPS servers.
  265. * Name Service Switch:: Configuring libc's name service switch.
  266. * Initial RAM Disk:: Linux-Libre bootstrapping.
  267. * Bootloader Configuration:: Configuring the boot loader.
  268. * Invoking guix system:: Instantiating a system configuration.
  269. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  270. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  271. * Defining Services:: Adding new service definitions.
  272. Services
  273. * Base Services:: Essential system services.
  274. * Scheduled Job Execution:: The mcron service.
  275. * Log Rotation:: The rottlog service.
  276. * Networking Services:: Network setup, SSH daemon, etc.
  277. * Unattended Upgrades:: Automated system upgrades.
  278. * X Window:: Graphical display.
  279. * Printing Services:: Local and remote printer support.
  280. * Desktop Services:: D-Bus and desktop services.
  281. * Sound Services:: ALSA and Pulseaudio services.
  282. * Database Services:: SQL databases, key-value stores, etc.
  283. * Mail Services:: IMAP, POP3, SMTP, and all that.
  284. * Messaging Services:: Messaging services.
  285. * Telephony Services:: Telephony services.
  286. * Monitoring Services:: Monitoring services.
  287. * Kerberos Services:: Kerberos services.
  288. * LDAP Services:: LDAP services.
  289. * Web Services:: Web servers.
  290. * Certificate Services:: TLS certificates via Let's Encrypt.
  291. * DNS Services:: DNS daemons.
  292. * VPN Services:: VPN daemons.
  293. * Network File System:: NFS related services.
  294. * Continuous Integration:: The Cuirass service.
  295. * Power Management Services:: Extending battery life.
  296. * Audio Services:: The MPD.
  297. * Virtualization Services:: Virtualization services.
  298. * Version Control Services:: Providing remote access to Git repositories.
  299. * Game Services:: Game servers.
  300. * PAM Mount Service:: Service to mount volumes when logging in.
  301. * Guix Services:: Services relating specifically to Guix.
  302. * Linux Services:: Services tied to the Linux kernel.
  303. * Hurd Services:: Services specific for a Hurd System.
  304. * Miscellaneous Services:: Other services.
  305. Defining Services
  306. * Service Composition:: The model for composing services.
  307. * Service Types and Services:: Types and services.
  308. * Service Reference:: API reference.
  309. * Shepherd Services:: A particular type of service.
  310. Installing Debugging Files
  311. * Separate Debug Info:: Installing 'debug' outputs.
  312. * Rebuilding Debug Info:: Building missing debug info.
  313. Bootstrapping
  314. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  315. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  316. @end detailmenu
  317. @end menu
  318. @c *********************************************************************
  319. @node Introduction
  320. @chapter Introduction
  321. @cindex purpose
  322. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  323. using the international phonetic alphabet (IPA).} is a package
  324. management tool for and distribution of the GNU system.
  325. Guix makes it easy for unprivileged
  326. users to install, upgrade, or remove software packages, to roll back to a
  327. previous package set, to build packages from source, and generally
  328. assists with the creation and maintenance of software environments.
  329. @cindex Guix System
  330. @cindex GuixSD, now Guix System
  331. @cindex Guix System Distribution, now Guix System
  332. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  333. complements the available tools without interference (@pxref{Installation}),
  334. or you can use it as a standalone operating system distribution,
  335. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  336. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  337. group everything under the ``Guix'' banner since, after all, Guix System is
  338. readily available through the @command{guix system} command, even if you're
  339. using a different distro underneath!}. @xref{GNU Distribution}.
  340. @menu
  341. * Managing Software the Guix Way:: What's special.
  342. * GNU Distribution:: The packages and tools.
  343. @end menu
  344. @node Managing Software the Guix Way
  345. @section Managing Software the Guix Way
  346. @cindex user interfaces
  347. Guix provides a command-line package management interface
  348. (@pxref{Package Management}), tools to help with software development
  349. (@pxref{Development}), command-line utilities for more advanced usage
  350. (@pxref{Utilities}), as well as Scheme programming interfaces
  351. (@pxref{Programming Interface}).
  352. @cindex build daemon
  353. Its @dfn{build daemon} is responsible for building packages on behalf of
  354. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  355. binaries from authorized sources (@pxref{Substitutes}).
  356. @cindex extensibility of the distribution
  357. @cindex customization, of packages
  358. Guix includes package definitions for many GNU and non-GNU packages, all
  359. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  360. user's computing freedom}. It is @emph{extensible}: users can write
  361. their own package definitions (@pxref{Defining Packages}) and make them
  362. available as independent package modules (@pxref{Package Modules}). It
  363. is also @emph{customizable}: users can @emph{derive} specialized package
  364. definitions from existing ones, including from the command line
  365. (@pxref{Package Transformation Options}).
  366. @cindex functional package management
  367. @cindex isolation
  368. Under the hood, Guix implements the @dfn{functional package management}
  369. discipline pioneered by Nix (@pxref{Acknowledgments}).
  370. In Guix, the package build and installation process is seen
  371. as a @emph{function}, in the mathematical sense. That function takes inputs,
  372. such as build scripts, a compiler, and libraries, and
  373. returns an installed package. As a pure function, its result depends
  374. solely on its inputs---for instance, it cannot refer to software or
  375. scripts that were not explicitly passed as inputs. A build function
  376. always produces the same result when passed a given set of inputs. It
  377. cannot alter the environment of the running system in
  378. any way; for instance, it cannot create, modify, or delete files outside
  379. of its build and installation directories. This is achieved by running
  380. build processes in isolated environments (or @dfn{containers}), where only their
  381. explicit inputs are visible.
  382. @cindex store
  383. The result of package build functions is @dfn{cached} in the file
  384. system, in a special directory called @dfn{the store} (@pxref{The
  385. Store}). Each package is installed in a directory of its own in the
  386. store---by default under @file{/gnu/store}. The directory name contains
  387. a hash of all the inputs used to build that package; thus, changing an
  388. input yields a different directory name.
  389. This approach is the foundation for the salient features of Guix: support
  390. for transactional package upgrade and rollback, per-user installation, and
  391. garbage collection of packages (@pxref{Features}).
  392. @node GNU Distribution
  393. @section GNU Distribution
  394. @cindex Guix System
  395. Guix comes with a distribution of the GNU system consisting entirely of
  396. free software@footnote{The term ``free'' here refers to the
  397. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  398. users of that software}.}. The
  399. distribution can be installed on its own (@pxref{System Installation}),
  400. but it is also possible to install Guix as a package manager on top of
  401. an installed GNU/Linux system (@pxref{Installation}). When we need to
  402. distinguish between the two, we refer to the standalone distribution as
  403. Guix@tie{}System.
  404. The distribution provides core GNU packages such as GNU libc, GCC, and
  405. Binutils, as well as many GNU and non-GNU applications. The complete
  406. list of available packages can be browsed
  407. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  408. running @command{guix package} (@pxref{Invoking guix package}):
  409. @example
  410. guix package --list-available
  411. @end example
  412. Our goal is to provide a practical 100% free software distribution of
  413. Linux-based and other variants of GNU, with a focus on the promotion and
  414. tight integration of GNU components, and an emphasis on programs and
  415. tools that help users exert that freedom.
  416. Packages are currently available on the following platforms:
  417. @table @code
  418. @item x86_64-linux
  419. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  420. @item i686-linux
  421. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  422. @item armhf-linux
  423. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  424. using the EABI hard-float application binary interface (ABI),
  425. and Linux-Libre kernel.
  426. @item aarch64-linux
  427. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  428. @item i586-gnu
  429. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  430. (IA32).
  431. This configuration is experimental and under development. The easiest
  432. way for you to give it a try is by setting up an instance of
  433. @code{hurd-vm-service-type} on your GNU/Linux machine
  434. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  435. @xref{Contributing}, on how to help!
  436. @item mips64el-linux (deprecated)
  437. little-endian 64-bit MIPS processors, specifically the Loongson series,
  438. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  439. supported; in particular, there is no ongoing work to ensure that this
  440. architecture still works. Should someone decide they wish to revive this
  441. architecture then the code is still available.
  442. @end table
  443. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  444. configuration and Guix takes care of instantiating the configuration in a
  445. transactional, reproducible, and stateless fashion (@pxref{System
  446. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  447. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  448. Manual}), the well-known GNU utilities and tool chain, as well as the
  449. graphical environment or system services of your choice.
  450. Guix System is available on all the above platforms except
  451. @code{mips64el-linux}.
  452. @noindent
  453. For information on porting to other architectures or kernels,
  454. @pxref{Porting}.
  455. Building this distribution is a cooperative effort, and you are invited
  456. to join! @xref{Contributing}, for information about how you can help.
  457. @c *********************************************************************
  458. @node Installation
  459. @chapter Installation
  460. @cindex installing Guix
  461. @quotation Note
  462. We recommend the use of this
  463. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  464. shell installer script} to install Guix on top of a running GNU/Linux system,
  465. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  466. with the installation of the package manager, which can be done on top of a
  467. running GNU/Linux system. If, instead, you want to install the complete GNU
  468. operating system, @pxref{System Installation}.} The script automates the
  469. download, installation, and initial configuration of Guix. It should be run
  470. as the root user.
  471. @end quotation
  472. @cindex foreign distro
  473. @cindex directories related to foreign distro
  474. When installed on a foreign distro, GNU@tie{}Guix complements the available
  475. tools without interference. Its data lives exclusively in two directories,
  476. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  477. such as @file{/etc}, are left untouched.
  478. Once installed, Guix can be updated by running @command{guix pull}
  479. (@pxref{Invoking guix pull}).
  480. If you prefer to perform the installation steps manually or want to tweak
  481. them, you may find the following subsections useful. They describe the
  482. software requirements of Guix, as well as how to install it manually and get
  483. ready to use it.
  484. @menu
  485. * Binary Installation:: Getting Guix running in no time!
  486. * Requirements:: Software needed to build and run Guix.
  487. * Running the Test Suite:: Testing Guix.
  488. * Setting Up the Daemon:: Preparing the build daemon's environment.
  489. * Invoking guix-daemon:: Running the build daemon.
  490. * Application Setup:: Application-specific setup.
  491. * Upgrading Guix:: Upgrading Guix and its build daemon.
  492. @end menu
  493. @node Binary Installation
  494. @section Binary Installation
  495. @cindex installing Guix from binaries
  496. @cindex installer script
  497. This section describes how to install Guix on an arbitrary system from a
  498. self-contained tarball providing binaries for Guix and for all its
  499. dependencies. This is often quicker than installing from source, which
  500. is described in the next sections. The only requirement is to have
  501. GNU@tie{}tar and Xz.
  502. @c Note duplicated from the ``Installation'' node.
  503. @quotation Note
  504. We recommend the use of this
  505. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  506. shell installer script}. The script automates the download, installation, and
  507. initial configuration steps described below. It should be run as the root
  508. user. As root, you can thus run this:
  509. @example
  510. cd /tmp
  511. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  512. chmod +x guix-install.sh
  513. ./guix-install.sh
  514. @end example
  515. When you're done, @pxref{Application Setup} for extra configuration you
  516. might need, and @ref{Getting Started} for your first steps!
  517. @end quotation
  518. Installing goes along these lines:
  519. @enumerate
  520. @item
  521. @cindex downloading Guix binary
  522. Download the binary tarball from
  523. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  524. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  525. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  526. (@pxref{GNU Distribution}).
  527. @c The following is somewhat duplicated in ``System Installation''.
  528. Make sure to download the associated @file{.sig} file and to verify the
  529. authenticity of the tarball against it, along these lines:
  530. @example
  531. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  532. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  533. @end example
  534. If that command fails because you do not have the required public key,
  535. then run this command to import it:
  536. @example
  537. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  538. -qO - | gpg --import -
  539. @end example
  540. @noindent
  541. and rerun the @code{gpg --verify} command.
  542. Take note that a warning like ``This key is not certified with a trusted
  543. signature!'' is normal.
  544. @c end authentication part
  545. @item
  546. Now, you need to become the @code{root} user. Depending on your distribution,
  547. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  548. @example
  549. # cd /tmp
  550. # tar --warning=no-timestamp -xf \
  551. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  552. # mv var/guix /var/ && mv gnu /
  553. @end example
  554. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  555. The latter contains a ready-to-use profile for @code{root} (see next
  556. step).
  557. Do @emph{not} unpack the tarball on a working Guix system since that
  558. would overwrite its own essential files.
  559. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  560. not emit warnings about ``implausibly old time stamps'' (such
  561. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  562. versions are fine).
  563. They stem from the fact that all the
  564. files in the archive have their modification time set to 1 (which
  565. means January 1st, 1970). This is done on purpose to make sure the
  566. archive content is independent of its creation time, thus making it
  567. reproducible.
  568. @item
  569. Make the profile available under @file{~root/.config/guix/current}, which is
  570. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  571. @example
  572. # mkdir -p ~root/.config/guix
  573. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  574. ~root/.config/guix/current
  575. @end example
  576. Source @file{etc/profile} to augment @env{PATH} and other relevant
  577. environment variables:
  578. @example
  579. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  580. source $GUIX_PROFILE/etc/profile
  581. @end example
  582. @item
  583. Create the group and user accounts for build users as explained below
  584. (@pxref{Build Environment Setup}).
  585. @item
  586. Run the daemon, and set it to automatically start on boot.
  587. If your host distro uses the systemd init system, this can be achieved
  588. with these commands:
  589. @c Versions of systemd that supported symlinked service files are not
  590. @c yet widely deployed, so we should suggest that users copy the service
  591. @c files into place.
  592. @c
  593. @c See this thread for more information:
  594. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  595. @example
  596. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  597. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  598. /etc/systemd/system/
  599. # systemctl enable --now gnu-store.mount guix-daemon
  600. @end example
  601. If your host distro uses the Upstart init system:
  602. @example
  603. # initctl reload-configuration
  604. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  605. /etc/init/
  606. # start guix-daemon
  607. @end example
  608. Otherwise, you can still start the daemon manually with:
  609. @example
  610. # ~root/.config/guix/current/bin/guix-daemon \
  611. --build-users-group=guixbuild
  612. @end example
  613. @item
  614. Make the @command{guix} command available to other users on the machine,
  615. for instance with:
  616. @example
  617. # mkdir -p /usr/local/bin
  618. # cd /usr/local/bin
  619. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  620. @end example
  621. It is also a good idea to make the Info version of this manual available
  622. there:
  623. @example
  624. # mkdir -p /usr/local/share/info
  625. # cd /usr/local/share/info
  626. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  627. do ln -s $i ; done
  628. @end example
  629. That way, assuming @file{/usr/local/share/info} is in the search path,
  630. running @command{info guix} will open this manual (@pxref{Other Info
  631. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  632. Info search path).
  633. @item
  634. @cindex substitutes, authorization thereof
  635. To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
  636. (@pxref{Substitutes}), authorize them:
  637. @example
  638. # guix archive --authorize < \
  639. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
  640. @end example
  641. @item
  642. Each user may need to perform a few additional steps to make their Guix
  643. environment ready for use, @pxref{Application Setup}.
  644. @end enumerate
  645. Voilà, the installation is complete!
  646. You can confirm that Guix is working by installing a sample package into
  647. the root profile:
  648. @example
  649. # guix install hello
  650. @end example
  651. The binary installation tarball can be (re)produced and verified simply
  652. by running the following command in the Guix source tree:
  653. @example
  654. make guix-binary.@var{system}.tar.xz
  655. @end example
  656. @noindent
  657. ...@: which, in turn, runs:
  658. @example
  659. guix pack -s @var{system} --localstatedir \
  660. --profile-name=current-guix guix
  661. @end example
  662. @xref{Invoking guix pack}, for more info on this handy tool.
  663. @node Requirements
  664. @section Requirements
  665. This section lists requirements when building Guix from source. The
  666. build procedure for Guix is the same as for other GNU software, and is
  667. not covered here. Please see the files @file{README} and @file{INSTALL}
  668. in the Guix source tree for additional details.
  669. @cindex official website
  670. GNU Guix is available for download from its website at
  671. @url{https://www.gnu.org/software/guix/}.
  672. GNU Guix depends on the following packages:
  673. @itemize
  674. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x or
  675. 2.2.x;
  676. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  677. 0.1.0 or later;
  678. @item
  679. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  680. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  681. Guile,, gnutls-guile, GnuTLS-Guile});
  682. @item
  683. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  684. or later;
  685. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib};
  686. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  687. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  688. @item
  689. @c FIXME: Specify a version number once a release has been made.
  690. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.3.0
  691. or later;
  692. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  693. 4.3.0 or later;
  694. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  695. @end itemize
  696. The following dependencies are optional:
  697. @itemize
  698. @item
  699. @c Note: We need at least 0.13.0 for #:nodelay.
  700. Support for build offloading (@pxref{Daemon Offload Setup}) and
  701. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  702. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  703. version 0.13.0 or later.
  704. @item
  705. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  706. compression and decompression in @command{guix publish} and for
  707. substitutes (@pxref{Invoking guix publish}).
  708. @item
  709. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  710. the @code{crate} importer (@pxref{Invoking guix import}).
  711. @item
  712. When @url{http://www.bzip.org, libbz2} is available,
  713. @command{guix-daemon} can use it to compress build logs.
  714. @end itemize
  715. Unless @option{--disable-daemon} was passed to @command{configure}, the
  716. following packages are also needed:
  717. @itemize
  718. @item @url{https://gnupg.org/, GNU libgcrypt};
  719. @item @url{https://sqlite.org, SQLite 3};
  720. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  721. C++11 standard.
  722. @end itemize
  723. @cindex state directory
  724. When configuring Guix on a system that already has a Guix installation,
  725. be sure to specify the same state directory as the existing installation
  726. using the @option{--localstatedir} option of the @command{configure}
  727. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  728. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  729. set to the value @file{/var}. The @command{configure} script protects
  730. against unintended misconfiguration of @var{localstatedir} so you do not
  731. inadvertently corrupt your store (@pxref{The Store}).
  732. @node Running the Test Suite
  733. @section Running the Test Suite
  734. @cindex test suite
  735. After a successful @command{configure} and @code{make} run, it is a good
  736. idea to run the test suite. It can help catch issues with the setup or
  737. environment, or bugs in Guix itself---and really, reporting test
  738. failures is a good way to help improve the software. To run the test
  739. suite, type:
  740. @example
  741. make check
  742. @end example
  743. Test cases can run in parallel: you can use the @code{-j} option of
  744. GNU@tie{}make to speed things up. The first run may take a few minutes
  745. on a recent machine; subsequent runs will be faster because the store
  746. that is created for test purposes will already have various things in
  747. cache.
  748. It is also possible to run a subset of the tests by defining the
  749. @code{TESTS} makefile variable as in this example:
  750. @example
  751. make check TESTS="tests/store.scm tests/cpio.scm"
  752. @end example
  753. By default, tests results are displayed at a file level. In order to
  754. see the details of every individual test cases, it is possible to define
  755. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  756. @example
  757. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  758. @end example
  759. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  760. @file{test-suite.log} file. Please specify the Guix version being used
  761. as well as version numbers of the dependencies (@pxref{Requirements}) in
  762. your message.
  763. Guix also comes with a whole-system test suite that tests complete
  764. Guix System instances. It can only run on systems where
  765. Guix is already installed, using:
  766. @example
  767. make check-system
  768. @end example
  769. @noindent
  770. or, again, by defining @code{TESTS} to select a subset of tests to run:
  771. @example
  772. make check-system TESTS="basic mcron"
  773. @end example
  774. These system tests are defined in the @code{(gnu tests @dots{})}
  775. modules. They work by running the operating systems under test with
  776. lightweight instrumentation in a virtual machine (VM). They can be
  777. computationally intensive or rather cheap, depending on whether
  778. substitutes are available for their dependencies (@pxref{Substitutes}).
  779. Some of them require a lot of storage space to hold VM images.
  780. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  781. all the details.
  782. @node Setting Up the Daemon
  783. @section Setting Up the Daemon
  784. @cindex daemon
  785. Operations such as building a package or running the garbage collector
  786. are all performed by a specialized process, the @dfn{build daemon}, on
  787. behalf of clients. Only the daemon may access the store and its
  788. associated database. Thus, any operation that manipulates the store
  789. goes through the daemon. For instance, command-line tools such as
  790. @command{guix package} and @command{guix build} communicate with the
  791. daemon (@i{via} remote procedure calls) to instruct it what to do.
  792. The following sections explain how to prepare the build daemon's
  793. environment. See also @ref{Substitutes}, for information on how to allow
  794. the daemon to download pre-built binaries.
  795. @menu
  796. * Build Environment Setup:: Preparing the isolated build environment.
  797. * Daemon Offload Setup:: Offloading builds to remote machines.
  798. * SELinux Support:: Using an SELinux policy for the daemon.
  799. @end menu
  800. @node Build Environment Setup
  801. @subsection Build Environment Setup
  802. @cindex build environment
  803. In a standard multi-user setup, Guix and its daemon---the
  804. @command{guix-daemon} program---are installed by the system
  805. administrator; @file{/gnu/store} is owned by @code{root} and
  806. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  807. Guix tools to build packages or otherwise access the store, and the
  808. daemon will do it on their behalf, ensuring that the store is kept in a
  809. consistent state, and allowing built packages to be shared among users.
  810. @cindex build users
  811. When @command{guix-daemon} runs as @code{root}, you may not want package
  812. build processes themselves to run as @code{root} too, for obvious
  813. security reasons. To avoid that, a special pool of @dfn{build users}
  814. should be created for use by build processes started by the daemon.
  815. These build users need not have a shell and a home directory: they will
  816. just be used when the daemon drops @code{root} privileges in build
  817. processes. Having several such users allows the daemon to launch
  818. distinct build processes under separate UIDs, which guarantees that they
  819. do not interfere with each other---an essential feature since builds are
  820. regarded as pure functions (@pxref{Introduction}).
  821. On a GNU/Linux system, a build user pool may be created like this (using
  822. Bash syntax and the @code{shadow} commands):
  823. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  824. @c for why `-G' is needed.
  825. @example
  826. # groupadd --system guixbuild
  827. # for i in `seq -w 1 10`;
  828. do
  829. useradd -g guixbuild -G guixbuild \
  830. -d /var/empty -s `which nologin` \
  831. -c "Guix build user $i" --system \
  832. guixbuilder$i;
  833. done
  834. @end example
  835. @noindent
  836. The number of build users determines how many build jobs may run in
  837. parallel, as specified by the @option{--max-jobs} option
  838. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  839. @command{guix system vm} and related commands, you may need to add the
  840. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  841. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  842. (@pxref{Invoking guix system}).
  843. The @code{guix-daemon} program may then be run as @code{root} with the
  844. following command@footnote{If your machine uses the systemd init system,
  845. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  846. file in @file{/etc/systemd/system} will ensure that
  847. @command{guix-daemon} is automatically started. Similarly, if your
  848. machine uses the Upstart init system, drop the
  849. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  850. file in @file{/etc/init}.}:
  851. @example
  852. # guix-daemon --build-users-group=guixbuild
  853. @end example
  854. @cindex chroot
  855. @noindent
  856. This way, the daemon starts build processes in a chroot, under one of
  857. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  858. environment contains nothing but:
  859. @c Keep this list in sync with libstore/build.cc! -----------------------
  860. @itemize
  861. @item
  862. a minimal @code{/dev} directory, created mostly independently from the
  863. host @code{/dev}@footnote{``Mostly'', because while the set of files
  864. that appear in the chroot's @code{/dev} is fixed, most of these files
  865. can only be created if the host has them.};
  866. @item
  867. the @code{/proc} directory; it only shows the processes of the container
  868. since a separate PID name space is used;
  869. @item
  870. @file{/etc/passwd} with an entry for the current user and an entry for
  871. user @file{nobody};
  872. @item
  873. @file{/etc/group} with an entry for the user's group;
  874. @item
  875. @file{/etc/hosts} with an entry that maps @code{localhost} to
  876. @code{127.0.0.1};
  877. @item
  878. a writable @file{/tmp} directory.
  879. @end itemize
  880. You can influence the directory where the daemon stores build trees
  881. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  882. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  883. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  884. This way, the value of @env{TMPDIR} does not leak inside build
  885. environments, which avoids discrepancies in cases where build processes
  886. capture the name of their build tree.
  887. @vindex http_proxy
  888. @vindex https_proxy
  889. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  890. environment variables for HTTP and HTTPS downloads it performs, be it
  891. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  892. (@pxref{Substitutes}).
  893. If you are installing Guix as an unprivileged user, it is still possible
  894. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  895. However, build processes will not be isolated from one another, and not
  896. from the rest of the system. Thus, build processes may interfere with
  897. each other, and may access programs, libraries, and other files
  898. available on the system---making it much harder to view them as
  899. @emph{pure} functions.
  900. @node Daemon Offload Setup
  901. @subsection Using the Offload Facility
  902. @cindex offloading
  903. @cindex build hook
  904. When desired, the build daemon can @dfn{offload} derivation builds to
  905. other machines running Guix, using the @code{offload} @dfn{build
  906. hook}@footnote{This feature is available only when
  907. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  908. present.}. When that feature is enabled, a list of user-specified build
  909. machines is read from @file{/etc/guix/machines.scm}; every time a build
  910. is requested, for instance via @code{guix build}, the daemon attempts to
  911. offload it to one of the machines that satisfy the constraints of the
  912. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  913. A single machine can have multiple system types, either because its
  914. architecture natively supports it, via emulation
  915. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  916. or both. Missing prerequisites for the build are
  917. copied over SSH to the target machine, which then proceeds with the
  918. build; upon success the output(s) of the build are copied back to the
  919. initial machine. The offload facility comes with a basic scheduler that
  920. attempts to select the best machine. The best machine is chosen among
  921. the available machines based on criteria such as:
  922. @enumerate
  923. @item
  924. The availability of a build slot. A build machine can have as many
  925. build slots (connections) as the value of the @code{parallel-builds}
  926. field of its @code{build-machine} object.
  927. @item
  928. Its relative speed, as defined via the @code{speed} field of its
  929. @code{build-machine} object.
  930. @item
  931. Its load. The normalized machine load must be lower than a threshold
  932. value, configurable via the @code{overload-threshold} field of its
  933. @code{build-machine} object.
  934. @item
  935. Disk space availability. More than a 100 MiB must be available.
  936. @end enumerate
  937. The @file{/etc/guix/machines.scm} file typically looks like this:
  938. @lisp
  939. (list (build-machine
  940. (name "eightysix.example.org")
  941. (systems (list "x86_64-linux" "i686-linux"))
  942. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  943. (user "bob")
  944. (speed 2.)) ;incredibly fast!
  945. (build-machine
  946. (name "armeight.example.org")
  947. (systems (list "aarch64-linux"))
  948. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  949. (user "alice")
  950. (private-key
  951. (string-append (getenv "HOME")
  952. "/.ssh/identity-for-guix"))))
  953. @end lisp
  954. @noindent
  955. In the example above we specify a list of two build machines, one for
  956. the @code{x86_64} and @code{i686} architectures and one for the
  957. @code{aarch64} architecture.
  958. In fact, this file is---not surprisingly!---a Scheme file that is
  959. evaluated when the @code{offload} hook is started. Its return value
  960. must be a list of @code{build-machine} objects. While this example
  961. shows a fixed list of build machines, one could imagine, say, using
  962. DNS-SD to return a list of potential build machines discovered in the
  963. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  964. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  965. detailed below.
  966. @deftp {Data Type} build-machine
  967. This data type represents build machines to which the daemon may offload
  968. builds. The important fields are:
  969. @table @code
  970. @item name
  971. The host name of the remote machine.
  972. @item systems
  973. The system types the remote machine supports---e.g., @code{(list
  974. "x86_64-linux" "i686-linux")}.
  975. @item user
  976. The user account to use when connecting to the remote machine over SSH.
  977. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  978. allow non-interactive logins.
  979. @item host-key
  980. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  981. This is used to authenticate the machine when we connect to it. It is a
  982. long string that looks like this:
  983. @example
  984. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  985. @end example
  986. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  987. key can be found in a file such as
  988. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  989. If the machine is running the SSH daemon of GNU@tie{}lsh,
  990. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  991. similar file. It can be converted to the OpenSSH format using
  992. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  993. @example
  994. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  995. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  996. @end example
  997. @end table
  998. A number of optional fields may be specified:
  999. @table @asis
  1000. @item @code{port} (default: @code{22})
  1001. Port number of SSH server on the machine.
  1002. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1003. The SSH private key file to use when connecting to the machine, in
  1004. OpenSSH format. This key must not be protected with a passphrase.
  1005. Note that the default value is the private key @emph{of the root
  1006. account}. Make sure it exists if you use the default.
  1007. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1008. @itemx @code{compression-level} (default: @code{3})
  1009. The SSH-level compression methods and compression level requested.
  1010. Note that offloading relies on SSH compression to reduce bandwidth usage
  1011. when transferring files to and from build machines.
  1012. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1013. File name of the Unix-domain socket @command{guix-daemon} is listening
  1014. to on that machine.
  1015. @item @code{overload-threshold} (default: @code{0.6})
  1016. The load threshold above which a potential offload machine is
  1017. disregarded by the offload scheduler. The value roughly translates to
  1018. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1019. 1.0 (100%). It can also be disabled by setting
  1020. @code{overload-threshold} to @code{#f}.
  1021. @item @code{parallel-builds} (default: @code{1})
  1022. The number of builds that may run in parallel on the machine.
  1023. @item @code{speed} (default: @code{1.0})
  1024. A ``relative speed factor''. The offload scheduler will tend to prefer
  1025. machines with a higher speed factor.
  1026. @item @code{features} (default: @code{'()})
  1027. A list of strings denoting specific features supported by the machine.
  1028. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1029. and corresponding hardware support. Derivations can request features by
  1030. name, and they will be scheduled on matching build machines.
  1031. @end table
  1032. @end deftp
  1033. The @command{guix} command must be in the search path on the build
  1034. machines. You can check whether this is the case by running:
  1035. @example
  1036. ssh build-machine guix repl --version
  1037. @end example
  1038. There is one last thing to do once @file{machines.scm} is in place. As
  1039. explained above, when offloading, files are transferred back and forth
  1040. between the machine stores. For this to work, you first need to
  1041. generate a key pair on each machine to allow the daemon to export signed
  1042. archives of files from the store (@pxref{Invoking guix archive}):
  1043. @example
  1044. # guix archive --generate-key
  1045. @end example
  1046. @noindent
  1047. Each build machine must authorize the key of the master machine so that
  1048. it accepts store items it receives from the master:
  1049. @example
  1050. # guix archive --authorize < master-public-key.txt
  1051. @end example
  1052. @noindent
  1053. Likewise, the master machine must authorize the key of each build machine.
  1054. All the fuss with keys is here to express pairwise mutual trust
  1055. relations between the master and the build machines. Concretely, when
  1056. the master receives files from a build machine (and @i{vice versa}), its
  1057. build daemon can make sure they are genuine, have not been tampered
  1058. with, and that they are signed by an authorized key.
  1059. @cindex offload test
  1060. To test whether your setup is operational, run this command on the
  1061. master node:
  1062. @example
  1063. # guix offload test
  1064. @end example
  1065. This will attempt to connect to each of the build machines specified in
  1066. @file{/etc/guix/machines.scm}, make sure Guix is
  1067. available on each machine, attempt to export to the machine and import
  1068. from it, and report any error in the process.
  1069. If you want to test a different machine file, just specify it on the
  1070. command line:
  1071. @example
  1072. # guix offload test machines-qualif.scm
  1073. @end example
  1074. Last, you can test the subset of the machines whose name matches a
  1075. regular expression like this:
  1076. @example
  1077. # guix offload test machines.scm '\.gnu\.org$'
  1078. @end example
  1079. @cindex offload status
  1080. To display the current load of all build hosts, run this command on the
  1081. main node:
  1082. @example
  1083. # guix offload status
  1084. @end example
  1085. @node SELinux Support
  1086. @subsection SELinux Support
  1087. @cindex SELinux, daemon policy
  1088. @cindex mandatory access control, SELinux
  1089. @cindex security, guix-daemon
  1090. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1091. can be installed on a system where SELinux is enabled, in order to label
  1092. Guix files and to specify the expected behavior of the daemon. Since
  1093. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1094. be used on Guix System.
  1095. @subsubsection Installing the SELinux policy
  1096. @cindex SELinux, policy installation
  1097. To install the policy run this command as root:
  1098. @example
  1099. semodule -i etc/guix-daemon.cil
  1100. @end example
  1101. Then relabel the file system with @code{restorecon} or by a different
  1102. mechanism provided by your system.
  1103. Once the policy is installed, the file system has been relabeled, and
  1104. the daemon has been restarted, it should be running in the
  1105. @code{guix_daemon_t} context. You can confirm this with the following
  1106. command:
  1107. @example
  1108. ps -Zax | grep guix-daemon
  1109. @end example
  1110. Monitor the SELinux log files as you run a command like @code{guix build
  1111. hello} to convince yourself that SELinux permits all necessary
  1112. operations.
  1113. @subsubsection Limitations
  1114. @cindex SELinux, limitations
  1115. This policy is not perfect. Here is a list of limitations or quirks
  1116. that should be considered when deploying the provided SELinux policy for
  1117. the Guix daemon.
  1118. @enumerate
  1119. @item
  1120. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1121. operations involve contexts that have anything to do with
  1122. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1123. but it would be preferrable to define socket rules for only this label.
  1124. @item
  1125. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1126. the file label of the destination of a symlink is independent of the
  1127. file label of the link itself. Although all profiles under
  1128. $localstatedir are labelled, the links to these profiles inherit the
  1129. label of the directory they are in. For links in the user’s home
  1130. directory this will be @code{user_home_t}. But for links from the root
  1131. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1132. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1133. reading and following these links.
  1134. @item
  1135. The daemon’s feature to listen for TCP connections might no longer work.
  1136. This might require extra rules, because SELinux treats network sockets
  1137. differently from files.
  1138. @item
  1139. Currently all files with a name matching the regular expression
  1140. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1141. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1142. that name in any profile would be permitted to run in the
  1143. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1144. build a package that provides this executable and convince a user to
  1145. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1146. At that point SELinux could not prevent it from accessing files that are
  1147. allowed for processes in that domain.
  1148. You will need to relabel the store directory after all upgrades to
  1149. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1150. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1151. or by other means provided by your operating system.
  1152. We could generate a much more restrictive policy at installation time,
  1153. so that only the @emph{exact} file name of the currently installed
  1154. @code{guix-daemon} executable would be labelled with
  1155. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1156. The downside is that root would have to install or upgrade the policy at
  1157. installation time whenever the Guix package that provides the
  1158. effectively running @code{guix-daemon} executable is upgraded.
  1159. @end enumerate
  1160. @node Invoking guix-daemon
  1161. @section Invoking @command{guix-daemon}
  1162. The @command{guix-daemon} program implements all the functionality to
  1163. access the store. This includes launching build processes, running the
  1164. garbage collector, querying the availability of a build result, etc. It
  1165. is normally run as @code{root} like this:
  1166. @example
  1167. # guix-daemon --build-users-group=guixbuild
  1168. @end example
  1169. @noindent
  1170. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1171. @cindex chroot
  1172. @cindex container, build environment
  1173. @cindex build environment
  1174. @cindex reproducible builds
  1175. By default, @command{guix-daemon} launches build processes under
  1176. different UIDs, taken from the build group specified with
  1177. @option{--build-users-group}. In addition, each build process is run in a
  1178. chroot environment that only contains the subset of the store that the
  1179. build process depends on, as specified by its derivation
  1180. (@pxref{Programming Interface, derivation}), plus a set of specific
  1181. system directories. By default, the latter contains @file{/dev} and
  1182. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1183. @dfn{container}: in addition to having its own file system tree, it has
  1184. a separate mount name space, its own PID name space, network name space,
  1185. etc. This helps achieve reproducible builds (@pxref{Features}).
  1186. When the daemon performs a build on behalf of the user, it creates a
  1187. build directory under @file{/tmp} or under the directory specified by
  1188. its @env{TMPDIR} environment variable. This directory is shared with
  1189. the container for the duration of the build, though within the container,
  1190. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1191. The build directory is automatically deleted upon completion, unless the
  1192. build failed and the client specified @option{--keep-failed}
  1193. (@pxref{Invoking guix build, @option{--keep-failed}}).
  1194. The daemon listens for connections and spawns one sub-process for each session
  1195. started by a client (one of the @command{guix} sub-commands). The
  1196. @command{guix processes} command allows you to get an overview of the activity
  1197. on your system by viewing each of the active sessions and clients.
  1198. @xref{Invoking guix processes}, for more information.
  1199. The following command-line options are supported:
  1200. @table @code
  1201. @item --build-users-group=@var{group}
  1202. Take users from @var{group} to run build processes (@pxref{Setting Up
  1203. the Daemon, build users}).
  1204. @item --no-substitutes
  1205. @cindex substitutes
  1206. Do not use substitutes for build products. That is, always build things
  1207. locally instead of allowing downloads of pre-built binaries
  1208. (@pxref{Substitutes}).
  1209. When the daemon runs with @option{--no-substitutes}, clients can still
  1210. explicitly enable substitution @i{via} the @code{set-build-options}
  1211. remote procedure call (@pxref{The Store}).
  1212. @anchor{daemon-substitute-urls}
  1213. @item --substitute-urls=@var{urls}
  1214. Consider @var{urls} the default whitespace-separated list of substitute
  1215. source URLs. When this option is omitted,
  1216. @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
  1217. This means that substitutes may be downloaded from @var{urls}, as long
  1218. as they are signed by a trusted signature (@pxref{Substitutes}).
  1219. @xref{Getting Substitutes from Other Servers}, for more information on
  1220. how to configure the daemon to get substitutes from other servers.
  1221. @cindex offloading
  1222. @item --no-offload
  1223. Do not use offload builds to other machines (@pxref{Daemon Offload
  1224. Setup}). That is, always build things locally instead of offloading
  1225. builds to remote machines.
  1226. @item --cache-failures
  1227. Cache build failures. By default, only successful builds are cached.
  1228. When this option is used, @command{guix gc --list-failures} can be used
  1229. to query the set of store items marked as failed; @command{guix gc
  1230. --clear-failures} removes store items from the set of cached failures.
  1231. @xref{Invoking guix gc}.
  1232. @item --cores=@var{n}
  1233. @itemx -c @var{n}
  1234. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1235. as available.
  1236. The default value is @code{0}, but it may be overridden by clients, such
  1237. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1238. guix build}).
  1239. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1240. in the build process, which can then use it to exploit internal
  1241. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1242. @item --max-jobs=@var{n}
  1243. @itemx -M @var{n}
  1244. Allow at most @var{n} build jobs in parallel. The default value is
  1245. @code{1}. Setting it to @code{0} means that no builds will be performed
  1246. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1247. Setup}), or simply fail.
  1248. @item --max-silent-time=@var{seconds}
  1249. When the build or substitution process remains silent for more than
  1250. @var{seconds}, terminate it and report a build failure.
  1251. The default value is @code{0}, which disables the timeout.
  1252. The value specified here can be overridden by clients (@pxref{Common
  1253. Build Options, @option{--max-silent-time}}).
  1254. @item --timeout=@var{seconds}
  1255. Likewise, when the build or substitution process lasts for more than
  1256. @var{seconds}, terminate it and report a build failure.
  1257. The default value is @code{0}, which disables the timeout.
  1258. The value specified here can be overridden by clients (@pxref{Common
  1259. Build Options, @option{--timeout}}).
  1260. @item --rounds=@var{N}
  1261. Build each derivation @var{n} times in a row, and raise an error if
  1262. consecutive build results are not bit-for-bit identical. Note that this
  1263. setting can be overridden by clients such as @command{guix build}
  1264. (@pxref{Invoking guix build}).
  1265. When used in conjunction with @option{--keep-failed}, the differing
  1266. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1267. This makes it easy to look for differences between the two results.
  1268. @item --debug
  1269. Produce debugging output.
  1270. This is useful to debug daemon start-up issues, but then it may be
  1271. overridden by clients, for example the @option{--verbosity} option of
  1272. @command{guix build} (@pxref{Invoking guix build}).
  1273. @item --chroot-directory=@var{dir}
  1274. Add @var{dir} to the build chroot.
  1275. Doing this may change the result of build processes---for instance if
  1276. they use optional dependencies found in @var{dir} when it is available,
  1277. and not otherwise. For that reason, it is not recommended to do so.
  1278. Instead, make sure that each derivation declares all the inputs that it
  1279. needs.
  1280. @item --disable-chroot
  1281. Disable chroot builds.
  1282. Using this option is not recommended since, again, it would allow build
  1283. processes to gain access to undeclared dependencies. It is necessary,
  1284. though, when @command{guix-daemon} is running under an unprivileged user
  1285. account.
  1286. @item --log-compression=@var{type}
  1287. Compress build logs according to @var{type}, one of @code{gzip},
  1288. @code{bzip2}, or @code{none}.
  1289. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1290. @var{localstatedir}. To save space, the daemon automatically compresses
  1291. them with Bzip2 by default.
  1292. @item --discover[=yes|no]
  1293. Whether to discover substitute servers on the local network using mDNS
  1294. and DNS-SD.
  1295. This feature is still experimental. However, here are a few
  1296. considerations.
  1297. @enumerate
  1298. @item
  1299. It might be faster/less expensive than fetching from remote servers;
  1300. @item
  1301. There are no security risks, only genuine substitutes will be used
  1302. (@pxref{Substitute Authentication});
  1303. @item
  1304. An attacker advertising @command{guix publish} on your LAN cannot serve
  1305. you malicious binaries, but they can learn what software you’re
  1306. installing;
  1307. @item
  1308. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1309. LAN can see what software you’re installing.
  1310. @end enumerate
  1311. It is also possible to enable or disable substitute server discovery at
  1312. run-time by running:
  1313. @example
  1314. herd discover guix-daemon on
  1315. herd discover guix-daemon off
  1316. @end example
  1317. @item --disable-deduplication
  1318. @cindex deduplication
  1319. Disable automatic file ``deduplication'' in the store.
  1320. By default, files added to the store are automatically ``deduplicated'':
  1321. if a newly added file is identical to another one found in the store,
  1322. the daemon makes the new file a hard link to the other file. This can
  1323. noticeably reduce disk usage, at the expense of slightly increased
  1324. input/output load at the end of a build process. This option disables
  1325. this optimization.
  1326. @item --gc-keep-outputs[=yes|no]
  1327. Tell whether the garbage collector (GC) must keep outputs of live
  1328. derivations.
  1329. @cindex GC roots
  1330. @cindex garbage collector roots
  1331. When set to @code{yes}, the GC will keep the outputs of any live
  1332. derivation available in the store---the @file{.drv} files. The default
  1333. is @code{no}, meaning that derivation outputs are kept only if they are
  1334. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1335. roots.
  1336. @item --gc-keep-derivations[=yes|no]
  1337. Tell whether the garbage collector (GC) must keep derivations
  1338. corresponding to live outputs.
  1339. When set to @code{yes}, as is the case by default, the GC keeps
  1340. derivations---i.e., @file{.drv} files---as long as at least one of their
  1341. outputs is live. This allows users to keep track of the origins of
  1342. items in their store. Setting it to @code{no} saves a bit of disk
  1343. space.
  1344. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1345. liveness to flow from outputs to derivations, and setting
  1346. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1347. derivations to outputs. When both are set to @code{yes}, the effect is
  1348. to keep all the build prerequisites (the sources, compiler, libraries,
  1349. and other build-time tools) of live objects in the store, regardless of
  1350. whether these prerequisites are reachable from a GC root. This is
  1351. convenient for developers since it saves rebuilds or downloads.
  1352. @item --impersonate-linux-2.6
  1353. On Linux-based systems, impersonate Linux 2.6. This means that the
  1354. kernel's @command{uname} system call will report 2.6 as the release number.
  1355. This might be helpful to build programs that (usually wrongfully) depend
  1356. on the kernel version number.
  1357. @item --lose-logs
  1358. Do not keep build logs. By default they are kept under
  1359. @file{@var{localstatedir}/guix/log}.
  1360. @item --system=@var{system}
  1361. Assume @var{system} as the current system type. By default it is the
  1362. architecture/kernel pair found at configure time, such as
  1363. @code{x86_64-linux}.
  1364. @item --listen=@var{endpoint}
  1365. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1366. as the file name of a Unix-domain socket if it starts with
  1367. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1368. host name or host name and port to listen to. Here are a few examples:
  1369. @table @code
  1370. @item --listen=/gnu/var/daemon
  1371. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1372. creating it if needed.
  1373. @item --listen=localhost
  1374. @cindex daemon, remote access
  1375. @cindex remote access to the daemon
  1376. @cindex daemon, cluster setup
  1377. @cindex clusters, daemon setup
  1378. Listen for TCP connections on the network interface corresponding to
  1379. @code{localhost}, on port 44146.
  1380. @item --listen=128.0.0.42:1234
  1381. Listen for TCP connections on the network interface corresponding to
  1382. @code{128.0.0.42}, on port 1234.
  1383. @end table
  1384. This option can be repeated multiple times, in which case
  1385. @command{guix-daemon} accepts connections on all the specified
  1386. endpoints. Users can tell client commands what endpoint to connect to
  1387. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1388. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1389. @quotation Note
  1390. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1391. @option{--listen=@var{host}} is suitable on local networks, such as
  1392. clusters, where only trusted nodes may connect to the build daemon. In
  1393. other cases where remote access to the daemon is needed, we recommend
  1394. using Unix-domain sockets along with SSH.
  1395. @end quotation
  1396. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1397. connections on the Unix-domain socket located at
  1398. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1399. @end table
  1400. @node Application Setup
  1401. @section Application Setup
  1402. @cindex foreign distro
  1403. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1404. so-called @dfn{foreign distro}---a few additional steps are needed to
  1405. get everything in place. Here are some of them.
  1406. @subsection Locales
  1407. @anchor{locales-and-locpath}
  1408. @cindex locales, when not on Guix System
  1409. @vindex LOCPATH
  1410. @vindex GUIX_LOCPATH
  1411. Packages installed @i{via} Guix will not use the locale data of the
  1412. host system. Instead, you must first install one of the locale packages
  1413. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1414. variable:
  1415. @example
  1416. $ guix install glibc-locales
  1417. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1418. @end example
  1419. Note that the @code{glibc-locales} package contains data for all the
  1420. locales supported by the GNU@tie{}libc and weighs in at around
  1421. 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1422. limited to a few UTF-8 locales.
  1423. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1424. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1425. Manual}). There are two important differences though:
  1426. @enumerate
  1427. @item
  1428. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1429. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1430. to make sure the programs of the foreign distro will not end up loading
  1431. incompatible locale data.
  1432. @item
  1433. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1434. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1435. should your Guix profile contain a mixture of programs linked against
  1436. different libc version, each libc version will only try to load locale
  1437. data in the right format.
  1438. @end enumerate
  1439. This is important because the locale data format used by different libc
  1440. versions may be incompatible.
  1441. @subsection Name Service Switch
  1442. @cindex name service switch, glibc
  1443. @cindex NSS (name service switch), glibc
  1444. @cindex nscd (name service caching daemon)
  1445. @cindex name service caching daemon (nscd)
  1446. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1447. the system run the GNU C library's @dfn{name service cache daemon},
  1448. @command{nscd}, which should be listening on the
  1449. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1450. installed with Guix may fail to look up host names or user accounts, or
  1451. may even crash. The next paragraphs explain why.
  1452. @cindex @file{nsswitch.conf}
  1453. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1454. an extensible mechanism for ``name lookups'' in general: host name
  1455. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1456. The GNU C Library Reference Manual}).
  1457. @cindex Network information service (NIS)
  1458. @cindex NIS (Network information service)
  1459. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1460. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1461. resolution of @code{.local} host names, the @code{nis} plugin allows
  1462. user account lookup using the Network information service (NIS), and so
  1463. on. These extra ``lookup services'' are configured system-wide in
  1464. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1465. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1466. Reference Manual}).
  1467. When they perform a name lookup---for instance by calling the
  1468. @code{getaddrinfo} function in C---applications first try to connect to
  1469. the nscd; on success, nscd performs name lookups on their behalf. If
  1470. the nscd is not running, then they perform the name lookup by
  1471. themselves, by loading the name lookup services into their own address
  1472. space and running it. These name lookup services---the
  1473. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1474. the host system's C library, rather than from the C library the
  1475. application is linked against (the C library coming from Guix).
  1476. And this is where the problem is: if your application is linked against
  1477. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1478. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1479. likely crash or have its name lookups fail unexpectedly.
  1480. Running @command{nscd} on the system, among other advantages, eliminates
  1481. this binary incompatibility problem because those @code{libnss_*.so}
  1482. files are loaded in the @command{nscd} process, not in applications
  1483. themselves.
  1484. @subsection X11 Fonts
  1485. @cindex fonts
  1486. The majority of graphical applications use Fontconfig to locate and
  1487. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1488. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1489. by default. Thus, to allow graphical applications installed with Guix
  1490. to display fonts, you have to install fonts with Guix as well.
  1491. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1492. @code{font-gnu-freefont}.
  1493. @cindex @code{fc-cache}
  1494. @cindex font cache
  1495. Once you have installed or removed fonts, or when you notice an
  1496. application that does not find fonts, you may need to install Fontconfig
  1497. and to force an update of its font cache by running:
  1498. @example
  1499. guix install fontconfig
  1500. fc-cache -rv
  1501. @end example
  1502. To display text written in Chinese languages, Japanese, or Korean in
  1503. graphical applications, consider installing
  1504. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1505. has multiple outputs, one per language family (@pxref{Packages with
  1506. Multiple Outputs}). For instance, the following command installs fonts
  1507. for Chinese languages:
  1508. @example
  1509. guix install font-adobe-source-han-sans:cn
  1510. @end example
  1511. @cindex @code{xterm}
  1512. Older programs such as @command{xterm} do not use Fontconfig and instead
  1513. rely on server-side font rendering. Such programs require to specify a
  1514. full name of a font using XLFD (X Logical Font Description), like this:
  1515. @example
  1516. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1517. @end example
  1518. To be able to use such full names for the TrueType fonts installed in
  1519. your Guix profile, you need to extend the font path of the X server:
  1520. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1521. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1522. @example
  1523. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1524. @end example
  1525. @cindex @code{xlsfonts}
  1526. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1527. to make sure your TrueType fonts are listed there.
  1528. @subsection X.509 Certificates
  1529. @cindex @code{nss-certs}
  1530. The @code{nss-certs} package provides X.509 certificates, which allow
  1531. programs to authenticate Web servers accessed over HTTPS.
  1532. When using Guix on a foreign distro, you can install this package and
  1533. define the relevant environment variables so that packages know where to
  1534. look for certificates. @xref{X.509 Certificates}, for detailed
  1535. information.
  1536. @subsection Emacs Packages
  1537. @cindex @code{emacs}
  1538. When you install Emacs packages with Guix, the Elisp files are placed
  1539. under the @file{share/emacs/site-lisp/} directory of the profile in
  1540. which they are installed. The Elisp libraries are made available to
  1541. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1542. set when installing Emacs itself.
  1543. Additionally, autoload definitions are automatically evaluated at the
  1544. initialization of Emacs, by the Guix-specific
  1545. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1546. want to avoid auto-loading the Emacs packages installed with Guix, you
  1547. can do so by running Emacs with the @option{--no-site-file} option
  1548. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1549. @node Upgrading Guix
  1550. @section Upgrading Guix
  1551. @cindex Upgrading Guix, on a foreign distro
  1552. To upgrade Guix, run:
  1553. @example
  1554. guix pull
  1555. @end example
  1556. @xref{Invoking guix pull}, for more information.
  1557. @cindex upgrading Guix for the root user, on a foreign distro
  1558. @cindex upgrading the Guix daemon, on a foreign distro
  1559. @cindex @command{guix pull} for the root user, on a foreign distro
  1560. On a foreign distro, you can upgrade the build daemon by running:
  1561. @example
  1562. sudo -i guix pull
  1563. @end example
  1564. @noindent
  1565. followed by (assuming your distro uses the systemd service management
  1566. tool):
  1567. @example
  1568. systemctl restart guix-daemon.service
  1569. @end example
  1570. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1571. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1572. @c TODO What else?
  1573. @c *********************************************************************
  1574. @node System Installation
  1575. @chapter System Installation
  1576. @cindex installing Guix System
  1577. @cindex Guix System, installation
  1578. This section explains how to install Guix System
  1579. on a machine. Guix, as a package manager, can
  1580. also be installed on top of a running GNU/Linux system,
  1581. @pxref{Installation}.
  1582. @ifinfo
  1583. @quotation Note
  1584. @c This paragraph is for people reading this from tty2 of the
  1585. @c installation image.
  1586. You are reading this documentation with an Info reader. For details on
  1587. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1588. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1589. Info}. Hit @kbd{l} afterwards to come back here.
  1590. Alternatively, run @command{info info} in another tty to keep the manual
  1591. available.
  1592. @end quotation
  1593. @end ifinfo
  1594. @menu
  1595. * Limitations:: What you can expect.
  1596. * Hardware Considerations:: Supported hardware.
  1597. * USB Stick and DVD Installation:: Preparing the installation medium.
  1598. * Preparing for Installation:: Networking, partitioning, etc.
  1599. * Guided Graphical Installation:: Easy graphical installation.
  1600. * Manual Installation:: Manual installation for wizards.
  1601. * After System Installation:: When installation succeeded.
  1602. * Installing Guix in a VM:: Guix System playground.
  1603. * Building the Installation Image:: How this comes to be.
  1604. @end menu
  1605. @node Limitations
  1606. @section Limitations
  1607. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1608. use cases. The reliability guarantees it provides---transactional upgrades
  1609. and rollbacks, reproducibility---make it a solid foundation.
  1610. Nevertheless, before you proceed with the installation, be aware of the
  1611. following noteworthy limitations applicable to version @value{VERSION}:
  1612. @itemize
  1613. @item
  1614. More and more system services are provided (@pxref{Services}), but some
  1615. may be missing.
  1616. @item
  1617. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1618. as well as a number of X11 window managers. However, KDE is currently
  1619. missing.
  1620. @end itemize
  1621. More than a disclaimer, this is an invitation to report issues (and success
  1622. stories!), and to join us in improving it. @xref{Contributing}, for more
  1623. info.
  1624. @node Hardware Considerations
  1625. @section Hardware Considerations
  1626. @cindex hardware support on Guix System
  1627. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1628. builds around the kernel Linux-libre, which means that only hardware for
  1629. which free software drivers and firmware exist is supported. Nowadays,
  1630. a wide range of off-the-shelf hardware is supported on
  1631. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1632. Ethernet controllers. Unfortunately, there are still areas where
  1633. hardware vendors deny users control over their own computing, and such
  1634. hardware is not supported on Guix System.
  1635. @cindex WiFi, hardware support
  1636. One of the main areas where free drivers or firmware are lacking is WiFi
  1637. devices. WiFi devices known to work include those using Atheros chips
  1638. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1639. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1640. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1641. Linux-libre driver. Free firmware exists for both and is available
  1642. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1643. (@pxref{operating-system Reference, @code{firmware}}).
  1644. @cindex RYF, Respects Your Freedom
  1645. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1646. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1647. certification program for hardware products that respect your freedom
  1648. and your privacy and ensure that you have control over your device. We
  1649. encourage you to check the list of RYF-certified devices.
  1650. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1651. web site. It contains a catalog of hardware devices with information
  1652. about their support in GNU/Linux.
  1653. @node USB Stick and DVD Installation
  1654. @section USB Stick and DVD Installation
  1655. An ISO-9660 installation image that can be written to a USB stick or
  1656. burnt to a DVD can be downloaded from
  1657. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz},
  1658. where you can replace @code{x86_64-linux} with one of:
  1659. @table @code
  1660. @item x86_64-linux
  1661. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1662. @item i686-linux
  1663. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1664. @end table
  1665. @c start duplication of authentication part from ``Binary Installation''
  1666. Make sure to download the associated @file{.sig} file and to verify the
  1667. authenticity of the image against it, along these lines:
  1668. @example
  1669. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1670. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1671. @end example
  1672. If that command fails because you do not have the required public key,
  1673. then run this command to import it:
  1674. @example
  1675. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1676. -qO - | gpg --import -
  1677. @end example
  1678. @noindent
  1679. and rerun the @code{gpg --verify} command.
  1680. Take note that a warning like ``This key is not certified with a trusted
  1681. signature!'' is normal.
  1682. @c end duplication
  1683. This image contains the tools necessary for an installation.
  1684. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1685. @unnumberedsubsec Copying to a USB Stick
  1686. To copy the image to a USB stick, follow these steps:
  1687. @enumerate
  1688. @item
  1689. Decompress the image using the @command{xz} command:
  1690. @example
  1691. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1692. @end example
  1693. @item
  1694. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1695. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1696. copy the image with:
  1697. @example
  1698. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1699. sync
  1700. @end example
  1701. Access to @file{/dev/sdX} usually requires root privileges.
  1702. @end enumerate
  1703. @unnumberedsubsec Burning on a DVD
  1704. To copy the image to a DVD, follow these steps:
  1705. @enumerate
  1706. @item
  1707. Decompress the image using the @command{xz} command:
  1708. @example
  1709. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1710. @end example
  1711. @item
  1712. Insert a blank DVD into your machine, and determine
  1713. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1714. copy the image with:
  1715. @example
  1716. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1717. @end example
  1718. Access to @file{/dev/srX} usually requires root privileges.
  1719. @end enumerate
  1720. @unnumberedsubsec Booting
  1721. Once this is done, you should be able to reboot the system and boot from
  1722. the USB stick or DVD@. The latter usually requires you to get in the
  1723. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1724. In order to boot from Libreboot, switch to the command mode by pressing
  1725. the @kbd{c} key and type @command{search_grub usb}.
  1726. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1727. Guix System in a virtual machine (VM).
  1728. @node Preparing for Installation
  1729. @section Preparing for Installation
  1730. Once you have booted, you can use the guided graphical installer, which makes
  1731. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1732. if you are already familiar with GNU/Linux and if you want more control than
  1733. what the graphical installer provides, you can choose the ``manual''
  1734. installation process (@pxref{Manual Installation}).
  1735. The graphical installer is available on TTY1. You can obtain root shells on
  1736. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1737. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1738. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1739. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1740. which allows you to select text with the left mouse button and to paste it
  1741. with the middle button.
  1742. @quotation Note
  1743. Installation requires access to the Internet so that any missing
  1744. dependencies of your system configuration can be downloaded. See the
  1745. ``Networking'' section below.
  1746. @end quotation
  1747. @node Guided Graphical Installation
  1748. @section Guided Graphical Installation
  1749. The graphical installer is a text-based user interface. It will guide you,
  1750. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1751. The first dialog boxes allow you to set up the system as you use it during the
  1752. installation: you can choose the language, keyboard layout, and set up
  1753. networking, which will be used during the installation. The image below shows
  1754. the networking dialog.
  1755. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1756. Later steps allow you to partition your hard disk, as shown in the image
  1757. below, to choose whether or not to use encrypted file systems, to enter the
  1758. host name and root password, and to create an additional account, among other
  1759. things.
  1760. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1761. Note that, at any time, the installer allows you to exit the current
  1762. installation step and resume at a previous step, as show in the image below.
  1763. @image{images/installer-resume,5in,, resuming the installation process}
  1764. Once you're done, the installer produces an operating system configuration and
  1765. displays it (@pxref{Using the Configuration System}). At that point you can
  1766. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1767. new system and enjoy. @xref{After System Installation}, for what's next!
  1768. @node Manual Installation
  1769. @section Manual Installation
  1770. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1771. on your machine. This option requires familiarity with GNU/Linux, with the
  1772. shell, and with common administration tools. If you think this is not for
  1773. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1774. Installation}).
  1775. The installation system provides root shells on TTYs 3 to 6; press
  1776. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1777. many common tools needed to install the system. But it is also a full-blown
  1778. Guix System, which means that you can install additional packages, should you
  1779. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1780. @menu
  1781. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1782. * Proceeding with the Installation:: Installing.
  1783. @end menu
  1784. @node Keyboard Layout and Networking and Partitioning
  1785. @subsection Keyboard Layout, Networking, and Partitioning
  1786. Before you can install the system, you may want to adjust the keyboard layout,
  1787. set up networking, and partition your target hard disk. This section will
  1788. guide you through this.
  1789. @subsubsection Keyboard Layout
  1790. @cindex keyboard layout
  1791. The installation image uses the US qwerty keyboard layout. If you want
  1792. to change it, you can use the @command{loadkeys} command. For example,
  1793. the following command selects the Dvorak keyboard layout:
  1794. @example
  1795. loadkeys dvorak
  1796. @end example
  1797. See the files under @file{/run/current-system/profile/share/keymaps} for
  1798. a list of available keyboard layouts. Run @command{man loadkeys} for
  1799. more information.
  1800. @subsubsection Networking
  1801. Run the following command to see what your network interfaces are called:
  1802. @example
  1803. ifconfig -a
  1804. @end example
  1805. @noindent
  1806. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1807. @example
  1808. ip address
  1809. @end example
  1810. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1811. Wired interfaces have a name starting with @samp{e}; for example, the
  1812. interface corresponding to the first on-board Ethernet controller is
  1813. called @samp{eno1}. Wireless interfaces have a name starting with
  1814. @samp{w}, like @samp{w1p2s0}.
  1815. @table @asis
  1816. @item Wired connection
  1817. To configure a wired network run the following command, substituting
  1818. @var{interface} with the name of the wired interface you want to use.
  1819. @example
  1820. ifconfig @var{interface} up
  1821. @end example
  1822. @noindent
  1823. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1824. @example
  1825. ip link set @var{interface} up
  1826. @end example
  1827. @item Wireless connection
  1828. @cindex wireless
  1829. @cindex WiFi
  1830. To configure wireless networking, you can create a configuration file
  1831. for the @command{wpa_supplicant} configuration tool (its location is not
  1832. important) using one of the available text editors such as
  1833. @command{nano}:
  1834. @example
  1835. nano wpa_supplicant.conf
  1836. @end example
  1837. As an example, the following stanza can go to this file and will work
  1838. for many wireless networks, provided you give the actual SSID and
  1839. passphrase for the network you are connecting to:
  1840. @example
  1841. network=@{
  1842. ssid="@var{my-ssid}"
  1843. key_mgmt=WPA-PSK
  1844. psk="the network's secret passphrase"
  1845. @}
  1846. @end example
  1847. Start the wireless service and run it in the background with the
  1848. following command (substitute @var{interface} with the name of the
  1849. network interface you want to use):
  1850. @example
  1851. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1852. @end example
  1853. Run @command{man wpa_supplicant} for more information.
  1854. @end table
  1855. @cindex DHCP
  1856. At this point, you need to acquire an IP address. On a network where IP
  1857. addresses are automatically assigned @i{via} DHCP, you can run:
  1858. @example
  1859. dhclient -v @var{interface}
  1860. @end example
  1861. Try to ping a server to see if networking is up and running:
  1862. @example
  1863. ping -c 3 gnu.org
  1864. @end example
  1865. Setting up network access is almost always a requirement because the
  1866. image does not contain all the software and tools that may be needed.
  1867. @cindex proxy, during system installation
  1868. If you need HTTP and HTTPS access to go through a proxy, run the
  1869. following command:
  1870. @example
  1871. herd set-http-proxy guix-daemon @var{URL}
  1872. @end example
  1873. @noindent
  1874. where @var{URL} is the proxy URL, for example
  1875. @code{http://example.org:8118}.
  1876. @cindex installing over SSH
  1877. If you want to, you can continue the installation remotely by starting
  1878. an SSH server:
  1879. @example
  1880. herd start ssh-daemon
  1881. @end example
  1882. Make sure to either set a password with @command{passwd}, or configure
  1883. OpenSSH public key authentication before logging in.
  1884. @subsubsection Disk Partitioning
  1885. Unless this has already been done, the next step is to partition, and
  1886. then format the target partition(s).
  1887. The installation image includes several partitioning tools, including
  1888. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1889. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1890. the partition layout you want:
  1891. @example
  1892. cfdisk
  1893. @end example
  1894. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1895. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1896. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1897. manual}).
  1898. @cindex EFI, installation
  1899. @cindex UEFI, installation
  1900. @cindex ESP, EFI system partition
  1901. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1902. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1903. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  1904. @example
  1905. parted /dev/sda set 1 esp on
  1906. @end example
  1907. @quotation Note
  1908. @vindex grub-bootloader
  1909. @vindex grub-efi-bootloader
  1910. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  1911. @file{/sys/firmware/efi} exists in the installation image, then you should
  1912. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  1913. Otherwise you should use the BIOS-based GRUB, known as
  1914. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  1915. bootloaders.
  1916. @end quotation
  1917. Once you are done partitioning the target hard disk drive, you have to
  1918. create a file system on the relevant partition(s)@footnote{Currently
  1919. Guix System only supports ext4, btrfs, JFS, and F2FS file systems. In
  1920. particular, code that reads file system UUIDs and labels only works for these
  1921. file system types.}. For the ESP, if you have one and assuming it is
  1922. @file{/dev/sda1}, run:
  1923. @example
  1924. mkfs.fat -F32 /dev/sda1
  1925. @end example
  1926. For the root file system, ext4 is the most widely used format. Other
  1927. file systems, such as Btrfs, support compression, which is reported to
  1928. nicely complement file deduplication that the daemon performs
  1929. independently of the file system (@pxref{Invoking guix-daemon,
  1930. deduplication}).
  1931. Preferably, assign file systems a label so that you can easily and
  1932. reliably refer to them in @code{file-system} declarations (@pxref{File
  1933. Systems}). This is typically done using the @code{-L} option of
  1934. @command{mkfs.ext4} and related commands. So, assuming the target root
  1935. partition lives at @file{/dev/sda2}, a file system with the label
  1936. @code{my-root} can be created with:
  1937. @example
  1938. mkfs.ext4 -L my-root /dev/sda2
  1939. @end example
  1940. @cindex encrypted disk
  1941. If you are instead planning to encrypt the root partition, you can use
  1942. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  1943. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  1944. @code{man cryptsetup}} for more information). Assuming you want to
  1945. store the root partition on @file{/dev/sda2}, the command sequence would
  1946. be along these lines:
  1947. @example
  1948. cryptsetup luksFormat /dev/sda2
  1949. cryptsetup open --type luks /dev/sda2 my-partition
  1950. mkfs.ext4 -L my-root /dev/mapper/my-partition
  1951. @end example
  1952. Once that is done, mount the target file system under @file{/mnt}
  1953. with a command like (again, assuming @code{my-root} is the label of the
  1954. root file system):
  1955. @example
  1956. mount LABEL=my-root /mnt
  1957. @end example
  1958. Also mount any other file systems you would like to use on the target
  1959. system relative to this path. If you have opted for @file{/boot/efi} as an
  1960. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  1961. found by @code{guix system init} afterwards.
  1962. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  1963. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  1964. sure to initialize them with @command{mkswap}. Assuming you have one
  1965. swap partition on @file{/dev/sda3}, you would run:
  1966. @example
  1967. mkswap /dev/sda3
  1968. swapon /dev/sda3
  1969. @end example
  1970. Alternatively, you may use a swap file. For example, assuming that in
  1971. the new system you want to use the file @file{/swapfile} as a swap file,
  1972. you would run@footnote{This example will work for many types of file
  1973. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  1974. btrfs), the required steps may be different. For details, see the
  1975. manual pages for @command{mkswap} and @command{swapon}.}:
  1976. @example
  1977. # This is 10 GiB of swap space. Adjust "count" to change the size.
  1978. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  1979. # For security, make the file readable and writable only by root.
  1980. chmod 600 /mnt/swapfile
  1981. mkswap /mnt/swapfile
  1982. swapon /mnt/swapfile
  1983. @end example
  1984. Note that if you have encrypted the root partition and created a swap
  1985. file in its file system as described above, then the encryption also
  1986. protects the swap file, just like any other file in that file system.
  1987. @node Proceeding with the Installation
  1988. @subsection Proceeding with the Installation
  1989. With the target partitions ready and the target root mounted on
  1990. @file{/mnt}, we're ready to go. First, run:
  1991. @example
  1992. herd start cow-store /mnt
  1993. @end example
  1994. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  1995. during the installation phase are written to the target disk on @file{/mnt}
  1996. rather than kept in memory. This is necessary because the first phase of
  1997. the @command{guix system init} command (see below) entails downloads or
  1998. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  1999. Next, you have to edit a file and
  2000. provide the declaration of the operating system to be installed. To
  2001. that end, the installation system comes with three text editors. We
  2002. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2003. supports syntax highlighting and parentheses matching; other editors
  2004. include GNU Zile (an Emacs clone), and
  2005. nvi (a clone of the original BSD @command{vi} editor).
  2006. We strongly recommend storing that file on the target root file system, say,
  2007. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2008. configuration file once you have rebooted into the newly-installed system.
  2009. @xref{Using the Configuration System}, for an overview of the
  2010. configuration file. The example configurations discussed in that
  2011. section are available under @file{/etc/configuration} in the
  2012. installation image. Thus, to get started with a system configuration
  2013. providing a graphical display server (a ``desktop'' system), you can run
  2014. something along these lines:
  2015. @example
  2016. # mkdir /mnt/etc
  2017. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2018. # nano /mnt/etc/config.scm
  2019. @end example
  2020. You should pay attention to what your configuration file contains, and
  2021. in particular:
  2022. @itemize
  2023. @item
  2024. Make sure the @code{bootloader-configuration} form refers to the target
  2025. you want to install GRUB on. It should mention @code{grub-bootloader} if
  2026. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  2027. for newer UEFI systems. For legacy systems, the @code{target} field
  2028. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  2029. to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
  2030. currently mounted and a @code{file-system} entry is specified in your
  2031. configuration.
  2032. @item
  2033. Be sure that your file system labels match the value of their respective
  2034. @code{device} fields in your @code{file-system} configuration, assuming
  2035. your @code{file-system} configuration uses the @code{file-system-label}
  2036. procedure in its @code{device} field.
  2037. @item
  2038. If there are encrypted or RAID partitions, make sure to add a
  2039. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2040. @end itemize
  2041. Once you are done preparing the configuration file, the new system must
  2042. be initialized (remember that the target root file system is mounted
  2043. under @file{/mnt}):
  2044. @example
  2045. guix system init /mnt/etc/config.scm /mnt
  2046. @end example
  2047. @noindent
  2048. This copies all the necessary files and installs GRUB on
  2049. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2050. more information, @pxref{Invoking guix system}. This command may trigger
  2051. downloads or builds of missing packages, which can take some time.
  2052. Once that command has completed---and hopefully succeeded!---you can run
  2053. @command{reboot} and boot into the new system. The @code{root} password
  2054. in the new system is initially empty; other users' passwords need to be
  2055. initialized by running the @command{passwd} command as @code{root},
  2056. unless your configuration specifies otherwise
  2057. (@pxref{user-account-password, user account passwords}).
  2058. @xref{After System Installation}, for what's next!
  2059. @node After System Installation
  2060. @section After System Installation
  2061. Success, you've now booted into Guix System! From then on, you can update the
  2062. system whenever you want by running, say:
  2063. @example
  2064. guix pull
  2065. sudo guix system reconfigure /etc/config.scm
  2066. @end example
  2067. @noindent
  2068. This builds a new system generation with the latest packages and services
  2069. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2070. your system includes the latest security updates (@pxref{Security Updates}).
  2071. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2072. @quotation Note
  2073. @cindex sudo vs. @command{guix pull}
  2074. Note that @command{sudo guix} runs your user's @command{guix} command and
  2075. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2076. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2077. The difference matters here, because @command{guix pull} updates
  2078. the @command{guix} command and package definitions only for the user it is ran
  2079. as. This means that if you choose to use @command{guix system reconfigure} in
  2080. root's login shell, you'll need to @command{guix pull} separately.
  2081. @end quotation
  2082. Now, @pxref{Getting Started}, and
  2083. join us on @code{#guix} on the Freenode IRC network or on
  2084. @email{guix-devel@@gnu.org} to share your experience!
  2085. @node Installing Guix in a VM
  2086. @section Installing Guix in a Virtual Machine
  2087. @cindex virtual machine, Guix System installation
  2088. @cindex virtual private server (VPS)
  2089. @cindex VPS (virtual private server)
  2090. If you'd like to install Guix System in a virtual machine (VM) or on a
  2091. virtual private server (VPS) rather than on your beloved machine, this
  2092. section is for you.
  2093. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2094. disk image, follow these steps:
  2095. @enumerate
  2096. @item
  2097. First, retrieve and decompress the Guix system installation image as
  2098. described previously (@pxref{USB Stick and DVD Installation}).
  2099. @item
  2100. Create a disk image that will hold the installed system. To make a
  2101. qcow2-formatted disk image, use the @command{qemu-img} command:
  2102. @example
  2103. qemu-img create -f qcow2 guix-system.img 50G
  2104. @end example
  2105. The resulting file will be much smaller than 50 GB (typically less than
  2106. 1 MB), but it will grow as the virtualized storage device is filled up.
  2107. @item
  2108. Boot the USB installation image in an VM:
  2109. @example
  2110. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2111. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2112. -drive file=guix-system.img \
  2113. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2114. @end example
  2115. @code{-enable-kvm} is optional, but significantly improves performance,
  2116. @pxref{Running Guix in a VM}.
  2117. @item
  2118. You're now root in the VM, proceed with the installation process.
  2119. @xref{Preparing for Installation}, and follow the instructions.
  2120. @end enumerate
  2121. Once installation is complete, you can boot the system that's on your
  2122. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2123. that.
  2124. @node Building the Installation Image
  2125. @section Building the Installation Image
  2126. @cindex installation image
  2127. The installation image described above was built using the @command{guix
  2128. system} command, specifically:
  2129. @example
  2130. guix system image -t iso9660 gnu/system/install.scm
  2131. @end example
  2132. Have a look at @file{gnu/system/install.scm} in the source tree,
  2133. and see also @ref{Invoking guix system} for more information
  2134. about the installation image.
  2135. @section Building the Installation Image for ARM Boards
  2136. Many ARM boards require a specific variant of the
  2137. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2138. If you build a disk image and the bootloader is not available otherwise
  2139. (on another boot drive etc), it's advisable to build an image that
  2140. includes the bootloader, specifically:
  2141. @example
  2142. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2143. @end example
  2144. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2145. board, a list of possible boards will be printed.
  2146. @c *********************************************************************
  2147. @node Getting Started
  2148. @chapter Getting Started
  2149. Presumably, you've reached this section because either you have
  2150. installed Guix on top of another distribution (@pxref{Installation}), or
  2151. you've installed the standalone Guix System (@pxref{System
  2152. Installation}). It's time for you to get started using Guix and this
  2153. section aims to help you do that and give you a feel of what it's like.
  2154. Guix is about installing software, so probably the first thing you'll
  2155. want to do is to actually look for software. Let's say you're looking
  2156. for a text editor, you can run:
  2157. @example
  2158. guix search text editor
  2159. @end example
  2160. This command shows you a number of matching @dfn{packages}, each time
  2161. showing the package's name, version, a description, and additional info.
  2162. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2163. you can go ahead and install it (run this command as a regular user,
  2164. @emph{no need for root privileges}!):
  2165. @example
  2166. guix install emacs
  2167. @end example
  2168. You've installed your first package, congrats! In the process, you've
  2169. probably noticed that Guix downloaded pre-built binaries; or, if you
  2170. explicitly chose to @emph{not} use pre-built binaries, then probably
  2171. Guix is still building software (@pxref{Substitutes}, for more info).
  2172. Unless you're using Guix System, the @command{guix install} command must
  2173. have printed this hint:
  2174. @example
  2175. hint: Consider setting the necessary environment variables by running:
  2176. GUIX_PROFILE="$HOME/.guix-profile"
  2177. . "$GUIX_PROFILE/etc/profile"
  2178. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2179. @end example
  2180. Indeed, you must now tell your shell where @command{emacs} and other
  2181. programs installed with Guix are to be found. Pasting the two lines
  2182. above will do just that: it will add
  2183. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2184. is---to the @code{PATH} environment variable. You can paste these two
  2185. lines in your shell so they take effect right away, but more importantly
  2186. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2187. do not use Bash) so that environment variables are set next time you
  2188. spawn a shell. You only need to do this once and other search paths
  2189. environment variables will be taken care of similarly---e.g., if you
  2190. eventually install @code{python} and Python libraries, @code{PYTHONPATH}
  2191. will be defined.
  2192. You can go on installing packages at your will. To list installed
  2193. packages, run:
  2194. @example
  2195. guix package --list-installed
  2196. @end example
  2197. To remove a package, you would unsurprisingly run @command{guix remove}.
  2198. A distinguishing feature is the ability to @dfn{roll back} any operation
  2199. you made---installation, removal, upgrade---by simply typing:
  2200. @example
  2201. guix package --roll-back
  2202. @end example
  2203. This is because each operation is in fact a @dfn{transaction} that
  2204. creates a new @dfn{generation}. These generations and the difference
  2205. between them can be displayed by running:
  2206. @example
  2207. guix package --list-generations
  2208. @end example
  2209. Now you know the basics of package management!
  2210. @quotation Going further
  2211. @xref{Package Management}, for more about package management. You may
  2212. like @dfn{declarative} package management with @command{guix package
  2213. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2214. deleting old generations, collecting garbage, and other nifty features
  2215. that will come in handy as you become more familiar with Guix. If you
  2216. are a developer, @pxref{Development} for additional tools. And if
  2217. you're curious, @pxref{Features}, to peek under the hood.
  2218. @end quotation
  2219. Once you've installed a set of packages, you will want to periodically
  2220. @emph{upgrade} them to the latest and greatest version. To do that, you
  2221. will first pull the latest revision of Guix and its package collection:
  2222. @example
  2223. guix pull
  2224. @end example
  2225. The end result is a new @command{guix} command, under
  2226. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2227. first time you run @command{guix pull}, be sure to follow the hint that
  2228. the command prints and, similar to what we saw above, paste these two
  2229. lines in your terminal and @file{.bash_profile}:
  2230. @example
  2231. GUIX_PROFILE="$HOME/.config/guix/current"
  2232. . "$GUIX_PROFILE/etc/profile"
  2233. @end example
  2234. @noindent
  2235. You must also instruct your shell to point to this new @command{guix}:
  2236. @example
  2237. hash guix
  2238. @end example
  2239. At this point, you're running a brand new Guix. You can thus go ahead
  2240. and actually upgrade all the packages you previously installed:
  2241. @example
  2242. guix upgrade
  2243. @end example
  2244. As you run this command, you will see that binaries are downloaded (or
  2245. perhaps some packages are built), and eventually you end up with the
  2246. upgraded packages. Should one of these upgraded packages not be to your
  2247. liking, remember you can always roll back!
  2248. You can display the exact revision of Guix you're currently using by
  2249. running:
  2250. @example
  2251. guix describe
  2252. @end example
  2253. The information it displays is @emph{all it takes to reproduce the exact
  2254. same Guix}, be it at a different point in time or on a different
  2255. machine.
  2256. @quotation Going further
  2257. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2258. how to specify additional @dfn{channels} to pull packages from, how to
  2259. replicate Guix, and more. You may also find @command{time-machine}
  2260. handy (@pxref{Invoking guix time-machine}).
  2261. @end quotation
  2262. If you installed Guix System, one of the first things you'll want to do
  2263. is to upgrade your system. Once you've run @command{guix pull} to get
  2264. the latest Guix, you can upgrade the system like this:
  2265. @example
  2266. sudo guix system reconfigure /etc/config.scm
  2267. @end example
  2268. Upon completion, the system runs the latest versions of its software
  2269. packages. When you eventually reboot, you'll notice a sub-menu in the
  2270. bootloader that reads ``Old system generations'': it's what allows you
  2271. to boot @emph{an older generation of your system}, should the latest
  2272. generation be ``broken'' or otherwise unsatisfying. Just like for
  2273. packages, you can always @emph{roll back} to a previous generation
  2274. @emph{of the whole system}:
  2275. @example
  2276. sudo guix system roll-back
  2277. @end example
  2278. There are many things you'll probably want to tweak on your system:
  2279. adding new user accounts, adding new system services, fiddling with the
  2280. configuration of those services, etc. The system configuration is
  2281. @emph{entirely} described in the @file{/etc/config.scm} file.
  2282. @xref{Using the Configuration System}, to learn how to change it.
  2283. Now you know enough to get started!
  2284. @quotation Resources
  2285. The rest of this manual provides a reference for all things Guix. Here
  2286. are some additional resources you may find useful:
  2287. @itemize
  2288. @item
  2289. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2290. ``how-to'' style of recipes for a variety of applications.
  2291. @item
  2292. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2293. Card} lists in two pages most of the commands and options you'll ever
  2294. need.
  2295. @item
  2296. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2297. instructional videos} covering topics such as everyday use of Guix, how
  2298. to get help, and how to become a contributor.
  2299. @item
  2300. @xref{Documentation}, to learn how to access documentation on your
  2301. computer.
  2302. @end itemize
  2303. We hope you will enjoy Guix as much as the community enjoys building it!
  2304. @end quotation
  2305. @c *********************************************************************
  2306. @node Package Management
  2307. @chapter Package Management
  2308. @cindex packages
  2309. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2310. remove software packages, without having to know about their build
  2311. procedures or dependencies. Guix also goes beyond this obvious set of
  2312. features.
  2313. This chapter describes the main features of Guix, as well as the
  2314. package management tools it provides. Along with the command-line
  2315. interface described below (@pxref{Invoking guix package, @code{guix
  2316. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2317. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2318. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2319. with it):
  2320. @example
  2321. guix install emacs-guix
  2322. @end example
  2323. @menu
  2324. * Features:: How Guix will make your life brighter.
  2325. * Invoking guix package:: Package installation, removal, etc.
  2326. * Substitutes:: Downloading pre-built binaries.
  2327. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2328. * Invoking guix gc:: Running the garbage collector.
  2329. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2330. * Invoking guix time-machine:: Running an older revision of Guix.
  2331. * Inferiors:: Interacting with another revision of Guix.
  2332. * Invoking guix describe:: Display information about your Guix revision.
  2333. * Invoking guix archive:: Exporting and importing store files.
  2334. @end menu
  2335. @node Features
  2336. @section Features
  2337. Here we assume you've already made your first steps with Guix
  2338. (@pxref{Getting Started}) and would like to get an overview about what's
  2339. going on under the hood.
  2340. When using Guix, each package ends up in the @dfn{package store}, in its
  2341. own directory---something that resembles
  2342. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2343. Instead of referring to these directories, users have their own
  2344. @dfn{profile}, which points to the packages that they actually want to
  2345. use. These profiles are stored within each user's home directory, at
  2346. @code{$HOME/.guix-profile}.
  2347. For example, @code{alice} installs GCC 4.7.2. As a result,
  2348. @file{/home/alice/.guix-profile/bin/gcc} points to
  2349. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2350. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2351. simply continues to point to
  2352. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2353. coexist on the same system without any interference.
  2354. The @command{guix package} command is the central tool to manage
  2355. packages (@pxref{Invoking guix package}). It operates on the per-user
  2356. profiles, and can be used @emph{with normal user privileges}.
  2357. @cindex transactions
  2358. The command provides the obvious install, remove, and upgrade
  2359. operations. Each invocation is actually a @emph{transaction}: either
  2360. the specified operation succeeds, or nothing happens. Thus, if the
  2361. @command{guix package} process is terminated during the transaction,
  2362. or if a power outage occurs during the transaction, then the user's
  2363. profile remains in its previous state, and remains usable.
  2364. In addition, any package transaction may be @emph{rolled back}. So, if,
  2365. for example, an upgrade installs a new version of a package that turns
  2366. out to have a serious bug, users may roll back to the previous instance
  2367. of their profile, which was known to work well. Similarly, the global
  2368. system configuration on Guix is subject to
  2369. transactional upgrades and roll-back
  2370. (@pxref{Using the Configuration System}).
  2371. All packages in the package store may be @emph{garbage-collected}.
  2372. Guix can determine which packages are still referenced by user
  2373. profiles, and remove those that are provably no longer referenced
  2374. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2375. generations of their profile so that the packages they refer to can be
  2376. collected.
  2377. @cindex reproducibility
  2378. @cindex reproducible builds
  2379. Guix takes a @dfn{purely functional} approach to package
  2380. management, as described in the introduction (@pxref{Introduction}).
  2381. Each @file{/gnu/store} package directory name contains a hash of all the
  2382. inputs that were used to build that package---compiler, libraries, build
  2383. scripts, etc. This direct correspondence allows users to make sure a
  2384. given package installation matches the current state of their
  2385. distribution. It also helps maximize @dfn{build reproducibility}:
  2386. thanks to the isolated build environments that are used, a given build
  2387. is likely to yield bit-identical files when performed on different
  2388. machines (@pxref{Invoking guix-daemon, container}).
  2389. @cindex substitutes
  2390. This foundation allows Guix to support @dfn{transparent binary/source
  2391. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2392. available from an external source---a @dfn{substitute}, Guix just
  2393. downloads it and unpacks it;
  2394. otherwise, it builds the package from source, locally
  2395. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2396. reproducible, users do not have to trust servers that provide
  2397. substitutes: they can force a local build and @emph{challenge} providers
  2398. (@pxref{Invoking guix challenge}).
  2399. Control over the build environment is a feature that is also useful for
  2400. developers. The @command{guix environment} command allows developers of
  2401. a package to quickly set up the right development environment for their
  2402. package, without having to manually install the dependencies of the
  2403. package into their profile (@pxref{Invoking guix environment}).
  2404. @cindex replication, of software environments
  2405. @cindex provenance tracking, of software artifacts
  2406. All of Guix and its package definitions is version-controlled, and
  2407. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2408. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2409. Guix instance on a different machine or at a later point in time, which in
  2410. turn allows you to @emph{replicate complete software environments}, while
  2411. retaining precise @dfn{provenance tracking} of the software.
  2412. @node Invoking guix package
  2413. @section Invoking @command{guix package}
  2414. @cindex installing packages
  2415. @cindex removing packages
  2416. @cindex package installation
  2417. @cindex package removal
  2418. The @command{guix package} command is the tool that allows users to
  2419. install, upgrade, and remove packages, as well as rolling back to
  2420. previous configurations. It operates only on the user's own profile,
  2421. and works with normal user privileges (@pxref{Features}). Its syntax
  2422. is:
  2423. @example
  2424. guix package @var{options}
  2425. @end example
  2426. @cindex transactions
  2427. Primarily, @var{options} specifies the operations to be performed during
  2428. the transaction. Upon completion, a new profile is created, but
  2429. previous @dfn{generations} of the profile remain available, should the user
  2430. want to roll back.
  2431. For example, to remove @code{lua} and install @code{guile} and
  2432. @code{guile-cairo} in a single transaction:
  2433. @example
  2434. guix package -r lua -i guile guile-cairo
  2435. @end example
  2436. @cindex aliases, for @command{guix package}
  2437. For your convenience, we also provide the following aliases:
  2438. @itemize
  2439. @item
  2440. @command{guix search} is an alias for @command{guix package -s},
  2441. @item
  2442. @command{guix install} is an alias for @command{guix package -i},
  2443. @item
  2444. @command{guix remove} is an alias for @command{guix package -r},
  2445. @item
  2446. @command{guix upgrade} is an alias for @command{guix package -u},
  2447. @item
  2448. and @command{guix show} is an alias for @command{guix package --show=}.
  2449. @end itemize
  2450. These aliases are less expressive than @command{guix package} and provide
  2451. fewer options, so in some cases you'll probably want to use @command{guix
  2452. package} directly.
  2453. @command{guix package} also supports a @dfn{declarative approach}
  2454. whereby the user specifies the exact set of packages to be available and
  2455. passes it @i{via} the @option{--manifest} option
  2456. (@pxref{profile-manifest, @option{--manifest}}).
  2457. @cindex profile
  2458. For each user, a symlink to the user's default profile is automatically
  2459. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2460. current generation of the user's default profile. Thus, users can add
  2461. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2462. variable, and so on.
  2463. @cindex search paths
  2464. If you are not using Guix System, consider adding the
  2465. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2466. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2467. shells get all the right environment variable definitions:
  2468. @example
  2469. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2470. source "$GUIX_PROFILE/etc/profile"
  2471. @end example
  2472. In a multi-user setup, user profiles are stored in a place registered as
  2473. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2474. to (@pxref{Invoking guix gc}). That directory is normally
  2475. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2476. @var{localstatedir} is the value passed to @code{configure} as
  2477. @option{--localstatedir}, and @var{user} is the user name. The
  2478. @file{per-user} directory is created when @command{guix-daemon} is
  2479. started, and the @var{user} sub-directory is created by @command{guix
  2480. package}.
  2481. The @var{options} can be among the following:
  2482. @table @code
  2483. @item --install=@var{package} @dots{}
  2484. @itemx -i @var{package} @dots{}
  2485. Install the specified @var{package}s.
  2486. Each @var{package} may specify either a simple package name, such as
  2487. @code{guile}, or a package name followed by an at-sign and version number,
  2488. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2489. case, the newest version prefixed by @code{1.8} is selected).
  2490. If no version number is specified, the
  2491. newest available version will be selected. In addition, @var{package}
  2492. may contain a colon, followed by the name of one of the outputs of the
  2493. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2494. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2495. name (and optionally version) are searched for among the GNU
  2496. distribution modules (@pxref{Package Modules}).
  2497. @cindex propagated inputs
  2498. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2499. that automatically get installed along with the required package
  2500. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2501. @code{package} objects}, for information about propagated inputs in
  2502. package definitions).
  2503. @anchor{package-cmd-propagated-inputs}
  2504. An example is the GNU MPC library: its C header files refer to those of
  2505. the GNU MPFR library, which in turn refer to those of the GMP library.
  2506. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2507. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2508. also been explicitly installed by the user.
  2509. Besides, packages sometimes rely on the definition of environment
  2510. variables for their search paths (see explanation of
  2511. @option{--search-paths} below). Any missing or possibly incorrect
  2512. environment variable definitions are reported here.
  2513. @item --install-from-expression=@var{exp}
  2514. @itemx -e @var{exp}
  2515. Install the package @var{exp} evaluates to.
  2516. @var{exp} must be a Scheme expression that evaluates to a
  2517. @code{<package>} object. This option is notably useful to disambiguate
  2518. between same-named variants of a package, with expressions such as
  2519. @code{(@@ (gnu packages base) guile-final)}.
  2520. Note that this option installs the first output of the specified
  2521. package, which may be insufficient when needing a specific output of a
  2522. multiple-output package.
  2523. @item --install-from-file=@var{file}
  2524. @itemx -f @var{file}
  2525. Install the package that the code within @var{file} evaluates to.
  2526. As an example, @var{file} might contain a definition like this
  2527. (@pxref{Defining Packages}):
  2528. @lisp
  2529. @include package-hello.scm
  2530. @end lisp
  2531. Developers may find it useful to include such a @file{guix.scm} file
  2532. in the root of their project source tree that can be used to test
  2533. development snapshots and create reproducible development environments
  2534. (@pxref{Invoking guix environment}).
  2535. The @var{file} may also contain a JSON representation of one or more
  2536. package definitions. Running @code{guix package -f} on
  2537. @file{hello.json} with the following contents would result in installing
  2538. the package @code{greeter} after building @code{myhello}:
  2539. @example
  2540. @verbatiminclude package-hello.json
  2541. @end example
  2542. @item --remove=@var{package} @dots{}
  2543. @itemx -r @var{package} @dots{}
  2544. Remove the specified @var{package}s.
  2545. As for @option{--install}, each @var{package} may specify a version number
  2546. and/or output name in addition to the package name. For instance,
  2547. @samp{-r glibc:debug} would remove the @code{debug} output of
  2548. @code{glibc}.
  2549. @item --upgrade[=@var{regexp} @dots{}]
  2550. @itemx -u [@var{regexp} @dots{}]
  2551. @cindex upgrading packages
  2552. Upgrade all the installed packages. If one or more @var{regexp}s are
  2553. specified, upgrade only installed packages whose name matches a
  2554. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2555. Note that this upgrades package to the latest version of packages found
  2556. in the distribution currently installed. To update your distribution,
  2557. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2558. pull}).
  2559. @cindex package transformations, upgrades
  2560. When upgrading, package transformations that were originally applied
  2561. when creating the profile are automatically re-applied (@pxref{Package
  2562. Transformation Options}). For example, assume you first installed Emacs
  2563. from the tip of its development branch with:
  2564. @example
  2565. guix install emacs-next --with-branch=emacs-next=master
  2566. @end example
  2567. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2568. of the Emacs development branch and build @code{emacs-next} from that
  2569. checkout.
  2570. Note that transformation options such as @option{--with-branch} and
  2571. @option{--with-source} depend on external state; it is up to you to
  2572. ensure that they work as expected. You can also discard a
  2573. transformations that apply to a package by running:
  2574. @example
  2575. guix install @var{package}
  2576. @end example
  2577. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2578. When used together with the @option{--upgrade} option, do @emph{not}
  2579. upgrade any packages whose name matches a @var{regexp}. For example, to
  2580. upgrade all packages in the current profile except those containing the
  2581. substring ``emacs'':
  2582. @example
  2583. $ guix package --upgrade . --do-not-upgrade emacs
  2584. @end example
  2585. @item @anchor{profile-manifest}--manifest=@var{file}
  2586. @itemx -m @var{file}
  2587. @cindex profile declaration
  2588. @cindex profile manifest
  2589. Create a new generation of the profile from the manifest object
  2590. returned by the Scheme code in @var{file}. This option can be repeated
  2591. several times, in which case the manifests are concatenated.
  2592. This allows you to @emph{declare} the profile's contents rather than
  2593. constructing it through a sequence of @option{--install} and similar
  2594. commands. The advantage is that @var{file} can be put under version
  2595. control, copied to different machines to reproduce the same profile, and
  2596. so on.
  2597. @c FIXME: Add reference to (guix profile) documentation when available.
  2598. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2599. of packages:
  2600. @findex packages->manifest
  2601. @lisp
  2602. (use-package-modules guile emacs)
  2603. (packages->manifest
  2604. (list emacs
  2605. guile-2.0
  2606. ;; Use a specific package output.
  2607. (list guile-2.0 "debug")))
  2608. @end lisp
  2609. @findex specifications->manifest
  2610. In this example we have to know which modules define the @code{emacs}
  2611. and @code{guile-2.0} variables to provide the right
  2612. @code{use-package-modules} line, which can be cumbersome. We can
  2613. instead provide regular package specifications and let
  2614. @code{specifications->manifest} look up the corresponding package
  2615. objects, like this:
  2616. @lisp
  2617. (specifications->manifest
  2618. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2619. @end lisp
  2620. @item --roll-back
  2621. @cindex rolling back
  2622. @cindex undoing transactions
  2623. @cindex transactions, undoing
  2624. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2625. the last transaction.
  2626. When combined with options such as @option{--install}, roll back occurs
  2627. before any other actions.
  2628. When rolling back from the first generation that actually contains
  2629. installed packages, the profile is made to point to the @dfn{zeroth
  2630. generation}, which contains no files apart from its own metadata.
  2631. After having rolled back, installing, removing, or upgrading packages
  2632. overwrites previous future generations. Thus, the history of the
  2633. generations in a profile is always linear.
  2634. @item --switch-generation=@var{pattern}
  2635. @itemx -S @var{pattern}
  2636. @cindex generations
  2637. Switch to a particular generation defined by @var{pattern}.
  2638. @var{pattern} may be either a generation number or a number prefixed
  2639. with ``+'' or ``-''. The latter means: move forward/backward by a
  2640. specified number of generations. For example, if you want to return to
  2641. the latest generation after @option{--roll-back}, use
  2642. @option{--switch-generation=+1}.
  2643. The difference between @option{--roll-back} and
  2644. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2645. not make a zeroth generation, so if a specified generation does not
  2646. exist, the current generation will not be changed.
  2647. @item --search-paths[=@var{kind}]
  2648. @cindex search paths
  2649. Report environment variable definitions, in Bash syntax, that may be
  2650. needed in order to use the set of installed packages. These environment
  2651. variables are used to specify @dfn{search paths} for files used by some
  2652. of the installed packages.
  2653. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2654. environment variables to be defined so it can look for headers and
  2655. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2656. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2657. library are installed in the profile, then @option{--search-paths} will
  2658. suggest setting these variables to @file{@var{profile}/include} and
  2659. @file{@var{profile}/lib}, respectively.
  2660. The typical use case is to define these environment variables in the
  2661. shell:
  2662. @example
  2663. $ eval `guix package --search-paths`
  2664. @end example
  2665. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2666. meaning that the returned environment variable definitions will either
  2667. be exact settings, or prefixes or suffixes of the current value of these
  2668. variables. When omitted, @var{kind} defaults to @code{exact}.
  2669. This option can also be used to compute the @emph{combined} search paths
  2670. of several profiles. Consider this example:
  2671. @example
  2672. $ guix package -p foo -i guile
  2673. $ guix package -p bar -i guile-json
  2674. $ guix package -p foo -p bar --search-paths
  2675. @end example
  2676. The last command above reports about the @env{GUILE_LOAD_PATH}
  2677. variable, even though, taken individually, neither @file{foo} nor
  2678. @file{bar} would lead to that recommendation.
  2679. @item --profile=@var{profile}
  2680. @itemx -p @var{profile}
  2681. Use @var{profile} instead of the user's default profile.
  2682. @var{profile} must be the name of a file that will be created upon
  2683. completion. Concretely, @var{profile} will be a mere symbolic link
  2684. (``symlink'') pointing to the actual profile where packages are
  2685. installed:
  2686. @example
  2687. $ guix install hello -p ~/code/my-profile
  2688. @dots{}
  2689. $ ~/code/my-profile/bin/hello
  2690. Hello, world!
  2691. @end example
  2692. All it takes to get rid of the profile is to remove this symlink and its
  2693. siblings that point to specific generations:
  2694. @example
  2695. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2696. @end example
  2697. @item --list-profiles
  2698. List all the user's profiles:
  2699. @example
  2700. $ guix package --list-profiles
  2701. /home/charlie/.guix-profile
  2702. /home/charlie/code/my-profile
  2703. /home/charlie/code/devel-profile
  2704. /home/charlie/tmp/test
  2705. @end example
  2706. When running as root, list all the profiles of all the users.
  2707. @cindex collisions, in a profile
  2708. @cindex colliding packages in profiles
  2709. @cindex profile collisions
  2710. @item --allow-collisions
  2711. Allow colliding packages in the new profile. Use at your own risk!
  2712. By default, @command{guix package} reports as an error @dfn{collisions}
  2713. in the profile. Collisions happen when two or more different versions
  2714. or variants of a given package end up in the profile.
  2715. @item --bootstrap
  2716. Use the bootstrap Guile to build the profile. This option is only
  2717. useful to distribution developers.
  2718. @end table
  2719. In addition to these actions, @command{guix package} supports the
  2720. following options to query the current state of a profile, or the
  2721. availability of packages:
  2722. @table @option
  2723. @item --search=@var{regexp}
  2724. @itemx -s @var{regexp}
  2725. @anchor{guix-search}
  2726. @cindex searching for packages
  2727. List the available packages whose name, synopsis, or description matches
  2728. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2729. Print all the metadata of matching packages in
  2730. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2731. GNU recutils manual}).
  2732. This allows specific fields to be extracted using the @command{recsel}
  2733. command, for instance:
  2734. @example
  2735. $ guix package -s malloc | recsel -p name,version,relevance
  2736. name: jemalloc
  2737. version: 4.5.0
  2738. relevance: 6
  2739. name: glibc
  2740. version: 2.25
  2741. relevance: 1
  2742. name: libgc
  2743. version: 7.6.0
  2744. relevance: 1
  2745. @end example
  2746. Similarly, to show the name of all the packages available under the
  2747. terms of the GNU@tie{}LGPL version 3:
  2748. @example
  2749. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2750. name: elfutils
  2751. name: gmp
  2752. @dots{}
  2753. @end example
  2754. It is also possible to refine search results using several @code{-s} flags to
  2755. @command{guix package}, or several arguments to @command{guix search}. For
  2756. example, the following command returns a list of board games (this time using
  2757. the @command{guix search} alias):
  2758. @example
  2759. $ guix search '\<board\>' game | recsel -p name
  2760. name: gnubg
  2761. @dots{}
  2762. @end example
  2763. If we were to omit @code{-s game}, we would also get software packages
  2764. that deal with printed circuit boards; removing the angle brackets
  2765. around @code{board} would further add packages that have to do with
  2766. keyboards.
  2767. And now for a more elaborate example. The following command searches
  2768. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2769. libraries, and prints the name and synopsis of the matching packages:
  2770. @example
  2771. $ guix search crypto library | \
  2772. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2773. @end example
  2774. @noindent
  2775. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2776. information on @dfn{selection expressions} for @code{recsel -e}.
  2777. @item --show=@var{package}
  2778. Show details about @var{package}, taken from the list of available packages, in
  2779. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2780. recutils manual}).
  2781. @example
  2782. $ guix package --show=python | recsel -p name,version
  2783. name: python
  2784. version: 2.7.6
  2785. name: python
  2786. version: 3.3.5
  2787. @end example
  2788. You may also specify the full name of a package to only get details about a
  2789. specific version of it (this time using the @command{guix show} alias):
  2790. @example
  2791. $ guix show python@@3.4 | recsel -p name,version
  2792. name: python
  2793. version: 3.4.3
  2794. @end example
  2795. @item --list-installed[=@var{regexp}]
  2796. @itemx -I [@var{regexp}]
  2797. List the currently installed packages in the specified profile, with the
  2798. most recently installed packages shown last. When @var{regexp} is
  2799. specified, list only installed packages whose name matches @var{regexp}.
  2800. For each installed package, print the following items, separated by
  2801. tabs: the package name, its version string, the part of the package that
  2802. is installed (for instance, @code{out} for the default output,
  2803. @code{include} for its headers, etc.), and the path of this package in
  2804. the store.
  2805. @item --list-available[=@var{regexp}]
  2806. @itemx -A [@var{regexp}]
  2807. List packages currently available in the distribution for this system
  2808. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2809. available packages whose name matches @var{regexp}.
  2810. For each package, print the following items separated by tabs: its name,
  2811. its version string, the parts of the package (@pxref{Packages with
  2812. Multiple Outputs}), and the source location of its definition.
  2813. @item --list-generations[=@var{pattern}]
  2814. @itemx -l [@var{pattern}]
  2815. @cindex generations
  2816. Return a list of generations along with their creation dates; for each
  2817. generation, show the installed packages, with the most recently
  2818. installed packages shown last. Note that the zeroth generation is never
  2819. shown.
  2820. For each installed package, print the following items, separated by
  2821. tabs: the name of a package, its version string, the part of the package
  2822. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2823. location of this package in the store.
  2824. When @var{pattern} is used, the command returns only matching
  2825. generations. Valid patterns include:
  2826. @itemize
  2827. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2828. generation numbers. For instance, @option{--list-generations=1} returns
  2829. the first one.
  2830. And @option{--list-generations=1,8,2} outputs three generations in the
  2831. specified order. Neither spaces nor trailing commas are allowed.
  2832. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2833. specified generations and everything in between. Note that the start of
  2834. a range must be smaller than its end.
  2835. It is also possible to omit the endpoint. For example,
  2836. @option{--list-generations=2..}, returns all generations starting from the
  2837. second one.
  2838. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2839. or months by passing an integer along with the first letter of the
  2840. duration. For example, @option{--list-generations=20d} lists generations
  2841. that are up to 20 days old.
  2842. @end itemize
  2843. @item --delete-generations[=@var{pattern}]
  2844. @itemx -d [@var{pattern}]
  2845. When @var{pattern} is omitted, delete all generations except the current
  2846. one.
  2847. This command accepts the same patterns as @option{--list-generations}.
  2848. When @var{pattern} is specified, delete the matching generations. When
  2849. @var{pattern} specifies a duration, generations @emph{older} than the
  2850. specified duration match. For instance, @option{--delete-generations=1m}
  2851. deletes generations that are more than one month old.
  2852. If the current generation matches, it is @emph{not} deleted. Also, the
  2853. zeroth generation is never deleted.
  2854. Note that deleting generations prevents rolling back to them.
  2855. Consequently, this command must be used with care.
  2856. @end table
  2857. Finally, since @command{guix package} may actually start build
  2858. processes, it supports all the common build options (@pxref{Common Build
  2859. Options}). It also supports package transformation options, such as
  2860. @option{--with-source} (@pxref{Package Transformation Options}).
  2861. However, note that package transformations are lost when upgrading; to
  2862. preserve transformations across upgrades, you should define your own
  2863. package variant in a Guile module and add it to @env{GUIX_PACKAGE_PATH}
  2864. (@pxref{Defining Packages}).
  2865. @node Substitutes
  2866. @section Substitutes
  2867. @cindex substitutes
  2868. @cindex pre-built binaries
  2869. Guix supports transparent source/binary deployment, which means that it
  2870. can either build things locally, or download pre-built items from a
  2871. server, or both. We call these pre-built items @dfn{substitutes}---they
  2872. are substitutes for local build results. In many cases, downloading a
  2873. substitute is much faster than building things locally.
  2874. Substitutes can be anything resulting from a derivation build
  2875. (@pxref{Derivations}). Of course, in the common case, they are
  2876. pre-built package binaries, but source tarballs, for instance, which
  2877. also result from derivation builds, can be available as substitutes.
  2878. @menu
  2879. * Official Substitute Server:: One particular source of substitutes.
  2880. * Substitute Server Authorization:: How to enable or disable substitutes.
  2881. * Getting Substitutes from Other Servers:: Substitute diversity.
  2882. * Substitute Authentication:: How Guix verifies substitutes.
  2883. * Proxy Settings:: How to get substitutes via proxy.
  2884. * Substitution Failure:: What happens when substitution fails.
  2885. * On Trusting Binaries:: How can you trust that binary blob?
  2886. @end menu
  2887. @node Official Substitute Server
  2888. @subsection Official Substitute Server
  2889. @cindex build farm
  2890. The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
  2891. that builds packages from Guix continuously for some
  2892. architectures, and makes them available as substitutes. This is the
  2893. default source of substitutes; it can be overridden by passing the
  2894. @option{--substitute-urls} option either to @command{guix-daemon}
  2895. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  2896. or to client tools such as @command{guix package}
  2897. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  2898. option}).
  2899. Substitute URLs can be either HTTP or HTTPS.
  2900. HTTPS is recommended because communications are encrypted; conversely,
  2901. using HTTP makes all communications visible to an eavesdropper, who
  2902. could use the information gathered to determine, for instance, whether
  2903. your system has unpatched security vulnerabilities.
  2904. Substitutes from the official build farm are enabled by default when
  2905. using Guix System (@pxref{GNU Distribution}). However,
  2906. they are disabled by default when using Guix on a foreign distribution,
  2907. unless you have explicitly enabled them via one of the recommended
  2908. installation steps (@pxref{Installation}). The following paragraphs
  2909. describe how to enable or disable substitutes for the official build
  2910. farm; the same procedure can also be used to enable substitutes for any
  2911. other substitute server.
  2912. @node Substitute Server Authorization
  2913. @subsection Substitute Server Authorization
  2914. @cindex security
  2915. @cindex substitutes, authorization thereof
  2916. @cindex access control list (ACL), for substitutes
  2917. @cindex ACL (access control list), for substitutes
  2918. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
  2919. mirror thereof, you
  2920. must add its public key to the access control list (ACL) of archive
  2921. imports, using the @command{guix archive} command (@pxref{Invoking guix
  2922. archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
  2923. be compromised and to serve genuine substitutes.
  2924. @quotation Note
  2925. If you are using Guix System, you can skip this section: Guix System
  2926. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER}} by default.
  2927. @end quotation
  2928. The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
  2929. @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
  2930. the installation prefix of Guix. If you installed Guix from source,
  2931. make sure you checked the GPG signature of
  2932. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  2933. Then, you can run something like this:
  2934. @example
  2935. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
  2936. @end example
  2937. Once this is in place, the output of a command like @code{guix build}
  2938. should change from something like:
  2939. @example
  2940. $ guix build emacs --dry-run
  2941. The following derivations would be built:
  2942. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  2943. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  2944. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  2945. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  2946. @dots{}
  2947. @end example
  2948. @noindent
  2949. to something like:
  2950. @example
  2951. $ guix build emacs --dry-run
  2952. 112.3 MB would be downloaded:
  2953. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  2954. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  2955. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  2956. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  2957. @dots{}
  2958. @end example
  2959. @noindent
  2960. The text changed from ``The following derivations would be built'' to
  2961. ``112.3 MB would be downloaded''. This indicates that substitutes from
  2962. @code{@value{SUBSTITUTE-SERVER}} are usable and will be downloaded, when
  2963. possible, for future builds.
  2964. @cindex substitutes, how to disable
  2965. The substitute mechanism can be disabled globally by running
  2966. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  2967. guix-daemon}). It can also be disabled temporarily by passing the
  2968. @option{--no-substitutes} option to @command{guix package},
  2969. @command{guix build}, and other command-line tools.
  2970. @node Getting Substitutes from Other Servers
  2971. @subsection Getting Substitutes from Other Servers
  2972. @cindex substitute servers, adding more
  2973. Guix can look up and fetch substitutes from several servers. This is
  2974. useful when you are using packages from additional channels for which
  2975. the official server does not have substitutes but another server
  2976. provides them. Another situation where this is useful is when you would
  2977. prefer to download from your organization's substitute server, resorting
  2978. to the official server only as a fallback or dismissing it altogether.
  2979. You can give Guix a list of substitute server URLs and it will check
  2980. them in the specified order. You also need to explicitly authorize the
  2981. public keys of substitute servers to instruct Guix to accept the
  2982. substitutes they sign.
  2983. On Guix System, this is achieved by modifying the configuration of the
  2984. @code{guix} service. Since the @code{guix} service is part of the
  2985. default lists of services, @code{%base-services} and
  2986. @code{%desktop-services}, you can use @code{modify-services} to change
  2987. its configuration and add the URLs and substitute keys that you want
  2988. (@pxref{Service Reference, @code{modify-services}}).
  2989. As an example, suppose you want to fetch substitutes from
  2990. @code{guix.example.org} and to authorize the signing key of that server,
  2991. in addition to the default @code{@value{SUBSTITUTE-SERVER}}. The
  2992. resulting operating system configuration will look something like:
  2993. @lisp
  2994. (operating-system
  2995. ;; @dots{}
  2996. (services
  2997. ;; Assume we're starting from '%desktop-services'. Replace it
  2998. ;; with the list of services you're actually using.
  2999. (modify-services %desktop-services
  3000. (guix-service-type config =>
  3001. (guix-configuration
  3002. (inherit config)
  3003. (substitute-urls
  3004. (append (list "https://guix.example.org")
  3005. %default-substitute-urls))
  3006. (authorized-keys
  3007. (append (list (local-file "./key.pub"))
  3008. %default-authorized-guix-keys)))))))
  3009. @end lisp
  3010. This assumes that the file @file{key.pub} contains the signing key of
  3011. @code{guix.example.org}. With this change in place in your operating
  3012. system configuration file (say @file{/etc/config.scm}), you can
  3013. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3014. changes take effect:
  3015. @example
  3016. $ sudo guix system reconfigure /etc/config.scm
  3017. $ sudo herd restart guix-daemon
  3018. @end example
  3019. If you're running Guix on a ``foreign distro'', you would instead take
  3020. the following steps to get substitutes from additional servers:
  3021. @enumerate
  3022. @item
  3023. Edit the service configuration file for @code{guix-daemon}; when using
  3024. systemd, this is normally
  3025. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3026. @option{--substitute-urls} option on the @command{guix-daemon} command
  3027. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3028. @code{guix-daemon --substitute-urls}}):
  3029. @example
  3030. @dots{} --substitute-urls='https://guix.example.org https://@value{SUBSTITUTE-SERVER}'
  3031. @end example
  3032. @item
  3033. Restart the daemon. For systemd, it goes like this:
  3034. @example
  3035. systemctl daemon-reload
  3036. systemctl restart guix-daemon.service
  3037. @end example
  3038. @item
  3039. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3040. @example
  3041. guix archive --authorize < key.pub
  3042. @end example
  3043. Again this assumes @file{key.pub} contains the public key that
  3044. @code{guix.example.org} uses to sign substitutes.
  3045. @end enumerate
  3046. Now you're all set! Substitutes will be preferably taken from
  3047. @code{https://guix.example.org}, using @code{@value{SUBSTITUTE-SERVER}}
  3048. as a fallback. Of course you can list as many substitute servers as you
  3049. like, with the caveat that substitute lookup can be slowed down if too
  3050. many servers need to be contacted.
  3051. Note that there are also situations where one may want to add the URL of
  3052. a substitute server @emph{without} authorizing its key.
  3053. @xref{Substitute Authentication}, to understand this fine point.
  3054. @node Substitute Authentication
  3055. @subsection Substitute Authentication
  3056. @cindex digital signatures
  3057. Guix detects and raises an error when attempting to use a substitute
  3058. that has been tampered with. Likewise, it ignores substitutes that are
  3059. not signed, or that are not signed by one of the keys listed in the ACL.
  3060. There is one exception though: if an unauthorized server provides
  3061. substitutes that are @emph{bit-for-bit identical} to those provided by
  3062. an authorized server, then the unauthorized server becomes eligible for
  3063. downloads. For example, assume we have chosen two substitute servers
  3064. with this option:
  3065. @example
  3066. --substitute-urls="https://a.example.org https://b.example.org"
  3067. @end example
  3068. @noindent
  3069. @cindex reproducible builds
  3070. If the ACL contains only the key for @samp{b.example.org}, and if
  3071. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3072. then Guix will download substitutes from @samp{a.example.org} because it
  3073. comes first in the list and can be considered a mirror of
  3074. @samp{b.example.org}. In practice, independent build machines usually
  3075. produce the same binaries, thanks to bit-reproducible builds (see
  3076. below).
  3077. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3078. (in other words, the server is not authenticated), contrary to what
  3079. HTTPS clients such as Web browsers usually do. This is because Guix
  3080. authenticates substitute information itself, as explained above, which
  3081. is what we care about (whereas X.509 certificates are about
  3082. authenticating bindings between domain names and public keys).
  3083. @node Proxy Settings
  3084. @subsection Proxy Settings
  3085. @vindex http_proxy
  3086. @vindex https_proxy
  3087. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3088. @env{https_proxy} environment variables can be set in the environment of
  3089. @command{guix-daemon} and are honored for downloads of substitutes.
  3090. Note that the value of those environment variables in the environment
  3091. where @command{guix build}, @command{guix package}, and other client
  3092. commands are run has @emph{absolutely no effect}.
  3093. @node Substitution Failure
  3094. @subsection Substitution Failure
  3095. Even when a substitute for a derivation is available, sometimes the
  3096. substitution attempt will fail. This can happen for a variety of
  3097. reasons: the substitute server might be offline, the substitute may
  3098. recently have been deleted, the connection might have been interrupted,
  3099. etc.
  3100. When substitutes are enabled and a substitute for a derivation is
  3101. available, but the substitution attempt fails, Guix will attempt to
  3102. build the derivation locally depending on whether or not
  3103. @option{--fallback} was given (@pxref{fallback-option,, common build
  3104. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3105. omitted, then no local build will be performed, and the derivation is
  3106. considered to have failed. However, if @option{--fallback} was given,
  3107. then Guix will attempt to build the derivation locally, and the success
  3108. or failure of the derivation depends on the success or failure of the
  3109. local build. Note that when substitutes are disabled or no substitute
  3110. is available for the derivation in question, a local build will
  3111. @emph{always} be performed, regardless of whether or not
  3112. @option{--fallback} was given.
  3113. To get an idea of how many substitutes are available right now, you can
  3114. try running the @command{guix weather} command (@pxref{Invoking guix
  3115. weather}). This command provides statistics on the substitutes provided
  3116. by a server.
  3117. @node On Trusting Binaries
  3118. @subsection On Trusting Binaries
  3119. @cindex trust, of pre-built binaries
  3120. Today, each individual's control over their own computing is at the
  3121. mercy of institutions, corporations, and groups with enough power and
  3122. determination to subvert the computing infrastructure and exploit its
  3123. weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
  3124. convenient, we encourage users to also build on their own, or even run
  3125. their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
  3126. interesting target. One way to help is by publishing the software you
  3127. build using @command{guix publish} so that others have one more choice
  3128. of server to download substitutes from (@pxref{Invoking guix publish}).
  3129. Guix has the foundations to maximize build reproducibility
  3130. (@pxref{Features}). In most cases, independent builds of a given
  3131. package or derivation should yield bit-identical results. Thus, through
  3132. a diverse set of independent package builds, we can strengthen the
  3133. integrity of our systems. The @command{guix challenge} command aims to
  3134. help users assess substitute servers, and to assist developers in
  3135. finding out about non-deterministic package builds (@pxref{Invoking guix
  3136. challenge}). Similarly, the @option{--check} option of @command{guix
  3137. build} allows users to check whether previously-installed substitutes
  3138. are genuine by rebuilding them locally (@pxref{build-check,
  3139. @command{guix build --check}}).
  3140. In the future, we want Guix to have support to publish and retrieve
  3141. binaries to/from other users, in a peer-to-peer fashion. If you would
  3142. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3143. @node Packages with Multiple Outputs
  3144. @section Packages with Multiple Outputs
  3145. @cindex multiple-output packages
  3146. @cindex package outputs
  3147. @cindex outputs
  3148. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3149. source package leads to exactly one directory in the store. When running
  3150. @command{guix install glibc}, one installs the default output of the
  3151. GNU libc package; the default output is called @code{out}, but its name
  3152. can be omitted as shown in this command. In this particular case, the
  3153. default output of @code{glibc} contains all the C header files, shared
  3154. libraries, static libraries, Info documentation, and other supporting
  3155. files.
  3156. Sometimes it is more appropriate to separate the various types of files
  3157. produced from a single source package into separate outputs. For
  3158. instance, the GLib C library (used by GTK+ and related packages)
  3159. installs more than 20 MiB of reference documentation as HTML pages.
  3160. To save space for users who do not need it, the documentation goes to a
  3161. separate output, called @code{doc}. To install the main GLib output,
  3162. which contains everything but the documentation, one would run:
  3163. @example
  3164. guix install glib
  3165. @end example
  3166. @cindex documentation
  3167. The command to install its documentation is:
  3168. @example
  3169. guix install glib:doc
  3170. @end example
  3171. Some packages install programs with different ``dependency footprints''.
  3172. For instance, the WordNet package installs both command-line tools and
  3173. graphical user interfaces (GUIs). The former depend solely on the C
  3174. library, whereas the latter depend on Tcl/Tk and the underlying X
  3175. libraries. In this case, we leave the command-line tools in the default
  3176. output, whereas the GUIs are in a separate output. This allows users
  3177. who do not need the GUIs to save space. The @command{guix size} command
  3178. can help find out about such situations (@pxref{Invoking guix size}).
  3179. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3180. There are several such multiple-output packages in the GNU distribution.
  3181. Other conventional output names include @code{lib} for libraries and
  3182. possibly header files, @code{bin} for stand-alone programs, and
  3183. @code{debug} for debugging information (@pxref{Installing Debugging
  3184. Files}). The outputs of a packages are listed in the third column of
  3185. the output of @command{guix package --list-available} (@pxref{Invoking
  3186. guix package}).
  3187. @node Invoking guix gc
  3188. @section Invoking @command{guix gc}
  3189. @cindex garbage collector
  3190. @cindex disk space
  3191. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3192. The @command{guix gc} command allows users to explicitly run the garbage
  3193. collector to reclaim space from the @file{/gnu/store} directory. It is
  3194. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3195. files or directories manually may break it beyond repair!
  3196. @cindex GC roots
  3197. @cindex garbage collector roots
  3198. The garbage collector has a set of known @dfn{roots}: any file under
  3199. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3200. cannot be deleted; any other file is considered @dfn{dead} and may be
  3201. deleted. The set of garbage collector roots (``GC roots'' for short)
  3202. includes default user profiles; by default, the symlinks under
  3203. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3204. added with @command{guix build --root}, for example (@pxref{Invoking
  3205. guix build}). The @command{guix gc --list-roots} command lists them.
  3206. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3207. often useful to remove old generations from user profiles; that way, old
  3208. package builds referenced by those generations can be reclaimed. This
  3209. is achieved by running @code{guix package --delete-generations}
  3210. (@pxref{Invoking guix package}).
  3211. Our recommendation is to run a garbage collection periodically, or when
  3212. you are short on disk space. For instance, to guarantee that at least
  3213. 5@tie{}GB are available on your disk, simply run:
  3214. @example
  3215. guix gc -F 5G
  3216. @end example
  3217. It is perfectly safe to run as a non-interactive periodic job
  3218. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3219. Running @command{guix gc} with no arguments will collect as
  3220. much garbage as it can, but that is often inconvenient: you may find
  3221. yourself having to rebuild or re-download software that is ``dead'' from
  3222. the GC viewpoint but that is necessary to build other pieces of
  3223. software---e.g., the compiler tool chain.
  3224. The @command{guix gc} command has three modes of operation: it can be
  3225. used to garbage-collect any dead files (the default), to delete specific
  3226. files (the @option{--delete} option), to print garbage-collector
  3227. information, or for more advanced queries. The garbage collection
  3228. options are as follows:
  3229. @table @code
  3230. @item --collect-garbage[=@var{min}]
  3231. @itemx -C [@var{min}]
  3232. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3233. sub-directories. This is the default operation when no option is
  3234. specified.
  3235. When @var{min} is given, stop once @var{min} bytes have been collected.
  3236. @var{min} may be a number of bytes, or it may include a unit as a
  3237. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3238. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3239. When @var{min} is omitted, collect all the garbage.
  3240. @item --free-space=@var{free}
  3241. @itemx -F @var{free}
  3242. Collect garbage until @var{free} space is available under
  3243. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3244. as @code{500MiB}, as described above.
  3245. When @var{free} or more is already available in @file{/gnu/store}, do
  3246. nothing and exit immediately.
  3247. @item --delete-generations[=@var{duration}]
  3248. @itemx -d [@var{duration}]
  3249. Before starting the garbage collection process, delete all the generations
  3250. older than @var{duration}, for all the user profiles; when run as root, this
  3251. applies to all the profiles @emph{of all the users}.
  3252. For example, this command deletes all the generations of all your profiles
  3253. that are older than 2 months (except generations that are current), and then
  3254. proceeds to free space until at least 10 GiB are available:
  3255. @example
  3256. guix gc -d 2m -F 10G
  3257. @end example
  3258. @item --delete
  3259. @itemx -D
  3260. Attempt to delete all the store files and directories specified as
  3261. arguments. This fails if some of the files are not in the store, or if
  3262. they are still live.
  3263. @item --list-failures
  3264. List store items corresponding to cached build failures.
  3265. This prints nothing unless the daemon was started with
  3266. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3267. @option{--cache-failures}}).
  3268. @item --list-roots
  3269. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3270. roots.
  3271. @item --list-busy
  3272. List store items in use by currently running processes. These store
  3273. items are effectively considered GC roots: they cannot be deleted.
  3274. @item --clear-failures
  3275. Remove the specified store items from the failed-build cache.
  3276. Again, this option only makes sense when the daemon is started with
  3277. @option{--cache-failures}. Otherwise, it does nothing.
  3278. @item --list-dead
  3279. Show the list of dead files and directories still present in the
  3280. store---i.e., files and directories no longer reachable from any root.
  3281. @item --list-live
  3282. Show the list of live store files and directories.
  3283. @end table
  3284. In addition, the references among existing store files can be queried:
  3285. @table @code
  3286. @item --references
  3287. @itemx --referrers
  3288. @cindex package dependencies
  3289. List the references (respectively, the referrers) of store files given
  3290. as arguments.
  3291. @item --requisites
  3292. @itemx -R
  3293. @cindex closure
  3294. List the requisites of the store files passed as arguments. Requisites
  3295. include the store files themselves, their references, and the references
  3296. of these, recursively. In other words, the returned list is the
  3297. @dfn{transitive closure} of the store files.
  3298. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3299. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3300. the graph of references.
  3301. @item --derivers
  3302. @cindex derivation
  3303. Return the derivation(s) leading to the given store items
  3304. (@pxref{Derivations}).
  3305. For example, this command:
  3306. @example
  3307. guix gc --derivers `guix package -I ^emacs$ | cut -f4`
  3308. @end example
  3309. @noindent
  3310. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3311. installed in your profile.
  3312. Note that there may be zero matching @file{.drv} files, for instance
  3313. because these files have been garbage-collected. There can also be more
  3314. than one matching @file{.drv} due to fixed-output derivations.
  3315. @end table
  3316. Lastly, the following options allow you to check the integrity of the
  3317. store and to control disk usage.
  3318. @table @option
  3319. @item --verify[=@var{options}]
  3320. @cindex integrity, of the store
  3321. @cindex integrity checking
  3322. Verify the integrity of the store.
  3323. By default, make sure that all the store items marked as valid in the
  3324. database of the daemon actually exist in @file{/gnu/store}.
  3325. When provided, @var{options} must be a comma-separated list containing one
  3326. or more of @code{contents} and @code{repair}.
  3327. When passing @option{--verify=contents}, the daemon computes the
  3328. content hash of each store item and compares it against its hash in the
  3329. database. Hash mismatches are reported as data corruptions. Because it
  3330. traverses @emph{all the files in the store}, this command can take a
  3331. long time, especially on systems with a slow disk drive.
  3332. @cindex repairing the store
  3333. @cindex corruption, recovering from
  3334. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3335. causes the daemon to try to repair corrupt store items by fetching
  3336. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3337. atomic, and thus potentially dangerous, it is available only to the
  3338. system administrator. A lightweight alternative, when you know exactly
  3339. which items in the store are corrupt, is @command{guix build --repair}
  3340. (@pxref{Invoking guix build}).
  3341. @item --optimize
  3342. @cindex deduplication
  3343. Optimize the store by hard-linking identical files---this is
  3344. @dfn{deduplication}.
  3345. The daemon performs deduplication after each successful build or archive
  3346. import, unless it was started with @option{--disable-deduplication}
  3347. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3348. this option is primarily useful when the daemon was running with
  3349. @option{--disable-deduplication}.
  3350. @end table
  3351. @node Invoking guix pull
  3352. @section Invoking @command{guix pull}
  3353. @cindex upgrading Guix
  3354. @cindex updating Guix
  3355. @cindex @command{guix pull}
  3356. @cindex pull
  3357. @cindex security, @command{guix pull}
  3358. @cindex authenticity, of code obtained with @command{guix pull}
  3359. Packages are installed or upgraded to the latest version available in
  3360. the distribution currently available on your local machine. To update
  3361. that distribution, along with the Guix tools, you must run @command{guix
  3362. pull}: the command downloads the latest Guix source code and package
  3363. descriptions, and deploys it. Source code is downloaded from a
  3364. @uref{https://git-scm.com, Git} repository, by default the official
  3365. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3366. pull} ensures that the code it downloads is @emph{authentic} by
  3367. verifying that commits are signed by Guix developers.
  3368. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3369. (@pxref{Channels}) specified by one of the followings, in this order:
  3370. @enumerate
  3371. @item
  3372. the @option{--channels} option;
  3373. @item
  3374. the user's @file{~/.config/guix/channels.scm} file;
  3375. @item
  3376. the system-wide @file{/etc/guix/channels.scm} file;
  3377. @item
  3378. the built-in default channels specified in the @code{%default-channels}
  3379. variable.
  3380. @end enumerate
  3381. On completion, @command{guix package} will use packages and package
  3382. versions from this just-retrieved copy of Guix. Not only that, but all
  3383. the Guix commands and Scheme modules will also be taken from that latest
  3384. version. New @command{guix} sub-commands added by the update also
  3385. become available.
  3386. Any user can update their Guix copy using @command{guix pull}, and the
  3387. effect is limited to the user who ran @command{guix pull}. For
  3388. instance, when user @code{root} runs @command{guix pull}, this has no
  3389. effect on the version of Guix that user @code{alice} sees, and vice
  3390. versa.
  3391. The result of running @command{guix pull} is a @dfn{profile} available
  3392. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3393. make sure to add it to the beginning of your search path so that you use
  3394. the latest version, and similarly for the Info manual
  3395. (@pxref{Documentation}):
  3396. @example
  3397. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3398. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3399. @end example
  3400. The @option{--list-generations} or @option{-l} option lists past generations
  3401. produced by @command{guix pull}, along with details about their provenance:
  3402. @example
  3403. $ guix pull -l
  3404. Generation 1 Jun 10 2018 00:18:18
  3405. guix 65956ad
  3406. repository URL: https://git.savannah.gnu.org/git/guix.git
  3407. branch: origin/master
  3408. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3409. Generation 2 Jun 11 2018 11:02:49
  3410. guix e0cc7f6
  3411. repository URL: https://git.savannah.gnu.org/git/guix.git
  3412. branch: origin/master
  3413. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3414. 2 new packages: keepalived, libnfnetlink
  3415. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3416. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3417. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3418. Generation 3 Jun 13 2018 23:31:07 (current)
  3419. guix 844cc1c
  3420. repository URL: https://git.savannah.gnu.org/git/guix.git
  3421. branch: origin/master
  3422. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3423. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3424. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3425. @end example
  3426. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3427. describe the current status of Guix.
  3428. This @code{~/.config/guix/current} profile works exactly like the profiles
  3429. created by @command{guix package} (@pxref{Invoking guix package}). That
  3430. is, you can list generations, roll back to the previous
  3431. generation---i.e., the previous Guix---and so on:
  3432. @example
  3433. $ guix pull --roll-back
  3434. switched from generation 3 to 2
  3435. $ guix pull --delete-generations=1
  3436. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3437. @end example
  3438. You can also use @command{guix package} (@pxref{Invoking guix package})
  3439. to manage the profile by naming it explicitly:
  3440. @example
  3441. $ guix package -p ~/.config/guix/current --roll-back
  3442. switched from generation 3 to 2
  3443. $ guix package -p ~/.config/guix/current --delete-generations=1
  3444. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3445. @end example
  3446. The @command{guix pull} command is usually invoked with no arguments,
  3447. but it supports the following options:
  3448. @table @code
  3449. @item --url=@var{url}
  3450. @itemx --commit=@var{commit}
  3451. @itemx --branch=@var{branch}
  3452. Download code for the @code{guix} channel from the specified @var{url}, at the
  3453. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3454. string), or @var{branch}.
  3455. @cindex @file{channels.scm}, configuration file
  3456. @cindex configuration file for channels
  3457. These options are provided for convenience, but you can also specify your
  3458. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3459. @option{--channels} option (see below).
  3460. @item --channels=@var{file}
  3461. @itemx -C @var{file}
  3462. Read the list of channels from @var{file} instead of
  3463. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3464. @var{file} must contain Scheme code that
  3465. evaluates to a list of channel objects. @xref{Channels}, for more
  3466. information.
  3467. @cindex channel news
  3468. @item --news
  3469. @itemx -N
  3470. Display the list of packages added or upgraded since the previous
  3471. generation, as well as, occasionally, news written by channel authors
  3472. for their users (@pxref{Channels, Writing Channel News}).
  3473. The package information is the same as displayed upon @command{guix
  3474. pull} completion, but without ellipses; it is also similar to the output
  3475. of @command{guix pull -l} for the last generation (see below).
  3476. @item --list-generations[=@var{pattern}]
  3477. @itemx -l [@var{pattern}]
  3478. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3479. is provided, the subset of generations that match @var{pattern}.
  3480. The syntax of @var{pattern} is the same as with @code{guix package
  3481. --list-generations} (@pxref{Invoking guix package}).
  3482. @item --roll-back
  3483. @cindex rolling back
  3484. @cindex undoing transactions
  3485. @cindex transactions, undoing
  3486. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3487. undo the last transaction.
  3488. @item --switch-generation=@var{pattern}
  3489. @itemx -S @var{pattern}
  3490. @cindex generations
  3491. Switch to a particular generation defined by @var{pattern}.
  3492. @var{pattern} may be either a generation number or a number prefixed
  3493. with ``+'' or ``-''. The latter means: move forward/backward by a
  3494. specified number of generations. For example, if you want to return to
  3495. the latest generation after @option{--roll-back}, use
  3496. @option{--switch-generation=+1}.
  3497. @item --delete-generations[=@var{pattern}]
  3498. @itemx -d [@var{pattern}]
  3499. When @var{pattern} is omitted, delete all generations except the current
  3500. one.
  3501. This command accepts the same patterns as @option{--list-generations}.
  3502. When @var{pattern} is specified, delete the matching generations. When
  3503. @var{pattern} specifies a duration, generations @emph{older} than the
  3504. specified duration match. For instance, @option{--delete-generations=1m}
  3505. deletes generations that are more than one month old.
  3506. If the current generation matches, it is @emph{not} deleted.
  3507. Note that deleting generations prevents rolling back to them.
  3508. Consequently, this command must be used with care.
  3509. @xref{Invoking guix describe}, for a way to display information about the
  3510. current generation only.
  3511. @item --profile=@var{profile}
  3512. @itemx -p @var{profile}
  3513. Use @var{profile} instead of @file{~/.config/guix/current}.
  3514. @item --dry-run
  3515. @itemx -n
  3516. Show which channel commit(s) would be used and what would be built or
  3517. substituted but do not actually do it.
  3518. @item --allow-downgrades
  3519. Allow pulling older or unrelated revisions of channels than those
  3520. currently in use.
  3521. @cindex downgrade attacks, protection against
  3522. By default, @command{guix pull} protects against so-called ``downgrade
  3523. attacks'' whereby the Git repository of a channel would be reset to an
  3524. earlier or unrelated revision of itself, potentially leading you to
  3525. install older, known-vulnerable versions of software packages.
  3526. @quotation Note
  3527. Make sure you understand its security implications before using
  3528. @option{--allow-downgrades}.
  3529. @end quotation
  3530. @item --disable-authentication
  3531. Allow pulling channel code without authenticating it.
  3532. @cindex authentication, of channel code
  3533. By default, @command{guix pull} authenticates code downloaded from
  3534. channels by verifying that its commits are signed by authorized
  3535. developers, and raises an error if this is not the case. This option
  3536. instructs it to not perform any such verification.
  3537. @quotation Note
  3538. Make sure you understand its security implications before using
  3539. @option{--disable-authentication}.
  3540. @end quotation
  3541. @item --system=@var{system}
  3542. @itemx -s @var{system}
  3543. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3544. the system type of the build host.
  3545. @item --bootstrap
  3546. Use the bootstrap Guile to build the latest Guix. This option is only
  3547. useful to Guix developers.
  3548. @end table
  3549. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3550. repository and branch to pull from, as well as @emph{additional} repositories
  3551. containing package modules that should be deployed. @xref{Channels}, for more
  3552. information.
  3553. In addition, @command{guix pull} supports all the common build options
  3554. (@pxref{Common Build Options}).
  3555. @node Invoking guix time-machine
  3556. @section Invoking @command{guix time-machine}
  3557. @cindex @command{guix time-machine}
  3558. @cindex pinning, channels
  3559. @cindex replicating Guix
  3560. @cindex reproducibility, of Guix
  3561. The @command{guix time-machine} command provides access to other
  3562. revisions of Guix, for example to install older versions of packages,
  3563. or to reproduce a computation in an identical environment. The revision
  3564. of Guix to be used is defined by a commit or by a channel
  3565. description file created by @command{guix describe}
  3566. (@pxref{Invoking guix describe}).
  3567. The general syntax is:
  3568. @example
  3569. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3570. @end example
  3571. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3572. @command{guix} command of the specified revision. The @var{options} that define
  3573. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3574. @table @code
  3575. @item --url=@var{url}
  3576. @itemx --commit=@var{commit}
  3577. @itemx --branch=@var{branch}
  3578. Use the @code{guix} channel from the specified @var{url}, at the
  3579. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3580. string), or @var{branch}.
  3581. @item --channels=@var{file}
  3582. @itemx -C @var{file}
  3583. Read the list of channels from @var{file}. @var{file} must contain
  3584. Scheme code that evaluates to a list of channel objects.
  3585. @xref{Channels} for more information.
  3586. @end table
  3587. As for @command{guix pull}, the absence of any options means that the
  3588. latest commit on the master branch will be used. The command
  3589. @example
  3590. guix time-machine -- build hello
  3591. @end example
  3592. will thus build the package @code{hello} as defined in the master branch,
  3593. which is in general a newer revision of Guix than you have installed.
  3594. Time travel works in both directions!
  3595. Note that @command{guix time-machine} can trigger builds of channels and
  3596. their dependencies, and these are controlled by the standard build
  3597. options (@pxref{Common Build Options}).
  3598. @node Inferiors
  3599. @section Inferiors
  3600. @c TODO: Remove this once we're more confident about API stability.
  3601. @quotation Note
  3602. The functionality described here is a ``technology preview'' as of version
  3603. @value{VERSION}. As such, the interface is subject to change.
  3604. @end quotation
  3605. @cindex inferiors
  3606. @cindex composition of Guix revisions
  3607. Sometimes you might need to mix packages from the revision of Guix you're
  3608. currently running with packages available in a different revision of Guix.
  3609. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3610. revisions in arbitrary ways.
  3611. @cindex inferior packages
  3612. Technically, an ``inferior'' is essentially a separate Guix process connected
  3613. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3614. @code{(guix inferior)} module allows you to create inferiors and to
  3615. communicate with them. It also provides a high-level interface to browse and
  3616. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3617. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3618. to interact with a separate revision of Guix. For example, let's assume you
  3619. want to install in your profile the current @code{guile} package, along with
  3620. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3621. because the newer @code{guile-json} has an incompatible API and you want to
  3622. run your code against the old API@. To do that, you could write a manifest for
  3623. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3624. manifest, you would create an inferior for that old Guix revision you care
  3625. about, and you would look up the @code{guile-json} package in the inferior:
  3626. @lisp
  3627. (use-modules (guix inferior) (guix channels)
  3628. (srfi srfi-1)) ;for 'first'
  3629. (define channels
  3630. ;; This is the old revision from which we want to
  3631. ;; extract guile-json.
  3632. (list (channel
  3633. (name 'guix)
  3634. (url "https://git.savannah.gnu.org/git/guix.git")
  3635. (commit
  3636. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3637. (define inferior
  3638. ;; An inferior representing the above revision.
  3639. (inferior-for-channels channels))
  3640. ;; Now create a manifest with the current "guile" package
  3641. ;; and the old "guile-json" package.
  3642. (packages->manifest
  3643. (list (first (lookup-inferior-packages inferior "guile-json"))
  3644. (specification->package "guile")))
  3645. @end lisp
  3646. On its first run, @command{guix package --manifest} might have to build the
  3647. channel you specified before it can create the inferior; subsequent runs will
  3648. be much faster because the Guix revision will be cached.
  3649. The @code{(guix inferior)} module provides the following procedures to open an
  3650. inferior:
  3651. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3652. [#:cache-directory] [#:ttl]
  3653. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3654. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3655. This procedure opens a new connection to the build daemon.
  3656. As a side effect, this procedure may build or substitute binaries for
  3657. @var{channels}, which can take time.
  3658. @end deffn
  3659. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3660. [#:command "bin/guix"]
  3661. Open the inferior Guix in @var{directory}, running
  3662. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3663. the inferior could not be launched.
  3664. @end deffn
  3665. @cindex inferior packages
  3666. The procedures listed below allow you to obtain and manipulate inferior
  3667. packages.
  3668. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3669. Return the list of packages known to @var{inferior}.
  3670. @end deffn
  3671. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3672. [@var{version}]
  3673. Return the sorted list of inferior packages matching @var{name} in
  3674. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3675. return only packages with a version number prefixed by @var{version}.
  3676. @end deffn
  3677. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3678. Return true if @var{obj} is an inferior package.
  3679. @end deffn
  3680. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3681. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3682. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3683. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3684. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3685. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3686. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3687. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3688. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3689. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3690. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3691. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3692. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3693. These procedures are the counterpart of package record accessors
  3694. (@pxref{package Reference}). Most of them work by querying the inferior
  3695. @var{package} comes from, so the inferior must still be live when you call
  3696. these procedures.
  3697. @end deffn
  3698. Inferior packages can be used transparently like any other package or
  3699. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3700. transparently handled by the @code{packages->manifest} procedure, which is
  3701. commonly use in manifests (@pxref{Invoking guix package, the
  3702. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3703. an inferior package pretty much anywhere you would insert a regular package:
  3704. in manifests, in the @code{packages} field of your @code{operating-system}
  3705. declaration, and so on.
  3706. @node Invoking guix describe
  3707. @section Invoking @command{guix describe}
  3708. @cindex reproducibility
  3709. @cindex replicating Guix
  3710. Often you may want to answer questions like: ``Which revision of Guix am I
  3711. using?'' or ``Which channels am I using?'' This is useful information in many
  3712. situations: if you want to @emph{replicate} an environment on a different
  3713. machine or user account, if you want to report a bug or to determine what
  3714. change in the channels you are using caused it, or if you want to record your
  3715. system state for reproducibility purposes. The @command{guix describe}
  3716. command answers these questions.
  3717. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3718. displays the channel(s) that it was built from, including their repository URL
  3719. and commit IDs (@pxref{Channels}):
  3720. @example
  3721. $ guix describe
  3722. Generation 10 Sep 03 2018 17:32:44 (current)
  3723. guix e0fa68c
  3724. repository URL: https://git.savannah.gnu.org/git/guix.git
  3725. branch: master
  3726. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3727. @end example
  3728. If you're familiar with the Git version control system, this is similar in
  3729. spirit to @command{git describe}; the output is also similar to that of
  3730. @command{guix pull --list-generations}, but limited to the current generation
  3731. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3732. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3733. information is all it takes to describe the revision of Guix you're using, and
  3734. also to replicate it.
  3735. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3736. to return a list of channels instead of the human-readable description above:
  3737. @example
  3738. $ guix describe -f channels
  3739. (list (channel
  3740. (name 'guix)
  3741. (url "https://git.savannah.gnu.org/git/guix.git")
  3742. (commit
  3743. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3744. (introduction
  3745. (make-channel-introduction
  3746. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3747. (openpgp-fingerprint
  3748. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3749. @end example
  3750. @noindent
  3751. You can save this to a file and feed it to @command{guix pull -C} on some
  3752. other machine or at a later point in time, which will instantiate @emph{this
  3753. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3754. From there on, since you're able to deploy the same revision of Guix, you can
  3755. just as well @emph{replicate a complete software environment}. We humbly
  3756. think that this is @emph{awesome}, and we hope you'll like it too!
  3757. The details of the options supported by @command{guix describe} are as
  3758. follows:
  3759. @table @code
  3760. @item --format=@var{format}
  3761. @itemx -f @var{format}
  3762. Produce output in the specified @var{format}, one of:
  3763. @table @code
  3764. @item human
  3765. produce human-readable output;
  3766. @item channels
  3767. produce a list of channel specifications that can be passed to @command{guix
  3768. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3769. guix pull});
  3770. @item channels-sans-intro
  3771. like @code{channels}, but omit the @code{introduction} field; use it to
  3772. produce a channel specification suitable for Guix version 1.1.0 or
  3773. earlier---the @code{introduction} field has to do with channel
  3774. authentication (@pxref{Channels, Channel Authentication}) and is not
  3775. supported by these older versions;
  3776. @item json
  3777. @cindex JSON
  3778. produce a list of channel specifications in JSON format;
  3779. @item recutils
  3780. produce a list of channel specifications in Recutils format.
  3781. @end table
  3782. @item --list-formats
  3783. Display available formats for @option{--format} option.
  3784. @item --profile=@var{profile}
  3785. @itemx -p @var{profile}
  3786. Display information about @var{profile}.
  3787. @end table
  3788. @node Invoking guix archive
  3789. @section Invoking @command{guix archive}
  3790. @cindex @command{guix archive}
  3791. @cindex archive
  3792. The @command{guix archive} command allows users to @dfn{export} files
  3793. from the store into a single archive, and to later @dfn{import} them on
  3794. a machine that runs Guix.
  3795. In particular, it allows store files to be transferred from one machine
  3796. to the store on another machine.
  3797. @quotation Note
  3798. If you're looking for a way to produce archives in a format suitable for
  3799. tools other than Guix, @pxref{Invoking guix pack}.
  3800. @end quotation
  3801. @cindex exporting store items
  3802. To export store files as an archive to standard output, run:
  3803. @example
  3804. guix archive --export @var{options} @var{specifications}...
  3805. @end example
  3806. @var{specifications} may be either store file names or package
  3807. specifications, as for @command{guix package} (@pxref{Invoking guix
  3808. package}). For instance, the following command creates an archive
  3809. containing the @code{gui} output of the @code{git} package and the main
  3810. output of @code{emacs}:
  3811. @example
  3812. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3813. @end example
  3814. If the specified packages are not built yet, @command{guix archive}
  3815. automatically builds them. The build process may be controlled with the
  3816. common build options (@pxref{Common Build Options}).
  3817. To transfer the @code{emacs} package to a machine connected over SSH,
  3818. one would run:
  3819. @example
  3820. guix archive --export -r emacs | ssh the-machine guix archive --import
  3821. @end example
  3822. @noindent
  3823. Similarly, a complete user profile may be transferred from one machine
  3824. to another like this:
  3825. @example
  3826. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3827. ssh the-machine guix archive --import
  3828. @end example
  3829. @noindent
  3830. However, note that, in both examples, all of @code{emacs} and the
  3831. profile as well as all of their dependencies are transferred (due to
  3832. @option{-r}), regardless of what is already available in the store on
  3833. the target machine. The @option{--missing} option can help figure out
  3834. which items are missing from the target store. The @command{guix copy}
  3835. command simplifies and optimizes this whole process, so this is probably
  3836. what you should use in this case (@pxref{Invoking guix copy}).
  3837. @cindex nar, archive format
  3838. @cindex normalized archive (nar)
  3839. @cindex nar bundle, archive format
  3840. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3841. format (described below), and the output of @command{guix archive
  3842. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3843. bundle}.
  3844. The nar format is
  3845. comparable in spirit to `tar', but with differences
  3846. that make it more appropriate for our purposes. First, rather than
  3847. recording all Unix metadata for each file, the nar format only mentions
  3848. the file type (regular, directory, or symbolic link); Unix permissions
  3849. and owner/group are dismissed. Second, the order in which directory
  3850. entries are stored always follows the order of file names according to
  3851. the C locale collation order. This makes archive production fully
  3852. deterministic.
  3853. That nar bundle format is essentially the concatenation of zero or more
  3854. nars along with metadata for each store item it contains: its file name,
  3855. references, corresponding derivation, and a digital signature.
  3856. When exporting, the daemon digitally signs the contents of the archive,
  3857. and that digital signature is appended. When importing, the daemon
  3858. verifies the signature and rejects the import in case of an invalid
  3859. signature or if the signing key is not authorized.
  3860. @c FIXME: Add xref to daemon doc about signatures.
  3861. The main options are:
  3862. @table @code
  3863. @item --export
  3864. Export the specified store files or packages (see below). Write the
  3865. resulting archive to the standard output.
  3866. Dependencies are @emph{not} included in the output, unless
  3867. @option{--recursive} is passed.
  3868. @item -r
  3869. @itemx --recursive
  3870. When combined with @option{--export}, this instructs @command{guix archive}
  3871. to include dependencies of the given items in the archive. Thus, the
  3872. resulting archive is self-contained: it contains the closure of the
  3873. exported store items.
  3874. @item --import
  3875. Read an archive from the standard input, and import the files listed
  3876. therein into the store. Abort if the archive has an invalid digital
  3877. signature, or if it is signed by a public key not among the authorized
  3878. keys (see @option{--authorize} below).
  3879. @item --missing
  3880. Read a list of store file names from the standard input, one per line,
  3881. and write on the standard output the subset of these files missing from
  3882. the store.
  3883. @item --generate-key[=@var{parameters}]
  3884. @cindex signing, archives
  3885. Generate a new key pair for the daemon. This is a prerequisite before
  3886. archives can be exported with @option{--export}. This
  3887. operation is usually instantaneous but it can take time if the system's
  3888. entropy pool needs to be refilled. On Guix System,
  3889. @code{guix-service-type} takes care of generating this key pair the
  3890. first boot.
  3891. The generated key pair is typically stored under @file{/etc/guix}, in
  3892. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  3893. key, which must be kept secret). When @var{parameters} is omitted,
  3894. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  3895. versions before 1.6.0, it is a 4096-bit RSA key.
  3896. Alternatively, @var{parameters} can specify
  3897. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  3898. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  3899. Libgcrypt Reference Manual}).
  3900. @item --authorize
  3901. @cindex authorizing, archives
  3902. Authorize imports signed by the public key passed on standard input.
  3903. The public key must be in ``s-expression advanced format''---i.e., the
  3904. same format as the @file{signing-key.pub} file.
  3905. The list of authorized keys is kept in the human-editable file
  3906. @file{/etc/guix/acl}. The file contains
  3907. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  3908. s-expressions''} and is structured as an access-control list in the
  3909. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  3910. (SPKI)}.
  3911. @item --extract=@var{directory}
  3912. @itemx -x @var{directory}
  3913. Read a single-item archive as served by substitute servers
  3914. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  3915. low-level operation needed in only very narrow use cases; see below.
  3916. For example, the following command extracts the substitute for Emacs
  3917. served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
  3918. @example
  3919. $ wget -O - \
  3920. https://@value{SUBSTITUTE-SERVER}/nar/gzip/@dots{}-emacs-24.5 \
  3921. | gunzip | guix archive -x /tmp/emacs
  3922. @end example
  3923. Single-item archives are different from multiple-item archives produced
  3924. by @command{guix archive --export}; they contain a single store item,
  3925. and they do @emph{not} embed a signature. Thus this operation does
  3926. @emph{no} signature verification and its output should be considered
  3927. unsafe.
  3928. The primary purpose of this operation is to facilitate inspection of
  3929. archive contents coming from possibly untrusted substitute servers
  3930. (@pxref{Invoking guix challenge}).
  3931. @item --list
  3932. @itemx -t
  3933. Read a single-item archive as served by substitute servers
  3934. (@pxref{Substitutes}) and print the list of files it contains, as in
  3935. this example:
  3936. @example
  3937. $ wget -O - \
  3938. https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-emacs-26.3 \
  3939. | lzip -d | guix archive -t
  3940. @end example
  3941. @end table
  3942. @c *********************************************************************
  3943. @node Channels
  3944. @chapter Channels
  3945. @cindex channels
  3946. @cindex @file{channels.scm}, configuration file
  3947. @cindex configuration file for channels
  3948. @cindex @command{guix pull}, configuration file
  3949. @cindex configuration of @command{guix pull}
  3950. Guix and its package collection are updated by running @command{guix pull}
  3951. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  3952. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  3953. customized by defining @dfn{channels} in the
  3954. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  3955. of a Git repository to be deployed, and @command{guix pull} can be instructed
  3956. to pull from one or more channels. In other words, channels can be used
  3957. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  3958. Guix is able to take into account security concerns and deal with authenticated
  3959. updates.
  3960. @menu
  3961. * Specifying Additional Channels:: Extending the package collection.
  3962. * Using a Custom Guix Channel:: Using a customized Guix.
  3963. * Replicating Guix:: Running the @emph{exact same} Guix.
  3964. * Channel Authentication:: How Guix verifies what it fetches.
  3965. * Creating a Channel:: How to write your custom channel.
  3966. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  3967. * Declaring Channel Dependencies:: How to depend on other channels.
  3968. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  3969. * Primary URL:: Distinguishing mirror to original.
  3970. * Writing Channel News:: Communicating information to channel's users.
  3971. @end menu
  3972. @node Specifying Additional Channels
  3973. @section Specifying Additional Channels
  3974. @cindex extending the package collection (channels)
  3975. @cindex variant packages (channels)
  3976. You can specify @emph{additional channels} to pull from. To use a channel, write
  3977. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  3978. @emph{in addition} to the default Guix channel(s):
  3979. @vindex %default-channels
  3980. @lisp
  3981. ;; Add variant packages to those Guix provides.
  3982. (cons (channel
  3983. (name 'variant-packages)
  3984. (url "https://example.org/variant-packages.git"))
  3985. %default-channels)
  3986. @end lisp
  3987. @noindent
  3988. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  3989. add a channel the list of channels that the variable @code{%default-channels}
  3990. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  3991. Manual}). With this file in place, @command{guix pull} builds not only Guix
  3992. but also the package modules from your own repository. The result in
  3993. @file{~/.config/guix/current} is the union of Guix with your own package
  3994. modules:
  3995. @example
  3996. $ guix pull --list-generations
  3997. @dots{}
  3998. Generation 19 Aug 27 2018 16:20:48
  3999. guix d894ab8
  4000. repository URL: https://git.savannah.gnu.org/git/guix.git
  4001. branch: master
  4002. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4003. variant-packages dd3df5e
  4004. repository URL: https://example.org/variant-packages.git
  4005. branch: master
  4006. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4007. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4008. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4009. @end example
  4010. @noindent
  4011. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4012. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4013. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4014. @code{variant-emacs-with-cool-features} might come from
  4015. @code{variant-packages}, while others come from the Guix default channel.
  4016. @node Using a Custom Guix Channel
  4017. @section Using a Custom Guix Channel
  4018. The channel called @code{guix} specifies where Guix itself---its command-line
  4019. tools as well as its package collection---should be downloaded. For instance,
  4020. suppose you want to update from another copy of the Guix repository at
  4021. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4022. write in @code{~/.config/guix/channels.scm} this specification:
  4023. @lisp
  4024. ;; Tell 'guix pull' to use another repo.
  4025. (list (channel
  4026. (name 'guix)
  4027. (url "https://example.org/another-guix.git")
  4028. (branch "super-hacks")))
  4029. @end lisp
  4030. @noindent
  4031. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4032. branch of the repository at @code{example.org}. The authentication concern is
  4033. addressed below ((@pxref{Channel Authentication}).
  4034. @node Replicating Guix
  4035. @section Replicating Guix
  4036. @cindex pinning, channels
  4037. @cindex replicating Guix
  4038. @cindex reproducibility, of Guix
  4039. The @command{guix pull --list-generations} output above shows precisely which
  4040. commits were used to build this instance of Guix. We can thus replicate it,
  4041. say, on another machine, by providing a channel specification in
  4042. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4043. @lisp
  4044. ;; Deploy specific commits of my channels of interest.
  4045. (list (channel
  4046. (name 'guix)
  4047. (url "https://git.savannah.gnu.org/git/guix.git")
  4048. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4049. (channel
  4050. (name 'variant-packages)
  4051. (url "https://example.org/variant-packages.git")
  4052. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4053. @end lisp
  4054. The @command{guix describe --format=channels} command can even generate this
  4055. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4056. file can be used with the -C options of @command{guix pull}
  4057. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4058. (@pxref{Invoking guix time-machine}).
  4059. At this point the two machines run the @emph{exact same Guix}, with access to
  4060. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4061. one machine will be exactly the same, bit for bit, as the output of the same
  4062. command on the other machine. It also means both machines have access to all
  4063. the source code of Guix and, transitively, to all the source code of every
  4064. package it defines.
  4065. This gives you super powers, allowing you to track the provenance of binary
  4066. artifacts with very fine grain, and to reproduce software environments at
  4067. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4068. @xref{Inferiors}, for another way to take advantage of these super powers.
  4069. @node Channel Authentication
  4070. @section Channel Authentication
  4071. @anchor{channel-authentication}
  4072. @cindex authentication, of channel code
  4073. The @command{guix pull} and @command{guix time-machine} commands
  4074. @dfn{authenticate} the code retrieved from channels: they make sure each
  4075. commit that is fetched is signed by an authorized developer. The goal
  4076. is to protect from unauthorized modifications to the channel that would
  4077. lead users to run malicious code.
  4078. As a user, you must provide a @dfn{channel introduction} in your
  4079. channels file so that Guix knows how to authenticate its first commit.
  4080. A channel specification, including its introduction, looks something
  4081. along these lines:
  4082. @lisp
  4083. (channel
  4084. (name 'some-channel)
  4085. (url "https://example.org/some-channel.git")
  4086. (introduction
  4087. (make-channel-introduction
  4088. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4089. (openpgp-fingerprint
  4090. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4091. @end lisp
  4092. The specification above shows the name and URL of the channel. The call
  4093. to @code{make-channel-introduction} above specifies that authentication
  4094. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4095. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4096. For the main channel, called @code{guix}, you automatically get that
  4097. information from your Guix installation. For other channels, include
  4098. the channel introduction provided by the channel authors in your
  4099. @file{channels.scm} file. Make sure you retrieve the channel
  4100. introduction from a trusted source since that is the root of your trust.
  4101. If you're curious about the authentication mechanics, read on!
  4102. @node Creating a Channel
  4103. @section Creating a Channel
  4104. @cindex personal packages (channels)
  4105. @cindex channels, for personal packages
  4106. Let's say you have a bunch of custom package variants or personal packages
  4107. that you think would make little sense to contribute to the Guix project, but
  4108. would like to have these packages transparently available to you at the
  4109. command line. You would first write modules containing those package
  4110. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4111. then you and anyone else can use it as an additional channel to get packages
  4112. from. Neat, no?
  4113. @c What follows stems from discussions at
  4114. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4115. @c earlier discussions on guix-devel@gnu.org.
  4116. @quotation Warning
  4117. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4118. publish your personal channel to the world, we would like to share a few words
  4119. of caution:
  4120. @itemize
  4121. @item
  4122. Before publishing a channel, please consider contributing your package
  4123. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4124. to free software of all sorts, and packages in Guix proper are readily
  4125. available to all Guix users and benefit from the project's quality assurance
  4126. process.
  4127. @item
  4128. When you maintain package definitions outside Guix, we, Guix developers,
  4129. consider that @emph{the compatibility burden is on you}. Remember that
  4130. package modules and package definitions are just Scheme code that uses various
  4131. programming interfaces (APIs). We want to remain free to change these APIs to
  4132. keep improving Guix, possibly in ways that break your channel. We never
  4133. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4134. either.
  4135. @item
  4136. Corollary: if you're using an external channel and that channel breaks, please
  4137. @emph{report the issue to the channel authors}, not to the Guix project.
  4138. @end itemize
  4139. You've been warned! Having said this, we believe external channels are a
  4140. practical way to exert your freedom to augment Guix' package collection and to
  4141. share your improvements, which are basic tenets of
  4142. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4143. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4144. @end quotation
  4145. To create a channel, create a Git repository containing your own package
  4146. modules and make it available. The repository can contain anything, but a
  4147. useful channel will contain Guile modules that export packages. Once you
  4148. start using a channel, Guix will behave as if the root directory of that
  4149. channel's Git repository has been added to the Guile load path (@pxref{Load
  4150. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4151. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4152. module, then the module will be available under the name @code{(my-packages
  4153. my-tools)}, and you will be able to use it like any other module
  4154. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4155. As a channel author, consider bundling authentication material with your
  4156. channel so that users can authenticate it. @xref{Channel
  4157. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4158. on how to do it.
  4159. @node Package Modules in a Sub-directory
  4160. @section Package Modules in a Sub-directory
  4161. @cindex subdirectory, channels
  4162. As a channel author, you may want to keep your channel modules in a
  4163. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4164. add a meta-data file @file{.guix-channel} that contains:
  4165. @lisp
  4166. (channel
  4167. (version 0)
  4168. (directory "guix"))
  4169. @end lisp
  4170. @node Declaring Channel Dependencies
  4171. @section Declaring Channel Dependencies
  4172. @cindex dependencies, channels
  4173. @cindex meta-data, channels
  4174. Channel authors may decide to augment a package collection provided by other
  4175. channels. They can declare their channel to be dependent on other channels in
  4176. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4177. the channel repository.
  4178. The meta-data file should contain a simple S-expression like this:
  4179. @lisp
  4180. (channel
  4181. (version 0)
  4182. (dependencies
  4183. (channel
  4184. (name 'some-collection)
  4185. (url "https://example.org/first-collection.git")
  4186. ;; The 'introduction' bit below is optional: you would
  4187. ;; provide it for dependencies that can be authenticated.
  4188. (introduction
  4189. (channel-introduction
  4190. (version 0)
  4191. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4192. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4193. (channel
  4194. (name 'some-other-collection)
  4195. (url "https://example.org/second-collection.git")
  4196. (branch "testing"))))
  4197. @end lisp
  4198. In the above example this channel is declared to depend on two other channels,
  4199. which will both be fetched automatically. The modules provided by the channel
  4200. will be compiled in an environment where the modules of all these declared
  4201. channels are available.
  4202. For the sake of reliability and maintainability, you should avoid dependencies
  4203. on channels that you don't control, and you should aim to keep the number of
  4204. dependencies to a minimum.
  4205. @node Specifying Channel Authorizations
  4206. @section Specifying Channel Authorizations
  4207. @cindex channel authorizations
  4208. @anchor{channel-authorizations}
  4209. As we saw above, Guix ensures the source code it pulls from channels
  4210. comes from authorized developers. As a channel author, you need to
  4211. specify the list of authorized developers in the
  4212. @file{.guix-authorizations} file in the channel's Git repository. The
  4213. authentication rule is simple: each commit must be signed by a key
  4214. listed in the @file{.guix-authorizations} file of its parent
  4215. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4216. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4217. have one parent and merge commits have two parent commits. Read
  4218. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4219. for Computer Scientists}} for a great overview.} The
  4220. @file{.guix-authorizations} file looks like this:
  4221. @lisp
  4222. ;; Example '.guix-authorizations' file.
  4223. (authorizations
  4224. (version 0) ;current file format version
  4225. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4226. (name "alice"))
  4227. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4228. (name "bob"))
  4229. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4230. (name "charlie"))))
  4231. @end lisp
  4232. Each fingerprint is followed by optional key/value pairs, as in the
  4233. example above. Currently these key/value pairs are ignored.
  4234. This authentication rule creates a chicken-and-egg issue: how do we
  4235. authenticate the first commit? Related to that: how do we deal with
  4236. channels whose repository history contains unsigned commits and lack
  4237. @file{.guix-authorizations}? And how do we fork existing channels?
  4238. @cindex channel introduction
  4239. Channel introductions answer these questions by describing the first
  4240. commit of a channel that should be authenticated. The first time a
  4241. channel is fetched with @command{guix pull} or @command{guix
  4242. time-machine}, the command looks up the introductory commit and verifies
  4243. that it is signed by the specified OpenPGP key. From then on, it
  4244. authenticates commits according to the rule above.
  4245. Additionally, your channel must provide all the OpenPGP keys that were
  4246. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4247. files, which can be either binary or ``ASCII-armored''. By default,
  4248. those @file{.key} files are searched for in the branch named
  4249. @code{keyring} but you can specify a different branch name in
  4250. @code{.guix-channel} like so:
  4251. @lisp
  4252. (channel
  4253. (version 0)
  4254. (keyring-reference "my-keyring-branch"))
  4255. @end lisp
  4256. To summarize, as the author of a channel, there are three things you have
  4257. to do to allow users to authenticate your code:
  4258. @enumerate
  4259. @item
  4260. Export the OpenPGP keys of past and present committers with @command{gpg
  4261. --export} and store them in @file{.key} files, by default in a branch
  4262. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4263. @item
  4264. Introduce an initial @file{.guix-authorizations} in the channel's
  4265. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4266. information on how to sign Git commits.)
  4267. @item
  4268. Advertise the channel introduction, for instance on your channel's web
  4269. page. The channel introduction, as we saw above, is the commit/key
  4270. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4271. the fingerprint of the OpenPGP used to sign it.
  4272. @end enumerate
  4273. Before pushing to your public Git repository, you can run @command{guix
  4274. git-authenticate} to verify that you did sign all the commits you are
  4275. about to push with an authorized key:
  4276. @example
  4277. guix git authenticate @var{commit} @var{signer}
  4278. @end example
  4279. @noindent
  4280. where @var{commit} and @var{signer} are your channel introduction.
  4281. @xref{Invoking guix git authenticate}, for details.
  4282. Publishing a signed channel requires discipline: any mistake, such as an
  4283. unsigned commit or a commit signed by an unauthorized key, will prevent
  4284. users from pulling from your channel---well, that's the whole point of
  4285. authentication! Pay attention to merges in particular: merge commits
  4286. are considered authentic if and only if they are signed by a key present
  4287. in the @file{.guix-authorizations} file of @emph{both} branches.
  4288. @node Primary URL
  4289. @section Primary URL
  4290. @cindex primary URL, channels
  4291. Channel authors can indicate the primary URL of their channel's Git
  4292. repository in the @file{.guix-channel} file, like so:
  4293. @lisp
  4294. (channel
  4295. (version 0)
  4296. (url "https://example.org/guix.git"))
  4297. @end lisp
  4298. This allows @command{guix pull} to determine whether it is pulling code
  4299. from a mirror of the channel; when that is the case, it warns the user
  4300. that the mirror might be stale and displays the primary URL@. That way,
  4301. users cannot be tricked into fetching code from a stale mirror that does
  4302. not receive security updates.
  4303. This feature only makes sense for authenticated repositories, such as
  4304. the official @code{guix} channel, for which @command{guix pull} ensures
  4305. the code it fetches is authentic.
  4306. @node Writing Channel News
  4307. @section Writing Channel News
  4308. @cindex news, for channels
  4309. Channel authors may occasionally want to communicate to their users
  4310. information about important changes in the channel. You'd send them all
  4311. an email, but that's not convenient.
  4312. Instead, channels can provide a @dfn{news file}; when the channel users
  4313. run @command{guix pull}, that news file is automatically read and
  4314. @command{guix pull --news} can display the announcements that correspond
  4315. to the new commits that have been pulled, if any.
  4316. To do that, channel authors must first declare the name of the news file
  4317. in their @file{.guix-channel} file:
  4318. @lisp
  4319. (channel
  4320. (version 0)
  4321. (news-file "etc/news.txt"))
  4322. @end lisp
  4323. The news file itself, @file{etc/news.txt} in this example, must look
  4324. something like this:
  4325. @lisp
  4326. (channel-news
  4327. (version 0)
  4328. (entry (tag "the-bug-fix")
  4329. (title (en "Fixed terrible bug")
  4330. (fr "Oh la la"))
  4331. (body (en "@@emph@{Good news@}! It's fixed!")
  4332. (eo "Certe ĝi pli bone funkcias nun!")))
  4333. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4334. (title (en "Added a great package")
  4335. (ca "Què vol dir guix?"))
  4336. (body (en "Don't miss the @@code@{hello@} package!"))))
  4337. @end lisp
  4338. While the news file is using the Scheme syntax, avoid naming it with a
  4339. @file{.scm} extension or else it will get picked up when building the
  4340. channel and yield an error since it is not a valid module.
  4341. Alternatively, you can move the channel module to a subdirectory and
  4342. store the news file in another directory.
  4343. The file consists of a list of @dfn{news entries}. Each entry is
  4344. associated with a commit or tag: it describes changes made in this
  4345. commit, possibly in preceding commits as well. Users see entries only
  4346. the first time they obtain the commit the entry refers to.
  4347. The @code{title} field should be a one-line summary while @code{body}
  4348. can be arbitrarily long, and both can contain Texinfo markup
  4349. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4350. a list of language tag/message tuples, which allows @command{guix pull}
  4351. to display news in the language that corresponds to the user's locale.
  4352. If you want to translate news using a gettext-based workflow, you can
  4353. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4354. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4355. you write news entries in English first, the command below creates a PO
  4356. file containing the strings to translate:
  4357. @example
  4358. xgettext -o news.po -l scheme -ken etc/news.txt
  4359. @end example
  4360. To sum up, yes, you could use your channel as a blog. But beware, this
  4361. is @emph{not quite} what your users might expect.
  4362. @c *********************************************************************
  4363. @node Development
  4364. @chapter Development
  4365. @cindex software development
  4366. If you are a software developer, Guix provides tools that you should find
  4367. helpful---independently of the language you're developing in. This is what
  4368. this chapter is about.
  4369. The @command{guix environment} command provides a convenient way to set up
  4370. @dfn{development environments} containing all the dependencies and tools
  4371. necessary to work on the software package of your choice. The @command{guix
  4372. pack} command allows you to create @dfn{application bundles} that can be
  4373. easily distributed to users who do not run Guix.
  4374. @menu
  4375. * Invoking guix environment:: Setting up development environments.
  4376. * Invoking guix pack:: Creating software bundles.
  4377. * The GCC toolchain:: Working with languages supported by GCC.
  4378. * Invoking guix git authenticate:: Authenticating Git repositories.
  4379. @end menu
  4380. @node Invoking guix environment
  4381. @section Invoking @command{guix environment}
  4382. @cindex reproducible build environments
  4383. @cindex development environments
  4384. @cindex @command{guix environment}
  4385. @cindex environment, package build environment
  4386. The purpose of @command{guix environment} is to assist hackers in
  4387. creating reproducible development environments without polluting their
  4388. package profile. The @command{guix environment} tool takes one or more
  4389. packages, builds all of their inputs, and creates a shell
  4390. environment to use them.
  4391. The general syntax is:
  4392. @example
  4393. guix environment @var{options} @var{package}@dots{}
  4394. @end example
  4395. The following example spawns a new shell set up for the development of
  4396. GNU@tie{}Guile:
  4397. @example
  4398. guix environment guile
  4399. @end example
  4400. If the needed dependencies are not built yet, @command{guix environment}
  4401. automatically builds them. The environment of the new shell is an
  4402. augmented version of the environment that @command{guix environment} was
  4403. run in. It contains the necessary search paths for building the given
  4404. package added to the existing environment variables. To create
  4405. a ``pure'' environment, in which the original environment variables have
  4406. been unset, use the @option{--pure} option@footnote{Users sometimes
  4407. wrongfully augment environment variables such as @env{PATH} in their
  4408. @file{~/.bashrc} file. As a consequence, when @command{guix
  4409. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4410. introducing ``impurities'' in these environment variables. It is an
  4411. error to define such environment variables in @file{.bashrc}; instead,
  4412. they should be defined in @file{.bash_profile}, which is sourced only by
  4413. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4414. Manual}, for details on Bash start-up files.}.
  4415. @vindex GUIX_ENVIRONMENT
  4416. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4417. variable in the shell it spawns; its value is the file name of the
  4418. profile of this environment. This allows users to, say, define a
  4419. specific prompt for development environments in their @file{.bashrc}
  4420. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4421. @example
  4422. if [ -n "$GUIX_ENVIRONMENT" ]
  4423. then
  4424. export PS1="\u@@\h \w [dev]\$ "
  4425. fi
  4426. @end example
  4427. @noindent
  4428. ...@: or to browse the profile:
  4429. @example
  4430. $ ls "$GUIX_ENVIRONMENT/bin"
  4431. @end example
  4432. Additionally, more than one package may be specified, in which case the
  4433. union of the inputs for the given packages are used. For example, the
  4434. command below spawns a shell where all of the dependencies of both Guile
  4435. and Emacs are available:
  4436. @example
  4437. guix environment guile emacs
  4438. @end example
  4439. Sometimes an interactive shell session is not desired. An arbitrary
  4440. command may be invoked by placing the @code{--} token to separate the
  4441. command from the rest of the arguments:
  4442. @example
  4443. guix environment guile -- make -j4
  4444. @end example
  4445. In other situations, it is more convenient to specify the list of
  4446. packages needed in the environment. For example, the following command
  4447. runs @command{python} from an environment containing Python@tie{}2.7 and
  4448. NumPy:
  4449. @example
  4450. guix environment --ad-hoc python2-numpy python-2.7 -- python
  4451. @end example
  4452. Furthermore, one might want the dependencies of a package and also some
  4453. additional packages that are not build-time or runtime dependencies, but
  4454. are useful when developing nonetheless. Because of this, the
  4455. @option{--ad-hoc} flag is positional. Packages appearing before
  4456. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4457. added to the environment. Packages appearing after are interpreted as
  4458. packages that will be added to the environment directly. For example,
  4459. the following command creates a Guix development environment that
  4460. additionally includes Git and strace:
  4461. @example
  4462. guix environment --pure guix --ad-hoc git strace
  4463. @end example
  4464. @cindex container
  4465. Sometimes it is desirable to isolate the environment as much as
  4466. possible, for maximal purity and reproducibility. In particular, when
  4467. using Guix on a host distro that is not Guix System, it is desirable to
  4468. prevent access to @file{/usr/bin} and other system-wide resources from
  4469. the development environment. For example, the following command spawns
  4470. a Guile REPL in a ``container'' where only the store and the current
  4471. working directory are mounted:
  4472. @example
  4473. guix environment --ad-hoc --container guile -- guile
  4474. @end example
  4475. @quotation Note
  4476. The @option{--container} option requires Linux-libre 3.19 or newer.
  4477. @end quotation
  4478. @cindex certificates
  4479. Another typical use case for containers is to run security-sensitive
  4480. applications such as a web browser. To run Eolie, we must expose and
  4481. share some files and directories; we include @code{nss-certs} and expose
  4482. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4483. @env{DISPLAY} environment variable since containerized graphical
  4484. applications won't display without it.
  4485. @example
  4486. guix environment --preserve='^DISPLAY$' --container --network \
  4487. --expose=/etc/machine-id \
  4488. --expose=/etc/ssl/certs/ \
  4489. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4490. --ad-hoc eolie nss-certs dbus -- eolie
  4491. @end example
  4492. The available options are summarized below.
  4493. @table @code
  4494. @item --root=@var{file}
  4495. @itemx -r @var{file}
  4496. @cindex persistent environment
  4497. @cindex garbage collector root, for environments
  4498. Make @var{file} a symlink to the profile for this environment, and
  4499. register it as a garbage collector root.
  4500. This is useful if you want to protect your environment from garbage
  4501. collection, to make it ``persistent''.
  4502. When this option is omitted, the environment is protected from garbage
  4503. collection only for the duration of the @command{guix environment}
  4504. session. This means that next time you recreate the same environment,
  4505. you could have to rebuild or re-download packages. @xref{Invoking guix
  4506. gc}, for more on GC roots.
  4507. @item --expression=@var{expr}
  4508. @itemx -e @var{expr}
  4509. Create an environment for the package or list of packages that
  4510. @var{expr} evaluates to.
  4511. For example, running:
  4512. @example
  4513. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4514. @end example
  4515. starts a shell with the environment for this specific variant of the
  4516. PETSc package.
  4517. Running:
  4518. @example
  4519. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4520. @end example
  4521. starts a shell with all the base system packages available.
  4522. The above commands only use the default output of the given packages.
  4523. To select other outputs, two element tuples can be specified:
  4524. @example
  4525. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4526. @end example
  4527. @item --load=@var{file}
  4528. @itemx -l @var{file}
  4529. Create an environment for the package or list of packages that the code
  4530. within @var{file} evaluates to.
  4531. As an example, @var{file} might contain a definition like this
  4532. (@pxref{Defining Packages}):
  4533. @lisp
  4534. @verbatiminclude environment-gdb.scm
  4535. @end lisp
  4536. @item --manifest=@var{file}
  4537. @itemx -m @var{file}
  4538. Create an environment for the packages contained in the manifest object
  4539. returned by the Scheme code in @var{file}. This option can be repeated
  4540. several times, in which case the manifests are concatenated.
  4541. This is similar to the same-named option in @command{guix package}
  4542. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4543. manifest files.
  4544. @item --ad-hoc
  4545. Include all specified packages in the resulting environment, as if an
  4546. @i{ad hoc} package were defined with them as inputs. This option is
  4547. useful for quickly creating an environment without having to write a
  4548. package expression to contain the desired inputs.
  4549. For instance, the command:
  4550. @example
  4551. guix environment --ad-hoc guile guile-sdl -- guile
  4552. @end example
  4553. runs @command{guile} in an environment where Guile and Guile-SDL are
  4554. available.
  4555. Note that this example implicitly asks for the default output of
  4556. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  4557. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  4558. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  4559. This option may be composed with the default behavior of @command{guix
  4560. environment}. Packages appearing before @option{--ad-hoc} are
  4561. interpreted as packages whose dependencies will be added to the
  4562. environment, the default behavior. Packages appearing after are
  4563. interpreted as packages that will be added to the environment directly.
  4564. @item --pure
  4565. Unset existing environment variables when building the new environment, except
  4566. those specified with @option{--preserve} (see below). This has the effect of
  4567. creating an environment in which search paths only contain package inputs.
  4568. @item --preserve=@var{regexp}
  4569. @itemx -E @var{regexp}
  4570. When used alongside @option{--pure}, preserve the environment variables
  4571. matching @var{regexp}---in other words, put them on a ``white list'' of
  4572. environment variables that must be preserved. This option can be repeated
  4573. several times.
  4574. @example
  4575. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  4576. -- mpirun @dots{}
  4577. @end example
  4578. This example runs @command{mpirun} in a context where the only environment
  4579. variables defined are @env{PATH}, environment variables whose name starts
  4580. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4581. @env{USER}, etc.).
  4582. @item --search-paths
  4583. Display the environment variable definitions that make up the
  4584. environment.
  4585. @item --system=@var{system}
  4586. @itemx -s @var{system}
  4587. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4588. @item --container
  4589. @itemx -C
  4590. @cindex container
  4591. Run @var{command} within an isolated container. The current working
  4592. directory outside the container is mapped inside the container.
  4593. Additionally, unless overridden with @option{--user}, a dummy home
  4594. directory is created that matches the current user's home directory, and
  4595. @file{/etc/passwd} is configured accordingly.
  4596. The spawned process runs as the current user outside the container. Inside
  4597. the container, it has the same UID and GID as the current user, unless
  4598. @option{--user} is passed (see below).
  4599. @item --network
  4600. @itemx -N
  4601. For containers, share the network namespace with the host system.
  4602. Containers created without this flag only have access to the loopback
  4603. device.
  4604. @item --link-profile
  4605. @itemx -P
  4606. For containers, link the environment profile to @file{~/.guix-profile}
  4607. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4608. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4609. actual profile within the container.
  4610. Linking will fail and abort the environment if the directory already
  4611. exists, which will certainly be the case if @command{guix environment}
  4612. was invoked in the user's home directory.
  4613. Certain packages are configured to look in @file{~/.guix-profile} for
  4614. configuration files and data;@footnote{For example, the
  4615. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4616. for additional fonts.} @option{--link-profile} allows these programs to
  4617. behave as expected within the environment.
  4618. @item --user=@var{user}
  4619. @itemx -u @var{user}
  4620. For containers, use the username @var{user} in place of the current
  4621. user. The generated @file{/etc/passwd} entry within the container will
  4622. contain the name @var{user}, the home directory will be
  4623. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4624. the UID and GID inside the container are 1000. @var{user}
  4625. need not exist on the system.
  4626. Additionally, any shared or exposed path (see @option{--share} and
  4627. @option{--expose} respectively) whose target is within the current user's
  4628. home directory will be remapped relative to @file{/home/USER}; this
  4629. includes the automatic mapping of the current working directory.
  4630. @example
  4631. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4632. cd $HOME/wd
  4633. guix environment --container --user=foo \
  4634. --expose=$HOME/test \
  4635. --expose=/tmp/target=$HOME/target
  4636. @end example
  4637. While this will limit the leaking of user identity through home paths
  4638. and each of the user fields, this is only one useful component of a
  4639. broader privacy/anonymity solution---not one in and of itself.
  4640. @item --no-cwd
  4641. For containers, the default behavior is to share the current working
  4642. directory with the isolated container and immediately change to that
  4643. directory within the container. If this is undesirable,
  4644. @option{--no-cwd} will cause the current working directory to @emph{not}
  4645. be automatically shared and will change to the user's home directory
  4646. within the container instead. See also @option{--user}.
  4647. @item --expose=@var{source}[=@var{target}]
  4648. @itemx --share=@var{source}[=@var{target}]
  4649. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4650. file system @var{source} from the host system as the read-only
  4651. (resp. writable) file system @var{target} within the container. If
  4652. @var{target} is not specified, @var{source} is used as the target mount
  4653. point in the container.
  4654. The example below spawns a Guile REPL in a container in which the user's
  4655. home directory is accessible read-only via the @file{/exchange}
  4656. directory:
  4657. @example
  4658. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  4659. @end example
  4660. @end table
  4661. @command{guix environment}
  4662. also supports all of the common build options that @command{guix
  4663. build} supports (@pxref{Common Build Options}) as well as package
  4664. transformation options (@pxref{Package Transformation Options}).
  4665. @node Invoking guix pack
  4666. @section Invoking @command{guix pack}
  4667. Occasionally you want to pass software to people who are not (yet!)
  4668. lucky enough to be using Guix. You'd tell them to run @command{guix
  4669. package -i @var{something}}, but that's not possible in this case. This
  4670. is where @command{guix pack} comes in.
  4671. @quotation Note
  4672. If you are looking for ways to exchange binaries among machines that
  4673. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  4674. publish}, and @ref{Invoking guix archive}.
  4675. @end quotation
  4676. @cindex pack
  4677. @cindex bundle
  4678. @cindex application bundle
  4679. @cindex software bundle
  4680. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  4681. @dfn{software bundle}: it creates a tarball or some other archive
  4682. containing the binaries of the software you're interested in, and all
  4683. its dependencies. The resulting archive can be used on any machine that
  4684. does not have Guix, and people can run the exact same binaries as those
  4685. you have with Guix. The pack itself is created in a bit-reproducible
  4686. fashion, so anyone can verify that it really contains the build results
  4687. that you pretend to be shipping.
  4688. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  4689. their dependencies, you can run:
  4690. @example
  4691. $ guix pack guile emacs geiser
  4692. @dots{}
  4693. /gnu/store/@dots{}-pack.tar.gz
  4694. @end example
  4695. The result here is a tarball containing a @file{/gnu/store} directory
  4696. with all the relevant packages. The resulting tarball contains a
  4697. @dfn{profile} with the three packages of interest; the profile is the
  4698. same as would be created by @command{guix package -i}. It is this
  4699. mechanism that is used to create Guix's own standalone binary tarball
  4700. (@pxref{Binary Installation}).
  4701. Users of this pack would have to run
  4702. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  4703. find inconvenient. To work around it, you can create, say, a
  4704. @file{/opt/gnu/bin} symlink to the profile:
  4705. @example
  4706. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  4707. @end example
  4708. @noindent
  4709. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  4710. @cindex relocatable binaries, with @command{guix pack}
  4711. What if the recipient of your pack does not have root privileges on
  4712. their machine, and thus cannot unpack it in the root file system? In
  4713. that case, you will want to use the @option{--relocatable} option (see
  4714. below). This option produces @dfn{relocatable binaries}, meaning they
  4715. they can be placed anywhere in the file system hierarchy: in the example
  4716. above, users can unpack your tarball in their home directory and
  4717. directly run @file{./opt/gnu/bin/guile}.
  4718. @cindex Docker, build an image with guix pack
  4719. Alternatively, you can produce a pack in the Docker image format using
  4720. the following command:
  4721. @example
  4722. guix pack -f docker -S /bin=bin guile guile-readline
  4723. @end example
  4724. @noindent
  4725. The result is a tarball that can be passed to the @command{docker load}
  4726. command, followed by @code{docker run}:
  4727. @example
  4728. docker load < @var{file}
  4729. docker run -ti guile-guile-readline /bin/guile
  4730. @end example
  4731. @noindent
  4732. where @var{file} is the image returned by @var{guix pack}, and
  4733. @code{guile-guile-readline} is its ``image tag''. See the
  4734. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  4735. documentation} for more information.
  4736. @cindex Singularity, build an image with guix pack
  4737. @cindex SquashFS, build an image with guix pack
  4738. Yet another option is to produce a SquashFS image with the following
  4739. command:
  4740. @example
  4741. guix pack -f squashfs bash guile emacs geiser
  4742. @end example
  4743. @noindent
  4744. The result is a SquashFS file system image that can either be mounted or
  4745. directly be used as a file system container image with the
  4746. @uref{https://www.sylabs.io/docs/, Singularity container execution
  4747. environment}, using commands like @command{singularity shell} or
  4748. @command{singularity exec}.
  4749. Several command-line options allow you to customize your pack:
  4750. @table @code
  4751. @item --format=@var{format}
  4752. @itemx -f @var{format}
  4753. Produce a pack in the given @var{format}.
  4754. The available formats are:
  4755. @table @code
  4756. @item tarball
  4757. This is the default format. It produces a tarball containing all the
  4758. specified binaries and symlinks.
  4759. @item docker
  4760. This produces a tarball that follows the
  4761. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  4762. Docker Image Specification}. The ``repository name'' as it appears in
  4763. the output of the @command{docker images} command is computed from
  4764. package names passed on the command line or in the manifest file.
  4765. @item squashfs
  4766. This produces a SquashFS image containing all the specified binaries and
  4767. symlinks, as well as empty mount points for virtual file systems like
  4768. procfs.
  4769. @quotation Note
  4770. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  4771. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  4772. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  4773. with something like:
  4774. @example
  4775. guix pack -f squashfs bash @dots{}
  4776. @end example
  4777. If you forget the @code{bash} (or similar) package, @command{singularity
  4778. run} and @command{singularity exec} will fail with an unhelpful ``no
  4779. such file or directory'' message.
  4780. @end quotation
  4781. @end table
  4782. @cindex relocatable binaries
  4783. @item --relocatable
  4784. @itemx -R
  4785. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  4786. anywhere in the file system hierarchy and run from there.
  4787. When this option is passed once, the resulting binaries require support for
  4788. @dfn{user namespaces} in the kernel Linux; when passed
  4789. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  4790. PRoot support, can be thought of as the abbreviation of ``Really
  4791. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  4792. other techniques if user namespaces are unavailable, and essentially
  4793. work anywhere---see below for the implications.
  4794. For example, if you create a pack containing Bash with:
  4795. @example
  4796. guix pack -RR -S /mybin=bin bash
  4797. @end example
  4798. @noindent
  4799. ...@: you can copy that pack to a machine that lacks Guix, and from your
  4800. home directory as a normal user, run:
  4801. @example
  4802. tar xf pack.tar.gz
  4803. ./mybin/sh
  4804. @end example
  4805. @noindent
  4806. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  4807. @file{/gnu/store} shows up and contains all the dependencies of
  4808. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  4809. altogether! That is probably the simplest way to deploy Guix-built
  4810. software on a non-Guix machine.
  4811. @quotation Note
  4812. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  4813. the kernel Linux, which allows unprivileged users to mount or change root.
  4814. Old versions of Linux did not support it, and some GNU/Linux distributions
  4815. turn it off.
  4816. To produce relocatable binaries that work even in the absence of user
  4817. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  4818. case, binaries will try user namespace support and fall back to another
  4819. @dfn{execution engine} if user namespaces are not supported. The
  4820. following execution engines are supported:
  4821. @table @code
  4822. @item default
  4823. Try user namespaces and fall back to PRoot if user namespaces are not
  4824. supported (see below).
  4825. @item performance
  4826. Try user namespaces and fall back to Fakechroot if user namespaces are
  4827. not supported (see below).
  4828. @item userns
  4829. Run the program through user namespaces and abort if they are not
  4830. supported.
  4831. @item proot
  4832. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  4833. provides the necessary
  4834. support for file system virtualization. It achieves that by using the
  4835. @code{ptrace} system call on the running program. This approach has the
  4836. advantage to work without requiring special kernel support, but it incurs
  4837. run-time overhead every time a system call is made.
  4838. @item fakechroot
  4839. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  4840. Fakechroot} virtualizes file system accesses by intercepting calls to C
  4841. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  4842. on. Unlike PRoot, it incurs very little overhead. However, it does not
  4843. always work: for example, some file system accesses made from within the
  4844. C library are not intercepted, and file system accesses made @i{via}
  4845. direct syscalls are not intercepted either, leading to erratic behavior.
  4846. @end table
  4847. @vindex GUIX_EXECUTION_ENGINE
  4848. When running a wrapped program, you can explicitly request one of the
  4849. execution engines listed above by setting the
  4850. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  4851. @end quotation
  4852. @cindex entry point, for Docker images
  4853. @item --entry-point=@var{command}
  4854. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  4855. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  4856. support it. @var{command} must be relative to the profile contained in the
  4857. pack.
  4858. The entry point specifies the command that tools like @code{docker run} or
  4859. @code{singularity run} automatically start by default. For example, you can
  4860. do:
  4861. @example
  4862. guix pack -f docker --entry-point=bin/guile guile
  4863. @end example
  4864. The resulting pack can easily be loaded and @code{docker run} with no extra
  4865. arguments will spawn @code{bin/guile}:
  4866. @example
  4867. docker load -i pack.tar.gz
  4868. docker run @var{image-id}
  4869. @end example
  4870. @item --expression=@var{expr}
  4871. @itemx -e @var{expr}
  4872. Consider the package @var{expr} evaluates to.
  4873. This has the same purpose as the same-named option in @command{guix
  4874. build} (@pxref{Additional Build Options, @option{--expression} in
  4875. @command{guix build}}).
  4876. @item --manifest=@var{file}
  4877. @itemx -m @var{file}
  4878. Use the packages contained in the manifest object returned by the Scheme
  4879. code in @var{file}. This option can be repeated several times, in which
  4880. case the manifests are concatenated.
  4881. This has a similar purpose as the same-named option in @command{guix
  4882. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  4883. same manifest files. It allows you to define a collection of packages
  4884. once and use it both for creating profiles and for creating archives
  4885. for use on machines that do not have Guix installed. Note that you can
  4886. specify @emph{either} a manifest file @emph{or} a list of packages,
  4887. but not both.
  4888. @item --system=@var{system}
  4889. @itemx -s @var{system}
  4890. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  4891. the system type of the build host.
  4892. @item --target=@var{triplet}
  4893. @cindex cross-compilation
  4894. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  4895. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  4896. configuration triplets,, autoconf, Autoconf}).
  4897. @item --compression=@var{tool}
  4898. @itemx -C @var{tool}
  4899. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  4900. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  4901. compression.
  4902. @item --symlink=@var{spec}
  4903. @itemx -S @var{spec}
  4904. Add the symlinks specified by @var{spec} to the pack. This option can
  4905. appear several times.
  4906. @var{spec} has the form @code{@var{source}=@var{target}}, where
  4907. @var{source} is the symlink that will be created and @var{target} is the
  4908. symlink target.
  4909. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  4910. symlink pointing to the @file{bin} sub-directory of the profile.
  4911. @item --save-provenance
  4912. Save provenance information for the packages passed on the command line.
  4913. Provenance information includes the URL and commit of the channels in use
  4914. (@pxref{Channels}).
  4915. Provenance information is saved in the
  4916. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  4917. usual package metadata---the name and version of each package, their
  4918. propagated inputs, and so on. It is useful information to the recipient of
  4919. the pack, who then knows how the pack was (supposedly) obtained.
  4920. This option is not enabled by default because, like timestamps, provenance
  4921. information contributes nothing to the build process. In other words, there
  4922. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  4923. Recording such ``silent'' metadata in the output thus potentially breaks the
  4924. source-to-binary bitwise reproducibility property.
  4925. @item --root=@var{file}
  4926. @itemx -r @var{file}
  4927. @cindex garbage collector root, for packs
  4928. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  4929. collector root.
  4930. @item --localstatedir
  4931. @itemx --profile-name=@var{name}
  4932. Include the ``local state directory'', @file{/var/guix}, in the resulting
  4933. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  4934. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  4935. @file{~root/.guix-profile}.
  4936. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  4937. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  4938. the pack means that the store is ``complete'' and manageable by Guix;
  4939. not providing it pack means that the store is ``dead'': items cannot be
  4940. added to it or removed from it after extraction of the pack.
  4941. One use case for this is the Guix self-contained binary tarball
  4942. (@pxref{Binary Installation}).
  4943. @item --derivation
  4944. @itemx -d
  4945. Print the name of the derivation that builds the pack.
  4946. @item --bootstrap
  4947. Use the bootstrap binaries to build the pack. This option is only
  4948. useful to Guix developers.
  4949. @end table
  4950. In addition, @command{guix pack} supports all the common build options
  4951. (@pxref{Common Build Options}) and all the package transformation
  4952. options (@pxref{Package Transformation Options}).
  4953. @node The GCC toolchain
  4954. @section The GCC toolchain
  4955. @cindex GCC
  4956. @cindex ld-wrapper
  4957. @cindex linker wrapper
  4958. @cindex toolchain, for C development
  4959. @cindex toolchain, for Fortran development
  4960. If you need a complete toolchain for compiling and linking C or C++
  4961. source code, use the @code{gcc-toolchain} package. This package
  4962. provides a complete GCC toolchain for C/C++ development, including GCC
  4963. itself, the GNU C Library (headers and binaries, plus debugging symbols
  4964. in the @code{debug} output), Binutils, and a linker wrapper.
  4965. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  4966. passed to the linker, add corresponding @code{-rpath} arguments, and
  4967. invoke the actual linker with this new set of arguments. You can instruct the
  4968. wrapper to refuse to link against libraries not in the store by setting the
  4969. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  4970. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  4971. for Fortran development. For other languages, please use
  4972. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  4973. @node Invoking guix git authenticate
  4974. @section Invoking @command{guix git authenticate}
  4975. The @command{guix git authenticate} command authenticates a Git checkout
  4976. following the same rule as for channels (@pxref{channel-authentication,
  4977. channel authentication}). That is, starting from a given commit, it
  4978. ensures that all subsequent commits are signed by an OpenPGP key whose
  4979. fingerprint appears in the @file{.guix-authorizations} file of its
  4980. parent commit(s).
  4981. You will find this command useful if you maintain a channel. But in
  4982. fact, this authentication mechanism is useful in a broader context, so
  4983. you might want to use it for Git repositories that have nothing to do
  4984. with Guix.
  4985. The general syntax is:
  4986. @example
  4987. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  4988. @end example
  4989. By default, this command authenticates the Git checkout in the current
  4990. directory; it outputs nothing and exits with exit code zero on success
  4991. and non-zero on failure. @var{commit} above denotes the first commit
  4992. where authentication takes place, and @var{signer} is the OpenPGP
  4993. fingerprint of public key used to sign @var{commit}. Together, they
  4994. form a ``channel introduction'' (@pxref{channel-authentication, channel
  4995. introduction}). The options below allow you to fine-tune the process.
  4996. @table @code
  4997. @item --repository=@var{directory}
  4998. @itemx -r @var{directory}
  4999. Open the Git repository in @var{directory} instead of the current
  5000. directory.
  5001. @item --keyring=@var{reference}
  5002. @itemx -k @var{reference}
  5003. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5004. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5005. contain OpenPGP public keys in @file{.key} files, either in binary form
  5006. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5007. named @code{keyring}.
  5008. @item --stats
  5009. Display commit signing statistics upon completion.
  5010. @item --cache-key=@var{key}
  5011. Previously-authenticated commits are cached in a file under
  5012. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5013. stored in file @var{key} in that directory.
  5014. @item --historical-authorizations=@var{file}
  5015. By default, any commit whose parent commit(s) lack the
  5016. @file{.guix-authorizations} file is considered inauthentic. In
  5017. contrast, this option considers the authorizations in @var{file} for any
  5018. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5019. is the same as that of @file{.guix-authorizations}
  5020. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5021. @end table
  5022. @c *********************************************************************
  5023. @node Programming Interface
  5024. @chapter Programming Interface
  5025. GNU Guix provides several Scheme programming interfaces (APIs) to
  5026. define, build, and query packages. The first interface allows users to
  5027. write high-level package definitions. These definitions refer to
  5028. familiar packaging concepts, such as the name and version of a package,
  5029. its build system, and its dependencies. These definitions can then be
  5030. turned into concrete build actions.
  5031. Build actions are performed by the Guix daemon, on behalf of users. In a
  5032. standard setup, the daemon has write access to the store---the
  5033. @file{/gnu/store} directory---whereas users do not. The recommended
  5034. setup also has the daemon perform builds in chroots, under specific
  5035. build users, to minimize interference with the rest of the system.
  5036. @cindex derivation
  5037. Lower-level APIs are available to interact with the daemon and the
  5038. store. To instruct the daemon to perform a build action, users actually
  5039. provide it with a @dfn{derivation}. A derivation is a low-level
  5040. representation of the build actions to be taken, and the environment in
  5041. which they should occur---derivations are to package definitions what
  5042. assembly is to C programs. The term ``derivation'' comes from the fact
  5043. that build results @emph{derive} from them.
  5044. This chapter describes all these APIs in turn, starting from high-level
  5045. package definitions.
  5046. @menu
  5047. * Package Modules:: Packages from the programmer's viewpoint.
  5048. * Defining Packages:: Defining new packages.
  5049. * Defining Package Variants:: Customizing packages.
  5050. * Build Systems:: Specifying how packages are built.
  5051. * Build Phases:: Phases of the build process of a package.
  5052. * Build Utilities:: Helpers for your package definitions and more.
  5053. * The Store:: Manipulating the package store.
  5054. * Derivations:: Low-level interface to package derivations.
  5055. * The Store Monad:: Purely functional interface to the store.
  5056. * G-Expressions:: Manipulating build expressions.
  5057. * Invoking guix repl:: Programming Guix in Guile
  5058. @end menu
  5059. @node Package Modules
  5060. @section Package Modules
  5061. From a programming viewpoint, the package definitions of the
  5062. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5063. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5064. packages @dots{})} module name space are not necessarily ``GNU
  5065. packages''. This module naming scheme follows the usual Guile module
  5066. naming convention: @code{gnu} means that these modules are distributed
  5067. as part of the GNU system, and @code{packages} identifies modules that
  5068. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5069. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5070. module exports a variable named @code{emacs}, which is bound to a
  5071. @code{<package>} object (@pxref{Defining Packages}).
  5072. The @code{(gnu packages @dots{})} module name space is
  5073. automatically scanned for packages by the command-line tools. For
  5074. instance, when running @code{guix install emacs}, all the @code{(gnu
  5075. packages @dots{})} modules are scanned until one that exports a package
  5076. object whose name is @code{emacs} is found. This package search
  5077. facility is implemented in the @code{(gnu packages)} module.
  5078. @cindex customization, of packages
  5079. @cindex package module search path
  5080. Users can store package definitions in modules with different
  5081. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5082. name and module name must match. For instance, the @code{(my-packages
  5083. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5084. relative to the load path specified with @option{--load-path} or
  5085. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5086. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5087. these package definitions visible to the user interfaces:
  5088. @enumerate
  5089. @item
  5090. By adding the directory containing your package modules to the search path
  5091. with the @code{-L} flag of @command{guix package} and other commands
  5092. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5093. environment variable described below.
  5094. @item
  5095. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5096. pulls from it. A channel is essentially a Git repository containing package
  5097. modules. @xref{Channels}, for more information on how to define and use
  5098. channels.
  5099. @end enumerate
  5100. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5101. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5102. This is a colon-separated list of directories to search for additional
  5103. package modules. Directories listed in this variable take precedence
  5104. over the own modules of the distribution.
  5105. @end defvr
  5106. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5107. each package is built based solely on other packages in the
  5108. distribution. The root of this dependency graph is a small set of
  5109. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5110. bootstrap)} module. For more information on bootstrapping,
  5111. @pxref{Bootstrapping}.
  5112. @node Defining Packages
  5113. @section Defining Packages
  5114. The high-level interface to package definitions is implemented in the
  5115. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5116. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5117. package looks like this:
  5118. @lisp
  5119. (define-module (gnu packages hello)
  5120. #:use-module (guix packages)
  5121. #:use-module (guix download)
  5122. #:use-module (guix build-system gnu)
  5123. #:use-module (guix licenses)
  5124. #:use-module (gnu packages gawk))
  5125. (define-public hello
  5126. (package
  5127. (name "hello")
  5128. (version "2.10")
  5129. (source (origin
  5130. (method url-fetch)
  5131. (uri (string-append "mirror://gnu/hello/hello-" version
  5132. ".tar.gz"))
  5133. (sha256
  5134. (base32
  5135. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5136. (build-system gnu-build-system)
  5137. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5138. (inputs `(("gawk" ,gawk)))
  5139. (synopsis "Hello, GNU world: An example GNU package")
  5140. (description "Guess what GNU Hello prints!")
  5141. (home-page "https://www.gnu.org/software/hello/")
  5142. (license gpl3+)))
  5143. @end lisp
  5144. @noindent
  5145. Without being a Scheme expert, the reader may have guessed the meaning
  5146. of the various fields here. This expression binds the variable
  5147. @code{hello} to a @code{<package>} object, which is essentially a record
  5148. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5149. This package object can be inspected using procedures found in the
  5150. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5151. returns---surprise!---@code{"hello"}.
  5152. With luck, you may be able to import part or all of the definition of
  5153. the package you are interested in from another repository, using the
  5154. @code{guix import} command (@pxref{Invoking guix import}).
  5155. In the example above, @code{hello} is defined in a module of its own,
  5156. @code{(gnu packages hello)}. Technically, this is not strictly
  5157. necessary, but it is convenient to do so: all the packages defined in
  5158. modules under @code{(gnu packages @dots{})} are automatically known to
  5159. the command-line tools (@pxref{Package Modules}).
  5160. There are a few points worth noting in the above package definition:
  5161. @itemize
  5162. @item
  5163. The @code{source} field of the package is an @code{<origin>} object
  5164. (@pxref{origin Reference}, for the complete reference).
  5165. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5166. meaning that the source is a file to be downloaded over FTP or HTTP.
  5167. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5168. the GNU mirrors defined in @code{(guix download)}.
  5169. The @code{sha256} field specifies the expected SHA256 hash of the file
  5170. being downloaded. It is mandatory, and allows Guix to check the
  5171. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5172. base32 representation of the hash. You can obtain this information with
  5173. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5174. hash} (@pxref{Invoking guix hash}).
  5175. @cindex patches
  5176. When needed, the @code{origin} form can also have a @code{patches} field
  5177. listing patches to be applied, and a @code{snippet} field giving a
  5178. Scheme expression to modify the source code.
  5179. @item
  5180. @cindex GNU Build System
  5181. The @code{build-system} field specifies the procedure to build the
  5182. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5183. represents the familiar GNU Build System, where packages may be
  5184. configured, built, and installed with the usual @code{./configure &&
  5185. make && make check && make install} command sequence.
  5186. When you start packaging non-trivial software, you may need tools to
  5187. manipulate those build phases, manipulate files, and so on. @xref{Build
  5188. Utilities}, for more on this.
  5189. @item
  5190. The @code{arguments} field specifies options for the build system
  5191. (@pxref{Build Systems}). Here it is interpreted by
  5192. @code{gnu-build-system} as a request run @file{configure} with the
  5193. @option{--enable-silent-rules} flag.
  5194. @cindex quote
  5195. @cindex quoting
  5196. @findex '
  5197. @findex quote
  5198. What about these quote (@code{'}) characters? They are Scheme syntax to
  5199. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5200. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5201. for details. Here the value of the @code{arguments} field is a list of
  5202. arguments passed to the build system down the road, as with @code{apply}
  5203. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5204. Manual}).
  5205. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5206. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5207. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5208. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5209. Reference Manual}).
  5210. @item
  5211. The @code{inputs} field specifies inputs to the build process---i.e.,
  5212. build-time or run-time dependencies of the package. Here, we define an
  5213. input called @code{"gawk"} whose value is that of the @code{gawk}
  5214. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5215. @cindex backquote (quasiquote)
  5216. @findex `
  5217. @findex quasiquote
  5218. @cindex comma (unquote)
  5219. @findex ,
  5220. @findex unquote
  5221. @findex ,@@
  5222. @findex unquote-splicing
  5223. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  5224. us to introduce a literal list in the @code{inputs} field, while
  5225. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  5226. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  5227. Reference Manual}).
  5228. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5229. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5230. of ensuring that they are present (@pxref{Build Systems}).
  5231. However, any other dependencies need to be specified in the
  5232. @code{inputs} field. Any dependency not specified here will simply be
  5233. unavailable to the build process, possibly leading to a build failure.
  5234. @end itemize
  5235. @xref{package Reference}, for a full description of possible fields.
  5236. Once a package definition is in place, the
  5237. package may actually be built using the @code{guix build} command-line
  5238. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5239. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5240. package definition using the @command{guix edit} command
  5241. (@pxref{Invoking guix edit}).
  5242. @xref{Packaging Guidelines}, for
  5243. more information on how to test package definitions, and
  5244. @ref{Invoking guix lint}, for information on how to check a definition
  5245. for style conformance.
  5246. @vindex GUIX_PACKAGE_PATH
  5247. Lastly, @pxref{Channels}, for information
  5248. on how to extend the distribution by adding your own package definitions
  5249. in a ``channel''.
  5250. Finally, updating the package definition to a new upstream version
  5251. can be partly automated by the @command{guix refresh} command
  5252. (@pxref{Invoking guix refresh}).
  5253. Behind the scenes, a derivation corresponding to the @code{<package>}
  5254. object is first computed by the @code{package-derivation} procedure.
  5255. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5256. The build actions it prescribes may then be realized by using the
  5257. @code{build-derivations} procedure (@pxref{The Store}).
  5258. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5259. Return the @code{<derivation>} object of @var{package} for @var{system}
  5260. (@pxref{Derivations}).
  5261. @var{package} must be a valid @code{<package>} object, and @var{system}
  5262. must be a string denoting the target system type---e.g.,
  5263. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5264. must be a connection to the daemon, which operates on the store
  5265. (@pxref{The Store}).
  5266. @end deffn
  5267. @noindent
  5268. @cindex cross-compilation
  5269. Similarly, it is possible to compute a derivation that cross-builds a
  5270. package for some other system:
  5271. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5272. @var{package} @var{target} [@var{system}]
  5273. Return the @code{<derivation>} object of @var{package} cross-built from
  5274. @var{system} to @var{target}.
  5275. @var{target} must be a valid GNU triplet denoting the target hardware
  5276. and operating system, such as @code{"aarch64-linux-gnu"}
  5277. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5278. @end deffn
  5279. Once you have package definitions, you can easily define @emph{variants}
  5280. of those packages. @xref{Defining Package Variants}, for more on that.
  5281. @menu
  5282. * package Reference:: The package data type.
  5283. * origin Reference:: The origin data type.
  5284. @end menu
  5285. @node package Reference
  5286. @subsection @code{package} Reference
  5287. This section summarizes all the options available in @code{package}
  5288. declarations (@pxref{Defining Packages}).
  5289. @deftp {Data Type} package
  5290. This is the data type representing a package recipe.
  5291. @table @asis
  5292. @item @code{name}
  5293. The name of the package, as a string.
  5294. @item @code{version}
  5295. The version of the package, as a string.
  5296. @item @code{source}
  5297. An object telling how the source code for the package should be
  5298. acquired. Most of the time, this is an @code{origin} object, which
  5299. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5300. can also be any other ``file-like'' object such as a @code{local-file},
  5301. which denotes a file from the local file system (@pxref{G-Expressions,
  5302. @code{local-file}}).
  5303. @item @code{build-system}
  5304. The build system that should be used to build the package (@pxref{Build
  5305. Systems}).
  5306. @item @code{arguments} (default: @code{'()})
  5307. The arguments that should be passed to the build system. This is a
  5308. list, typically containing sequential keyword-value pairs.
  5309. @item @code{inputs} (default: @code{'()})
  5310. @itemx @code{native-inputs} (default: @code{'()})
  5311. @itemx @code{propagated-inputs} (default: @code{'()})
  5312. @cindex inputs, of packages
  5313. These fields list dependencies of the package. Each one is a list of
  5314. tuples, where each tuple has a label for the input (a string) as its
  5315. first element, a package, origin, or derivation as its second element,
  5316. and optionally the name of the output thereof that should be used, which
  5317. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  5318. more on package outputs). For example, the list below specifies three
  5319. inputs:
  5320. @lisp
  5321. `(("libffi" ,libffi)
  5322. ("libunistring" ,libunistring)
  5323. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  5324. @end lisp
  5325. @cindex cross compilation, package dependencies
  5326. The distinction between @code{native-inputs} and @code{inputs} is
  5327. necessary when considering cross-compilation. When cross-compiling,
  5328. dependencies listed in @code{inputs} are built for the @emph{target}
  5329. architecture; conversely, dependencies listed in @code{native-inputs}
  5330. are built for the architecture of the @emph{build} machine.
  5331. @code{native-inputs} is typically used to list tools needed at
  5332. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5333. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5334. this area (@pxref{Invoking guix lint}).
  5335. @anchor{package-propagated-inputs}
  5336. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5337. specified packages will be automatically installed to profiles
  5338. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5339. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5340. package}}, for information on how @command{guix package} deals with
  5341. propagated inputs).
  5342. For example this is necessary when packaging a C/C++ library that needs
  5343. headers of another library to compile, or when a pkg-config file refers
  5344. to another one @i{via} its @code{Requires} field.
  5345. Another example where @code{propagated-inputs} is useful is for languages
  5346. that lack a facility to record the run-time search path akin to the
  5347. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5348. more. When packaging libraries written in those languages, ensure they
  5349. can find library code they depend on at run time by listing run-time
  5350. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5351. @item @code{outputs} (default: @code{'("out")})
  5352. The list of output names of the package. @xref{Packages with Multiple
  5353. Outputs}, for typical uses of additional outputs.
  5354. @item @code{native-search-paths} (default: @code{'()})
  5355. @itemx @code{search-paths} (default: @code{'()})
  5356. A list of @code{search-path-specification} objects describing
  5357. search-path environment variables honored by the package.
  5358. @item @code{replacement} (default: @code{#f})
  5359. This must be either @code{#f} or a package object that will be used as a
  5360. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5361. for details.
  5362. @item @code{synopsis}
  5363. A one-line description of the package.
  5364. @item @code{description}
  5365. A more elaborate description of the package.
  5366. @item @code{license}
  5367. @cindex license, of packages
  5368. The license of the package; a value from @code{(guix licenses)},
  5369. or a list of such values.
  5370. @item @code{home-page}
  5371. The URL to the home-page of the package, as a string.
  5372. @item @code{supported-systems} (default: @code{%supported-systems})
  5373. The list of systems supported by the package, as strings of the form
  5374. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5375. @item @code{location} (default: source location of the @code{package} form)
  5376. The source location of the package. It is useful to override this when
  5377. inheriting from another package, in which case this field is not
  5378. automatically corrected.
  5379. @end table
  5380. @end deftp
  5381. @deffn {Scheme Syntax} this-package
  5382. When used in the @emph{lexical scope} of a package field definition, this
  5383. identifier resolves to the package being defined.
  5384. The example below shows how to add a package as a native input of itself when
  5385. cross-compiling:
  5386. @lisp
  5387. (package
  5388. (name "guile")
  5389. ;; ...
  5390. ;; When cross-compiled, Guile, for example, depends on
  5391. ;; a native version of itself. Add it here.
  5392. (native-inputs (if (%current-target-system)
  5393. `(("self" ,this-package))
  5394. '())))
  5395. @end lisp
  5396. It is an error to refer to @code{this-package} outside a package definition.
  5397. @end deffn
  5398. Because packages are regular Scheme objects that capture a complete
  5399. dependency graph and associated build procedures, it is often useful to
  5400. write procedures that take a package and return a modified version
  5401. thereof according to some parameters. Below are a few examples.
  5402. @cindex tool chain, choosing a package's tool chain
  5403. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  5404. Return a variant of @var{package} that uses @var{toolchain} instead of
  5405. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  5406. inputs (label/package tuples) providing equivalent functionality, such
  5407. as the @code{gcc-toolchain} package.
  5408. The example below returns a variant of the @code{hello} package built
  5409. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  5410. GNU C Library) instead of the default tool chain:
  5411. @lisp
  5412. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  5413. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  5414. @end lisp
  5415. The build tool chain is part of the @dfn{implicit inputs} of
  5416. packages---it's usually not listed as part of the various ``inputs''
  5417. fields and is instead pulled in by the build system. Consequently, this
  5418. procedure works by changing the build system of @var{package} so that it
  5419. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  5420. for more on build systems.
  5421. @end deffn
  5422. @node origin Reference
  5423. @subsection @code{origin} Reference
  5424. This section documents @dfn{origins}. An @code{origin} declaration
  5425. specifies data that must be ``produced''---downloaded, usually---and
  5426. whose content hash is known in advance. Origins are primarily used to
  5427. represent the source code of packages (@pxref{Defining Packages}). For
  5428. that reason, the @code{origin} form allows you to declare patches to
  5429. apply to the original source code as well as code snippets to modify it.
  5430. @deftp {Data Type} origin
  5431. This is the data type representing a source code origin.
  5432. @table @asis
  5433. @item @code{uri}
  5434. An object containing the URI of the source. The object type depends on
  5435. the @code{method} (see below). For example, when using the
  5436. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5437. values are: a URL represented as a string, or a list thereof.
  5438. @cindex fixed-output derivations, for download
  5439. @item @code{method}
  5440. A monadic procedure that handles the given URI@. The procedure must
  5441. accept at least three arguments: the value of the @code{uri} field and
  5442. the hash algorithm and hash value specified by the @code{hash} field.
  5443. It must return a store item or a derivation in the store monad
  5444. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  5445. (@pxref{Derivations}).
  5446. Commonly used methods include @code{url-fetch}, which fetches data from
  5447. a URL, and @code{git-fetch}, which fetches data from a Git repository
  5448. (see below).
  5449. @item @code{sha256}
  5450. A bytevector containing the SHA-256 hash of the source. This is
  5451. equivalent to providing a @code{content-hash} SHA256 object in the
  5452. @code{hash} field described below.
  5453. @item @code{hash}
  5454. The @code{content-hash} object of the source---see below for how to use
  5455. @code{content-hash}.
  5456. You can obtain this information using @code{guix download}
  5457. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5458. guix hash}).
  5459. @item @code{file-name} (default: @code{#f})
  5460. The file name under which the source code should be saved. When this is
  5461. @code{#f}, a sensible default value will be used in most cases. In case
  5462. the source is fetched from a URL, the file name from the URL will be
  5463. used. For version control checkouts, it is recommended to provide the
  5464. file name explicitly because the default is not very descriptive.
  5465. @item @code{patches} (default: @code{'()})
  5466. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  5467. file-like objects}) pointing to patches to be applied to the source.
  5468. This list of patches must be unconditional. In particular, it cannot
  5469. depend on the value of @code{%current-system} or
  5470. @code{%current-target-system}.
  5471. @item @code{snippet} (default: @code{#f})
  5472. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  5473. in the source directory. This is a convenient way to modify the source,
  5474. sometimes more convenient than a patch.
  5475. @item @code{patch-flags} (default: @code{'("-p1")})
  5476. A list of command-line flags that should be passed to the @code{patch}
  5477. command.
  5478. @item @code{patch-inputs} (default: @code{#f})
  5479. Input packages or derivations to the patching process. When this is
  5480. @code{#f}, the usual set of inputs necessary for patching are provided,
  5481. such as GNU@tie{}Patch.
  5482. @item @code{modules} (default: @code{'()})
  5483. A list of Guile modules that should be loaded during the patching
  5484. process and while running the code in the @code{snippet} field.
  5485. @item @code{patch-guile} (default: @code{#f})
  5486. The Guile package that should be used in the patching process. When
  5487. this is @code{#f}, a sensible default is used.
  5488. @end table
  5489. @end deftp
  5490. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  5491. Construct a content hash object for the given @var{algorithm}, and with
  5492. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  5493. it is @code{sha256}.
  5494. @var{value} can be a literal string, in which case it is base32-decoded,
  5495. or it can be a bytevector.
  5496. The following forms are all equivalent:
  5497. @lisp
  5498. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  5499. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  5500. sha256)
  5501. (content-hash (base32
  5502. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  5503. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  5504. sha256)
  5505. @end lisp
  5506. Technically, @code{content-hash} is currently implemented as a macro.
  5507. It performs sanity checks at macro-expansion time, when possible, such
  5508. as ensuring that @var{value} has the right size for @var{algorithm}.
  5509. @end deftp
  5510. As we have seen above, how exactly the data an origin refers to is
  5511. retrieved is determined by its @code{method} field. The @code{(guix
  5512. download)} module provides the most common method, @code{url-fetch},
  5513. described below.
  5514. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  5515. [name] [#:executable? #f]
  5516. Return a fixed-output derivation that fetches data from @var{url} (a
  5517. string, or a list of strings denoting alternate URLs), which is expected
  5518. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  5519. the file name is the base name of URL; optionally, @var{name} can
  5520. specify a different file name. When @var{executable?} is true, make the
  5521. downloaded file executable.
  5522. When one of the URL starts with @code{mirror://}, then its host part is
  5523. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  5524. Alternatively, when URL starts with @code{file://}, return the
  5525. corresponding file name in the store.
  5526. @end deffn
  5527. Likewise, the @code{(guix git-download)} module defines the
  5528. @code{git-fetch} origin method, which fetches data from a Git version
  5529. control repository, and the @code{git-reference} data type to describe
  5530. the repository and revision to fetch.
  5531. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  5532. Return a fixed-output derivation that fetches @var{ref}, a
  5533. @code{<git-reference>} object. The output is expected to have recursive
  5534. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5535. the file name, or a generic name if @code{#f}.
  5536. @end deffn
  5537. @deftp {Data Type} git-reference
  5538. This data type represents a Git reference for @code{git-fetch} to
  5539. retrieve.
  5540. @table @asis
  5541. @item @code{url}
  5542. The URL of the Git repository to clone.
  5543. @item @code{commit}
  5544. This string denotes either the commit to fetch (a hexadecimal string,
  5545. either the full SHA1 commit or a ``short'' commit string; the latter is
  5546. not recommended) or the tag to fetch.
  5547. @item @code{recursive?} (default: @code{#f})
  5548. This Boolean indicates whether to recursively fetch Git sub-modules.
  5549. @end table
  5550. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  5551. repository:
  5552. @lisp
  5553. (git-reference
  5554. (url "https://git.savannah.gnu.org/git/hello.git")
  5555. (commit "v2.10"))
  5556. @end lisp
  5557. This is equivalent to the reference below, which explicitly names the
  5558. commit:
  5559. @lisp
  5560. (git-reference
  5561. (url "https://git.savannah.gnu.org/git/hello.git")
  5562. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  5563. @end lisp
  5564. @end deftp
  5565. For Mercurial repositories, the module @code{(guix hg-download)} defines
  5566. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  5567. support of the Mercurial version control system.
  5568. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  5569. [name]
  5570. Return a fixed-output derivation that fetches @var{ref}, a
  5571. @code{<hg-reference>} object. The output is expected to have recursive
  5572. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5573. the file name, or a generic name if @code{#false}.
  5574. @end deffn
  5575. @node Defining Package Variants
  5576. @section Defining Package Variants
  5577. @cindex customizing packages
  5578. @cindex variants, of packages
  5579. One of the nice things with Guix is that, given a package definition,
  5580. you can easily @emph{derive} variants of that package---for a different
  5581. upstream version, with different dependencies, different compilation
  5582. options, and so on. Some of these custom packages can be defined
  5583. straight from the command line (@pxref{Package Transformation Options}).
  5584. This section describes how to define package variants in code. This can
  5585. be useful in ``manifests'' (@pxref{profile-manifest,
  5586. @option{--manifest}}) and in your own package collection
  5587. (@pxref{Creating a Channel}), among others!
  5588. @cindex inherit, for package definitions
  5589. As discussed earlier, packages are first-class objects in the Scheme
  5590. language. The @code{(guix packages)} module provides the @code{package}
  5591. construct to define new package objects (@pxref{package Reference}).
  5592. The easiest way to define a package variant is using the @code{inherit}
  5593. keyword together with @code{package}. This allows you to inherit from a
  5594. package definition while overriding the fields you want.
  5595. For example, given the @code{hello} variable, which contains a
  5596. definition for the current version of GNU@tie{}Hello, here's how you
  5597. would define a variant for version 2.2 (released in 2006, it's
  5598. vintage!):
  5599. @lisp
  5600. (use-modules (gnu packages base)) ;for 'hello'
  5601. (define hello-2.2
  5602. (package
  5603. (inherit hello)
  5604. (version "2.2")
  5605. (source (origin
  5606. (method url-fetch)
  5607. (uri (string-append "mirror://gnu/hello/hello-" version
  5608. ".tar.gz"))
  5609. (sha256
  5610. (base32
  5611. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  5612. @end lisp
  5613. The example above corresponds to what the @option{--with-source} package
  5614. transformation option does. Essentially @code{hello-2.2} preserves all
  5615. the fields of @code{hello}, except @code{version} and @code{source},
  5616. which it overrides. Note that the original @code{hello} variable is
  5617. still there, in the @code{(gnu packages base)} module, unchanged. When
  5618. you define a custom package like this, you are really @emph{adding} a
  5619. new package definition; the original one remains available.
  5620. You can just as well define variants with a different set of
  5621. dependencies than the original package. For example, the default
  5622. @code{gdb} package depends on @code{guile}, but since that is an
  5623. optional dependency, you can define a variant that removes that
  5624. dependency like so:
  5625. @lisp
  5626. (use-modules (gnu packages gdb) ;for 'gdb'
  5627. (srfi srfi-1)) ;for 'alist-delete'
  5628. (define gdb-sans-guile
  5629. (package
  5630. (inherit gdb)
  5631. (inputs (alist-delete "guile"
  5632. (package-inputs gdb)))))
  5633. @end lisp
  5634. The @code{alist-delete} call above removes the tuple from the
  5635. @code{inputs} field that has @code{"guile"} as its first element
  5636. (@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference
  5637. Manual}).
  5638. In some cases, you may find it useful to write functions
  5639. (``procedures'', in Scheme parlance) that return a package based on some
  5640. parameters. For example, consider the @code{luasocket} library for the
  5641. Lua programming language. We want to create @code{luasocket} packages
  5642. for major versions of Lua. One way to do that is to define a procedure
  5643. that takes a Lua package and returns a @code{luasocket} package that
  5644. depends on it:
  5645. @lisp
  5646. (define (make-lua-socket name lua)
  5647. ;; Return a luasocket package built with LUA.
  5648. (package
  5649. (name name)
  5650. (version "3.0")
  5651. ;; several fields omitted
  5652. (inputs
  5653. `(("lua" ,lua)))
  5654. (synopsis "Socket library for Lua")))
  5655. (define-public lua5.1-socket
  5656. (make-lua-socket "lua5.1-socket" lua-5.1))
  5657. (define-public lua5.2-socket
  5658. (make-lua-socket "lua5.2-socket" lua-5.2))
  5659. @end lisp
  5660. Here we have defined packages @code{lua5.1-socket} and
  5661. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  5662. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  5663. more info on procedures. Having top-level public definitions for these
  5664. two packages means that they can be referred to from the command line
  5665. (@pxref{Package Modules}).
  5666. @cindex package transformations
  5667. These are pretty simple package variants. As a convenience, the
  5668. @code{(guix transformations)} module provides a high-level interface
  5669. that directly maps to the more sophisticated package transformation
  5670. options (@pxref{Package Transformation Options}):
  5671. @deffn {Scheme Procedure} options->transformation @var{opts}
  5672. Return a procedure that, when passed an object to build (package,
  5673. derivation, etc.), applies the transformations specified by @var{opts} and returns
  5674. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  5675. @lisp
  5676. ((with-branch . "guile-gcrypt=master")
  5677. (without-tests . "libgcrypt"))
  5678. @end lisp
  5679. Each symbol names a transformation and the corresponding string is an argument
  5680. to that transformation.
  5681. @end deffn
  5682. For instance, a manifest equivalent to this command:
  5683. @example
  5684. guix build guix \
  5685. --with-branch=guile-gcrypt=master \
  5686. --with-debug-info=zlib
  5687. @end example
  5688. @noindent
  5689. ... would look like this:
  5690. @lisp
  5691. (use-modules (guix transformations))
  5692. (define transform
  5693. ;; The package transformation procedure.
  5694. (options->transformation
  5695. '((with-branch . "guile-gcrypt=master")
  5696. (with-debug-info . "zlib"))))
  5697. (packages->manifest
  5698. (list (transform (specification->package "guix"))))
  5699. @end lisp
  5700. @cindex input rewriting
  5701. @cindex dependency graph rewriting
  5702. The @code{options->transformation} procedure is convenient, but it's
  5703. perhaps also not as flexible as you may like. How is it implemented?
  5704. The astute reader probably noticed that most package transformation
  5705. options go beyond the superficial changes shown in the first examples of
  5706. this section: they involve @dfn{input rewriting}, whereby the dependency
  5707. graph of a package is rewritten by replacing specific inputs by others.
  5708. Dependency graph rewriting, for the purposes of swapping packages in the
  5709. graph, is what the @code{package-input-rewriting} procedure in
  5710. @code{(guix packages)} implements.
  5711. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  5712. [@var{rewrite-name}] [#:deep? #t]
  5713. Return a procedure that, when passed a package, replaces its direct and
  5714. indirect dependencies, including implicit inputs when @var{deep?} is
  5715. true, according to @var{replacements}. @var{replacements} is a list of
  5716. package pairs; the first element of each pair is the package to replace,
  5717. and the second one is the replacement.
  5718. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  5719. the name of a package and returns its new name after rewrite.
  5720. @end deffn
  5721. @noindent
  5722. Consider this example:
  5723. @lisp
  5724. (define libressl-instead-of-openssl
  5725. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  5726. ;; recursively.
  5727. (package-input-rewriting `((,openssl . ,libressl))))
  5728. (define git-with-libressl
  5729. (libressl-instead-of-openssl git))
  5730. @end lisp
  5731. @noindent
  5732. Here we first define a rewriting procedure that replaces @var{openssl}
  5733. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  5734. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  5735. This is exactly what the @option{--with-input} command-line option does
  5736. (@pxref{Package Transformation Options, @option{--with-input}}).
  5737. The following variant of @code{package-input-rewriting} can match packages to
  5738. be replaced by name rather than by identity.
  5739. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  5740. Return a procedure that, given a package, applies the given
  5741. @var{replacements} to all the package graph, including implicit inputs
  5742. unless @var{deep?} is false. @var{replacements} is a list of
  5743. spec/procedures pair; each spec is a package specification such as
  5744. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  5745. package and returns a replacement for that package.
  5746. @end deffn
  5747. The example above could be rewritten this way:
  5748. @lisp
  5749. (define libressl-instead-of-openssl
  5750. ;; Replace all the packages called "openssl" with LibreSSL.
  5751. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  5752. @end lisp
  5753. The key difference here is that, this time, packages are matched by spec and
  5754. not by identity. In other words, any package in the graph that is called
  5755. @code{openssl} will be replaced.
  5756. A more generic procedure to rewrite a package dependency graph is
  5757. @code{package-mapping}: it supports arbitrary changes to nodes in the
  5758. graph.
  5759. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  5760. Return a procedure that, given a package, applies @var{proc} to all the packages
  5761. depended on and returns the resulting package. The procedure stops recursion
  5762. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  5763. applied to implicit inputs as well.
  5764. @end deffn
  5765. @node Build Systems
  5766. @section Build Systems
  5767. @cindex build system
  5768. Each package definition specifies a @dfn{build system} and arguments for
  5769. that build system (@pxref{Defining Packages}). This @code{build-system}
  5770. field represents the build procedure of the package, as well as implicit
  5771. dependencies of that build procedure.
  5772. Build systems are @code{<build-system>} objects. The interface to
  5773. create and manipulate them is provided by the @code{(guix build-system)}
  5774. module, and actual build systems are exported by specific modules.
  5775. @cindex bag (low-level package representation)
  5776. Under the hood, build systems first compile package objects to
  5777. @dfn{bags}. A @dfn{bag} is like a package, but with less
  5778. ornamentation---in other words, a bag is a lower-level representation of
  5779. a package, which includes all the inputs of that package, including some
  5780. that were implicitly added by the build system. This intermediate
  5781. representation is then compiled to a derivation (@pxref{Derivations}).
  5782. The @code{package-with-c-toolchain} is an example of a way to change the
  5783. implicit inputs that a package's build system pulls in (@pxref{package
  5784. Reference, @code{package-with-c-toolchain}}).
  5785. Build systems accept an optional list of @dfn{arguments}. In package
  5786. definitions, these are passed @i{via} the @code{arguments} field
  5787. (@pxref{Defining Packages}). They are typically keyword arguments
  5788. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  5789. Guile Reference Manual}). The value of these arguments is usually
  5790. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  5791. by the daemon (@pxref{Derivations}).
  5792. The main build system is @code{gnu-build-system}, which implements the
  5793. standard build procedure for GNU and many other packages. It
  5794. is provided by the @code{(guix build-system gnu)} module.
  5795. @defvr {Scheme Variable} gnu-build-system
  5796. @code{gnu-build-system} represents the GNU Build System, and variants
  5797. thereof (@pxref{Configuration, configuration and makefile conventions,,
  5798. standards, GNU Coding Standards}).
  5799. @cindex build phases
  5800. In a nutshell, packages using it are configured, built, and installed with
  5801. the usual @code{./configure && make && make check && make install}
  5802. command sequence. In practice, a few additional steps are often needed.
  5803. All these steps are split up in separate @dfn{phases},
  5804. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  5805. modules for more details about the build phases.}:
  5806. @table @code
  5807. @item unpack
  5808. Unpack the source tarball, and change the current directory to the
  5809. extracted source tree. If the source is actually a directory, copy it
  5810. to the build tree, and enter that directory.
  5811. @item patch-source-shebangs
  5812. Patch shebangs encountered in source files so they refer to the right
  5813. store file names. For instance, this changes @code{#!/bin/sh} to
  5814. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  5815. @item configure
  5816. Run the @file{configure} script with a number of default options, such
  5817. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  5818. by the @code{#:configure-flags} argument.
  5819. @item build
  5820. Run @code{make} with the list of flags specified with
  5821. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  5822. (the default), build with @code{make -j}.
  5823. @item check
  5824. Run @code{make check}, or some other target specified with
  5825. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  5826. @code{#:parallel-tests?} argument is true (the default), run @code{make
  5827. check -j}.
  5828. @item install
  5829. Run @code{make install} with the flags listed in @code{#:make-flags}.
  5830. @item patch-shebangs
  5831. Patch shebangs on the installed executable files.
  5832. @item strip
  5833. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  5834. is false), copying them to the @code{debug} output when available
  5835. (@pxref{Installing Debugging Files}).
  5836. @end table
  5837. @vindex %standard-phases
  5838. The build-side module @code{(guix build gnu-build-system)} defines
  5839. @code{%standard-phases} as the default list of build phases.
  5840. @code{%standard-phases} is a list of symbol/procedure pairs, where the
  5841. procedure implements the actual phase.
  5842. @xref{Build Phases}, for more info on build phases and ways to customize
  5843. them.
  5844. In addition, this build system ensures that the ``standard'' environment
  5845. for GNU packages is available. This includes tools such as GCC, libc,
  5846. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  5847. build-system gnu)} module for a complete list). We call these the
  5848. @dfn{implicit inputs} of a package, because package definitions do not
  5849. have to mention them.
  5850. @end defvr
  5851. Other @code{<build-system>} objects are defined to support other
  5852. conventions and tools used by free software packages. They inherit most
  5853. of @code{gnu-build-system}, and differ mainly in the set of inputs
  5854. implicitly added to the build process, and in the list of phases
  5855. executed. Some of these build systems are listed below.
  5856. @defvr {Scheme Variable} ant-build-system
  5857. This variable is exported by @code{(guix build-system ant)}. It
  5858. implements the build procedure for Java packages that can be built with
  5859. @url{https://ant.apache.org/, Ant build tool}.
  5860. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  5861. provided by the @code{icedtea} package to the set of inputs. Different
  5862. packages can be specified with the @code{#:ant} and @code{#:jdk}
  5863. parameters, respectively.
  5864. When the original package does not provide a suitable Ant build file,
  5865. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  5866. build file @file{build.xml} with tasks to build the specified jar
  5867. archive. In this case the parameter @code{#:source-dir} can be used to
  5868. specify the source sub-directory, defaulting to ``src''.
  5869. The @code{#:main-class} parameter can be used with the minimal ant
  5870. buildfile to specify the main class of the resulting jar. This makes the
  5871. jar file executable. The @code{#:test-include} parameter can be used to
  5872. specify the list of junit tests to run. It defaults to
  5873. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  5874. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  5875. because abstract classes cannot be run as tests.
  5876. The parameter @code{#:build-target} can be used to specify the Ant task
  5877. that should be run during the @code{build} phase. By default the
  5878. ``jar'' task will be run.
  5879. @end defvr
  5880. @defvr {Scheme Variable} android-ndk-build-system
  5881. @cindex Android distribution
  5882. @cindex Android NDK build system
  5883. This variable is exported by @code{(guix build-system android-ndk)}. It
  5884. implements a build procedure for Android NDK (native development kit)
  5885. packages using a Guix-specific build process.
  5886. The build system assumes that packages install their public interface
  5887. (header) files to the subdirectory @file{include} of the @code{out} output and
  5888. their libraries to the subdirectory @file{lib} the @code{out} output.
  5889. It's also assumed that the union of all the dependencies of a package
  5890. has no conflicting files.
  5891. For the time being, cross-compilation is not supported - so right now
  5892. the libraries and header files are assumed to be host tools.
  5893. @end defvr
  5894. @defvr {Scheme Variable} asdf-build-system/source
  5895. @defvrx {Scheme Variable} asdf-build-system/sbcl
  5896. @defvrx {Scheme Variable} asdf-build-system/ecl
  5897. These variables, exported by @code{(guix build-system asdf)}, implement
  5898. build procedures for Common Lisp packages using
  5899. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  5900. definition facility for Common Lisp programs and libraries.
  5901. The @code{asdf-build-system/source} system installs the packages in
  5902. source form, and can be loaded using any common lisp implementation, via
  5903. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  5904. systems in the format which a particular implementation understands.
  5905. These build systems can also be used to produce executable programs, or
  5906. lisp images which contain a set of packages pre-loaded.
  5907. The build system uses naming conventions. For binary packages, the
  5908. package name should be prefixed with the lisp implementation, such as
  5909. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  5910. Additionally, the corresponding source package should be labeled using
  5911. the same convention as python packages (see @ref{Python Modules}), using
  5912. the @code{cl-} prefix.
  5913. In order to create executable programs and images, the build-side
  5914. procedures @code{build-program} and @code{build-image} can be used.
  5915. They should be called in a build phase after the
  5916. @code{create-asdf-configuration} phase, so that the system which was
  5917. just built can be used within the resulting image. @code{build-program}
  5918. requires a list of Common Lisp expressions to be passed as the
  5919. @code{#:entry-program} argument.
  5920. By default, all the @file{.asd} files present in the sources are read to
  5921. find system definitions. The @code{#:asd-files} parameter can be used
  5922. to specify the list of @file{.asd} files to read. Furthermore, if the
  5923. package defines a system for its tests in a separate file, it will be
  5924. loaded before the tests are run if it is specified by the
  5925. @code{#:test-asd-file} parameter. If it is not set, the files
  5926. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  5927. and @code{test.asd} will be tried if they exist.
  5928. If for some reason the package must be named in a different way than the
  5929. naming conventions suggest, or if several systems must be compiled, the
  5930. @code{#:asd-systems} parameter can be used to specify the list of system
  5931. names.
  5932. @end defvr
  5933. @defvr {Scheme Variable} cargo-build-system
  5934. @cindex Rust programming language
  5935. @cindex Cargo (Rust build system)
  5936. This variable is exported by @code{(guix build-system cargo)}. It
  5937. supports builds of packages using Cargo, the build tool of the
  5938. @uref{https://www.rust-lang.org, Rust programming language}.
  5939. It adds @code{rustc} and @code{cargo} to the set of inputs.
  5940. A different Rust package can be specified with the @code{#:rust} parameter.
  5941. Regular cargo dependencies should be added to the package definition via the
  5942. @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  5943. spec can be a package or a source definition. Note that the spec must
  5944. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  5945. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  5946. should be added to the package definition via the
  5947. @code{#:cargo-development-inputs} parameter.
  5948. In its @code{configure} phase, this build system will make any source inputs
  5949. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  5950. parameters available to cargo. It will also remove an included
  5951. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  5952. @code{build} phase. The @code{install} phase installs the binaries
  5953. defined by the crate.
  5954. @end defvr
  5955. @defvr {Scheme Variable} chicken-build-system
  5956. This variable is exported by @code{(guix build-system chicken)}. It
  5957. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  5958. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  5959. gets compiled by a C compiler, in this case GCC.
  5960. This build system adds @code{chicken} to the package inputs, as well as
  5961. the packages of @code{gnu-build-system}.
  5962. The build system can't (yet) deduce the egg's name automatically, so just like
  5963. with @code{go-build-system} and its @code{#:import-path}, you should define
  5964. @code{#:egg-name} in the package's @code{arguments} field.
  5965. For example, if you are packaging the @code{srfi-1} egg:
  5966. @lisp
  5967. (arguments '(#:egg-name "srfi-1"))
  5968. @end lisp
  5969. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  5970. because CHICKEN doesn't embed absolute references in compiled eggs.
  5971. Test dependencies should go to @code{native-inputs}, as usual.
  5972. @end defvr
  5973. @defvr {Scheme Variable} copy-build-system
  5974. This variable is exported by @code{(guix build-system copy)}. It
  5975. supports builds of simple packages that don't require much compiling,
  5976. mostly just moving files around.
  5977. It adds much of the @code{gnu-build-system} packages to the set of
  5978. inputs. Because of this, the @code{copy-build-system} does not require
  5979. all the boilerplate code often needed for the
  5980. @code{trivial-build-system}.
  5981. To further simplify the file installation process, an
  5982. @code{#:install-plan} argument is exposed to let the packager specify
  5983. which files go where. The install plan is a list of @code{(@var{source}
  5984. @var{target} [@var{filters}])}. @var{filters} are optional.
  5985. @itemize
  5986. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  5987. @itemize
  5988. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  5989. @item Otherwise install @var{source} as @var{target}.
  5990. @end itemize
  5991. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  5992. the trailing slash of @var{target} is implied with the same meaning
  5993. as above.
  5994. @itemize
  5995. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  5996. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  5997. @code{#:exclude-regexp}, only select files are installed depending on
  5998. the filters. Each filters is specified by a list of strings.
  5999. @itemize
  6000. @item With @code{#:include}, install all the files which the path suffix matches
  6001. at least one of the elements in the given list.
  6002. @item With @code{#:include-regexp}, install all the files which the
  6003. subpaths match at least one of the regular expressions in the given
  6004. list.
  6005. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6006. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6007. install all files but those matching the exclusion filters.
  6008. If both inclusions and exclusions are specified, the exclusions are done
  6009. on top of the inclusions.
  6010. @end itemize
  6011. @end itemize
  6012. In all cases, the paths relative to @var{source} are preserved within
  6013. @var{target}.
  6014. @end itemize
  6015. Examples:
  6016. @itemize
  6017. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6018. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6019. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6020. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6021. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6022. @file{share/my-app/sub/file}.
  6023. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6024. @file{share/my-app/file}.
  6025. @end itemize
  6026. @end defvr
  6027. @cindex Clojure (programming language)
  6028. @cindex simple Clojure build system
  6029. @defvr {Scheme Variable} clojure-build-system
  6030. This variable is exported by @code{(guix build-system clojure)}. It implements
  6031. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6032. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6033. yet.
  6034. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6035. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6036. @code{#:zip} parameters, respectively.
  6037. A list of source directories, test directories and jar names can be specified
  6038. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6039. parameters, respectively. Compile directory and main class can be specified
  6040. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6041. Other parameters are documented below.
  6042. This build system is an extension of @code{ant-build-system}, but with the
  6043. following phases changed:
  6044. @table @code
  6045. @item build
  6046. This phase calls @code{compile} in Clojure to compile source files and runs
  6047. @command{jar} to create jars from both source files and compiled files
  6048. according to the include list and exclude list specified in
  6049. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6050. has priority over the include list. These lists consist of symbols
  6051. representing Clojure libraries or the special keyword @code{#:all} representing
  6052. all Clojure libraries found under the source directories. The parameter
  6053. @code{#:omit-source?} decides if source should be included into the jars.
  6054. @item check
  6055. This phase runs tests according to the include list and exclude list specified
  6056. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6057. meanings are analogous to that of @code{#:aot-include} and
  6058. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6059. stands for all Clojure libraries found under the test directories. The
  6060. parameter @code{#:tests?} decides if tests should be run.
  6061. @item install
  6062. This phase installs all jars built previously.
  6063. @end table
  6064. Apart from the above, this build system also contains an additional phase:
  6065. @table @code
  6066. @item install-doc
  6067. This phase installs all top-level files with base name matching
  6068. @code{%doc-regex}. A different regex can be specified with the
  6069. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6070. directories specified in @code{#:doc-dirs} are installed as well.
  6071. @end table
  6072. @end defvr
  6073. @defvr {Scheme Variable} cmake-build-system
  6074. This variable is exported by @code{(guix build-system cmake)}. It
  6075. implements the build procedure for packages using the
  6076. @url{https://www.cmake.org, CMake build tool}.
  6077. It automatically adds the @code{cmake} package to the set of inputs.
  6078. Which package is used can be specified with the @code{#:cmake}
  6079. parameter.
  6080. The @code{#:configure-flags} parameter is taken as a list of flags
  6081. passed to the @command{cmake} command. The @code{#:build-type}
  6082. parameter specifies in abstract terms the flags passed to the compiler;
  6083. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6084. debugging information''), which roughly means that code is compiled with
  6085. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6086. @end defvr
  6087. @defvr {Scheme Variable} dune-build-system
  6088. This variable is exported by @code{(guix build-system dune)}. It
  6089. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6090. tool for the OCaml programming language. It is implemented as an extension
  6091. of the @code{ocaml-build-system} which is described below. As such, the
  6092. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6093. system.
  6094. It automatically adds the @code{dune} package to the set of inputs.
  6095. Which package is used can be specified with the @code{#:dune}
  6096. parameter.
  6097. There is no @code{configure} phase because dune packages typically don't
  6098. need to be configured. The @code{#:build-flags} parameter is taken as a
  6099. list of flags passed to the @code{dune} command during the build.
  6100. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6101. command instead of the more recent @code{dune} command while building
  6102. a package. Its default value is @code{#f}.
  6103. The @code{#:package} parameter can be passed to specify a package name, which
  6104. is useful when a package contains multiple packages and you want to build
  6105. only one of them. This is equivalent to passing the @code{-p} argument to
  6106. @code{dune}.
  6107. @end defvr
  6108. @defvr {Scheme Variable} go-build-system
  6109. This variable is exported by @code{(guix build-system go)}. It
  6110. implements a build procedure for Go packages using the standard
  6111. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6112. Go build mechanisms}.
  6113. The user is expected to provide a value for the key @code{#:import-path}
  6114. and, in some cases, @code{#:unpack-path}. The
  6115. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6116. corresponds to the file system path expected by the package's build
  6117. scripts and any referring packages, and provides a unique way to
  6118. refer to a Go package. It is typically based on a combination of the
  6119. package source code's remote URI and file system hierarchy structure. In
  6120. some cases, you will need to unpack the package's source code to a
  6121. different directory structure than the one indicated by the import path,
  6122. and @code{#:unpack-path} should be used in such cases.
  6123. Packages that provide Go libraries should install their source code into
  6124. the built output. The key @code{#:install-source?}, which defaults to
  6125. @code{#t}, controls whether or not the source code is installed. It can
  6126. be set to @code{#f} for packages that only provide executable files.
  6127. @end defvr
  6128. @defvr {Scheme Variable} glib-or-gtk-build-system
  6129. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6130. is intended for use with packages making use of GLib or GTK+.
  6131. This build system adds the following two phases to the ones defined by
  6132. @code{gnu-build-system}:
  6133. @table @code
  6134. @item glib-or-gtk-wrap
  6135. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6136. @file{bin/} are able to find GLib ``schemas'' and
  6137. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6138. modules}. This is achieved by wrapping the programs in launch scripts
  6139. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6140. environment variables.
  6141. It is possible to exclude specific package outputs from that wrapping
  6142. process by listing their names in the
  6143. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6144. when an output is known not to contain any GLib or GTK+ binaries, and
  6145. where wrapping would gratuitously add a dependency of that output on
  6146. GLib and GTK+.
  6147. @item glib-or-gtk-compile-schemas
  6148. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6149. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6150. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6151. @command{glib-compile-schemas} program. It is provided by the package
  6152. @code{glib:bin} which is automatically imported by the build system.
  6153. The @code{glib} package providing @command{glib-compile-schemas} can be
  6154. specified with the @code{#:glib} parameter.
  6155. @end table
  6156. Both phases are executed after the @code{install} phase.
  6157. @end defvr
  6158. @defvr {Scheme Variable} guile-build-system
  6159. This build system is for Guile packages that consist exclusively of Scheme
  6160. code and that are so lean that they don't even have a makefile, let alone a
  6161. @file{configure} script. It compiles Scheme code using @command{guild
  6162. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6163. installs the @file{.scm} and @file{.go} files in the right place. It also
  6164. installs documentation.
  6165. This build system supports cross-compilation by using the
  6166. @option{--target} option of @samp{guild compile}.
  6167. Packages built with @code{guile-build-system} must provide a Guile package in
  6168. their @code{native-inputs} field.
  6169. @end defvr
  6170. @defvr {Scheme Variable} julia-build-system
  6171. This variable is exported by @code{(guix build-system julia)}. It
  6172. implements the build procedure used by @uref{https://julialang.org/,
  6173. julia} packages, which essentially is similar to running @samp{julia -e
  6174. 'using Pkg; Pkg.add(package)'} in an environment where
  6175. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6176. Tests are run with @code{Pkg.test}.
  6177. Julia packages require the source @code{file-name} to be the real name of the
  6178. package, correctly capitalized.
  6179. For packages requiring shared library dependencies, you may need to write the
  6180. @file{/deps/deps.jl} file manually. It's usually a line of @code{const
  6181. variable = /gnu/store/library.so} for each dependency, plus a void function
  6182. @code{check_deps() = nothing}.
  6183. Some older packages that aren't using @file{Package.toml} yet, will require
  6184. this file to be created, too. The function @code{julia-create-package-toml}
  6185. helps creating the file. You need to pass the outputs and the source of the
  6186. package, it's name (the same as the @code{file-name} parameter), the package
  6187. uuid, the package version, and a list of dependencies specified by their name
  6188. and their uuid.
  6189. @end defvr
  6190. @defvr {Scheme Variable} maven-build-system
  6191. This variable is exported by @code{(guix build-system maven)}. It implements
  6192. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6193. is a dependency and lifecycle management tool for Java. A user of Maven
  6194. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6195. When Maven does not have one of the dependencies or plugins in its repository,
  6196. it will download them and use them to build the package.
  6197. The maven build system ensures that maven will not try to download any
  6198. dependency by running in offline mode. Maven will fail if a dependency is
  6199. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6200. modified to specify the version of dependencies and plugins that match the
  6201. versions available in the guix build environment. Dependencies and plugins
  6202. must be installed in the fake maven repository at @file{lib/m2}, and are
  6203. symlinked into a proper repository before maven is run. Maven is instructed
  6204. to use that repository for the build and installs built artifacts there.
  6205. Changed files are copied to the @file{lib/m2} directory of the package output.
  6206. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6207. or let the build system use the default @file{pom.xml} file in the sources.
  6208. In case you need to specify a dependency's version manually, you can use the
  6209. @code{#:local-packages} argument. It takes an association list where the key
  6210. is the groupId of the package and its value is an association list where the
  6211. key is the artifactId of the package and its value is the version you want to
  6212. override in the @file{pom.xml}.
  6213. Some packages use dependencies or plugins that are not useful at runtime nor
  6214. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6215. using the @code{#:exclude} argument. Its value is an association list where
  6216. the key is the groupId of the plugin or dependency you want to remove, and
  6217. the value is a list of artifactId you want to remove.
  6218. You can override the default @code{jdk} and @code{maven} packages with the
  6219. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6220. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6221. the build, with the same format as the @code{inputs} fields of the package
  6222. declaration. Its default value is @code{(default-maven-plugins)} which is
  6223. also exported.
  6224. @end defvr
  6225. @defvr {Scheme Variable} minify-build-system
  6226. This variable is exported by @code{(guix build-system minify)}. It
  6227. implements a minification procedure for simple JavaScript packages.
  6228. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6229. all JavaScript files in the @file{src} directory. A different minifier
  6230. package can be specified with the @code{#:uglify-js} parameter, but it
  6231. is expected that the package writes the minified code to the standard
  6232. output.
  6233. When the input JavaScript files are not all located in the @file{src}
  6234. directory, the parameter @code{#:javascript-files} can be used to
  6235. specify a list of file names to feed to the minifier.
  6236. @end defvr
  6237. @defvr {Scheme Variable} ocaml-build-system
  6238. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6239. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6240. of choosing the correct set of commands to run for each package. OCaml
  6241. packages can expect many different commands to be run. This build system will
  6242. try some of them.
  6243. When the package has a @file{setup.ml} file present at the top-level, it will
  6244. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6245. @code{ocaml setup.ml -install}. The build system will assume that this file
  6246. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6247. care of setting the prefix and enabling tests if they are not disabled. You
  6248. can pass configure and build flags with the @code{#:configure-flags} and
  6249. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6250. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6251. bypass this system in the build and install phases.
  6252. When the package has a @file{configure} file, it is assumed that it is a
  6253. hand-made configure script that requires a different argument format than
  6254. in the @code{gnu-build-system}. You can add more flags with the
  6255. @code{#:configure-flags} key.
  6256. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6257. @code{#t}), it will be used and more flags can be passed to the build and
  6258. install phases with the @code{#:make-flags} key.
  6259. Finally, some packages do not have these files and use a somewhat standard
  6260. location for its build system. In that case, the build system will run
  6261. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6262. providing the path to the required findlib module. Additional flags can
  6263. be passed via the @code{#:build-flags} key. Install is taken care of by
  6264. @command{opam-installer}. In this case, the @code{opam} package must
  6265. be added to the @code{native-inputs} field of the package definition.
  6266. Note that most OCaml packages assume they will be installed in the same
  6267. directory as OCaml, which is not what we want in guix. In particular, they
  6268. will install @file{.so} files in their module's directory, which is usually
  6269. fine because it is in the OCaml compiler directory. In guix though, these
  6270. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6271. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6272. @file{.so} libraries should be installed.
  6273. @end defvr
  6274. @defvr {Scheme Variable} python-build-system
  6275. This variable is exported by @code{(guix build-system python)}. It
  6276. implements the more or less standard build procedure used by Python
  6277. packages, which consists in running @code{python setup.py build} and
  6278. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6279. For packages that install stand-alone Python programs under @code{bin/},
  6280. it takes care of wrapping these programs so that their @env{PYTHONPATH}
  6281. environment variable points to all the Python libraries they depend on.
  6282. Which Python package is used to perform the build can be specified with
  6283. the @code{#:python} parameter. This is a useful way to force a package
  6284. to be built for a specific version of the Python interpreter, which
  6285. might be necessary if the package is only compatible with a single
  6286. interpreter version.
  6287. By default guix calls @code{setup.py} under control of
  6288. @code{setuptools}, much like @command{pip} does. Some packages are not
  6289. compatible with setuptools (and pip), thus you can disable this by
  6290. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6291. @end defvr
  6292. @defvr {Scheme Variable} perl-build-system
  6293. This variable is exported by @code{(guix build-system perl)}. It
  6294. implements the standard build procedure for Perl packages, which either
  6295. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6296. followed by @code{Build} and @code{Build install}; or in running
  6297. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  6298. @code{make} and @code{make install}, depending on which of
  6299. @code{Build.PL} or @code{Makefile.PL} is present in the package
  6300. distribution. Preference is given to the former if both @code{Build.PL}
  6301. and @code{Makefile.PL} exist in the package distribution. This
  6302. preference can be reversed by specifying @code{#t} for the
  6303. @code{#:make-maker?} parameter.
  6304. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  6305. passes flags specified by the @code{#:make-maker-flags} or
  6306. @code{#:module-build-flags} parameter, respectively.
  6307. Which Perl package is used can be specified with @code{#:perl}.
  6308. @end defvr
  6309. @defvr {Scheme Variable} qt-build-system
  6310. This variable is exported by @code{(guix build-system qt)}. It
  6311. is intended for use with applications using Qt or KDE.
  6312. This build system adds the following two phases to the ones defined by
  6313. @code{cmake-build-system}:
  6314. @table @code
  6315. @item check-setup
  6316. The phase @code{check-setup} prepares the environment for running
  6317. the checks as commonly used by Qt test programs.
  6318. For now this only sets some environment variables:
  6319. @code{QT_QPA_PLATFORM=offscreen},
  6320. @code{DBUS_FATAL_WARNINGS=0} and
  6321. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  6322. This phase is added before the @code{check} phase.
  6323. It's a separate phase to ease adjusting if necessary.
  6324. @item qt-wrap
  6325. The phase @code{qt-wrap}
  6326. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  6327. and output. In case some path is found, all programs in the output's
  6328. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  6329. are wrapped in scripts defining the necessary environment variables.
  6330. It is possible to exclude specific package outputs from that wrapping process
  6331. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  6332. This is useful when an output is known not to contain any Qt binaries, and
  6333. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  6334. or such.
  6335. This phase is added after the @code{install} phase.
  6336. @end table
  6337. @end defvr
  6338. @defvr {Scheme Variable} r-build-system
  6339. This variable is exported by @code{(guix build-system r)}. It
  6340. implements the build procedure used by @uref{https://r-project.org, R}
  6341. packages, which essentially is little more than running @samp{R CMD
  6342. INSTALL --library=/gnu/store/@dots{}} in an environment where
  6343. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  6344. run after installation using the R function
  6345. @code{tools::testInstalledPackage}.
  6346. @end defvr
  6347. @defvr {Scheme Variable} rakudo-build-system
  6348. This variable is exported by @code{(guix build-system rakudo)}. It
  6349. implements the build procedure used by @uref{https://rakudo.org/,
  6350. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  6351. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  6352. installs the binaries, library files and the resources, as well as wrap
  6353. the files under the @code{bin/} directory. Tests can be skipped by
  6354. passing @code{#f} to the @code{tests?} parameter.
  6355. Which rakudo package is used can be specified with @code{rakudo}.
  6356. Which perl6-tap-harness package used for the tests can be specified with
  6357. @code{#:prove6} or removed by passing @code{#f} to the
  6358. @code{with-prove6?} parameter.
  6359. Which perl6-zef package used for tests and installing can be specified
  6360. with @code{#:zef} or removed by passing @code{#f} to the
  6361. @code{with-zef?} parameter.
  6362. @end defvr
  6363. @defvr {Scheme Variable} texlive-build-system
  6364. This variable is exported by @code{(guix build-system texlive)}. It is
  6365. used to build TeX packages in batch mode with a specified engine. The
  6366. build system sets the @env{TEXINPUTS} variable to find all TeX source
  6367. files in the inputs.
  6368. By default it runs @code{luatex} on all files ending on @code{ins}. A
  6369. different engine and format can be specified with the
  6370. @code{#:tex-format} argument. Different build targets can be specified
  6371. with the @code{#:build-targets} argument, which expects a list of file
  6372. names. The build system adds only @code{texlive-bin} and
  6373. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  6374. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  6375. and @code{#:texlive-latex-base}, respectively.
  6376. The @code{#:tex-directory} parameter tells the build system where to
  6377. install the built files under the texmf tree.
  6378. @end defvr
  6379. @defvr {Scheme Variable} ruby-build-system
  6380. This variable is exported by @code{(guix build-system ruby)}. It
  6381. implements the RubyGems build procedure used by Ruby packages, which
  6382. involves running @code{gem build} followed by @code{gem install}.
  6383. The @code{source} field of a package that uses this build system
  6384. typically references a gem archive, since this is the format that Ruby
  6385. developers use when releasing their software. The build system unpacks
  6386. the gem archive, potentially patches the source, runs the test suite,
  6387. repackages the gem, and installs it. Additionally, directories and
  6388. tarballs may be referenced to allow building unreleased gems from Git or
  6389. a traditional source release tarball.
  6390. Which Ruby package is used can be specified with the @code{#:ruby}
  6391. parameter. A list of additional flags to be passed to the @command{gem}
  6392. command can be specified with the @code{#:gem-flags} parameter.
  6393. @end defvr
  6394. @defvr {Scheme Variable} waf-build-system
  6395. This variable is exported by @code{(guix build-system waf)}. It
  6396. implements a build procedure around the @code{waf} script. The common
  6397. phases---@code{configure}, @code{build}, and @code{install}---are
  6398. implemented by passing their names as arguments to the @code{waf}
  6399. script.
  6400. The @code{waf} script is executed by the Python interpreter. Which
  6401. Python package is used to run the script can be specified with the
  6402. @code{#:python} parameter.
  6403. @end defvr
  6404. @defvr {Scheme Variable} scons-build-system
  6405. This variable is exported by @code{(guix build-system scons)}. It
  6406. implements the build procedure used by the SCons software construction
  6407. tool. This build system runs @code{scons} to build the package,
  6408. @code{scons test} to run tests, and then @code{scons install} to install
  6409. the package.
  6410. Additional flags to be passed to @code{scons} can be specified with the
  6411. @code{#:scons-flags} parameter. The default build and install targets
  6412. can be overridden with @code{#:build-targets} and
  6413. @code{#:install-targets} respectively. The version of Python used to
  6414. run SCons can be specified by selecting the appropriate SCons package
  6415. with the @code{#:scons} parameter.
  6416. @end defvr
  6417. @defvr {Scheme Variable} haskell-build-system
  6418. This variable is exported by @code{(guix build-system haskell)}. It
  6419. implements the Cabal build procedure used by Haskell packages, which
  6420. involves running @code{runhaskell Setup.hs configure
  6421. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  6422. Instead of installing the package by running @code{runhaskell Setup.hs
  6423. install}, to avoid trying to register libraries in the read-only
  6424. compiler store directory, the build system uses @code{runhaskell
  6425. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  6426. addition, the build system generates the package documentation by
  6427. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  6428. is passed. Optional Haddock parameters can be passed with the help of
  6429. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  6430. not found, the build system looks for @code{Setup.lhs} instead.
  6431. Which Haskell compiler is used can be specified with the @code{#:haskell}
  6432. parameter which defaults to @code{ghc}.
  6433. @end defvr
  6434. @defvr {Scheme Variable} dub-build-system
  6435. This variable is exported by @code{(guix build-system dub)}. It
  6436. implements the Dub build procedure used by D packages, which
  6437. involves running @code{dub build} and @code{dub run}.
  6438. Installation is done by copying the files manually.
  6439. Which D compiler is used can be specified with the @code{#:ldc}
  6440. parameter which defaults to @code{ldc}.
  6441. @end defvr
  6442. @anchor{emacs-build-system}
  6443. @defvr {Scheme Variable} emacs-build-system
  6444. This variable is exported by @code{(guix build-system emacs)}. It
  6445. implements an installation procedure similar to the packaging system
  6446. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  6447. It first creates the @code{@code{package}-autoloads.el} file, then it
  6448. byte compiles all Emacs Lisp files. Differently from the Emacs
  6449. packaging system, the Info documentation files are moved to the standard
  6450. documentation directory and the @file{dir} file is deleted. The Elisp
  6451. package files are installed directly under @file{share/emacs/site-lisp}.
  6452. @end defvr
  6453. @defvr {Scheme Variable} font-build-system
  6454. This variable is exported by @code{(guix build-system font)}. It
  6455. implements an installation procedure for font packages where upstream
  6456. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  6457. need to be copied into place. It copies font files to standard
  6458. locations in the output directory.
  6459. @end defvr
  6460. @defvr {Scheme Variable} meson-build-system
  6461. This variable is exported by @code{(guix build-system meson)}. It
  6462. implements the build procedure for packages that use
  6463. @url{https://mesonbuild.com, Meson} as their build system.
  6464. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  6465. of inputs, and they can be changed with the parameters @code{#:meson}
  6466. and @code{#:ninja} if needed. The default Meson is
  6467. @code{meson-for-build}, which is special because it doesn't clear the
  6468. @code{RUNPATH} of binaries and libraries when they are installed.
  6469. This build system is an extension of @code{gnu-build-system}, but with the
  6470. following phases changed to some specific for Meson:
  6471. @table @code
  6472. @item configure
  6473. The phase runs @code{meson} with the flags specified in
  6474. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  6475. @code{debugoptimized} unless something else is specified in
  6476. @code{#:build-type}.
  6477. @item build
  6478. The phase runs @code{ninja} to build the package in parallel by default, but
  6479. this can be changed with @code{#:parallel-build?}.
  6480. @item check
  6481. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  6482. which is @code{"test"} by default.
  6483. @item install
  6484. The phase runs @code{ninja install} and can not be changed.
  6485. @end table
  6486. Apart from that, the build system also adds the following phases:
  6487. @table @code
  6488. @item fix-runpath
  6489. This phase ensures that all binaries can find the libraries they need.
  6490. It searches for required libraries in subdirectories of the package being
  6491. built, and adds those to @code{RUNPATH} where needed. It also removes
  6492. references to libraries left over from the build phase by
  6493. @code{meson-for-build}, such as test dependencies, that aren't actually
  6494. required for the program to run.
  6495. @item glib-or-gtk-wrap
  6496. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6497. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6498. @item glib-or-gtk-compile-schemas
  6499. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6500. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6501. @end table
  6502. @end defvr
  6503. @defvr {Scheme Variable} linux-module-build-system
  6504. @code{linux-module-build-system} allows building Linux kernel modules.
  6505. @cindex build phases
  6506. This build system is an extension of @code{gnu-build-system}, but with the
  6507. following phases changed:
  6508. @table @code
  6509. @item configure
  6510. This phase configures the environment so that the Linux kernel's Makefile
  6511. can be used to build the external kernel module.
  6512. @item build
  6513. This phase uses the Linux kernel's Makefile in order to build the external
  6514. kernel module.
  6515. @item install
  6516. This phase uses the Linux kernel's Makefile in order to install the external
  6517. kernel module.
  6518. @end table
  6519. It is possible and useful to specify the Linux kernel to use for building
  6520. the module (in the @code{arguments} form of a package using the
  6521. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  6522. @end defvr
  6523. @defvr {Scheme Variable} node-build-system
  6524. This variable is exported by @code{(guix build-system node)}. It
  6525. implements the build procedure used by @uref{https://nodejs.org,
  6526. Node.js}, which implements an approximation of the @code{npm install}
  6527. command, followed by an @code{npm test} command.
  6528. Which Node.js package is used to interpret the @code{npm} commands can
  6529. be specified with the @code{#:node} parameter which defaults to
  6530. @code{node}.
  6531. @end defvr
  6532. Lastly, for packages that do not need anything as sophisticated, a
  6533. ``trivial'' build system is provided. It is trivial in the sense that
  6534. it provides basically no support: it does not pull any implicit inputs,
  6535. and does not have a notion of build phases.
  6536. @defvr {Scheme Variable} trivial-build-system
  6537. This variable is exported by @code{(guix build-system trivial)}.
  6538. This build system requires a @code{#:builder} argument. This argument
  6539. must be a Scheme expression that builds the package output(s)---as
  6540. with @code{build-expression->derivation} (@pxref{Derivations,
  6541. @code{build-expression->derivation}}).
  6542. @end defvr
  6543. @node Build Phases
  6544. @section Build Phases
  6545. @cindex build phases, for packages
  6546. Almost all package build systems implement a notion @dfn{build phases}:
  6547. a sequence of actions that the build system executes, when you build the
  6548. package, leading to the installed byproducts in the store. A notable
  6549. exception is the ``bare-bones'' @code{trivial-build-system}
  6550. (@pxref{Build Systems}).
  6551. As discussed in the previous section, those build systems provide a
  6552. standard list of phases. For @code{gnu-build-system}, the standard
  6553. phases include an @code{unpack} phase to unpack the source code tarball,
  6554. a @command{configure} phase to run @code{./configure}, a @code{build}
  6555. phase to run @command{make}, and (among others) an @code{install} phase
  6556. to run @command{make install}; @pxref{Build Systems}, for a more
  6557. detailed view of these phases. Likewise, @code{cmake-build-system}
  6558. inherits these phases, but its @code{configure} phase runs
  6559. @command{cmake} instead of @command{./configure}. Other build systems,
  6560. such as @code{python-build-system}, have a wholly different list of
  6561. standard phases. All this code runs on the @dfn{build side}: it is
  6562. evaluated when you actually build the package, in a dedicated build
  6563. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  6564. Build phases are represented as association lists or ``alists''
  6565. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  6566. each key is a symbol for the name of the phase and the associated value
  6567. is a procedure that accepts an arbitrary number of arguments. By
  6568. convention, those procedures receive information about the build in the
  6569. form of @dfn{keyword parameters}, which they can use or ignore.
  6570. For example, here is how @code{(guix build gnu-build-system)} defines
  6571. @code{%standard-phases}, the variable holding its alist of build
  6572. phases@footnote{We present a simplified view of those build phases, but
  6573. do take a look at @code{(guix build gnu-build-system)} to see all the
  6574. details!}:
  6575. @lisp
  6576. ;; The build phases of 'gnu-build-system'.
  6577. (define* (unpack #:key source #:allow-other-keys)
  6578. ;; Extract the source tarball.
  6579. (invoke "tar" "xvf" source))
  6580. (define* (configure #:key outputs #:allow-other-keys)
  6581. ;; Run the 'configure' script. Install to output "out".
  6582. (let ((out (assoc-ref outputs "out")))
  6583. (invoke "./configure"
  6584. (string-append "--prefix=" out))))
  6585. (define* (build #:allow-other-keys)
  6586. ;; Compile.
  6587. (invoke "make"))
  6588. (define* (check #:key (test-target "check") (tests? #true)
  6589. #:allow-other-keys)
  6590. ;; Run the test suite.
  6591. (if tests?
  6592. (invoke "make" test-target)
  6593. (display "test suite not run\n")))
  6594. (define* (install #:allow-other-keys)
  6595. ;; Install files to the prefix 'configure' specified.
  6596. (invoke "make" "install"))
  6597. (define %standard-phases
  6598. ;; The list of standard phases (quite a few are omitted
  6599. ;; for brevity). Each element is a symbol/procedure pair.
  6600. (list (cons 'unpack unpack)
  6601. (cons 'configure configure)
  6602. (cons 'build build)
  6603. (cons 'check check)
  6604. (cons 'install install)))
  6605. @end lisp
  6606. This shows how @code{%standard-phases} is defined as a list of
  6607. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  6608. Manual}). The first pair associates the @code{unpack} procedure with
  6609. the @code{unpack} symbol---a name; the second pair defines the
  6610. @code{configure} phase similarly, and so on. When building a package
  6611. that uses @code{gnu-build-system} with its default list of phases, those
  6612. phases are executed sequentially. You can see the name of each phase
  6613. started and completed in the build log of packages that you build.
  6614. Let's now look at the procedures themselves. Each one is defined with
  6615. @code{define*}: @code{#:key} lists keyword parameters the procedure
  6616. accepts, possibly with a default value, and @code{#:allow-other-keys}
  6617. specifies that other keyword parameters are ignored (@pxref{Optional
  6618. Arguments,,, guile, GNU Guile Reference Manual}).
  6619. The @code{unpack} procedure honors the @code{source} parameter, which
  6620. the build system uses to pass the file name of the source tarball (or
  6621. version control checkout), and it ignores other parameters. The
  6622. @code{configure} phase only cares about the @code{outputs} parameter, an
  6623. alist mapping package output names to their store file name
  6624. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  6625. for @code{out}, the default output, and passes it to
  6626. @command{./configure} as the installation prefix, meaning that
  6627. @command{make install} will eventually copy all the files in that
  6628. directory (@pxref{Configuration, configuration and makefile
  6629. conventions,, standards, GNU Coding Standards}). @code{build} and
  6630. @code{install} ignore all their arguments. @code{check} honors the
  6631. @code{test-target} argument, which specifies the name of the Makefile
  6632. target to run tests; it prints a message and skips tests when
  6633. @code{tests?} is false.
  6634. @cindex build phases, customizing
  6635. The list of phases used for a particular package can be changed with the
  6636. @code{#:phases} parameter of the build system. Changing the set of
  6637. build phases boils down to building a new alist of phases based on the
  6638. @code{%standard-phases} alist described above. This can be done with
  6639. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  6640. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  6641. more convenient to do so with @code{modify-phases} (@pxref{Build
  6642. Utilities, @code{modify-phases}}).
  6643. Here is an example of a package definition that removes the
  6644. @code{configure} phase of @code{%standard-phases} and inserts a new
  6645. phase before the @code{build} phase, called
  6646. @code{set-prefix-in-makefile}:
  6647. @lisp
  6648. (define-public example
  6649. (package
  6650. (name "example")
  6651. ;; other fields omitted
  6652. (build-system gnu-build-system)
  6653. (arguments
  6654. '(#:phases (modify-phases %standard-phases
  6655. (delete 'configure)
  6656. (add-before 'build 'set-prefix-in-makefile
  6657. (lambda* (#:key outputs #:allow-other-keys)
  6658. ;; Modify the makefile so that its
  6659. ;; 'PREFIX' variable points to "out".
  6660. (let ((out (assoc-ref outputs "out")))
  6661. (substitute* "Makefile"
  6662. (("PREFIX =.*")
  6663. (string-append "PREFIX = "
  6664. out "\n")))
  6665. #true))))))))
  6666. @end lisp
  6667. The new phase that is inserted is written as an anonymous procedure,
  6668. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  6669. we have seen before. @xref{Build Utilities}, for more about the helpers
  6670. used by this phase, and for more examples of @code{modify-phases}.
  6671. @cindex code staging
  6672. @cindex staging, of code
  6673. Keep in mind that build phases are code evaluated at the time the
  6674. package is actually built. This explains why the whole
  6675. @code{modify-phases} expression above is quoted (it comes after the
  6676. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  6677. @xref{G-Expressions}, for an explanation of code staging and the
  6678. @dfn{code strata} involved.
  6679. @node Build Utilities
  6680. @section Build Utilities
  6681. As soon as you start writing non-trivial package definitions
  6682. (@pxref{Defining Packages}) or other build actions
  6683. (@pxref{G-Expressions}), you will likely start looking for helpers for
  6684. ``shell-like'' actions---creating directories, copying and deleting
  6685. files recursively, manipulating build phases, and so on. The
  6686. @code{(guix build utils)} module provides such utility procedures.
  6687. Most build systems load @code{(guix build utils)} (@pxref{Build
  6688. Systems}). Thus, when writing custom build phases for your package
  6689. definitions, you can usually assume those procedures are in scope.
  6690. When writing G-expressions, you can import @code{(guix build utils)} on
  6691. the ``build side'' using @code{with-imported-modules} and then put it in
  6692. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  6693. guile, GNU Guile Reference Manual}):
  6694. @lisp
  6695. (with-imported-modules '((guix build utils)) ;import it
  6696. (computed-file "empty-tree"
  6697. #~(begin
  6698. ;; Put it in scope.
  6699. (use-modules (guix build utils))
  6700. ;; Happily use its 'mkdir-p' procedure.
  6701. (mkdir-p (string-append #$output "/a/b/c")))))
  6702. @end lisp
  6703. The remainder of this section is the reference for most of the utility
  6704. procedures provided by @code{(guix build utils)}.
  6705. @c TODO Document what's missing.
  6706. @subsection Dealing with Store File Names
  6707. This section documents procedures that deal with store file names.
  6708. @deffn {Scheme Procedure} %store-directory
  6709. Return the directory name of the store.
  6710. @end deffn
  6711. @deffn {Scheme Procedure} store-file-name? @var{file}
  6712. Return true if @var{file} is in the store.
  6713. @end deffn
  6714. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  6715. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  6716. The result is typically a @code{"@var{package}-@var{version}"} string.
  6717. @end deffn
  6718. @deffn {Scheme Procedure} package-name->name+version @var{name}
  6719. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  6720. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  6721. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  6722. followed by a digit is considered to introduce the version part.
  6723. @end deffn
  6724. @subsection File Types
  6725. The procedures below deal with files and file types.
  6726. @deffn {Scheme Procedure} directory-exists? @var{dir}
  6727. Return @code{#t} if @var{dir} exists and is a directory.
  6728. @end deffn
  6729. @deffn {Scheme Procedure} executable-file? @var{file}
  6730. Return @code{#t} if @var{file} exists and is executable.
  6731. @end deffn
  6732. @deffn {Scheme Procedure} symbolic-link? @var{file}
  6733. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  6734. @end deffn
  6735. @deffn {Scheme Procedure} elf-file? @var{file}
  6736. @deffnx {Scheme Procedure} ar-file? @var{file}
  6737. @deffnx {Scheme Procedure} gzip-file? @var{file}
  6738. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  6739. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  6740. @end deffn
  6741. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  6742. If @var{file} is a gzip file, reset its embedded timestamp (as with
  6743. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  6744. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  6745. @end deffn
  6746. @subsection File Manipulation
  6747. The following procedures and macros help create, modify, and delete
  6748. files. They provide functionality comparable to common shell utilities
  6749. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  6750. @command{sed}. They complement Guile's extensive, but low-level, file
  6751. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  6752. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  6753. Run @var{body} with @var{directory} as the process's current directory.
  6754. Essentially, this macro changes the current directory to @var{directory}
  6755. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  6756. guile, GNU Guile Reference Manual}). It changes back to the initial
  6757. directory when the dynamic extent of @var{body} is left, be it @i{via}
  6758. normal procedure return or @i{via} a non-local exit such as an
  6759. exception.
  6760. @end deffn
  6761. @deffn {Scheme Procedure} mkdir-p @var{dir}
  6762. Create directory @var{dir} and all its ancestors.
  6763. @end deffn
  6764. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  6765. Create @var{directory} if it does not exist and copy @var{file} in there
  6766. under the same name.
  6767. @end deffn
  6768. @deffn {Scheme Procedure} make-file-writable @var{file}
  6769. Make @var{file} writable for its owner.
  6770. @end deffn
  6771. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  6772. [#:log (current-output-port)] [#:follow-symlinks? #f] [#:keep-mtime? #f]
  6773. Copy @var{source} directory to @var{destination}. Follow symlinks if
  6774. @var{follow-symlinks?} is true; otherwise, just preserve them. When
  6775. @var{keep-mtime?} is true, keep the modification time of the files in
  6776. @var{source} on those of @var{destination}. Write verbose output to the
  6777. @var{log} port.
  6778. @end deffn
  6779. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  6780. [#:follow-mounts? #f]
  6781. Delete @var{dir} recursively, like @command{rm -rf}, without following
  6782. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  6783. is true. Report but ignore errors.
  6784. @end deffn
  6785. @deffn {Scheme Syntax} substitute* @var{file} @
  6786. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  6787. Substitute @var{regexp} in @var{file} by the string returned by
  6788. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  6789. the corresponding positional regexp sub-expression. For example:
  6790. @lisp
  6791. (substitute* file
  6792. (("hello")
  6793. "good morning\n")
  6794. (("foo([a-z]+)bar(.*)$" all letters end)
  6795. (string-append "baz" letter end)))
  6796. @end lisp
  6797. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  6798. by @code{good morning}. Anytime a line of @var{file} matches the second
  6799. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  6800. to the first sub-expression, and @code{end} is bound to the last one.
  6801. When one of the @var{match-var} is @code{_}, no variable is bound to the
  6802. corresponding match substring.
  6803. Alternatively, @var{file} may be a list of file names, in which case
  6804. they are all subject to the substitutions.
  6805. Be careful about using @code{$} to match the end of a line; by itself it
  6806. won't match the terminating newline of a line.
  6807. @end deffn
  6808. @subsection File Search
  6809. @cindex file, searching
  6810. This section documents procedures to search and filter files.
  6811. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  6812. Return a predicate that returns true when passed a file name whose base
  6813. name matches @var{regexp}.
  6814. @end deffn
  6815. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  6816. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  6817. Return the lexicographically sorted list of files under @var{dir} for
  6818. which @var{pred} returns true. @var{pred} is passed two arguments: the
  6819. absolute file name, and its stat buffer; the default predicate always
  6820. returns true. @var{pred} can also be a regular expression, in which
  6821. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  6822. @var{stat} is used to obtain file information; using @code{lstat} means
  6823. that symlinks are not followed. If @var{directories?} is true, then
  6824. directories will also be included. If @var{fail-on-error?} is true,
  6825. raise an exception upon error.
  6826. @end deffn
  6827. Here are a few examples where we assume that the current directory is
  6828. the root of the Guix source tree:
  6829. @lisp
  6830. ;; List all the regular files in the current directory.
  6831. (find-files ".")
  6832. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  6833. ;; List all the .scm files under gnu/services.
  6834. (find-files "gnu/services" "\\.scm$")
  6835. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  6836. ;; List ar files in the current directory.
  6837. (find-files "." (lambda (file stat) (ar-file? file)))
  6838. @result{} ("./libformat.a" "./libstore.a" @dots{})
  6839. @end lisp
  6840. @deffn {Scheme Procedure} which @var{program}
  6841. Return the complete file name for @var{program} as found in
  6842. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  6843. @end deffn
  6844. @subsection Build Phases
  6845. @cindex build phases
  6846. The @code{(guix build utils)} also contains tools to manipulate build
  6847. phases as used by build systems (@pxref{Build Systems}). Build phases
  6848. are represented as association lists or ``alists'' (@pxref{Association
  6849. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  6850. naming the phase and the associated value is a procedure (@pxref{Build
  6851. Phases}).
  6852. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  6853. manipulate alists. The @code{(guix build utils)} module complements
  6854. those with tools written with build phases in mind.
  6855. @cindex build phases, modifying
  6856. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  6857. Modify @var{phases} sequentially as per each @var{clause}, which may
  6858. have one of the following forms:
  6859. @lisp
  6860. (delete @var{old-phase-name})
  6861. (replace @var{old-phase-name} @var{new-phase})
  6862. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  6863. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  6864. @end lisp
  6865. Where every @var{phase-name} above is an expression evaluating to a
  6866. symbol, and @var{new-phase} an expression evaluating to a procedure.
  6867. @end deffn
  6868. The example below is taken from the definition of the @code{grep}
  6869. package. It adds a phase to run after the @code{install} phase, called
  6870. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  6871. is for anonymous procedures) that takes a @code{#:outputs} keyword
  6872. argument and ignores extra keyword arguments (@pxref{Optional
  6873. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  6874. @code{lambda*} and optional and keyword arguments.) The phase uses
  6875. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  6876. scripts so that they refer to @code{grep} by its absolute file name:
  6877. @lisp
  6878. (modify-phases %standard-phases
  6879. (add-after 'install 'fix-egrep-and-fgrep
  6880. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  6881. ;; absolute file name instead of searching for it in $PATH.
  6882. (lambda* (#:key outputs #:allow-other-keys)
  6883. (let* ((out (assoc-ref outputs "out"))
  6884. (bin (string-append out "/bin")))
  6885. (substitute* (list (string-append bin "/egrep")
  6886. (string-append bin "/fgrep"))
  6887. (("^exec grep")
  6888. (string-append "exec " bin "/grep")))
  6889. #t))))
  6890. @end lisp
  6891. In the example below, phases are modified in two ways: the standard
  6892. @code{configure} phase is deleted, presumably because the package does
  6893. not have a @file{configure} script or anything similar, and the default
  6894. @code{install} phase is replaced by one that manually copies the
  6895. executable files to be installed:
  6896. @lisp
  6897. (modify-phases %standard-phases
  6898. (delete 'configure) ;no 'configure' script
  6899. (replace 'install
  6900. (lambda* (#:key outputs #:allow-other-keys)
  6901. ;; The package's Makefile doesn't provide an "install"
  6902. ;; rule so do it by ourselves.
  6903. (let ((bin (string-append (assoc-ref outputs "out")
  6904. "/bin")))
  6905. (install-file "footswitch" bin)
  6906. (install-file "scythe" bin)
  6907. #t))))
  6908. @end lisp
  6909. @c TODO: Add more examples.
  6910. @node The Store
  6911. @section The Store
  6912. @cindex store
  6913. @cindex store items
  6914. @cindex store paths
  6915. Conceptually, the @dfn{store} is the place where derivations that have
  6916. been built successfully are stored---by default, @file{/gnu/store}.
  6917. Sub-directories in the store are referred to as @dfn{store items} or
  6918. sometimes @dfn{store paths}. The store has an associated database that
  6919. contains information such as the store paths referred to by each store
  6920. path, and the list of @emph{valid} store items---results of successful
  6921. builds. This database resides in @file{@var{localstatedir}/guix/db},
  6922. where @var{localstatedir} is the state directory specified @i{via}
  6923. @option{--localstatedir} at configure time, usually @file{/var}.
  6924. The store is @emph{always} accessed by the daemon on behalf of its clients
  6925. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  6926. connect to the daemon over a Unix-domain socket, send requests to it,
  6927. and read the result---these are remote procedure calls, or RPCs.
  6928. @quotation Note
  6929. Users must @emph{never} modify files under @file{/gnu/store} directly.
  6930. This would lead to inconsistencies and break the immutability
  6931. assumptions of Guix's functional model (@pxref{Introduction}).
  6932. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  6933. how to check the integrity of the store and attempt recovery from
  6934. accidental modifications.
  6935. @end quotation
  6936. The @code{(guix store)} module provides procedures to connect to the
  6937. daemon, and to perform RPCs. These are described below. By default,
  6938. @code{open-connection}, and thus all the @command{guix} commands,
  6939. connect to the local daemon or to the URI specified by the
  6940. @env{GUIX_DAEMON_SOCKET} environment variable.
  6941. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  6942. When set, the value of this variable should be a file name or a URI
  6943. designating the daemon endpoint. When it is a file name, it denotes a
  6944. Unix-domain socket to connect to. In addition to file names, the
  6945. supported URI schemes are:
  6946. @table @code
  6947. @item file
  6948. @itemx unix
  6949. These are for Unix-domain sockets.
  6950. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  6951. @file{/var/guix/daemon-socket/socket}.
  6952. @item guix
  6953. @cindex daemon, remote access
  6954. @cindex remote access to the daemon
  6955. @cindex daemon, cluster setup
  6956. @cindex clusters, daemon setup
  6957. These URIs denote connections over TCP/IP, without encryption nor
  6958. authentication of the remote host. The URI must specify the host name
  6959. and optionally a port number (by default port 44146 is used):
  6960. @example
  6961. guix://master.guix.example.org:1234
  6962. @end example
  6963. This setup is suitable on local networks, such as clusters, where only
  6964. trusted nodes may connect to the build daemon at
  6965. @code{master.guix.example.org}.
  6966. The @option{--listen} option of @command{guix-daemon} can be used to
  6967. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  6968. @option{--listen}}).
  6969. @item ssh
  6970. @cindex SSH access to build daemons
  6971. These URIs allow you to connect to a remote daemon over SSH@. This
  6972. feature requires Guile-SSH (@pxref{Requirements}) and a working
  6973. @command{guile} binary in @env{PATH} on the destination machine. It
  6974. supports public key and GSSAPI authentication. A typical URL might look
  6975. like this:
  6976. @example
  6977. ssh://charlie@@guix.example.org:22
  6978. @end example
  6979. As for @command{guix copy}, the usual OpenSSH client configuration files
  6980. are honored (@pxref{Invoking guix copy}).
  6981. @end table
  6982. Additional URI schemes may be supported in the future.
  6983. @c XXX: Remove this note when the protocol incurs fewer round trips
  6984. @c and when (guix derivations) no longer relies on file system access.
  6985. @quotation Note
  6986. The ability to connect to remote build daemons is considered
  6987. experimental as of @value{VERSION}. Please get in touch with us to
  6988. share any problems or suggestions you may have (@pxref{Contributing}).
  6989. @end quotation
  6990. @end defvr
  6991. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  6992. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  6993. @var{reserve-space?} is true, instruct it to reserve a little bit of
  6994. extra space on the file system so that the garbage collector can still
  6995. operate should the disk become full. Return a server object.
  6996. @var{file} defaults to @code{%default-socket-path}, which is the normal
  6997. location given the options that were passed to @command{configure}.
  6998. @end deffn
  6999. @deffn {Scheme Procedure} close-connection @var{server}
  7000. Close the connection to @var{server}.
  7001. @end deffn
  7002. @defvr {Scheme Variable} current-build-output-port
  7003. This variable is bound to a SRFI-39 parameter, which refers to the port
  7004. where build and error logs sent by the daemon should be written.
  7005. @end defvr
  7006. Procedures that make RPCs all take a server object as their first
  7007. argument.
  7008. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  7009. @cindex invalid store items
  7010. Return @code{#t} when @var{path} designates a valid store item and
  7011. @code{#f} otherwise (an invalid item may exist on disk but still be
  7012. invalid, for instance because it is the result of an aborted or failed
  7013. build).
  7014. A @code{&store-protocol-error} condition is raised if @var{path} is not
  7015. prefixed by the store directory (@file{/gnu/store}).
  7016. @end deffn
  7017. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  7018. Add @var{text} under file @var{name} in the store, and return its store
  7019. path. @var{references} is the list of store paths referred to by the
  7020. resulting store path.
  7021. @end deffn
  7022. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  7023. [@var{mode}]
  7024. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  7025. file names, or derivation/output pairs, using the specified
  7026. @var{mode}---@code{(build-mode normal)} by default.
  7027. @end deffn
  7028. Note that the @code{(guix monads)} module provides a monad as well as
  7029. monadic versions of the above procedures, with the goal of making it
  7030. more convenient to work with code that accesses the store (@pxref{The
  7031. Store Monad}).
  7032. @c FIXME
  7033. @i{This section is currently incomplete.}
  7034. @node Derivations
  7035. @section Derivations
  7036. @cindex derivations
  7037. Low-level build actions and the environment in which they are performed
  7038. are represented by @dfn{derivations}. A derivation contains the
  7039. following pieces of information:
  7040. @itemize
  7041. @item
  7042. The outputs of the derivation---derivations produce at least one file or
  7043. directory in the store, but may produce more.
  7044. @item
  7045. @cindex build-time dependencies
  7046. @cindex dependencies, build-time
  7047. The inputs of the derivations---i.e., its build-time dependencies---which may
  7048. be other derivations or plain files in the store (patches, build scripts,
  7049. etc.).
  7050. @item
  7051. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  7052. @item
  7053. The file name of a build script in the store, along with the arguments
  7054. to be passed.
  7055. @item
  7056. A list of environment variables to be defined.
  7057. @end itemize
  7058. @cindex derivation path
  7059. Derivations allow clients of the daemon to communicate build actions to
  7060. the store. They exist in two forms: as an in-memory representation,
  7061. both on the client- and daemon-side, and as files in the store whose
  7062. name end in @file{.drv}---these files are referred to as @dfn{derivation
  7063. paths}. Derivations paths can be passed to the @code{build-derivations}
  7064. procedure to perform the build actions they prescribe (@pxref{The
  7065. Store}).
  7066. @cindex fixed-output derivations
  7067. Operations such as file downloads and version-control checkouts for
  7068. which the expected content hash is known in advance are modeled as
  7069. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  7070. of a fixed-output derivation are independent of its inputs---e.g., a
  7071. source code download produces the same result regardless of the download
  7072. method and tools being used.
  7073. @cindex references
  7074. @cindex run-time dependencies
  7075. @cindex dependencies, run-time
  7076. The outputs of derivations---i.e., the build results---have a set of
  7077. @dfn{references}, as reported by the @code{references} RPC or the
  7078. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  7079. are the set of run-time dependencies of the build results. References are a
  7080. subset of the inputs of the derivation; this subset is automatically computed
  7081. by the build daemon by scanning all the files in the outputs.
  7082. The @code{(guix derivations)} module provides a representation of
  7083. derivations as Scheme objects, along with procedures to create and
  7084. otherwise manipulate derivations. The lowest-level primitive to create
  7085. a derivation is the @code{derivation} procedure:
  7086. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  7087. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7088. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  7089. [#:system (%current-system)] [#:references-graphs #f] @
  7090. [#:allowed-references #f] [#:disallowed-references #f] @
  7091. [#:leaked-env-vars #f] [#:local-build? #f] @
  7092. [#:substitutable? #t] [#:properties '()]
  7093. Build a derivation with the given arguments, and return the resulting
  7094. @code{<derivation>} object.
  7095. When @var{hash} and @var{hash-algo} are given, a
  7096. @dfn{fixed-output derivation} is created---i.e., one whose result is
  7097. known in advance, such as a file download. If, in addition,
  7098. @var{recursive?} is true, then that fixed output may be an executable
  7099. file or a directory and @var{hash} must be the hash of an archive
  7100. containing this output.
  7101. When @var{references-graphs} is true, it must be a list of file
  7102. name/store path pairs. In that case, the reference graph of each store
  7103. path is exported in the build environment in the corresponding file, in
  7104. a simple text format.
  7105. When @var{allowed-references} is true, it must be a list of store items
  7106. or outputs that the derivation's output may refer to. Likewise,
  7107. @var{disallowed-references}, if true, must be a list of things the
  7108. outputs may @emph{not} refer to.
  7109. When @var{leaked-env-vars} is true, it must be a list of strings
  7110. denoting environment variables that are allowed to ``leak'' from the
  7111. daemon's environment to the build environment. This is only applicable
  7112. to fixed-output derivations---i.e., when @var{hash} is true. The main
  7113. use is to allow variables such as @code{http_proxy} to be passed to
  7114. derivations that download files.
  7115. When @var{local-build?} is true, declare that the derivation is not a
  7116. good candidate for offloading and should rather be built locally
  7117. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  7118. where the costs of data transfers would outweigh the benefits.
  7119. When @var{substitutable?} is false, declare that substitutes of the
  7120. derivation's output should not be used (@pxref{Substitutes}). This is
  7121. useful, for instance, when building packages that capture details of the
  7122. host CPU instruction set.
  7123. @var{properties} must be an association list describing ``properties'' of the
  7124. derivation. It is kept as-is, uninterpreted, in the derivation.
  7125. @end deffn
  7126. @noindent
  7127. Here's an example with a shell script as its builder, assuming
  7128. @var{store} is an open connection to the daemon, and @var{bash} points
  7129. to a Bash executable in the store:
  7130. @lisp
  7131. (use-modules (guix utils)
  7132. (guix store)
  7133. (guix derivations))
  7134. (let ((builder ; add the Bash script to the store
  7135. (add-text-to-store store "my-builder.sh"
  7136. "echo hello world > $out\n" '())))
  7137. (derivation store "foo"
  7138. bash `("-e" ,builder)
  7139. #:inputs `((,bash) (,builder))
  7140. #:env-vars '(("HOME" . "/homeless"))))
  7141. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  7142. @end lisp
  7143. As can be guessed, this primitive is cumbersome to use directly. A
  7144. better approach is to write build scripts in Scheme, of course! The
  7145. best course of action for that is to write the build code as a
  7146. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  7147. information, @pxref{G-Expressions}.
  7148. Once upon a time, @code{gexp->derivation} did not exist and constructing
  7149. derivations with build code written in Scheme was achieved with
  7150. @code{build-expression->derivation}, documented below. This procedure
  7151. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  7152. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  7153. @var{name} @var{exp} @
  7154. [#:system (%current-system)] [#:inputs '()] @
  7155. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7156. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7157. [#:references-graphs #f] [#:allowed-references #f] @
  7158. [#:disallowed-references #f] @
  7159. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  7160. Return a derivation that executes Scheme expression @var{exp} as a
  7161. builder for derivation @var{name}. @var{inputs} must be a list of
  7162. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  7163. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  7164. modules from the current search path to be copied in the store,
  7165. compiled, and made available in the load path during the execution of
  7166. @var{exp}---e.g., @code{((guix build utils) (guix build
  7167. gnu-build-system))}.
  7168. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  7169. to a list of output/path pairs, and where @code{%build-inputs} is bound
  7170. to a list of string/output-path pairs made from @var{inputs}.
  7171. Optionally, @var{env-vars} is a list of string pairs specifying the name
  7172. and value of environment variables visible to the builder. The builder
  7173. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  7174. @var{exp} returns @code{#f}, the build is considered to have failed.
  7175. @var{exp} is built using @var{guile-for-build} (a derivation). When
  7176. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  7177. @code{%guile-for-build} fluid is used instead.
  7178. See the @code{derivation} procedure for the meaning of
  7179. @var{references-graphs}, @var{allowed-references},
  7180. @var{disallowed-references}, @var{local-build?}, and
  7181. @var{substitutable?}.
  7182. @end deffn
  7183. @noindent
  7184. Here's an example of a single-output derivation that creates a directory
  7185. containing one file:
  7186. @lisp
  7187. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  7188. (mkdir out) ; create /gnu/store/@dots{}-goo
  7189. (call-with-output-file (string-append out "/test")
  7190. (lambda (p)
  7191. (display '(hello guix) p))))))
  7192. (build-expression->derivation store "goo" builder))
  7193. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  7194. @end lisp
  7195. @node The Store Monad
  7196. @section The Store Monad
  7197. @cindex monad
  7198. The procedures that operate on the store described in the previous
  7199. sections all take an open connection to the build daemon as their first
  7200. argument. Although the underlying model is functional, they either have
  7201. side effects or depend on the current state of the store.
  7202. The former is inconvenient: the connection to the build daemon has to be
  7203. carried around in all those functions, making it impossible to compose
  7204. functions that do not take that parameter with functions that do. The
  7205. latter can be problematic: since store operations have side effects
  7206. and/or depend on external state, they have to be properly sequenced.
  7207. @cindex monadic values
  7208. @cindex monadic functions
  7209. This is where the @code{(guix monads)} module comes in. This module
  7210. provides a framework for working with @dfn{monads}, and a particularly
  7211. useful monad for our uses, the @dfn{store monad}. Monads are a
  7212. construct that allows two things: associating ``context'' with values
  7213. (in our case, the context is the store), and building sequences of
  7214. computations (here computations include accesses to the store). Values
  7215. in a monad---values that carry this additional context---are called
  7216. @dfn{monadic values}; procedures that return such values are called
  7217. @dfn{monadic procedures}.
  7218. Consider this ``normal'' procedure:
  7219. @lisp
  7220. (define (sh-symlink store)
  7221. ;; Return a derivation that symlinks the 'bash' executable.
  7222. (let* ((drv (package-derivation store bash))
  7223. (out (derivation->output-path drv))
  7224. (sh (string-append out "/bin/bash")))
  7225. (build-expression->derivation store "sh"
  7226. `(symlink ,sh %output))))
  7227. @end lisp
  7228. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  7229. as a monadic function:
  7230. @lisp
  7231. (define (sh-symlink)
  7232. ;; Same, but return a monadic value.
  7233. (mlet %store-monad ((drv (package->derivation bash)))
  7234. (gexp->derivation "sh"
  7235. #~(symlink (string-append #$drv "/bin/bash")
  7236. #$output))))
  7237. @end lisp
  7238. There are several things to note in the second version: the @code{store}
  7239. parameter is now implicit and is ``threaded'' in the calls to the
  7240. @code{package->derivation} and @code{gexp->derivation} monadic
  7241. procedures, and the monadic value returned by @code{package->derivation}
  7242. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  7243. As it turns out, the call to @code{package->derivation} can even be
  7244. omitted since it will take place implicitly, as we will see later
  7245. (@pxref{G-Expressions}):
  7246. @lisp
  7247. (define (sh-symlink)
  7248. (gexp->derivation "sh"
  7249. #~(symlink (string-append #$bash "/bin/bash")
  7250. #$output)))
  7251. @end lisp
  7252. @c See
  7253. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  7254. @c for the funny quote.
  7255. Calling the monadic @code{sh-symlink} has no effect. As someone once
  7256. said, ``you exit a monad like you exit a building on fire: by running''.
  7257. So, to exit the monad and get the desired effect, one must use
  7258. @code{run-with-store}:
  7259. @lisp
  7260. (run-with-store (open-connection) (sh-symlink))
  7261. @result{} /gnu/store/...-sh-symlink
  7262. @end lisp
  7263. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  7264. new ``meta-commands'' to make it easier to deal with monadic procedures:
  7265. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  7266. to ``run'' a single monadic value through the store:
  7267. @example
  7268. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  7269. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7270. @end example
  7271. The latter enters a recursive REPL, where all the return values are
  7272. automatically run through the store:
  7273. @example
  7274. scheme@@(guile-user)> ,enter-store-monad
  7275. store-monad@@(guile-user) [1]> (package->derivation hello)
  7276. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7277. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  7278. $3 = "/gnu/store/@dots{}-foo"
  7279. store-monad@@(guile-user) [1]> ,q
  7280. scheme@@(guile-user)>
  7281. @end example
  7282. @noindent
  7283. Note that non-monadic values cannot be returned in the
  7284. @code{store-monad} REPL.
  7285. The main syntactic forms to deal with monads in general are provided by
  7286. the @code{(guix monads)} module and are described below.
  7287. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  7288. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  7289. in @var{monad}.
  7290. @end deffn
  7291. @deffn {Scheme Syntax} return @var{val}
  7292. Return a monadic value that encapsulates @var{val}.
  7293. @end deffn
  7294. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  7295. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  7296. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  7297. referred to as ``bind'', but that name denotes an unrelated procedure in
  7298. Guile. Thus we use this somewhat cryptic symbol inherited from the
  7299. Haskell language.}. There can be one @var{mproc} or several of them, as
  7300. in this example:
  7301. @lisp
  7302. (run-with-state
  7303. (with-monad %state-monad
  7304. (>>= (return 1)
  7305. (lambda (x) (return (+ 1 x)))
  7306. (lambda (x) (return (* 2 x)))))
  7307. 'some-state)
  7308. @result{} 4
  7309. @result{} some-state
  7310. @end lisp
  7311. @end deffn
  7312. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  7313. @var{body} ...
  7314. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  7315. @var{body} ...
  7316. Bind the variables @var{var} to the monadic values @var{mval} in
  7317. @var{body}, which is a sequence of expressions. As with the bind
  7318. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  7319. value ``contained'' in @var{mval} and making @var{var} refer to that
  7320. raw, non-monadic value within the scope of the @var{body}. The form
  7321. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  7322. @var{val}, as per @code{let}. The binding operations occur in sequence
  7323. from left to right. The last expression of @var{body} must be a monadic
  7324. expression, and its result will become the result of the @code{mlet} or
  7325. @code{mlet*} when run in the @var{monad}.
  7326. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  7327. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  7328. @end deffn
  7329. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  7330. Bind @var{mexp} and the following monadic expressions in sequence,
  7331. returning the result of the last expression. Every expression in the
  7332. sequence must be a monadic expression.
  7333. This is akin to @code{mlet}, except that the return values of the
  7334. monadic expressions are ignored. In that sense, it is analogous to
  7335. @code{begin}, but applied to monadic expressions.
  7336. @end deffn
  7337. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  7338. When @var{condition} is true, evaluate the sequence of monadic
  7339. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7340. @var{condition} is false, return @code{*unspecified*} in the current
  7341. monad. Every expression in the sequence must be a monadic expression.
  7342. @end deffn
  7343. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  7344. When @var{condition} is false, evaluate the sequence of monadic
  7345. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7346. @var{condition} is true, return @code{*unspecified*} in the current
  7347. monad. Every expression in the sequence must be a monadic expression.
  7348. @end deffn
  7349. @cindex state monad
  7350. The @code{(guix monads)} module provides the @dfn{state monad}, which
  7351. allows an additional value---the state---to be @emph{threaded} through
  7352. monadic procedure calls.
  7353. @defvr {Scheme Variable} %state-monad
  7354. The state monad. Procedures in the state monad can access and change
  7355. the state that is threaded.
  7356. Consider the example below. The @code{square} procedure returns a value
  7357. in the state monad. It returns the square of its argument, but also
  7358. increments the current state value:
  7359. @lisp
  7360. (define (square x)
  7361. (mlet %state-monad ((count (current-state)))
  7362. (mbegin %state-monad
  7363. (set-current-state (+ 1 count))
  7364. (return (* x x)))))
  7365. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  7366. @result{} (0 1 4)
  7367. @result{} 3
  7368. @end lisp
  7369. When ``run'' through @code{%state-monad}, we obtain that additional state
  7370. value, which is the number of @code{square} calls.
  7371. @end defvr
  7372. @deffn {Monadic Procedure} current-state
  7373. Return the current state as a monadic value.
  7374. @end deffn
  7375. @deffn {Monadic Procedure} set-current-state @var{value}
  7376. Set the current state to @var{value} and return the previous state as a
  7377. monadic value.
  7378. @end deffn
  7379. @deffn {Monadic Procedure} state-push @var{value}
  7380. Push @var{value} to the current state, which is assumed to be a list,
  7381. and return the previous state as a monadic value.
  7382. @end deffn
  7383. @deffn {Monadic Procedure} state-pop
  7384. Pop a value from the current state and return it as a monadic value.
  7385. The state is assumed to be a list.
  7386. @end deffn
  7387. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  7388. Run monadic value @var{mval} starting with @var{state} as the initial
  7389. state. Return two values: the resulting value, and the resulting state.
  7390. @end deffn
  7391. The main interface to the store monad, provided by the @code{(guix
  7392. store)} module, is as follows.
  7393. @defvr {Scheme Variable} %store-monad
  7394. The store monad---an alias for @code{%state-monad}.
  7395. Values in the store monad encapsulate accesses to the store. When its
  7396. effect is needed, a value of the store monad must be ``evaluated'' by
  7397. passing it to the @code{run-with-store} procedure (see below).
  7398. @end defvr
  7399. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  7400. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  7401. open store connection.
  7402. @end deffn
  7403. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  7404. Return as a monadic value the absolute file name in the store of the file
  7405. containing @var{text}, a string. @var{references} is a list of store items that the
  7406. resulting text file refers to; it defaults to the empty list.
  7407. @end deffn
  7408. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  7409. Return as a monadic value the absolute file name in the store of the file
  7410. containing @var{data}, a bytevector. @var{references} is a list of store
  7411. items that the resulting binary file refers to; it defaults to the empty list.
  7412. @end deffn
  7413. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  7414. [#:recursive? #t] [#:select? (const #t)]
  7415. Return the name of @var{file} once interned in the store. Use
  7416. @var{name} as its store name, or the basename of @var{file} if
  7417. @var{name} is omitted.
  7418. When @var{recursive?} is true, the contents of @var{file} are added
  7419. recursively; if @var{file} designates a flat file and @var{recursive?}
  7420. is true, its contents are added, and its permission bits are kept.
  7421. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7422. @var{stat})} for each directory entry, where @var{file} is the entry's
  7423. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7424. entries for which @var{select?} does not return true.
  7425. The example below adds a file to the store, under two different names:
  7426. @lisp
  7427. (run-with-store (open-connection)
  7428. (mlet %store-monad ((a (interned-file "README"))
  7429. (b (interned-file "README" "LEGU-MIN")))
  7430. (return (list a b))))
  7431. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  7432. @end lisp
  7433. @end deffn
  7434. The @code{(guix packages)} module exports the following package-related
  7435. monadic procedures:
  7436. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  7437. [#:system (%current-system)] [#:target #f] @
  7438. [#:output "out"]
  7439. Return as a monadic
  7440. value in the absolute file name of @var{file} within the @var{output}
  7441. directory of @var{package}. When @var{file} is omitted, return the name
  7442. of the @var{output} directory of @var{package}. When @var{target} is
  7443. true, use it as a cross-compilation target triplet.
  7444. Note that this procedure does @emph{not} build @var{package}. Thus, the
  7445. result might or might not designate an existing file. We recommend not
  7446. using this procedure unless you know what you are doing.
  7447. @end deffn
  7448. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  7449. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  7450. @var{target} [@var{system}]
  7451. Monadic version of @code{package-derivation} and
  7452. @code{package-cross-derivation} (@pxref{Defining Packages}).
  7453. @end deffn
  7454. @node G-Expressions
  7455. @section G-Expressions
  7456. @cindex G-expression
  7457. @cindex build code quoting
  7458. So we have ``derivations'', which represent a sequence of build actions
  7459. to be performed to produce an item in the store (@pxref{Derivations}).
  7460. These build actions are performed when asking the daemon to actually
  7461. build the derivations; they are run by the daemon in a container
  7462. (@pxref{Invoking guix-daemon}).
  7463. @cindex code staging
  7464. @cindex staging, of code
  7465. @cindex strata of code
  7466. It should come as no surprise that we like to write these build actions
  7467. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  7468. code@footnote{The term @dfn{stratum} in this context was coined by
  7469. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  7470. Kiselyov, who has written insightful
  7471. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  7472. on this topic}, refers to this kind of code generation as
  7473. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  7474. to the daemon, etc.---and the ``build code''---code that actually
  7475. performs build actions, such as making directories, invoking
  7476. @command{make}, and so on (@pxref{Build Phases}).
  7477. To describe a derivation and its build actions, one typically needs to
  7478. embed build code inside host code. It boils down to manipulating build
  7479. code as data, and the homoiconicity of Scheme---code has a direct
  7480. representation as data---comes in handy for that. But we need more than
  7481. the normal @code{quasiquote} mechanism in Scheme to construct build
  7482. expressions.
  7483. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  7484. S-expressions adapted to build expressions. G-expressions, or
  7485. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  7486. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  7487. @code{#$}, and @code{#$@@}), which are comparable to
  7488. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  7489. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  7490. GNU Guile Reference Manual}). However, there are major differences:
  7491. @itemize
  7492. @item
  7493. Gexps are meant to be written to a file and run or manipulated by other
  7494. processes.
  7495. @item
  7496. When a high-level object such as a package or derivation is unquoted
  7497. inside a gexp, the result is as if its output file name had been
  7498. introduced.
  7499. @item
  7500. Gexps carry information about the packages or derivations they refer to,
  7501. and these dependencies are automatically added as inputs to the build
  7502. processes that use them.
  7503. @end itemize
  7504. @cindex lowering, of high-level objects in gexps
  7505. This mechanism is not limited to package and derivation
  7506. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  7507. derivations or files in the store can be defined,
  7508. such that these objects can also be inserted
  7509. into gexps. For example, a useful type of high-level objects that can be
  7510. inserted in a gexp is ``file-like objects'', which make it easy to
  7511. add files to the store and to refer to them in
  7512. derivations and such (see @code{local-file} and @code{plain-file}
  7513. below).
  7514. To illustrate the idea, here is an example of a gexp:
  7515. @lisp
  7516. (define build-exp
  7517. #~(begin
  7518. (mkdir #$output)
  7519. (chdir #$output)
  7520. (symlink (string-append #$coreutils "/bin/ls")
  7521. "list-files")))
  7522. @end lisp
  7523. This gexp can be passed to @code{gexp->derivation}; we obtain a
  7524. derivation that builds a directory containing exactly one symlink to
  7525. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  7526. @lisp
  7527. (gexp->derivation "the-thing" build-exp)
  7528. @end lisp
  7529. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  7530. substituted to the reference to the @var{coreutils} package in the
  7531. actual build code, and @var{coreutils} is automatically made an input to
  7532. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  7533. output)}) is replaced by a string containing the directory name of the
  7534. output of the derivation.
  7535. @cindex cross compilation
  7536. In a cross-compilation context, it is useful to distinguish between
  7537. references to the @emph{native} build of a package---that can run on the
  7538. host---versus references to cross builds of a package. To that end, the
  7539. @code{#+} plays the same role as @code{#$}, but is a reference to a
  7540. native package build:
  7541. @lisp
  7542. (gexp->derivation "vi"
  7543. #~(begin
  7544. (mkdir #$output)
  7545. (mkdir (string-append #$output "/bin"))
  7546. (system* (string-append #+coreutils "/bin/ln")
  7547. "-s"
  7548. (string-append #$emacs "/bin/emacs")
  7549. (string-append #$output "/bin/vi")))
  7550. #:target "aarch64-linux-gnu")
  7551. @end lisp
  7552. @noindent
  7553. In the example above, the native build of @var{coreutils} is used, so
  7554. that @command{ln} can actually run on the host; but then the
  7555. cross-compiled build of @var{emacs} is referenced.
  7556. @cindex imported modules, for gexps
  7557. @findex with-imported-modules
  7558. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  7559. able to use certain Guile modules from the ``host environment'' in the
  7560. gexp, so those modules should be imported in the ``build environment''.
  7561. The @code{with-imported-modules} form allows you to express that:
  7562. @lisp
  7563. (let ((build (with-imported-modules '((guix build utils))
  7564. #~(begin
  7565. (use-modules (guix build utils))
  7566. (mkdir-p (string-append #$output "/bin"))))))
  7567. (gexp->derivation "empty-dir"
  7568. #~(begin
  7569. #$build
  7570. (display "success!\n")
  7571. #t)))
  7572. @end lisp
  7573. @noindent
  7574. In this example, the @code{(guix build utils)} module is automatically
  7575. pulled into the isolated build environment of our gexp, such that
  7576. @code{(use-modules (guix build utils))} works as expected.
  7577. @cindex module closure
  7578. @findex source-module-closure
  7579. Usually you want the @emph{closure} of the module to be imported---i.e.,
  7580. the module itself and all the modules it depends on---rather than just
  7581. the module; failing to do that, attempts to use the module will fail
  7582. because of missing dependent modules. The @code{source-module-closure}
  7583. procedure computes the closure of a module by looking at its source file
  7584. headers, which comes in handy in this case:
  7585. @lisp
  7586. (use-modules (guix modules)) ;for 'source-module-closure'
  7587. (with-imported-modules (source-module-closure
  7588. '((guix build utils)
  7589. (gnu build vm)))
  7590. (gexp->derivation "something-with-vms"
  7591. #~(begin
  7592. (use-modules (guix build utils)
  7593. (gnu build vm))
  7594. @dots{})))
  7595. @end lisp
  7596. @cindex extensions, for gexps
  7597. @findex with-extensions
  7598. In the same vein, sometimes you want to import not just pure-Scheme
  7599. modules, but also ``extensions'' such as Guile bindings to C libraries
  7600. or other ``full-blown'' packages. Say you need the @code{guile-json}
  7601. package available on the build side, here's how you would do it:
  7602. @lisp
  7603. (use-modules (gnu packages guile)) ;for 'guile-json'
  7604. (with-extensions (list guile-json)
  7605. (gexp->derivation "something-with-json"
  7606. #~(begin
  7607. (use-modules (json))
  7608. @dots{})))
  7609. @end lisp
  7610. The syntactic form to construct gexps is summarized below.
  7611. @deffn {Scheme Syntax} #~@var{exp}
  7612. @deffnx {Scheme Syntax} (gexp @var{exp})
  7613. Return a G-expression containing @var{exp}. @var{exp} may contain one
  7614. or more of the following forms:
  7615. @table @code
  7616. @item #$@var{obj}
  7617. @itemx (ungexp @var{obj})
  7618. Introduce a reference to @var{obj}. @var{obj} may have one of the
  7619. supported types, for example a package or a
  7620. derivation, in which case the @code{ungexp} form is replaced by its
  7621. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  7622. If @var{obj} is a list, it is traversed and references to supported
  7623. objects are substituted similarly.
  7624. If @var{obj} is another gexp, its contents are inserted and its
  7625. dependencies are added to those of the containing gexp.
  7626. If @var{obj} is another kind of object, it is inserted as is.
  7627. @item #$@var{obj}:@var{output}
  7628. @itemx (ungexp @var{obj} @var{output})
  7629. This is like the form above, but referring explicitly to the
  7630. @var{output} of @var{obj}---this is useful when @var{obj} produces
  7631. multiple outputs (@pxref{Packages with Multiple Outputs}).
  7632. @item #+@var{obj}
  7633. @itemx #+@var{obj}:output
  7634. @itemx (ungexp-native @var{obj})
  7635. @itemx (ungexp-native @var{obj} @var{output})
  7636. Same as @code{ungexp}, but produces a reference to the @emph{native}
  7637. build of @var{obj} when used in a cross compilation context.
  7638. @item #$output[:@var{output}]
  7639. @itemx (ungexp output [@var{output}])
  7640. Insert a reference to derivation output @var{output}, or to the main
  7641. output when @var{output} is omitted.
  7642. This only makes sense for gexps passed to @code{gexp->derivation}.
  7643. @item #$@@@var{lst}
  7644. @itemx (ungexp-splicing @var{lst})
  7645. Like the above, but splices the contents of @var{lst} inside the
  7646. containing list.
  7647. @item #+@@@var{lst}
  7648. @itemx (ungexp-native-splicing @var{lst})
  7649. Like the above, but refers to native builds of the objects listed in
  7650. @var{lst}.
  7651. @end table
  7652. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  7653. of the @code{gexp?} type (see below).
  7654. @end deffn
  7655. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  7656. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  7657. in their execution environment.
  7658. Each item in @var{modules} can be the name of a module, such as
  7659. @code{(guix build utils)}, or it can be a module name, followed by an
  7660. arrow, followed by a file-like object:
  7661. @lisp
  7662. `((guix build utils)
  7663. (guix gcrypt)
  7664. ((guix config) => ,(scheme-file "config.scm"
  7665. #~(define-module @dots{}))))
  7666. @end lisp
  7667. @noindent
  7668. In the example above, the first two modules are taken from the search
  7669. path, and the last one is created from the given file-like object.
  7670. This form has @emph{lexical} scope: it has an effect on the gexps
  7671. directly defined in @var{body}@dots{}, but not on those defined, say, in
  7672. procedures called from @var{body}@dots{}.
  7673. @end deffn
  7674. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  7675. Mark the gexps defined in @var{body}@dots{} as requiring
  7676. @var{extensions} in their build and execution environment.
  7677. @var{extensions} is typically a list of package objects such as those
  7678. defined in the @code{(gnu packages guile)} module.
  7679. Concretely, the packages listed in @var{extensions} are added to the
  7680. load path while compiling imported modules in @var{body}@dots{}; they
  7681. are also added to the load path of the gexp returned by
  7682. @var{body}@dots{}.
  7683. @end deffn
  7684. @deffn {Scheme Procedure} gexp? @var{obj}
  7685. Return @code{#t} if @var{obj} is a G-expression.
  7686. @end deffn
  7687. G-expressions are meant to be written to disk, either as code building
  7688. some derivation, or as plain files in the store. The monadic procedures
  7689. below allow you to do that (@pxref{The Store Monad}, for more
  7690. information about monads).
  7691. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  7692. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  7693. [#:hash #f] [#:hash-algo #f] @
  7694. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7695. [#:module-path @code{%load-path}] @
  7696. [#:effective-version "2.2"] @
  7697. [#:references-graphs #f] [#:allowed-references #f] @
  7698. [#:disallowed-references #f] @
  7699. [#:leaked-env-vars #f] @
  7700. [#:script-name (string-append @var{name} "-builder")] @
  7701. [#:deprecation-warnings #f] @
  7702. [#:local-build? #f] [#:substitutable? #t] @
  7703. [#:properties '()] [#:guile-for-build #f]
  7704. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  7705. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  7706. stored in a file called @var{script-name}. When @var{target} is true,
  7707. it is used as the cross-compilation target triplet for packages referred
  7708. to by @var{exp}.
  7709. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  7710. Its meaning is to
  7711. make @var{modules} available in the evaluation context of @var{exp};
  7712. @var{modules} is a list of names of Guile modules searched in
  7713. @var{module-path} to be copied in the store, compiled, and made available in
  7714. the load path during the execution of @var{exp}---e.g., @code{((guix
  7715. build utils) (guix build gnu-build-system))}.
  7716. @var{effective-version} determines the string to use when adding extensions of
  7717. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  7718. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  7719. applicable.
  7720. When @var{references-graphs} is true, it must be a list of tuples of one of the
  7721. following forms:
  7722. @example
  7723. (@var{file-name} @var{package})
  7724. (@var{file-name} @var{package} @var{output})
  7725. (@var{file-name} @var{derivation})
  7726. (@var{file-name} @var{derivation} @var{output})
  7727. (@var{file-name} @var{store-item})
  7728. @end example
  7729. The right-hand-side of each element of @var{references-graphs} is automatically made
  7730. an input of the build process of @var{exp}. In the build environment, each
  7731. @var{file-name} contains the reference graph of the corresponding item, in a simple
  7732. text format.
  7733. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  7734. In the latter case, the list denotes store items that the result is allowed to
  7735. refer to. Any reference to another store item will lead to a build error.
  7736. Similarly for @var{disallowed-references}, which can list items that must not be
  7737. referenced by the outputs.
  7738. @var{deprecation-warnings} determines whether to show deprecation warnings while
  7739. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  7740. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  7741. @end deffn
  7742. @cindex file-like objects
  7743. The @code{local-file}, @code{plain-file}, @code{computed-file},
  7744. @code{program-file}, and @code{scheme-file} procedures below return
  7745. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  7746. these objects lead to a file in the store. Consider this G-expression:
  7747. @lisp
  7748. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  7749. #$(local-file "/tmp/my-nscd.conf"))
  7750. @end lisp
  7751. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  7752. to the store. Once expanded, for instance @i{via}
  7753. @code{gexp->derivation}, the G-expression refers to that copy under
  7754. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  7755. does not have any effect on what the G-expression does.
  7756. @code{plain-file} can be used similarly; it differs in that the file
  7757. content is directly passed as a string.
  7758. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  7759. [#:recursive? #f] [#:select? (const #t)]
  7760. Return an object representing local file @var{file} to add to the store;
  7761. this object can be used in a gexp. If @var{file} is a literal string
  7762. denoting a relative file name, it is looked up relative to the source
  7763. file where it appears; if @var{file} is not a literal string, it is
  7764. looked up relative to the current working directory at run time.
  7765. @var{file} will be added to the store under @var{name}--by default the
  7766. base name of @var{file}.
  7767. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  7768. designates a flat file and @var{recursive?} is true, its contents are added, and its
  7769. permission bits are kept.
  7770. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7771. @var{stat})} for each directory entry, where @var{file} is the entry's
  7772. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7773. entries for which @var{select?} does not return true.
  7774. This is the declarative counterpart of the @code{interned-file} monadic
  7775. procedure (@pxref{The Store Monad, @code{interned-file}}).
  7776. @end deffn
  7777. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  7778. Return an object representing a text file called @var{name} with the given
  7779. @var{content} (a string or a bytevector) to be added to the store.
  7780. This is the declarative counterpart of @code{text-file}.
  7781. @end deffn
  7782. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  7783. [#:local-build? #t]
  7784. [#:options '()]
  7785. Return an object representing the store item @var{name}, a file or
  7786. directory computed by @var{gexp}. When @var{local-build?} is true (the
  7787. default), the derivation is built locally. @var{options} is a list of
  7788. additional arguments to pass to @code{gexp->derivation}.
  7789. This is the declarative counterpart of @code{gexp->derivation}.
  7790. @end deffn
  7791. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  7792. [#:guile (default-guile)] [#:module-path %load-path] @
  7793. [#:system (%current-system)] [#:target #f]
  7794. Return an executable script @var{name} that runs @var{exp} using
  7795. @var{guile}, with @var{exp}'s imported modules in its search path.
  7796. Look up @var{exp}'s modules in @var{module-path}.
  7797. The example below builds a script that simply invokes the @command{ls}
  7798. command:
  7799. @lisp
  7800. (use-modules (guix gexp) (gnu packages base))
  7801. (gexp->script "list-files"
  7802. #~(execl #$(file-append coreutils "/bin/ls")
  7803. "ls"))
  7804. @end lisp
  7805. When ``running'' it through the store (@pxref{The Store Monad,
  7806. @code{run-with-store}}), we obtain a derivation that produces an
  7807. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  7808. @example
  7809. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  7810. !#
  7811. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  7812. @end example
  7813. @end deffn
  7814. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  7815. [#:guile #f] [#:module-path %load-path]
  7816. Return an object representing the executable store item @var{name} that
  7817. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  7818. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  7819. This is the declarative counterpart of @code{gexp->script}.
  7820. @end deffn
  7821. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  7822. [#:set-load-path? #t] [#:module-path %load-path] @
  7823. [#:splice? #f] @
  7824. [#:guile (default-guile)]
  7825. Return a derivation that builds a file @var{name} containing @var{exp}.
  7826. When @var{splice?} is true, @var{exp} is considered to be a list of
  7827. expressions that will be spliced in the resulting file.
  7828. When @var{set-load-path?} is true, emit code in the resulting file to
  7829. set @code{%load-path} and @code{%load-compiled-path} to honor
  7830. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  7831. @var{module-path}.
  7832. The resulting file holds references to all the dependencies of @var{exp}
  7833. or a subset thereof.
  7834. @end deffn
  7835. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  7836. [#:splice? #f] [#:set-load-path? #t]
  7837. Return an object representing the Scheme file @var{name} that contains
  7838. @var{exp}.
  7839. This is the declarative counterpart of @code{gexp->file}.
  7840. @end deffn
  7841. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  7842. Return as a monadic value a derivation that builds a text file
  7843. containing all of @var{text}. @var{text} may list, in addition to
  7844. strings, objects of any type that can be used in a gexp: packages,
  7845. derivations, local file objects, etc. The resulting store file holds
  7846. references to all these.
  7847. This variant should be preferred over @code{text-file} anytime the file
  7848. to create will reference items from the store. This is typically the
  7849. case when building a configuration file that embeds store file names,
  7850. like this:
  7851. @lisp
  7852. (define (profile.sh)
  7853. ;; Return the name of a shell script in the store that
  7854. ;; initializes the 'PATH' environment variable.
  7855. (text-file* "profile.sh"
  7856. "export PATH=" coreutils "/bin:"
  7857. grep "/bin:" sed "/bin\n"))
  7858. @end lisp
  7859. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  7860. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  7861. preventing them from being garbage-collected during its lifetime.
  7862. @end deffn
  7863. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  7864. Return an object representing store file @var{name} containing
  7865. @var{text}. @var{text} is a sequence of strings and file-like objects,
  7866. as in:
  7867. @lisp
  7868. (mixed-text-file "profile"
  7869. "export PATH=" coreutils "/bin:" grep "/bin")
  7870. @end lisp
  7871. This is the declarative counterpart of @code{text-file*}.
  7872. @end deffn
  7873. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  7874. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  7875. Each item in @var{files} must be a two-element list where the first element is the
  7876. file name to use in the new directory, and the second element is a gexp
  7877. denoting the target file. Here's an example:
  7878. @lisp
  7879. (file-union "etc"
  7880. `(("hosts" ,(plain-file "hosts"
  7881. "127.0.0.1 localhost"))
  7882. ("bashrc" ,(plain-file "bashrc"
  7883. "alias ls='ls --color=auto'"))))
  7884. @end lisp
  7885. This yields an @code{etc} directory containing these two files.
  7886. @end deffn
  7887. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  7888. Return a directory that is the union of @var{things}, where @var{things} is a list of
  7889. file-like objects denoting directories. For example:
  7890. @lisp
  7891. (directory-union "guile+emacs" (list guile emacs))
  7892. @end lisp
  7893. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  7894. @end deffn
  7895. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  7896. Return a file-like object that expands to the concatenation of @var{obj}
  7897. and @var{suffix}, where @var{obj} is a lowerable object and each
  7898. @var{suffix} is a string.
  7899. As an example, consider this gexp:
  7900. @lisp
  7901. (gexp->script "run-uname"
  7902. #~(system* #$(file-append coreutils
  7903. "/bin/uname")))
  7904. @end lisp
  7905. The same effect could be achieved with:
  7906. @lisp
  7907. (gexp->script "run-uname"
  7908. #~(system* (string-append #$coreutils
  7909. "/bin/uname")))
  7910. @end lisp
  7911. There is one difference though: in the @code{file-append} case, the
  7912. resulting script contains the absolute file name as a string, whereas in
  7913. the second case, the resulting script contains a @code{(string-append
  7914. @dots{})} expression to construct the file name @emph{at run time}.
  7915. @end deffn
  7916. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  7917. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  7918. Bind @var{system} to the currently targeted system---e.g.,
  7919. @code{"x86_64-linux"}---within @var{body}.
  7920. In the second case, additionally bind @var{target} to the current
  7921. cross-compilation target---a GNU triplet such as
  7922. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  7923. cross-compiling.
  7924. @code{let-system} is useful in the occasional case where the object
  7925. spliced into the gexp depends on the target system, as in this example:
  7926. @lisp
  7927. #~(system*
  7928. #+(let-system system
  7929. (cond ((string-prefix? "armhf-" system)
  7930. (file-append qemu "/bin/qemu-system-arm"))
  7931. ((string-prefix? "x86_64-" system)
  7932. (file-append qemu "/bin/qemu-system-x86_64"))
  7933. (else
  7934. (error "dunno!"))))
  7935. "-net" "user" #$image)
  7936. @end lisp
  7937. @end deffn
  7938. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  7939. This macro is similar to the @code{parameterize} form for
  7940. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  7941. Guile Reference Manual}). The key difference is that it takes effect
  7942. when the file-like object returned by @var{exp} is lowered to a
  7943. derivation or store item.
  7944. A typical use of @code{with-parameters} is to force the system in effect
  7945. for a given object:
  7946. @lisp
  7947. (with-parameters ((%current-system "i686-linux"))
  7948. coreutils)
  7949. @end lisp
  7950. The example above returns an object that corresponds to the i686 build
  7951. of Coreutils, regardless of the current value of @code{%current-system}.
  7952. @end deffn
  7953. Of course, in addition to gexps embedded in ``host'' code, there are
  7954. also modules containing build tools. To make it clear that they are
  7955. meant to be used in the build stratum, these modules are kept in the
  7956. @code{(guix build @dots{})} name space.
  7957. @cindex lowering, of high-level objects in gexps
  7958. Internally, high-level objects are @dfn{lowered}, using their compiler,
  7959. to either derivations or store items. For instance, lowering a package
  7960. yields a derivation, and lowering a @code{plain-file} yields a store
  7961. item. This is achieved using the @code{lower-object} monadic procedure.
  7962. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  7963. [#:target #f]
  7964. Return as a value in @code{%store-monad} the derivation or store item
  7965. corresponding to @var{obj} for @var{system}, cross-compiling for
  7966. @var{target} if @var{target} is true. @var{obj} must be an object that
  7967. has an associated gexp compiler, such as a @code{<package>}.
  7968. @end deffn
  7969. @node Invoking guix repl
  7970. @section Invoking @command{guix repl}
  7971. @cindex REPL, read-eval-print loop, script
  7972. The @command{guix repl} command makes it easier to program Guix in Guile
  7973. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  7974. programming (@pxref{Using Guile Interactively,,, guile,
  7975. GNU Guile Reference Manual}), or by running Guile scripts
  7976. (@pxref{Running Guile Scripts,,, guile,
  7977. GNU Guile Reference Manual}).
  7978. Compared to just launching the @command{guile}
  7979. command, @command{guix repl} guarantees that all the Guix modules and all its
  7980. dependencies are available in the search path.
  7981. The general syntax is:
  7982. @example
  7983. guix repl @var{options} [@var{file} @var{args}]
  7984. @end example
  7985. When a @var{file} argument is provided, @var{file} is
  7986. executed as a Guile scripts:
  7987. @example
  7988. guix repl my-script.scm
  7989. @end example
  7990. To pass arguments to the script, use @code{--} to prevent them from
  7991. being interpreted as arguments to @command{guix repl} itself:
  7992. @example
  7993. guix repl -- my-script.scm --input=foo.txt
  7994. @end example
  7995. To make a script executable directly from the shell, using the guix
  7996. executable that is on the user's search path, add the following two
  7997. lines at the top of the script:
  7998. @example
  7999. @code{#!/usr/bin/env -S guix repl --}
  8000. @code{!#}
  8001. @end example
  8002. Without a file name argument, a Guile REPL is started:
  8003. @example
  8004. $ guix repl
  8005. scheme@@(guile-user)> ,use (gnu packages base)
  8006. scheme@@(guile-user)> coreutils
  8007. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  8008. @end example
  8009. @cindex inferiors
  8010. In addition, @command{guix repl} implements a simple machine-readable REPL
  8011. protocol for use by @code{(guix inferior)}, a facility to interact with
  8012. @dfn{inferiors}, separate processes running a potentially different revision
  8013. of Guix.
  8014. The available options are as follows:
  8015. @table @code
  8016. @item --type=@var{type}
  8017. @itemx -t @var{type}
  8018. Start a REPL of the given @var{TYPE}, which can be one of the following:
  8019. @table @code
  8020. @item guile
  8021. This is default, and it spawns a standard full-featured Guile REPL.
  8022. @item machine
  8023. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  8024. that the @code{(guix inferior)} module speaks.
  8025. @end table
  8026. @item --listen=@var{endpoint}
  8027. By default, @command{guix repl} reads from standard input and writes to
  8028. standard output. When this option is passed, it will instead listen for
  8029. connections on @var{endpoint}. Here are examples of valid options:
  8030. @table @code
  8031. @item --listen=tcp:37146
  8032. Accept connections on localhost on port 37146.
  8033. @item --listen=unix:/tmp/socket
  8034. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  8035. @end table
  8036. @item --load-path=@var{directory}
  8037. @itemx -L @var{directory}
  8038. Add @var{directory} to the front of the package module search path
  8039. (@pxref{Package Modules}).
  8040. This allows users to define their own packages and make them visible to
  8041. the script or REPL.
  8042. @item -q
  8043. Inhibit loading of the @file{~/.guile} file. By default, that
  8044. configuration file is loaded when spawning a @code{guile} REPL.
  8045. @end table
  8046. @c *********************************************************************
  8047. @node Utilities
  8048. @chapter Utilities
  8049. This section describes Guix command-line utilities. Some of them are
  8050. primarily targeted at developers and users who write new package
  8051. definitions, while others are more generally useful. They complement
  8052. the Scheme programming interface of Guix in a convenient way.
  8053. @menu
  8054. * Invoking guix build:: Building packages from the command line.
  8055. * Invoking guix edit:: Editing package definitions.
  8056. * Invoking guix download:: Downloading a file and printing its hash.
  8057. * Invoking guix hash:: Computing the cryptographic hash of a file.
  8058. * Invoking guix import:: Importing package definitions.
  8059. * Invoking guix refresh:: Updating package definitions.
  8060. * Invoking guix lint:: Finding errors in package definitions.
  8061. * Invoking guix size:: Profiling disk usage.
  8062. * Invoking guix graph:: Visualizing the graph of packages.
  8063. * Invoking guix publish:: Sharing substitutes.
  8064. * Invoking guix challenge:: Challenging substitute servers.
  8065. * Invoking guix copy:: Copying to and from a remote store.
  8066. * Invoking guix container:: Process isolation.
  8067. * Invoking guix weather:: Assessing substitute availability.
  8068. * Invoking guix processes:: Listing client processes.
  8069. @end menu
  8070. @node Invoking guix build
  8071. @section Invoking @command{guix build}
  8072. @cindex package building
  8073. @cindex @command{guix build}
  8074. The @command{guix build} command builds packages or derivations and
  8075. their dependencies, and prints the resulting store paths. Note that it
  8076. does not modify the user's profile---this is the job of the
  8077. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  8078. it is mainly useful for distribution developers.
  8079. The general syntax is:
  8080. @example
  8081. guix build @var{options} @var{package-or-derivation}@dots{}
  8082. @end example
  8083. As an example, the following command builds the latest versions of Emacs
  8084. and of Guile, displays their build logs, and finally displays the
  8085. resulting directories:
  8086. @example
  8087. guix build emacs guile
  8088. @end example
  8089. Similarly, the following command builds all the available packages:
  8090. @example
  8091. guix build --quiet --keep-going \
  8092. `guix package -A | cut -f1,2 --output-delimiter=@@`
  8093. @end example
  8094. @var{package-or-derivation} may be either the name of a package found in
  8095. the software distribution such as @code{coreutils} or
  8096. @code{coreutils@@8.20}, or a derivation such as
  8097. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  8098. package with the corresponding name (and optionally version) is searched
  8099. for among the GNU distribution modules (@pxref{Package Modules}).
  8100. Alternatively, the @option{--expression} option may be used to specify a
  8101. Scheme expression that evaluates to a package; this is useful when
  8102. disambiguating among several same-named packages or package variants is
  8103. needed.
  8104. There may be zero or more @var{options}. The available options are
  8105. described in the subsections below.
  8106. @menu
  8107. * Common Build Options:: Build options for most commands.
  8108. * Package Transformation Options:: Creating variants of packages.
  8109. * Additional Build Options:: Options specific to 'guix build'.
  8110. * Debugging Build Failures:: Real life packaging experience.
  8111. @end menu
  8112. @node Common Build Options
  8113. @subsection Common Build Options
  8114. A number of options that control the build process are common to
  8115. @command{guix build} and other commands that can spawn builds, such as
  8116. @command{guix package} or @command{guix archive}. These are the
  8117. following:
  8118. @table @code
  8119. @item --load-path=@var{directory}
  8120. @itemx -L @var{directory}
  8121. Add @var{directory} to the front of the package module search path
  8122. (@pxref{Package Modules}).
  8123. This allows users to define their own packages and make them visible to
  8124. the command-line tools.
  8125. @item --keep-failed
  8126. @itemx -K
  8127. Keep the build tree of failed builds. Thus, if a build fails, its build
  8128. tree is kept under @file{/tmp}, in a directory whose name is shown at
  8129. the end of the build log. This is useful when debugging build issues.
  8130. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  8131. build issues.
  8132. This option implies @option{--no-offload}, and it has no effect when
  8133. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  8134. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  8135. @item --keep-going
  8136. @itemx -k
  8137. Keep going when some of the derivations fail to build; return only once
  8138. all the builds have either completed or failed.
  8139. The default behavior is to stop as soon as one of the specified
  8140. derivations has failed.
  8141. @item --dry-run
  8142. @itemx -n
  8143. Do not build the derivations.
  8144. @anchor{fallback-option}
  8145. @item --fallback
  8146. When substituting a pre-built binary fails, fall back to building
  8147. packages locally (@pxref{Substitution Failure}).
  8148. @item --substitute-urls=@var{urls}
  8149. @anchor{client-substitute-urls}
  8150. Consider @var{urls} the whitespace-separated list of substitute source
  8151. URLs, overriding the default list of URLs of @command{guix-daemon}
  8152. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  8153. This means that substitutes may be downloaded from @var{urls}, provided
  8154. they are signed by a key authorized by the system administrator
  8155. (@pxref{Substitutes}).
  8156. When @var{urls} is the empty string, substitutes are effectively
  8157. disabled.
  8158. @item --no-substitutes
  8159. Do not use substitutes for build products. That is, always build things
  8160. locally instead of allowing downloads of pre-built binaries
  8161. (@pxref{Substitutes}).
  8162. @item --no-grafts
  8163. Do not ``graft'' packages. In practice, this means that package updates
  8164. available as grafts are not applied. @xref{Security Updates}, for more
  8165. information on grafts.
  8166. @item --rounds=@var{n}
  8167. Build each derivation @var{n} times in a row, and raise an error if
  8168. consecutive build results are not bit-for-bit identical.
  8169. This is a useful way to detect non-deterministic builds processes.
  8170. Non-deterministic build processes are a problem because they make it
  8171. practically impossible for users to @emph{verify} whether third-party
  8172. binaries are genuine. @xref{Invoking guix challenge}, for more.
  8173. When used in conjunction with @option{--keep-failed}, the differing
  8174. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8175. This makes it easy to look for differences between the two results.
  8176. @item --no-offload
  8177. Do not use offload builds to other machines (@pxref{Daemon Offload
  8178. Setup}). That is, always build things locally instead of offloading
  8179. builds to remote machines.
  8180. @item --max-silent-time=@var{seconds}
  8181. When the build or substitution process remains silent for more than
  8182. @var{seconds}, terminate it and report a build failure.
  8183. By default, the daemon's setting is honored (@pxref{Invoking
  8184. guix-daemon, @option{--max-silent-time}}).
  8185. @item --timeout=@var{seconds}
  8186. Likewise, when the build or substitution process lasts for more than
  8187. @var{seconds}, terminate it and report a build failure.
  8188. By default, the daemon's setting is honored (@pxref{Invoking
  8189. guix-daemon, @option{--timeout}}).
  8190. @c Note: This option is actually not part of %standard-build-options but
  8191. @c most programs honor it.
  8192. @cindex verbosity, of the command-line tools
  8193. @cindex build logs, verbosity
  8194. @item -v @var{level}
  8195. @itemx --verbosity=@var{level}
  8196. Use the given verbosity @var{level}, an integer. Choosing 0 means that no
  8197. output is produced, 1 is for quiet output, and 2 shows all the build log
  8198. output on standard error.
  8199. @item --cores=@var{n}
  8200. @itemx -c @var{n}
  8201. Allow the use of up to @var{n} CPU cores for the build. The special
  8202. value @code{0} means to use as many CPU cores as available.
  8203. @item --max-jobs=@var{n}
  8204. @itemx -M @var{n}
  8205. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  8206. guix-daemon, @option{--max-jobs}}, for details about this option and the
  8207. equivalent @command{guix-daemon} option.
  8208. @item --debug=@var{level}
  8209. Produce debugging output coming from the build daemon. @var{level} must be an
  8210. integer between 0 and 5; higher means more verbose output. Setting a level of
  8211. 4 or more may be helpful when debugging setup issues with the build daemon.
  8212. @end table
  8213. Behind the scenes, @command{guix build} is essentially an interface to
  8214. the @code{package-derivation} procedure of the @code{(guix packages)}
  8215. module, and to the @code{build-derivations} procedure of the @code{(guix
  8216. derivations)} module.
  8217. In addition to options explicitly passed on the command line,
  8218. @command{guix build} and other @command{guix} commands that support
  8219. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  8220. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  8221. Users can define this variable to a list of command line options that
  8222. will automatically be used by @command{guix build} and other
  8223. @command{guix} commands that can perform builds, as in the example
  8224. below:
  8225. @example
  8226. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  8227. @end example
  8228. These options are parsed independently, and the result is appended to
  8229. the parsed command-line options.
  8230. @end defvr
  8231. @node Package Transformation Options
  8232. @subsection Package Transformation Options
  8233. @cindex package variants
  8234. Another set of command-line options supported by @command{guix build}
  8235. and also @command{guix package} are @dfn{package transformation
  8236. options}. These are options that make it possible to define @dfn{package
  8237. variants}---for instance, packages built from different source code.
  8238. This is a convenient way to create customized packages on the fly
  8239. without having to type in the definitions of package variants
  8240. (@pxref{Defining Packages}).
  8241. Package transformation options are preserved across upgrades:
  8242. @command{guix upgrade} attempts to apply transformation options
  8243. initially used when creating the profile to the upgraded packages.
  8244. The available options are listed below. Most commands support them and
  8245. also support a @option{--help-transform} option that lists all the
  8246. available options and a synopsis (these options are not shown in the
  8247. @option{--help} output for brevity).
  8248. @table @code
  8249. @item --with-source=@var{source}
  8250. @itemx --with-source=@var{package}=@var{source}
  8251. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  8252. Use @var{source} as the source of @var{package}, and @var{version} as
  8253. its version number.
  8254. @var{source} must be a file name or a URL, as for @command{guix
  8255. download} (@pxref{Invoking guix download}).
  8256. When @var{package} is omitted,
  8257. it is taken to be the package name specified on the
  8258. command line that matches the base of @var{source}---e.g.,
  8259. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  8260. package is @code{guile}.
  8261. Likewise, when @var{version} is omitted, the version string is inferred from
  8262. @var{source}; in the previous example, it is @code{2.0.10}.
  8263. This option allows users to try out versions of packages other than the
  8264. one provided by the distribution. The example below downloads
  8265. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  8266. the @code{ed} package:
  8267. @example
  8268. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  8269. @end example
  8270. As a developer, @option{--with-source} makes it easy to test release
  8271. candidates:
  8272. @example
  8273. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  8274. @end example
  8275. @dots{} or to build from a checkout in a pristine environment:
  8276. @example
  8277. $ git clone git://git.sv.gnu.org/guix.git
  8278. $ guix build guix --with-source=guix@@1.0=./guix
  8279. @end example
  8280. @item --with-input=@var{package}=@var{replacement}
  8281. Replace dependency on @var{package} by a dependency on
  8282. @var{replacement}. @var{package} must be a package name, and
  8283. @var{replacement} must be a package specification such as @code{guile}
  8284. or @code{guile@@1.8}.
  8285. For instance, the following command builds Guix, but replaces its
  8286. dependency on the current stable version of Guile with a dependency on
  8287. the legacy version of Guile, @code{guile@@2.0}:
  8288. @example
  8289. guix build --with-input=guile=guile@@2.0 guix
  8290. @end example
  8291. This is a recursive, deep replacement. So in this example, both
  8292. @code{guix} and its dependency @code{guile-json} (which also depends on
  8293. @code{guile}) get rebuilt against @code{guile@@2.0}.
  8294. This is implemented using the @code{package-input-rewriting} Scheme
  8295. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  8296. @item --with-graft=@var{package}=@var{replacement}
  8297. This is similar to @option{--with-input} but with an important difference:
  8298. instead of rebuilding the whole dependency chain, @var{replacement} is
  8299. built and then @dfn{grafted} onto the binaries that were initially
  8300. referring to @var{package}. @xref{Security Updates}, for more
  8301. information on grafts.
  8302. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  8303. and all its dependencies, replacing references to the version of GnuTLS
  8304. they currently refer to:
  8305. @example
  8306. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  8307. @end example
  8308. This has the advantage of being much faster than rebuilding everything.
  8309. But there is a caveat: it works if and only if @var{package} and
  8310. @var{replacement} are strictly compatible---for example, if they provide
  8311. a library, the application binary interface (ABI) of those libraries
  8312. must be compatible. If @var{replacement} is somehow incompatible with
  8313. @var{package}, then the resulting package may be unusable. Use with
  8314. care!
  8315. @cindex debugging info, rebuilding
  8316. @item --with-debug-info=@var{package}
  8317. Build @var{package} in a way that preserves its debugging info and graft
  8318. it onto packages that depend on it. This is useful if @var{package}
  8319. does not already provide debugging info as a @code{debug} output
  8320. (@pxref{Installing Debugging Files}).
  8321. For example, suppose you're experiencing a crash in Inkscape and would
  8322. like to see what's up in GLib, a library deep down in Inkscape's
  8323. dependency graph. GLib lacks a @code{debug} output, so debugging is
  8324. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  8325. Inkscape:
  8326. @example
  8327. guix install inkscape --with-debug-info=glib
  8328. @end example
  8329. Only GLib needs to be recompiled so this takes a reasonable amount of
  8330. time. @xref{Installing Debugging Files}, for more info.
  8331. @quotation Note
  8332. Under the hood, this option works by passing the @samp{#:strip-binaries?
  8333. #f} to the build system of the package of interest (@pxref{Build
  8334. Systems}). Most build systems support that option but some do not. In
  8335. that case, an error is raised.
  8336. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  8337. the case), debugging info will remain unavailable even when
  8338. @code{#:strip-binaries?} is false.
  8339. @end quotation
  8340. @cindex tool chain, changing the build tool chain of a package
  8341. @item --with-c-toolchain=@var{package}=@var{toolchain}
  8342. This option changes the compilation of @var{package} and everything that
  8343. depends on it so that they get built with @var{toolchain} instead of the
  8344. default GNU tool chain for C/C++.
  8345. Consider this example:
  8346. @example
  8347. guix build octave-cli \
  8348. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  8349. --with-c-toolchain=fftwf=gcc-toolchain@@10
  8350. @end example
  8351. The command above builds a variant of the @code{fftw} and @code{fftwf}
  8352. packages using version 10 of @code{gcc-toolchain} instead of the default
  8353. tool chain, and then builds a variant of the GNU@tie{}Octave
  8354. command-line interface using them. GNU@tie{}Octave itself is also built
  8355. with @code{gcc-toolchain@@10}.
  8356. This other example builds the Hardware Locality (@code{hwloc}) library
  8357. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  8358. compiler:
  8359. @example
  8360. guix build --with-c-toolchain=hwloc=clang-toolchain \
  8361. intel-mpi-benchmarks
  8362. @end example
  8363. @quotation Note
  8364. There can be application binary interface (ABI) incompatibilities among
  8365. tool chains. This is particularly true of the C++ standard library and
  8366. run-time support libraries such as that of OpenMP@. By rebuilding all
  8367. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  8368. the risks of incompatibility but cannot entirely eliminate them. Choose
  8369. @var{package} wisely.
  8370. @end quotation
  8371. @item --with-git-url=@var{package}=@var{url}
  8372. @cindex Git, using the latest commit
  8373. @cindex latest commit, building
  8374. Build @var{package} from the latest commit of the @code{master} branch of the
  8375. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  8376. recursively.
  8377. For example, the following command builds the NumPy Python library against the
  8378. latest commit of the master branch of Python itself:
  8379. @example
  8380. guix build python-numpy \
  8381. --with-git-url=python=https://github.com/python/cpython
  8382. @end example
  8383. This option can also be combined with @option{--with-branch} or
  8384. @option{--with-commit} (see below).
  8385. @cindex continuous integration
  8386. Obviously, since it uses the latest commit of the given branch, the result of
  8387. such a command varies over time. Nevertheless it is a convenient way to
  8388. rebuild entire software stacks against the latest commit of one or more
  8389. packages. This is particularly useful in the context of continuous
  8390. integration (CI).
  8391. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  8392. consecutive accesses to the same repository. You may want to clean it up once
  8393. in a while to save disk space.
  8394. @item --with-branch=@var{package}=@var{branch}
  8395. Build @var{package} from the latest commit of @var{branch}. If the
  8396. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  8397. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  8398. repository URL is taken from that @code{source}. Otherwise you have to use
  8399. @option{--with-git-url} to specify the URL of the Git repository.
  8400. For instance, the following command builds @code{guile-sqlite3} from the
  8401. latest commit of its @code{master} branch, and then builds @code{guix} (which
  8402. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  8403. specific @code{guile-sqlite3} build:
  8404. @example
  8405. guix build --with-branch=guile-sqlite3=master cuirass
  8406. @end example
  8407. @item --with-commit=@var{package}=@var{commit}
  8408. This is similar to @option{--with-branch}, except that it builds from
  8409. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  8410. Git commit SHA1 identifier or a tag.
  8411. @item --with-patch=@var{package}=@var{file}
  8412. Add @var{file} to the list of patches applied to @var{package}, where
  8413. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  8414. @var{file} must contain a patch; it is applied with the flags specified
  8415. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  8416. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  8417. Comparing and Merging Files}).
  8418. As an example, the command below rebuilds Coreutils with the GNU C
  8419. Library (glibc) patched with the given patch:
  8420. @example
  8421. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  8422. @end example
  8423. In this example, glibc itself as well as everything that leads to
  8424. Coreutils in the dependency graph is rebuilt.
  8425. @cindex upstream, latest version
  8426. @item --with-latest=@var{package}
  8427. So you like living on the bleeding edge? This option is for you! It
  8428. replaces occurrences of @var{package} in the dependency graph with its
  8429. latest upstream version, as reported by @command{guix refresh}
  8430. (@pxref{Invoking guix refresh}).
  8431. It does so by determining the latest upstream release of @var{package}
  8432. (if possible), downloading it, and authenticating it @emph{if} it comes
  8433. with an OpenPGP signature.
  8434. As an example, the command below builds Guix against the latest version
  8435. of Guile-JSON:
  8436. @example
  8437. guix build guix --with-latest=guile-json
  8438. @end example
  8439. There are limitations. First, in cases where the tool cannot or does
  8440. not know how to authenticate source code, you are at risk of running
  8441. malicious code; a warning is emitted in this case. Second, this option
  8442. simply changes the source used in the existing package definitions,
  8443. which is not always sufficient: there might be additional dependencies
  8444. that need to be added, patches to apply, and more generally the quality
  8445. assurance work that Guix developers normally do will be missing.
  8446. You've been warned! In all the other cases, it's a snappy way to stay
  8447. on top. We encourage you to submit patches updating the actual package
  8448. definitions once you have successfully tested an upgrade
  8449. (@pxref{Contributing}).
  8450. @cindex test suite, skipping
  8451. @item --without-tests=@var{package}
  8452. Build @var{package} without running its tests. This can be useful in
  8453. situations where you want to skip the lengthy test suite of a
  8454. intermediate package, or if a package's test suite fails in a
  8455. non-deterministic fashion. It should be used with care because running
  8456. the test suite is a good way to ensure a package is working as intended.
  8457. Turning off tests leads to a different store item. Consequently, when
  8458. using this option, anything that depends on @var{package} must be
  8459. rebuilt, as in this example:
  8460. @example
  8461. guix install --without-tests=python python-notebook
  8462. @end example
  8463. The command above installs @code{python-notebook} on top of
  8464. @code{python} built without running its test suite. To do so, it also
  8465. rebuilds everything that depends on @code{python}, including
  8466. @code{python-notebook} itself.
  8467. Internally, @option{--without-tests} relies on changing the
  8468. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  8469. Systems}). Note that some packages use a customized @code{check} phase
  8470. that does not respect a @code{#:tests? #f} setting. Therefore,
  8471. @option{--without-tests} has no effect on these packages.
  8472. @end table
  8473. Wondering how to achieve the same effect using Scheme code, for example
  8474. in your manifest, or how to write your own package transformation?
  8475. @xref{Defining Package Variants}, for an overview of the programming
  8476. interfaces available.
  8477. @node Additional Build Options
  8478. @subsection Additional Build Options
  8479. The command-line options presented below are specific to @command{guix
  8480. build}.
  8481. @table @code
  8482. @item --quiet
  8483. @itemx -q
  8484. Build quietly, without displaying the build log; this is equivalent to
  8485. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  8486. (or similar) and can always be retrieved using the @option{--log-file} option.
  8487. @item --file=@var{file}
  8488. @itemx -f @var{file}
  8489. Build the package, derivation, or other file-like object that the code within
  8490. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  8491. As an example, @var{file} might contain a package definition like this
  8492. (@pxref{Defining Packages}):
  8493. @lisp
  8494. @include package-hello.scm
  8495. @end lisp
  8496. The @var{file} may also contain a JSON representation of one or more
  8497. package definitions. Running @code{guix build -f} on @file{hello.json}
  8498. with the following contents would result in building the packages
  8499. @code{myhello} and @code{greeter}:
  8500. @example
  8501. @verbatiminclude package-hello.json
  8502. @end example
  8503. @item --manifest=@var{manifest}
  8504. @itemx -m @var{manifest}
  8505. Build all packages listed in the given @var{manifest}
  8506. (@pxref{profile-manifest, @option{--manifest}}).
  8507. @item --expression=@var{expr}
  8508. @itemx -e @var{expr}
  8509. Build the package or derivation @var{expr} evaluates to.
  8510. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  8511. guile-1.8)}, which unambiguously designates this specific variant of
  8512. version 1.8 of Guile.
  8513. Alternatively, @var{expr} may be a G-expression, in which case it is used
  8514. as a build program passed to @code{gexp->derivation}
  8515. (@pxref{G-Expressions}).
  8516. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  8517. (@pxref{The Store Monad}). The procedure must return a derivation as a
  8518. monadic value, which is then passed through @code{run-with-store}.
  8519. @item --source
  8520. @itemx -S
  8521. Build the source derivations of the packages, rather than the packages
  8522. themselves.
  8523. For instance, @code{guix build -S gcc} returns something like
  8524. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  8525. source tarball.
  8526. The returned source tarball is the result of applying any patches and
  8527. code snippets specified in the package @code{origin} (@pxref{Defining
  8528. Packages}).
  8529. @cindex source, verification
  8530. As with other derivations, the result of building a source derivation
  8531. can be verified using the @option{--check} option (@pxref{build-check}).
  8532. This is useful to validate that a (potentially already built or
  8533. substituted, thus cached) package source matches against its declared
  8534. hash.
  8535. Note that @command{guix build -S} compiles the sources only of the
  8536. specified packages. They do not include the sources of statically
  8537. linked dependencies and by themselves are insufficient for reproducing
  8538. the packages.
  8539. @item --sources
  8540. Fetch and return the source of @var{package-or-derivation} and all their
  8541. dependencies, recursively. This is a handy way to obtain a local copy
  8542. of all the source code needed to build @var{packages}, allowing you to
  8543. eventually build them even without network access. It is an extension
  8544. of the @option{--source} option and can accept one of the following
  8545. optional argument values:
  8546. @table @code
  8547. @item package
  8548. This value causes the @option{--sources} option to behave in the same way
  8549. as the @option{--source} option.
  8550. @item all
  8551. Build the source derivations of all packages, including any source that
  8552. might be listed as @code{inputs}. This is the default value.
  8553. @example
  8554. $ guix build --sources tzdata
  8555. The following derivations will be built:
  8556. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  8557. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8558. @end example
  8559. @item transitive
  8560. Build the source derivations of all packages, as well of all transitive
  8561. inputs to the packages. This can be used e.g.@: to
  8562. prefetch package source for later offline building.
  8563. @example
  8564. $ guix build --sources=transitive tzdata
  8565. The following derivations will be built:
  8566. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8567. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  8568. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  8569. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  8570. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  8571. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  8572. @dots{}
  8573. @end example
  8574. @end table
  8575. @item --system=@var{system}
  8576. @itemx -s @var{system}
  8577. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  8578. the system type of the build host. The @command{guix build} command allows
  8579. you to repeat this option several times, in which case it builds for all the
  8580. specified systems; other commands ignore extraneous @option{-s} options.
  8581. @quotation Note
  8582. The @option{--system} flag is for @emph{native} compilation and must not
  8583. be confused with cross-compilation. See @option{--target} below for
  8584. information on cross-compilation.
  8585. @end quotation
  8586. An example use of this is on Linux-based systems, which can emulate
  8587. different personalities. For instance, passing
  8588. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  8589. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  8590. you to build packages in a complete 32-bit environment.
  8591. @quotation Note
  8592. Building for an @code{armhf-linux} system is unconditionally enabled on
  8593. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  8594. allow for this functionality, notably the ThunderX.
  8595. @end quotation
  8596. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  8597. is enabled (@pxref{Virtualization Services,
  8598. @code{qemu-binfmt-service-type}}), you can build for any system for
  8599. which a QEMU @code{binfmt_misc} handler is installed.
  8600. Builds for a system other than that of the machine you are using can
  8601. also be offloaded to a remote machine of the right architecture.
  8602. @xref{Daemon Offload Setup}, for more information on offloading.
  8603. @item --target=@var{triplet}
  8604. @cindex cross-compilation
  8605. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  8606. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  8607. configuration triplets,, autoconf, Autoconf}).
  8608. @anchor{build-check}
  8609. @item --check
  8610. @cindex determinism, checking
  8611. @cindex reproducibility, checking
  8612. Rebuild @var{package-or-derivation}, which are already available in the
  8613. store, and raise an error if the build results are not bit-for-bit
  8614. identical.
  8615. This mechanism allows you to check whether previously installed
  8616. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  8617. of a package is deterministic. @xref{Invoking guix challenge}, for more
  8618. background information and tools.
  8619. When used in conjunction with @option{--keep-failed}, the differing
  8620. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8621. This makes it easy to look for differences between the two results.
  8622. @item --repair
  8623. @cindex repairing store items
  8624. @cindex corruption, recovering from
  8625. Attempt to repair the specified store items, if they are corrupt, by
  8626. re-downloading or rebuilding them.
  8627. This operation is not atomic and thus restricted to @code{root}.
  8628. @item --derivations
  8629. @itemx -d
  8630. Return the derivation paths, not the output paths, of the given
  8631. packages.
  8632. @item --root=@var{file}
  8633. @itemx -r @var{file}
  8634. @cindex GC roots, adding
  8635. @cindex garbage collector roots, adding
  8636. Make @var{file} a symlink to the result, and register it as a garbage
  8637. collector root.
  8638. Consequently, the results of this @command{guix build} invocation are
  8639. protected from garbage collection until @var{file} is removed. When
  8640. that option is omitted, build results are eligible for garbage
  8641. collection as soon as the build completes. @xref{Invoking guix gc}, for
  8642. more on GC roots.
  8643. @item --log-file
  8644. @cindex build logs, access
  8645. Return the build log file names or URLs for the given
  8646. @var{package-or-derivation}, or raise an error if build logs are
  8647. missing.
  8648. This works regardless of how packages or derivations are specified. For
  8649. instance, the following invocations are equivalent:
  8650. @example
  8651. guix build --log-file `guix build -d guile`
  8652. guix build --log-file `guix build guile`
  8653. guix build --log-file guile
  8654. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  8655. @end example
  8656. If a log is unavailable locally, and unless @option{--no-substitutes} is
  8657. passed, the command looks for a corresponding log on one of the
  8658. substitute servers (as specified with @option{--substitute-urls}).
  8659. So for instance, imagine you want to see the build log of GDB on MIPS,
  8660. but you are actually on an @code{x86_64} machine:
  8661. @example
  8662. $ guix build --log-file gdb -s aarch64-linux
  8663. https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
  8664. @end example
  8665. You can freely access a huge library of build logs!
  8666. @end table
  8667. @node Debugging Build Failures
  8668. @subsection Debugging Build Failures
  8669. @cindex build failures, debugging
  8670. When defining a new package (@pxref{Defining Packages}), you will
  8671. probably find yourself spending some time debugging and tweaking the
  8672. build until it succeeds. To do that, you need to operate the build
  8673. commands yourself in an environment as close as possible to the one the
  8674. build daemon uses.
  8675. To that end, the first thing to do is to use the @option{--keep-failed}
  8676. or @option{-K} option of @command{guix build}, which will keep the
  8677. failed build tree in @file{/tmp} or whatever directory you specified as
  8678. @env{TMPDIR} (@pxref{Invoking guix build, @option{--keep-failed}}).
  8679. From there on, you can @command{cd} to the failed build tree and source
  8680. the @file{environment-variables} file, which contains all the
  8681. environment variable definitions that were in place when the build
  8682. failed. So let's say you're debugging a build failure in package
  8683. @code{foo}; a typical session would look like this:
  8684. @example
  8685. $ guix build foo -K
  8686. @dots{} @i{build fails}
  8687. $ cd /tmp/guix-build-foo.drv-0
  8688. $ source ./environment-variables
  8689. $ cd foo-1.2
  8690. @end example
  8691. Now, you can invoke commands as if you were the daemon (almost) and
  8692. troubleshoot your build process.
  8693. Sometimes it happens that, for example, a package's tests pass when you
  8694. run them manually but they fail when the daemon runs them. This can
  8695. happen because the daemon runs builds in containers where, unlike in our
  8696. environment above, network access is missing, @file{/bin/sh} does not
  8697. exist, etc. (@pxref{Build Environment Setup}).
  8698. In such cases, you may need to run inspect the build process from within
  8699. a container similar to the one the build daemon creates:
  8700. @example
  8701. $ guix build -K foo
  8702. @dots{}
  8703. $ cd /tmp/guix-build-foo.drv-0
  8704. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  8705. [env]# source ./environment-variables
  8706. [env]# cd foo-1.2
  8707. @end example
  8708. Here, @command{guix environment -C} creates a container and spawns a new
  8709. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  8710. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  8711. the container, which you may find handy while debugging. The
  8712. @option{--no-grafts} option makes sure we get the exact same
  8713. environment, with ungrafted packages (@pxref{Security Updates}, for more
  8714. info on grafts).
  8715. To get closer to a container like that used by the build daemon, we can
  8716. remove @file{/bin/sh}:
  8717. @example
  8718. [env]# rm /bin/sh
  8719. @end example
  8720. (Don't worry, this is harmless: this is all happening in the throw-away
  8721. container created by @command{guix environment}.)
  8722. The @command{strace} command is probably not in the search path, but we
  8723. can run:
  8724. @example
  8725. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  8726. @end example
  8727. In this way, not only you will have reproduced the environment variables
  8728. the daemon uses, you will also be running the build process in a container
  8729. similar to the one the daemon uses.
  8730. @node Invoking guix edit
  8731. @section Invoking @command{guix edit}
  8732. @cindex @command{guix edit}
  8733. @cindex package definition, editing
  8734. So many packages, so many source files! The @command{guix edit} command
  8735. facilitates the life of users and packagers by pointing their editor at
  8736. the source file containing the definition of the specified packages.
  8737. For instance:
  8738. @example
  8739. guix edit gcc@@4.9 vim
  8740. @end example
  8741. @noindent
  8742. launches the program specified in the @env{VISUAL} or in the
  8743. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  8744. and that of Vim.
  8745. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  8746. have created your own packages on @env{GUIX_PACKAGE_PATH}
  8747. (@pxref{Package Modules}), you will be able to edit the package
  8748. recipes. In other cases, you will be able to examine the read-only recipes
  8749. for packages currently in the store.
  8750. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  8751. @option{--load-path=@var{directory}} (or in short @option{-L
  8752. @var{directory}}) allows you to add @var{directory} to the front of the
  8753. package module search path and so make your own packages visible.
  8754. @node Invoking guix download
  8755. @section Invoking @command{guix download}
  8756. @cindex @command{guix download}
  8757. @cindex downloading package sources
  8758. When writing a package definition, developers typically need to download
  8759. a source tarball, compute its SHA256 hash, and write that
  8760. hash in the package definition (@pxref{Defining Packages}). The
  8761. @command{guix download} tool helps with this task: it downloads a file
  8762. from the given URI, adds it to the store, and prints both its file name
  8763. in the store and its SHA256 hash.
  8764. The fact that the downloaded file is added to the store saves bandwidth:
  8765. when the developer eventually tries to build the newly defined package
  8766. with @command{guix build}, the source tarball will not have to be
  8767. downloaded again because it is already in the store. It is also a
  8768. convenient way to temporarily stash files, which may be deleted
  8769. eventually (@pxref{Invoking guix gc}).
  8770. The @command{guix download} command supports the same URIs as used in
  8771. package definitions. In particular, it supports @code{mirror://} URIs.
  8772. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  8773. Guile bindings for GnuTLS are available in the user's environment; when
  8774. they are not available, an error is raised. @xref{Guile Preparations,
  8775. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  8776. GnuTLS-Guile}, for more information.
  8777. @command{guix download} verifies HTTPS server certificates by loading
  8778. the certificates of X.509 authorities from the directory pointed to by
  8779. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  8780. Certificates}), unless @option{--no-check-certificate} is used.
  8781. The following options are available:
  8782. @table @code
  8783. @item --hash=@var{algorithm}
  8784. @itemx -H @var{algorithm}
  8785. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  8786. hash}, for more information.
  8787. @item --format=@var{fmt}
  8788. @itemx -f @var{fmt}
  8789. Write the hash in the format specified by @var{fmt}. For more
  8790. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  8791. @item --no-check-certificate
  8792. Do not validate the X.509 certificates of HTTPS servers.
  8793. When using this option, you have @emph{absolutely no guarantee} that you
  8794. are communicating with the authentic server responsible for the given
  8795. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  8796. @item --output=@var{file}
  8797. @itemx -o @var{file}
  8798. Save the downloaded file to @var{file} instead of adding it to the
  8799. store.
  8800. @end table
  8801. @node Invoking guix hash
  8802. @section Invoking @command{guix hash}
  8803. @cindex @command{guix hash}
  8804. The @command{guix hash} command computes the hash of a file.
  8805. It is primarily a convenience tool for anyone contributing to the
  8806. distribution: it computes the cryptographic hash of a file, which can be
  8807. used in the definition of a package (@pxref{Defining Packages}).
  8808. The general syntax is:
  8809. @example
  8810. guix hash @var{option} @var{file}
  8811. @end example
  8812. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  8813. hash of data read from standard input. @command{guix hash} has the
  8814. following options:
  8815. @table @code
  8816. @item --hash=@var{algorithm}
  8817. @itemx -H @var{algorithm}
  8818. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  8819. default.
  8820. @var{algorithm} must the name of a cryptographic hash algorithm
  8821. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  8822. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  8823. Reference Manual}).
  8824. @item --format=@var{fmt}
  8825. @itemx -f @var{fmt}
  8826. Write the hash in the format specified by @var{fmt}.
  8827. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  8828. (@code{hex} and @code{hexadecimal} can be used as well).
  8829. If the @option{--format} option is not specified, @command{guix hash}
  8830. will output the hash in @code{nix-base32}. This representation is used
  8831. in the definitions of packages.
  8832. @item --recursive
  8833. @itemx -r
  8834. Compute the hash on @var{file} recursively.
  8835. In this case, the hash is computed on an archive containing @var{file},
  8836. including its children if it is a directory. Some of the metadata of
  8837. @var{file} is part of the archive; for instance, when @var{file} is a
  8838. regular file, the hash is different depending on whether @var{file} is
  8839. executable or not. Metadata such as time stamps has no impact on the
  8840. hash (@pxref{Invoking guix archive}).
  8841. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  8842. @c it exists.
  8843. @item --exclude-vcs
  8844. @itemx -x
  8845. When combined with @option{--recursive}, exclude version control system
  8846. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  8847. @vindex git-fetch
  8848. As an example, here is how you would compute the hash of a Git checkout,
  8849. which is useful when using the @code{git-fetch} method (@pxref{origin
  8850. Reference}):
  8851. @example
  8852. $ git clone http://example.org/foo.git
  8853. $ cd foo
  8854. $ guix hash -rx .
  8855. @end example
  8856. @end table
  8857. @node Invoking guix import
  8858. @section Invoking @command{guix import}
  8859. @cindex importing packages
  8860. @cindex package import
  8861. @cindex package conversion
  8862. @cindex Invoking @command{guix import}
  8863. The @command{guix import} command is useful for people who would like to
  8864. add a package to the distribution with as little work as
  8865. possible---a legitimate demand. The command knows of a few
  8866. repositories from which it can ``import'' package metadata. The result
  8867. is a package definition, or a template thereof, in the format we know
  8868. (@pxref{Defining Packages}).
  8869. The general syntax is:
  8870. @example
  8871. guix import @var{importer} @var{options}@dots{}
  8872. @end example
  8873. @var{importer} specifies the source from which to import package
  8874. metadata, and @var{options} specifies a package identifier and other
  8875. options specific to @var{importer}.
  8876. Some of the importers rely on the ability to run the @command{gpgv} command.
  8877. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  8878. gnupg} if needed.
  8879. Currently, the available ``importers'' are:
  8880. @table @code
  8881. @item gnu
  8882. Import metadata for the given GNU package. This provides a template
  8883. for the latest version of that GNU package, including the hash of its
  8884. source tarball, and its canonical synopsis and description.
  8885. Additional information such as the package dependencies and its
  8886. license needs to be figured out manually.
  8887. For example, the following command returns a package definition for
  8888. GNU@tie{}Hello:
  8889. @example
  8890. guix import gnu hello
  8891. @end example
  8892. Specific command-line options are:
  8893. @table @code
  8894. @item --key-download=@var{policy}
  8895. As for @command{guix refresh}, specify the policy to handle missing
  8896. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  8897. refresh, @option{--key-download}}.
  8898. @end table
  8899. @item pypi
  8900. @cindex pypi
  8901. Import metadata from the @uref{https://pypi.python.org/, Python Package
  8902. Index}. Information is taken from the JSON-formatted description
  8903. available at @code{pypi.python.org} and usually includes all the relevant
  8904. information, including package dependencies. For maximum efficiency, it
  8905. is recommended to install the @command{unzip} utility, so that the
  8906. importer can unzip Python wheels and gather data from them.
  8907. The command below imports metadata for the @code{itsdangerous} Python
  8908. package:
  8909. @example
  8910. guix import pypi itsdangerous
  8911. @end example
  8912. @table @code
  8913. @item --recursive
  8914. @itemx -r
  8915. Traverse the dependency graph of the given upstream package recursively
  8916. and generate package expressions for all those packages that are not yet
  8917. in Guix.
  8918. @end table
  8919. @item gem
  8920. @cindex gem
  8921. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  8922. is taken from the JSON-formatted description available at
  8923. @code{rubygems.org} and includes most relevant information, including
  8924. runtime dependencies. There are some caveats, however. The metadata
  8925. doesn't distinguish between synopses and descriptions, so the same string
  8926. is used for both fields. Additionally, the details of non-Ruby
  8927. dependencies required to build native extensions is unavailable and left
  8928. as an exercise to the packager.
  8929. The command below imports metadata for the @code{rails} Ruby package:
  8930. @example
  8931. guix import gem rails
  8932. @end example
  8933. @table @code
  8934. @item --recursive
  8935. @itemx -r
  8936. Traverse the dependency graph of the given upstream package recursively
  8937. and generate package expressions for all those packages that are not yet
  8938. in Guix.
  8939. @end table
  8940. @item cpan
  8941. @cindex CPAN
  8942. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  8943. Information is taken from the JSON-formatted metadata provided through
  8944. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  8945. relevant information, such as module dependencies. License information
  8946. should be checked closely. If Perl is available in the store, then the
  8947. @code{corelist} utility will be used to filter core modules out of the
  8948. list of dependencies.
  8949. The command command below imports metadata for the Acme::Boolean Perl
  8950. module:
  8951. @example
  8952. guix import cpan Acme::Boolean
  8953. @end example
  8954. @item cran
  8955. @cindex CRAN
  8956. @cindex Bioconductor
  8957. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  8958. central repository for the @uref{https://r-project.org, GNU@tie{}R
  8959. statistical and graphical environment}.
  8960. Information is extracted from the @file{DESCRIPTION} file of the package.
  8961. The command command below imports metadata for the Cairo R package:
  8962. @example
  8963. guix import cran Cairo
  8964. @end example
  8965. When @option{--recursive} is added, the importer will traverse the
  8966. dependency graph of the given upstream package recursively and generate
  8967. package expressions for all those packages that are not yet in Guix.
  8968. When @option{--style=specification} is added, the importer will generate
  8969. package definitions whose inputs are package specifications instead of
  8970. references to package variables. This is useful when generated package
  8971. definitions are to be appended to existing user modules, as the list of
  8972. used package modules need not be changed. The default is
  8973. @option{--style=variable}.
  8974. When @option{--archive=bioconductor} is added, metadata is imported from
  8975. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  8976. packages for the analysis and comprehension of high-throughput
  8977. genomic data in bioinformatics.
  8978. Information is extracted from the @file{DESCRIPTION} file contained in the
  8979. package archive.
  8980. The command below imports metadata for the GenomicRanges R package:
  8981. @example
  8982. guix import cran --archive=bioconductor GenomicRanges
  8983. @end example
  8984. Finally, you can also import R packages that have not yet been published on
  8985. CRAN or Bioconductor as long as they are in a git repository. Use
  8986. @option{--archive=git} followed by the URL of the git repository:
  8987. @example
  8988. guix import cran --archive=git https://github.com/immunogenomics/harmony
  8989. @end example
  8990. @item texlive
  8991. @cindex TeX Live
  8992. @cindex CTAN
  8993. Import metadata from @uref{https://www.ctan.org/, CTAN}, the
  8994. comprehensive TeX archive network for TeX packages that are part of the
  8995. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  8996. Information about the package is obtained through the XML API provided
  8997. by CTAN, while the source code is downloaded from the SVN repository of
  8998. the Tex Live project. This is done because the CTAN does not keep
  8999. versioned archives.
  9000. The command command below imports metadata for the @code{fontspec}
  9001. TeX package:
  9002. @example
  9003. guix import texlive fontspec
  9004. @end example
  9005. When @option{--archive=@var{directory}} is added, the source code is
  9006. downloaded not from the @file{latex} sub-directory of the
  9007. @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
  9008. the specified sibling @var{directory} under the same root.
  9009. The command below imports metadata for the @code{ifxetex} package from
  9010. CTAN while fetching the sources from the directory
  9011. @file{texmf/source/generic}:
  9012. @example
  9013. guix import texlive --archive=generic ifxetex
  9014. @end example
  9015. @item json
  9016. @cindex JSON, import
  9017. Import package metadata from a local JSON file. Consider the following
  9018. example package definition in JSON format:
  9019. @example
  9020. @{
  9021. "name": "hello",
  9022. "version": "2.10",
  9023. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  9024. "build-system": "gnu",
  9025. "home-page": "https://www.gnu.org/software/hello/",
  9026. "synopsis": "Hello, GNU world: An example GNU package",
  9027. "description": "GNU Hello prints a greeting.",
  9028. "license": "GPL-3.0+",
  9029. "native-inputs": ["gettext"]
  9030. @}
  9031. @end example
  9032. The field names are the same as for the @code{<package>} record
  9033. (@xref{Defining Packages}). References to other packages are provided
  9034. as JSON lists of quoted package specification strings such as
  9035. @code{guile} or @code{guile@@2.0}.
  9036. The importer also supports a more explicit source definition using the
  9037. common fields for @code{<origin>} records:
  9038. @example
  9039. @{
  9040. @dots{}
  9041. "source": @{
  9042. "method": "url-fetch",
  9043. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  9044. "sha256": @{
  9045. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  9046. @}
  9047. @}
  9048. @dots{}
  9049. @}
  9050. @end example
  9051. The command below reads metadata from the JSON file @code{hello.json}
  9052. and outputs a package expression:
  9053. @example
  9054. guix import json hello.json
  9055. @end example
  9056. @item nix
  9057. Import metadata from a local copy of the source of the
  9058. @uref{https://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  9059. relies on the @command{nix-instantiate} command of
  9060. @uref{https://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  9061. typically written in a mixture of Nix-language and Bash code. This
  9062. command only imports the high-level package structure that is written in
  9063. the Nix language. It normally includes all the basic fields of a
  9064. package definition.
  9065. When importing a GNU package, the synopsis and descriptions are replaced
  9066. by their canonical upstream variant.
  9067. Usually, you will first need to do:
  9068. @example
  9069. export NIX_REMOTE=daemon
  9070. @end example
  9071. @noindent
  9072. so that @command{nix-instantiate} does not try to open the Nix database.
  9073. As an example, the command below imports the package definition of
  9074. LibreOffice (more precisely, it imports the definition of the package
  9075. bound to the @code{libreoffice} top-level attribute):
  9076. @example
  9077. guix import nix ~/path/to/nixpkgs libreoffice
  9078. @end example
  9079. @item hackage
  9080. @cindex hackage
  9081. Import metadata from the Haskell community's central package archive
  9082. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  9083. Cabal files and includes all the relevant information, including package
  9084. dependencies.
  9085. Specific command-line options are:
  9086. @table @code
  9087. @item --stdin
  9088. @itemx -s
  9089. Read a Cabal file from standard input.
  9090. @item --no-test-dependencies
  9091. @itemx -t
  9092. Do not include dependencies required only by the test suites.
  9093. @item --cabal-environment=@var{alist}
  9094. @itemx -e @var{alist}
  9095. @var{alist} is a Scheme alist defining the environment in which the
  9096. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  9097. @code{arch}, @code{impl} and a string representing the name of a flag.
  9098. The value associated with a flag has to be either the symbol
  9099. @code{true} or @code{false}. The value associated with other keys
  9100. has to conform to the Cabal file format definition. The default value
  9101. associated with the keys @code{os}, @code{arch} and @code{impl} is
  9102. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  9103. @item --recursive
  9104. @itemx -r
  9105. Traverse the dependency graph of the given upstream package recursively
  9106. and generate package expressions for all those packages that are not yet
  9107. in Guix.
  9108. @end table
  9109. The command below imports metadata for the latest version of the
  9110. HTTP Haskell package without including test dependencies and
  9111. specifying the value of the flag @samp{network-uri} as @code{false}:
  9112. @example
  9113. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  9114. @end example
  9115. A specific package version may optionally be specified by following the
  9116. package name by an at-sign and a version number as in the following example:
  9117. @example
  9118. guix import hackage mtl@@2.1.3.1
  9119. @end example
  9120. @item stackage
  9121. @cindex stackage
  9122. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  9123. It takes a package name, looks up the package version included in a
  9124. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  9125. release and uses the @code{hackage} importer to retrieve its metadata.
  9126. Note that it is up to you to select an LTS release compatible with the
  9127. GHC compiler used by Guix.
  9128. Specific command-line options are:
  9129. @table @code
  9130. @item --no-test-dependencies
  9131. @itemx -t
  9132. Do not include dependencies required only by the test suites.
  9133. @item --lts-version=@var{version}
  9134. @itemx -l @var{version}
  9135. @var{version} is the desired LTS release version. If omitted the latest
  9136. release is used.
  9137. @item --recursive
  9138. @itemx -r
  9139. Traverse the dependency graph of the given upstream package recursively
  9140. and generate package expressions for all those packages that are not yet
  9141. in Guix.
  9142. @end table
  9143. The command below imports metadata for the HTTP Haskell package
  9144. included in the LTS Stackage release version 7.18:
  9145. @example
  9146. guix import stackage --lts-version=7.18 HTTP
  9147. @end example
  9148. @item elpa
  9149. @cindex elpa
  9150. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  9151. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  9152. Specific command-line options are:
  9153. @table @code
  9154. @item --archive=@var{repo}
  9155. @itemx -a @var{repo}
  9156. @var{repo} identifies the archive repository from which to retrieve the
  9157. information. Currently the supported repositories and their identifiers
  9158. are:
  9159. @itemize -
  9160. @item
  9161. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  9162. identifier. This is the default.
  9163. Packages from @code{elpa.gnu.org} are signed with one of the keys
  9164. contained in the GnuPG keyring at
  9165. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  9166. @code{emacs} package (@pxref{Package Installation, ELPA package
  9167. signatures,, emacs, The GNU Emacs Manual}).
  9168. @item
  9169. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  9170. @code{melpa-stable} identifier.
  9171. @item
  9172. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  9173. identifier.
  9174. @end itemize
  9175. @item --recursive
  9176. @itemx -r
  9177. Traverse the dependency graph of the given upstream package recursively
  9178. and generate package expressions for all those packages that are not yet
  9179. in Guix.
  9180. @end table
  9181. @item crate
  9182. @cindex crate
  9183. Import metadata from the crates.io Rust package repository
  9184. @uref{https://crates.io, crates.io}, as in this example:
  9185. @example
  9186. guix import crate blake2-rfc
  9187. @end example
  9188. The crate importer also allows you to specify a version string:
  9189. @example
  9190. guix import crate constant-time-eq@@0.1.0
  9191. @end example
  9192. Additional options include:
  9193. @table @code
  9194. @item --recursive
  9195. @itemx -r
  9196. Traverse the dependency graph of the given upstream package recursively
  9197. and generate package expressions for all those packages that are not yet
  9198. in Guix.
  9199. @end table
  9200. @item opam
  9201. @cindex OPAM
  9202. @cindex OCaml
  9203. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  9204. repository used by the OCaml community.
  9205. Additional options include:
  9206. @table @code
  9207. @item --recursive
  9208. @itemx -r
  9209. Traverse the dependency graph of the given upstream package recursively
  9210. and generate package expressions for all those packages that are not yet
  9211. in Guix.
  9212. @item --repo
  9213. Select the given repository (a repository name). Possible values include:
  9214. @itemize
  9215. @item @code{opam}, the default opam repository,
  9216. @item @code{coq} or @code{coq-released}, the stable repository for coq packages,
  9217. @item @code{coq-core-dev}, the repository that contains development versions of coq,
  9218. @item @code{coq-extra-dev}, the repository that contains development versions
  9219. of coq packages.
  9220. @end itemize
  9221. @end table
  9222. @end table
  9223. The structure of the @command{guix import} code is modular. It would be
  9224. useful to have more importers for other package formats, and your help
  9225. is welcome here (@pxref{Contributing}).
  9226. @node Invoking guix refresh
  9227. @section Invoking @command{guix refresh}
  9228. @cindex @command {guix refresh}
  9229. The primary audience of the @command{guix refresh} command is developers
  9230. of the GNU software distribution. By default, it reports any packages
  9231. provided by the distribution that are outdated compared to the latest
  9232. upstream version, like this:
  9233. @example
  9234. $ guix refresh
  9235. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  9236. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  9237. @end example
  9238. Alternatively, one can specify packages to consider, in which case a
  9239. warning is emitted for packages that lack an updater:
  9240. @example
  9241. $ guix refresh coreutils guile guile-ssh
  9242. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  9243. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  9244. @end example
  9245. @command{guix refresh} browses the upstream repository of each package and determines
  9246. the highest version number of the releases therein. The command
  9247. knows how to update specific types of packages: GNU packages, ELPA
  9248. packages, etc.---see the documentation for @option{--type} below. There
  9249. are many packages, though, for which it lacks a method to determine
  9250. whether a new upstream release is available. However, the mechanism is
  9251. extensible, so feel free to get in touch with us to add a new method!
  9252. @table @code
  9253. @item --recursive
  9254. Consider the packages specified, and all the packages upon which they depend.
  9255. @example
  9256. $ guix refresh --recursive coreutils
  9257. gnu/packages/acl.scm:35:2: warning: no updater for acl
  9258. gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
  9259. gnu/packages/xml.scm:68:2: warning: no updater for expat
  9260. gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
  9261. @dots{}
  9262. @end example
  9263. @end table
  9264. Sometimes the upstream name differs from the package name used in Guix,
  9265. and @command{guix refresh} needs a little help. Most updaters honor the
  9266. @code{upstream-name} property in package definitions, which can be used
  9267. to that effect:
  9268. @lisp
  9269. (define-public network-manager
  9270. (package
  9271. (name "network-manager")
  9272. ;; @dots{}
  9273. (properties '((upstream-name . "NetworkManager")))))
  9274. @end lisp
  9275. When passed @option{--update}, it modifies distribution source files to
  9276. update the version numbers and source tarball hashes of those package
  9277. recipes (@pxref{Defining Packages}). This is achieved by downloading
  9278. each package's latest source tarball and its associated OpenPGP
  9279. signature, authenticating the downloaded tarball against its signature
  9280. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  9281. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  9282. When the public
  9283. key used to sign the tarball is missing from the user's keyring, an
  9284. attempt is made to automatically retrieve it from a public key server;
  9285. when this is successful, the key is added to the user's keyring; otherwise,
  9286. @command{guix refresh} reports an error.
  9287. The following options are supported:
  9288. @table @code
  9289. @item --expression=@var{expr}
  9290. @itemx -e @var{expr}
  9291. Consider the package @var{expr} evaluates to.
  9292. This is useful to precisely refer to a package, as in this example:
  9293. @example
  9294. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  9295. @end example
  9296. This command lists the dependents of the ``final'' libc (essentially all
  9297. the packages).
  9298. @item --update
  9299. @itemx -u
  9300. Update distribution source files (package recipes) in place. This is
  9301. usually run from a checkout of the Guix source tree (@pxref{Running
  9302. Guix Before It Is Installed}):
  9303. @example
  9304. $ ./pre-inst-env guix refresh -s non-core -u
  9305. @end example
  9306. @xref{Defining Packages}, for more information on package definitions.
  9307. @item --select=[@var{subset}]
  9308. @itemx -s @var{subset}
  9309. Select all the packages in @var{subset}, one of @code{core} or
  9310. @code{non-core}.
  9311. The @code{core} subset refers to all the packages at the core of the
  9312. distribution---i.e., packages that are used to build ``everything
  9313. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  9314. changing one of these packages in the distribution entails a rebuild of
  9315. all the others. Thus, such updates are an inconvenience to users in
  9316. terms of build time or bandwidth used to achieve the upgrade.
  9317. The @code{non-core} subset refers to the remaining packages. It is
  9318. typically useful in cases where an update of the core packages would be
  9319. inconvenient.
  9320. @item --manifest=@var{file}
  9321. @itemx -m @var{file}
  9322. Select all the packages from the manifest in @var{file}. This is useful to
  9323. check if any packages of the user manifest can be updated.
  9324. @item --type=@var{updater}
  9325. @itemx -t @var{updater}
  9326. Select only packages handled by @var{updater} (may be a comma-separated
  9327. list of updaters). Currently, @var{updater} may be one of:
  9328. @table @code
  9329. @item gnu
  9330. the updater for GNU packages;
  9331. @item savannah
  9332. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  9333. @item gnome
  9334. the updater for GNOME packages;
  9335. @item kde
  9336. the updater for KDE packages;
  9337. @item xorg
  9338. the updater for X.org packages;
  9339. @item kernel.org
  9340. the updater for packages hosted on kernel.org;
  9341. @item elpa
  9342. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  9343. @item cran
  9344. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  9345. @item bioconductor
  9346. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  9347. @item cpan
  9348. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  9349. @item pypi
  9350. the updater for @uref{https://pypi.python.org, PyPI} packages.
  9351. @item gem
  9352. the updater for @uref{https://rubygems.org, RubyGems} packages.
  9353. @item github
  9354. the updater for @uref{https://github.com, GitHub} packages.
  9355. @item hackage
  9356. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  9357. @item stackage
  9358. the updater for @uref{https://www.stackage.org, Stackage} packages.
  9359. @item crate
  9360. the updater for @uref{https://crates.io, Crates} packages.
  9361. @item launchpad
  9362. the updater for @uref{https://launchpad.net, Launchpad} packages.
  9363. @end table
  9364. For instance, the following command only checks for updates of Emacs
  9365. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  9366. @example
  9367. $ guix refresh --type=elpa,cran
  9368. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  9369. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  9370. @end example
  9371. @end table
  9372. In addition, @command{guix refresh} can be passed one or more package
  9373. names, as in this example:
  9374. @example
  9375. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  9376. @end example
  9377. @noindent
  9378. The command above specifically updates the @code{emacs} and
  9379. @code{idutils} packages. The @option{--select} option would have no
  9380. effect in this case.
  9381. When considering whether to upgrade a package, it is sometimes
  9382. convenient to know which packages would be affected by the upgrade and
  9383. should be checked for compatibility. For this the following option may
  9384. be used when passing @command{guix refresh} one or more package names:
  9385. @table @code
  9386. @item --list-updaters
  9387. @itemx -L
  9388. List available updaters and exit (see @option{--type} above).
  9389. For each updater, display the fraction of packages it covers; at the
  9390. end, display the fraction of packages covered by all these updaters.
  9391. @item --list-dependent
  9392. @itemx -l
  9393. List top-level dependent packages that would need to be rebuilt as a
  9394. result of upgrading one or more packages.
  9395. @xref{Invoking guix graph, the @code{reverse-package} type of
  9396. @command{guix graph}}, for information on how to visualize the list of
  9397. dependents of a package.
  9398. @end table
  9399. Be aware that the @option{--list-dependent} option only
  9400. @emph{approximates} the rebuilds that would be required as a result of
  9401. an upgrade. More rebuilds might be required under some circumstances.
  9402. @example
  9403. $ guix refresh --list-dependent flex
  9404. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  9405. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  9406. @end example
  9407. The command above lists a set of packages that could be built to check
  9408. for compatibility with an upgraded @code{flex} package.
  9409. @table @code
  9410. @item --list-transitive
  9411. List all the packages which one or more packages depend upon.
  9412. @example
  9413. $ guix refresh --list-transitive flex
  9414. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  9415. bison@@3.0.5 indent@@2.2.10 tar@@1.30 gzip@@1.9 bzip2@@1.0.6 xz@@5.2.4 file@@5.33 @dots{}
  9416. @end example
  9417. @end table
  9418. The command above lists a set of packages which, when changed, would cause
  9419. @code{flex} to be rebuilt.
  9420. The following options can be used to customize GnuPG operation:
  9421. @table @code
  9422. @item --gpg=@var{command}
  9423. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  9424. for in @code{$PATH}.
  9425. @item --keyring=@var{file}
  9426. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  9427. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  9428. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  9429. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  9430. information on a tool to manipulate keybox files).
  9431. When this option is omitted, @command{guix refresh} uses
  9432. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  9433. signing keys. OpenPGP signatures are checked against keys from this keyring;
  9434. missing keys are downloaded to this keyring as well (see
  9435. @option{--key-download} below).
  9436. You can export keys from your default GPG keyring into a keybox file using
  9437. commands like this one:
  9438. @example
  9439. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  9440. @end example
  9441. Likewise, you can fetch keys to a specific keybox file like this:
  9442. @example
  9443. gpg --no-default-keyring --keyring mykeyring.kbx \
  9444. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  9445. @end example
  9446. @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  9447. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  9448. @item --key-download=@var{policy}
  9449. Handle missing OpenPGP keys according to @var{policy}, which may be one
  9450. of:
  9451. @table @code
  9452. @item always
  9453. Always download missing OpenPGP keys from the key server, and add them
  9454. to the user's GnuPG keyring.
  9455. @item never
  9456. Never try to download missing OpenPGP keys. Instead just bail out.
  9457. @item interactive
  9458. When a package signed with an unknown OpenPGP key is encountered, ask
  9459. the user whether to download it or not. This is the default behavior.
  9460. @end table
  9461. @item --key-server=@var{host}
  9462. Use @var{host} as the OpenPGP key server when importing a public key.
  9463. @item --load-path=@var{directory}
  9464. Add @var{directory} to the front of the package module search path
  9465. (@pxref{Package Modules}).
  9466. This allows users to define their own packages and make them visible to
  9467. the command-line tools.
  9468. @end table
  9469. The @code{github} updater uses the
  9470. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  9471. releases. When used repeatedly e.g.@: when refreshing all packages,
  9472. GitHub will eventually refuse to answer any further API requests. By
  9473. default 60 API requests per hour are allowed, and a full refresh on all
  9474. GitHub packages in Guix requires more than this. Authentication with
  9475. GitHub through the use of an API token alleviates these limits. To use
  9476. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  9477. token procured from @uref{https://github.com/settings/tokens} or
  9478. otherwise.
  9479. @node Invoking guix lint
  9480. @section Invoking @command{guix lint}
  9481. @cindex @command{guix lint}
  9482. @cindex package, checking for errors
  9483. The @command{guix lint} command is meant to help package developers avoid
  9484. common errors and use a consistent style. It runs a number of checks on
  9485. a given set of packages in order to find common mistakes in their
  9486. definitions. Available @dfn{checkers} include (see
  9487. @option{--list-checkers} for a complete list):
  9488. @table @code
  9489. @item synopsis
  9490. @itemx description
  9491. Validate certain typographical and stylistic rules about package
  9492. descriptions and synopses.
  9493. @item inputs-should-be-native
  9494. Identify inputs that should most likely be native inputs.
  9495. @item source
  9496. @itemx home-page
  9497. @itemx mirror-url
  9498. @itemx github-url
  9499. @itemx source-file-name
  9500. Probe @code{home-page} and @code{source} URLs and report those that are
  9501. invalid. Suggest a @code{mirror://} URL when applicable. If the
  9502. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  9503. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  9504. version number or ``git-checkout'', without a declared @code{file-name}
  9505. (@pxref{origin Reference}).
  9506. @item source-unstable-tarball
  9507. Parse the @code{source} URL to determine if a tarball from GitHub is
  9508. autogenerated or if it is a release tarball. Unfortunately GitHub's
  9509. autogenerated tarballs are sometimes regenerated.
  9510. @item derivation
  9511. Check that the derivation of the given packages can be successfully
  9512. computed for all the supported systems (@pxref{Derivations}).
  9513. @item profile-collisions
  9514. Check whether installing the given packages in a profile would lead to
  9515. collisions. Collisions occur when several packages with the same name
  9516. but a different version or a different store file name are propagated.
  9517. @xref{package Reference, @code{propagated-inputs}}, for more information
  9518. on propagated inputs.
  9519. @item archival
  9520. @cindex Software Heritage, source code archive
  9521. @cindex archival of source code, Software Heritage
  9522. Checks whether the package's source code is archived at
  9523. @uref{https://www.softwareheritage.org, Software Heritage}.
  9524. When the source code that is not archived comes from a version-control system
  9525. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  9526. ``save'' request so that it eventually archives it. This ensures that the
  9527. source will remain available in the long term, and that Guix can fall back to
  9528. Software Heritage should the source code disappear from its original host.
  9529. The status of recent ``save'' requests can be
  9530. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  9531. When source code is a tarball obtained with @code{url-fetch}, simply print a
  9532. message when it is not archived. As of this writing, Software Heritage does
  9533. not allow requests to save arbitrary tarballs; we are working on ways to
  9534. ensure that non-VCS source code is also archived.
  9535. Software Heritage
  9536. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  9537. request rate per IP address}. When the limit is reached, @command{guix lint}
  9538. prints a message and the @code{archival} checker stops doing anything until
  9539. that limit has been reset.
  9540. @item cve
  9541. @cindex security vulnerabilities
  9542. @cindex CVE, Common Vulnerabilities and Exposures
  9543. Report known vulnerabilities found in the Common Vulnerabilities and
  9544. Exposures (CVE) databases of the current and past year
  9545. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  9546. NIST}.
  9547. To view information about a particular vulnerability, visit pages such as:
  9548. @itemize
  9549. @item
  9550. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  9551. @item
  9552. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  9553. @end itemize
  9554. @noindent
  9555. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  9556. @code{CVE-2015-7554}.
  9557. Package developers can specify in package recipes the
  9558. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  9559. name and version of the package when they differ from the name or version
  9560. that Guix uses, as in this example:
  9561. @lisp
  9562. (package
  9563. (name "grub")
  9564. ;; @dots{}
  9565. ;; CPE calls this package "grub2".
  9566. (properties '((cpe-name . "grub2")
  9567. (cpe-version . "2.3"))))
  9568. @end lisp
  9569. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  9570. Some entries in the CVE database do not specify which version of a
  9571. package they apply to, and would thus ``stick around'' forever. Package
  9572. developers who found CVE alerts and verified they can be ignored can
  9573. declare them as in this example:
  9574. @lisp
  9575. (package
  9576. (name "t1lib")
  9577. ;; @dots{}
  9578. ;; These CVEs no longer apply and can be safely ignored.
  9579. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  9580. "CVE-2011-1553"
  9581. "CVE-2011-1554"
  9582. "CVE-2011-5244")))))
  9583. @end lisp
  9584. @item formatting
  9585. Warn about obvious source code formatting issues: trailing white space,
  9586. use of tabulations, etc.
  9587. @end table
  9588. The general syntax is:
  9589. @example
  9590. guix lint @var{options} @var{package}@dots{}
  9591. @end example
  9592. If no package is given on the command line, then all packages are checked.
  9593. The @var{options} may be zero or more of the following:
  9594. @table @code
  9595. @item --list-checkers
  9596. @itemx -l
  9597. List and describe all the available checkers that will be run on packages
  9598. and exit.
  9599. @item --checkers
  9600. @itemx -c
  9601. Only enable the checkers specified in a comma-separated list using the
  9602. names returned by @option{--list-checkers}.
  9603. @item --exclude
  9604. @itemx -x
  9605. Only disable the checkers specified in a comma-separated list using the
  9606. names returned by @option{--list-checkers}.
  9607. @item --no-network
  9608. @itemx -n
  9609. Only enable the checkers that do not depend on Internet access.
  9610. @item --load-path=@var{directory}
  9611. @itemx -L @var{directory}
  9612. Add @var{directory} to the front of the package module search path
  9613. (@pxref{Package Modules}).
  9614. This allows users to define their own packages and make them visible to
  9615. the command-line tools.
  9616. @end table
  9617. @node Invoking guix size
  9618. @section Invoking @command{guix size}
  9619. @cindex size
  9620. @cindex package size
  9621. @cindex closure
  9622. @cindex @command{guix size}
  9623. The @command{guix size} command helps package developers profile the
  9624. disk usage of packages. It is easy to overlook the impact of an
  9625. additional dependency added to a package, or the impact of using a
  9626. single output for a package that could easily be split (@pxref{Packages
  9627. with Multiple Outputs}). Such are the typical issues that
  9628. @command{guix size} can highlight.
  9629. The command can be passed one or more package specifications
  9630. such as @code{gcc@@4.8}
  9631. or @code{guile:debug}, or a file name in the store. Consider this
  9632. example:
  9633. @example
  9634. $ guix size coreutils
  9635. store item total self
  9636. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  9637. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  9638. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  9639. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  9640. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  9641. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  9642. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  9643. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  9644. total: 78.9 MiB
  9645. @end example
  9646. @cindex closure
  9647. The store items listed here constitute the @dfn{transitive closure} of
  9648. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  9649. would be returned by:
  9650. @example
  9651. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  9652. @end example
  9653. Here the output shows three columns next to store items. The first column,
  9654. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  9655. the store item---that is, its own size plus the size of all its
  9656. dependencies. The next column, labeled ``self'', shows the size of the
  9657. item itself. The last column shows the ratio of the size of the item
  9658. itself to the space occupied by all the items listed here.
  9659. In this example, we see that the closure of Coreutils weighs in at
  9660. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  9661. libraries. (That libc and GCC's libraries represent a large fraction of
  9662. the closure is not a problem @i{per se} because they are always available
  9663. on the system anyway.)
  9664. Since the command also accepts store file names, assessing the size of
  9665. a build result is straightforward:
  9666. @example
  9667. guix size $(guix system build config.scm)
  9668. @end example
  9669. When the package(s) passed to @command{guix size} are available in the
  9670. store@footnote{More precisely, @command{guix size} looks for the
  9671. @emph{ungrafted} variant of the given package(s), as returned by
  9672. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  9673. for information on grafts.}, @command{guix size} queries the daemon to determine its
  9674. dependencies, and measures its size in the store, similar to @command{du
  9675. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  9676. Coreutils}).
  9677. When the given packages are @emph{not} in the store, @command{guix size}
  9678. reports information based on the available substitutes
  9679. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  9680. store items that are not even on disk, only available remotely.
  9681. You can also specify several package names:
  9682. @example
  9683. $ guix size coreutils grep sed bash
  9684. store item total self
  9685. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  9686. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  9687. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  9688. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  9689. @dots{}
  9690. total: 102.3 MiB
  9691. @end example
  9692. @noindent
  9693. In this example we see that the combination of the four packages takes
  9694. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  9695. since they have a lot of dependencies in common.
  9696. When looking at the profile returned by @command{guix size}, you may
  9697. find yourself wondering why a given package shows up in the profile at
  9698. all. To understand it, you can use @command{guix graph --path -t
  9699. references} to display the shortest path between the two packages
  9700. (@pxref{Invoking guix graph}).
  9701. The available options are:
  9702. @table @option
  9703. @item --substitute-urls=@var{urls}
  9704. Use substitute information from @var{urls}.
  9705. @xref{client-substitute-urls, the same option for @code{guix build}}.
  9706. @item --sort=@var{key}
  9707. Sort lines according to @var{key}, one of the following options:
  9708. @table @code
  9709. @item self
  9710. the size of each item (the default);
  9711. @item closure
  9712. the total size of the item's closure.
  9713. @end table
  9714. @item --map-file=@var{file}
  9715. Write a graphical map of disk usage in PNG format to @var{file}.
  9716. For the example above, the map looks like this:
  9717. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  9718. produced by @command{guix size}}
  9719. This option requires that
  9720. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  9721. installed and visible in Guile's module search path. When that is not
  9722. the case, @command{guix size} fails as it tries to load it.
  9723. @item --system=@var{system}
  9724. @itemx -s @var{system}
  9725. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  9726. @item --load-path=@var{directory}
  9727. @itemx -L @var{directory}
  9728. Add @var{directory} to the front of the package module search path
  9729. (@pxref{Package Modules}).
  9730. This allows users to define their own packages and make them visible to
  9731. the command-line tools.
  9732. @end table
  9733. @node Invoking guix graph
  9734. @section Invoking @command{guix graph}
  9735. @cindex DAG
  9736. @cindex @command{guix graph}
  9737. @cindex package dependencies
  9738. Packages and their dependencies form a @dfn{graph}, specifically a
  9739. directed acyclic graph (DAG). It can quickly become difficult to have a
  9740. mental model of the package DAG, so the @command{guix graph} command
  9741. provides a visual representation of the DAG@. By default,
  9742. @command{guix graph} emits a DAG representation in the input format of
  9743. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  9744. directly to the @command{dot} command of Graphviz. It can also emit an
  9745. HTML page with embedded JavaScript code to display a ``chord diagram''
  9746. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  9747. emit Cypher queries to construct a graph in a graph database supporting
  9748. the @uref{https://www.opencypher.org/, openCypher} query language. With
  9749. @option{--path}, it simply displays the shortest path between two
  9750. packages. The general syntax is:
  9751. @example
  9752. guix graph @var{options} @var{package}@dots{}
  9753. @end example
  9754. For example, the following command generates a PDF file representing the
  9755. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  9756. dependencies:
  9757. @example
  9758. guix graph coreutils | dot -Tpdf > dag.pdf
  9759. @end example
  9760. The output looks like this:
  9761. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  9762. Nice little graph, no?
  9763. You may find it more pleasant to navigate the graph interactively with
  9764. @command{xdot} (from the @code{xdot} package):
  9765. @example
  9766. guix graph coreutils | xdot -
  9767. @end example
  9768. But there is more than one graph! The one above is concise: it is the
  9769. graph of package objects, omitting implicit inputs such as GCC, libc,
  9770. grep, etc. It is often useful to have such a concise graph, but
  9771. sometimes one may want to see more details. @command{guix graph} supports
  9772. several types of graphs, allowing you to choose the level of detail:
  9773. @table @code
  9774. @item package
  9775. This is the default type used in the example above. It shows the DAG of
  9776. package objects, excluding implicit dependencies. It is concise, but
  9777. filters out many details.
  9778. @item reverse-package
  9779. This shows the @emph{reverse} DAG of packages. For example:
  9780. @example
  9781. guix graph --type=reverse-package ocaml
  9782. @end example
  9783. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  9784. you are also interested in cases where OCaml is an implicit dependency, see
  9785. @code{reverse-bag} below).
  9786. Note that for core packages this can yield huge graphs. If all you want
  9787. is to know the number of packages that depend on a given package, use
  9788. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  9789. @option{--list-dependent}}).
  9790. @item bag-emerged
  9791. This is the package DAG, @emph{including} implicit inputs.
  9792. For instance, the following command:
  9793. @example
  9794. guix graph --type=bag-emerged coreutils
  9795. @end example
  9796. ...@: yields this bigger graph:
  9797. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  9798. At the bottom of the graph, we see all the implicit inputs of
  9799. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  9800. Now, note that the dependencies of these implicit inputs---that is, the
  9801. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  9802. here, for conciseness.
  9803. @item bag
  9804. Similar to @code{bag-emerged}, but this time including all the bootstrap
  9805. dependencies.
  9806. @item bag-with-origins
  9807. Similar to @code{bag}, but also showing origins and their dependencies.
  9808. @item reverse-bag
  9809. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  9810. it also takes implicit dependencies into account. For example:
  9811. @example
  9812. guix graph -t reverse-bag dune
  9813. @end example
  9814. @noindent
  9815. ...@: yields the graph of all packages that depend on Dune, directly or
  9816. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  9817. @i{via} @code{dune-build-system}, this shows a large number of packages,
  9818. whereas @code{reverse-package} would show very few if any.
  9819. @item derivation
  9820. This is the most detailed representation: It shows the DAG of
  9821. derivations (@pxref{Derivations}) and plain store items. Compared to
  9822. the above representation, many additional nodes are visible, including
  9823. build scripts, patches, Guile modules, etc.
  9824. For this type of graph, it is also possible to pass a @file{.drv} file
  9825. name instead of a package name, as in:
  9826. @example
  9827. guix graph -t derivation `guix system build -d my-config.scm`
  9828. @end example
  9829. @item module
  9830. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  9831. For example, the following command shows the graph for the package
  9832. module that defines the @code{guile} package:
  9833. @example
  9834. guix graph -t module guile | xdot -
  9835. @end example
  9836. @end table
  9837. All the types above correspond to @emph{build-time dependencies}. The
  9838. following graph type represents the @emph{run-time dependencies}:
  9839. @table @code
  9840. @item references
  9841. This is the graph of @dfn{references} of a package output, as returned
  9842. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  9843. If the given package output is not available in the store, @command{guix
  9844. graph} attempts to obtain dependency information from substitutes.
  9845. Here you can also pass a store file name instead of a package name. For
  9846. example, the command below produces the reference graph of your profile
  9847. (which can be big!):
  9848. @example
  9849. guix graph -t references `readlink -f ~/.guix-profile`
  9850. @end example
  9851. @item referrers
  9852. This is the graph of the @dfn{referrers} of a store item, as returned by
  9853. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  9854. This relies exclusively on local information from your store. For
  9855. instance, let us suppose that the current Inkscape is available in 10
  9856. profiles on your machine; @command{guix graph -t referrers inkscape}
  9857. will show a graph rooted at Inkscape and with those 10 profiles linked
  9858. to it.
  9859. It can help determine what is preventing a store item from being garbage
  9860. collected.
  9861. @end table
  9862. @cindex shortest path, between packages
  9863. Often, the graph of the package you are interested in does not fit on
  9864. your screen, and anyway all you want to know is @emph{why} that package
  9865. actually depends on some seemingly unrelated package. The
  9866. @option{--path} option instructs @command{guix graph} to display the
  9867. shortest path between two packages (or derivations, or store items,
  9868. etc.):
  9869. @example
  9870. $ guix graph --path emacs libunistring
  9871. emacs@@26.3
  9872. mailutils@@3.9
  9873. libunistring@@0.9.10
  9874. $ guix graph --path -t derivation emacs libunistring
  9875. /gnu/store/@dots{}-emacs-26.3.drv
  9876. /gnu/store/@dots{}-mailutils-3.9.drv
  9877. /gnu/store/@dots{}-libunistring-0.9.10.drv
  9878. $ guix graph --path -t references emacs libunistring
  9879. /gnu/store/@dots{}-emacs-26.3
  9880. /gnu/store/@dots{}-libidn2-2.2.0
  9881. /gnu/store/@dots{}-libunistring-0.9.10
  9882. @end example
  9883. The available options are the following:
  9884. @table @option
  9885. @item --type=@var{type}
  9886. @itemx -t @var{type}
  9887. Produce a graph output of @var{type}, where @var{type} must be one of
  9888. the values listed above.
  9889. @item --list-types
  9890. List the supported graph types.
  9891. @item --backend=@var{backend}
  9892. @itemx -b @var{backend}
  9893. Produce a graph using the selected @var{backend}.
  9894. @item --list-backends
  9895. List the supported graph backends.
  9896. Currently, the available backends are Graphviz and d3.js.
  9897. @item --path
  9898. Display the shortest path between two nodes of the type specified by
  9899. @option{--type}. The example below shows the shortest path between
  9900. @code{libreoffice} and @code{llvm} according to the references of
  9901. @code{libreoffice}:
  9902. @example
  9903. $ guix graph --path -t references libreoffice llvm
  9904. /gnu/store/@dots{}-libreoffice-6.4.2.2
  9905. /gnu/store/@dots{}-libepoxy-1.5.4
  9906. /gnu/store/@dots{}-mesa-19.3.4
  9907. /gnu/store/@dots{}-llvm-9.0.1
  9908. @end example
  9909. @item --expression=@var{expr}
  9910. @itemx -e @var{expr}
  9911. Consider the package @var{expr} evaluates to.
  9912. This is useful to precisely refer to a package, as in this example:
  9913. @example
  9914. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  9915. @end example
  9916. @item --system=@var{system}
  9917. @itemx -s @var{system}
  9918. Display the graph for @var{system}---e.g., @code{i686-linux}.
  9919. The package dependency graph is largely architecture-independent, but there
  9920. are some architecture-dependent bits that this option allows you to visualize.
  9921. @item --load-path=@var{directory}
  9922. @itemx -L @var{directory}
  9923. Add @var{directory} to the front of the package module search path
  9924. (@pxref{Package Modules}).
  9925. This allows users to define their own packages and make them visible to
  9926. the command-line tools.
  9927. @end table
  9928. On top of that, @command{guix graph} supports all the usual package
  9929. transformation options (@pxref{Package Transformation Options}). This
  9930. makes it easy to view the effect of a graph-rewriting transformation
  9931. such as @option{--with-input}. For example, the command below outputs
  9932. the graph of @code{git} once @code{openssl} has been replaced by
  9933. @code{libressl} everywhere in the graph:
  9934. @example
  9935. guix graph git --with-input=openssl=libressl
  9936. @end example
  9937. So many possibilities, so much fun!
  9938. @node Invoking guix publish
  9939. @section Invoking @command{guix publish}
  9940. @cindex @command{guix publish}
  9941. The purpose of @command{guix publish} is to enable users to easily share
  9942. their store with others, who can then use it as a substitute server
  9943. (@pxref{Substitutes}).
  9944. When @command{guix publish} runs, it spawns an HTTP server which allows
  9945. anyone with network access to obtain substitutes from it. This means
  9946. that any machine running Guix can also act as if it were a build farm,
  9947. since the HTTP interface is compatible with Cuirass, the software behind
  9948. the @code{@value{SUBSTITUTE-SERVER}} build farm.
  9949. For security, each substitute is signed, allowing recipients to check
  9950. their authenticity and integrity (@pxref{Substitutes}). Because
  9951. @command{guix publish} uses the signing key of the system, which is only
  9952. readable by the system administrator, it must be started as root; the
  9953. @option{--user} option makes it drop root privileges early on.
  9954. The signing key pair must be generated before @command{guix publish} is
  9955. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  9956. guix archive}).
  9957. When the @option{--advertise} option is passed, the server advertises
  9958. its availability on the local network using multicast DNS (mDNS) and DNS
  9959. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  9960. guile-avahi, Using Avahi in Guile Scheme Programs}).
  9961. The general syntax is:
  9962. @example
  9963. guix publish @var{options}@dots{}
  9964. @end example
  9965. Running @command{guix publish} without any additional arguments will
  9966. spawn an HTTP server on port 8080:
  9967. @example
  9968. guix publish
  9969. @end example
  9970. Once a publishing server has been authorized, the daemon may download
  9971. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  9972. By default, @command{guix publish} compresses archives on the fly as it
  9973. serves them. This ``on-the-fly'' mode is convenient in that it requires
  9974. no setup and is immediately available. However, when serving lots of
  9975. clients, we recommend using the @option{--cache} option, which enables
  9976. caching of the archives before they are sent to clients---see below for
  9977. details. The @command{guix weather} command provides a handy way to
  9978. check what a server provides (@pxref{Invoking guix weather}).
  9979. As a bonus, @command{guix publish} also serves as a content-addressed
  9980. mirror for source files referenced in @code{origin} records
  9981. (@pxref{origin Reference}). For instance, assuming @command{guix
  9982. publish} is running on @code{example.org}, the following URL returns the
  9983. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  9984. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  9985. @example
  9986. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  9987. @end example
  9988. Obviously, these URLs only work for files that are in the store; in
  9989. other cases, they return 404 (``Not Found'').
  9990. @cindex build logs, publication
  9991. Build logs are available from @code{/log} URLs like:
  9992. @example
  9993. http://example.org/log/gwspk@dots{}-guile-2.2.3
  9994. @end example
  9995. @noindent
  9996. When @command{guix-daemon} is configured to save compressed build logs,
  9997. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  9998. URLs return the compressed log as-is, with an appropriate
  9999. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  10000. running @command{guix-daemon} with @option{--log-compression=gzip} since
  10001. Web browsers can automatically decompress it, which is not the case with
  10002. Bzip2 compression.
  10003. The following options are available:
  10004. @table @code
  10005. @item --port=@var{port}
  10006. @itemx -p @var{port}
  10007. Listen for HTTP requests on @var{port}.
  10008. @item --listen=@var{host}
  10009. Listen on the network interface for @var{host}. The default is to
  10010. accept connections from any interface.
  10011. @item --user=@var{user}
  10012. @itemx -u @var{user}
  10013. Change privileges to @var{user} as soon as possible---i.e., once the
  10014. server socket is open and the signing key has been read.
  10015. @item --compression[=@var{method}[:@var{level}]]
  10016. @itemx -C [@var{method}[:@var{level}]]
  10017. Compress data using the given @var{method} and @var{level}. @var{method} is
  10018. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  10019. omitted, @code{gzip} is used.
  10020. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  10021. to different compression levels: 1 is the fastest, and 9 is the best
  10022. (CPU-intensive). The default is 3.
  10023. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  10024. small increase in CPU usage; see
  10025. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  10026. Web page}. However, @code{lzip} achieves low decompression throughput
  10027. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  10028. bottleneck for someone who downloads over a fast network connection.
  10029. The compression ratio of @code{zstd} is between that of @code{lzip} and
  10030. that of @code{gzip}; its main advantage is a
  10031. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  10032. Unless @option{--cache} is used, compression occurs on the fly and
  10033. the compressed streams are not
  10034. cached. Thus, to reduce load on the machine that runs @command{guix
  10035. publish}, it may be a good idea to choose a low compression level, to
  10036. run @command{guix publish} behind a caching proxy, or to use
  10037. @option{--cache}. Using @option{--cache} has the advantage that it
  10038. allows @command{guix publish} to add @code{Content-Length} HTTP header
  10039. to its responses.
  10040. This option can be repeated, in which case every substitute gets compressed
  10041. using all the selected methods, and all of them are advertised. This is
  10042. useful when users may not support all the compression methods: they can select
  10043. the one they support.
  10044. @item --cache=@var{directory}
  10045. @itemx -c @var{directory}
  10046. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  10047. and only serve archives that are in cache.
  10048. When this option is omitted, archives and meta-data are created
  10049. on-the-fly. This can reduce the available bandwidth, especially when
  10050. compression is enabled, since this may become CPU-bound. Another
  10051. drawback of the default mode is that the length of archives is not known
  10052. in advance, so @command{guix publish} does not add a
  10053. @code{Content-Length} HTTP header to its responses, which in turn
  10054. prevents clients from knowing the amount of data being downloaded.
  10055. Conversely, when @option{--cache} is used, the first request for a store
  10056. item (@i{via} a @code{.narinfo} URL) triggers a
  10057. background process to @dfn{bake} the archive---computing its
  10058. @code{.narinfo} and compressing the archive, if needed. Once the
  10059. archive is cached in @var{directory}, subsequent requests succeed and
  10060. are served directly from the cache, which guarantees that clients get
  10061. the best possible bandwidth.
  10062. That first @code{.narinfo} request nonetheless returns 200, provided the
  10063. requested store item is ``small enough'', below the cache bypass
  10064. threshold---see @option{--cache-bypass-threshold} below. That way,
  10065. clients do not have to wait until the archive is baked. For larger
  10066. store items, the first @code{.narinfo} request returns 404, meaning that
  10067. clients have to wait until the archive is baked.
  10068. The ``baking'' process is performed by worker threads. By default, one
  10069. thread per CPU core is created, but this can be customized. See
  10070. @option{--workers} below.
  10071. When @option{--ttl} is used, cached entries are automatically deleted
  10072. when they have expired.
  10073. @item --workers=@var{N}
  10074. When @option{--cache} is used, request the allocation of @var{N} worker
  10075. threads to ``bake'' archives.
  10076. @item --ttl=@var{ttl}
  10077. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  10078. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  10079. days, @code{1m} means 1 month, and so on.
  10080. This allows the user's Guix to keep substitute information in cache for
  10081. @var{ttl}. However, note that @code{guix publish} does not itself
  10082. guarantee that the store items it provides will indeed remain available
  10083. for as long as @var{ttl}.
  10084. Additionally, when @option{--cache} is used, cached entries that have
  10085. not been accessed for @var{ttl} and that no longer have a corresponding
  10086. item in the store, may be deleted.
  10087. @item --cache-bypass-threshold=@var{size}
  10088. When used in conjunction with @option{--cache}, store items smaller than
  10089. @var{size} are immediately available, even when they are not yet in
  10090. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  10091. for megabytes and so on. The default is @code{10M}.
  10092. ``Cache bypass'' allows you to reduce the publication delay for clients
  10093. at the expense of possibly additional I/O and CPU use on the server
  10094. side: depending on the client access patterns, those store items can end
  10095. up being baked several times until a copy is available in cache.
  10096. Increasing the threshold may be useful for sites that have few users, or
  10097. to guarantee that users get substitutes even for store items that are
  10098. not popular.
  10099. @item --nar-path=@var{path}
  10100. Use @var{path} as the prefix for the URLs of ``nar'' files
  10101. (@pxref{Invoking guix archive, normalized archives}).
  10102. By default, nars are served at a URL such as
  10103. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  10104. change the @code{/nar} part to @var{path}.
  10105. @item --public-key=@var{file}
  10106. @itemx --private-key=@var{file}
  10107. Use the specific @var{file}s as the public/private key pair used to sign
  10108. the store items being published.
  10109. The files must correspond to the same key pair (the private key is used
  10110. for signing and the public key is merely advertised in the signature
  10111. metadata). They must contain keys in the canonical s-expression format
  10112. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  10113. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  10114. @file{/etc/guix/signing-key.sec} are used.
  10115. @item --repl[=@var{port}]
  10116. @itemx -r [@var{port}]
  10117. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  10118. Reference Manual}) on @var{port} (37146 by default). This is used
  10119. primarily for debugging a running @command{guix publish} server.
  10120. @end table
  10121. Enabling @command{guix publish} on Guix System is a one-liner: just
  10122. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  10123. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  10124. @code{guix-publish-service-type}}).
  10125. If you are instead running Guix on a ``foreign distro'', follow these
  10126. instructions:
  10127. @itemize
  10128. @item
  10129. If your host distro uses the systemd init system:
  10130. @example
  10131. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  10132. /etc/systemd/system/
  10133. # systemctl start guix-publish && systemctl enable guix-publish
  10134. @end example
  10135. @item
  10136. If your host distro uses the Upstart init system:
  10137. @example
  10138. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  10139. # start guix-publish
  10140. @end example
  10141. @item
  10142. Otherwise, proceed similarly with your distro's init system.
  10143. @end itemize
  10144. @node Invoking guix challenge
  10145. @section Invoking @command{guix challenge}
  10146. @cindex reproducible builds
  10147. @cindex verifiable builds
  10148. @cindex @command{guix challenge}
  10149. @cindex challenge
  10150. Do the binaries provided by this server really correspond to the source
  10151. code it claims to build? Is a package build process deterministic?
  10152. These are the questions the @command{guix challenge} command attempts to
  10153. answer.
  10154. The former is obviously an important question: Before using a substitute
  10155. server (@pxref{Substitutes}), one had better @emph{verify} that it
  10156. provides the right binaries, and thus @emph{challenge} it. The latter
  10157. is what enables the former: If package builds are deterministic, then
  10158. independent builds of the package should yield the exact same result,
  10159. bit for bit; if a server provides a binary different from the one
  10160. obtained locally, it may be either corrupt or malicious.
  10161. We know that the hash that shows up in @file{/gnu/store} file names is
  10162. the hash of all the inputs of the process that built the file or
  10163. directory---compilers, libraries, build scripts,
  10164. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  10165. one store file name should map to exactly one build output.
  10166. @command{guix challenge} checks whether there is, indeed, a single
  10167. mapping by comparing the build outputs of several independent builds of
  10168. any given store item.
  10169. The command output looks like this:
  10170. @smallexample
  10171. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10172. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
  10173. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10174. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  10175. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10176. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10177. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  10178. differing files:
  10179. /lib/libcrypto.so.1.1
  10180. /lib/libssl.so.1.1
  10181. /gnu/store/@dots{}-git-2.5.0 contents differ:
  10182. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  10183. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  10184. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  10185. differing file:
  10186. /libexec/git-core/git-fsck
  10187. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  10188. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10189. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10190. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  10191. differing file:
  10192. /share/man/man1/pius.1.gz
  10193. @dots{}
  10194. 6,406 store items were analyzed:
  10195. - 4,749 (74.1%) were identical
  10196. - 525 (8.2%) differed
  10197. - 1,132 (17.7%) were inconclusive
  10198. @end smallexample
  10199. @noindent
  10200. In this example, @command{guix challenge} first scans the store to
  10201. determine the set of locally-built derivations---as opposed to store
  10202. items that were downloaded from a substitute server---and then queries
  10203. all the substitute servers. It then reports those store items for which
  10204. the servers obtained a result different from the local build.
  10205. @cindex non-determinism, in package builds
  10206. As an example, @code{guix.example.org} always gets a different answer.
  10207. Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
  10208. case of Git. This might indicate that the build process of Git is
  10209. non-deterministic, meaning that its output varies as a function of
  10210. various things that Guix does not fully control, in spite of building
  10211. packages in isolated environments (@pxref{Features}). Most common
  10212. sources of non-determinism include the addition of timestamps in build
  10213. results, the inclusion of random numbers, and directory listings sorted
  10214. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  10215. more information.
  10216. To find out what is wrong with this Git binary, the easiest approach is
  10217. to run:
  10218. @example
  10219. guix challenge git \
  10220. --diff=diffoscope \
  10221. --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10222. @end example
  10223. This automatically invokes @command{diffoscope}, which displays detailed
  10224. information about files that differ.
  10225. Alternatively, we can do something along these lines (@pxref{Invoking guix
  10226. archive}):
  10227. @example
  10228. $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-git-2.5.0 \
  10229. | lzip -d | guix archive -x /tmp/git
  10230. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  10231. @end example
  10232. This command shows the difference between the files resulting from the
  10233. local build, and the files resulting from the build on
  10234. @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
  10235. diffutils, Comparing and Merging Files}). The @command{diff} command
  10236. works great for text files. When binary files differ, a better option
  10237. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  10238. visualize differences for all kinds of files.
  10239. Once you have done that work, you can tell whether the differences are due
  10240. to a non-deterministic build process or to a malicious server. We try
  10241. hard to remove sources of non-determinism in packages to make it easier
  10242. to verify substitutes, but of course, this is a process that
  10243. involves not just Guix, but a large part of the free software community.
  10244. In the meantime, @command{guix challenge} is one tool to help address
  10245. the problem.
  10246. If you are writing packages for Guix, you are encouraged to check
  10247. whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
  10248. same build result as you did with:
  10249. @example
  10250. $ guix challenge @var{package}
  10251. @end example
  10252. @noindent
  10253. where @var{package} is a package specification such as
  10254. @code{guile@@2.0} or @code{glibc:debug}.
  10255. The general syntax is:
  10256. @example
  10257. guix challenge @var{options} [@var{packages}@dots{}]
  10258. @end example
  10259. When a difference is found between the hash of a locally-built item and
  10260. that of a server-provided substitute, or among substitutes provided by
  10261. different servers, the command displays it as in the example above and
  10262. its exit code is 2 (other non-zero exit codes denote other kinds of
  10263. errors).
  10264. The one option that matters is:
  10265. @table @code
  10266. @item --substitute-urls=@var{urls}
  10267. Consider @var{urls} the whitespace-separated list of substitute source
  10268. URLs to compare to.
  10269. @item --diff=@var{mode}
  10270. Upon mismatches, show differences according to @var{mode}, one of:
  10271. @table @asis
  10272. @item @code{simple} (the default)
  10273. Show the list of files that differ.
  10274. @item @code{diffoscope}
  10275. @itemx @var{command}
  10276. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  10277. two directories whose contents do not match.
  10278. When @var{command} is an absolute file name, run @var{command} instead
  10279. of Diffoscope.
  10280. @item @code{none}
  10281. Do not show further details about the differences.
  10282. @end table
  10283. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  10284. downloads the store items from the given substitute servers so that it
  10285. can compare them.
  10286. @item --verbose
  10287. @itemx -v
  10288. Show details about matches (identical contents) in addition to
  10289. information about mismatches.
  10290. @end table
  10291. @node Invoking guix copy
  10292. @section Invoking @command{guix copy}
  10293. @cindex copy, of store items, over SSH
  10294. @cindex SSH, copy of store items
  10295. @cindex sharing store items across machines
  10296. @cindex transferring store items across machines
  10297. The @command{guix copy} command copies items from the store of one
  10298. machine to that of another machine over a secure shell (SSH)
  10299. connection@footnote{This command is available only when Guile-SSH was
  10300. found. @xref{Requirements}, for details.}. For example, the following
  10301. command copies the @code{coreutils} package, the user's profile, and all
  10302. their dependencies over to @var{host}, logged in as @var{user}:
  10303. @example
  10304. guix copy --to=@var{user}@@@var{host} \
  10305. coreutils `readlink -f ~/.guix-profile`
  10306. @end example
  10307. If some of the items to be copied are already present on @var{host},
  10308. they are not actually sent.
  10309. The command below retrieves @code{libreoffice} and @code{gimp} from
  10310. @var{host}, assuming they are available there:
  10311. @example
  10312. guix copy --from=@var{host} libreoffice gimp
  10313. @end example
  10314. The SSH connection is established using the Guile-SSH client, which is
  10315. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  10316. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  10317. The key used to sign items that are sent must be accepted by the remote
  10318. machine. Likewise, the key used by the remote machine to sign items you
  10319. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  10320. own daemon. @xref{Invoking guix archive}, for more information about
  10321. store item authentication.
  10322. The general syntax is:
  10323. @example
  10324. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  10325. @end example
  10326. You must always specify one of the following options:
  10327. @table @code
  10328. @item --to=@var{spec}
  10329. @itemx --from=@var{spec}
  10330. Specify the host to send to or receive from. @var{spec} must be an SSH
  10331. spec such as @code{example.org}, @code{charlie@@example.org}, or
  10332. @code{charlie@@example.org:2222}.
  10333. @end table
  10334. The @var{items} can be either package names, such as @code{gimp}, or
  10335. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  10336. When specifying the name of a package to send, it is first built if
  10337. needed, unless @option{--dry-run} was specified. Common build options
  10338. are supported (@pxref{Common Build Options}).
  10339. @node Invoking guix container
  10340. @section Invoking @command{guix container}
  10341. @cindex container
  10342. @cindex @command{guix container}
  10343. @quotation Note
  10344. As of version @value{VERSION}, this tool is experimental. The interface
  10345. is subject to radical change in the future.
  10346. @end quotation
  10347. The purpose of @command{guix container} is to manipulate processes
  10348. running within an isolated environment, commonly known as a
  10349. ``container'', typically created by the @command{guix environment}
  10350. (@pxref{Invoking guix environment}) and @command{guix system container}
  10351. (@pxref{Invoking guix system}) commands.
  10352. The general syntax is:
  10353. @example
  10354. guix container @var{action} @var{options}@dots{}
  10355. @end example
  10356. @var{action} specifies the operation to perform with a container, and
  10357. @var{options} specifies the context-specific arguments for the action.
  10358. The following actions are available:
  10359. @table @code
  10360. @item exec
  10361. Execute a command within the context of a running container.
  10362. The syntax is:
  10363. @example
  10364. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  10365. @end example
  10366. @var{pid} specifies the process ID of the running container.
  10367. @var{program} specifies an executable file name within the root file
  10368. system of the container. @var{arguments} are the additional options that
  10369. will be passed to @var{program}.
  10370. The following command launches an interactive login shell inside a
  10371. Guix system container, started by @command{guix system container}, and whose
  10372. process ID is 9001:
  10373. @example
  10374. guix container exec 9001 /run/current-system/profile/bin/bash --login
  10375. @end example
  10376. Note that the @var{pid} cannot be the parent process of a container. It
  10377. must be PID 1 of the container or one of its child processes.
  10378. @end table
  10379. @node Invoking guix weather
  10380. @section Invoking @command{guix weather}
  10381. Occasionally you're grumpy because substitutes are lacking and you end
  10382. up building packages by yourself (@pxref{Substitutes}). The
  10383. @command{guix weather} command reports on substitute availability on the
  10384. specified servers so you can have an idea of whether you'll be grumpy
  10385. today. It can sometimes be useful info as a user, but it is primarily
  10386. useful to people running @command{guix publish} (@pxref{Invoking guix
  10387. publish}).
  10388. @cindex statistics, for substitutes
  10389. @cindex availability of substitutes
  10390. @cindex substitute availability
  10391. @cindex weather, substitute availability
  10392. Here's a sample run:
  10393. @example
  10394. $ guix weather --substitute-urls=https://guix.example.org
  10395. computing 5,872 package derivations for x86_64-linux...
  10396. looking for 6,128 store items on https://guix.example.org..
  10397. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10398. https://guix.example.org
  10399. 43.4% substitutes available (2,658 out of 6,128)
  10400. 7,032.5 MiB of nars (compressed)
  10401. 19,824.2 MiB on disk (uncompressed)
  10402. 0.030 seconds per request (182.9 seconds in total)
  10403. 33.5 requests per second
  10404. 9.8% (342 out of 3,470) of the missing items are queued
  10405. 867 queued builds
  10406. x86_64-linux: 518 (59.7%)
  10407. i686-linux: 221 (25.5%)
  10408. aarch64-linux: 128 (14.8%)
  10409. build rate: 23.41 builds per hour
  10410. x86_64-linux: 11.16 builds per hour
  10411. i686-linux: 6.03 builds per hour
  10412. aarch64-linux: 6.41 builds per hour
  10413. @end example
  10414. @cindex continuous integration, statistics
  10415. As you can see, it reports the fraction of all the packages for which
  10416. substitutes are available on the server---regardless of whether
  10417. substitutes are enabled, and regardless of whether this server's signing
  10418. key is authorized. It also reports the size of the compressed archives
  10419. (``nars'') provided by the server, the size the corresponding store
  10420. items occupy in the store (assuming deduplication is turned off), and
  10421. the server's throughput. The second part gives continuous integration
  10422. (CI) statistics, if the server supports it. In addition, using the
  10423. @option{--coverage} option, @command{guix weather} can list ``important''
  10424. package substitutes missing on the server (see below).
  10425. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  10426. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  10427. challenge}, it ignores signatures on those substitutes, which is
  10428. innocuous since the command only gathers statistics and cannot install
  10429. those substitutes.
  10430. The general syntax is:
  10431. @example
  10432. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  10433. @end example
  10434. When @var{packages} is omitted, @command{guix weather} checks the availability
  10435. of substitutes for @emph{all} the packages, or for those specified with
  10436. @option{--manifest}; otherwise it only considers the specified packages. It
  10437. is also possible to query specific system types with @option{--system}.
  10438. @command{guix weather} exits with a non-zero code when the fraction of
  10439. available substitutes is below 100%.
  10440. The available options are listed below.
  10441. @table @code
  10442. @item --substitute-urls=@var{urls}
  10443. @var{urls} is the space-separated list of substitute server URLs to
  10444. query. When this option is omitted, the default set of substitute
  10445. servers is queried.
  10446. @item --system=@var{system}
  10447. @itemx -s @var{system}
  10448. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  10449. option can be repeated, in which case @command{guix weather} will query
  10450. substitutes for several system types.
  10451. @item --manifest=@var{file}
  10452. Instead of querying substitutes for all the packages, only ask for those
  10453. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  10454. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  10455. guix package}).
  10456. This option can be repeated several times, in which case the manifests
  10457. are concatenated.
  10458. @item --coverage[=@var{count}]
  10459. @itemx -c [@var{count}]
  10460. Report on substitute coverage for packages: list packages with at least
  10461. @var{count} dependents (zero by default) for which substitutes are
  10462. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  10463. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  10464. @var{b} usually lacks substitutes as well. The result looks like this:
  10465. @example
  10466. $ guix weather --substitute-urls=@value{SUBSTITUTE-URL} -c 10
  10467. computing 8,983 package derivations for x86_64-linux...
  10468. looking for 9,343 store items on @value{SUBSTITUTE-URL}...
  10469. updating substitutes from '@value{SUBSTITUTE-URL}'... 100.0%
  10470. @value{SUBSTITUTE-URL}
  10471. 64.7% substitutes available (6,047 out of 9,343)
  10472. @dots{}
  10473. 2502 packages are missing from '@value{SUBSTITUTE-URL}' for 'x86_64-linux', among which:
  10474. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  10475. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  10476. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  10477. @dots{}
  10478. @end example
  10479. What this example shows is that @code{kcoreaddons} and presumably the 58
  10480. packages that depend on it have no substitutes at
  10481. @code{@value{SUBSTITUTE-SERVER}}; likewise for @code{qgpgme} and the 46
  10482. packages that depend on it.
  10483. If you are a Guix developer, or if you are taking care of this build farm,
  10484. you'll probably want to have a closer look at these packages: they may simply
  10485. fail to build.
  10486. @item --display-missing
  10487. Display the list of store items for which substitutes are missing.
  10488. @end table
  10489. @node Invoking guix processes
  10490. @section Invoking @command{guix processes}
  10491. The @command{guix processes} command can be useful to developers and system
  10492. administrators, especially on multi-user machines and on build farms: it lists
  10493. the current sessions (connections to the daemon), as well as information about
  10494. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  10495. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  10496. listed.}. Here's an example of the information it returns:
  10497. @example
  10498. $ sudo guix processes
  10499. SessionPID: 19002
  10500. ClientPID: 19090
  10501. ClientCommand: guix environment --ad-hoc python
  10502. SessionPID: 19402
  10503. ClientPID: 19367
  10504. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  10505. SessionPID: 19444
  10506. ClientPID: 19419
  10507. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10508. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  10509. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  10510. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  10511. ChildPID: 20495
  10512. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10513. ChildPID: 27733
  10514. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10515. ChildPID: 27793
  10516. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10517. @end example
  10518. In this example we see that @command{guix-daemon} has three clients:
  10519. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  10520. integration tool; their process identifier (PID) is given by the
  10521. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  10522. @command{guix-daemon} sub-process of this particular session.
  10523. The @code{LockHeld} fields show which store items are currently locked
  10524. by this session, which corresponds to store items being built or
  10525. substituted (the @code{LockHeld} field is not displayed when
  10526. @command{guix processes} is not running as root). Last, by looking at
  10527. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  10528. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  10529. The output is in Recutils format so we can use the handy @command{recsel}
  10530. command to select sessions of interest (@pxref{Selection Expressions,,,
  10531. recutils, GNU recutils manual}). As an example, the command shows the command
  10532. line and PID of the client that triggered the build of a Perl package:
  10533. @example
  10534. $ sudo guix processes | \
  10535. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  10536. ClientPID: 19419
  10537. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10538. @end example
  10539. Additional options are listed below.
  10540. @table @code
  10541. @item --format=@var{format}
  10542. @itemx -f @var{format}
  10543. Produce output in the specified @var{format}, one of:
  10544. @table @code
  10545. @item recutils
  10546. The default option. It outputs a set of Session recutils records
  10547. that include each @code{ChildProcess} as a field.
  10548. @item normalized
  10549. Normalize the output records into record sets (@pxref{Record Sets,,,
  10550. recutils, GNU recutils manual}). Normalizing into record sets allows
  10551. joins across record types. The example below lists the PID of each
  10552. @code{ChildProcess} and the associated PID for @code{Session} that
  10553. spawned the @code{ChildProcess} where the @code{Session} was started
  10554. using @command{guix build}.
  10555. @example
  10556. $ guix processes --format=normalized | \
  10557. recsel \
  10558. -j Session \
  10559. -t ChildProcess \
  10560. -p Session.PID,PID \
  10561. -e 'Session.ClientCommand ~ "guix build"'
  10562. PID: 4435
  10563. Session_PID: 4278
  10564. PID: 4554
  10565. Session_PID: 4278
  10566. PID: 4646
  10567. Session_PID: 4278
  10568. @end example
  10569. @end table
  10570. @end table
  10571. @node System Configuration
  10572. @chapter System Configuration
  10573. @cindex system configuration
  10574. Guix System supports a consistent whole-system configuration
  10575. mechanism. By that we mean that all aspects of the global system
  10576. configuration---such as the available system services, timezone and
  10577. locale settings, user accounts---are declared in a single place. Such
  10578. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  10579. One of the advantages of putting all the system configuration under the
  10580. control of Guix is that it supports transactional system upgrades, and
  10581. makes it possible to roll back to a previous system instantiation,
  10582. should something go wrong with the new one (@pxref{Features}). Another
  10583. advantage is that it makes it easy to replicate the exact same configuration
  10584. across different machines, or at different points in time, without
  10585. having to resort to additional administration tools layered on top of
  10586. the own tools of the system.
  10587. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  10588. This section describes this mechanism. First we focus on the system
  10589. administrator's viewpoint---explaining how the system is configured and
  10590. instantiated. Then we show how this mechanism can be extended, for
  10591. instance to support new system services.
  10592. @menu
  10593. * Using the Configuration System:: Customizing your GNU system.
  10594. * operating-system Reference:: Detail of operating-system declarations.
  10595. * File Systems:: Configuring file system mounts.
  10596. * Mapped Devices:: Block device extra processing.
  10597. * User Accounts:: Specifying user accounts.
  10598. * Keyboard Layout:: How the system interprets key strokes.
  10599. * Locales:: Language and cultural convention settings.
  10600. * Services:: Specifying system services.
  10601. * Setuid Programs:: Programs running with root privileges.
  10602. * X.509 Certificates:: Authenticating HTTPS servers.
  10603. * Name Service Switch:: Configuring libc's name service switch.
  10604. * Initial RAM Disk:: Linux-Libre bootstrapping.
  10605. * Bootloader Configuration:: Configuring the boot loader.
  10606. * Invoking guix system:: Instantiating a system configuration.
  10607. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  10608. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  10609. * Defining Services:: Adding new service definitions.
  10610. @end menu
  10611. @node Using the Configuration System
  10612. @section Using the Configuration System
  10613. The operating system is configured by providing an
  10614. @code{operating-system} declaration in a file that can then be passed to
  10615. the @command{guix system} command (@pxref{Invoking guix system}). A
  10616. simple setup, with the default system services, the default Linux-Libre
  10617. kernel, initial RAM disk, and boot loader looks like this:
  10618. @findex operating-system
  10619. @lisp
  10620. @include os-config-bare-bones.texi
  10621. @end lisp
  10622. This example should be self-describing. Some of the fields defined
  10623. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  10624. Others, such as @code{packages} and @code{services}, can be omitted, in
  10625. which case they get a default value.
  10626. Below we discuss the effect of some of the most important fields
  10627. (@pxref{operating-system Reference}, for details about all the available
  10628. fields), and how to @dfn{instantiate} the operating system using
  10629. @command{guix system}.
  10630. @unnumberedsubsec Bootloader
  10631. @cindex legacy boot, on Intel machines
  10632. @cindex BIOS boot, on Intel machines
  10633. @cindex UEFI boot
  10634. @cindex EFI boot
  10635. The @code{bootloader} field describes the method that will be used to boot
  10636. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  10637. mode, as in the example above. However, more recent machines rely instead on
  10638. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  10639. the @code{bootloader} field should contain something along these lines:
  10640. @lisp
  10641. (bootloader-configuration
  10642. (bootloader grub-efi-bootloader)
  10643. (target "/boot/efi"))
  10644. @end lisp
  10645. @xref{Bootloader Configuration}, for more information on the available
  10646. configuration options.
  10647. @unnumberedsubsec Globally-Visible Packages
  10648. @vindex %base-packages
  10649. The @code{packages} field lists packages that will be globally visible
  10650. on the system, for all user accounts---i.e., in every user's @env{PATH}
  10651. environment variable---in addition to the per-user profiles
  10652. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  10653. provides all the tools one would expect for basic user and administrator
  10654. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  10655. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  10656. etc. The example above adds GNU@tie{}Screen to those,
  10657. taken from the @code{(gnu packages screen)}
  10658. module (@pxref{Package Modules}). The
  10659. @code{(list package output)} syntax can be used to add a specific output
  10660. of a package:
  10661. @lisp
  10662. (use-modules (gnu packages))
  10663. (use-modules (gnu packages dns))
  10664. (operating-system
  10665. ;; ...
  10666. (packages (cons (list bind "utils")
  10667. %base-packages)))
  10668. @end lisp
  10669. @findex specification->package
  10670. Referring to packages by variable name, like @code{bind} above, has
  10671. the advantage of being unambiguous; it also allows typos and such to be
  10672. diagnosed right away as ``unbound variables''. The downside is that one
  10673. needs to know which module defines which package, and to augment the
  10674. @code{use-package-modules} line accordingly. To avoid that, one can use
  10675. the @code{specification->package} procedure of the @code{(gnu packages)}
  10676. module, which returns the best package for a given name or name and
  10677. version:
  10678. @lisp
  10679. (use-modules (gnu packages))
  10680. (operating-system
  10681. ;; ...
  10682. (packages (append (map specification->package
  10683. '("tcpdump" "htop" "gnupg@@2.0"))
  10684. %base-packages)))
  10685. @end lisp
  10686. @unnumberedsubsec System Services
  10687. @cindex services
  10688. @vindex %base-services
  10689. The @code{services} field lists @dfn{system services} to be made
  10690. available when the system starts (@pxref{Services}).
  10691. The @code{operating-system} declaration above specifies that, in
  10692. addition to the basic services, we want the OpenSSH secure shell
  10693. daemon listening on port 2222 (@pxref{Networking Services,
  10694. @code{openssh-service-type}}). Under the hood,
  10695. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  10696. right command-line options, possibly with supporting configuration files
  10697. generated as needed (@pxref{Defining Services}).
  10698. @cindex customization, of services
  10699. @findex modify-services
  10700. Occasionally, instead of using the base services as is, you will want to
  10701. customize them. To do this, use @code{modify-services} (@pxref{Service
  10702. Reference, @code{modify-services}}) to modify the list.
  10703. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  10704. (the console log-in) in the @code{%base-services} list (@pxref{Base
  10705. Services, @code{%base-services}}). To do that, you can write the
  10706. following in your operating system declaration:
  10707. @lisp
  10708. (define %my-services
  10709. ;; My very own list of services.
  10710. (modify-services %base-services
  10711. (guix-service-type config =>
  10712. (guix-configuration
  10713. (inherit config)
  10714. ;; Fetch substitutes from example.org.
  10715. (substitute-urls
  10716. (list "https://example.org/guix"
  10717. "https://ci.guix.gnu.org"))))
  10718. (mingetty-service-type config =>
  10719. (mingetty-configuration
  10720. (inherit config)
  10721. ;; Automatially log in as "guest".
  10722. (auto-login "guest")))))
  10723. (operating-system
  10724. ;; @dots{}
  10725. (services %my-services))
  10726. @end lisp
  10727. This changes the configuration---i.e., the service parameters---of the
  10728. @code{guix-service-type} instance, and that of all the
  10729. @code{mingetty-service-type} instances in the @code{%base-services} list.
  10730. Observe how this is accomplished: first, we arrange for the original
  10731. configuration to be bound to the identifier @code{config} in the
  10732. @var{body}, and then we write the @var{body} so that it evaluates to the
  10733. desired configuration. In particular, notice how we use @code{inherit}
  10734. to create a new configuration which has the same values as the old
  10735. configuration, but with a few modifications.
  10736. @cindex encrypted disk
  10737. The configuration for a typical ``desktop'' usage, with an encrypted
  10738. root partition, the X11 display
  10739. server, GNOME and Xfce (users can choose which of these desktop
  10740. environments to use at the log-in screen by pressing @kbd{F1}), network
  10741. management, power management, and more, would look like this:
  10742. @lisp
  10743. @include os-config-desktop.texi
  10744. @end lisp
  10745. A graphical system with a choice of lightweight window managers
  10746. instead of full-blown desktop environments would look like this:
  10747. @lisp
  10748. @include os-config-lightweight-desktop.texi
  10749. @end lisp
  10750. This example refers to the @file{/boot/efi} file system by its UUID,
  10751. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  10752. as returned by the @command{blkid} command.
  10753. @xref{Desktop Services}, for the exact list of services provided by
  10754. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  10755. information about the @code{nss-certs} package that is used here.
  10756. Again, @code{%desktop-services} is just a list of service objects. If
  10757. you want to remove services from there, you can do so using the
  10758. procedures for list filtering (@pxref{SRFI-1 Filtering and
  10759. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  10760. following expression returns a list that contains all the services in
  10761. @code{%desktop-services} minus the Avahi service:
  10762. @lisp
  10763. (remove (lambda (service)
  10764. (eq? (service-kind service) avahi-service-type))
  10765. %desktop-services)
  10766. @end lisp
  10767. @unnumberedsubsec Instantiating the System
  10768. Assuming the @code{operating-system} declaration
  10769. is stored in the @file{my-system-config.scm}
  10770. file, the @command{guix system reconfigure my-system-config.scm} command
  10771. instantiates that configuration, and makes it the default GRUB boot
  10772. entry (@pxref{Invoking guix system}).
  10773. The normal way to change the system configuration is by updating this
  10774. file and re-running @command{guix system reconfigure}. One should never
  10775. have to touch files in @file{/etc} or to run commands that modify the
  10776. system state such as @command{useradd} or @command{grub-install}. In
  10777. fact, you must avoid that since that would not only void your warranty
  10778. but also prevent you from rolling back to previous versions of your
  10779. system, should you ever need to.
  10780. @cindex roll-back, of the operating system
  10781. Speaking of roll-back, each time you run @command{guix system
  10782. reconfigure}, a new @dfn{generation} of the system is created---without
  10783. modifying or deleting previous generations. Old system generations get
  10784. an entry in the bootloader boot menu, allowing you to boot them in case
  10785. something went wrong with the latest generation. Reassuring, no? The
  10786. @command{guix system list-generations} command lists the system
  10787. generations available on disk. It is also possible to roll back the
  10788. system via the commands @command{guix system roll-back} and
  10789. @command{guix system switch-generation}.
  10790. Although the @command{guix system reconfigure} command will not modify
  10791. previous generations, you must take care when the current generation is not
  10792. the latest (e.g., after invoking @command{guix system roll-back}), since
  10793. the operation might overwrite a later generation (@pxref{Invoking guix
  10794. system}).
  10795. @unnumberedsubsec The Programming Interface
  10796. At the Scheme level, the bulk of an @code{operating-system} declaration
  10797. is instantiated with the following monadic procedure (@pxref{The Store
  10798. Monad}):
  10799. @deffn {Monadic Procedure} operating-system-derivation os
  10800. Return a derivation that builds @var{os}, an @code{operating-system}
  10801. object (@pxref{Derivations}).
  10802. The output of the derivation is a single directory that refers to all
  10803. the packages, configuration files, and other supporting files needed to
  10804. instantiate @var{os}.
  10805. @end deffn
  10806. This procedure is provided by the @code{(gnu system)} module. Along
  10807. with @code{(gnu services)} (@pxref{Services}), this module contains the
  10808. guts of Guix System. Make sure to visit it!
  10809. @node operating-system Reference
  10810. @section @code{operating-system} Reference
  10811. This section summarizes all the options available in
  10812. @code{operating-system} declarations (@pxref{Using the Configuration
  10813. System}).
  10814. @deftp {Data Type} operating-system
  10815. This is the data type representing an operating system configuration.
  10816. By that, we mean all the global system configuration, not per-user
  10817. configuration (@pxref{Using the Configuration System}).
  10818. @table @asis
  10819. @item @code{kernel} (default: @code{linux-libre})
  10820. The package object of the operating system kernel to
  10821. use@footnote{Currently only the Linux-libre kernel is fully supported.
  10822. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  10823. available when building a virtual machine disk image.}.
  10824. @cindex hurd
  10825. @item @code{hurd} (default: @code{#f})
  10826. The package object of the Hurd to be started by the kernel. When this
  10827. field is set, produce a GNU/Hurd operating system. In that case,
  10828. @code{kernel} must also be set to the @code{gnumach} package---the
  10829. microkernel the Hurd runs on.
  10830. @quotation Warning
  10831. This feature is experimental and only supported for disk images.
  10832. @end quotation
  10833. @item @code{kernel-loadable-modules} (default: '())
  10834. A list of objects (usually packages) to collect loadable kernel modules
  10835. from--e.g. @code{(list ddcci-driver-linux)}.
  10836. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  10837. List of strings or gexps representing additional arguments to pass on
  10838. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  10839. @item @code{bootloader}
  10840. The system bootloader configuration object. @xref{Bootloader Configuration}.
  10841. @item @code{label}
  10842. This is the label (a string) as it appears in the bootloader's menu entry.
  10843. The default label includes the kernel name and version.
  10844. @item @code{keyboard-layout} (default: @code{#f})
  10845. This field specifies the keyboard layout to use in the console. It can be
  10846. either @code{#f}, in which case the default keyboard layout is used (usually
  10847. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  10848. for more information.
  10849. This keyboard layout is in effect as soon as the kernel has booted. For
  10850. instance, it is the keyboard layout in effect when you type a passphrase if
  10851. your root file system is on a @code{luks-device-mapping} mapped device
  10852. (@pxref{Mapped Devices}).
  10853. @quotation Note
  10854. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  10855. that used by the graphical display server. @xref{Bootloader Configuration},
  10856. for information on how to specify the bootloader's keyboard layout. @xref{X
  10857. Window}, for information on how to specify the keyboard layout used by the X
  10858. Window System.
  10859. @end quotation
  10860. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  10861. @cindex initrd
  10862. @cindex initial RAM disk
  10863. The list of Linux kernel modules that need to be available in the
  10864. initial RAM disk. @xref{Initial RAM Disk}.
  10865. @item @code{initrd} (default: @code{base-initrd})
  10866. A procedure that returns an initial RAM disk for the Linux
  10867. kernel. This field is provided to support low-level customization and
  10868. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  10869. @item @code{firmware} (default: @code{%base-firmware})
  10870. @cindex firmware
  10871. List of firmware packages loadable by the operating system kernel.
  10872. The default includes firmware needed for Atheros- and Broadcom-based
  10873. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  10874. respectively). @xref{Hardware Considerations}, for more info on
  10875. supported hardware.
  10876. @item @code{host-name}
  10877. The host name.
  10878. @item @code{hosts-file}
  10879. @cindex hosts file
  10880. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  10881. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  10882. Reference Manual}). The default is a file with entries for
  10883. @code{localhost} and @var{host-name}.
  10884. @item @code{mapped-devices} (default: @code{'()})
  10885. A list of mapped devices. @xref{Mapped Devices}.
  10886. @item @code{file-systems}
  10887. A list of file systems. @xref{File Systems}.
  10888. @cindex swap devices
  10889. @cindex swap space
  10890. @item @code{swap-devices} (default: @code{'()})
  10891. A list of UUIDs, file system labels, or strings identifying devices or
  10892. files to be used for ``swap
  10893. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  10894. Manual}). Here are some examples:
  10895. @table @code
  10896. @item (list (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))
  10897. Use the swap partition with the given UUID@. You can learn the UUID of a
  10898. Linux swap partition by running @command{swaplabel @var{device}}, where
  10899. @var{device} is the @file{/dev} file name of that partition.
  10900. @item (list (file-system-label "swap"))
  10901. Use the partition with label @code{swap}. Again, the
  10902. @command{swaplabel} command allows you to view and change the label of a
  10903. Linux swap partition.
  10904. @item (list "/swapfile")
  10905. Use the file @file{/swapfile} as swap space.
  10906. @item (list "/dev/sda3" "/dev/sdb2")
  10907. Use the @file{/dev/sda3} and @file{/dev/sdb2} partitions as swap space.
  10908. We recommend referring to swap devices by UUIDs or labels as shown above
  10909. instead.
  10910. @end table
  10911. It is possible to specify a swap file in a file system on a mapped
  10912. device (under @file{/dev/mapper}), provided that the necessary device
  10913. mapping and file system are also specified. @xref{Mapped Devices} and
  10914. @ref{File Systems}.
  10915. @item @code{users} (default: @code{%base-user-accounts})
  10916. @itemx @code{groups} (default: @code{%base-groups})
  10917. List of user accounts and groups. @xref{User Accounts}.
  10918. If the @code{users} list lacks a user account with UID@tie{}0, a
  10919. ``root'' account with UID@tie{}0 is automatically added.
  10920. @item @code{skeletons} (default: @code{(default-skeletons)})
  10921. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  10922. file-like objects}). These are the skeleton files that will be added to
  10923. the home directory of newly-created user accounts.
  10924. For instance, a valid value may look like this:
  10925. @lisp
  10926. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  10927. (".guile" ,(plain-file "guile"
  10928. "(use-modules (ice-9 readline))
  10929. (activate-readline)")))
  10930. @end lisp
  10931. @item @code{issue} (default: @code{%default-issue})
  10932. A string denoting the contents of the @file{/etc/issue} file, which is
  10933. displayed when users log in on a text console.
  10934. @item @code{packages} (default: @code{%base-packages})
  10935. A list of packages to be installed in the global profile, which is accessible
  10936. at @file{/run/current-system/profile}. Each element is either a package
  10937. variable or a package/output tuple. Here's a simple example of both:
  10938. @lisp
  10939. (cons* git ; the default "out" output
  10940. (list git "send-email") ; another output of git
  10941. %base-packages) ; the default set
  10942. @end lisp
  10943. The default set includes core utilities and it is good practice to
  10944. install non-core utilities in user profiles (@pxref{Invoking guix
  10945. package}).
  10946. @item @code{timezone}
  10947. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  10948. You can run the @command{tzselect} command to find out which timezone
  10949. string corresponds to your region. Choosing an invalid timezone name
  10950. causes @command{guix system} to fail.
  10951. @item @code{locale} (default: @code{"en_US.utf8"})
  10952. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  10953. Library Reference Manual}). @xref{Locales}, for more information.
  10954. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  10955. The list of locale definitions to be compiled and that may be used at
  10956. run time. @xref{Locales}.
  10957. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  10958. The list of GNU@tie{}libc packages whose locale data and tools are used
  10959. to build the locale definitions. @xref{Locales}, for compatibility
  10960. considerations that justify this option.
  10961. @item @code{name-service-switch} (default: @code{%default-nss})
  10962. Configuration of the libc name service switch (NSS)---a
  10963. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  10964. details.
  10965. @item @code{services} (default: @code{%base-services})
  10966. A list of service objects denoting system services. @xref{Services}.
  10967. @cindex essential services
  10968. @item @code{essential-services} (default: ...)
  10969. The list of ``essential services''---i.e., things like instances of
  10970. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  10971. Reference}), which are derived from the operating system definition itself.
  10972. As a user you should @emph{never} need to touch this field.
  10973. @item @code{pam-services} (default: @code{(base-pam-services)})
  10974. @cindex PAM
  10975. @cindex pluggable authentication modules
  10976. Linux @dfn{pluggable authentication module} (PAM) services.
  10977. @c FIXME: Add xref to PAM services section.
  10978. @item @code{setuid-programs} (default: @code{%setuid-programs})
  10979. List of string-valued G-expressions denoting setuid programs.
  10980. @xref{Setuid Programs}.
  10981. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  10982. @cindex sudoers file
  10983. The contents of the @file{/etc/sudoers} file as a file-like object
  10984. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  10985. This file specifies which users can use the @command{sudo} command, what
  10986. they are allowed to do, and what privileges they may gain. The default
  10987. is that only @code{root} and members of the @code{wheel} group may use
  10988. @code{sudo}.
  10989. @end table
  10990. @deffn {Scheme Syntax} this-operating-system
  10991. When used in the @emph{lexical scope} of an operating system field definition,
  10992. this identifier resolves to the operating system being defined.
  10993. The example below shows how to refer to the operating system being defined in
  10994. the definition of the @code{label} field:
  10995. @lisp
  10996. (use-modules (gnu) (guix))
  10997. (operating-system
  10998. ;; ...
  10999. (label (package-full-name
  11000. (operating-system-kernel this-operating-system))))
  11001. @end lisp
  11002. It is an error to refer to @code{this-operating-system} outside an operating
  11003. system definition.
  11004. @end deffn
  11005. @end deftp
  11006. @node File Systems
  11007. @section File Systems
  11008. The list of file systems to be mounted is specified in the
  11009. @code{file-systems} field of the operating system declaration
  11010. (@pxref{Using the Configuration System}). Each file system is declared
  11011. using the @code{file-system} form, like this:
  11012. @lisp
  11013. (file-system
  11014. (mount-point "/home")
  11015. (device "/dev/sda3")
  11016. (type "ext4"))
  11017. @end lisp
  11018. As usual, some of the fields are mandatory---those shown in the example
  11019. above---while others can be omitted. These are described below.
  11020. @deftp {Data Type} file-system
  11021. Objects of this type represent file systems to be mounted. They
  11022. contain the following members:
  11023. @table @asis
  11024. @item @code{type}
  11025. This is a string specifying the type of the file system---e.g.,
  11026. @code{"ext4"}.
  11027. @item @code{mount-point}
  11028. This designates the place where the file system is to be mounted.
  11029. @item @code{device}
  11030. This names the ``source'' of the file system. It can be one of three
  11031. things: a file system label, a file system UUID, or the name of a
  11032. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  11033. systems without having to hard-code their actual device
  11034. name@footnote{Note that, while it is tempting to use
  11035. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  11036. result, this is not recommended: These special device nodes are created
  11037. by the udev daemon and may be unavailable at the time the device is
  11038. mounted.}.
  11039. @findex file-system-label
  11040. File system labels are created using the @code{file-system-label}
  11041. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  11042. plain strings. Here's an example of a file system referred to by its
  11043. label, as shown by the @command{e2label} command:
  11044. @lisp
  11045. (file-system
  11046. (mount-point "/home")
  11047. (type "ext4")
  11048. (device (file-system-label "my-home")))
  11049. @end lisp
  11050. @findex uuid
  11051. UUIDs are converted from their string representation (as shown by the
  11052. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  11053. @code{uuid} form expects 16-byte UUIDs as defined in
  11054. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  11055. form of UUID used by the ext2 family of file systems and others, but it
  11056. is different from ``UUIDs'' found in FAT file systems, for instance.},
  11057. like this:
  11058. @lisp
  11059. (file-system
  11060. (mount-point "/home")
  11061. (type "ext4")
  11062. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  11063. @end lisp
  11064. When the source of a file system is a mapped device (@pxref{Mapped
  11065. Devices}), its @code{device} field @emph{must} refer to the mapped
  11066. device name---e.g., @file{"/dev/mapper/root-partition"}.
  11067. This is required so that
  11068. the system knows that mounting the file system depends on having the
  11069. corresponding device mapping established.
  11070. @item @code{flags} (default: @code{'()})
  11071. This is a list of symbols denoting mount flags. Recognized flags
  11072. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  11073. access to special files), @code{no-suid} (ignore setuid and setgid
  11074. bits), @code{no-atime} (do not update file access times),
  11075. @code{strict-atime} (update file access time), @code{lazy-time} (only
  11076. update time on the in-memory version of the file inode), and
  11077. @code{no-exec} (disallow program execution).
  11078. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  11079. Manual}, for more information on these flags.
  11080. @item @code{options} (default: @code{#f})
  11081. This is either @code{#f}, or a string denoting mount options passed to
  11082. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  11083. Library Reference Manual}, for details and run @command{man 8 mount} for
  11084. options for various file systems. Note that the
  11085. @code{file-system-options->alist} and @code{alist->file-system-options}
  11086. procedures from @code{(gnu system file-systems)} can be used to convert
  11087. file system options given as an association list to the string
  11088. representation, and vice-versa.
  11089. @item @code{mount?} (default: @code{#t})
  11090. This value indicates whether to automatically mount the file system when
  11091. the system is brought up. When set to @code{#f}, the file system gets
  11092. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  11093. is not automatically mounted.
  11094. @item @code{needed-for-boot?} (default: @code{#f})
  11095. This Boolean value indicates whether the file system is needed when
  11096. booting. If that is true, then the file system is mounted when the
  11097. initial RAM disk (initrd) is loaded. This is always the case, for
  11098. instance, for the root file system.
  11099. @item @code{check?} (default: @code{#t})
  11100. This Boolean indicates whether the file system needs to be checked for
  11101. errors before being mounted.
  11102. @item @code{create-mount-point?} (default: @code{#f})
  11103. When true, the mount point is created if it does not exist yet.
  11104. @item @code{mount-may-fail?} (default: @code{#f})
  11105. When true, this indicates that mounting this file system can fail but
  11106. that should not be considered an error. This is useful in unusual
  11107. cases; an example of this is @code{efivarfs}, a file system that can
  11108. only be mounted on EFI/UEFI systems.
  11109. @item @code{dependencies} (default: @code{'()})
  11110. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  11111. representing file systems that must be mounted or mapped devices that
  11112. must be opened before (and unmounted or closed after) this one.
  11113. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  11114. a dependency of @file{/sys/fs/cgroup/cpu} and
  11115. @file{/sys/fs/cgroup/memory}.
  11116. Another example is a file system that depends on a mapped device, for
  11117. example for an encrypted partition (@pxref{Mapped Devices}).
  11118. @end table
  11119. @end deftp
  11120. @deffn {Scheme Procedure} file-system-label @var{str}
  11121. This procedure returns an opaque file system label from @var{str}, a
  11122. string:
  11123. @lisp
  11124. (file-system-label "home")
  11125. @result{} #<file-system-label "home">
  11126. @end lisp
  11127. File system labels are used to refer to file systems by label rather
  11128. than by device name. See above for examples.
  11129. @end deffn
  11130. The @code{(gnu system file-systems)} exports the following useful
  11131. variables.
  11132. @defvr {Scheme Variable} %base-file-systems
  11133. These are essential file systems that are required on normal systems,
  11134. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  11135. below). Operating system declarations should always contain at least
  11136. these.
  11137. @end defvr
  11138. @defvr {Scheme Variable} %pseudo-terminal-file-system
  11139. This is the file system to be mounted as @file{/dev/pts}. It supports
  11140. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  11141. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  11142. Manual}). Pseudo-terminals are used by terminal emulators such as
  11143. @command{xterm}.
  11144. @end defvr
  11145. @defvr {Scheme Variable} %shared-memory-file-system
  11146. This file system is mounted as @file{/dev/shm} and is used to support
  11147. memory sharing across processes (@pxref{Memory-mapped I/O,
  11148. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  11149. @end defvr
  11150. @defvr {Scheme Variable} %immutable-store
  11151. This file system performs a read-only ``bind mount'' of
  11152. @file{/gnu/store}, making it read-only for all the users including
  11153. @code{root}. This prevents against accidental modification by software
  11154. running as @code{root} or by system administrators.
  11155. The daemon itself is still able to write to the store: it remounts it
  11156. read-write in its own ``name space.''
  11157. @end defvr
  11158. @defvr {Scheme Variable} %binary-format-file-system
  11159. The @code{binfmt_misc} file system, which allows handling of arbitrary
  11160. executable file types to be delegated to user space. This requires the
  11161. @code{binfmt.ko} kernel module to be loaded.
  11162. @end defvr
  11163. @defvr {Scheme Variable} %fuse-control-file-system
  11164. The @code{fusectl} file system, which allows unprivileged users to mount
  11165. and unmount user-space FUSE file systems. This requires the
  11166. @code{fuse.ko} kernel module to be loaded.
  11167. @end defvr
  11168. The @code{(gnu system uuid)} module provides tools to deal with file
  11169. system ``unique identifiers'' (UUIDs).
  11170. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  11171. Return an opaque UUID (unique identifier) object of the given @var{type}
  11172. (a symbol) by parsing @var{str} (a string):
  11173. @lisp
  11174. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  11175. @result{} #<<uuid> type: dce bv: @dots{}>
  11176. (uuid "1234-ABCD" 'fat)
  11177. @result{} #<<uuid> type: fat bv: @dots{}>
  11178. @end lisp
  11179. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  11180. @code{ntfs}, or one of the commonly found synonyms for these.
  11181. UUIDs are another way to unambiguously refer to file systems in
  11182. operating system configuration. See the examples above.
  11183. @end deffn
  11184. @node Btrfs file system
  11185. @subsection Btrfs file system
  11186. The Btrfs has special features, such as subvolumes, that merit being
  11187. explained in more details. The following section attempts to cover
  11188. basic as well as complex uses of a Btrfs file system with the Guix
  11189. System.
  11190. In its simplest usage, a Btrfs file system can be described, for
  11191. example, by:
  11192. @lisp
  11193. (file-system
  11194. (mount-point "/home")
  11195. (type "btrfs")
  11196. (device (file-system-label "my-home")))
  11197. @end lisp
  11198. The example below is more complex, as it makes use of a Btrfs
  11199. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  11200. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  11201. dependency on @code{mapped-devices}):
  11202. @lisp
  11203. (file-system
  11204. (device (file-system-label "my-btrfs-pool"))
  11205. (mount-point "/")
  11206. (type "btrfs")
  11207. (options "subvol=rootfs")
  11208. (dependencies mapped-devices))
  11209. @end lisp
  11210. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  11211. top level during the early boot, and rely on their configuration to
  11212. refer to the correct subvolume path within that top level. The
  11213. bootloaders operating in this way typically produce their configuration
  11214. on a running system where the Btrfs partitions are already mounted and
  11215. where the subvolume information is readily available. As an example,
  11216. @command{grub-mkconfig}, the configuration generator command shipped
  11217. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  11218. path of a subvolume.
  11219. The Guix System produces a bootloader configuration using the operating
  11220. system configuration as its sole input; it is therefore necessary to
  11221. extract the subvolume name on which @file{/gnu/store} lives (if any)
  11222. from that operating system configuration. To better illustrate,
  11223. consider a subvolume named 'rootfs' which contains the root file system
  11224. data. In such situation, the GRUB bootloader would only see the top
  11225. level of the root Btrfs partition, e.g.:
  11226. @example
  11227. / (top level)
  11228. ├── rootfs (subvolume directory)
  11229. ├── gnu (normal directory)
  11230. ├── store (normal directory)
  11231. [...]
  11232. @end example
  11233. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  11234. of the kernel, initrd binaries and any other files referred to in the
  11235. GRUB configuration that must be found during the early boot.
  11236. The next example shows a nested hierarchy of subvolumes and
  11237. directories:
  11238. @example
  11239. / (top level)
  11240. ├── rootfs (subvolume)
  11241. ├── gnu (normal directory)
  11242. ├── store (subvolume)
  11243. [...]
  11244. @end example
  11245. This scenario would work without mounting the 'store' subvolume.
  11246. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  11247. intended mount point in the file system hierarchy. Alternatively, the
  11248. 'store' subvolume could be referred to by setting the @code{subvol}
  11249. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  11250. Finally, a more contrived example of nested subvolumes:
  11251. @example
  11252. / (top level)
  11253. ├── root-snapshots (subvolume)
  11254. ├── root-current (subvolume)
  11255. ├── guix-store (subvolume)
  11256. [...]
  11257. @end example
  11258. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  11259. so it is necessary to mount it. The subvolume must be fully specified,
  11260. by passing its file name to the @code{subvol} option. To illustrate,
  11261. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  11262. a file system declaration such as:
  11263. @lisp
  11264. (file-system
  11265. (device (file-system-label "btrfs-pool-1"))
  11266. (mount-point "/gnu/store")
  11267. (type "btrfs")
  11268. (options "subvol=root-snapshots/root-current/guix-store,\
  11269. compress-force=zstd,space_cache=v2"))
  11270. @end lisp
  11271. @node Mapped Devices
  11272. @section Mapped Devices
  11273. @cindex device mapping
  11274. @cindex mapped devices
  11275. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  11276. such as a hard disk partition, can be @dfn{mapped} into another device,
  11277. usually in @code{/dev/mapper/},
  11278. with additional processing over the data that flows through
  11279. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  11280. concept of a ``mapped device'' and that of a file system: both boil down
  11281. to @emph{translating} input/output operations made on a file to
  11282. operations on its backing store. Thus, the Hurd implements mapped
  11283. devices, like file systems, using the generic @dfn{translator} mechanism
  11284. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  11285. typical example is encryption device mapping: all writes to the mapped
  11286. device are encrypted, and all reads are deciphered, transparently.
  11287. Guix extends this notion by considering any device or set of devices that
  11288. are @dfn{transformed} in some way to create a new device; for instance,
  11289. RAID devices are obtained by @dfn{assembling} several other devices, such
  11290. as hard disks or partitions, into a new one that behaves as one partition.
  11291. Mapped devices are declared using the @code{mapped-device} form,
  11292. defined as follows; for examples, see below.
  11293. @deftp {Data Type} mapped-device
  11294. Objects of this type represent device mappings that will be made when
  11295. the system boots up.
  11296. @table @code
  11297. @item source
  11298. This is either a string specifying the name of the block device to be mapped,
  11299. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  11300. need to be assembled for creating a new one. In case of LVM this is a
  11301. string specifying name of the volume group to be mapped.
  11302. @item target
  11303. This string specifies the name of the resulting mapped device. For
  11304. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  11305. specifying @code{"my-partition"} leads to the creation of
  11306. the @code{"/dev/mapper/my-partition"} device.
  11307. For RAID devices of type @code{raid-device-mapping}, the full device name
  11308. such as @code{"/dev/md0"} needs to be given.
  11309. LVM logical volumes of type @code{lvm-device-mapping} need to
  11310. be specified as @code{"VGNAME-LVNAME"}.
  11311. @item targets
  11312. This list of strings specifies names of the resulting mapped devices in case
  11313. there are several. The format is identical to @var{target}.
  11314. @item type
  11315. This must be a @code{mapped-device-kind} object, which specifies how
  11316. @var{source} is mapped to @var{target}.
  11317. @end table
  11318. @end deftp
  11319. @defvr {Scheme Variable} luks-device-mapping
  11320. This defines LUKS block device encryption using the @command{cryptsetup}
  11321. command from the package with the same name. It relies on the
  11322. @code{dm-crypt} Linux kernel module.
  11323. @end defvr
  11324. @defvr {Scheme Variable} raid-device-mapping
  11325. This defines a RAID device, which is assembled using the @code{mdadm}
  11326. command from the package with the same name. It requires a Linux kernel
  11327. module for the appropriate RAID level to be loaded, such as @code{raid456}
  11328. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  11329. @end defvr
  11330. @cindex LVM, logical volume manager
  11331. @defvr {Scheme Variable} lvm-device-mapping
  11332. This defines one or more logical volumes for the Linux
  11333. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  11334. The volume group is activated by the @command{vgchange} command from the
  11335. @code{lvm2} package.
  11336. @end defvr
  11337. @cindex disk encryption
  11338. @cindex LUKS
  11339. The following example specifies a mapping from @file{/dev/sda3} to
  11340. @file{/dev/mapper/home} using LUKS---the
  11341. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  11342. standard mechanism for disk encryption.
  11343. The @file{/dev/mapper/home}
  11344. device can then be used as the @code{device} of a @code{file-system}
  11345. declaration (@pxref{File Systems}).
  11346. @lisp
  11347. (mapped-device
  11348. (source "/dev/sda3")
  11349. (target "home")
  11350. (type luks-device-mapping))
  11351. @end lisp
  11352. Alternatively, to become independent of device numbering, one may obtain
  11353. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  11354. command like:
  11355. @example
  11356. cryptsetup luksUUID /dev/sda3
  11357. @end example
  11358. and use it as follows:
  11359. @lisp
  11360. (mapped-device
  11361. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  11362. (target "home")
  11363. (type luks-device-mapping))
  11364. @end lisp
  11365. @cindex swap encryption
  11366. It is also desirable to encrypt swap space, since swap space may contain
  11367. sensitive data. One way to accomplish that is to use a swap file in a
  11368. file system on a device mapped via LUKS encryption. In this way, the
  11369. swap file is encrypted because the entire device is encrypted.
  11370. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  11371. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  11372. may be declared as follows:
  11373. @lisp
  11374. (mapped-device
  11375. (source (list "/dev/sda1" "/dev/sdb1"))
  11376. (target "/dev/md0")
  11377. (type raid-device-mapping))
  11378. @end lisp
  11379. The @file{/dev/md0} device can then be used as the @code{device} of a
  11380. @code{file-system} declaration (@pxref{File Systems}).
  11381. Note that the RAID level need not be given; it is chosen during the
  11382. initial creation and formatting of the RAID device and is determined
  11383. automatically later.
  11384. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  11385. be declared as follows:
  11386. @lisp
  11387. (mapped-device
  11388. (source "vg0")
  11389. (target (list "vg0-alpha" "vg0-beta"))
  11390. (type lvm-device-mapping))
  11391. @end lisp
  11392. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  11393. then be used as the @code{device} of a @code{file-system} declaration
  11394. (@pxref{File Systems}).
  11395. @node User Accounts
  11396. @section User Accounts
  11397. @cindex users
  11398. @cindex accounts
  11399. @cindex user accounts
  11400. User accounts and groups are entirely managed through the
  11401. @code{operating-system} declaration. They are specified with the
  11402. @code{user-account} and @code{user-group} forms:
  11403. @lisp
  11404. (user-account
  11405. (name "alice")
  11406. (group "users")
  11407. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  11408. "audio" ;sound card
  11409. "video" ;video devices such as webcams
  11410. "cdrom")) ;the good ol' CD-ROM
  11411. (comment "Bob's sister"))
  11412. @end lisp
  11413. Here's a user account that uses a different shell and a custom home
  11414. directory (the default would be @file{"/home/bob"}):
  11415. @lisp
  11416. (user-account
  11417. (name "bob")
  11418. (group "users")
  11419. (comment "Alice's bro")
  11420. (shell (file-append zsh "/bin/zsh"))
  11421. (home-directory "/home/robert"))
  11422. @end lisp
  11423. When booting or upon completion of @command{guix system reconfigure},
  11424. the system ensures that only the user accounts and groups specified in
  11425. the @code{operating-system} declaration exist, and with the specified
  11426. properties. Thus, account or group creations or modifications made by
  11427. directly invoking commands such as @command{useradd} are lost upon
  11428. reconfiguration or reboot. This ensures that the system remains exactly
  11429. as declared.
  11430. @deftp {Data Type} user-account
  11431. Objects of this type represent user accounts. The following members may
  11432. be specified:
  11433. @table @asis
  11434. @item @code{name}
  11435. The name of the user account.
  11436. @item @code{group}
  11437. @cindex groups
  11438. This is the name (a string) or identifier (a number) of the user group
  11439. this account belongs to.
  11440. @item @code{supplementary-groups} (default: @code{'()})
  11441. Optionally, this can be defined as a list of group names that this
  11442. account belongs to.
  11443. @item @code{uid} (default: @code{#f})
  11444. This is the user ID for this account (a number), or @code{#f}. In the
  11445. latter case, a number is automatically chosen by the system when the
  11446. account is created.
  11447. @item @code{comment} (default: @code{""})
  11448. A comment about the account, such as the account owner's full name.
  11449. @item @code{home-directory}
  11450. This is the name of the home directory for the account.
  11451. @item @code{create-home-directory?} (default: @code{#t})
  11452. Indicates whether the home directory of this account should be created
  11453. if it does not exist yet.
  11454. @item @code{shell} (default: Bash)
  11455. This is a G-expression denoting the file name of a program to be used as
  11456. the shell (@pxref{G-Expressions}). For example, you would refer to the
  11457. Bash executable like this:
  11458. @lisp
  11459. (file-append bash "/bin/bash")
  11460. @end lisp
  11461. @noindent
  11462. ... and to the Zsh executable like that:
  11463. @lisp
  11464. (file-append zsh "/bin/zsh")
  11465. @end lisp
  11466. @item @code{system?} (default: @code{#f})
  11467. This Boolean value indicates whether the account is a ``system''
  11468. account. System accounts are sometimes treated specially; for instance,
  11469. graphical login managers do not list them.
  11470. @anchor{user-account-password}
  11471. @cindex password, for user accounts
  11472. @item @code{password} (default: @code{#f})
  11473. You would normally leave this field to @code{#f}, initialize user
  11474. passwords as @code{root} with the @command{passwd} command, and then let
  11475. users change it with @command{passwd}. Passwords set with
  11476. @command{passwd} are of course preserved across reboot and
  11477. reconfiguration.
  11478. If you @emph{do} want to set an initial password for an account, then
  11479. this field must contain the encrypted password, as a string. You can use the
  11480. @code{crypt} procedure for this purpose:
  11481. @lisp
  11482. (user-account
  11483. (name "charlie")
  11484. (group "users")
  11485. ;; Specify a SHA-512-hashed initial password.
  11486. (password (crypt "InitialPassword!" "$6$abc")))
  11487. @end lisp
  11488. @quotation Note
  11489. The hash of this initial password will be available in a file in
  11490. @file{/gnu/store}, readable by all the users, so this method must be used with
  11491. care.
  11492. @end quotation
  11493. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  11494. more information on password encryption, and @ref{Encryption,,, guile, GNU
  11495. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  11496. @end table
  11497. @end deftp
  11498. @cindex groups
  11499. User group declarations are even simpler:
  11500. @lisp
  11501. (user-group (name "students"))
  11502. @end lisp
  11503. @deftp {Data Type} user-group
  11504. This type is for, well, user groups. There are just a few fields:
  11505. @table @asis
  11506. @item @code{name}
  11507. The name of the group.
  11508. @item @code{id} (default: @code{#f})
  11509. The group identifier (a number). If @code{#f}, a new number is
  11510. automatically allocated when the group is created.
  11511. @item @code{system?} (default: @code{#f})
  11512. This Boolean value indicates whether the group is a ``system'' group.
  11513. System groups have low numerical IDs.
  11514. @item @code{password} (default: @code{#f})
  11515. What, user groups can have a password? Well, apparently yes. Unless
  11516. @code{#f}, this field specifies the password of the group.
  11517. @end table
  11518. @end deftp
  11519. For convenience, a variable lists all the basic user groups one may
  11520. expect:
  11521. @defvr {Scheme Variable} %base-groups
  11522. This is the list of basic user groups that users and/or packages expect
  11523. to be present on the system. This includes groups such as ``root'',
  11524. ``wheel'', and ``users'', as well as groups used to control access to
  11525. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  11526. @end defvr
  11527. @defvr {Scheme Variable} %base-user-accounts
  11528. This is the list of basic system accounts that programs may expect to
  11529. find on a GNU/Linux system, such as the ``nobody'' account.
  11530. Note that the ``root'' account is not included here. It is a
  11531. special-case and is automatically added whether or not it is specified.
  11532. @end defvr
  11533. @node Keyboard Layout
  11534. @section Keyboard Layout
  11535. @cindex keyboard layout
  11536. @cindex keymap
  11537. To specify what each key of your keyboard does, you need to tell the operating
  11538. system what @dfn{keyboard layout} you want to use. The default, when nothing
  11539. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  11540. However, German speakers will usually prefer the German QWERTZ layout, French
  11541. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  11542. or bépo, and they might even want to further customize the effect of some of
  11543. the keys. This section explains how to get that done.
  11544. @cindex keyboard layout, definition
  11545. There are three components that will want to know about your keyboard layout:
  11546. @itemize
  11547. @item
  11548. The @emph{bootloader} may want to know what keyboard layout you want to use
  11549. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  11550. you want, for instance, to make sure that you can type the passphrase of your
  11551. encrypted root partition using the right layout.
  11552. @item
  11553. The @emph{operating system kernel}, Linux, will need that so that the console
  11554. is properly configured (@pxref{operating-system Reference,
  11555. @code{keyboard-layout}}).
  11556. @item
  11557. The @emph{graphical display server}, usually Xorg, also has its own idea of
  11558. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  11559. @end itemize
  11560. Guix allows you to configure all three separately but, fortunately, it allows
  11561. you to share the same keyboard layout for all three components.
  11562. @cindex XKB, keyboard layouts
  11563. Keyboard layouts are represented by records created by the
  11564. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  11565. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  11566. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  11567. optional variant name, an optional keyboard model name, and a possibly empty
  11568. list of additional options. In most cases the layout name is all you care
  11569. about.
  11570. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  11571. [#:model] [#:options '()]
  11572. Return a new keyboard layout with the given @var{name} and @var{variant}.
  11573. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  11574. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  11575. @code{xkeyboard-config} package for valid options.
  11576. @end deffn
  11577. Here are a few examples:
  11578. @lisp
  11579. ;; The German QWERTZ layout. Here we assume a standard
  11580. ;; "pc105" keyboard model.
  11581. (keyboard-layout "de")
  11582. ;; The bépo variant of the French layout.
  11583. (keyboard-layout "fr" "bepo")
  11584. ;; The Catalan layout.
  11585. (keyboard-layout "es" "cat")
  11586. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  11587. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  11588. ;; The Latin American Spanish layout. In addition, the
  11589. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  11590. ;; and the "Menu" key is used as a "Compose" key to enter
  11591. ;; accented letters.
  11592. (keyboard-layout "latam"
  11593. #:options '("ctrl:nocaps" "compose:menu"))
  11594. ;; The Russian layout for a ThinkPad keyboard.
  11595. (keyboard-layout "ru" #:model "thinkpad")
  11596. ;; The "US international" layout, which is the US layout plus
  11597. ;; dead keys to enter accented characters. This is for an
  11598. ;; Apple MacBook keyboard.
  11599. (keyboard-layout "us" "intl" #:model "macbook78")
  11600. @end lisp
  11601. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  11602. for a complete list of supported layouts, variants, and models.
  11603. @cindex keyboard layout, configuration
  11604. Let's say you want your system to use the Turkish keyboard layout throughout
  11605. your system---bootloader, console, and Xorg. Here's what your system
  11606. configuration would look like:
  11607. @findex set-xorg-configuration
  11608. @lisp
  11609. ;; Using the Turkish layout for the bootloader, the console,
  11610. ;; and for Xorg.
  11611. (operating-system
  11612. ;; ...
  11613. (keyboard-layout (keyboard-layout "tr")) ;for the console
  11614. (bootloader (bootloader-configuration
  11615. (bootloader grub-efi-bootloader)
  11616. (target "/boot/efi")
  11617. (keyboard-layout keyboard-layout))) ;for GRUB
  11618. (services (cons (set-xorg-configuration
  11619. (xorg-configuration ;for Xorg
  11620. (keyboard-layout keyboard-layout)))
  11621. %desktop-services)))
  11622. @end lisp
  11623. In the example above, for GRUB and for Xorg, we just refer to the
  11624. @code{keyboard-layout} field defined above, but we could just as well refer to
  11625. a different layout. The @code{set-xorg-configuration} procedure communicates
  11626. the desired Xorg configuration to the graphical log-in manager, by default
  11627. GDM.
  11628. We've discussed how to specify the @emph{default} keyboard layout of your
  11629. system when it starts, but you can also adjust it at run time:
  11630. @itemize
  11631. @item
  11632. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  11633. where you can select one or more keyboard layouts.
  11634. @item
  11635. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  11636. allows you to change the current layout. For example, this is how you would
  11637. change the layout to US Dvorak:
  11638. @example
  11639. setxkbmap us dvorak
  11640. @end example
  11641. @item
  11642. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  11643. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  11644. keyboard layout categorization described above. The command below loads the
  11645. French bépo layout:
  11646. @example
  11647. loadkeys fr-bepo
  11648. @end example
  11649. @end itemize
  11650. @node Locales
  11651. @section Locales
  11652. @cindex locale
  11653. A @dfn{locale} defines cultural conventions for a particular language
  11654. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  11655. Reference Manual}). Each locale has a name that typically has the form
  11656. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  11657. @code{fr_LU.utf8} designates the locale for the French language, with
  11658. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  11659. @cindex locale definition
  11660. Usually, you will want to specify the default locale for the machine
  11661. using the @code{locale} field of the @code{operating-system} declaration
  11662. (@pxref{operating-system Reference, @code{locale}}).
  11663. The selected locale is automatically added to the @dfn{locale
  11664. definitions} known to the system if needed, with its codeset inferred
  11665. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  11666. @code{UTF-8} codeset. Additional locale definitions can be specified in
  11667. the @code{locale-definitions} slot of @code{operating-system}---this is
  11668. useful, for instance, if the codeset could not be inferred from the
  11669. locale name. The default set of locale definitions includes some widely
  11670. used locales, but not all the available locales, in order to save space.
  11671. For instance, to add the North Frisian locale for Germany, the value of
  11672. that field may be:
  11673. @lisp
  11674. (cons (locale-definition
  11675. (name "fy_DE.utf8") (source "fy_DE"))
  11676. %default-locale-definitions)
  11677. @end lisp
  11678. Likewise, to save space, one might want @code{locale-definitions} to
  11679. list only the locales that are actually used, as in:
  11680. @lisp
  11681. (list (locale-definition
  11682. (name "ja_JP.eucjp") (source "ja_JP")
  11683. (charset "EUC-JP")))
  11684. @end lisp
  11685. @vindex LOCPATH
  11686. The compiled locale definitions are available at
  11687. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  11688. version, which is the default location where the GNU@tie{}libc provided
  11689. by Guix looks for locale data. This can be overridden using the
  11690. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  11691. @env{LOCPATH} and locale packages}).
  11692. The @code{locale-definition} form is provided by the @code{(gnu system
  11693. locale)} module. Details are given below.
  11694. @deftp {Data Type} locale-definition
  11695. This is the data type of a locale definition.
  11696. @table @asis
  11697. @item @code{name}
  11698. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  11699. Reference Manual}, for more information on locale names.
  11700. @item @code{source}
  11701. The name of the source for that locale. This is typically the
  11702. @code{@var{language}_@var{territory}} part of the locale name.
  11703. @item @code{charset} (default: @code{"UTF-8"})
  11704. The ``character set'' or ``code set'' for that locale,
  11705. @uref{https://www.iana.org/assignments/character-sets, as defined by
  11706. IANA}.
  11707. @end table
  11708. @end deftp
  11709. @defvr {Scheme Variable} %default-locale-definitions
  11710. A list of commonly used UTF-8 locales, used as the default
  11711. value of the @code{locale-definitions} field of @code{operating-system}
  11712. declarations.
  11713. @cindex locale name
  11714. @cindex normalized codeset in locale names
  11715. These locale definitions use the @dfn{normalized codeset} for the part
  11716. that follows the dot in the name (@pxref{Using gettextized software,
  11717. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  11718. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  11719. @code{uk_UA.UTF-8}.
  11720. @end defvr
  11721. @subsection Locale Data Compatibility Considerations
  11722. @cindex incompatibility, of locale data
  11723. @code{operating-system} declarations provide a @code{locale-libcs} field
  11724. to specify the GNU@tie{}libc packages that are used to compile locale
  11725. declarations (@pxref{operating-system Reference}). ``Why would I
  11726. care?'', you may ask. Well, it turns out that the binary format of
  11727. locale data is occasionally incompatible from one libc version to
  11728. another.
  11729. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  11730. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  11731. For instance, a program linked against libc version 2.21 is unable to
  11732. read locale data produced with libc 2.22; worse, that program
  11733. @emph{aborts} instead of simply ignoring the incompatible locale
  11734. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  11735. the incompatible locale data, which is already an improvement.}.
  11736. Similarly, a program linked against libc 2.22 can read most, but not
  11737. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  11738. data is incompatible); thus calls to @code{setlocale} may fail, but
  11739. programs will not abort.
  11740. The ``problem'' with Guix is that users have a lot of freedom: They can
  11741. choose whether and when to upgrade software in their profiles, and might
  11742. be using a libc version different from the one the system administrator
  11743. used to build the system-wide locale data.
  11744. Fortunately, unprivileged users can also install their own locale data
  11745. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  11746. @env{GUIX_LOCPATH} and locale packages}).
  11747. Still, it is best if the system-wide locale data at
  11748. @file{/run/current-system/locale} is built for all the libc versions
  11749. actually in use on the system, so that all the programs can access
  11750. it---this is especially crucial on a multi-user system. To do that, the
  11751. administrator can specify several libc packages in the
  11752. @code{locale-libcs} field of @code{operating-system}:
  11753. @lisp
  11754. (use-package-modules base)
  11755. (operating-system
  11756. ;; @dots{}
  11757. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  11758. @end lisp
  11759. This example would lead to a system containing locale definitions for
  11760. both libc 2.21 and the current version of libc in
  11761. @file{/run/current-system/locale}.
  11762. @node Services
  11763. @section Services
  11764. @cindex system services
  11765. An important part of preparing an @code{operating-system} declaration is
  11766. listing @dfn{system services} and their configuration (@pxref{Using the
  11767. Configuration System}). System services are typically daemons launched
  11768. when the system boots, or other actions needed at that time---e.g.,
  11769. configuring network access.
  11770. Guix has a broad definition of ``service'' (@pxref{Service
  11771. Composition}), but many services are managed by the GNU@tie{}Shepherd
  11772. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  11773. command allows you to list the available services, show their status,
  11774. start and stop them, or do other specific operations (@pxref{Jump
  11775. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  11776. @example
  11777. # herd status
  11778. @end example
  11779. The above command, run as @code{root}, lists the currently defined
  11780. services. The @command{herd doc} command shows a synopsis of the given
  11781. service and its associated actions:
  11782. @example
  11783. # herd doc nscd
  11784. Run libc's name service cache daemon (nscd).
  11785. # herd doc nscd action invalidate
  11786. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  11787. @end example
  11788. The @command{start}, @command{stop}, and @command{restart} sub-commands
  11789. have the effect you would expect. For instance, the commands below stop
  11790. the nscd service and restart the Xorg display server:
  11791. @example
  11792. # herd stop nscd
  11793. Service nscd has been stopped.
  11794. # herd restart xorg-server
  11795. Service xorg-server has been stopped.
  11796. Service xorg-server has been started.
  11797. @end example
  11798. The following sections document the available services, starting with
  11799. the core services, that may be used in an @code{operating-system}
  11800. declaration.
  11801. @menu
  11802. * Base Services:: Essential system services.
  11803. * Scheduled Job Execution:: The mcron service.
  11804. * Log Rotation:: The rottlog service.
  11805. * Networking Services:: Network setup, SSH daemon, etc.
  11806. * Unattended Upgrades:: Automated system upgrades.
  11807. * X Window:: Graphical display.
  11808. * Printing Services:: Local and remote printer support.
  11809. * Desktop Services:: D-Bus and desktop services.
  11810. * Sound Services:: ALSA and Pulseaudio services.
  11811. * Database Services:: SQL databases, key-value stores, etc.
  11812. * Mail Services:: IMAP, POP3, SMTP, and all that.
  11813. * Messaging Services:: Messaging services.
  11814. * Telephony Services:: Telephony services.
  11815. * Monitoring Services:: Monitoring services.
  11816. * Kerberos Services:: Kerberos services.
  11817. * LDAP Services:: LDAP services.
  11818. * Web Services:: Web servers.
  11819. * Certificate Services:: TLS certificates via Let's Encrypt.
  11820. * DNS Services:: DNS daemons.
  11821. * VPN Services:: VPN daemons.
  11822. * Network File System:: NFS related services.
  11823. * Continuous Integration:: The Cuirass service.
  11824. * Power Management Services:: Extending battery life.
  11825. * Audio Services:: The MPD.
  11826. * Virtualization Services:: Virtualization services.
  11827. * Version Control Services:: Providing remote access to Git repositories.
  11828. * Game Services:: Game servers.
  11829. * PAM Mount Service:: Service to mount volumes when logging in.
  11830. * Guix Services:: Services relating specifically to Guix.
  11831. * Linux Services:: Services tied to the Linux kernel.
  11832. * Hurd Services:: Services specific for a Hurd System.
  11833. * Miscellaneous Services:: Other services.
  11834. @end menu
  11835. @node Base Services
  11836. @subsection Base Services
  11837. The @code{(gnu services base)} module provides definitions for the basic
  11838. services that one expects from the system. The services exported by
  11839. this module are listed below.
  11840. @defvr {Scheme Variable} %base-services
  11841. This variable contains a list of basic services (@pxref{Service Types
  11842. and Services}, for more information on service objects) one would
  11843. expect from the system: a login service (mingetty) on each tty, syslogd,
  11844. the libc name service cache daemon (nscd), the udev device manager, and
  11845. more.
  11846. This is the default value of the @code{services} field of
  11847. @code{operating-system} declarations. Usually, when customizing a
  11848. system, you will want to append services to @code{%base-services}, like
  11849. this:
  11850. @lisp
  11851. (append (list (service avahi-service-type)
  11852. (service openssh-service-type))
  11853. %base-services)
  11854. @end lisp
  11855. @end defvr
  11856. @defvr {Scheme Variable} special-files-service-type
  11857. This is the service that sets up ``special files'' such as
  11858. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  11859. The value associated with @code{special-files-service-type} services
  11860. must be a list of tuples where the first element is the ``special file''
  11861. and the second element is its target. By default it is:
  11862. @cindex @file{/bin/sh}
  11863. @cindex @file{sh}, in @file{/bin}
  11864. @lisp
  11865. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  11866. @end lisp
  11867. @cindex @file{/usr/bin/env}
  11868. @cindex @file{env}, in @file{/usr/bin}
  11869. If you want to add, say, @code{/usr/bin/env} to your system, you can
  11870. change it to:
  11871. @lisp
  11872. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  11873. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  11874. @end lisp
  11875. Since this is part of @code{%base-services}, you can use
  11876. @code{modify-services} to customize the set of special files
  11877. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  11878. to add a special file is @i{via} the @code{extra-special-file} procedure
  11879. (see below).
  11880. @end defvr
  11881. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  11882. Use @var{target} as the ``special file'' @var{file}.
  11883. For example, adding the following lines to the @code{services} field of
  11884. your operating system declaration leads to a @file{/usr/bin/env}
  11885. symlink:
  11886. @lisp
  11887. (extra-special-file "/usr/bin/env"
  11888. (file-append coreutils "/bin/env"))
  11889. @end lisp
  11890. @end deffn
  11891. @deffn {Scheme Procedure} host-name-service @var{name}
  11892. Return a service that sets the host name to @var{name}.
  11893. @end deffn
  11894. @defvr {Scheme Variable} console-font-service-type
  11895. Install the given fonts on the specified ttys (fonts are per
  11896. virtual console on the kernel Linux). The value of this service is a list of
  11897. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  11898. package or any valid argument to @command{setfont}, as in this example:
  11899. @lisp
  11900. `(("tty1" . "LatGrkCyr-8x16")
  11901. ("tty2" . ,(file-append
  11902. font-tamzen
  11903. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  11904. ("tty3" . ,(file-append
  11905. font-terminus
  11906. "/share/consolefonts/ter-132n"))) ; for HDPI
  11907. @end lisp
  11908. @end defvr
  11909. @deffn {Scheme Procedure} login-service @var{config}
  11910. Return a service to run login according to @var{config}, a
  11911. @code{<login-configuration>} object, which specifies the message of the day,
  11912. among other things.
  11913. @end deffn
  11914. @deftp {Data Type} login-configuration
  11915. This is the data type representing the configuration of login.
  11916. @table @asis
  11917. @item @code{motd}
  11918. @cindex message of the day
  11919. A file-like object containing the ``message of the day''.
  11920. @item @code{allow-empty-passwords?} (default: @code{#t})
  11921. Allow empty passwords by default so that first-time users can log in when
  11922. the 'root' account has just been created.
  11923. @end table
  11924. @end deftp
  11925. @deffn {Scheme Procedure} mingetty-service @var{config}
  11926. Return a service to run mingetty according to @var{config}, a
  11927. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  11928. other things.
  11929. @end deffn
  11930. @deftp {Data Type} mingetty-configuration
  11931. This is the data type representing the configuration of Mingetty, which
  11932. provides the default implementation of virtual console log-in.
  11933. @table @asis
  11934. @item @code{tty}
  11935. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  11936. @item @code{auto-login} (default: @code{#f})
  11937. When true, this field must be a string denoting the user name under
  11938. which the system automatically logs in. When it is @code{#f}, a
  11939. user name and password must be entered to log in.
  11940. @item @code{login-program} (default: @code{#f})
  11941. This must be either @code{#f}, in which case the default log-in program
  11942. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  11943. the name of the log-in program.
  11944. @item @code{login-pause?} (default: @code{#f})
  11945. When set to @code{#t} in conjunction with @var{auto-login}, the user
  11946. will have to press a key before the log-in shell is launched.
  11947. @item @code{clear-on-logout?} (default: @code{#t})
  11948. When set to @code{#t}, the screen will be cleared after logout.
  11949. @item @code{mingetty} (default: @var{mingetty})
  11950. The Mingetty package to use.
  11951. @end table
  11952. @end deftp
  11953. @deffn {Scheme Procedure} agetty-service @var{config}
  11954. Return a service to run agetty according to @var{config}, an
  11955. @code{<agetty-configuration>} object, which specifies the tty to run,
  11956. among other things.
  11957. @end deffn
  11958. @deftp {Data Type} agetty-configuration
  11959. This is the data type representing the configuration of agetty, which
  11960. implements virtual and serial console log-in. See the @code{agetty(8)}
  11961. man page for more information.
  11962. @table @asis
  11963. @item @code{tty}
  11964. The name of the console this agetty runs on, as a string---e.g.,
  11965. @code{"ttyS0"}. This argument is optional, it will default to
  11966. a reasonable default serial port used by the kernel Linux.
  11967. For this, if there is a value for an option @code{agetty.tty} in the kernel
  11968. command line, agetty will extract the device name of the serial port
  11969. from it and use that.
  11970. If not and if there is a value for an option @code{console} with a tty in
  11971. the Linux command line, agetty will extract the device name of the
  11972. serial port from it and use that.
  11973. In both cases, agetty will leave the other serial device settings
  11974. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  11975. correct values.
  11976. @item @code{baud-rate} (default: @code{#f})
  11977. A string containing a comma-separated list of one or more baud rates, in
  11978. descending order.
  11979. @item @code{term} (default: @code{#f})
  11980. A string containing the value used for the @env{TERM} environment
  11981. variable.
  11982. @item @code{eight-bits?} (default: @code{#f})
  11983. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  11984. disabled.
  11985. @item @code{auto-login} (default: @code{#f})
  11986. When passed a login name, as a string, the specified user will be logged
  11987. in automatically without prompting for their login name or password.
  11988. @item @code{no-reset?} (default: @code{#f})
  11989. When @code{#t}, don't reset terminal cflags (control modes).
  11990. @item @code{host} (default: @code{#f})
  11991. This accepts a string containing the ``login_host'', which will be written
  11992. into the @file{/var/run/utmpx} file.
  11993. @item @code{remote?} (default: @code{#f})
  11994. When set to @code{#t} in conjunction with @var{host}, this will add an
  11995. @code{-r} fakehost option to the command line of the login program
  11996. specified in @var{login-program}.
  11997. @item @code{flow-control?} (default: @code{#f})
  11998. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  11999. @item @code{no-issue?} (default: @code{#f})
  12000. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  12001. not be displayed before presenting the login prompt.
  12002. @item @code{init-string} (default: @code{#f})
  12003. This accepts a string that will be sent to the tty or modem before
  12004. sending anything else. It can be used to initialize a modem.
  12005. @item @code{no-clear?} (default: @code{#f})
  12006. When set to @code{#t}, agetty will not clear the screen before showing
  12007. the login prompt.
  12008. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  12009. This must be either a gexp denoting the name of a log-in program, or
  12010. unset, in which case the default value is the @command{login} from the
  12011. Shadow tool suite.
  12012. @item @code{local-line} (default: @code{#f})
  12013. Control the CLOCAL line flag. This accepts one of three symbols as
  12014. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  12015. the default value chosen by agetty is @code{'auto}.
  12016. @item @code{extract-baud?} (default: @code{#f})
  12017. When set to @code{#t}, instruct agetty to try to extract the baud rate
  12018. from the status messages produced by certain types of modems.
  12019. @item @code{skip-login?} (default: @code{#f})
  12020. When set to @code{#t}, do not prompt the user for a login name. This
  12021. can be used with @var{login-program} field to use non-standard login
  12022. systems.
  12023. @item @code{no-newline?} (default: @code{#f})
  12024. When set to @code{#t}, do not print a newline before printing the
  12025. @file{/etc/issue} file.
  12026. @c Is this dangerous only when used with login-program, or always?
  12027. @item @code{login-options} (default: @code{#f})
  12028. This option accepts a string containing options that are passed to the
  12029. login program. When used with the @var{login-program}, be aware that a
  12030. malicious user could try to enter a login name containing embedded
  12031. options that could be parsed by the login program.
  12032. @item @code{login-pause} (default: @code{#f})
  12033. When set to @code{#t}, wait for any key before showing the login prompt.
  12034. This can be used in conjunction with @var{auto-login} to save memory by
  12035. lazily spawning shells.
  12036. @item @code{chroot} (default: @code{#f})
  12037. Change root to the specified directory. This option accepts a directory
  12038. path as a string.
  12039. @item @code{hangup?} (default: @code{#f})
  12040. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  12041. specified terminal.
  12042. @item @code{keep-baud?} (default: @code{#f})
  12043. When set to @code{#t}, try to keep the existing baud rate. The baud
  12044. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  12045. character.
  12046. @item @code{timeout} (default: @code{#f})
  12047. When set to an integer value, terminate if no user name could be read
  12048. within @var{timeout} seconds.
  12049. @item @code{detect-case?} (default: @code{#f})
  12050. When set to @code{#t}, turn on support for detecting an uppercase-only
  12051. terminal. This setting will detect a login name containing only
  12052. uppercase letters as indicating an uppercase-only terminal and turn on
  12053. some upper-to-lower case conversions. Note that this will not support
  12054. Unicode characters.
  12055. @item @code{wait-cr?} (default: @code{#f})
  12056. When set to @code{#t}, wait for the user or modem to send a
  12057. carriage-return or linefeed character before displaying
  12058. @file{/etc/issue} or login prompt. This is typically used with the
  12059. @var{init-string} option.
  12060. @item @code{no-hints?} (default: @code{#f})
  12061. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  12062. locks.
  12063. @item @code{no-hostname?} (default: @code{#f})
  12064. By default, the hostname is printed. When this option is set to
  12065. @code{#t}, no hostname will be shown at all.
  12066. @item @code{long-hostname?} (default: @code{#f})
  12067. By default, the hostname is only printed until the first dot. When this
  12068. option is set to @code{#t}, the fully qualified hostname by
  12069. @code{gethostname} or @code{getaddrinfo} is shown.
  12070. @item @code{erase-characters} (default: @code{#f})
  12071. This option accepts a string of additional characters that should be
  12072. interpreted as backspace when the user types their login name.
  12073. @item @code{kill-characters} (default: @code{#f})
  12074. This option accepts a string that should be interpreted to mean ``ignore
  12075. all previous characters'' (also called a ``kill'' character) when the user
  12076. types their login name.
  12077. @item @code{chdir} (default: @code{#f})
  12078. This option accepts, as a string, a directory path that will be changed
  12079. to before login.
  12080. @item @code{delay} (default: @code{#f})
  12081. This options accepts, as an integer, the number of seconds to sleep
  12082. before opening the tty and displaying the login prompt.
  12083. @item @code{nice} (default: @code{#f})
  12084. This option accepts, as an integer, the nice value with which to run the
  12085. @command{login} program.
  12086. @item @code{extra-options} (default: @code{'()})
  12087. This option provides an ``escape hatch'' for the user to provide arbitrary
  12088. command-line arguments to @command{agetty} as a list of strings.
  12089. @end table
  12090. @end deftp
  12091. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  12092. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  12093. according to @var{config}, a @code{<kmscon-configuration>} object, which
  12094. specifies the tty to run, among other things.
  12095. @end deffn
  12096. @deftp {Data Type} kmscon-configuration
  12097. This is the data type representing the configuration of Kmscon, which
  12098. implements virtual console log-in.
  12099. @table @asis
  12100. @item @code{virtual-terminal}
  12101. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  12102. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  12103. A gexp denoting the name of the log-in program. The default log-in program is
  12104. @command{login} from the Shadow tool suite.
  12105. @item @code{login-arguments} (default: @code{'("-p")})
  12106. A list of arguments to pass to @command{login}.
  12107. @item @code{auto-login} (default: @code{#f})
  12108. When passed a login name, as a string, the specified user will be logged
  12109. in automatically without prompting for their login name or password.
  12110. @item @code{hardware-acceleration?} (default: #f)
  12111. Whether to use hardware acceleration.
  12112. @item @code{kmscon} (default: @var{kmscon})
  12113. The Kmscon package to use.
  12114. @end table
  12115. @end deftp
  12116. @cindex name service cache daemon
  12117. @cindex nscd
  12118. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  12119. [#:name-services '()]
  12120. Return a service that runs the libc name service cache daemon (nscd) with the
  12121. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  12122. Service Switch}, for an example.
  12123. For convenience, the Shepherd service for nscd provides the following actions:
  12124. @table @code
  12125. @item invalidate
  12126. @cindex cache invalidation, nscd
  12127. @cindex nscd, cache invalidation
  12128. This invalidate the given cache. For instance, running:
  12129. @example
  12130. herd invalidate nscd hosts
  12131. @end example
  12132. @noindent
  12133. invalidates the host name lookup cache of nscd.
  12134. @item statistics
  12135. Running @command{herd statistics nscd} displays information about nscd usage
  12136. and caches.
  12137. @end table
  12138. @end deffn
  12139. @defvr {Scheme Variable} %nscd-default-configuration
  12140. This is the default @code{<nscd-configuration>} value (see below) used
  12141. by @code{nscd-service}. It uses the caches defined by
  12142. @code{%nscd-default-caches}; see below.
  12143. @end defvr
  12144. @deftp {Data Type} nscd-configuration
  12145. This is the data type representing the name service cache daemon (nscd)
  12146. configuration.
  12147. @table @asis
  12148. @item @code{name-services} (default: @code{'()})
  12149. List of packages denoting @dfn{name services} that must be visible to
  12150. the nscd---e.g., @code{(list @var{nss-mdns})}.
  12151. @item @code{glibc} (default: @var{glibc})
  12152. Package object denoting the GNU C Library providing the @command{nscd}
  12153. command.
  12154. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  12155. Name of the nscd log file. This is where debugging output goes when
  12156. @code{debug-level} is strictly positive.
  12157. @item @code{debug-level} (default: @code{0})
  12158. Integer denoting the debugging levels. Higher numbers mean that more
  12159. debugging output is logged.
  12160. @item @code{caches} (default: @code{%nscd-default-caches})
  12161. List of @code{<nscd-cache>} objects denoting things to be cached; see
  12162. below.
  12163. @end table
  12164. @end deftp
  12165. @deftp {Data Type} nscd-cache
  12166. Data type representing a cache database of nscd and its parameters.
  12167. @table @asis
  12168. @item @code{database}
  12169. This is a symbol representing the name of the database to be cached.
  12170. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  12171. @code{services}, which designate the corresponding NSS database
  12172. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  12173. @item @code{positive-time-to-live}
  12174. @itemx @code{negative-time-to-live} (default: @code{20})
  12175. A number representing the number of seconds during which a positive or
  12176. negative lookup result remains in cache.
  12177. @item @code{check-files?} (default: @code{#t})
  12178. Whether to check for updates of the files corresponding to
  12179. @var{database}.
  12180. For instance, when @var{database} is @code{hosts}, setting this flag
  12181. instructs nscd to check for updates in @file{/etc/hosts} and to take
  12182. them into account.
  12183. @item @code{persistent?} (default: @code{#t})
  12184. Whether the cache should be stored persistently on disk.
  12185. @item @code{shared?} (default: @code{#t})
  12186. Whether the cache should be shared among users.
  12187. @item @code{max-database-size} (default: 32@tie{}MiB)
  12188. Maximum size in bytes of the database cache.
  12189. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  12190. @c settings, so leave them out.
  12191. @end table
  12192. @end deftp
  12193. @defvr {Scheme Variable} %nscd-default-caches
  12194. List of @code{<nscd-cache>} objects used by default by
  12195. @code{nscd-configuration} (see above).
  12196. It enables persistent and aggressive caching of service and host name
  12197. lookups. The latter provides better host name lookup performance,
  12198. resilience in the face of unreliable name servers, and also better
  12199. privacy---often the result of host name lookups is in local cache, so
  12200. external name servers do not even need to be queried.
  12201. @end defvr
  12202. @anchor{syslog-configuration-type}
  12203. @cindex syslog
  12204. @cindex logging
  12205. @deftp {Data Type} syslog-configuration
  12206. This data type represents the configuration of the syslog daemon.
  12207. @table @asis
  12208. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  12209. The syslog daemon to use.
  12210. @item @code{config-file} (default: @code{%default-syslog.conf})
  12211. The syslog configuration file to use.
  12212. @end table
  12213. @end deftp
  12214. @anchor{syslog-service}
  12215. @cindex syslog
  12216. @deffn {Scheme Procedure} syslog-service @var{config}
  12217. Return a service that runs a syslog daemon according to @var{config}.
  12218. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  12219. information on the configuration file syntax.
  12220. @end deffn
  12221. @defvr {Scheme Variable} guix-service-type
  12222. This is the type of the service that runs the build daemon,
  12223. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  12224. @code{guix-configuration} record as described below.
  12225. @end defvr
  12226. @anchor{guix-configuration-type}
  12227. @deftp {Data Type} guix-configuration
  12228. This data type represents the configuration of the Guix build daemon.
  12229. @xref{Invoking guix-daemon}, for more information.
  12230. @table @asis
  12231. @item @code{guix} (default: @var{guix})
  12232. The Guix package to use.
  12233. @item @code{build-group} (default: @code{"guixbuild"})
  12234. Name of the group for build user accounts.
  12235. @item @code{build-accounts} (default: @code{10})
  12236. Number of build user accounts to create.
  12237. @item @code{authorize-key?} (default: @code{#t})
  12238. @cindex substitutes, authorization thereof
  12239. Whether to authorize the substitute keys listed in
  12240. @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
  12241. (@pxref{Substitutes}).
  12242. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  12243. changed by invoking @command{guix archive --authorize}. You must
  12244. instead adjust @code{guix-configuration} as you wish and reconfigure the
  12245. system. This ensures that your operating system configuration file is
  12246. self-contained.
  12247. @quotation Note
  12248. When booting or reconfiguring to a system where @code{authorize-key?}
  12249. is true, the existing @file{/etc/guix/acl} file is backed up as
  12250. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  12251. file. This is to facilitate migration from earlier versions, which
  12252. allowed for in-place modifications to @file{/etc/guix/acl}.
  12253. @end quotation
  12254. @vindex %default-authorized-guix-keys
  12255. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  12256. The list of authorized key files for archive imports, as a list of
  12257. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  12258. contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
  12259. See @code{substitute-urls} below for an example on how to change it.
  12260. @item @code{use-substitutes?} (default: @code{#t})
  12261. Whether to use substitutes.
  12262. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  12263. The list of URLs where to look for substitutes by default.
  12264. Suppose you would like to fetch substitutes from @code{guix.example.org}
  12265. in addition to @code{@value{SUBSTITUTE-SERVER}}. You will need to do
  12266. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  12267. and (2) authorize its signing key, having done appropriate checks
  12268. (@pxref{Substitute Server Authorization}). The configuration below does
  12269. exactly that:
  12270. @lisp
  12271. (guix-configuration
  12272. (substitute-urls
  12273. (append (list "https://guix.example.org")
  12274. %default-substitute-urls))
  12275. (authorized-keys
  12276. (append (list (local-file "./guix.example.org-key.pub"))
  12277. %default-authorized-guix-keys)))
  12278. @end lisp
  12279. This example assumes that the file @file{./guix.example.org-key.pub}
  12280. contains the public key that @code{guix.example.org} uses to sign
  12281. substitutes.
  12282. @item @code{max-silent-time} (default: @code{0})
  12283. @itemx @code{timeout} (default: @code{0})
  12284. The number of seconds of silence and the number of seconds of activity,
  12285. respectively, after which a build process times out. A value of zero
  12286. disables the timeout.
  12287. @item @code{log-compression} (default: @code{'bzip2})
  12288. The type of compression used for build logs---one of @code{gzip},
  12289. @code{bzip2}, or @code{none}.
  12290. @item @code{discover?} (default: @code{#f})
  12291. Whether to discover substitute servers on the local network using mDNS
  12292. and DNS-SD.
  12293. @item @code{extra-options} (default: @code{'()})
  12294. List of extra command-line options for @command{guix-daemon}.
  12295. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  12296. File where @command{guix-daemon}'s standard output and standard error
  12297. are written.
  12298. @cindex HTTP proxy, for @code{guix-daemon}
  12299. @cindex proxy, for @code{guix-daemon} HTTP access
  12300. @item @code{http-proxy} (default: @code{#f})
  12301. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  12302. derivations and substitutes.
  12303. It is also possible to change the daemon's proxy at run time through the
  12304. @code{set-http-proxy} action, which restarts it:
  12305. @example
  12306. herd set-http-proxy guix-daemon http://localhost:8118
  12307. @end example
  12308. To clear the proxy settings, run:
  12309. @example
  12310. herd set-http-proxy guix-daemon
  12311. @end example
  12312. @item @code{tmpdir} (default: @code{#f})
  12313. A directory path where the @command{guix-daemon} will perform builds.
  12314. @end table
  12315. @end deftp
  12316. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  12317. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  12318. udev rules can be provided as a list of files through the @var{rules}
  12319. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  12320. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  12321. creation of such rule files.
  12322. The @command{herd rules udev} command, as root, returns the name of the
  12323. directory containing all the active udev rules.
  12324. @end deffn
  12325. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  12326. Return a udev-rule file named @var{file-name} containing the rules
  12327. defined by the @var{contents} literal.
  12328. In the following example, a rule for a USB device is defined to be
  12329. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  12330. upon detecting a USB device with a given product identifier.
  12331. @lisp
  12332. (define %example-udev-rule
  12333. (udev-rule
  12334. "90-usb-thing.rules"
  12335. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  12336. "ATTR@{product@}==\"Example\", "
  12337. "RUN+=\"/path/to/script\"")))
  12338. @end lisp
  12339. @end deffn
  12340. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  12341. [#:groups @var{groups}]
  12342. Return a service that extends @code{udev-service-type } with @var{rules}
  12343. and @code{account-service-type} with @var{groups} as system groups.
  12344. This works by creating a singleton service type
  12345. @code{@var{name}-udev-rules}, of which the returned service is an
  12346. instance.
  12347. Here we show how it can be used to extend @code{udev-service-type} with the
  12348. previously defined rule @code{%example-udev-rule}.
  12349. @lisp
  12350. (operating-system
  12351. ;; @dots{}
  12352. (services
  12353. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  12354. %desktop-services)))
  12355. @end lisp
  12356. @end deffn
  12357. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  12358. Return a udev file named @var{file-name} containing the rules defined
  12359. within @var{file}, a file-like object.
  12360. The following example showcases how we can use an existing rule file.
  12361. @lisp
  12362. (use-modules (guix download) ;for url-fetch
  12363. (guix packages) ;for origin
  12364. @dots{})
  12365. (define %android-udev-rules
  12366. (file->udev-rule
  12367. "51-android-udev.rules"
  12368. (let ((version "20170910"))
  12369. (origin
  12370. (method url-fetch)
  12371. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  12372. "android-udev-rules/" version "/51-android.rules"))
  12373. (sha256
  12374. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  12375. @end lisp
  12376. @end deffn
  12377. Additionally, Guix package definitions can be included in @var{rules} in
  12378. order to extend the udev rules with the definitions found under their
  12379. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  12380. @var{file->udev-rule} example, we could have used the
  12381. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  12382. packages android)} module.
  12383. The following example shows how to use the @var{android-udev-rules}
  12384. package so that the Android tool @command{adb} can detect devices
  12385. without root privileges. It also details how to create the
  12386. @code{adbusers} group, which is required for the proper functioning of
  12387. the rules defined within the @code{android-udev-rules} package. To
  12388. create such a group, we must define it both as part of the
  12389. @code{supplementary-groups} of our @code{user-account} declaration, as
  12390. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  12391. @lisp
  12392. (use-modules (gnu packages android) ;for android-udev-rules
  12393. (gnu system shadow) ;for user-group
  12394. @dots{})
  12395. (operating-system
  12396. ;; @dots{}
  12397. (users (cons (user-account
  12398. ;; @dots{}
  12399. (supplementary-groups
  12400. '("adbusers" ;for adb
  12401. "wheel" "netdev" "audio" "video")))))
  12402. ;; @dots{}
  12403. (services
  12404. (cons (udev-rules-service 'android android-udev-rules
  12405. #:groups '("adbusers"))
  12406. %desktop-services)))
  12407. @end lisp
  12408. @defvr {Scheme Variable} urandom-seed-service-type
  12409. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  12410. when rebooting. It also tries to seed @file{/dev/urandom} from
  12411. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  12412. readable.
  12413. @end defvr
  12414. @defvr {Scheme Variable} %random-seed-file
  12415. This is the name of the file where some random bytes are saved by
  12416. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  12417. It defaults to @file{/var/lib/random-seed}.
  12418. @end defvr
  12419. @cindex mouse
  12420. @cindex gpm
  12421. @defvr {Scheme Variable} gpm-service-type
  12422. This is the type of the service that runs GPM, the @dfn{general-purpose
  12423. mouse daemon}, which provides mouse support to the Linux console. GPM
  12424. allows users to use the mouse in the console, notably to select, copy,
  12425. and paste text.
  12426. The value for services of this type must be a @code{gpm-configuration}
  12427. (see below). This service is not part of @code{%base-services}.
  12428. @end defvr
  12429. @deftp {Data Type} gpm-configuration
  12430. Data type representing the configuration of GPM.
  12431. @table @asis
  12432. @item @code{options} (default: @code{%default-gpm-options})
  12433. Command-line options passed to @command{gpm}. The default set of
  12434. options instruct @command{gpm} to listen to mouse events on
  12435. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  12436. more information.
  12437. @item @code{gpm} (default: @code{gpm})
  12438. The GPM package to use.
  12439. @end table
  12440. @end deftp
  12441. @anchor{guix-publish-service-type}
  12442. @deffn {Scheme Variable} guix-publish-service-type
  12443. This is the service type for @command{guix publish} (@pxref{Invoking
  12444. guix publish}). Its value must be a @code{guix-publish-configuration}
  12445. object, as described below.
  12446. This assumes that @file{/etc/guix} already contains a signing key pair as
  12447. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  12448. archive}). If that is not the case, the service will fail to start.
  12449. @end deffn
  12450. @deftp {Data Type} guix-publish-configuration
  12451. Data type representing the configuration of the @code{guix publish}
  12452. service.
  12453. @table @asis
  12454. @item @code{guix} (default: @code{guix})
  12455. The Guix package to use.
  12456. @item @code{port} (default: @code{80})
  12457. The TCP port to listen for connections.
  12458. @item @code{host} (default: @code{"localhost"})
  12459. The host (and thus, network interface) to listen to. Use
  12460. @code{"0.0.0.0"} to listen on all the network interfaces.
  12461. @item @code{advertise?} (default: @code{#f})
  12462. When true, advertise the service on the local network @i{via} the DNS-SD
  12463. protocol, using Avahi.
  12464. This allows neighboring Guix devices with discovery on (see
  12465. @code{guix-configuration} above) to discover this @command{guix publish}
  12466. instance and to automatically download substitutes from it.
  12467. @item @code{compression} (default: @code{'(("gzip" 3))})
  12468. This is a list of compression method/level tuple used when compressing
  12469. substitutes. For example, to compress all substitutes with @emph{both} lzip
  12470. at level 7 and gzip at level 9, write:
  12471. @lisp
  12472. '(("lzip" 7) ("gzip" 9))
  12473. @end lisp
  12474. Level 9 achieves the best compression ratio at the expense of increased CPU
  12475. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  12476. publish}, for more information on the available compression methods and
  12477. the tradeoffs involved.
  12478. An empty list disables compression altogether.
  12479. @item @code{nar-path} (default: @code{"nar"})
  12480. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  12481. publish, @option{--nar-path}}, for details.
  12482. @item @code{cache} (default: @code{#f})
  12483. When it is @code{#f}, disable caching and instead generate archives on
  12484. demand. Otherwise, this should be the name of a directory---e.g.,
  12485. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  12486. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  12487. @option{--cache}}, for more information on the tradeoffs involved.
  12488. @item @code{workers} (default: @code{#f})
  12489. When it is an integer, this is the number of worker threads used for
  12490. caching; when @code{#f}, the number of processors is used.
  12491. @xref{Invoking guix publish, @option{--workers}}, for more information.
  12492. @item @code{cache-bypass-threshold} (default: 10 MiB)
  12493. When @code{cache} is true, this is the maximum size in bytes of a store
  12494. item for which @command{guix publish} may bypass its cache in case of a
  12495. cache miss. @xref{Invoking guix publish,
  12496. @option{--cache-bypass-threshold}}, for more information.
  12497. @item @code{ttl} (default: @code{#f})
  12498. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  12499. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  12500. for more information.
  12501. @end table
  12502. @end deftp
  12503. @anchor{rngd-service}
  12504. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  12505. [#:device "/dev/hwrng"]
  12506. Return a service that runs the @command{rngd} program from @var{rng-tools}
  12507. to add @var{device} to the kernel's entropy pool. The service will fail if
  12508. @var{device} does not exist.
  12509. @end deffn
  12510. @anchor{pam-limits-service}
  12511. @cindex session limits
  12512. @cindex ulimit
  12513. @cindex priority
  12514. @cindex realtime
  12515. @cindex jackd
  12516. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  12517. Return a service that installs a configuration file for the
  12518. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  12519. @code{pam_limits} module}. The procedure optionally takes a list of
  12520. @code{pam-limits-entry} values, which can be used to specify
  12521. @code{ulimit} limits and nice priority limits to user sessions.
  12522. The following limits definition sets two hard and soft limits for all
  12523. login sessions of users in the @code{realtime} group:
  12524. @lisp
  12525. (pam-limits-service
  12526. (list
  12527. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  12528. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  12529. @end lisp
  12530. The first entry increases the maximum realtime priority for
  12531. non-privileged processes; the second entry lifts any restriction of the
  12532. maximum address space that can be locked in memory. These settings are
  12533. commonly used for real-time audio systems.
  12534. @end deffn
  12535. @node Scheduled Job Execution
  12536. @subsection Scheduled Job Execution
  12537. @cindex cron
  12538. @cindex mcron
  12539. @cindex scheduling jobs
  12540. The @code{(gnu services mcron)} module provides an interface to
  12541. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  12542. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  12543. Unix @command{cron} daemon; the main difference is that it is
  12544. implemented in Guile Scheme, which provides a lot of flexibility when
  12545. specifying the scheduling of jobs and their actions.
  12546. The example below defines an operating system that runs the
  12547. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  12548. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  12549. well as the @command{mkid} command on behalf of an unprivileged user
  12550. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  12551. gexps to introduce job definitions that are passed to mcron
  12552. (@pxref{G-Expressions}).
  12553. @lisp
  12554. (use-modules (guix) (gnu) (gnu services mcron))
  12555. (use-package-modules base idutils)
  12556. (define updatedb-job
  12557. ;; Run 'updatedb' at 3AM every day. Here we write the
  12558. ;; job's action as a Scheme procedure.
  12559. #~(job '(next-hour '(3))
  12560. (lambda ()
  12561. (execl (string-append #$findutils "/bin/updatedb")
  12562. "updatedb"
  12563. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  12564. (define garbage-collector-job
  12565. ;; Collect garbage 5 minutes after midnight every day.
  12566. ;; The job's action is a shell command.
  12567. #~(job "5 0 * * *" ;Vixie cron syntax
  12568. "guix gc -F 1G"))
  12569. (define idutils-job
  12570. ;; Update the index database as user "charlie" at 12:15PM
  12571. ;; and 19:15PM. This runs from the user's home directory.
  12572. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  12573. (string-append #$idutils "/bin/mkid src")
  12574. #:user "charlie"))
  12575. (operating-system
  12576. ;; @dots{}
  12577. ;; %BASE-SERVICES already includes an instance of
  12578. ;; 'mcron-service-type', which we extend with additional
  12579. ;; jobs using 'simple-service'.
  12580. (services (cons (simple-service 'my-cron-jobs
  12581. mcron-service-type
  12582. (list garbage-collector-job
  12583. updatedb-job
  12584. idutils-job))
  12585. %base-services)))
  12586. @end lisp
  12587. For more complex jobs defined in Scheme where you need control over the top
  12588. level, for instance to introduce a @code{use-modules} form, you can move your
  12589. code to a separate program using the @code{program-file} procedure of the
  12590. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  12591. illustrates that.
  12592. @lisp
  12593. (define %battery-alert-job
  12594. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  12595. #~(job
  12596. '(next-minute (range 0 60 1))
  12597. #$(program-file
  12598. "battery-alert.scm"
  12599. (with-imported-modules (source-module-closure
  12600. '((guix build utils)))
  12601. #~(begin
  12602. (use-modules (guix build utils)
  12603. (ice-9 popen)
  12604. (ice-9 regex)
  12605. (ice-9 textual-ports)
  12606. (srfi srfi-2))
  12607. (define %min-level 20)
  12608. (setenv "LC_ALL" "C") ;ensure English output
  12609. (and-let* ((input-pipe (open-pipe*
  12610. OPEN_READ
  12611. #$(file-append acpi "/bin/acpi")))
  12612. (output (get-string-all input-pipe))
  12613. (m (string-match "Discharging, ([0-9]+)%" output))
  12614. (level (string->number (match:substring m 1)))
  12615. ((< level %min-level)))
  12616. (format #t "warning: Battery level is low (~a%)~%" level)
  12617. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  12618. @end lisp
  12619. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  12620. for more information on mcron job specifications. Below is the
  12621. reference of the mcron service.
  12622. On a running system, you can use the @code{schedule} action of the service to
  12623. visualize the mcron jobs that will be executed next:
  12624. @example
  12625. # herd schedule mcron
  12626. @end example
  12627. @noindent
  12628. The example above lists the next five tasks that will be executed, but you can
  12629. also specify the number of tasks to display:
  12630. @example
  12631. # herd schedule mcron 10
  12632. @end example
  12633. @defvr {Scheme Variable} mcron-service-type
  12634. This is the type of the @code{mcron} service, whose value is an
  12635. @code{mcron-configuration} object.
  12636. This service type can be the target of a service extension that provides
  12637. it additional job specifications (@pxref{Service Composition}). In
  12638. other words, it is possible to define services that provide additional
  12639. mcron jobs to run.
  12640. @end defvr
  12641. @deftp {Data Type} mcron-configuration
  12642. Data type representing the configuration of mcron.
  12643. @table @asis
  12644. @item @code{mcron} (default: @var{mcron})
  12645. The mcron package to use.
  12646. @item @code{jobs}
  12647. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  12648. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  12649. specifications,, mcron, GNU@tie{}mcron}).
  12650. @end table
  12651. @end deftp
  12652. @node Log Rotation
  12653. @subsection Log Rotation
  12654. @cindex rottlog
  12655. @cindex log rotation
  12656. @cindex logging
  12657. Log files such as those found in @file{/var/log} tend to grow endlessly,
  12658. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  12659. their contents in separate files, possibly compressed. The @code{(gnu
  12660. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  12661. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  12662. This service is part of @code{%base-services}, and thus enabled by
  12663. default, with the default settings, for commonly encountered log files.
  12664. The example below shows how to extend it with an additional
  12665. @dfn{rotation}, should you need to do that (usually, services that
  12666. produce log files already take care of that):
  12667. @lisp
  12668. (use-modules (guix) (gnu))
  12669. (use-service-modules admin)
  12670. (define my-log-files
  12671. ;; Log files that I want to rotate.
  12672. '("/var/log/something.log" "/var/log/another.log"))
  12673. (operating-system
  12674. ;; @dots{}
  12675. (services (cons (simple-service 'rotate-my-stuff
  12676. rottlog-service-type
  12677. (list (log-rotation
  12678. (frequency 'daily)
  12679. (files my-log-files))))
  12680. %base-services)))
  12681. @end lisp
  12682. @defvr {Scheme Variable} rottlog-service-type
  12683. This is the type of the Rottlog service, whose value is a
  12684. @code{rottlog-configuration} object.
  12685. Other services can extend this one with new @code{log-rotation} objects
  12686. (see below), thereby augmenting the set of files to be rotated.
  12687. This service type can define mcron jobs (@pxref{Scheduled Job
  12688. Execution}) to run the rottlog service.
  12689. @end defvr
  12690. @deftp {Data Type} rottlog-configuration
  12691. Data type representing the configuration of rottlog.
  12692. @table @asis
  12693. @item @code{rottlog} (default: @code{rottlog})
  12694. The Rottlog package to use.
  12695. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  12696. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  12697. rottlog, GNU Rot[t]log Manual}).
  12698. @item @code{rotations} (default: @code{%default-rotations})
  12699. A list of @code{log-rotation} objects as defined below.
  12700. @item @code{jobs}
  12701. This is a list of gexps where each gexp corresponds to an mcron job
  12702. specification (@pxref{Scheduled Job Execution}).
  12703. @end table
  12704. @end deftp
  12705. @deftp {Data Type} log-rotation
  12706. Data type representing the rotation of a group of log files.
  12707. Taking an example from the Rottlog manual (@pxref{Period Related File
  12708. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  12709. defined like this:
  12710. @lisp
  12711. (log-rotation
  12712. (frequency 'daily)
  12713. (files '("/var/log/apache/*"))
  12714. (options '("storedir apache-archives"
  12715. "rotate 6"
  12716. "notifempty"
  12717. "nocompress")))
  12718. @end lisp
  12719. The list of fields is as follows:
  12720. @table @asis
  12721. @item @code{frequency} (default: @code{'weekly})
  12722. The log rotation frequency, a symbol.
  12723. @item @code{files}
  12724. The list of files or file glob patterns to rotate.
  12725. @item @code{options} (default: @code{'()})
  12726. The list of rottlog options for this rotation (@pxref{Configuration
  12727. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  12728. @item @code{post-rotate} (default: @code{#f})
  12729. Either @code{#f} or a gexp to execute once the rotation has completed.
  12730. @end table
  12731. @end deftp
  12732. @defvr {Scheme Variable} %default-rotations
  12733. Specifies weekly rotation of @code{%rotated-files} and of
  12734. @file{/var/log/guix-daemon.log}.
  12735. @end defvr
  12736. @defvr {Scheme Variable} %rotated-files
  12737. The list of syslog-controlled files to be rotated. By default it is:
  12738. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  12739. "/var/log/maillog")}.
  12740. @end defvr
  12741. @node Networking Services
  12742. @subsection Networking Services
  12743. The @code{(gnu services networking)} module provides services to configure
  12744. the network interface.
  12745. @cindex DHCP, networking service
  12746. @defvr {Scheme Variable} dhcp-client-service-type
  12747. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  12748. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  12749. is the DHCP client package to use, @code{isc-dhcp} by default.
  12750. @end defvr
  12751. @deffn {Scheme Procedure} dhcpd-service-type
  12752. This type defines a service that runs a DHCP daemon. To create a
  12753. service of this type, you must supply a @code{<dhcpd-configuration>}.
  12754. For example:
  12755. @lisp
  12756. (service dhcpd-service-type
  12757. (dhcpd-configuration
  12758. (config-file (local-file "my-dhcpd.conf"))
  12759. (interfaces '("enp0s25"))))
  12760. @end lisp
  12761. @end deffn
  12762. @deftp {Data Type} dhcpd-configuration
  12763. @table @asis
  12764. @item @code{package} (default: @code{isc-dhcp})
  12765. The package that provides the DHCP daemon. This package is expected to
  12766. provide the daemon at @file{sbin/dhcpd} relative to its output
  12767. directory. The default package is the
  12768. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  12769. @item @code{config-file} (default: @code{#f})
  12770. The configuration file to use. This is required. It will be passed to
  12771. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  12772. object (@pxref{G-Expressions, file-like objects}). See @code{man
  12773. dhcpd.conf} for details on the configuration file syntax.
  12774. @item @code{version} (default: @code{"4"})
  12775. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  12776. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  12777. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  12778. details.
  12779. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  12780. The run directory to use. At service activation time, this directory
  12781. will be created if it does not exist.
  12782. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  12783. The PID file to use. This corresponds to the @code{-pf} option of
  12784. @code{dhcpd}. See @code{man dhcpd} for details.
  12785. @item @code{interfaces} (default: @code{'()})
  12786. The names of the network interfaces on which dhcpd should listen for
  12787. broadcasts. If this list is not empty, then its elements (which must be
  12788. strings) will be appended to the @code{dhcpd} invocation when starting
  12789. the daemon. It may not be necessary to explicitly specify any
  12790. interfaces here; see @code{man dhcpd} for details.
  12791. @end table
  12792. @end deftp
  12793. @defvr {Scheme Variable} static-networking-service-type
  12794. This is the type for statically-configured network interfaces.
  12795. @c TODO Document <static-networking> data structures.
  12796. @end defvr
  12797. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  12798. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  12799. [#:requirement @code{'(udev)}]
  12800. Return a service that starts @var{interface} with address @var{ip}. If
  12801. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  12802. it must be a string specifying the default network gateway. @var{requirement}
  12803. can be used to declare a dependency on another service before configuring the
  12804. interface.
  12805. This procedure can be called several times, one for each network
  12806. interface of interest. Behind the scenes what it does is extend
  12807. @code{static-networking-service-type} with additional network interfaces
  12808. to handle.
  12809. For example:
  12810. @lisp
  12811. (static-networking-service "eno1" "192.168.1.82"
  12812. #:gateway "192.168.1.2"
  12813. #:name-servers '("192.168.1.2"))
  12814. @end lisp
  12815. @end deffn
  12816. @cindex wicd
  12817. @cindex wireless
  12818. @cindex WiFi
  12819. @cindex network management
  12820. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  12821. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  12822. management daemon that aims to simplify wired and wireless networking.
  12823. This service adds the @var{wicd} package to the global profile, providing
  12824. several commands to interact with the daemon and configure networking:
  12825. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  12826. and @command{wicd-curses} user interfaces.
  12827. @end deffn
  12828. @cindex ModemManager
  12829. @defvr {Scheme Variable} modem-manager-service-type
  12830. This is the service type for the
  12831. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  12832. service. The value for this service type is a
  12833. @code{modem-manager-configuration} record.
  12834. This service is part of @code{%desktop-services} (@pxref{Desktop
  12835. Services}).
  12836. @end defvr
  12837. @deftp {Data Type} modem-manager-configuration
  12838. Data type representing the configuration of ModemManager.
  12839. @table @asis
  12840. @item @code{modem-manager} (default: @code{modem-manager})
  12841. The ModemManager package to use.
  12842. @end table
  12843. @end deftp
  12844. @cindex USB_ModeSwitch
  12845. @cindex Modeswitching
  12846. @defvr {Scheme Variable} usb-modeswitch-service-type
  12847. This is the service type for the
  12848. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  12849. service. The value for this service type is
  12850. a @code{usb-modeswitch-configuration} record.
  12851. When plugged in, some USB modems (and other USB devices) initially present
  12852. themselves as a read-only storage medium and not as a modem. They need to be
  12853. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  12854. installs udev rules to automatically modeswitch these devices when they are
  12855. plugged in.
  12856. This service is part of @code{%desktop-services} (@pxref{Desktop
  12857. Services}).
  12858. @end defvr
  12859. @deftp {Data Type} usb-modeswitch-configuration
  12860. Data type representing the configuration of USB_ModeSwitch.
  12861. @table @asis
  12862. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  12863. The USB_ModeSwitch package providing the binaries for modeswitching.
  12864. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  12865. The package providing the device data and udev rules file used by
  12866. USB_ModeSwitch.
  12867. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  12868. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  12869. config file shipped with USB_ModeSwitch is used which disables logging to
  12870. @file{/var/log} among other default settings. If set to @code{#f}, no config
  12871. file is used.
  12872. @end table
  12873. @end deftp
  12874. @cindex NetworkManager
  12875. @defvr {Scheme Variable} network-manager-service-type
  12876. This is the service type for the
  12877. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  12878. service. The value for this service type is a
  12879. @code{network-manager-configuration} record.
  12880. This service is part of @code{%desktop-services} (@pxref{Desktop
  12881. Services}).
  12882. @end defvr
  12883. @deftp {Data Type} network-manager-configuration
  12884. Data type representing the configuration of NetworkManager.
  12885. @table @asis
  12886. @item @code{network-manager} (default: @code{network-manager})
  12887. The NetworkManager package to use.
  12888. @item @code{dns} (default: @code{"default"})
  12889. Processing mode for DNS, which affects how NetworkManager uses the
  12890. @code{resolv.conf} configuration file.
  12891. @table @samp
  12892. @item default
  12893. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  12894. provided by currently active connections.
  12895. @item dnsmasq
  12896. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  12897. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  12898. then update @code{resolv.conf} to point to the local nameserver.
  12899. With this setting, you can share your network connection. For example when
  12900. you want to share your network connection to another laptop @i{via} an
  12901. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  12902. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  12903. and reestablish the connection (or reboot).
  12904. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  12905. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  12906. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  12907. browser on your host system, or connect to the VM @i{via} SSH
  12908. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  12909. host-to-guest connection, run this command once:
  12910. @example
  12911. nmcli connection add type tun \
  12912. connection.interface-name tap0 \
  12913. tun.mode tap tun.owner $(id -u) \
  12914. ipv4.method shared \
  12915. ipv4.addresses 172.28.112.1/24
  12916. @end example
  12917. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  12918. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  12919. @command{qemu-system-...}.
  12920. @item none
  12921. NetworkManager will not modify @code{resolv.conf}.
  12922. @end table
  12923. @item @code{vpn-plugins} (default: @code{'()})
  12924. This is the list of available plugins for virtual private networks
  12925. (VPNs). An example of this is the @code{network-manager-openvpn}
  12926. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  12927. @end table
  12928. @end deftp
  12929. @cindex Connman
  12930. @deffn {Scheme Variable} connman-service-type
  12931. This is the service type to run @url{https://01.org/connman,Connman},
  12932. a network connection manager.
  12933. Its value must be an
  12934. @code{connman-configuration} record as in this example:
  12935. @lisp
  12936. (service connman-service-type
  12937. (connman-configuration
  12938. (disable-vpn? #t)))
  12939. @end lisp
  12940. See below for details about @code{connman-configuration}.
  12941. @end deffn
  12942. @deftp {Data Type} connman-configuration
  12943. Data Type representing the configuration of connman.
  12944. @table @asis
  12945. @item @code{connman} (default: @var{connman})
  12946. The connman package to use.
  12947. @item @code{disable-vpn?} (default: @code{#f})
  12948. When true, disable connman's vpn plugin.
  12949. @end table
  12950. @end deftp
  12951. @cindex WPA Supplicant
  12952. @defvr {Scheme Variable} wpa-supplicant-service-type
  12953. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  12954. supplicant}, an authentication daemon required to authenticate against
  12955. encrypted WiFi or ethernet networks.
  12956. @end defvr
  12957. @deftp {Data Type} wpa-supplicant-configuration
  12958. Data type representing the configuration of WPA Supplicant.
  12959. It takes the following parameters:
  12960. @table @asis
  12961. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  12962. The WPA Supplicant package to use.
  12963. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  12964. List of services that should be started before WPA Supplicant starts.
  12965. @item @code{dbus?} (default: @code{#t})
  12966. Whether to listen for requests on D-Bus.
  12967. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  12968. Where to store the PID file.
  12969. @item @code{interface} (default: @code{#f})
  12970. If this is set, it must specify the name of a network interface that
  12971. WPA supplicant will control.
  12972. @item @code{config-file} (default: @code{#f})
  12973. Optional configuration file to use.
  12974. @item @code{extra-options} (default: @code{'()})
  12975. List of additional command-line arguments to pass to the daemon.
  12976. @end table
  12977. @end deftp
  12978. @cindex hostapd service, for Wi-Fi access points
  12979. @cindex Wi-Fi access points, hostapd service
  12980. @defvr {Scheme Variable} hostapd-service-type
  12981. This is the service type to run the @uref{https://w1.fi/hostapd/,
  12982. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  12983. authentication servers. Its associated value must be a
  12984. @code{hostapd-configuration} as shown below:
  12985. @lisp
  12986. ;; Use wlan1 to run the access point for "My Network".
  12987. (service hostapd-service-type
  12988. (hostapd-configuration
  12989. (interface "wlan1")
  12990. (ssid "My Network")
  12991. (channel 12)))
  12992. @end lisp
  12993. @end defvr
  12994. @deftp {Data Type} hostapd-configuration
  12995. This data type represents the configuration of the hostapd service, with
  12996. the following fields:
  12997. @table @asis
  12998. @item @code{package} (default: @code{hostapd})
  12999. The hostapd package to use.
  13000. @item @code{interface} (default: @code{"wlan0"})
  13001. The network interface to run the WiFi access point.
  13002. @item @code{ssid}
  13003. The SSID (@dfn{service set identifier}), a string that identifies this
  13004. network.
  13005. @item @code{broadcast-ssid?} (default: @code{#t})
  13006. Whether to broadcast this SSID.
  13007. @item @code{channel} (default: @code{1})
  13008. The WiFi channel to use.
  13009. @item @code{driver} (default: @code{"nl80211"})
  13010. The driver interface type. @code{"nl80211"} is used with all Linux
  13011. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  13012. RADIUS server that does # not control any wireless/wired driver.
  13013. @item @code{extra-settings} (default: @code{""})
  13014. Extra settings to append as-is to the hostapd configuration file. See
  13015. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  13016. configuration file reference.
  13017. @end table
  13018. @end deftp
  13019. @defvr {Scheme Variable} simulated-wifi-service-type
  13020. This is the type of a service to simulate WiFi networking, which can be
  13021. useful in virtual machines for testing purposes. The service loads the
  13022. Linux kernel
  13023. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  13024. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  13025. network that can be seen on @code{wlan0}, by default.
  13026. The service's value is a @code{hostapd-configuration} record.
  13027. @end defvr
  13028. @cindex iptables
  13029. @defvr {Scheme Variable} iptables-service-type
  13030. This is the service type to set up an iptables configuration. iptables is a
  13031. packet filtering framework supported by the Linux kernel. This service
  13032. supports configuring iptables for both IPv4 and IPv6. A simple example
  13033. configuration rejecting all incoming connections except those to the ssh port
  13034. 22 is shown below.
  13035. @lisp
  13036. (service iptables-service-type
  13037. (iptables-configuration
  13038. (ipv4-rules (plain-file "iptables.rules" "*filter
  13039. :INPUT ACCEPT
  13040. :FORWARD ACCEPT
  13041. :OUTPUT ACCEPT
  13042. -A INPUT -p tcp --dport 22 -j ACCEPT
  13043. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  13044. COMMIT
  13045. "))
  13046. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  13047. :INPUT ACCEPT
  13048. :FORWARD ACCEPT
  13049. :OUTPUT ACCEPT
  13050. -A INPUT -p tcp --dport 22 -j ACCEPT
  13051. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  13052. COMMIT
  13053. "))))
  13054. @end lisp
  13055. @end defvr
  13056. @deftp {Data Type} iptables-configuration
  13057. The data type representing the configuration of iptables.
  13058. @table @asis
  13059. @item @code{iptables} (default: @code{iptables})
  13060. The iptables package that provides @code{iptables-restore} and
  13061. @code{ip6tables-restore}.
  13062. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  13063. The iptables rules to use. It will be passed to @code{iptables-restore}.
  13064. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13065. objects}).
  13066. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  13067. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  13068. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13069. objects}).
  13070. @end table
  13071. @end deftp
  13072. @cindex nftables
  13073. @defvr {Scheme Variable} nftables-service-type
  13074. This is the service type to set up a nftables configuration. nftables is a
  13075. netfilter project that aims to replace the existing iptables, ip6tables,
  13076. arptables and ebtables framework. It provides a new packet filtering
  13077. framework, a new user-space utility @command{nft}, and a compatibility layer
  13078. for iptables. This service comes with a default ruleset
  13079. @code{%default-nftables-ruleset} that rejecting all incomming connections
  13080. except those to the ssh port 22. To use it, simply write:
  13081. @lisp
  13082. (service nftables-service-type)
  13083. @end lisp
  13084. @end defvr
  13085. @deftp {Data Type} nftables-configuration
  13086. The data type representing the configuration of nftables.
  13087. @table @asis
  13088. @item @code{package} (default: @code{nftables})
  13089. The nftables package that provides @command{nft}.
  13090. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  13091. The nftables ruleset to use. This may be any ``file-like'' object
  13092. (@pxref{G-Expressions, file-like objects}).
  13093. @end table
  13094. @end deftp
  13095. @cindex NTP (Network Time Protocol), service
  13096. @cindex ntpd, service for the Network Time Protocol daemon
  13097. @cindex real time clock
  13098. @defvr {Scheme Variable} ntp-service-type
  13099. This is the type of the service running the @uref{https://www.ntp.org,
  13100. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  13101. system clock synchronized with that of the specified NTP servers.
  13102. The value of this service is an @code{ntpd-configuration} object, as described
  13103. below.
  13104. @end defvr
  13105. @deftp {Data Type} ntp-configuration
  13106. This is the data type for the NTP service configuration.
  13107. @table @asis
  13108. @item @code{servers} (default: @code{%ntp-servers})
  13109. This is the list of servers (@code{<ntp-server>} records) with which
  13110. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  13111. definition below.
  13112. @item @code{allow-large-adjustment?} (default: @code{#t})
  13113. This determines whether @command{ntpd} is allowed to make an initial
  13114. adjustment of more than 1,000 seconds.
  13115. @item @code{ntp} (default: @code{ntp})
  13116. The NTP package to use.
  13117. @end table
  13118. @end deftp
  13119. @defvr {Scheme Variable} %ntp-servers
  13120. List of host names used as the default NTP servers. These are servers of the
  13121. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  13122. @end defvr
  13123. @deftp {Data Type} ntp-server
  13124. The data type representing the configuration of a NTP server.
  13125. @table @asis
  13126. @item @code{type} (default: @code{'server})
  13127. The type of the NTP server, given as a symbol. One of @code{'pool},
  13128. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  13129. @item @code{address}
  13130. The address of the server, as a string.
  13131. @item @code{options}
  13132. NTPD options to use with that specific server, given as a list of option names
  13133. and/or of option names and values tuples. The following example define a server
  13134. to use with the options @option{iburst} and @option{prefer}, as well as
  13135. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  13136. @example
  13137. (ntp-server
  13138. (type 'server)
  13139. (address "some.ntp.server.org")
  13140. (options `(iburst (version 3) (maxpoll 16) prefer))))
  13141. @end example
  13142. @end table
  13143. @end deftp
  13144. @cindex OpenNTPD
  13145. @deffn {Scheme Procedure} openntpd-service-type
  13146. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  13147. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  13148. clock synchronized with that of the given servers.
  13149. @lisp
  13150. (service
  13151. openntpd-service-type
  13152. (openntpd-configuration
  13153. (listen-on '("127.0.0.1" "::1"))
  13154. (sensor '("udcf0 correction 70000"))
  13155. (constraint-from '("www.gnu.org"))
  13156. (constraints-from '("https://www.google.com/"))))
  13157. @end lisp
  13158. @end deffn
  13159. @defvr {Scheme Variable} %openntpd-servers
  13160. This variable is a list of the server addresses defined in
  13161. @code{%ntp-servers}.
  13162. @end defvr
  13163. @deftp {Data Type} openntpd-configuration
  13164. @table @asis
  13165. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  13166. The openntpd executable to use.
  13167. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  13168. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  13169. @item @code{query-from} (default: @code{'()})
  13170. A list of local IP address the ntpd daemon should use for outgoing queries.
  13171. @item @code{sensor} (default: @code{'()})
  13172. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  13173. will listen to each sensor that actually exists and ignore non-existent ones.
  13174. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  13175. information.
  13176. @item @code{server} (default: @code{'()})
  13177. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  13178. @item @code{servers} (default: @code{%openntp-servers})
  13179. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  13180. @item @code{constraint-from} (default: @code{'()})
  13181. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  13182. This time information is not used for precision but acts as an authenticated
  13183. constraint, thereby reducing the impact of unauthenticated NTP
  13184. man-in-the-middle attacks.
  13185. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  13186. a constraint.
  13187. @item @code{constraints-from} (default: @code{'()})
  13188. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  13189. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  13190. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  13191. @end table
  13192. @end deftp
  13193. @cindex inetd
  13194. @deffn {Scheme variable} inetd-service-type
  13195. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  13196. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  13197. connections on internet sockets, and lazily starts the specified server
  13198. program when a connection is made on one of these sockets.
  13199. The value of this service is an @code{inetd-configuration} object. The
  13200. following example configures the @command{inetd} daemon to provide the
  13201. built-in @command{echo} service, as well as an smtp service which
  13202. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  13203. gateway @code{hostname}:
  13204. @lisp
  13205. (service
  13206. inetd-service-type
  13207. (inetd-configuration
  13208. (entries (list
  13209. (inetd-entry
  13210. (name "echo")
  13211. (socket-type 'stream)
  13212. (protocol "tcp")
  13213. (wait? #f)
  13214. (user "root"))
  13215. (inetd-entry
  13216. (node "127.0.0.1")
  13217. (name "smtp")
  13218. (socket-type 'stream)
  13219. (protocol "tcp")
  13220. (wait? #f)
  13221. (user "root")
  13222. (program (file-append openssh "/bin/ssh"))
  13223. (arguments
  13224. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  13225. "-W" "smtp-server:25" "user@@hostname")))))))
  13226. @end lisp
  13227. See below for more details about @code{inetd-configuration}.
  13228. @end deffn
  13229. @deftp {Data Type} inetd-configuration
  13230. Data type representing the configuration of @command{inetd}.
  13231. @table @asis
  13232. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  13233. The @command{inetd} executable to use.
  13234. @item @code{entries} (default: @code{'()})
  13235. A list of @command{inetd} service entries. Each entry should be created
  13236. by the @code{inetd-entry} constructor.
  13237. @end table
  13238. @end deftp
  13239. @deftp {Data Type} inetd-entry
  13240. Data type representing an entry in the @command{inetd} configuration.
  13241. Each entry corresponds to a socket where @command{inetd} will listen for
  13242. requests.
  13243. @table @asis
  13244. @item @code{node} (default: @code{#f})
  13245. Optional string, a comma-separated list of local addresses
  13246. @command{inetd} should use when listening for this service.
  13247. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  13248. description of all options.
  13249. @item @code{name}
  13250. A string, the name must correspond to an entry in @code{/etc/services}.
  13251. @item @code{socket-type}
  13252. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  13253. @code{'seqpacket}.
  13254. @item @code{protocol}
  13255. A string, must correspond to an entry in @code{/etc/protocols}.
  13256. @item @code{wait?} (default: @code{#t})
  13257. Whether @command{inetd} should wait for the server to exit before
  13258. listening to new service requests.
  13259. @item @code{user}
  13260. A string containing the user (and, optionally, group) name of the user
  13261. as whom the server should run. The group name can be specified in a
  13262. suffix, separated by a colon or period, i.e.@: @code{"user"},
  13263. @code{"user:group"} or @code{"user.group"}.
  13264. @item @code{program} (default: @code{"internal"})
  13265. The server program which will serve the requests, or @code{"internal"}
  13266. if @command{inetd} should use a built-in service.
  13267. @item @code{arguments} (default: @code{'()})
  13268. A list strings or file-like objects, which are the server program's
  13269. arguments, starting with the zeroth argument, i.e.@: the name of the
  13270. program itself. For @command{inetd}'s internal services, this entry
  13271. must be @code{'()} or @code{'("internal")}.
  13272. @end table
  13273. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  13274. detailed discussion of each configuration field.
  13275. @end deftp
  13276. @cindex Tor
  13277. @defvr {Scheme Variable} tor-service-type
  13278. This is the type for a service that runs the @uref{https://torproject.org,
  13279. Tor} anonymous networking daemon. The service is configured using a
  13280. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  13281. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  13282. @end defvr
  13283. @deftp {Data Type} tor-configuration
  13284. @table @asis
  13285. @item @code{tor} (default: @code{tor})
  13286. The package that provides the Tor daemon. This package is expected to provide
  13287. the daemon at @file{bin/tor} relative to its output directory. The default
  13288. package is the @uref{https://www.torproject.org, Tor Project's}
  13289. implementation.
  13290. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  13291. The configuration file to use. It will be appended to a default configuration
  13292. file, and the final configuration file will be passed to @code{tor} via its
  13293. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  13294. file-like objects}). See @code{man tor} for details on the configuration file
  13295. syntax.
  13296. @item @code{hidden-services} (default: @code{'()})
  13297. The list of @code{<hidden-service>} records to use. For any hidden service
  13298. you include in this list, appropriate configuration to enable the hidden
  13299. service will be automatically added to the default configuration file. You
  13300. may conveniently create @code{<hidden-service>} records using the
  13301. @code{tor-hidden-service} procedure described below.
  13302. @item @code{socks-socket-type} (default: @code{'tcp})
  13303. The default socket type that Tor should use for its SOCKS socket. This must
  13304. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  13305. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  13306. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  13307. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  13308. @code{tor} group.
  13309. If you want to customize the SOCKS socket in more detail, leave
  13310. @code{socks-socket-type} at its default value of @code{'tcp} and use
  13311. @code{config-file} to override the default by providing your own
  13312. @code{SocksPort} option.
  13313. @end table
  13314. @end deftp
  13315. @cindex hidden service
  13316. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  13317. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  13318. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  13319. @example
  13320. '((22 "127.0.0.1:22")
  13321. (80 "127.0.0.1:8080"))
  13322. @end example
  13323. In this example, port 22 of the hidden service is mapped to local port 22, and
  13324. port 80 is mapped to local port 8080.
  13325. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  13326. the @file{hostname} file contains the @code{.onion} host name for the hidden
  13327. service.
  13328. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  13329. project's documentation} for more information.
  13330. @end deffn
  13331. The @code{(gnu services rsync)} module provides the following services:
  13332. You might want an rsync daemon if you have files that you want available
  13333. so anyone (or just yourself) can download existing files or upload new
  13334. files.
  13335. @deffn {Scheme Variable} rsync-service-type
  13336. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  13337. The value for this service type is a
  13338. @command{rsync-configuration} record as in this example:
  13339. @lisp
  13340. (service rsync-service-type)
  13341. @end lisp
  13342. See below for details about @code{rsync-configuration}.
  13343. @end deffn
  13344. @deftp {Data Type} rsync-configuration
  13345. Data type representing the configuration for @code{rsync-service}.
  13346. @table @asis
  13347. @item @code{package} (default: @var{rsync})
  13348. @code{rsync} package to use.
  13349. @item @code{port-number} (default: @code{873})
  13350. TCP port on which @command{rsync} listens for incoming connections. If port
  13351. is less than @code{1024} @command{rsync} needs to be started as the
  13352. @code{root} user and group.
  13353. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  13354. Name of the file where @command{rsync} writes its PID.
  13355. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  13356. Name of the file where @command{rsync} writes its lock file.
  13357. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  13358. Name of the file where @command{rsync} writes its log file.
  13359. @item @code{use-chroot?} (default: @var{#t})
  13360. Whether to use chroot for @command{rsync} shared directory.
  13361. @item @code{share-path} (default: @file{/srv/rsync})
  13362. Location of the @command{rsync} shared directory.
  13363. @item @code{share-comment} (default: @code{"Rsync share"})
  13364. Comment of the @command{rsync} shared directory.
  13365. @item @code{read-only?} (default: @var{#f})
  13366. Read-write permissions to shared directory.
  13367. @item @code{timeout} (default: @code{300})
  13368. I/O timeout in seconds.
  13369. @item @code{user} (default: @var{"root"})
  13370. Owner of the @code{rsync} process.
  13371. @item @code{group} (default: @var{"root"})
  13372. Group of the @code{rsync} process.
  13373. @item @code{uid} (default: @var{"rsyncd"})
  13374. User name or user ID that file transfers to and from that module should take
  13375. place as when the daemon was run as @code{root}.
  13376. @item @code{gid} (default: @var{"rsyncd"})
  13377. Group name or group ID that will be used when accessing the module.
  13378. @end table
  13379. @end deftp
  13380. The @code{(gnu services syncthing)} module provides the following services:
  13381. @cindex syncthing
  13382. You might want a syncthing daemon if you have files between two or more
  13383. computers and want to sync them in real time, safely protected from
  13384. prying eyes.
  13385. @deffn {Scheme Variable} syncthing-service-type
  13386. This is the service type for the @uref{https://syncthing.net/,
  13387. syncthing} daemon, The value for this service type is a
  13388. @command{syncthing-configuration} record as in this example:
  13389. @lisp
  13390. (service syncthing-service-type
  13391. (syncthing-configuration (user "alice")))
  13392. @end lisp
  13393. See below for details about @code{syncthing-configuration}.
  13394. @deftp {Data Type} syncthing-configuration
  13395. Data type representing the configuration for @code{syncthing-service-type}.
  13396. @table @asis
  13397. @item @code{syncthing} (default: @var{syncthing})
  13398. @code{syncthing} package to use.
  13399. @item @code{arguments} (default: @var{'()})
  13400. List of command-line arguments passing to @code{syncthing} binary.
  13401. @item @code{logflags} (default: @var{0})
  13402. Sum of loging flags, see
  13403. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  13404. @item @code{user} (default: @var{#f})
  13405. The user as which the Syncthing service is to be run.
  13406. This assumes that the specified user exists.
  13407. @item @code{group} (default: @var{"users"})
  13408. The group as which the Syncthing service is to be run.
  13409. This assumes that the specified group exists.
  13410. @item @code{home} (default: @var{#f})
  13411. Common configuration and data directory. The default configuration
  13412. directory is @file{$HOME} of the specified Syncthing @code{user}.
  13413. @end table
  13414. @end deftp
  13415. @end deffn
  13416. Furthermore, @code{(gnu services ssh)} provides the following services.
  13417. @cindex SSH
  13418. @cindex SSH server
  13419. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  13420. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  13421. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  13422. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  13423. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  13424. [#:public-key-authentication? #t] [#:initialize? #t]
  13425. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  13426. @var{host-key} must designate a file containing the host key, and readable
  13427. only by root.
  13428. When @var{daemonic?} is true, @command{lshd} will detach from the
  13429. controlling terminal and log its output to syslogd, unless one sets
  13430. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  13431. depend on existence of syslogd service. When @var{pid-file?} is true,
  13432. @command{lshd} writes its PID to the file called @var{pid-file}.
  13433. When @var{initialize?} is true, automatically create the seed and host key
  13434. upon service activation if they do not exist yet. This may take long and
  13435. require interaction.
  13436. When @var{initialize?} is false, it is up to the user to initialize the
  13437. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  13438. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  13439. basics,,, lsh, LSH Manual}).
  13440. When @var{interfaces} is empty, lshd listens for connections on all the
  13441. network interfaces; otherwise, @var{interfaces} must be a list of host names
  13442. or addresses.
  13443. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  13444. passwords, and @var{root-login?} specifies whether to accept log-ins as
  13445. root.
  13446. The other options should be self-descriptive.
  13447. @end deffn
  13448. @cindex SSH
  13449. @cindex SSH server
  13450. @deffn {Scheme Variable} openssh-service-type
  13451. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  13452. shell daemon, @command{sshd}. Its value must be an
  13453. @code{openssh-configuration} record as in this example:
  13454. @lisp
  13455. (service openssh-service-type
  13456. (openssh-configuration
  13457. (x11-forwarding? #t)
  13458. (permit-root-login 'without-password)
  13459. (authorized-keys
  13460. `(("alice" ,(local-file "alice.pub"))
  13461. ("bob" ,(local-file "bob.pub"))))))
  13462. @end lisp
  13463. See below for details about @code{openssh-configuration}.
  13464. This service can be extended with extra authorized keys, as in this
  13465. example:
  13466. @lisp
  13467. (service-extension openssh-service-type
  13468. (const `(("charlie"
  13469. ,(local-file "charlie.pub")))))
  13470. @end lisp
  13471. @end deffn
  13472. @deftp {Data Type} openssh-configuration
  13473. This is the configuration record for OpenSSH's @command{sshd}.
  13474. @table @asis
  13475. @item @code{openssh} (default @var{openssh})
  13476. The Openssh package to use.
  13477. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  13478. Name of the file where @command{sshd} writes its PID.
  13479. @item @code{port-number} (default: @code{22})
  13480. TCP port on which @command{sshd} listens for incoming connections.
  13481. @item @code{permit-root-login} (default: @code{#f})
  13482. This field determines whether and when to allow logins as root. If
  13483. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  13484. If it's the symbol @code{'without-password}, then root logins are
  13485. permitted but not with password-based authentication.
  13486. @item @code{allow-empty-passwords?} (default: @code{#f})
  13487. When true, users with empty passwords may log in. When false, they may
  13488. not.
  13489. @item @code{password-authentication?} (default: @code{#t})
  13490. When true, users may log in with their password. When false, they have
  13491. other authentication methods.
  13492. @item @code{public-key-authentication?} (default: @code{#t})
  13493. When true, users may log in using public key authentication. When
  13494. false, users have to use other authentication method.
  13495. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  13496. This is used only by protocol version 2.
  13497. @item @code{x11-forwarding?} (default: @code{#f})
  13498. When true, forwarding of X11 graphical client connections is
  13499. enabled---in other words, @command{ssh} options @option{-X} and
  13500. @option{-Y} will work.
  13501. @item @code{allow-agent-forwarding?} (default: @code{#t})
  13502. Whether to allow agent forwarding.
  13503. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  13504. Whether to allow TCP forwarding.
  13505. @item @code{gateway-ports?} (default: @code{#f})
  13506. Whether to allow gateway ports.
  13507. @item @code{challenge-response-authentication?} (default: @code{#f})
  13508. Specifies whether challenge response authentication is allowed (e.g.@: via
  13509. PAM).
  13510. @item @code{use-pam?} (default: @code{#t})
  13511. Enables the Pluggable Authentication Module interface. If set to
  13512. @code{#t}, this will enable PAM authentication using
  13513. @code{challenge-response-authentication?} and
  13514. @code{password-authentication?}, in addition to PAM account and session
  13515. module processing for all authentication types.
  13516. Because PAM challenge response authentication usually serves an
  13517. equivalent role to password authentication, you should disable either
  13518. @code{challenge-response-authentication?} or
  13519. @code{password-authentication?}.
  13520. @item @code{print-last-log?} (default: @code{#t})
  13521. Specifies whether @command{sshd} should print the date and time of the
  13522. last user login when a user logs in interactively.
  13523. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  13524. Configures external subsystems (e.g.@: file transfer daemon).
  13525. This is a list of two-element lists, each of which containing the
  13526. subsystem name and a command (with optional arguments) to execute upon
  13527. subsystem request.
  13528. The command @command{internal-sftp} implements an in-process SFTP
  13529. server. Alternatively, one can specify the @command{sftp-server} command:
  13530. @lisp
  13531. (service openssh-service-type
  13532. (openssh-configuration
  13533. (subsystems
  13534. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  13535. @end lisp
  13536. @item @code{accepted-environment} (default: @code{'()})
  13537. List of strings describing which environment variables may be exported.
  13538. Each string gets on its own line. See the @code{AcceptEnv} option in
  13539. @code{man sshd_config}.
  13540. This example allows ssh-clients to export the @env{COLORTERM} variable.
  13541. It is set by terminal emulators, which support colors. You can use it in
  13542. your shell's resource file to enable colors for the prompt and commands
  13543. if this variable is set.
  13544. @lisp
  13545. (service openssh-service-type
  13546. (openssh-configuration
  13547. (accepted-environment '("COLORTERM"))))
  13548. @end lisp
  13549. @item @code{authorized-keys} (default: @code{'()})
  13550. @cindex authorized keys, SSH
  13551. @cindex SSH authorized keys
  13552. This is the list of authorized keys. Each element of the list is a user
  13553. name followed by one or more file-like objects that represent SSH public
  13554. keys. For example:
  13555. @lisp
  13556. (openssh-configuration
  13557. (authorized-keys
  13558. `(("rekado" ,(local-file "rekado.pub"))
  13559. ("chris" ,(local-file "chris.pub"))
  13560. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  13561. @end lisp
  13562. @noindent
  13563. registers the specified public keys for user accounts @code{rekado},
  13564. @code{chris}, and @code{root}.
  13565. Additional authorized keys can be specified @i{via}
  13566. @code{service-extension}.
  13567. Note that this does @emph{not} interfere with the use of
  13568. @file{~/.ssh/authorized_keys}.
  13569. @item @code{log-level} (default: @code{'info})
  13570. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  13571. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  13572. page for @file{sshd_config} for the full list of level names.
  13573. @item @code{extra-content} (default: @code{""})
  13574. This field can be used to append arbitrary text to the configuration file. It
  13575. is especially useful for elaborate configurations that cannot be expressed
  13576. otherwise. This configuration, for example, would generally disable root
  13577. logins, but permit them from one specific IP address:
  13578. @lisp
  13579. (openssh-configuration
  13580. (extra-content "\
  13581. Match Address 192.168.0.1
  13582. PermitRootLogin yes"))
  13583. @end lisp
  13584. @end table
  13585. @end deftp
  13586. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  13587. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  13588. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  13589. object.
  13590. For example, to specify a Dropbear service listening on port 1234, add
  13591. this call to the operating system's @code{services} field:
  13592. @lisp
  13593. (dropbear-service (dropbear-configuration
  13594. (port-number 1234)))
  13595. @end lisp
  13596. @end deffn
  13597. @deftp {Data Type} dropbear-configuration
  13598. This data type represents the configuration of a Dropbear SSH daemon.
  13599. @table @asis
  13600. @item @code{dropbear} (default: @var{dropbear})
  13601. The Dropbear package to use.
  13602. @item @code{port-number} (default: 22)
  13603. The TCP port where the daemon waits for incoming connections.
  13604. @item @code{syslog-output?} (default: @code{#t})
  13605. Whether to enable syslog output.
  13606. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  13607. File name of the daemon's PID file.
  13608. @item @code{root-login?} (default: @code{#f})
  13609. Whether to allow @code{root} logins.
  13610. @item @code{allow-empty-passwords?} (default: @code{#f})
  13611. Whether to allow empty passwords.
  13612. @item @code{password-authentication?} (default: @code{#t})
  13613. Whether to enable password-based authentication.
  13614. @end table
  13615. @end deftp
  13616. @cindex AutoSSH
  13617. @deffn {Scheme Variable} autossh-service-type
  13618. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  13619. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  13620. restarting it as necessary should it die or stop passing traffic.
  13621. AutoSSH can be run manually from the command-line by passing arguments
  13622. to the binary @command{autossh} from the package @code{autossh}, but it
  13623. can also be run as a Guix service. This latter use case is documented
  13624. here.
  13625. AutoSSH can be used to forward local traffic to a remote machine using
  13626. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  13627. is run as.
  13628. For example, to specify a service running autossh as the user
  13629. @code{pino} and forwarding all local connections to port @code{8081} to
  13630. @code{remote:8081} using an SSH tunnel, add this call to the operating
  13631. system's @code{services} field:
  13632. @lisp
  13633. (service autossh-service-type
  13634. (autossh-configuration
  13635. (user "pino")
  13636. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  13637. @end lisp
  13638. @end deffn
  13639. @deftp {Data Type} autossh-configuration
  13640. This data type represents the configuration of an AutoSSH service.
  13641. @table @asis
  13642. @item @code{user} (default @code{"autossh"})
  13643. The user as which the AutoSSH service is to be run.
  13644. This assumes that the specified user exists.
  13645. @item @code{poll} (default @code{600})
  13646. Specifies the connection poll time in seconds.
  13647. @item @code{first-poll} (default @code{#f})
  13648. Specifies how many seconds AutoSSH waits before the first connection
  13649. test. After this first test, polling is resumed at the pace defined in
  13650. @code{poll}. When set to @code{#f}, the first poll is not treated
  13651. specially and will also use the connection poll specified in
  13652. @code{poll}.
  13653. @item @code{gate-time} (default @code{30})
  13654. Specifies how many seconds an SSH connection must be active before it is
  13655. considered successful.
  13656. @item @code{log-level} (default @code{1})
  13657. The log level, corresponding to the levels used by syslog---so @code{0}
  13658. is the most silent while @code{7} is the chattiest.
  13659. @item @code{max-start} (default @code{#f})
  13660. The maximum number of times SSH may be (re)started before AutoSSH exits.
  13661. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  13662. @item @code{message} (default @code{""})
  13663. The message to append to the echo message sent when testing connections.
  13664. @item @code{port} (default @code{"0"})
  13665. The ports used for monitoring the connection. When set to @code{"0"},
  13666. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  13667. a positive integer, ports @var{n} and @var{n}+1 are used for
  13668. monitoring the connection, such that port @var{n} is the base
  13669. monitoring port and @code{n+1} is the echo port. When set to
  13670. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  13671. integers, the ports @var{n} and @var{m} are used for monitoring the
  13672. connection, such that port @var{n} is the base monitoring port and
  13673. @var{m} is the echo port.
  13674. @item @code{ssh-options} (default @code{'()})
  13675. The list of command-line arguments to pass to @command{ssh} when it is
  13676. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  13677. may cause undefined behaviour.
  13678. @end table
  13679. @end deftp
  13680. @cindex WebSSH
  13681. @deffn {Scheme Variable} webssh-service-type
  13682. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  13683. program that runs a web SSH client. WebSSH can be run manually from the
  13684. command-line by passing arguments to the binary @command{wssh} from the
  13685. package @code{webssh}, but it can also be run as a Guix service. This
  13686. latter use case is documented here.
  13687. For example, to specify a service running WebSSH on loopback interface
  13688. on port @code{8888} with reject policy with a list of allowed to
  13689. connection hosts, and NGINX as a reverse-proxy to this service listening
  13690. for HTTPS connection, add this call to the operating system's
  13691. @code{services} field:
  13692. @lisp
  13693. (service webssh-service-type
  13694. (webssh-configuration (address "127.0.0.1")
  13695. (port 8888)
  13696. (policy 'reject)
  13697. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  13698. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  13699. (service nginx-service-type
  13700. (nginx-configuration
  13701. (server-blocks
  13702. (list
  13703. (nginx-server-configuration
  13704. (inherit %webssh-configuration-nginx)
  13705. (server-name '("webssh.example.com"))
  13706. (listen '("443 ssl"))
  13707. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  13708. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  13709. (locations
  13710. (cons (nginx-location-configuration
  13711. (uri "/.well-known")
  13712. (body '("root /var/www;")))
  13713. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  13714. @end lisp
  13715. @end deffn
  13716. @deftp {Data Type} webssh-configuration
  13717. Data type representing the configuration for @code{webssh-service}.
  13718. @table @asis
  13719. @item @code{package} (default: @var{webssh})
  13720. @code{webssh} package to use.
  13721. @item @code{user-name} (default: @var{"webssh"})
  13722. User name or user ID that file transfers to and from that module should take
  13723. place.
  13724. @item @code{group-name} (default: @var{"webssh"})
  13725. Group name or group ID that will be used when accessing the module.
  13726. @item @code{address} (default: @var{#f})
  13727. IP address on which @command{webssh} listens for incoming connections.
  13728. @item @code{port} (default: @var{8888})
  13729. TCP port on which @command{webssh} listens for incoming connections.
  13730. @item @code{policy} (default: @var{#f})
  13731. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  13732. @item @code{known-hosts} (default: @var{'()})
  13733. List of hosts which allowed for SSH connection from @command{webssh}.
  13734. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  13735. Name of the file where @command{webssh} writes its log file.
  13736. @item @code{log-level} (default: @var{#f})
  13737. Logging level.
  13738. @end table
  13739. @end deftp
  13740. @defvr {Scheme Variable} %facebook-host-aliases
  13741. This variable contains a string for use in @file{/etc/hosts}
  13742. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  13743. line contains a entry that maps a known server name of the Facebook
  13744. on-line service---e.g., @code{www.facebook.com}---to the local
  13745. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  13746. This variable is typically used in the @code{hosts-file} field of an
  13747. @code{operating-system} declaration (@pxref{operating-system Reference,
  13748. @file{/etc/hosts}}):
  13749. @lisp
  13750. (use-modules (gnu) (guix))
  13751. (operating-system
  13752. (host-name "mymachine")
  13753. ;; ...
  13754. (hosts-file
  13755. ;; Create a /etc/hosts file with aliases for "localhost"
  13756. ;; and "mymachine", as well as for Facebook servers.
  13757. (plain-file "hosts"
  13758. (string-append (local-host-aliases host-name)
  13759. %facebook-host-aliases))))
  13760. @end lisp
  13761. This mechanism can prevent programs running locally, such as Web
  13762. browsers, from accessing Facebook.
  13763. @end defvr
  13764. The @code{(gnu services avahi)} provides the following definition.
  13765. @defvr {Scheme Variable} avahi-service-type
  13766. This is the service that runs @command{avahi-daemon}, a system-wide
  13767. mDNS/DNS-SD responder that allows for service discovery and
  13768. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  13769. Its value must be an @code{avahi-configuration} record---see below.
  13770. This service extends the name service cache daemon (nscd) so that it can
  13771. resolve @code{.local} host names using
  13772. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  13773. Service Switch}, for information on host name resolution.
  13774. Additionally, add the @var{avahi} package to the system profile so that
  13775. commands such as @command{avahi-browse} are directly usable.
  13776. @end defvr
  13777. @deftp {Data Type} avahi-configuration
  13778. Data type representation the configuration for Avahi.
  13779. @table @asis
  13780. @item @code{host-name} (default: @code{#f})
  13781. If different from @code{#f}, use that as the host name to
  13782. publish for this machine; otherwise, use the machine's actual host name.
  13783. @item @code{publish?} (default: @code{#t})
  13784. When true, allow host names and services to be published (broadcast) over the
  13785. network.
  13786. @item @code{publish-workstation?} (default: @code{#t})
  13787. When true, @command{avahi-daemon} publishes the machine's host name and IP
  13788. address via mDNS on the local network. To view the host names published on
  13789. your local network, you can run:
  13790. @example
  13791. avahi-browse _workstation._tcp
  13792. @end example
  13793. @item @code{wide-area?} (default: @code{#f})
  13794. When true, DNS-SD over unicast DNS is enabled.
  13795. @item @code{ipv4?} (default: @code{#t})
  13796. @itemx @code{ipv6?} (default: @code{#t})
  13797. These fields determine whether to use IPv4/IPv6 sockets.
  13798. @item @code{domains-to-browse} (default: @code{'()})
  13799. This is a list of domains to browse.
  13800. @end table
  13801. @end deftp
  13802. @deffn {Scheme Variable} openvswitch-service-type
  13803. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  13804. service, whose value should be an @code{openvswitch-configuration}
  13805. object.
  13806. @end deffn
  13807. @deftp {Data Type} openvswitch-configuration
  13808. Data type representing the configuration of Open vSwitch, a multilayer
  13809. virtual switch which is designed to enable massive network automation
  13810. through programmatic extension.
  13811. @table @asis
  13812. @item @code{package} (default: @var{openvswitch})
  13813. Package object of the Open vSwitch.
  13814. @end table
  13815. @end deftp
  13816. @defvr {Scheme Variable} pagekite-service-type
  13817. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  13818. a tunneling solution for making localhost servers publicly visible, even from
  13819. behind restrictive firewalls or NAT without forwarded ports. The value for
  13820. this service type is a @code{pagekite-configuration} record.
  13821. Here's an example exposing the local HTTP and SSH daemons:
  13822. @lisp
  13823. (service pagekite-service-type
  13824. (pagekite-configuration
  13825. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  13826. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  13827. (extra-file "/etc/pagekite.rc")))
  13828. @end lisp
  13829. @end defvr
  13830. @deftp {Data Type} pagekite-configuration
  13831. Data type representing the configuration of PageKite.
  13832. @table @asis
  13833. @item @code{package} (default: @var{pagekite})
  13834. Package object of PageKite.
  13835. @item @code{kitename} (default: @code{#f})
  13836. PageKite name for authenticating to the frontend server.
  13837. @item @code{kitesecret} (default: @code{#f})
  13838. Shared secret for authenticating to the frontend server. You should probably
  13839. put this inside @code{extra-file} instead.
  13840. @item @code{frontend} (default: @code{#f})
  13841. Connect to the named PageKite frontend server instead of the
  13842. @uref{https://pagekite.net,,pagekite.net} service.
  13843. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  13844. List of service kites to use. Exposes HTTP on port 80 by default. The format
  13845. is @code{proto:kitename:host:port:secret}.
  13846. @item @code{extra-file} (default: @code{#f})
  13847. Extra configuration file to read, which you are expected to create manually.
  13848. Use this to add additional options and manage shared secrets out-of-band.
  13849. @end table
  13850. @end deftp
  13851. @defvr {Scheme Variable} yggdrasil-service-type
  13852. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  13853. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  13854. encrypted IPv6 network.
  13855. @quotation
  13856. Yggdrasil provides name-independent routing with cryptographically generated
  13857. addresses. Static addressing means you can keep the same address as long as
  13858. you want, even if you move to a new location, or generate a new address (by
  13859. generating new keys) whenever you want.
  13860. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  13861. @end quotation
  13862. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  13863. peers and/or local peers.
  13864. Here is an example using public peers and a static address. The static
  13865. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  13866. (the default value for @code{config-file}).
  13867. @lisp
  13868. ;; part of the operating-system declaration
  13869. (service yggdrasil-service-type
  13870. (yggdrasil-configuration
  13871. (autoconf? #f) ;; use only the public peers
  13872. (json-config
  13873. ;; choose one from
  13874. ;; https://github.com/yggdrasil-network/public-peers
  13875. '((peers . #("tcp://1.2.3.4:1337"))))
  13876. ;; /etc/yggdrasil-private.conf is the default value for config-file
  13877. ))
  13878. @end lisp
  13879. @example
  13880. # sample content for /etc/yggdrasil-private.conf
  13881. @{
  13882. # Your public encryption key. Your peers may ask you for this to put
  13883. # into their AllowedEncryptionPublicKeys configuration.
  13884. EncryptionPublicKey: 378dc5...
  13885. # Your private encryption key. DO NOT share this with anyone!
  13886. EncryptionPrivateKey: 0777...
  13887. # Your public signing key. You should not ordinarily need to share
  13888. # this with anyone.
  13889. SigningPublicKey: e1664...
  13890. # Your private signing key. DO NOT share this with anyone!
  13891. SigningPrivateKey: 0589d...
  13892. @}
  13893. @end example
  13894. @end defvr
  13895. @deftp {Data Type} yggdrasil-configuration
  13896. Data type representing the configuration of Yggdrasil.
  13897. @table @asis
  13898. @item @code{package} (default: @code{yggdrasil})
  13899. Package object of Yggdrasil.
  13900. @item @code{json-config} (default: @code{'()})
  13901. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  13902. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  13903. the Guix store, which is readable to all users. @strong{Do not store your
  13904. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  13905. quick overview of valid keys and their default values.
  13906. @item @code{autoconf?} (default: @code{#f})
  13907. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  13908. and peer with IPv6 neighbors.
  13909. @item @code{log-level} (default: @code{'info})
  13910. How much detail to include in logs. Use @code{'debug} for more detail.
  13911. @item @code{log-to} (default: @code{'stdout})
  13912. Where to send logs. By default, the service logs standard output to
  13913. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  13914. sends output to the running syslog service.
  13915. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  13916. What HJSON file to load sensitive data from. This is where private keys
  13917. should be stored, which are necessary to specify if you don't want a
  13918. randomized address after each restart. Use @code{#f} to disable. Options
  13919. defined in this file take precedence over @code{json-config}. Use the output
  13920. of @code{yggdrasil -genconf} as a starting point. To configure a static
  13921. address, delete everything except these options:
  13922. @itemize
  13923. @item @code{EncryptionPublicKey}
  13924. @item @code{EncryptionPrivateKey}
  13925. @item @code{SigningPublicKey}
  13926. @item @code{SigningPrivateKey}
  13927. @end itemize
  13928. @end table
  13929. @end deftp
  13930. @cindex keepalived
  13931. @deffn {Scheme Variable} keepalived-service-type
  13932. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  13933. routing software, @command{keepalived}. Its value must be an
  13934. @code{keepalived-configuration} record as in this example for master
  13935. machine:
  13936. @lisp
  13937. (service keepalived-service-type
  13938. (keepalived-configuration
  13939. (config-file (local-file "keepalived-master.conf"))))
  13940. @end lisp
  13941. where @file{keepalived-master.conf}:
  13942. @example
  13943. vrrp_instance my-group @{
  13944. state MASTER
  13945. interface enp9s0
  13946. virtual_router_id 100
  13947. priority 100
  13948. unicast_peer @{ 10.0.0.2 @}
  13949. virtual_ipaddress @{
  13950. 10.0.0.4/24
  13951. @}
  13952. @}
  13953. @end example
  13954. and for backup machine:
  13955. @lisp
  13956. (service keepalived-service-type
  13957. (keepalived-configuration
  13958. (config-file (local-file "keepalived-backup.conf"))))
  13959. @end lisp
  13960. where @file{keepalived-backup.conf}:
  13961. @example
  13962. vrrp_instance my-group @{
  13963. state BACKUP
  13964. interface enp9s0
  13965. virtual_router_id 100
  13966. priority 99
  13967. unicast_peer @{ 10.0.0.3 @}
  13968. virtual_ipaddress @{
  13969. 10.0.0.4/24
  13970. @}
  13971. @}
  13972. @end example
  13973. @end deffn
  13974. @node Unattended Upgrades
  13975. @subsection Unattended Upgrades
  13976. @cindex unattended upgrades
  13977. @cindex upgrades, unattended
  13978. Guix provides a service to perform @emph{unattended upgrades}:
  13979. periodically, the system automatically reconfigures itself from the
  13980. latest Guix. Guix System has several properties that make unattended
  13981. upgrades safe:
  13982. @itemize
  13983. @item
  13984. upgrades are transactional (either the upgrade succeeds or it fails, but
  13985. you cannot end up with an ``in-between'' system state);
  13986. @item
  13987. the upgrade log is kept---you can view it with @command{guix system
  13988. list-generations}---and you can roll back to any previous generation,
  13989. should the upgraded system fail to behave as intended;
  13990. @item
  13991. channel code is authenticated so you know you can only run genuine code
  13992. (@pxref{Channels});
  13993. @item
  13994. @command{guix system reconfigure} prevents downgrades, which makes it
  13995. immune to @dfn{downgrade attacks}.
  13996. @end itemize
  13997. To set up unattended upgrades, add an instance of
  13998. @code{unattended-upgrade-service-type} like the one below to the list of
  13999. your operating system services:
  14000. @lisp
  14001. (service unattended-upgrade-service-type)
  14002. @end lisp
  14003. The defaults above set up weekly upgrades: every Sunday at midnight.
  14004. You do not need to provide the operating system configuration file: it
  14005. uses @file{/run/current-system/configuration.scm}, which ensures it
  14006. always uses your latest configuration---@pxref{provenance-service-type},
  14007. for more information about this file.
  14008. There are several things that can be configured, in particular the
  14009. periodicity and services (daemons) to be restarted upon completion.
  14010. When the upgrade is successful, the service takes care of deleting
  14011. system generations older that some threshold, as per @command{guix
  14012. system delete-generations}. See the reference below for details.
  14013. To ensure that upgrades are actually happening, you can run
  14014. @command{guix system describe}. To investigate upgrade failures, visit
  14015. the unattended upgrade log file (see below).
  14016. @defvr {Scheme Variable} unattended-upgrade-service-type
  14017. This is the service type for unattended upgrades. It sets up an mcron
  14018. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  14019. reconfigure} from the latest version of the specified channels.
  14020. Its value must be a @code{unattended-upgrade-configuration} record (see
  14021. below).
  14022. @end defvr
  14023. @deftp {Data Type} unattended-upgrade-configuration
  14024. This data type represents the configuration of the unattended upgrade
  14025. service. The following fields are available:
  14026. @table @asis
  14027. @item @code{schedule} (default: @code{"30 01 * * 0"})
  14028. This is the schedule of upgrades, expressed as a gexp containing an
  14029. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  14030. mcron, GNU@tie{}mcron}).
  14031. @item @code{channels} (default: @code{#~%default-channels})
  14032. This gexp specifies the channels to use for the upgrade
  14033. (@pxref{Channels}). By default, the tip of the official @code{guix}
  14034. channel is used.
  14035. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  14036. This field specifies the operating system configuration file to use.
  14037. The default is to reuse the config file of the current configuration.
  14038. There are cases, though, where referring to
  14039. @file{/run/current-system/configuration.scm} is not enough, for instance
  14040. because that file refers to extra files (SSH public keys, extra
  14041. configuration files, etc.) @i{via} @code{local-file} and similar
  14042. constructs. For those cases, we recommend something along these lines:
  14043. @lisp
  14044. (unattended-upgrade-configuration
  14045. (operating-system-file
  14046. (file-append (local-file "." "config-dir" #:recursive? #t)
  14047. "/config.scm")))
  14048. @end lisp
  14049. The effect here is to import all of the current directory into the
  14050. store, and to refer to @file{config.scm} within that directory.
  14051. Therefore, uses of @code{local-file} within @file{config.scm} will work
  14052. as expected. @xref{G-Expressions}, for information about
  14053. @code{local-file} and @code{file-append}.
  14054. @item @code{services-to-restart} (default: @code{'(mcron)})
  14055. This field specifies the Shepherd services to restart when the upgrade
  14056. completes.
  14057. Those services are restarted right away upon completion, as with
  14058. @command{herd restart}, which ensures that the latest version is
  14059. running---remember that by default @command{guix system reconfigure}
  14060. only restarts services that are not currently running, which is
  14061. conservative: it minimizes disruption but leaves outdated services
  14062. running.
  14063. Use @command{herd status} to find out candidates for restarting.
  14064. @xref{Services}, for general information about services. Common
  14065. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  14066. By default, the @code{mcron} service is restarted. This ensures that
  14067. the latest version of the unattended upgrade job will be used next time.
  14068. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  14069. This is the expiration time in seconds for system generations. System
  14070. generations older that this amount of time are deleted with
  14071. @command{guix system delete-generations} when an upgrade completes.
  14072. @quotation Note
  14073. The unattended upgrade service does not run the garbage collector. You
  14074. will probably want to set up your own mcron job to run @command{guix gc}
  14075. periodically.
  14076. @end quotation
  14077. @item @code{maximum-duration} (default: @code{3600})
  14078. Maximum duration in seconds for the upgrade; past that time, the upgrade
  14079. aborts.
  14080. This is primarily useful to ensure the upgrade does not end up
  14081. rebuilding or re-downloading ``the world''.
  14082. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  14083. File where unattended upgrades are logged.
  14084. @end table
  14085. @end deftp
  14086. @node X Window
  14087. @subsection X Window
  14088. @cindex X11
  14089. @cindex X Window System
  14090. @cindex login manager
  14091. Support for the X Window graphical display system---specifically
  14092. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  14093. there is no @code{xorg-service} procedure. Instead, the X server is
  14094. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  14095. @cindex GDM
  14096. @cindex GNOME, login manager
  14097. GDM of course allows users to log in into window managers and desktop
  14098. environments other than GNOME; for those using GNOME, GDM is required for
  14099. features such as automatic screen locking.
  14100. @cindex window manager
  14101. To use X11, you must install at least one @dfn{window manager}---for
  14102. example the @code{windowmaker} or @code{openbox} packages---preferably
  14103. by adding it to the @code{packages} field of your operating system
  14104. definition (@pxref{operating-system Reference, system-wide packages}).
  14105. @defvr {Scheme Variable} gdm-service-type
  14106. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  14107. Desktop Manager} (GDM), a program that manages graphical display servers and
  14108. handles graphical user logins. Its value must be a @code{gdm-configuration}
  14109. (see below).
  14110. @cindex session types (X11)
  14111. @cindex X11 session types
  14112. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  14113. @file{/run/current-system/profile/share/xsessions} and allows users to choose
  14114. a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
  14115. and @code{i3} provide @file{.desktop} files; adding them to the system-wide
  14116. set of packages automatically makes them available at the log-in screen.
  14117. In addition, @file{~/.xsession} files are honored. When available,
  14118. @file{~/.xsession} must be an executable that starts a window manager
  14119. and/or other X clients.
  14120. @end defvr
  14121. @deftp {Data Type} gdm-configuration
  14122. @table @asis
  14123. @item @code{auto-login?} (default: @code{#f})
  14124. @itemx @code{default-user} (default: @code{#f})
  14125. When @code{auto-login?} is false, GDM presents a log-in screen.
  14126. When @code{auto-login?} is true, GDM logs in directly as
  14127. @code{default-user}.
  14128. @item @code{debug?} (default: @code{#f})
  14129. When true, GDM writes debug messages to its log.
  14130. @item @code{gnome-shell-assets} (default: ...)
  14131. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  14132. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  14133. Configuration of the Xorg graphical server.
  14134. @item @code{xsession} (default: @code{(xinitrc)})
  14135. Script to run before starting a X session.
  14136. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  14137. File name of the @code{dbus-daemon} executable.
  14138. @item @code{gdm} (default: @code{gdm})
  14139. The GDM package to use.
  14140. @end table
  14141. @end deftp
  14142. @defvr {Scheme Variable} slim-service-type
  14143. This is the type for the SLiM graphical login manager for X11.
  14144. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  14145. allows users to choose a session from the log-in screen using @kbd{F1}. It
  14146. also honors @file{~/.xsession} files.
  14147. Unlike GDM, SLiM does not spawn the user session on a different VT after
  14148. logging in, which means that you can only start one graphical session. If you
  14149. want to be able to run multiple graphical sessions at the same time you have
  14150. to add multiple SLiM services to your system services. The following example
  14151. shows how to replace the default GDM service with two SLiM services on tty7
  14152. and tty8.
  14153. @lisp
  14154. (use-modules (gnu services)
  14155. (gnu services desktop)
  14156. (gnu services xorg)
  14157. (srfi srfi-1)) ;for 'remove'
  14158. (operating-system
  14159. ;; ...
  14160. (services (cons* (service slim-service-type (slim-configuration
  14161. (display ":0")
  14162. (vt "vt7")))
  14163. (service slim-service-type (slim-configuration
  14164. (display ":1")
  14165. (vt "vt8")))
  14166. (remove (lambda (service)
  14167. (eq? (service-kind service) gdm-service-type))
  14168. %desktop-services))))
  14169. @end lisp
  14170. @end defvr
  14171. @deftp {Data Type} slim-configuration
  14172. Data type representing the configuration of @code{slim-service-type}.
  14173. @table @asis
  14174. @item @code{allow-empty-passwords?} (default: @code{#t})
  14175. Whether to allow logins with empty passwords.
  14176. @item @code{auto-login?} (default: @code{#f})
  14177. @itemx @code{default-user} (default: @code{""})
  14178. When @code{auto-login?} is false, SLiM presents a log-in screen.
  14179. When @code{auto-login?} is true, SLiM logs in directly as
  14180. @code{default-user}.
  14181. @item @code{theme} (default: @code{%default-slim-theme})
  14182. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  14183. The graphical theme to use and its name.
  14184. @item @code{auto-login-session} (default: @code{#f})
  14185. If true, this must be the name of the executable to start as the default
  14186. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  14187. If false, a session described by one of the available @file{.desktop}
  14188. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  14189. will be used.
  14190. @quotation Note
  14191. You must install at least one window manager in the system profile or in
  14192. your user profile. Failing to do that, if @code{auto-login-session} is
  14193. false, you will be unable to log in.
  14194. @end quotation
  14195. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14196. Configuration of the Xorg graphical server.
  14197. @item @code{display} (default @code{":0"})
  14198. The display on which to start the Xorg graphical server.
  14199. @item @code{vt} (default @code{"vt7"})
  14200. The VT on which to start the Xorg graphical server.
  14201. @item @code{xauth} (default: @code{xauth})
  14202. The XAuth package to use.
  14203. @item @code{shepherd} (default: @code{shepherd})
  14204. The Shepherd package used when invoking @command{halt} and
  14205. @command{reboot}.
  14206. @item @code{sessreg} (default: @code{sessreg})
  14207. The sessreg package used in order to register the session.
  14208. @item @code{slim} (default: @code{slim})
  14209. The SLiM package to use.
  14210. @end table
  14211. @end deftp
  14212. @defvr {Scheme Variable} %default-theme
  14213. @defvrx {Scheme Variable} %default-theme-name
  14214. The default SLiM theme and its name.
  14215. @end defvr
  14216. @deftp {Data Type} sddm-configuration
  14217. This is the data type representing the SDDM service configuration.
  14218. @table @asis
  14219. @item @code{display-server} (default: "x11")
  14220. Select display server to use for the greeter. Valid values are
  14221. @samp{"x11"} or @samp{"wayland"}.
  14222. @item @code{numlock} (default: "on")
  14223. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  14224. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  14225. Command to run when halting.
  14226. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  14227. Command to run when rebooting.
  14228. @item @code{theme} (default "maldives")
  14229. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  14230. @samp{"maldives"} or @samp{"maya"}.
  14231. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  14232. Directory to look for themes.
  14233. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  14234. Directory to look for faces.
  14235. @item @code{default-path} (default "/run/current-system/profile/bin")
  14236. Default PATH to use.
  14237. @item @code{minimum-uid} (default: 1000)
  14238. Minimum UID displayed in SDDM and allowed for log-in.
  14239. @item @code{maximum-uid} (default: 2000)
  14240. Maximum UID to display in SDDM.
  14241. @item @code{remember-last-user?} (default #t)
  14242. Remember last user.
  14243. @item @code{remember-last-session?} (default #t)
  14244. Remember last session.
  14245. @item @code{hide-users} (default "")
  14246. Usernames to hide from SDDM greeter.
  14247. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  14248. Users with shells listed will be hidden from the SDDM greeter.
  14249. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  14250. Script to run before starting a wayland session.
  14251. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  14252. Directory to look for desktop files starting wayland sessions.
  14253. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14254. Configuration of the Xorg graphical server.
  14255. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  14256. Path to xauth.
  14257. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  14258. Path to Xephyr.
  14259. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  14260. Script to run after starting xorg-server.
  14261. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  14262. Script to run before stopping xorg-server.
  14263. @item @code{xsession-command} (default: @code{xinitrc})
  14264. Script to run before starting a X session.
  14265. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  14266. Directory to look for desktop files starting X sessions.
  14267. @item @code{minimum-vt} (default: 7)
  14268. Minimum VT to use.
  14269. @item @code{auto-login-user} (default "")
  14270. User to use for auto-login.
  14271. @item @code{auto-login-session} (default "")
  14272. Desktop file to use for auto-login.
  14273. @item @code{relogin?} (default #f)
  14274. Relogin after logout.
  14275. @end table
  14276. @end deftp
  14277. @cindex login manager
  14278. @cindex X11 login
  14279. @defvr {Scheme Variable} sddm-service-type
  14280. This is the type of the service to run the
  14281. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  14282. must be a @code{sddm-configuration} record (see below).
  14283. Here's an example use:
  14284. @lisp
  14285. (service sddm-service-type
  14286. (sddm-configuration
  14287. (auto-login-user "alice")
  14288. (auto-login-session "xfce.desktop")))
  14289. @end lisp
  14290. @end defvr
  14291. @deftp {Data Type} sddm-configuration
  14292. This data type represents the configuration of the SDDM login manager.
  14293. The available fields are:
  14294. @table @asis
  14295. @item @code{sddm} (default: @code{sddm})
  14296. The SDDM package to use.
  14297. @item @code{display-server} (default: @code{"x11"})
  14298. This must be either @code{"x11"} or @code{"wayland"}.
  14299. @c FIXME: Add more fields.
  14300. @item @code{auto-login-user} (default: @code{""})
  14301. If non-empty, this is the user account under which to log in
  14302. automatically.
  14303. @item @code{auto-login-session} (default: @code{""})
  14304. If non-empty, this is the @file{.desktop} file name to use as the
  14305. auto-login session.
  14306. @end table
  14307. @end deftp
  14308. @cindex Xorg, configuration
  14309. @deftp {Data Type} xorg-configuration
  14310. This data type represents the configuration of the Xorg graphical display
  14311. server. Note that there is no Xorg service; instead, the X server is started
  14312. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  14313. of these display managers aggregates an @code{xorg-configuration} record.
  14314. @table @asis
  14315. @item @code{modules} (default: @code{%default-xorg-modules})
  14316. This is a list of @dfn{module packages} loaded by the Xorg
  14317. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  14318. @item @code{fonts} (default: @code{%default-xorg-fonts})
  14319. This is a list of font directories to add to the server's @dfn{font path}.
  14320. @item @code{drivers} (default: @code{'()})
  14321. This must be either the empty list, in which case Xorg chooses a graphics
  14322. driver automatically, or a list of driver names that will be tried in this
  14323. order---e.g., @code{("modesetting" "vesa")}.
  14324. @item @code{resolutions} (default: @code{'()})
  14325. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  14326. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  14327. 768) (640 480))}.
  14328. @cindex keyboard layout, for Xorg
  14329. @cindex keymap, for Xorg
  14330. @item @code{keyboard-layout} (default: @code{#f})
  14331. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  14332. English (``qwerty'') for a 105-key PC keyboard.
  14333. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  14334. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  14335. information on how to specify the keyboard layout.
  14336. @item @code{extra-config} (default: @code{'()})
  14337. This is a list of strings or objects appended to the configuration file. It
  14338. is used to pass extra text to be added verbatim to the configuration file.
  14339. @item @code{server} (default: @code{xorg-server})
  14340. This is the package providing the Xorg server.
  14341. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  14342. This is the list of command-line arguments to pass to the X server. The
  14343. default is @code{-nolisten tcp}.
  14344. @end table
  14345. @end deftp
  14346. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  14347. [@var{login-manager-service-type}]
  14348. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  14349. @var{config}, an @code{<xorg-configuration>} record.
  14350. Since the Xorg configuration is embedded in the log-in manager's
  14351. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  14352. shorthand to set the Xorg configuration.
  14353. @end deffn
  14354. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  14355. Return a @code{startx} script in which the modules, fonts, etc. specified
  14356. in @var{config}, are available. The result should be used in place of
  14357. @code{startx}.
  14358. Usually the X server is started by a login manager.
  14359. @end deffn
  14360. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  14361. Add @var{package}, a package for a screen locker or screen saver whose
  14362. command is @var{program}, to the set of setuid programs and add a PAM entry
  14363. for it. For example:
  14364. @lisp
  14365. (screen-locker-service xlockmore "xlock")
  14366. @end lisp
  14367. makes the good ol' XlockMore usable.
  14368. @end deffn
  14369. @node Printing Services
  14370. @subsection Printing Services
  14371. @cindex printer support with CUPS
  14372. The @code{(gnu services cups)} module provides a Guix service definition
  14373. for the CUPS printing service. To add printer support to a Guix
  14374. system, add a @code{cups-service} to the operating system definition:
  14375. @deffn {Scheme Variable} cups-service-type
  14376. The service type for the CUPS print server. Its value should be a valid
  14377. CUPS configuration (see below). To use the default settings, simply
  14378. write:
  14379. @lisp
  14380. (service cups-service-type)
  14381. @end lisp
  14382. @end deffn
  14383. The CUPS configuration controls the basic things about your CUPS
  14384. installation: what interfaces it listens on, what to do if a print job
  14385. fails, how much logging to do, and so on. To actually add a printer,
  14386. you have to visit the @url{http://localhost:631} URL, or use a tool such
  14387. as GNOME's printer configuration services. By default, configuring a
  14388. CUPS service will generate a self-signed certificate if needed, for
  14389. secure connections to the print server.
  14390. Suppose you want to enable the Web interface of CUPS and also add
  14391. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  14392. package and for HP printers @i{via} the @code{hplip-minimal} package.
  14393. You can do that directly, like this (you need to use the
  14394. @code{(gnu packages cups)} module):
  14395. @lisp
  14396. (service cups-service-type
  14397. (cups-configuration
  14398. (web-interface? #t)
  14399. (extensions
  14400. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  14401. @end lisp
  14402. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  14403. package then it is suggested that you install the @code{hplip} package,
  14404. either in your OS configuration file or as your user.
  14405. The available configuration parameters follow. Each parameter
  14406. definition is preceded by its type; for example, @samp{string-list foo}
  14407. indicates that the @code{foo} parameter should be specified as a list of
  14408. strings. There is also a way to specify the configuration as a string,
  14409. if you have an old @code{cupsd.conf} file that you want to port over
  14410. from some other system; see the end for more details.
  14411. @c The following documentation was initially generated by
  14412. @c (generate-documentation) in (gnu services cups). Manually maintained
  14413. @c documentation is better, so we shouldn't hesitate to edit below as
  14414. @c needed. However if the change you want to make to this documentation
  14415. @c can be done in an automated way, it's probably easier to change
  14416. @c (generate-documentation) than to make it below and have to deal with
  14417. @c the churn as CUPS updates.
  14418. Available @code{cups-configuration} fields are:
  14419. @deftypevr {@code{cups-configuration} parameter} package cups
  14420. The CUPS package.
  14421. @end deftypevr
  14422. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  14423. Drivers and other extensions to the CUPS package.
  14424. @end deftypevr
  14425. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  14426. Configuration of where to write logs, what directories to use for print
  14427. spools, and related privileged configuration parameters.
  14428. Available @code{files-configuration} fields are:
  14429. @deftypevr {@code{files-configuration} parameter} log-location access-log
  14430. Defines the access log filename. Specifying a blank filename disables
  14431. access log generation. The value @code{stderr} causes log entries to be
  14432. sent to the standard error file when the scheduler is running in the
  14433. foreground, or to the system log daemon when run in the background. The
  14434. value @code{syslog} causes log entries to be sent to the system log
  14435. daemon. The server name may be included in filenames using the string
  14436. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  14437. Defaults to @samp{"/var/log/cups/access_log"}.
  14438. @end deftypevr
  14439. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  14440. Where CUPS should cache data.
  14441. Defaults to @samp{"/var/cache/cups"}.
  14442. @end deftypevr
  14443. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  14444. Specifies the permissions for all configuration files that the scheduler
  14445. writes.
  14446. Note that the permissions for the printers.conf file are currently
  14447. masked to only allow access from the scheduler user (typically root).
  14448. This is done because printer device URIs sometimes contain sensitive
  14449. authentication information that should not be generally known on the
  14450. system. There is no way to disable this security feature.
  14451. Defaults to @samp{"0640"}.
  14452. @end deftypevr
  14453. @deftypevr {@code{files-configuration} parameter} log-location error-log
  14454. Defines the error log filename. Specifying a blank filename disables
  14455. error log generation. The value @code{stderr} causes log entries to be
  14456. sent to the standard error file when the scheduler is running in the
  14457. foreground, or to the system log daemon when run in the background. The
  14458. value @code{syslog} causes log entries to be sent to the system log
  14459. daemon. The server name may be included in filenames using the string
  14460. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  14461. Defaults to @samp{"/var/log/cups/error_log"}.
  14462. @end deftypevr
  14463. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  14464. Specifies which errors are fatal, causing the scheduler to exit. The
  14465. kind strings are:
  14466. @table @code
  14467. @item none
  14468. No errors are fatal.
  14469. @item all
  14470. All of the errors below are fatal.
  14471. @item browse
  14472. Browsing initialization errors are fatal, for example failed connections
  14473. to the DNS-SD daemon.
  14474. @item config
  14475. Configuration file syntax errors are fatal.
  14476. @item listen
  14477. Listen or Port errors are fatal, except for IPv6 failures on the
  14478. loopback or @code{any} addresses.
  14479. @item log
  14480. Log file creation or write errors are fatal.
  14481. @item permissions
  14482. Bad startup file permissions are fatal, for example shared TLS
  14483. certificate and key files with world-read permissions.
  14484. @end table
  14485. Defaults to @samp{"all -browse"}.
  14486. @end deftypevr
  14487. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  14488. Specifies whether the file pseudo-device can be used for new printer
  14489. queues. The URI @uref{file:///dev/null} is always allowed.
  14490. Defaults to @samp{#f}.
  14491. @end deftypevr
  14492. @deftypevr {@code{files-configuration} parameter} string group
  14493. Specifies the group name or ID that will be used when executing external
  14494. programs.
  14495. Defaults to @samp{"lp"}.
  14496. @end deftypevr
  14497. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  14498. Specifies the permissions for all log files that the scheduler writes.
  14499. Defaults to @samp{"0644"}.
  14500. @end deftypevr
  14501. @deftypevr {@code{files-configuration} parameter} log-location page-log
  14502. Defines the page log filename. Specifying a blank filename disables
  14503. page log generation. The value @code{stderr} causes log entries to be
  14504. sent to the standard error file when the scheduler is running in the
  14505. foreground, or to the system log daemon when run in the background. The
  14506. value @code{syslog} causes log entries to be sent to the system log
  14507. daemon. The server name may be included in filenames using the string
  14508. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  14509. Defaults to @samp{"/var/log/cups/page_log"}.
  14510. @end deftypevr
  14511. @deftypevr {@code{files-configuration} parameter} string remote-root
  14512. Specifies the username that is associated with unauthenticated accesses
  14513. by clients claiming to be the root user. The default is @code{remroot}.
  14514. Defaults to @samp{"remroot"}.
  14515. @end deftypevr
  14516. @deftypevr {@code{files-configuration} parameter} file-name request-root
  14517. Specifies the directory that contains print jobs and other HTTP request
  14518. data.
  14519. Defaults to @samp{"/var/spool/cups"}.
  14520. @end deftypevr
  14521. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  14522. Specifies the level of security sandboxing that is applied to print
  14523. filters, backends, and other child processes of the scheduler; either
  14524. @code{relaxed} or @code{strict}. This directive is currently only
  14525. used/supported on macOS.
  14526. Defaults to @samp{strict}.
  14527. @end deftypevr
  14528. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  14529. Specifies the location of TLS certificates and private keys. CUPS will
  14530. look for public and private keys in this directory: @file{.crt} files
  14531. for PEM-encoded certificates and corresponding @file{.key} files for
  14532. PEM-encoded private keys.
  14533. Defaults to @samp{"/etc/cups/ssl"}.
  14534. @end deftypevr
  14535. @deftypevr {@code{files-configuration} parameter} file-name server-root
  14536. Specifies the directory containing the server configuration files.
  14537. Defaults to @samp{"/etc/cups"}.
  14538. @end deftypevr
  14539. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  14540. Specifies whether the scheduler calls fsync(2) after writing
  14541. configuration or state files.
  14542. Defaults to @samp{#f}.
  14543. @end deftypevr
  14544. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  14545. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  14546. @end deftypevr
  14547. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  14548. Specifies the directory where temporary files are stored.
  14549. Defaults to @samp{"/var/spool/cups/tmp"}.
  14550. @end deftypevr
  14551. @deftypevr {@code{files-configuration} parameter} string user
  14552. Specifies the user name or ID that is used when running external
  14553. programs.
  14554. Defaults to @samp{"lp"}.
  14555. @end deftypevr
  14556. @deftypevr {@code{files-configuration} parameter} string set-env
  14557. Set the specified environment variable to be passed to child processes.
  14558. Defaults to @samp{"variable value"}.
  14559. @end deftypevr
  14560. @end deftypevr
  14561. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  14562. Specifies the logging level for the AccessLog file. The @code{config}
  14563. level logs when printers and classes are added, deleted, or modified and
  14564. when configuration files are accessed or updated. The @code{actions}
  14565. level logs when print jobs are submitted, held, released, modified, or
  14566. canceled, and any of the conditions for @code{config}. The @code{all}
  14567. level logs all requests.
  14568. Defaults to @samp{actions}.
  14569. @end deftypevr
  14570. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  14571. Specifies whether to purge job history data automatically when it is no
  14572. longer required for quotas.
  14573. Defaults to @samp{#f}.
  14574. @end deftypevr
  14575. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  14576. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  14577. For example, @samp{"_cups" "_print"} will tell network clients that both
  14578. CUPS sharing and IPP Everywhere are supported.
  14579. Defaults to @samp{"_cups"}.
  14580. @end deftypevr
  14581. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  14582. Specifies which protocols to use for local printer sharing.
  14583. Defaults to @samp{dnssd}.
  14584. @end deftypevr
  14585. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  14586. Specifies whether the CUPS web interface is advertised.
  14587. Defaults to @samp{#f}.
  14588. @end deftypevr
  14589. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  14590. Specifies whether shared printers are advertised.
  14591. Defaults to @samp{#f}.
  14592. @end deftypevr
  14593. @deftypevr {@code{cups-configuration} parameter} string classification
  14594. Specifies the security classification of the server. Any valid banner
  14595. name can be used, including @samp{"classified"}, @samp{"confidential"},
  14596. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  14597. banner can be omitted to disable secure printing functions.
  14598. Defaults to @samp{""}.
  14599. @end deftypevr
  14600. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  14601. Specifies whether users may override the classification (cover page) of
  14602. individual print jobs using the @code{job-sheets} option.
  14603. Defaults to @samp{#f}.
  14604. @end deftypevr
  14605. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  14606. Specifies the default type of authentication to use.
  14607. Defaults to @samp{Basic}.
  14608. @end deftypevr
  14609. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  14610. Specifies whether encryption will be used for authenticated requests.
  14611. Defaults to @samp{Required}.
  14612. @end deftypevr
  14613. @deftypevr {@code{cups-configuration} parameter} string default-language
  14614. Specifies the default language to use for text and web content.
  14615. Defaults to @samp{"en"}.
  14616. @end deftypevr
  14617. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  14618. Specifies the default paper size for new print queues. @samp{"Auto"}
  14619. uses a locale-specific default, while @samp{"None"} specifies there is
  14620. no default paper size. Specific size names are typically
  14621. @samp{"Letter"} or @samp{"A4"}.
  14622. Defaults to @samp{"Auto"}.
  14623. @end deftypevr
  14624. @deftypevr {@code{cups-configuration} parameter} string default-policy
  14625. Specifies the default access policy to use.
  14626. Defaults to @samp{"default"}.
  14627. @end deftypevr
  14628. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  14629. Specifies whether local printers are shared by default.
  14630. Defaults to @samp{#t}.
  14631. @end deftypevr
  14632. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  14633. Specifies the delay for updating of configuration and state files, in
  14634. seconds. A value of 0 causes the update to happen as soon as possible,
  14635. typically within a few milliseconds.
  14636. Defaults to @samp{30}.
  14637. @end deftypevr
  14638. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  14639. Specifies what to do when an error occurs. Possible values are
  14640. @code{abort-job}, which will discard the failed print job;
  14641. @code{retry-job}, which will retry the job at a later time;
  14642. @code{retry-current-job}, which retries the failed job immediately; and
  14643. @code{stop-printer}, which stops the printer.
  14644. Defaults to @samp{stop-printer}.
  14645. @end deftypevr
  14646. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  14647. Specifies the maximum cost of filters that are run concurrently, which
  14648. can be used to minimize disk, memory, and CPU resource problems. A
  14649. limit of 0 disables filter limiting. An average print to a
  14650. non-PostScript printer needs a filter limit of about 200. A PostScript
  14651. printer needs about half that (100). Setting the limit below these
  14652. thresholds will effectively limit the scheduler to printing a single job
  14653. at any time.
  14654. Defaults to @samp{0}.
  14655. @end deftypevr
  14656. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  14657. Specifies the scheduling priority of filters that are run to print a
  14658. job. The nice value ranges from 0, the highest priority, to 19, the
  14659. lowest priority.
  14660. Defaults to @samp{0}.
  14661. @end deftypevr
  14662. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  14663. Specifies whether to do reverse lookups on connecting clients. The
  14664. @code{double} setting causes @code{cupsd} to verify that the hostname
  14665. resolved from the address matches one of the addresses returned for that
  14666. hostname. Double lookups also prevent clients with unregistered
  14667. addresses from connecting to your server. Only set this option to
  14668. @code{#t} or @code{double} if absolutely required.
  14669. Defaults to @samp{#f}.
  14670. @end deftypevr
  14671. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  14672. Specifies the number of seconds to wait before killing the filters and
  14673. backend associated with a canceled or held job.
  14674. Defaults to @samp{30}.
  14675. @end deftypevr
  14676. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  14677. Specifies the interval between retries of jobs in seconds. This is
  14678. typically used for fax queues but can also be used with normal print
  14679. queues whose error policy is @code{retry-job} or
  14680. @code{retry-current-job}.
  14681. Defaults to @samp{30}.
  14682. @end deftypevr
  14683. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  14684. Specifies the number of retries that are done for jobs. This is
  14685. typically used for fax queues but can also be used with normal print
  14686. queues whose error policy is @code{retry-job} or
  14687. @code{retry-current-job}.
  14688. Defaults to @samp{5}.
  14689. @end deftypevr
  14690. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  14691. Specifies whether to support HTTP keep-alive connections.
  14692. Defaults to @samp{#t}.
  14693. @end deftypevr
  14694. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  14695. Specifies how long an idle client connection remains open, in seconds.
  14696. Defaults to @samp{30}.
  14697. @end deftypevr
  14698. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  14699. Specifies the maximum size of print files, IPP requests, and HTML form
  14700. data. A limit of 0 disables the limit check.
  14701. Defaults to @samp{0}.
  14702. @end deftypevr
  14703. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  14704. Listens on the specified interfaces for connections. Valid values are
  14705. of the form @var{address}:@var{port}, where @var{address} is either an
  14706. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  14707. indicate all addresses. Values can also be file names of local UNIX
  14708. domain sockets. The Listen directive is similar to the Port directive
  14709. but allows you to restrict access to specific interfaces or networks.
  14710. @end deftypevr
  14711. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  14712. Specifies the number of pending connections that will be allowed. This
  14713. normally only affects very busy servers that have reached the MaxClients
  14714. limit, but can also be triggered by large numbers of simultaneous
  14715. connections. When the limit is reached, the operating system will
  14716. refuse additional connections until the scheduler can accept the pending
  14717. ones.
  14718. Defaults to @samp{128}.
  14719. @end deftypevr
  14720. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  14721. Specifies a set of additional access controls.
  14722. Available @code{location-access-controls} fields are:
  14723. @deftypevr {@code{location-access-controls} parameter} file-name path
  14724. Specifies the URI path to which the access control applies.
  14725. @end deftypevr
  14726. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  14727. Access controls for all access to this path, in the same format as the
  14728. @code{access-controls} of @code{operation-access-control}.
  14729. Defaults to @samp{()}.
  14730. @end deftypevr
  14731. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  14732. Access controls for method-specific access to this path.
  14733. Defaults to @samp{()}.
  14734. Available @code{method-access-controls} fields are:
  14735. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  14736. If @code{#t}, apply access controls to all methods except the listed
  14737. methods. Otherwise apply to only the listed methods.
  14738. Defaults to @samp{#f}.
  14739. @end deftypevr
  14740. @deftypevr {@code{method-access-controls} parameter} method-list methods
  14741. Methods to which this access control applies.
  14742. Defaults to @samp{()}.
  14743. @end deftypevr
  14744. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  14745. Access control directives, as a list of strings. Each string should be
  14746. one directive, such as @samp{"Order allow,deny"}.
  14747. Defaults to @samp{()}.
  14748. @end deftypevr
  14749. @end deftypevr
  14750. @end deftypevr
  14751. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  14752. Specifies the number of debugging messages that are retained for logging
  14753. if an error occurs in a print job. Debug messages are logged regardless
  14754. of the LogLevel setting.
  14755. Defaults to @samp{100}.
  14756. @end deftypevr
  14757. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  14758. Specifies the level of logging for the ErrorLog file. The value
  14759. @code{none} stops all logging while @code{debug2} logs everything.
  14760. Defaults to @samp{info}.
  14761. @end deftypevr
  14762. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  14763. Specifies the format of the date and time in the log files. The value
  14764. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  14765. Defaults to @samp{standard}.
  14766. @end deftypevr
  14767. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  14768. Specifies the maximum number of simultaneous clients that are allowed by
  14769. the scheduler.
  14770. Defaults to @samp{100}.
  14771. @end deftypevr
  14772. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  14773. Specifies the maximum number of simultaneous clients that are allowed
  14774. from a single address.
  14775. Defaults to @samp{100}.
  14776. @end deftypevr
  14777. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  14778. Specifies the maximum number of copies that a user can print of each
  14779. job.
  14780. Defaults to @samp{9999}.
  14781. @end deftypevr
  14782. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  14783. Specifies the maximum time a job may remain in the @code{indefinite}
  14784. hold state before it is canceled. A value of 0 disables cancellation of
  14785. held jobs.
  14786. Defaults to @samp{0}.
  14787. @end deftypevr
  14788. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  14789. Specifies the maximum number of simultaneous jobs that are allowed. Set
  14790. to 0 to allow an unlimited number of jobs.
  14791. Defaults to @samp{500}.
  14792. @end deftypevr
  14793. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  14794. Specifies the maximum number of simultaneous jobs that are allowed per
  14795. printer. A value of 0 allows up to MaxJobs jobs per printer.
  14796. Defaults to @samp{0}.
  14797. @end deftypevr
  14798. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  14799. Specifies the maximum number of simultaneous jobs that are allowed per
  14800. user. A value of 0 allows up to MaxJobs jobs per user.
  14801. Defaults to @samp{0}.
  14802. @end deftypevr
  14803. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  14804. Specifies the maximum time a job may take to print before it is
  14805. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  14806. Defaults to @samp{10800}.
  14807. @end deftypevr
  14808. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  14809. Specifies the maximum size of the log files before they are rotated, in
  14810. bytes. The value 0 disables log rotation.
  14811. Defaults to @samp{1048576}.
  14812. @end deftypevr
  14813. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  14814. Specifies the maximum amount of time to allow between files in a
  14815. multiple file print job, in seconds.
  14816. Defaults to @samp{300}.
  14817. @end deftypevr
  14818. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  14819. Specifies the format of PageLog lines. Sequences beginning with percent
  14820. (@samp{%}) characters are replaced with the corresponding information,
  14821. while all other characters are copied literally. The following percent
  14822. sequences are recognized:
  14823. @table @samp
  14824. @item %%
  14825. insert a single percent character
  14826. @item %@{name@}
  14827. insert the value of the specified IPP attribute
  14828. @item %C
  14829. insert the number of copies for the current page
  14830. @item %P
  14831. insert the current page number
  14832. @item %T
  14833. insert the current date and time in common log format
  14834. @item %j
  14835. insert the job ID
  14836. @item %p
  14837. insert the printer name
  14838. @item %u
  14839. insert the username
  14840. @end table
  14841. A value of the empty string disables page logging. The string @code{%p
  14842. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  14843. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  14844. standard items.
  14845. Defaults to @samp{""}.
  14846. @end deftypevr
  14847. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  14848. Passes the specified environment variable(s) to child processes; a list
  14849. of strings.
  14850. Defaults to @samp{()}.
  14851. @end deftypevr
  14852. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  14853. Specifies named access control policies.
  14854. Available @code{policy-configuration} fields are:
  14855. @deftypevr {@code{policy-configuration} parameter} string name
  14856. Name of the policy.
  14857. @end deftypevr
  14858. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  14859. Specifies an access list for a job's private values. @code{@@ACL} maps
  14860. to the printer's requesting-user-name-allowed or
  14861. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  14862. owner. @code{@@SYSTEM} maps to the groups listed for the
  14863. @code{system-group} field of the @code{files-config} configuration,
  14864. which is reified into the @code{cups-files.conf(5)} file. Other
  14865. possible elements of the access list include specific user names, and
  14866. @code{@@@var{group}} to indicate members of a specific group. The
  14867. access list may also be simply @code{all} or @code{default}.
  14868. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  14869. @end deftypevr
  14870. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  14871. Specifies the list of job values to make private, or @code{all},
  14872. @code{default}, or @code{none}.
  14873. Defaults to @samp{"job-name job-originating-host-name
  14874. job-originating-user-name phone"}.
  14875. @end deftypevr
  14876. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  14877. Specifies an access list for a subscription's private values.
  14878. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  14879. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  14880. owner. @code{@@SYSTEM} maps to the groups listed for the
  14881. @code{system-group} field of the @code{files-config} configuration,
  14882. which is reified into the @code{cups-files.conf(5)} file. Other
  14883. possible elements of the access list include specific user names, and
  14884. @code{@@@var{group}} to indicate members of a specific group. The
  14885. access list may also be simply @code{all} or @code{default}.
  14886. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  14887. @end deftypevr
  14888. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  14889. Specifies the list of job values to make private, or @code{all},
  14890. @code{default}, or @code{none}.
  14891. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  14892. notify-subscriber-user-name notify-user-data"}.
  14893. @end deftypevr
  14894. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  14895. Access control by IPP operation.
  14896. Defaults to @samp{()}.
  14897. @end deftypevr
  14898. @end deftypevr
  14899. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  14900. Specifies whether job files (documents) are preserved after a job is
  14901. printed. If a numeric value is specified, job files are preserved for
  14902. the indicated number of seconds after printing. Otherwise a boolean
  14903. value applies indefinitely.
  14904. Defaults to @samp{86400}.
  14905. @end deftypevr
  14906. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  14907. Specifies whether the job history is preserved after a job is printed.
  14908. If a numeric value is specified, the job history is preserved for the
  14909. indicated number of seconds after printing. If @code{#t}, the job
  14910. history is preserved until the MaxJobs limit is reached.
  14911. Defaults to @samp{#t}.
  14912. @end deftypevr
  14913. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  14914. Specifies the amount of time to wait for job completion before
  14915. restarting the scheduler.
  14916. Defaults to @samp{30}.
  14917. @end deftypevr
  14918. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  14919. Specifies the maximum amount of memory to use when converting documents
  14920. into bitmaps for a printer.
  14921. Defaults to @samp{"128m"}.
  14922. @end deftypevr
  14923. @deftypevr {@code{cups-configuration} parameter} string server-admin
  14924. Specifies the email address of the server administrator.
  14925. Defaults to @samp{"root@@localhost.localdomain"}.
  14926. @end deftypevr
  14927. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  14928. The ServerAlias directive is used for HTTP Host header validation when
  14929. clients connect to the scheduler from external interfaces. Using the
  14930. special name @code{*} can expose your system to known browser-based DNS
  14931. rebinding attacks, even when accessing sites through a firewall. If the
  14932. auto-discovery of alternate names does not work, we recommend listing
  14933. each alternate name with a ServerAlias directive instead of using
  14934. @code{*}.
  14935. Defaults to @samp{*}.
  14936. @end deftypevr
  14937. @deftypevr {@code{cups-configuration} parameter} string server-name
  14938. Specifies the fully-qualified host name of the server.
  14939. Defaults to @samp{"localhost"}.
  14940. @end deftypevr
  14941. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  14942. Specifies what information is included in the Server header of HTTP
  14943. responses. @code{None} disables the Server header. @code{ProductOnly}
  14944. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  14945. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  14946. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  14947. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  14948. 2.0.0 (@var{uname}) IPP/2.0}.
  14949. Defaults to @samp{Minimal}.
  14950. @end deftypevr
  14951. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  14952. Listens on the specified interfaces for encrypted connections. Valid
  14953. values are of the form @var{address}:@var{port}, where @var{address} is
  14954. either an IPv6 address enclosed in brackets, an IPv4 address, or
  14955. @code{*} to indicate all addresses.
  14956. Defaults to @samp{()}.
  14957. @end deftypevr
  14958. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  14959. Sets encryption options. By default, CUPS only supports encryption
  14960. using TLS v1.0 or higher using known secure cipher suites. Security is
  14961. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  14962. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  14963. suites, which are required for some older clients. The @code{AllowSSL3} option
  14964. enables SSL v3.0, which is required for some older clients that do not support
  14965. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  14966. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  14967. protocol version to TLS v1.1.
  14968. Defaults to @samp{()}.
  14969. @end deftypevr
  14970. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  14971. Specifies whether the scheduler requires clients to strictly adhere to
  14972. the IPP specifications.
  14973. Defaults to @samp{#f}.
  14974. @end deftypevr
  14975. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  14976. Specifies the HTTP request timeout, in seconds.
  14977. Defaults to @samp{300}.
  14978. @end deftypevr
  14979. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  14980. Specifies whether the web interface is enabled.
  14981. Defaults to @samp{#f}.
  14982. @end deftypevr
  14983. At this point you're probably thinking ``oh dear, Guix manual, I like
  14984. you but you can stop already with the configuration options''. Indeed.
  14985. However, one more point: it could be that you have an existing
  14986. @code{cupsd.conf} that you want to use. In that case, you can pass an
  14987. @code{opaque-cups-configuration} as the configuration of a
  14988. @code{cups-service-type}.
  14989. Available @code{opaque-cups-configuration} fields are:
  14990. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  14991. The CUPS package.
  14992. @end deftypevr
  14993. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  14994. The contents of the @code{cupsd.conf}, as a string.
  14995. @end deftypevr
  14996. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  14997. The contents of the @code{cups-files.conf} file, as a string.
  14998. @end deftypevr
  14999. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  15000. strings of the same name, you could instantiate a CUPS service like
  15001. this:
  15002. @lisp
  15003. (service cups-service-type
  15004. (opaque-cups-configuration
  15005. (cupsd.conf cupsd.conf)
  15006. (cups-files.conf cups-files.conf)))
  15007. @end lisp
  15008. @node Desktop Services
  15009. @subsection Desktop Services
  15010. The @code{(gnu services desktop)} module provides services that are
  15011. usually useful in the context of a ``desktop'' setup---that is, on a
  15012. machine running a graphical display server, possibly with graphical user
  15013. interfaces, etc. It also defines services that provide specific desktop
  15014. environments like GNOME, Xfce or MATE.
  15015. To simplify things, the module defines a variable containing the set of
  15016. services that users typically expect on a machine with a graphical
  15017. environment and networking:
  15018. @defvr {Scheme Variable} %desktop-services
  15019. This is a list of services that builds upon @code{%base-services} and
  15020. adds or adjusts services for a typical ``desktop'' setup.
  15021. In particular, it adds a graphical login manager (@pxref{X Window,
  15022. @code{gdm-service-type}}), screen lockers, a network management tool
  15023. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  15024. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  15025. energy and color management services, the @code{elogind} login and seat
  15026. manager, the Polkit privilege service, the GeoClue location service, the
  15027. AccountsService daemon that allows authorized users change system passwords,
  15028. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  15029. name service switch service configured to be able to use @code{nss-mdns}
  15030. (@pxref{Name Service Switch, mDNS}).
  15031. @end defvr
  15032. The @code{%desktop-services} variable can be used as the @code{services}
  15033. field of an @code{operating-system} declaration (@pxref{operating-system
  15034. Reference, @code{services}}).
  15035. Additionally, the @code{gnome-desktop-service-type},
  15036. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  15037. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  15038. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  15039. ``add GNOME'' means that system-level services like the backlight adjustment
  15040. helpers and the power management utilities are added to the system, extending
  15041. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  15042. elevated privileges on a limited number of special-purpose system interfaces.
  15043. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  15044. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  15045. service not only adds the @code{xfce} metapackage to the system profile, but
  15046. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  15047. management window, if the user authenticates using the administrator's
  15048. password via the standard polkit graphical interface. To ``add MATE'' means
  15049. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  15050. to operate with elevated privileges on a limited number of special-purpose
  15051. system interfaces. Additionally, adding a service of type
  15052. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  15053. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  15054. appropriately, and several of Enlightenment's binaries are set as setuid,
  15055. allowing Enlightenment's screen locker and other functionality to work as
  15056. expected.
  15057. The desktop environments in Guix use the Xorg display server by
  15058. default. If you'd like to use the newer display server protocol
  15059. called Wayland, you need to use the @code{sddm-service} instead of
  15060. GDM as the graphical login manager. You should then
  15061. select the ``GNOME (Wayland)'' session in SDDM@. Alternatively you can
  15062. also try starting GNOME on Wayland manually from a TTY with the
  15063. command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  15064. gnome-session``. Currently only GNOME has support for Wayland.
  15065. @defvr {Scheme Variable} gnome-desktop-service-type
  15066. This is the type of the service that adds the @uref{https://www.gnome.org,
  15067. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  15068. object (see below).
  15069. This service adds the @code{gnome} package to the system profile, and extends
  15070. polkit with the actions from @code{gnome-settings-daemon}.
  15071. @end defvr
  15072. @deftp {Data Type} gnome-desktop-configuration
  15073. Configuration record for the GNOME desktop environment.
  15074. @table @asis
  15075. @item @code{gnome} (default: @code{gnome})
  15076. The GNOME package to use.
  15077. @end table
  15078. @end deftp
  15079. @defvr {Scheme Variable} xfce-desktop-service-type
  15080. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  15081. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  15082. (see below).
  15083. This service adds the @code{xfce} package to the system profile, and
  15084. extends polkit with the ability for @code{thunar} to manipulate the file
  15085. system as root from within a user session, after the user has authenticated
  15086. with the administrator's password.
  15087. Note that @code{xfce4-panel} and its plugin packages should be installed in
  15088. the same profile to ensure compatibility. When using this service, you should
  15089. add extra plugins (@code{xfce4-whiskermenu-plugin},
  15090. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  15091. @code{operating-system}.
  15092. @end defvr
  15093. @deftp {Data Type} xfce-desktop-configuration
  15094. Configuration record for the Xfce desktop environment.
  15095. @table @asis
  15096. @item @code{xfce} (default: @code{xfce})
  15097. The Xfce package to use.
  15098. @end table
  15099. @end deftp
  15100. @deffn {Scheme Variable} mate-desktop-service-type
  15101. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  15102. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  15103. object (see below).
  15104. This service adds the @code{mate} package to the system
  15105. profile, and extends polkit with the actions from
  15106. @code{mate-settings-daemon}.
  15107. @end deffn
  15108. @deftp {Data Type} mate-desktop-configuration
  15109. Configuration record for the MATE desktop environment.
  15110. @table @asis
  15111. @item @code{mate} (default: @code{mate})
  15112. The MATE package to use.
  15113. @end table
  15114. @end deftp
  15115. @deffn {Scheme Variable} lxqt-desktop-service-type
  15116. This is the type of the service that runs the @uref{https://lxqt.github.io,
  15117. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  15118. object (see below).
  15119. This service adds the @code{lxqt} package to the system
  15120. profile.
  15121. @end deffn
  15122. @deftp {Data Type} lxqt-desktop-configuration
  15123. Configuration record for the LXQt desktop environment.
  15124. @table @asis
  15125. @item @code{lxqt} (default: @code{lxqt})
  15126. The LXQT package to use.
  15127. @end table
  15128. @end deftp
  15129. @deffn {Scheme Variable} enlightenment-desktop-service-type
  15130. Return a service that adds the @code{enlightenment} package to the system
  15131. profile, and extends dbus with actions from @code{efl}.
  15132. @end deffn
  15133. @deftp {Data Type} enlightenment-desktop-service-configuration
  15134. @table @asis
  15135. @item @code{enlightenment} (default: @code{enlightenment})
  15136. The enlightenment package to use.
  15137. @end table
  15138. @end deftp
  15139. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  15140. the default @code{%desktop-services} variable doesn't include any of
  15141. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  15142. @code{%desktop-services} in the @code{services} field of your
  15143. @code{operating-system}:
  15144. @lisp
  15145. (use-modules (gnu))
  15146. (use-service-modules desktop)
  15147. (operating-system
  15148. ...
  15149. ;; cons* adds items to the list given as its last argument.
  15150. (services (cons* (service gnome-desktop-service-type)
  15151. (service xfce-desktop-service)
  15152. %desktop-services))
  15153. ...)
  15154. @end lisp
  15155. These desktop environments will then be available as options in the
  15156. graphical login window.
  15157. The actual service definitions included in @code{%desktop-services} and
  15158. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  15159. are described below.
  15160. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  15161. Return a service that runs the ``system bus'', using @var{dbus}, with
  15162. support for @var{services}.
  15163. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  15164. facility. Its system bus is used to allow system services to communicate
  15165. and to be notified of system-wide events.
  15166. @var{services} must be a list of packages that provide an
  15167. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  15168. and policy files. For example, to allow avahi-daemon to use the system bus,
  15169. @var{services} must be equal to @code{(list avahi)}.
  15170. @end deffn
  15171. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  15172. Return a service that runs the @code{elogind} login and
  15173. seat management daemon. @uref{https://github.com/elogind/elogind,
  15174. Elogind} exposes a D-Bus interface that can be used to know which users
  15175. are logged in, know what kind of sessions they have open, suspend the
  15176. system, inhibit system suspend, reboot the system, and other tasks.
  15177. Elogind handles most system-level power events for a computer, for
  15178. example suspending the system when a lid is closed, or shutting it down
  15179. when the power button is pressed.
  15180. The @var{config} keyword argument specifies the configuration for
  15181. elogind, and should be the result of an @code{(elogind-configuration
  15182. (@var{parameter} @var{value})...)} invocation. Available parameters and
  15183. their default values are:
  15184. @table @code
  15185. @item kill-user-processes?
  15186. @code{#f}
  15187. @item kill-only-users
  15188. @code{()}
  15189. @item kill-exclude-users
  15190. @code{("root")}
  15191. @item inhibit-delay-max-seconds
  15192. @code{5}
  15193. @item handle-power-key
  15194. @code{poweroff}
  15195. @item handle-suspend-key
  15196. @code{suspend}
  15197. @item handle-hibernate-key
  15198. @code{hibernate}
  15199. @item handle-lid-switch
  15200. @code{suspend}
  15201. @item handle-lid-switch-docked
  15202. @code{ignore}
  15203. @item handle-lid-switch-external-power
  15204. @code{ignore}
  15205. @item power-key-ignore-inhibited?
  15206. @code{#f}
  15207. @item suspend-key-ignore-inhibited?
  15208. @code{#f}
  15209. @item hibernate-key-ignore-inhibited?
  15210. @code{#f}
  15211. @item lid-switch-ignore-inhibited?
  15212. @code{#t}
  15213. @item holdoff-timeout-seconds
  15214. @code{30}
  15215. @item idle-action
  15216. @code{ignore}
  15217. @item idle-action-seconds
  15218. @code{(* 30 60)}
  15219. @item runtime-directory-size-percent
  15220. @code{10}
  15221. @item runtime-directory-size
  15222. @code{#f}
  15223. @item remove-ipc?
  15224. @code{#t}
  15225. @item suspend-state
  15226. @code{("mem" "standby" "freeze")}
  15227. @item suspend-mode
  15228. @code{()}
  15229. @item hibernate-state
  15230. @code{("disk")}
  15231. @item hibernate-mode
  15232. @code{("platform" "shutdown")}
  15233. @item hybrid-sleep-state
  15234. @code{("disk")}
  15235. @item hybrid-sleep-mode
  15236. @code{("suspend" "platform" "shutdown")}
  15237. @end table
  15238. @end deffn
  15239. @deffn {Scheme Procedure} accountsservice-service @
  15240. [#:accountsservice @var{accountsservice}]
  15241. Return a service that runs AccountsService, a system service that can
  15242. list available accounts, change their passwords, and so on.
  15243. AccountsService integrates with PolicyKit to enable unprivileged users
  15244. to acquire the capability to modify their system configuration.
  15245. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  15246. accountsservice web site} for more information.
  15247. The @var{accountsservice} keyword argument is the @code{accountsservice}
  15248. package to expose as a service.
  15249. @end deffn
  15250. @deffn {Scheme Procedure} polkit-service @
  15251. [#:polkit @var{polkit}]
  15252. Return a service that runs the
  15253. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  15254. management service}, which allows system administrators to grant access to
  15255. privileged operations in a structured way. By querying the Polkit service, a
  15256. privileged system component can know when it should grant additional
  15257. capabilities to ordinary users. For example, an ordinary user can be granted
  15258. the capability to suspend the system if the user is logged in locally.
  15259. @end deffn
  15260. @defvr {Scheme Variable} polkit-wheel-service
  15261. Service that adds the @code{wheel} group as admins to the Polkit
  15262. service. This makes it so that users in the @code{wheel} group are queried
  15263. for their own passwords when performing administrative actions instead of
  15264. @code{root}'s, similar to the behaviour used by @code{sudo}.
  15265. @end defvr
  15266. @defvr {Scheme Variable} upower-service-type
  15267. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  15268. system-wide monitor for power consumption and battery levels, with the given
  15269. configuration settings.
  15270. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  15271. notably used by GNOME.
  15272. @end defvr
  15273. @deftp {Data Type} upower-configuration
  15274. Data type representation the configuration for UPower.
  15275. @table @asis
  15276. @item @code{upower} (default: @var{upower})
  15277. Package to use for @code{upower}.
  15278. @item @code{watts-up-pro?} (default: @code{#f})
  15279. Enable the Watts Up Pro device.
  15280. @item @code{poll-batteries?} (default: @code{#t})
  15281. Enable polling the kernel for battery level changes.
  15282. @item @code{ignore-lid?} (default: @code{#f})
  15283. Ignore the lid state, this can be useful if it's incorrect on a device.
  15284. @item @code{use-percentage-for-policy?} (default: @code{#f})
  15285. Whether battery percentage based policy should be used. The default is to use
  15286. the time left, change to @code{#t} to use the percentage.
  15287. @item @code{percentage-low} (default: @code{10})
  15288. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15289. at which the battery is considered low.
  15290. @item @code{percentage-critical} (default: @code{3})
  15291. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15292. at which the battery is considered critical.
  15293. @item @code{percentage-action} (default: @code{2})
  15294. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15295. at which action will be taken.
  15296. @item @code{time-low} (default: @code{1200})
  15297. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15298. seconds at which the battery is considered low.
  15299. @item @code{time-critical} (default: @code{300})
  15300. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15301. seconds at which the battery is considered critical.
  15302. @item @code{time-action} (default: @code{120})
  15303. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15304. seconds at which action will be taken.
  15305. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  15306. The action taken when @code{percentage-action} or @code{time-action} is
  15307. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  15308. Possible values are:
  15309. @itemize @bullet
  15310. @item
  15311. @code{'power-off}
  15312. @item
  15313. @code{'hibernate}
  15314. @item
  15315. @code{'hybrid-sleep}.
  15316. @end itemize
  15317. @end table
  15318. @end deftp
  15319. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  15320. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  15321. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  15322. with notifications and ways to mount/unmount disks. Programs that talk
  15323. to UDisks include the @command{udisksctl} command, part of UDisks, and
  15324. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  15325. it will only be able to use the file-system utilities installed in the
  15326. system profile. For example if you want to be able to mount NTFS
  15327. file-systems in read and write fashion, you'll need to have
  15328. @code{ntfs-3g} installed system-wide.
  15329. @end deffn
  15330. @deffn {Scheme Variable} colord-service-type
  15331. This is the type of the service that runs @command{colord}, a system
  15332. service with a D-Bus
  15333. interface to manage the color profiles of input and output devices such as
  15334. screens and scanners. It is notably used by the GNOME Color Manager graphical
  15335. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  15336. site} for more information.
  15337. @end deffn
  15338. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  15339. Return a configuration allowing an application to access GeoClue
  15340. location data. @var{name} is the Desktop ID of the application, without
  15341. the @code{.desktop} part. If @var{allowed?} is true, the application
  15342. will have access to location information by default. The boolean
  15343. @var{system?} value indicates whether an application is a system component
  15344. or not. Finally @var{users} is a list of UIDs of all users for which
  15345. this application is allowed location info access. An empty users list
  15346. means that all users are allowed.
  15347. @end deffn
  15348. @cindex scanner access
  15349. @deffn {Scheme Procedure} sane-service-type
  15350. This service provides access to scanners @i{via}
  15351. @uref{http://www.sane-project.org, SANE} by installing the necessary udev
  15352. rules.
  15353. @end deffn
  15354. @defvr {Scheme Variable} %standard-geoclue-applications
  15355. The standard list of well-known GeoClue application configurations,
  15356. granting authority to the GNOME date-and-time utility to ask for the
  15357. current location in order to set the time zone, and allowing the
  15358. IceCat and Epiphany web browsers to request location information.
  15359. IceCat and Epiphany both query the user before allowing a web page to
  15360. know the user's location.
  15361. @end defvr
  15362. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  15363. [#:whitelist '()] @
  15364. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  15365. [#:submit-data? #f]
  15366. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  15367. [#:submission-nick "geoclue"] @
  15368. [#:applications %standard-geoclue-applications]
  15369. Return a service that runs the GeoClue location service. This service
  15370. provides a D-Bus interface to allow applications to request access to a
  15371. user's physical location, and optionally to add information to online
  15372. location databases. See
  15373. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  15374. web site} for more information.
  15375. @end deffn
  15376. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  15377. [@w{#:auto-enable? #f}]
  15378. Return a service that runs the @command{bluetoothd} daemon, which
  15379. manages all the Bluetooth devices and provides a number of D-Bus
  15380. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  15381. powered automatically at boot, which can be useful when using a
  15382. bluetooth keyboard or mouse.
  15383. Users need to be in the @code{lp} group to access the D-Bus service.
  15384. @end deffn
  15385. @defvr {Scheme Variable} gnome-keyring-service-type
  15386. This is the type of the service that adds the
  15387. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  15388. value is a @code{gnome-keyring-configuration} object (see below).
  15389. This service adds the @code{gnome-keyring} package to the system profile
  15390. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  15391. a user's login keyring when they log in or setting its password with passwd.
  15392. @end defvr
  15393. @deftp {Data Type} gnome-keyring-configuration
  15394. Configuration record for the GNOME Keyring service.
  15395. @table @asis
  15396. @item @code{keyring} (default: @code{gnome-keyring})
  15397. The GNOME keyring package to use.
  15398. @item @code{pam-services}
  15399. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  15400. services to extend, where @var{service} is the name of an existing
  15401. service to extend and @var{kind} is one of @code{login} or
  15402. @code{passwd}.
  15403. If @code{login} is given, it adds an optional
  15404. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  15405. the session block with @code{auto_start}. If @code{passwd} is given, it
  15406. adds an optional @code{pam_gnome_keyring.so} to the password block
  15407. without arguments.
  15408. By default, this field contains ``gdm-password'' with the value @code{login}
  15409. and ``passwd'' is with the value @code{passwd}.
  15410. @end table
  15411. @end deftp
  15412. @node Sound Services
  15413. @subsection Sound Services
  15414. @cindex sound support
  15415. @cindex ALSA
  15416. @cindex PulseAudio, sound support
  15417. The @code{(gnu services sound)} module provides a service to configure the
  15418. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  15419. preferred ALSA output driver.
  15420. @deffn {Scheme Variable} alsa-service-type
  15421. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  15422. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  15423. configuration file. The value for this type is a @command{alsa-configuration}
  15424. record as in this example:
  15425. @lisp
  15426. (service alsa-service-type)
  15427. @end lisp
  15428. See below for details about @code{alsa-configuration}.
  15429. @end deffn
  15430. @deftp {Data Type} alsa-configuration
  15431. Data type representing the configuration for @code{alsa-service}.
  15432. @table @asis
  15433. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  15434. @code{alsa-plugins} package to use.
  15435. @item @code{pulseaudio?} (default: @var{#t})
  15436. Whether ALSA applications should transparently be made to use the
  15437. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  15438. Using PulseAudio allows you to run several sound-producing applications
  15439. at the same time and to individual control them @i{via}
  15440. @command{pavucontrol}, among other things.
  15441. @item @code{extra-options} (default: @var{""})
  15442. String to append to the @file{/etc/asound.conf} file.
  15443. @end table
  15444. @end deftp
  15445. Individual users who want to override the system configuration of ALSA can do
  15446. it with the @file{~/.asoundrc} file:
  15447. @example
  15448. # In guix, we have to specify the absolute path for plugins.
  15449. pcm_type.jack @{
  15450. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  15451. @}
  15452. # Routing ALSA to jack:
  15453. # <http://jackaudio.org/faq/routing_alsa.html>.
  15454. pcm.rawjack @{
  15455. type jack
  15456. playback_ports @{
  15457. 0 system:playback_1
  15458. 1 system:playback_2
  15459. @}
  15460. capture_ports @{
  15461. 0 system:capture_1
  15462. 1 system:capture_2
  15463. @}
  15464. @}
  15465. pcm.!default @{
  15466. type plug
  15467. slave @{
  15468. pcm "rawjack"
  15469. @}
  15470. @}
  15471. @end example
  15472. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  15473. details.
  15474. @deffn {Scheme Variable} pulseaudio-service-type
  15475. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  15476. sound server. It exists to allow system overrides of the default settings
  15477. via @code{pulseaudio-configuration}, see below.
  15478. @quotation Warning
  15479. This service overrides per-user configuration files. If you want
  15480. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  15481. have to unset the environment variables @env{PULSE_CONFIG} and
  15482. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  15483. @end quotation
  15484. @quotation Warning
  15485. This service on its own does not ensure, that the @code{pulseaudio} package
  15486. exists on your machine. It merely adds configuration files for it, as
  15487. detailed below. In the (admittedly unlikely) case, that you find yourself
  15488. without a @code{pulseaudio} package, consider enabling it through the
  15489. @code{alsa-service-type} above.
  15490. @end quotation
  15491. @end deffn
  15492. @deftp {Data Type} pulseaudio-configuration
  15493. Data type representing the configuration for @code{pulseaudio-service}.
  15494. @table @asis
  15495. @item @code{client-conf} (default: @code{'()})
  15496. List of settings to set in @file{client.conf}.
  15497. Accepts a list of strings or a symbol-value pairs. A string will be
  15498. inserted as-is with a newline added. A pair will be formatted as
  15499. ``key = value'', again with a newline added.
  15500. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  15501. List of settings to set in @file{daemon.conf}, formatted just like
  15502. @var{client-conf}.
  15503. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  15504. Script file to use as @file{default.pa}.
  15505. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  15506. Script file to use as @file{system.pa}.
  15507. @end table
  15508. @end deftp
  15509. @deffn {Scheme Variable} ladspa-service-type
  15510. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  15511. respect it, e.g. PulseAudio, can load LADSPA plugins.
  15512. The following example will setup the service to enable modules from the
  15513. @code{swh-plugins} package:
  15514. @lisp
  15515. (service ladspa-service-type
  15516. (ladspa-configuration (plugins (list swh-plugins))))
  15517. @end lisp
  15518. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  15519. details.
  15520. @end deffn
  15521. @node Database Services
  15522. @subsection Database Services
  15523. @cindex database
  15524. @cindex SQL
  15525. The @code{(gnu services databases)} module provides the following services.
  15526. @subsubheading PostgreSQL
  15527. The following example describes a PostgreSQL service with the default
  15528. configuration.
  15529. @lisp
  15530. (service postgresql-service-type
  15531. (postgresql-configuration
  15532. (postgresql postgresql-10)))
  15533. @end lisp
  15534. If the services fails to start, it may be due to an incompatible
  15535. cluster already present in @var{data-directory}. Adjust it (or, if you
  15536. don't need the cluster anymore, delete @var{data-directory}), then
  15537. restart the service.
  15538. Peer authentication is used by default and the @code{postgres} user
  15539. account has no shell, which prevents the direct execution of @code{psql}
  15540. commands as this user. To use @code{psql}, you can temporarily log in
  15541. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  15542. same name as one of the system users and then create the associated
  15543. database.
  15544. @example
  15545. sudo -u postgres -s /bin/sh
  15546. createuser --interactive
  15547. createdb $MY_USER_LOGIN # Replace appropriately.
  15548. @end example
  15549. @deftp {Data Type} postgresql-configuration
  15550. Data type representing the configuration for the
  15551. @code{postgresql-service-type}.
  15552. @table @asis
  15553. @item @code{postgresql}
  15554. PostgreSQL package to use for the service.
  15555. @item @code{port} (default: @code{5432})
  15556. Port on which PostgreSQL should listen.
  15557. @item @code{locale} (default: @code{"en_US.utf8"})
  15558. Locale to use as the default when creating the database cluster.
  15559. @item @code{config-file} (default: @code{(postgresql-config-file)})
  15560. The configuration file to use when running PostgreSQL@. The default
  15561. behaviour uses the postgresql-config-file record with the default values
  15562. for the fields.
  15563. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  15564. Directory in which to store the data.
  15565. @item @code{extension-packages} (default: @code{'()})
  15566. @cindex postgresql extension-packages
  15567. Additional extensions are loaded from packages listed in
  15568. @var{extension-packages}. Extensions are available at runtime. For instance,
  15569. to create a geographic database using the @code{postgis} extension, a user can
  15570. configure the postgresql-service as in this example:
  15571. @cindex postgis
  15572. @lisp
  15573. (use-package-modules databases geo)
  15574. (operating-system
  15575. ...
  15576. ;; postgresql is required to run `psql' but postgis is not required for
  15577. ;; proper operation.
  15578. (packages (cons* postgresql %base-packages))
  15579. (services
  15580. (cons*
  15581. (service postgresql-service-type
  15582. (postgresql-configuration
  15583. (postgresql postgresql-10)
  15584. (extension-packages (list postgis))))
  15585. %base-services)))
  15586. @end lisp
  15587. Then the extension becomes visible and you can initialise an empty geographic
  15588. database in this way:
  15589. @example
  15590. psql -U postgres
  15591. > create database postgistest;
  15592. > \connect postgistest;
  15593. > create extension postgis;
  15594. > create extension postgis_topology;
  15595. @end example
  15596. There is no need to add this field for contrib extensions such as hstore or
  15597. dblink as they are already loadable by postgresql. This field is only
  15598. required to add extensions provided by other packages.
  15599. @end table
  15600. @end deftp
  15601. @deftp {Data Type} postgresql-config-file
  15602. Data type representing the PostgreSQL configuration file. As shown in
  15603. the following example, this can be used to customize the configuration
  15604. of PostgreSQL@. Note that you can use any G-expression or filename in
  15605. place of this record, if you already have a configuration file you'd
  15606. like to use for example.
  15607. @lisp
  15608. (service postgresql-service-type
  15609. (postgresql-configuration
  15610. (config-file
  15611. (postgresql-config-file
  15612. (log-destination "stderr")
  15613. (hba-file
  15614. (plain-file "pg_hba.conf"
  15615. "
  15616. local all all trust
  15617. host all all 127.0.0.1/32 md5
  15618. host all all ::1/128 md5"))
  15619. (extra-config
  15620. '(("session_preload_libraries" "'auto_explain'")
  15621. ("random_page_cost" "2")
  15622. ("auto_explain.log_min_duration" "'100ms'")
  15623. ("work_mem" "'500MB'")
  15624. ("logging_collector" "on")
  15625. ("log_directory" "'/var/log/postgresql'")))))))
  15626. @end lisp
  15627. @table @asis
  15628. @item @code{log-destination} (default: @code{"syslog"})
  15629. The logging method to use for PostgreSQL@. Multiple values are accepted,
  15630. separated by commas.
  15631. @item @code{hba-file} (default: @code{%default-postgres-hba})
  15632. Filename or G-expression for the host-based authentication
  15633. configuration.
  15634. @item @code{ident-file} (default: @code{%default-postgres-ident})
  15635. Filename or G-expression for the user name mapping configuration.
  15636. @item @code{extra-config} (default: @code{'()})
  15637. List of additional keys and values to include in the PostgreSQL config
  15638. file. Each entry in the list should be a list where the first element
  15639. is the key, and the remaining elements are the values.
  15640. @end table
  15641. @end deftp
  15642. @subsubheading MariaDB/MySQL
  15643. @defvr {Scheme Variable} mysql-service-type
  15644. This is the service type for a MySQL or MariaDB database server. Its value
  15645. is a @code{mysql-configuration} object that specifies which package to use,
  15646. as well as various settings for the @command{mysqld} daemon.
  15647. @end defvr
  15648. @deftp {Data Type} mysql-configuration
  15649. Data type representing the configuration of @var{mysql-service-type}.
  15650. @table @asis
  15651. @item @code{mysql} (default: @var{mariadb})
  15652. Package object of the MySQL database server, can be either @var{mariadb}
  15653. or @var{mysql}.
  15654. For MySQL, a temporary root password will be displayed at activation time.
  15655. For MariaDB, the root password is empty.
  15656. @item @code{bind-address} (default: @code{"127.0.0.1"})
  15657. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  15658. to bind to all available network interfaces.
  15659. @item @code{port} (default: @code{3306})
  15660. TCP port on which the database server listens for incoming connections.
  15661. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  15662. Socket file to use for local (non-network) connections.
  15663. @item @code{extra-content} (default: @code{""})
  15664. Additional settings for the @file{my.cnf} configuration file.
  15665. @item @code{auto-upgrade?} (default: @code{#t})
  15666. Whether to automatically run @command{mysql_upgrade} after starting the
  15667. service. This is necessary to upgrade the @dfn{system schema} after
  15668. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  15669. be disabled if you would rather do that manually.
  15670. @end table
  15671. @end deftp
  15672. @subsubheading Memcached
  15673. @defvr {Scheme Variable} memcached-service-type
  15674. This is the service type for the @uref{https://memcached.org/,
  15675. Memcached} service, which provides a distributed in memory cache. The
  15676. value for the service type is a @code{memcached-configuration} object.
  15677. @end defvr
  15678. @lisp
  15679. (service memcached-service-type)
  15680. @end lisp
  15681. @deftp {Data Type} memcached-configuration
  15682. Data type representing the configuration of memcached.
  15683. @table @asis
  15684. @item @code{memcached} (default: @code{memcached})
  15685. The Memcached package to use.
  15686. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  15687. Network interfaces on which to listen.
  15688. @item @code{tcp-port} (default: @code{11211})
  15689. Port on which to accept connections.
  15690. @item @code{udp-port} (default: @code{11211})
  15691. Port on which to accept UDP connections on, a value of 0 will disable
  15692. listening on a UDP socket.
  15693. @item @code{additional-options} (default: @code{'()})
  15694. Additional command line options to pass to @code{memcached}.
  15695. @end table
  15696. @end deftp
  15697. @subsubheading MongoDB
  15698. @defvr {Scheme Variable} mongodb-service-type
  15699. This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
  15700. The value for the service type is a @code{mongodb-configuration} object.
  15701. @end defvr
  15702. @lisp
  15703. (service mongodb-service-type)
  15704. @end lisp
  15705. @deftp {Data Type} mongodb-configuration
  15706. Data type representing the configuration of mongodb.
  15707. @table @asis
  15708. @item @code{mongodb} (default: @code{mongodb})
  15709. The MongoDB package to use.
  15710. @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
  15711. The configuration file for MongoDB.
  15712. @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
  15713. This value is used to create the directory, so that it exists and is
  15714. owned by the mongodb user. It should match the data-directory which
  15715. MongoDB is configured to use through the configuration file.
  15716. @end table
  15717. @end deftp
  15718. @subsubheading Redis
  15719. @defvr {Scheme Variable} redis-service-type
  15720. This is the service type for the @uref{https://redis.io/, Redis}
  15721. key/value store, whose value is a @code{redis-configuration} object.
  15722. @end defvr
  15723. @deftp {Data Type} redis-configuration
  15724. Data type representing the configuration of redis.
  15725. @table @asis
  15726. @item @code{redis} (default: @code{redis})
  15727. The Redis package to use.
  15728. @item @code{bind} (default: @code{"127.0.0.1"})
  15729. Network interface on which to listen.
  15730. @item @code{port} (default: @code{6379})
  15731. Port on which to accept connections on, a value of 0 will disable
  15732. listening on a TCP socket.
  15733. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  15734. Directory in which to store the database and related files.
  15735. @end table
  15736. @end deftp
  15737. @node Mail Services
  15738. @subsection Mail Services
  15739. @cindex mail
  15740. @cindex email
  15741. The @code{(gnu services mail)} module provides Guix service definitions
  15742. for email services: IMAP, POP3, and LMTP servers, as well as mail
  15743. transport agents (MTAs). Lots of acronyms! These services are detailed
  15744. in the subsections below.
  15745. @subsubheading Dovecot Service
  15746. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  15747. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  15748. @end deffn
  15749. By default, Dovecot does not need much configuration; the default
  15750. configuration object created by @code{(dovecot-configuration)} will
  15751. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  15752. certificate will be generated for TLS-protected connections, though
  15753. Dovecot will also listen on cleartext ports by default. There are a
  15754. number of options, though, which mail administrators might need to change,
  15755. and as is the case with other services, Guix allows the system
  15756. administrator to specify these parameters via a uniform Scheme interface.
  15757. For example, to specify that mail is located at @code{maildir~/.mail},
  15758. one would instantiate the Dovecot service like this:
  15759. @lisp
  15760. (dovecot-service #:config
  15761. (dovecot-configuration
  15762. (mail-location "maildir:~/.mail")))
  15763. @end lisp
  15764. The available configuration parameters follow. Each parameter
  15765. definition is preceded by its type; for example, @samp{string-list foo}
  15766. indicates that the @code{foo} parameter should be specified as a list of
  15767. strings. There is also a way to specify the configuration as a string,
  15768. if you have an old @code{dovecot.conf} file that you want to port over
  15769. from some other system; see the end for more details.
  15770. @c The following documentation was initially generated by
  15771. @c (generate-documentation) in (gnu services mail). Manually maintained
  15772. @c documentation is better, so we shouldn't hesitate to edit below as
  15773. @c needed. However if the change you want to make to this documentation
  15774. @c can be done in an automated way, it's probably easier to change
  15775. @c (generate-documentation) than to make it below and have to deal with
  15776. @c the churn as dovecot updates.
  15777. Available @code{dovecot-configuration} fields are:
  15778. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  15779. The dovecot package.
  15780. @end deftypevr
  15781. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  15782. A list of IPs or hosts where to listen for connections. @samp{*}
  15783. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  15784. interfaces. If you want to specify non-default ports or anything more
  15785. complex, customize the address and port fields of the
  15786. @samp{inet-listener} of the specific services you are interested in.
  15787. @end deftypevr
  15788. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  15789. List of protocols we want to serve. Available protocols include
  15790. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  15791. Available @code{protocol-configuration} fields are:
  15792. @deftypevr {@code{protocol-configuration} parameter} string name
  15793. The name of the protocol.
  15794. @end deftypevr
  15795. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  15796. UNIX socket path to the master authentication server to find users.
  15797. This is used by imap (for shared users) and lda.
  15798. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  15799. @end deftypevr
  15800. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  15801. Space separated list of plugins to load.
  15802. @end deftypevr
  15803. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  15804. Maximum number of IMAP connections allowed for a user from each IP
  15805. address. NOTE: The username is compared case-sensitively.
  15806. Defaults to @samp{10}.
  15807. @end deftypevr
  15808. @end deftypevr
  15809. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  15810. List of services to enable. Available services include @samp{imap},
  15811. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  15812. @samp{lmtp}.
  15813. Available @code{service-configuration} fields are:
  15814. @deftypevr {@code{service-configuration} parameter} string kind
  15815. The service kind. Valid values include @code{director},
  15816. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  15817. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  15818. @code{tcpwrap}, @code{quota-warning}, or anything else.
  15819. @end deftypevr
  15820. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  15821. Listeners for the service. A listener is either a
  15822. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  15823. an @code{inet-listener-configuration}.
  15824. Defaults to @samp{()}.
  15825. Available @code{unix-listener-configuration} fields are:
  15826. @deftypevr {@code{unix-listener-configuration} parameter} string path
  15827. Path to the file, relative to @code{base-dir} field. This is also used as
  15828. the section name.
  15829. @end deftypevr
  15830. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  15831. The access mode for the socket.
  15832. Defaults to @samp{"0600"}.
  15833. @end deftypevr
  15834. @deftypevr {@code{unix-listener-configuration} parameter} string user
  15835. The user to own the socket.
  15836. Defaults to @samp{""}.
  15837. @end deftypevr
  15838. @deftypevr {@code{unix-listener-configuration} parameter} string group
  15839. The group to own the socket.
  15840. Defaults to @samp{""}.
  15841. @end deftypevr
  15842. Available @code{fifo-listener-configuration} fields are:
  15843. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  15844. Path to the file, relative to @code{base-dir} field. This is also used as
  15845. the section name.
  15846. @end deftypevr
  15847. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  15848. The access mode for the socket.
  15849. Defaults to @samp{"0600"}.
  15850. @end deftypevr
  15851. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  15852. The user to own the socket.
  15853. Defaults to @samp{""}.
  15854. @end deftypevr
  15855. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  15856. The group to own the socket.
  15857. Defaults to @samp{""}.
  15858. @end deftypevr
  15859. Available @code{inet-listener-configuration} fields are:
  15860. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  15861. The protocol to listen for.
  15862. @end deftypevr
  15863. @deftypevr {@code{inet-listener-configuration} parameter} string address
  15864. The address on which to listen, or empty for all addresses.
  15865. Defaults to @samp{""}.
  15866. @end deftypevr
  15867. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  15868. The port on which to listen.
  15869. @end deftypevr
  15870. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  15871. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  15872. @samp{required}.
  15873. Defaults to @samp{#t}.
  15874. @end deftypevr
  15875. @end deftypevr
  15876. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  15877. Maximum number of simultaneous client connections per process. Once
  15878. this number of connections is received, the next incoming connection
  15879. will prompt Dovecot to spawn another process. If set to 0,
  15880. @code{default-client-limit} is used instead.
  15881. Defaults to @samp{0}.
  15882. @end deftypevr
  15883. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  15884. Number of connections to handle before starting a new process.
  15885. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  15886. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  15887. Defaults to @samp{1}.
  15888. @end deftypevr
  15889. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  15890. Maximum number of processes that can exist for this service. If set to
  15891. 0, @code{default-process-limit} is used instead.
  15892. Defaults to @samp{0}.
  15893. @end deftypevr
  15894. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  15895. Number of processes to always keep waiting for more connections.
  15896. Defaults to @samp{0}.
  15897. @end deftypevr
  15898. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  15899. If you set @samp{service-count 0}, you probably need to grow
  15900. this.
  15901. Defaults to @samp{256000000}.
  15902. @end deftypevr
  15903. @end deftypevr
  15904. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  15905. Dict configuration, as created by the @code{dict-configuration}
  15906. constructor.
  15907. Available @code{dict-configuration} fields are:
  15908. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  15909. A list of key-value pairs that this dict should hold.
  15910. Defaults to @samp{()}.
  15911. @end deftypevr
  15912. @end deftypevr
  15913. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  15914. A list of passdb configurations, each one created by the
  15915. @code{passdb-configuration} constructor.
  15916. Available @code{passdb-configuration} fields are:
  15917. @deftypevr {@code{passdb-configuration} parameter} string driver
  15918. The driver that the passdb should use. Valid values include
  15919. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  15920. @samp{static}.
  15921. Defaults to @samp{"pam"}.
  15922. @end deftypevr
  15923. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  15924. Space separated list of arguments to the passdb driver.
  15925. Defaults to @samp{""}.
  15926. @end deftypevr
  15927. @end deftypevr
  15928. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  15929. List of userdb configurations, each one created by the
  15930. @code{userdb-configuration} constructor.
  15931. Available @code{userdb-configuration} fields are:
  15932. @deftypevr {@code{userdb-configuration} parameter} string driver
  15933. The driver that the userdb should use. Valid values include
  15934. @samp{passwd} and @samp{static}.
  15935. Defaults to @samp{"passwd"}.
  15936. @end deftypevr
  15937. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  15938. Space separated list of arguments to the userdb driver.
  15939. Defaults to @samp{""}.
  15940. @end deftypevr
  15941. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  15942. Override fields from passwd.
  15943. Defaults to @samp{()}.
  15944. @end deftypevr
  15945. @end deftypevr
  15946. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  15947. Plug-in configuration, created by the @code{plugin-configuration}
  15948. constructor.
  15949. @end deftypevr
  15950. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  15951. List of namespaces. Each item in the list is created by the
  15952. @code{namespace-configuration} constructor.
  15953. Available @code{namespace-configuration} fields are:
  15954. @deftypevr {@code{namespace-configuration} parameter} string name
  15955. Name for this namespace.
  15956. @end deftypevr
  15957. @deftypevr {@code{namespace-configuration} parameter} string type
  15958. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  15959. Defaults to @samp{"private"}.
  15960. @end deftypevr
  15961. @deftypevr {@code{namespace-configuration} parameter} string separator
  15962. Hierarchy separator to use. You should use the same separator for
  15963. all namespaces or some clients get confused. @samp{/} is usually a good
  15964. one. The default however depends on the underlying mail storage
  15965. format.
  15966. Defaults to @samp{""}.
  15967. @end deftypevr
  15968. @deftypevr {@code{namespace-configuration} parameter} string prefix
  15969. Prefix required to access this namespace. This needs to be
  15970. different for all namespaces. For example @samp{Public/}.
  15971. Defaults to @samp{""}.
  15972. @end deftypevr
  15973. @deftypevr {@code{namespace-configuration} parameter} string location
  15974. Physical location of the mailbox. This is in the same format as
  15975. mail_location, which is also the default for it.
  15976. Defaults to @samp{""}.
  15977. @end deftypevr
  15978. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  15979. There can be only one INBOX, and this setting defines which
  15980. namespace has it.
  15981. Defaults to @samp{#f}.
  15982. @end deftypevr
  15983. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  15984. If namespace is hidden, it's not advertised to clients via NAMESPACE
  15985. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  15986. useful when converting from another server with different namespaces
  15987. which you want to deprecate but still keep working. For example you can
  15988. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  15989. and @samp{mail/}.
  15990. Defaults to @samp{#f}.
  15991. @end deftypevr
  15992. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  15993. Show the mailboxes under this namespace with the LIST command. This
  15994. makes the namespace visible for clients that do not support the NAMESPACE
  15995. extension. The special @code{children} value lists child mailboxes, but
  15996. hides the namespace prefix.
  15997. Defaults to @samp{#t}.
  15998. @end deftypevr
  15999. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  16000. Namespace handles its own subscriptions. If set to @code{#f}, the
  16001. parent namespace handles them. The empty prefix should always have this
  16002. as @code{#t}).
  16003. Defaults to @samp{#t}.
  16004. @end deftypevr
  16005. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  16006. List of predefined mailboxes in this namespace.
  16007. Defaults to @samp{()}.
  16008. Available @code{mailbox-configuration} fields are:
  16009. @deftypevr {@code{mailbox-configuration} parameter} string name
  16010. Name for this mailbox.
  16011. @end deftypevr
  16012. @deftypevr {@code{mailbox-configuration} parameter} string auto
  16013. @samp{create} will automatically create this mailbox.
  16014. @samp{subscribe} will both create and subscribe to the mailbox.
  16015. Defaults to @samp{"no"}.
  16016. @end deftypevr
  16017. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  16018. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  16019. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  16020. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  16021. Defaults to @samp{()}.
  16022. @end deftypevr
  16023. @end deftypevr
  16024. @end deftypevr
  16025. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  16026. Base directory where to store runtime data.
  16027. Defaults to @samp{"/var/run/dovecot/"}.
  16028. @end deftypevr
  16029. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  16030. Greeting message for clients.
  16031. Defaults to @samp{"Dovecot ready."}.
  16032. @end deftypevr
  16033. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  16034. List of trusted network ranges. Connections from these IPs are
  16035. allowed to override their IP addresses and ports (for logging and for
  16036. authentication checks). @samp{disable-plaintext-auth} is also ignored
  16037. for these networks. Typically you would specify your IMAP proxy servers
  16038. here.
  16039. Defaults to @samp{()}.
  16040. @end deftypevr
  16041. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  16042. List of login access check sockets (e.g.@: tcpwrap).
  16043. Defaults to @samp{()}.
  16044. @end deftypevr
  16045. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  16046. Show more verbose process titles (in ps). Currently shows user name
  16047. and IP address. Useful for seeing who is actually using the IMAP
  16048. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  16049. accounts).
  16050. Defaults to @samp{#f}.
  16051. @end deftypevr
  16052. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  16053. Should all processes be killed when Dovecot master process shuts down.
  16054. Setting this to @code{#f} means that Dovecot can be upgraded without
  16055. forcing existing client connections to close (although that could also
  16056. be a problem if the upgrade is e.g.@: due to a security fix).
  16057. Defaults to @samp{#t}.
  16058. @end deftypevr
  16059. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  16060. If non-zero, run mail commands via this many connections to doveadm
  16061. server, instead of running them directly in the same process.
  16062. Defaults to @samp{0}.
  16063. @end deftypevr
  16064. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  16065. UNIX socket or host:port used for connecting to doveadm server.
  16066. Defaults to @samp{"doveadm-server"}.
  16067. @end deftypevr
  16068. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  16069. List of environment variables that are preserved on Dovecot startup
  16070. and passed down to all of its child processes. You can also give
  16071. key=value pairs to always set specific settings.
  16072. @end deftypevr
  16073. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  16074. Disable LOGIN command and all other plaintext authentications unless
  16075. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  16076. matches the local IP (i.e.@: you're connecting from the same computer),
  16077. the connection is considered secure and plaintext authentication is
  16078. allowed. See also ssl=required setting.
  16079. Defaults to @samp{#t}.
  16080. @end deftypevr
  16081. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  16082. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  16083. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  16084. for caching to be used.
  16085. Defaults to @samp{0}.
  16086. @end deftypevr
  16087. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  16088. Time to live for cached data. After TTL expires the cached record
  16089. is no longer used, *except* if the main database lookup returns internal
  16090. failure. We also try to handle password changes automatically: If
  16091. user's previous authentication was successful, but this one wasn't, the
  16092. cache isn't used. For now this works only with plaintext
  16093. authentication.
  16094. Defaults to @samp{"1 hour"}.
  16095. @end deftypevr
  16096. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  16097. TTL for negative hits (user not found, password mismatch).
  16098. 0 disables caching them completely.
  16099. Defaults to @samp{"1 hour"}.
  16100. @end deftypevr
  16101. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  16102. List of realms for SASL authentication mechanisms that need them.
  16103. You can leave it empty if you don't want to support multiple realms.
  16104. Many clients simply use the first one listed here, so keep the default
  16105. realm first.
  16106. Defaults to @samp{()}.
  16107. @end deftypevr
  16108. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  16109. Default realm/domain to use if none was specified. This is used for
  16110. both SASL realms and appending @@domain to username in plaintext
  16111. logins.
  16112. Defaults to @samp{""}.
  16113. @end deftypevr
  16114. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  16115. List of allowed characters in username. If the user-given username
  16116. contains a character not listed in here, the login automatically fails.
  16117. This is just an extra check to make sure user can't exploit any
  16118. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  16119. you want to allow all characters, set this value to empty.
  16120. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  16121. @end deftypevr
  16122. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  16123. Username character translations before it's looked up from
  16124. databases. The value contains series of from -> to characters. For
  16125. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  16126. translated to @samp{@@}.
  16127. Defaults to @samp{""}.
  16128. @end deftypevr
  16129. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  16130. Username formatting before it's looked up from databases. You can
  16131. use the standard variables here, e.g.@: %Lu would lowercase the username,
  16132. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  16133. change the @samp{@@} into @samp{-AT-}. This translation is done after
  16134. @samp{auth-username-translation} changes.
  16135. Defaults to @samp{"%Lu"}.
  16136. @end deftypevr
  16137. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  16138. If you want to allow master users to log in by specifying the master
  16139. username within the normal username string (i.e.@: not using SASL
  16140. mechanism's support for it), you can specify the separator character
  16141. here. The format is then <username><separator><master username>.
  16142. UW-IMAP uses @samp{*} as the separator, so that could be a good
  16143. choice.
  16144. Defaults to @samp{""}.
  16145. @end deftypevr
  16146. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  16147. Username to use for users logging in with ANONYMOUS SASL
  16148. mechanism.
  16149. Defaults to @samp{"anonymous"}.
  16150. @end deftypevr
  16151. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  16152. Maximum number of dovecot-auth worker processes. They're used to
  16153. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  16154. They're automatically created and destroyed as needed.
  16155. Defaults to @samp{30}.
  16156. @end deftypevr
  16157. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  16158. Host name to use in GSSAPI principal names. The default is to use
  16159. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  16160. allow all keytab entries.
  16161. Defaults to @samp{""}.
  16162. @end deftypevr
  16163. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  16164. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  16165. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  16166. need to change the auth service to run as root to be able to read this
  16167. file.
  16168. Defaults to @samp{""}.
  16169. @end deftypevr
  16170. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  16171. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  16172. and @samp{ntlm-auth} helper.
  16173. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  16174. Defaults to @samp{#f}.
  16175. @end deftypevr
  16176. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  16177. Path for Samba's @samp{ntlm-auth} helper binary.
  16178. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  16179. @end deftypevr
  16180. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  16181. Time to delay before replying to failed authentications.
  16182. Defaults to @samp{"2 secs"}.
  16183. @end deftypevr
  16184. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  16185. Require a valid SSL client certificate or the authentication
  16186. fails.
  16187. Defaults to @samp{#f}.
  16188. @end deftypevr
  16189. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  16190. Take the username from client's SSL certificate, using
  16191. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  16192. CommonName.
  16193. Defaults to @samp{#f}.
  16194. @end deftypevr
  16195. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  16196. List of wanted authentication mechanisms. Supported mechanisms are:
  16197. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  16198. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  16199. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  16200. @samp{disable-plaintext-auth} setting.
  16201. @end deftypevr
  16202. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  16203. List of IPs or hostnames to all director servers, including ourself.
  16204. Ports can be specified as ip:port. The default port is the same as what
  16205. director service's @samp{inet-listener} is using.
  16206. Defaults to @samp{()}.
  16207. @end deftypevr
  16208. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  16209. List of IPs or hostnames to all backend mail servers. Ranges are
  16210. allowed too, like 10.0.0.10-10.0.0.30.
  16211. Defaults to @samp{()}.
  16212. @end deftypevr
  16213. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  16214. How long to redirect users to a specific server after it no longer
  16215. has any connections.
  16216. Defaults to @samp{"15 min"}.
  16217. @end deftypevr
  16218. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  16219. How the username is translated before being hashed. Useful values
  16220. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  16221. are shared within domain.
  16222. Defaults to @samp{"%Lu"}.
  16223. @end deftypevr
  16224. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  16225. Log file to use for error messages. @samp{syslog} logs to syslog,
  16226. @samp{/dev/stderr} logs to stderr.
  16227. Defaults to @samp{"syslog"}.
  16228. @end deftypevr
  16229. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  16230. Log file to use for informational messages. Defaults to
  16231. @samp{log-path}.
  16232. Defaults to @samp{""}.
  16233. @end deftypevr
  16234. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  16235. Log file to use for debug messages. Defaults to
  16236. @samp{info-log-path}.
  16237. Defaults to @samp{""}.
  16238. @end deftypevr
  16239. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  16240. Syslog facility to use if you're logging to syslog. Usually if you
  16241. don't want to use @samp{mail}, you'll use local0..local7. Also other
  16242. standard facilities are supported.
  16243. Defaults to @samp{"mail"}.
  16244. @end deftypevr
  16245. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  16246. Log unsuccessful authentication attempts and the reasons why they
  16247. failed.
  16248. Defaults to @samp{#f}.
  16249. @end deftypevr
  16250. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  16251. In case of password mismatches, log the attempted password. Valid
  16252. values are no, plain and sha1. sha1 can be useful for detecting brute
  16253. force password attempts vs. user simply trying the same password over
  16254. and over again. You can also truncate the value to n chars by appending
  16255. ":n" (e.g.@: sha1:6).
  16256. Defaults to @samp{"no"}.
  16257. @end deftypevr
  16258. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  16259. Even more verbose logging for debugging purposes. Shows for example
  16260. SQL queries.
  16261. Defaults to @samp{#f}.
  16262. @end deftypevr
  16263. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  16264. In case of password mismatches, log the passwords and used scheme so
  16265. the problem can be debugged. Enabling this also enables
  16266. @samp{auth-debug}.
  16267. Defaults to @samp{#f}.
  16268. @end deftypevr
  16269. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  16270. Enable mail process debugging. This can help you figure out why
  16271. Dovecot isn't finding your mails.
  16272. Defaults to @samp{#f}.
  16273. @end deftypevr
  16274. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  16275. Show protocol level SSL errors.
  16276. Defaults to @samp{#f}.
  16277. @end deftypevr
  16278. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  16279. Prefix for each line written to log file. % codes are in
  16280. strftime(3) format.
  16281. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  16282. @end deftypevr
  16283. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  16284. List of elements we want to log. The elements which have a
  16285. non-empty variable value are joined together to form a comma-separated
  16286. string.
  16287. @end deftypevr
  16288. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  16289. Login log format. %s contains @samp{login-log-format-elements}
  16290. string, %$ contains the data we want to log.
  16291. Defaults to @samp{"%$: %s"}.
  16292. @end deftypevr
  16293. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  16294. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  16295. of possible variables you can use.
  16296. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  16297. @end deftypevr
  16298. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  16299. Format to use for logging mail deliveries. You can use variables:
  16300. @table @code
  16301. @item %$
  16302. Delivery status message (e.g.@: @samp{saved to INBOX})
  16303. @item %m
  16304. Message-ID
  16305. @item %s
  16306. Subject
  16307. @item %f
  16308. From address
  16309. @item %p
  16310. Physical size
  16311. @item %w
  16312. Virtual size.
  16313. @end table
  16314. Defaults to @samp{"msgid=%m: %$"}.
  16315. @end deftypevr
  16316. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  16317. Location for users' mailboxes. The default is empty, which means
  16318. that Dovecot tries to find the mailboxes automatically. This won't work
  16319. if the user doesn't yet have any mail, so you should explicitly tell
  16320. Dovecot the full location.
  16321. If you're using mbox, giving a path to the INBOX
  16322. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  16323. where the other mailboxes are kept. This is called the @emph{root mail
  16324. directory}, and it must be the first path given in the
  16325. @samp{mail-location} setting.
  16326. There are a few special variables you can use, e.g.:
  16327. @table @samp
  16328. @item %u
  16329. username
  16330. @item %n
  16331. user part in user@@domain, same as %u if there's no domain
  16332. @item %d
  16333. domain part in user@@domain, empty if there's no domain
  16334. @item %h
  16335. home director
  16336. @end table
  16337. See doc/wiki/Variables.txt for full list. Some examples:
  16338. @table @samp
  16339. @item maildir:~/Maildir
  16340. @item mbox:~/mail:INBOX=/var/mail/%u
  16341. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  16342. @end table
  16343. Defaults to @samp{""}.
  16344. @end deftypevr
  16345. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  16346. System user and group used to access mails. If you use multiple,
  16347. userdb can override these by returning uid or gid fields. You can use
  16348. either numbers or names. <doc/wiki/UserIds.txt>.
  16349. Defaults to @samp{""}.
  16350. @end deftypevr
  16351. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  16352. Defaults to @samp{""}.
  16353. @end deftypevr
  16354. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  16355. Group to enable temporarily for privileged operations. Currently
  16356. this is used only with INBOX when either its initial creation or
  16357. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  16358. @file{/var/mail}.
  16359. Defaults to @samp{""}.
  16360. @end deftypevr
  16361. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  16362. Grant access to these supplementary groups for mail processes.
  16363. Typically these are used to set up access to shared mailboxes. Note
  16364. that it may be dangerous to set these if users can create symlinks
  16365. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  16366. could allow a user to delete others' mailboxes, or @code{ln -s
  16367. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  16368. @samp{""}.
  16369. @end deftypevr
  16370. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  16371. Allow full file system access to clients. There's no access checks
  16372. other than what the operating system does for the active UID/GID@. It
  16373. works with both maildir and mboxes, allowing you to prefix mailboxes
  16374. names with e.g.@: @file{/path/} or @file{~user/}.
  16375. Defaults to @samp{#f}.
  16376. @end deftypevr
  16377. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  16378. Don't use @code{mmap()} at all. This is required if you store indexes to
  16379. shared file systems (NFS or clustered file system).
  16380. Defaults to @samp{#f}.
  16381. @end deftypevr
  16382. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  16383. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  16384. supports @samp{O_EXCL} since version 3, so this should be safe to use
  16385. nowadays by default.
  16386. Defaults to @samp{#t}.
  16387. @end deftypevr
  16388. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  16389. When to use fsync() or fdatasync() calls:
  16390. @table @code
  16391. @item optimized
  16392. Whenever necessary to avoid losing important data
  16393. @item always
  16394. Useful with e.g.@: NFS when @code{write()}s are delayed
  16395. @item never
  16396. Never use it (best performance, but crashes can lose data).
  16397. @end table
  16398. Defaults to @samp{"optimized"}.
  16399. @end deftypevr
  16400. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  16401. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  16402. NFS caches whenever needed. If you're using only a single mail server
  16403. this isn't needed.
  16404. Defaults to @samp{#f}.
  16405. @end deftypevr
  16406. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  16407. Mail index files also exist in NFS@. Setting this to yes requires
  16408. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  16409. Defaults to @samp{#f}.
  16410. @end deftypevr
  16411. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  16412. Locking method for index files. Alternatives are fcntl, flock and
  16413. dotlock. Dotlocking uses some tricks which may create more disk I/O
  16414. than other locking methods. NFS users: flock doesn't work, remember to
  16415. change @samp{mmap-disable}.
  16416. Defaults to @samp{"fcntl"}.
  16417. @end deftypevr
  16418. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  16419. Directory in which LDA/LMTP temporarily stores incoming mails >128
  16420. kB.
  16421. Defaults to @samp{"/tmp"}.
  16422. @end deftypevr
  16423. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  16424. Valid UID range for users. This is mostly to make sure that users can't
  16425. log in as daemons or other system users. Note that denying root logins is
  16426. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  16427. is set to 0.
  16428. Defaults to @samp{500}.
  16429. @end deftypevr
  16430. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  16431. Defaults to @samp{0}.
  16432. @end deftypevr
  16433. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  16434. Valid GID range for users. Users having non-valid GID as primary group ID
  16435. aren't allowed to log in. If user belongs to supplementary groups with
  16436. non-valid GIDs, those groups are not set.
  16437. Defaults to @samp{1}.
  16438. @end deftypevr
  16439. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  16440. Defaults to @samp{0}.
  16441. @end deftypevr
  16442. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  16443. Maximum allowed length for mail keyword name. It's only forced when
  16444. trying to create new keywords.
  16445. Defaults to @samp{50}.
  16446. @end deftypevr
  16447. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  16448. List of directories under which chrooting is allowed for mail
  16449. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  16450. too). This setting doesn't affect @samp{login-chroot}
  16451. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  16452. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  16453. which local users can modify, that may lead to root exploit. Usually
  16454. this should be done only if you don't allow shell access for users.
  16455. <doc/wiki/Chrooting.txt>.
  16456. Defaults to @samp{()}.
  16457. @end deftypevr
  16458. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  16459. Default chroot directory for mail processes. This can be overridden
  16460. for specific users in user database by giving @samp{/./} in user's home
  16461. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  16462. there is no real need to do chrooting, Dovecot doesn't allow users to
  16463. access files outside their mail directory anyway. If your home
  16464. directories are prefixed with the chroot directory, append @samp{/.} to
  16465. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  16466. Defaults to @samp{""}.
  16467. @end deftypevr
  16468. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  16469. UNIX socket path to master authentication server to find users.
  16470. This is used by imap (for shared users) and lda.
  16471. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16472. @end deftypevr
  16473. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  16474. Directory where to look up mail plugins.
  16475. Defaults to @samp{"/usr/lib/dovecot"}.
  16476. @end deftypevr
  16477. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  16478. List of plugins to load for all services. Plugins specific to IMAP,
  16479. LDA, etc.@: are added to this list in their own .conf files.
  16480. Defaults to @samp{()}.
  16481. @end deftypevr
  16482. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  16483. The minimum number of mails in a mailbox before updates are done to
  16484. cache file. This allows optimizing Dovecot's behavior to do less disk
  16485. writes at the cost of more disk reads.
  16486. Defaults to @samp{0}.
  16487. @end deftypevr
  16488. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  16489. When IDLE command is running, mailbox is checked once in a while to
  16490. see if there are any new mails or other changes. This setting defines
  16491. the minimum time to wait between those checks. Dovecot can also use
  16492. dnotify, inotify and kqueue to find out immediately when changes
  16493. occur.
  16494. Defaults to @samp{"30 secs"}.
  16495. @end deftypevr
  16496. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  16497. Save mails with CR+LF instead of plain LF@. This makes sending those
  16498. mails take less CPU, especially with sendfile() syscall with Linux and
  16499. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  16500. slower. Also note that if other software reads the mboxes/maildirs,
  16501. they may handle the extra CRs wrong and cause problems.
  16502. Defaults to @samp{#f}.
  16503. @end deftypevr
  16504. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  16505. By default LIST command returns all entries in maildir beginning
  16506. with a dot. Enabling this option makes Dovecot return only entries
  16507. which are directories. This is done by stat()ing each entry, so it
  16508. causes more disk I/O.
  16509. (For systems setting struct @samp{dirent->d_type} this check is free
  16510. and it's done always regardless of this setting).
  16511. Defaults to @samp{#f}.
  16512. @end deftypevr
  16513. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  16514. When copying a message, do it with hard links whenever possible.
  16515. This makes the performance much better, and it's unlikely to have any
  16516. side effects.
  16517. Defaults to @samp{#t}.
  16518. @end deftypevr
  16519. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  16520. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  16521. directory only when its mtime changes unexpectedly or when we can't find
  16522. the mail otherwise.
  16523. Defaults to @samp{#f}.
  16524. @end deftypevr
  16525. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  16526. Which locking methods to use for locking mbox. There are four
  16527. available:
  16528. @table @code
  16529. @item dotlock
  16530. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  16531. solution. If you want to use /var/mail/ like directory, the users will
  16532. need write access to that directory.
  16533. @item dotlock-try
  16534. Same as dotlock, but if it fails because of permissions or because there
  16535. isn't enough disk space, just skip it.
  16536. @item fcntl
  16537. Use this if possible. Works with NFS too if lockd is used.
  16538. @item flock
  16539. May not exist in all systems. Doesn't work with NFS.
  16540. @item lockf
  16541. May not exist in all systems. Doesn't work with NFS.
  16542. @end table
  16543. You can use multiple locking methods; if you do the order they're declared
  16544. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  16545. locking methods as well. Some operating systems don't allow using some of
  16546. them simultaneously.
  16547. @end deftypevr
  16548. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  16549. @end deftypevr
  16550. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  16551. Maximum time to wait for lock (all of them) before aborting.
  16552. Defaults to @samp{"5 mins"}.
  16553. @end deftypevr
  16554. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  16555. If dotlock exists but the mailbox isn't modified in any way,
  16556. override the lock file after this much time.
  16557. Defaults to @samp{"2 mins"}.
  16558. @end deftypevr
  16559. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  16560. When mbox changes unexpectedly we have to fully read it to find out
  16561. what changed. If the mbox is large this can take a long time. Since
  16562. the change is usually just a newly appended mail, it'd be faster to
  16563. simply read the new mails. If this setting is enabled, Dovecot does
  16564. this but still safely fallbacks to re-reading the whole mbox file
  16565. whenever something in mbox isn't how it's expected to be. The only real
  16566. downside to this setting is that if some other MUA changes message
  16567. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  16568. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  16569. Defaults to @samp{#t}.
  16570. @end deftypevr
  16571. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  16572. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  16573. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  16574. @samp{mbox-dirty-syncs} is ignored.
  16575. Defaults to @samp{#f}.
  16576. @end deftypevr
  16577. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  16578. Delay writing mbox headers until doing a full write sync (EXPUNGE
  16579. and CHECK commands and when closing the mailbox). This is especially
  16580. useful for POP3 where clients often delete all mails. The downside is
  16581. that our changes aren't immediately visible to other MUAs.
  16582. Defaults to @samp{#t}.
  16583. @end deftypevr
  16584. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  16585. If mbox size is smaller than this (e.g.@: 100k), don't write index
  16586. files. If an index file already exists it's still read, just not
  16587. updated.
  16588. Defaults to @samp{0}.
  16589. @end deftypevr
  16590. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  16591. Maximum dbox file size until it's rotated.
  16592. Defaults to @samp{10000000}.
  16593. @end deftypevr
  16594. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  16595. Maximum dbox file age until it's rotated. Typically in days. Day
  16596. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  16597. disabled.
  16598. Defaults to @samp{"1d"}.
  16599. @end deftypevr
  16600. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  16601. When creating new mdbox files, immediately preallocate their size to
  16602. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  16603. with some file systems (ext4, xfs).
  16604. Defaults to @samp{#f}.
  16605. @end deftypevr
  16606. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  16607. sdbox and mdbox support saving mail attachments to external files,
  16608. which also allows single instance storage for them. Other backends
  16609. don't support this for now.
  16610. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  16611. Directory root where to store mail attachments. Disabled, if empty.
  16612. Defaults to @samp{""}.
  16613. @end deftypevr
  16614. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  16615. Attachments smaller than this aren't saved externally. It's also
  16616. possible to write a plugin to disable saving specific attachments
  16617. externally.
  16618. Defaults to @samp{128000}.
  16619. @end deftypevr
  16620. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  16621. File system backend to use for saving attachments:
  16622. @table @code
  16623. @item posix
  16624. No SiS done by Dovecot (but this might help FS's own deduplication)
  16625. @item sis posix
  16626. SiS with immediate byte-by-byte comparison during saving
  16627. @item sis-queue posix
  16628. SiS with delayed comparison and deduplication.
  16629. @end table
  16630. Defaults to @samp{"sis posix"}.
  16631. @end deftypevr
  16632. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  16633. Hash format to use in attachment filenames. You can add any text and
  16634. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  16635. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  16636. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  16637. Defaults to @samp{"%@{sha1@}"}.
  16638. @end deftypevr
  16639. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  16640. Defaults to @samp{100}.
  16641. @end deftypevr
  16642. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  16643. Defaults to @samp{1000}.
  16644. @end deftypevr
  16645. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  16646. Default VSZ (virtual memory size) limit for service processes.
  16647. This is mainly intended to catch and kill processes that leak memory
  16648. before they eat up everything.
  16649. Defaults to @samp{256000000}.
  16650. @end deftypevr
  16651. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  16652. Login user is internally used by login processes. This is the most
  16653. untrusted user in Dovecot system. It shouldn't have access to anything
  16654. at all.
  16655. Defaults to @samp{"dovenull"}.
  16656. @end deftypevr
  16657. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  16658. Internal user is used by unprivileged processes. It should be
  16659. separate from login user, so that login processes can't disturb other
  16660. processes.
  16661. Defaults to @samp{"dovecot"}.
  16662. @end deftypevr
  16663. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  16664. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  16665. Defaults to @samp{"required"}.
  16666. @end deftypevr
  16667. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  16668. PEM encoded X.509 SSL/TLS certificate (public key).
  16669. Defaults to @samp{"</etc/dovecot/default.pem"}.
  16670. @end deftypevr
  16671. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  16672. PEM encoded SSL/TLS private key. The key is opened before
  16673. dropping root privileges, so keep the key file unreadable by anyone but
  16674. root.
  16675. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  16676. @end deftypevr
  16677. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  16678. If key file is password protected, give the password here.
  16679. Alternatively give it when starting dovecot with -p parameter. Since
  16680. this file is often world-readable, you may want to place this setting
  16681. instead to a different.
  16682. Defaults to @samp{""}.
  16683. @end deftypevr
  16684. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  16685. PEM encoded trusted certificate authority. Set this only if you
  16686. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  16687. contain the CA certificate(s) followed by the matching
  16688. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  16689. Defaults to @samp{""}.
  16690. @end deftypevr
  16691. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  16692. Require that CRL check succeeds for client certificates.
  16693. Defaults to @samp{#t}.
  16694. @end deftypevr
  16695. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  16696. Request client to send a certificate. If you also want to require
  16697. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  16698. Defaults to @samp{#f}.
  16699. @end deftypevr
  16700. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  16701. Which field from certificate to use for username. commonName and
  16702. x500UniqueIdentifier are the usual choices. You'll also need to set
  16703. @samp{auth-ssl-username-from-cert? #t}.
  16704. Defaults to @samp{"commonName"}.
  16705. @end deftypevr
  16706. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  16707. Minimum SSL protocol version to accept.
  16708. Defaults to @samp{"TLSv1"}.
  16709. @end deftypevr
  16710. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  16711. SSL ciphers to use.
  16712. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  16713. @end deftypevr
  16714. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  16715. SSL crypto device to use, for valid values run "openssl engine".
  16716. Defaults to @samp{""}.
  16717. @end deftypevr
  16718. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  16719. Address to use when sending rejection mails.
  16720. %d expands to recipient domain.
  16721. Defaults to @samp{"postmaster@@%d"}.
  16722. @end deftypevr
  16723. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  16724. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  16725. and in LMTP replies. Default is the system's real hostname@@domain.
  16726. Defaults to @samp{""}.
  16727. @end deftypevr
  16728. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  16729. If user is over quota, return with temporary failure instead of
  16730. bouncing the mail.
  16731. Defaults to @samp{#f}.
  16732. @end deftypevr
  16733. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  16734. Binary to use for sending mails.
  16735. Defaults to @samp{"/usr/sbin/sendmail"}.
  16736. @end deftypevr
  16737. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  16738. If non-empty, send mails via this SMTP host[:port] instead of
  16739. sendmail.
  16740. Defaults to @samp{""}.
  16741. @end deftypevr
  16742. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  16743. Subject: header to use for rejection mails. You can use the same
  16744. variables as for @samp{rejection-reason} below.
  16745. Defaults to @samp{"Rejected: %s"}.
  16746. @end deftypevr
  16747. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  16748. Human readable error message for rejection mails. You can use
  16749. variables:
  16750. @table @code
  16751. @item %n
  16752. CRLF
  16753. @item %r
  16754. reason
  16755. @item %s
  16756. original subject
  16757. @item %t
  16758. recipient
  16759. @end table
  16760. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  16761. @end deftypevr
  16762. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  16763. Delimiter character between local-part and detail in email
  16764. address.
  16765. Defaults to @samp{"+"}.
  16766. @end deftypevr
  16767. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  16768. Header where the original recipient address (SMTP's RCPT TO:
  16769. address) is taken from if not available elsewhere. With dovecot-lda -a
  16770. parameter overrides this. A commonly used header for this is
  16771. X-Original-To.
  16772. Defaults to @samp{""}.
  16773. @end deftypevr
  16774. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  16775. Should saving a mail to a nonexistent mailbox automatically create
  16776. it?.
  16777. Defaults to @samp{#f}.
  16778. @end deftypevr
  16779. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  16780. Should automatically created mailboxes be also automatically
  16781. subscribed?.
  16782. Defaults to @samp{#f}.
  16783. @end deftypevr
  16784. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  16785. Maximum IMAP command line length. Some clients generate very long
  16786. command lines with huge mailboxes, so you may need to raise this if you
  16787. get "Too long argument" or "IMAP command line too large" errors
  16788. often.
  16789. Defaults to @samp{64000}.
  16790. @end deftypevr
  16791. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  16792. IMAP logout format string:
  16793. @table @code
  16794. @item %i
  16795. total number of bytes read from client
  16796. @item %o
  16797. total number of bytes sent to client.
  16798. @end table
  16799. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  16800. Defaults to @samp{"in=%i out=%o deleted=%@{deleted@} expunged=%@{expunged@} trashed=%@{trashed@} hdr_count=%@{fetch_hdr_count@} hdr_bytes=%@{fetch_hdr_bytes@} body_count=%@{fetch_body_count@} body_bytes=%@{fetch_body_bytes@}"}.
  16801. @end deftypevr
  16802. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  16803. Override the IMAP CAPABILITY response. If the value begins with '+',
  16804. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  16805. Defaults to @samp{""}.
  16806. @end deftypevr
  16807. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  16808. How long to wait between "OK Still here" notifications when client
  16809. is IDLEing.
  16810. Defaults to @samp{"2 mins"}.
  16811. @end deftypevr
  16812. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  16813. ID field names and values to send to clients. Using * as the value
  16814. makes Dovecot use the default value. The following fields have default
  16815. values currently: name, version, os, os-version, support-url,
  16816. support-email.
  16817. Defaults to @samp{""}.
  16818. @end deftypevr
  16819. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  16820. ID fields sent by client to log. * means everything.
  16821. Defaults to @samp{""}.
  16822. @end deftypevr
  16823. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  16824. Workarounds for various client bugs:
  16825. @table @code
  16826. @item delay-newmail
  16827. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  16828. CHECK commands. Some clients ignore them otherwise, for example OSX
  16829. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  16830. may show user "Message no longer in server" errors. Note that OE6
  16831. still breaks even with this workaround if synchronization is set to
  16832. "Headers Only".
  16833. @item tb-extra-mailbox-sep
  16834. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  16835. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  16836. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  16837. @item tb-lsub-flags
  16838. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  16839. This makes Thunderbird realize they aren't selectable and show them
  16840. greyed out, instead of only later giving "not selectable" popup error.
  16841. @end table
  16842. Defaults to @samp{()}.
  16843. @end deftypevr
  16844. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  16845. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  16846. Defaults to @samp{""}.
  16847. @end deftypevr
  16848. Whew! Lots of configuration options. The nice thing about it though is
  16849. that Guix has a complete interface to Dovecot's configuration
  16850. language. This allows not only a nice way to declare configurations,
  16851. but also offers reflective capabilities as well: users can write code to
  16852. inspect and transform configurations from within Scheme.
  16853. However, it could be that you just want to get a @code{dovecot.conf} up
  16854. and running. In that case, you can pass an
  16855. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  16856. @code{dovecot-service}. As its name indicates, an opaque configuration
  16857. does not have easy reflective capabilities.
  16858. Available @code{opaque-dovecot-configuration} fields are:
  16859. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  16860. The dovecot package.
  16861. @end deftypevr
  16862. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  16863. The contents of the @code{dovecot.conf}, as a string.
  16864. @end deftypevr
  16865. For example, if your @code{dovecot.conf} is just the empty string, you
  16866. could instantiate a dovecot service like this:
  16867. @lisp
  16868. (dovecot-service #:config
  16869. (opaque-dovecot-configuration
  16870. (string "")))
  16871. @end lisp
  16872. @subsubheading OpenSMTPD Service
  16873. @deffn {Scheme Variable} opensmtpd-service-type
  16874. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  16875. service, whose value should be an @code{opensmtpd-configuration} object
  16876. as in this example:
  16877. @lisp
  16878. (service opensmtpd-service-type
  16879. (opensmtpd-configuration
  16880. (config-file (local-file "./my-smtpd.conf"))))
  16881. @end lisp
  16882. @end deffn
  16883. @deftp {Data Type} opensmtpd-configuration
  16884. Data type representing the configuration of opensmtpd.
  16885. @table @asis
  16886. @item @code{package} (default: @var{opensmtpd})
  16887. Package object of the OpenSMTPD SMTP server.
  16888. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  16889. File-like object of the OpenSMTPD configuration file to use. By default
  16890. it listens on the loopback network interface, and allows for mail from
  16891. users and daemons on the local machine, as well as permitting email to
  16892. remote servers. Run @command{man smtpd.conf} for more information.
  16893. @end table
  16894. @end deftp
  16895. @subsubheading Exim Service
  16896. @cindex mail transfer agent (MTA)
  16897. @cindex MTA (mail transfer agent)
  16898. @cindex SMTP
  16899. @deffn {Scheme Variable} exim-service-type
  16900. This is the type of the @uref{https://exim.org, Exim} mail transfer
  16901. agent (MTA), whose value should be an @code{exim-configuration} object
  16902. as in this example:
  16903. @lisp
  16904. (service exim-service-type
  16905. (exim-configuration
  16906. (config-file (local-file "./my-exim.conf"))))
  16907. @end lisp
  16908. @end deffn
  16909. In order to use an @code{exim-service-type} service you must also have a
  16910. @code{mail-aliases-service-type} service present in your
  16911. @code{operating-system} (even if it has no aliases).
  16912. @deftp {Data Type} exim-configuration
  16913. Data type representing the configuration of exim.
  16914. @table @asis
  16915. @item @code{package} (default: @var{exim})
  16916. Package object of the Exim server.
  16917. @item @code{config-file} (default: @code{#f})
  16918. File-like object of the Exim configuration file to use. If its value is
  16919. @code{#f} then use the default configuration file from the package
  16920. provided in @code{package}. The resulting configuration file is loaded
  16921. after setting the @code{exim_user} and @code{exim_group} configuration
  16922. variables.
  16923. @end table
  16924. @end deftp
  16925. @subsubheading Getmail service
  16926. @cindex IMAP
  16927. @cindex POP
  16928. @deffn {Scheme Variable} getmail-service-type
  16929. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  16930. mail retriever, whose value should be an @code{getmail-configuration}.
  16931. @end deffn
  16932. Available @code{getmail-configuration} fields are:
  16933. @deftypevr {@code{getmail-configuration} parameter} symbol name
  16934. A symbol to identify the getmail service.
  16935. Defaults to @samp{"unset"}.
  16936. @end deftypevr
  16937. @deftypevr {@code{getmail-configuration} parameter} package package
  16938. The getmail package to use.
  16939. @end deftypevr
  16940. @deftypevr {@code{getmail-configuration} parameter} string user
  16941. The user to run getmail as.
  16942. Defaults to @samp{"getmail"}.
  16943. @end deftypevr
  16944. @deftypevr {@code{getmail-configuration} parameter} string group
  16945. The group to run getmail as.
  16946. Defaults to @samp{"getmail"}.
  16947. @end deftypevr
  16948. @deftypevr {@code{getmail-configuration} parameter} string directory
  16949. The getmail directory to use.
  16950. Defaults to @samp{"/var/lib/getmail/default"}.
  16951. @end deftypevr
  16952. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  16953. The getmail configuration file to use.
  16954. Available @code{getmail-configuration-file} fields are:
  16955. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  16956. What mail account to retrieve mail from, and how to access that account.
  16957. Available @code{getmail-retriever-configuration} fields are:
  16958. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  16959. The type of mail retriever to use. Valid values include @samp{passwd}
  16960. and @samp{static}.
  16961. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  16962. @end deftypevr
  16963. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  16964. Username to login to the mail server with.
  16965. Defaults to @samp{unset}.
  16966. @end deftypevr
  16967. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  16968. Username to login to the mail server with.
  16969. Defaults to @samp{unset}.
  16970. @end deftypevr
  16971. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  16972. Port number to connect to.
  16973. Defaults to @samp{#f}.
  16974. @end deftypevr
  16975. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  16976. Override fields from passwd.
  16977. Defaults to @samp{""}.
  16978. @end deftypevr
  16979. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  16980. Override fields from passwd.
  16981. Defaults to @samp{()}.
  16982. @end deftypevr
  16983. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  16984. PEM-formatted key file to use for the TLS negotiation.
  16985. Defaults to @samp{""}.
  16986. @end deftypevr
  16987. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  16988. PEM-formatted certificate file to use for the TLS negotiation.
  16989. Defaults to @samp{""}.
  16990. @end deftypevr
  16991. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  16992. CA certificates to use.
  16993. Defaults to @samp{""}.
  16994. @end deftypevr
  16995. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  16996. Extra retriever parameters.
  16997. Defaults to @samp{()}.
  16998. @end deftypevr
  16999. @end deftypevr
  17000. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  17001. What to do with retrieved messages.
  17002. Available @code{getmail-destination-configuration} fields are:
  17003. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  17004. The type of mail destination. Valid values include @samp{Maildir},
  17005. @samp{Mboxrd} and @samp{MDA_external}.
  17006. Defaults to @samp{unset}.
  17007. @end deftypevr
  17008. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  17009. The path option for the mail destination. The behaviour depends on the
  17010. chosen type.
  17011. Defaults to @samp{""}.
  17012. @end deftypevr
  17013. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  17014. Extra destination parameters
  17015. Defaults to @samp{()}.
  17016. @end deftypevr
  17017. @end deftypevr
  17018. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  17019. Configure getmail.
  17020. Available @code{getmail-options-configuration} fields are:
  17021. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  17022. If set to @samp{0}, getmail will only print warnings and errors. A
  17023. value of @samp{1} means that messages will be printed about retrieving
  17024. and deleting messages. If set to @samp{2}, getmail will print messages
  17025. about each of it's actions.
  17026. Defaults to @samp{1}.
  17027. @end deftypevr
  17028. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  17029. If true, getmail will retrieve all available messages. Otherwise it
  17030. will only retrieve messages it hasn't seen previously.
  17031. Defaults to @samp{#t}.
  17032. @end deftypevr
  17033. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  17034. If set to true, messages will be deleted from the server after
  17035. retrieving and successfully delivering them. Otherwise, messages will
  17036. be left on the server.
  17037. Defaults to @samp{#f}.
  17038. @end deftypevr
  17039. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  17040. Getmail will delete messages this number of days after seeing them, if
  17041. they have been delivered. This means messages will be left on the
  17042. server this number of days after delivering them. A value of @samp{0}
  17043. disabled this feature.
  17044. Defaults to @samp{0}.
  17045. @end deftypevr
  17046. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  17047. Delete messages larger than this of bytes after retrieving them, even if
  17048. the delete and delete-after options are disabled. A value of @samp{0}
  17049. disables this feature.
  17050. Defaults to @samp{0}.
  17051. @end deftypevr
  17052. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  17053. Retrieve messages totalling up to this number of bytes before closing
  17054. the session with the server. A value of @samp{0} disables this feature.
  17055. Defaults to @samp{0}.
  17056. @end deftypevr
  17057. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  17058. Don't retrieve messages larger than this number of bytes. A value of
  17059. @samp{0} disables this feature.
  17060. Defaults to @samp{0}.
  17061. @end deftypevr
  17062. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  17063. If true, getmail will add a Delivered-To header to messages.
  17064. Defaults to @samp{#t}.
  17065. @end deftypevr
  17066. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  17067. If set, getmail adds a Received header to the messages.
  17068. Defaults to @samp{#t}.
  17069. @end deftypevr
  17070. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  17071. Getmail will record a log of its actions to the named file. A value of
  17072. @samp{""} disables this feature.
  17073. Defaults to @samp{""}.
  17074. @end deftypevr
  17075. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  17076. If true, getmail will record a log of its actions using the system
  17077. logger.
  17078. Defaults to @samp{#f}.
  17079. @end deftypevr
  17080. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  17081. If true, getmail will log information about messages not retrieved and
  17082. the reason for not retrieving them, as well as starting and ending
  17083. information lines.
  17084. Defaults to @samp{#f}.
  17085. @end deftypevr
  17086. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  17087. Extra options to include.
  17088. Defaults to @samp{()}.
  17089. @end deftypevr
  17090. @end deftypevr
  17091. @end deftypevr
  17092. @deftypevr {@code{getmail-configuration} parameter} list idle
  17093. A list of mailboxes that getmail should wait on the server for new mail
  17094. notifications. This depends on the server supporting the IDLE
  17095. extension.
  17096. Defaults to @samp{()}.
  17097. @end deftypevr
  17098. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  17099. Environment variables to set for getmail.
  17100. Defaults to @samp{()}.
  17101. @end deftypevr
  17102. @subsubheading Mail Aliases Service
  17103. @cindex email aliases
  17104. @cindex aliases, for email addresses
  17105. @deffn {Scheme Variable} mail-aliases-service-type
  17106. This is the type of the service which provides @code{/etc/aliases},
  17107. specifying how to deliver mail to users on this system.
  17108. @lisp
  17109. (service mail-aliases-service-type
  17110. '(("postmaster" "bob")
  17111. ("bob" "bob@@example.com" "bob@@example2.com")))
  17112. @end lisp
  17113. @end deffn
  17114. The configuration for a @code{mail-aliases-service-type} service is an
  17115. association list denoting how to deliver mail that comes to this
  17116. system. Each entry is of the form @code{(alias addresses ...)}, with
  17117. @code{alias} specifying the local alias and @code{addresses} specifying
  17118. where to deliver this user's mail.
  17119. The aliases aren't required to exist as users on the local system. In
  17120. the above example, there doesn't need to be a @code{postmaster} entry in
  17121. the @code{operating-system}'s @code{user-accounts} in order to deliver
  17122. the @code{postmaster} mail to @code{bob} (which subsequently would
  17123. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  17124. @subsubheading GNU Mailutils IMAP4 Daemon
  17125. @cindex GNU Mailutils IMAP4 Daemon
  17126. @deffn {Scheme Variable} imap4d-service-type
  17127. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  17128. mailutils, GNU Mailutils Manual}), whose value should be an
  17129. @code{imap4d-configuration} object as in this example:
  17130. @lisp
  17131. (service imap4d-service-type
  17132. (imap4d-configuration
  17133. (config-file (local-file "imap4d.conf"))))
  17134. @end lisp
  17135. @end deffn
  17136. @deftp {Data Type} imap4d-configuration
  17137. Data type representing the configuration of @command{imap4d}.
  17138. @table @asis
  17139. @item @code{package} (default: @code{mailutils})
  17140. The package that provides @command{imap4d}.
  17141. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  17142. File-like object of the configuration file to use, by default it will listen
  17143. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  17144. Mailutils Manual}, for details.
  17145. @end table
  17146. @end deftp
  17147. @subsubheading Radicale Service
  17148. @cindex CalDAV
  17149. @cindex CardDAV
  17150. @deffn {Scheme Variable} radicale-service-type
  17151. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  17152. server whose value should be a @code{radicale-configuration}.
  17153. @end deffn
  17154. @deftp {Data Type} radicale-configuration
  17155. Data type representing the configuration of @command{radicale}.
  17156. @table @asis
  17157. @item @code{package} (default: @code{radicale})
  17158. The package that provides @command{radicale}.
  17159. @item @code{config-file} (default: @code{%default-radicale-config-file})
  17160. File-like object of the configuration file to use, by default it will listen
  17161. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  17162. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  17163. @end table
  17164. @end deftp
  17165. @node Messaging Services
  17166. @subsection Messaging Services
  17167. @cindex messaging
  17168. @cindex jabber
  17169. @cindex XMPP
  17170. The @code{(gnu services messaging)} module provides Guix service
  17171. definitions for messaging services. Currently it provides the following
  17172. services:
  17173. @subsubheading Prosody Service
  17174. @deffn {Scheme Variable} prosody-service-type
  17175. This is the type for the @uref{https://prosody.im, Prosody XMPP
  17176. communication server}. Its value must be a @code{prosody-configuration}
  17177. record as in this example:
  17178. @lisp
  17179. (service prosody-service-type
  17180. (prosody-configuration
  17181. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  17182. (int-components
  17183. (list
  17184. (int-component-configuration
  17185. (hostname "conference.example.net")
  17186. (plugin "muc")
  17187. (mod-muc (mod-muc-configuration)))))
  17188. (virtualhosts
  17189. (list
  17190. (virtualhost-configuration
  17191. (domain "example.net"))))))
  17192. @end lisp
  17193. See below for details about @code{prosody-configuration}.
  17194. @end deffn
  17195. By default, Prosody does not need much configuration. Only one
  17196. @code{virtualhosts} field is needed: it specifies the domain you wish
  17197. Prosody to serve.
  17198. You can perform various sanity checks on the generated configuration
  17199. with the @code{prosodyctl check} command.
  17200. Prosodyctl will also help you to import certificates from the
  17201. @code{letsencrypt} directory so that the @code{prosody} user can access
  17202. them. See @url{https://prosody.im/doc/letsencrypt}.
  17203. @example
  17204. prosodyctl --root cert import /etc/letsencrypt/live
  17205. @end example
  17206. The available configuration parameters follow. Each parameter
  17207. definition is preceded by its type; for example, @samp{string-list foo}
  17208. indicates that the @code{foo} parameter should be specified as a list of
  17209. strings. Types starting with @code{maybe-} denote parameters that won't
  17210. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  17211. There is also a way to specify the configuration as a string, if you
  17212. have an old @code{prosody.cfg.lua} file that you want to port over from
  17213. some other system; see the end for more details.
  17214. The @code{file-object} type designates either a file-like object
  17215. (@pxref{G-Expressions, file-like objects}) or a file name.
  17216. @c The following documentation was initially generated by
  17217. @c (generate-documentation) in (gnu services messaging). Manually maintained
  17218. @c documentation is better, so we shouldn't hesitate to edit below as
  17219. @c needed. However if the change you want to make to this documentation
  17220. @c can be done in an automated way, it's probably easier to change
  17221. @c (generate-documentation) than to make it below and have to deal with
  17222. @c the churn as Prosody updates.
  17223. Available @code{prosody-configuration} fields are:
  17224. @deftypevr {@code{prosody-configuration} parameter} package prosody
  17225. The Prosody package.
  17226. @end deftypevr
  17227. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  17228. Location of the Prosody data storage directory. See
  17229. @url{https://prosody.im/doc/configure}.
  17230. Defaults to @samp{"/var/lib/prosody"}.
  17231. @end deftypevr
  17232. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  17233. Additional plugin directories. They are searched in all the specified
  17234. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  17235. Defaults to @samp{()}.
  17236. @end deftypevr
  17237. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  17238. Every virtual host and component needs a certificate so that clients and
  17239. servers can securely verify its identity. Prosody will automatically load
  17240. certificates/keys from the directory specified here.
  17241. Defaults to @samp{"/etc/prosody/certs"}.
  17242. @end deftypevr
  17243. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  17244. This is a list of accounts that are admins for the server. Note that you
  17245. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  17246. @url{https://prosody.im/doc/creating_accounts}.
  17247. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  17248. Defaults to @samp{()}.
  17249. @end deftypevr
  17250. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  17251. Enable use of libevent for better performance under high load. See
  17252. @url{https://prosody.im/doc/libevent}.
  17253. Defaults to @samp{#f}.
  17254. @end deftypevr
  17255. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  17256. This is the list of modules Prosody will load on startup. It looks for
  17257. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  17258. Documentation on modules can be found at:
  17259. @url{https://prosody.im/doc/modules}.
  17260. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  17261. @end deftypevr
  17262. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  17263. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  17264. should you want to disable them then add them to this list.
  17265. Defaults to @samp{()}.
  17266. @end deftypevr
  17267. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  17268. Path to a text file where the shared groups are defined. If this path is
  17269. empty then @samp{mod_groups} does nothing. See
  17270. @url{https://prosody.im/doc/modules/mod_groups}.
  17271. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  17272. @end deftypevr
  17273. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  17274. Disable account creation by default, for security. See
  17275. @url{https://prosody.im/doc/creating_accounts}.
  17276. Defaults to @samp{#f}.
  17277. @end deftypevr
  17278. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  17279. These are the SSL/TLS-related settings. Most of them are disabled so to
  17280. use Prosody's defaults. If you do not completely understand these options, do
  17281. not add them to your config, it is easy to lower the security of your server
  17282. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  17283. Available @code{ssl-configuration} fields are:
  17284. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  17285. This determines what handshake to use.
  17286. @end deftypevr
  17287. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  17288. Path to your private key file.
  17289. @end deftypevr
  17290. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  17291. Path to your certificate file.
  17292. @end deftypevr
  17293. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  17294. Path to directory containing root certificates that you wish Prosody to
  17295. trust when verifying the certificates of remote servers.
  17296. Defaults to @samp{"/etc/ssl/certs"}.
  17297. @end deftypevr
  17298. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  17299. Path to a file containing root certificates that you wish Prosody to trust.
  17300. Similar to @code{capath} but with all certificates concatenated together.
  17301. @end deftypevr
  17302. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  17303. A list of verification options (these mostly map to OpenSSL's
  17304. @code{set_verify()} flags).
  17305. @end deftypevr
  17306. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  17307. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  17308. @code{set_options()}. For a full list of options available in LuaSec, see the
  17309. LuaSec source.
  17310. @end deftypevr
  17311. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  17312. How long a chain of certificate authorities to check when looking for a
  17313. trusted root certificate.
  17314. @end deftypevr
  17315. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  17316. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  17317. clients, and in what order.
  17318. @end deftypevr
  17319. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  17320. A path to a file containing parameters for Diffie-Hellman key exchange. You
  17321. can create such a file with:
  17322. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  17323. @end deftypevr
  17324. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  17325. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  17326. @samp{"secp384r1"}.
  17327. @end deftypevr
  17328. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  17329. A list of ``extra'' verification options.
  17330. @end deftypevr
  17331. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  17332. Password for encrypted private keys.
  17333. @end deftypevr
  17334. @end deftypevr
  17335. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  17336. Whether to force all client-to-server connections to be encrypted or not.
  17337. See @url{https://prosody.im/doc/modules/mod_tls}.
  17338. Defaults to @samp{#f}.
  17339. @end deftypevr
  17340. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  17341. Set of mechanisms that will never be offered. See
  17342. @url{https://prosody.im/doc/modules/mod_saslauth}.
  17343. Defaults to @samp{("DIGEST-MD5")}.
  17344. @end deftypevr
  17345. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  17346. Whether to force all server-to-server connections to be encrypted or not.
  17347. See @url{https://prosody.im/doc/modules/mod_tls}.
  17348. Defaults to @samp{#f}.
  17349. @end deftypevr
  17350. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  17351. Whether to require encryption and certificate authentication. This
  17352. provides ideal security, but requires servers you communicate with to support
  17353. encryption AND present valid, trusted certificates. See
  17354. @url{https://prosody.im/doc/s2s#security}.
  17355. Defaults to @samp{#f}.
  17356. @end deftypevr
  17357. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  17358. Many servers don't support encryption or have invalid or self-signed
  17359. certificates. You can list domains here that will not be required to
  17360. authenticate using certificates. They will be authenticated using DNS@. See
  17361. @url{https://prosody.im/doc/s2s#security}.
  17362. Defaults to @samp{()}.
  17363. @end deftypevr
  17364. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  17365. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  17366. valid certificates for some domains by specifying a list here. See
  17367. @url{https://prosody.im/doc/s2s#security}.
  17368. Defaults to @samp{()}.
  17369. @end deftypevr
  17370. @deftypevr {@code{prosody-configuration} parameter} string authentication
  17371. Select the authentication backend to use. The default provider stores
  17372. passwords in plaintext and uses Prosody's configured data storage to store the
  17373. authentication data. If you do not trust your server please see
  17374. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  17375. about using the hashed backend. See also
  17376. @url{https://prosody.im/doc/authentication}
  17377. Defaults to @samp{"internal_plain"}.
  17378. @end deftypevr
  17379. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  17380. Set logging options. Advanced logging configuration is not yet supported
  17381. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  17382. Defaults to @samp{"*syslog"}.
  17383. @end deftypevr
  17384. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  17385. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  17386. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  17387. @end deftypevr
  17388. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  17389. Maximum allowed size of the HTTP body (in bytes).
  17390. @end deftypevr
  17391. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  17392. Some modules expose their own URL in various ways. This URL is built
  17393. from the protocol, host and port used. If Prosody sits behind a proxy, the
  17394. public URL will be @code{http-external-url} instead. See
  17395. @url{https://prosody.im/doc/http#external_url}.
  17396. @end deftypevr
  17397. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  17398. A host in Prosody is a domain on which user accounts can be created. For
  17399. example if you want your users to have addresses like
  17400. @samp{"john.smith@@example.com"} then you need to add a host
  17401. @samp{"example.com"}. All options in this list will apply only to this host.
  17402. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  17403. the actual physical host that Prosody is installed on. A single Prosody
  17404. instance can serve many domains, each one defined as a VirtualHost entry in
  17405. Prosody's configuration. Conversely a server that hosts a single domain would
  17406. have just one VirtualHost entry.
  17407. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  17408. Available @code{virtualhost-configuration} fields are:
  17409. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  17410. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  17411. Domain you wish Prosody to serve.
  17412. @end deftypevr
  17413. @end deftypevr
  17414. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  17415. Components are extra services on a server which are available to clients,
  17416. usually on a subdomain of the main server (such as
  17417. @samp{"mycomponent.example.com"}). Example components might be chatroom
  17418. servers, user directories, or gateways to other protocols.
  17419. Internal components are implemented with Prosody-specific plugins. To add an
  17420. internal component, you simply fill the hostname field, and the plugin you wish
  17421. to use for the component.
  17422. See @url{https://prosody.im/doc/components}.
  17423. Defaults to @samp{()}.
  17424. Available @code{int-component-configuration} fields are:
  17425. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  17426. @deftypevr {@code{int-component-configuration} parameter} string hostname
  17427. Hostname of the component.
  17428. @end deftypevr
  17429. @deftypevr {@code{int-component-configuration} parameter} string plugin
  17430. Plugin you wish to use for the component.
  17431. @end deftypevr
  17432. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  17433. Multi-user chat (MUC) is Prosody's module for allowing you to create
  17434. hosted chatrooms/conferences for XMPP users.
  17435. General information on setting up and using multi-user chatrooms can be found
  17436. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  17437. which you should read if you are new to XMPP chatrooms.
  17438. See also @url{https://prosody.im/doc/modules/mod_muc}.
  17439. Available @code{mod-muc-configuration} fields are:
  17440. @deftypevr {@code{mod-muc-configuration} parameter} string name
  17441. The name to return in service discovery responses.
  17442. Defaults to @samp{"Prosody Chatrooms"}.
  17443. @end deftypevr
  17444. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  17445. If @samp{#t}, this will only allow admins to create new chatrooms.
  17446. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  17447. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  17448. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  17449. restricts to service administrators only.
  17450. Defaults to @samp{#f}.
  17451. @end deftypevr
  17452. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  17453. Maximum number of history messages that will be sent to the member that has
  17454. just joined the room.
  17455. Defaults to @samp{20}.
  17456. @end deftypevr
  17457. @end deftypevr
  17458. @end deftypevr
  17459. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  17460. External components use XEP-0114, which most standalone components
  17461. support. To add an external component, you simply fill the hostname field. See
  17462. @url{https://prosody.im/doc/components}.
  17463. Defaults to @samp{()}.
  17464. Available @code{ext-component-configuration} fields are:
  17465. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  17466. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  17467. Password which the component will use to log in.
  17468. @end deftypevr
  17469. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  17470. Hostname of the component.
  17471. @end deftypevr
  17472. @end deftypevr
  17473. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  17474. Port(s) Prosody listens on for component connections.
  17475. Defaults to @samp{(5347)}.
  17476. @end deftypevr
  17477. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  17478. Interface Prosody listens on for component connections.
  17479. Defaults to @samp{"127.0.0.1"}.
  17480. @end deftypevr
  17481. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  17482. Raw content that will be added to the configuration file.
  17483. @end deftypevr
  17484. It could be that you just want to get a @code{prosody.cfg.lua}
  17485. up and running. In that case, you can pass an
  17486. @code{opaque-prosody-configuration} record as the value of
  17487. @code{prosody-service-type}. As its name indicates, an opaque configuration
  17488. does not have easy reflective capabilities.
  17489. Available @code{opaque-prosody-configuration} fields are:
  17490. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  17491. The prosody package.
  17492. @end deftypevr
  17493. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  17494. The contents of the @code{prosody.cfg.lua} to use.
  17495. @end deftypevr
  17496. For example, if your @code{prosody.cfg.lua} is just the empty
  17497. string, you could instantiate a prosody service like this:
  17498. @lisp
  17499. (service prosody-service-type
  17500. (opaque-prosody-configuration
  17501. (prosody.cfg.lua "")))
  17502. @end lisp
  17503. @c end of Prosody auto-generated documentation
  17504. @subsubheading BitlBee Service
  17505. @cindex IRC (Internet Relay Chat)
  17506. @cindex IRC gateway
  17507. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  17508. interface to a variety of messaging protocols such as XMPP.
  17509. @defvr {Scheme Variable} bitlbee-service-type
  17510. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  17511. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  17512. below).
  17513. To have BitlBee listen on port 6667 on localhost, add this line to your
  17514. services:
  17515. @lisp
  17516. (service bitlbee-service-type)
  17517. @end lisp
  17518. @end defvr
  17519. @deftp {Data Type} bitlbee-configuration
  17520. This is the configuration for BitlBee, with the following fields:
  17521. @table @asis
  17522. @item @code{interface} (default: @code{"127.0.0.1"})
  17523. @itemx @code{port} (default: @code{6667})
  17524. Listen on the network interface corresponding to the IP address
  17525. specified in @var{interface}, on @var{port}.
  17526. When @var{interface} is @code{127.0.0.1}, only local clients can
  17527. connect; when it is @code{0.0.0.0}, connections can come from any
  17528. networking interface.
  17529. @item @code{bitlbee} (default: @code{bitlbee})
  17530. The BitlBee package to use.
  17531. @item @code{plugins} (default: @code{'()})
  17532. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  17533. @item @code{extra-settings} (default: @code{""})
  17534. Configuration snippet added as-is to the BitlBee configuration file.
  17535. @end table
  17536. @end deftp
  17537. @subsubheading Quassel Service
  17538. @cindex IRC (Internet Relay Chat)
  17539. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  17540. meaning that one or more clients can attach to and detach from the
  17541. central core.
  17542. @defvr {Scheme Variable} quassel-service-type
  17543. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  17544. IRC backend daemon. Its value is a @code{quassel-configuration}
  17545. (see below).
  17546. @end defvr
  17547. @deftp {Data Type} quassel-configuration
  17548. This is the configuration for Quassel, with the following fields:
  17549. @table @asis
  17550. @item @code{quassel} (default: @code{quassel})
  17551. The Quassel package to use.
  17552. @item @code{interface} (default: @code{"::,0.0.0.0"})
  17553. @item @code{port} (default: @code{4242})
  17554. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  17555. interfaces specified in the comma delimited @var{interface}, on
  17556. @var{port}.
  17557. @item @code{loglevel} (default: @code{"Info"})
  17558. The level of logging desired. Accepted values are Debug, Info, Warning
  17559. and Error.
  17560. @end table
  17561. @end deftp
  17562. @node Telephony Services
  17563. @subsection Telephony Services
  17564. @cindex Murmur (VoIP server)
  17565. @cindex VoIP server
  17566. This section describes how to set up and run a Murmur server. Murmur is
  17567. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  17568. (VoIP) suite.
  17569. @deftp {Data Type} murmur-configuration
  17570. The service type for the Murmur server. An example configuration can
  17571. look like this:
  17572. @lisp
  17573. (service murmur-service-type
  17574. (murmur-configuration
  17575. (welcome-text
  17576. "Welcome to this Mumble server running on Guix!")
  17577. (cert-required? #t) ;disallow text password logins
  17578. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  17579. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  17580. @end lisp
  17581. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  17582. password with the command that is printed during the activation phase.
  17583. It is recommended to register a normal Mumble user account
  17584. and grant it admin or moderator rights.
  17585. You can use the @code{mumble} client to
  17586. login as new normal user, register yourself, and log out.
  17587. For the next step login with the name @code{SuperUser} use
  17588. the @code{SuperUser} password that you set previously,
  17589. and grant your newly registered mumble user administrator or moderator
  17590. rights and create some channels.
  17591. Available @code{murmur-configuration} fields are:
  17592. @table @asis
  17593. @item @code{package} (default: @code{mumble})
  17594. Package that contains @code{bin/murmurd}.
  17595. @item @code{user} (default: @code{"murmur"})
  17596. User who will run the Murmur server.
  17597. @item @code{group} (default: @code{"murmur"})
  17598. Group of the user who will run the murmur server.
  17599. @item @code{port} (default: @code{64738})
  17600. Port on which the server will listen.
  17601. @item @code{welcome-text} (default: @code{""})
  17602. Welcome text sent to clients when they connect.
  17603. @item @code{server-password} (default: @code{""})
  17604. Password the clients have to enter in order to connect.
  17605. @item @code{max-users} (default: @code{100})
  17606. Maximum of users that can be connected to the server at once.
  17607. @item @code{max-user-bandwidth} (default: @code{#f})
  17608. Maximum voice traffic a user can send per second.
  17609. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  17610. File name of the sqlite database.
  17611. The service's user will become the owner of the directory.
  17612. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  17613. File name of the log file.
  17614. The service's user will become the owner of the directory.
  17615. @item @code{autoban-attempts} (default: @code{10})
  17616. Maximum number of logins a user can make in @code{autoban-timeframe}
  17617. without getting auto banned for @code{autoban-time}.
  17618. @item @code{autoban-timeframe} (default: @code{120})
  17619. Timeframe for autoban in seconds.
  17620. @item @code{autoban-time} (default: @code{300})
  17621. Amount of time in seconds for which a client gets banned
  17622. when violating the autoban limits.
  17623. @item @code{opus-threshold} (default: @code{100})
  17624. Percentage of clients that need to support opus
  17625. before switching over to opus audio codec.
  17626. @item @code{channel-nesting-limit} (default: @code{10})
  17627. How deep channels can be nested at maximum.
  17628. @item @code{channelname-regex} (default: @code{#f})
  17629. A string in form of a Qt regular expression that channel names must conform to.
  17630. @item @code{username-regex} (default: @code{#f})
  17631. A string in form of a Qt regular expression that user names must conform to.
  17632. @item @code{text-message-length} (default: @code{5000})
  17633. Maximum size in bytes that a user can send in one text chat message.
  17634. @item @code{image-message-length} (default: @code{(* 128 1024)})
  17635. Maximum size in bytes that a user can send in one image message.
  17636. @item @code{cert-required?} (default: @code{#f})
  17637. If it is set to @code{#t} clients that use weak password authentication
  17638. will not be accepted. Users must have completed the certificate wizard to join.
  17639. @item @code{remember-channel?} (default: @code{#f})
  17640. Should murmur remember the last channel each user was in when they disconnected
  17641. and put them into the remembered channel when they rejoin.
  17642. @item @code{allow-html?} (default: @code{#f})
  17643. Should html be allowed in text messages, user comments, and channel descriptions.
  17644. @item @code{allow-ping?} (default: @code{#f})
  17645. Setting to true exposes the current user count, the maximum user count, and
  17646. the server's maximum bandwidth per client to unauthenticated users. In the
  17647. Mumble client, this information is shown in the Connect dialog.
  17648. Disabling this setting will prevent public listing of the server.
  17649. @item @code{bonjour?} (default: @code{#f})
  17650. Should the server advertise itself in the local network through the bonjour protocol.
  17651. @item @code{send-version?} (default: @code{#f})
  17652. Should the murmur server version be exposed in ping requests.
  17653. @item @code{log-days} (default: @code{31})
  17654. Murmur also stores logs in the database, which are accessible via RPC.
  17655. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  17656. or -1 to disable logging to the database.
  17657. @item @code{obfuscate-ips?} (default: @code{#t})
  17658. Should logged ips be obfuscated to protect the privacy of users.
  17659. @item @code{ssl-cert} (default: @code{#f})
  17660. File name of the SSL/TLS certificate used for encrypted connections.
  17661. @lisp
  17662. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  17663. @end lisp
  17664. @item @code{ssl-key} (default: @code{#f})
  17665. Filepath to the ssl private key used for encrypted connections.
  17666. @lisp
  17667. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  17668. @end lisp
  17669. @item @code{ssl-dh-params} (default: @code{#f})
  17670. File name of a PEM-encoded file with Diffie-Hellman parameters
  17671. for the SSL/TLS encryption. Alternatively you set it to
  17672. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  17673. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  17674. @item @code{ssl-ciphers} (default: @code{#f})
  17675. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  17676. in SSL/TLS.
  17677. This option is specified using
  17678. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  17679. OpenSSL cipher list notation}.
  17680. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  17681. before setting it here, to get a feel for which cipher suites you will get.
  17682. After setting this option, it is recommend that you inspect your Murmur log
  17683. to ensure that Murmur is using the cipher suites that you expected it to.
  17684. Note: Changing this option may impact the backwards compatibility of your
  17685. Murmur server, and can remove the ability for older Mumble clients to be able
  17686. to connect to it.
  17687. @item @code{public-registration} (default: @code{#f})
  17688. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  17689. You can optionally register your server in the public server list that the
  17690. @code{mumble} client shows on startup.
  17691. You cannot register your server if you have set a @code{server-password},
  17692. or set @code{allow-ping} to @code{#f}.
  17693. It might take a few hours until it shows up in the public list.
  17694. @item @code{file} (default: @code{#f})
  17695. Optional alternative override for this configuration.
  17696. @end table
  17697. @end deftp
  17698. @deftp {Data Type} murmur-public-registration-configuration
  17699. Configuration for public registration of a murmur service.
  17700. @table @asis
  17701. @item @code{name}
  17702. This is a display name for your server. Not to be confused with the hostname.
  17703. @item @code{password}
  17704. A password to identify your registration.
  17705. Subsequent updates will need the same password. Don't lose your password.
  17706. @item @code{url}
  17707. This should be a @code{http://} or @code{https://} link to your web
  17708. site.
  17709. @item @code{hostname} (default: @code{#f})
  17710. By default your server will be listed by its IP address.
  17711. If it is set your server will be linked by this host name instead.
  17712. @end table
  17713. @end deftp
  17714. @node Monitoring Services
  17715. @subsection Monitoring Services
  17716. @subsubheading Tailon Service
  17717. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  17718. viewing and searching log files.
  17719. The following example will configure the service with default values.
  17720. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  17721. @lisp
  17722. (service tailon-service-type)
  17723. @end lisp
  17724. The following example customises more of the Tailon configuration,
  17725. adding @command{sed} to the list of allowed commands.
  17726. @lisp
  17727. (service tailon-service-type
  17728. (tailon-configuration
  17729. (config-file
  17730. (tailon-configuration-file
  17731. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  17732. @end lisp
  17733. @deftp {Data Type} tailon-configuration
  17734. Data type representing the configuration of Tailon.
  17735. This type has the following parameters:
  17736. @table @asis
  17737. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  17738. The configuration file to use for Tailon. This can be set to a
  17739. @dfn{tailon-configuration-file} record value, or any gexp
  17740. (@pxref{G-Expressions}).
  17741. For example, to instead use a local file, the @code{local-file} function
  17742. can be used:
  17743. @lisp
  17744. (service tailon-service-type
  17745. (tailon-configuration
  17746. (config-file (local-file "./my-tailon.conf"))))
  17747. @end lisp
  17748. @item @code{package} (default: @code{tailon})
  17749. The tailon package to use.
  17750. @end table
  17751. @end deftp
  17752. @deftp {Data Type} tailon-configuration-file
  17753. Data type representing the configuration options for Tailon.
  17754. This type has the following parameters:
  17755. @table @asis
  17756. @item @code{files} (default: @code{(list "/var/log")})
  17757. List of files to display. The list can include strings for a single file
  17758. or directory, or a list, where the first item is the name of a
  17759. subsection, and the remaining items are the files or directories in that
  17760. subsection.
  17761. @item @code{bind} (default: @code{"localhost:8080"})
  17762. Address and port to which Tailon should bind on.
  17763. @item @code{relative-root} (default: @code{#f})
  17764. URL path to use for Tailon, set to @code{#f} to not use a path.
  17765. @item @code{allow-transfers?} (default: @code{#t})
  17766. Allow downloading the log files in the web interface.
  17767. @item @code{follow-names?} (default: @code{#t})
  17768. Allow tailing of not-yet existent files.
  17769. @item @code{tail-lines} (default: @code{200})
  17770. Number of lines to read initially from each file.
  17771. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  17772. Commands to allow running. By default, @code{sed} is disabled.
  17773. @item @code{debug?} (default: @code{#f})
  17774. Set @code{debug?} to @code{#t} to show debug messages.
  17775. @item @code{wrap-lines} (default: @code{#t})
  17776. Initial line wrapping state in the web interface. Set to @code{#t} to
  17777. initially wrap lines (the default), or to @code{#f} to initially not
  17778. wrap lines.
  17779. @item @code{http-auth} (default: @code{#f})
  17780. HTTP authentication type to use. Set to @code{#f} to disable
  17781. authentication (the default). Supported values are @code{"digest"} or
  17782. @code{"basic"}.
  17783. @item @code{users} (default: @code{#f})
  17784. If HTTP authentication is enabled (see @code{http-auth}), access will be
  17785. restricted to the credentials provided here. To configure users, use a
  17786. list of pairs, where the first element of the pair is the username, and
  17787. the 2nd element of the pair is the password.
  17788. @lisp
  17789. (tailon-configuration-file
  17790. (http-auth "basic")
  17791. (users '(("user1" . "password1")
  17792. ("user2" . "password2"))))
  17793. @end lisp
  17794. @end table
  17795. @end deftp
  17796. @subsubheading Darkstat Service
  17797. @cindex darkstat
  17798. Darkstat is a packet sniffer that captures network traffic, calculates
  17799. statistics about usage, and serves reports over HTTP.
  17800. @defvar {Scheme Variable} darkstat-service-type
  17801. This is the service type for the
  17802. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  17803. service, its value must be a @code{darkstat-configuration} record as in
  17804. this example:
  17805. @lisp
  17806. (service darkstat-service-type
  17807. (darkstat-configuration
  17808. (interface "eno1")))
  17809. @end lisp
  17810. @end defvar
  17811. @deftp {Data Type} darkstat-configuration
  17812. Data type representing the configuration of @command{darkstat}.
  17813. @table @asis
  17814. @item @code{package} (default: @code{darkstat})
  17815. The darkstat package to use.
  17816. @item @code{interface}
  17817. Capture traffic on the specified network interface.
  17818. @item @code{port} (default: @code{"667"})
  17819. Bind the web interface to the specified port.
  17820. @item @code{bind-address} (default: @code{"127.0.0.1"})
  17821. Bind the web interface to the specified address.
  17822. @item @code{base} (default: @code{"/"})
  17823. Specify the path of the base URL@. This can be useful if
  17824. @command{darkstat} is accessed via a reverse proxy.
  17825. @end table
  17826. @end deftp
  17827. @subsubheading Prometheus Node Exporter Service
  17828. @cindex prometheus-node-exporter
  17829. The Prometheus ``node exporter'' makes hardware and operating system statistics
  17830. provided by the Linux kernel available for the Prometheus monitoring system.
  17831. This service should be deployed on all physical nodes and virtual machines,
  17832. where monitoring these statistics is desirable.
  17833. @defvar {Scheme variable} prometheus-node-exporter-service-type
  17834. This is the service type for the
  17835. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  17836. service, its value must be a @code{prometheus-node-exporter-configuration}.
  17837. @lisp
  17838. (service prometheus-node-exporter-service-type)
  17839. @end lisp
  17840. @end defvar
  17841. @deftp {Data Type} prometheus-node-exporter-configuration
  17842. Data type representing the configuration of @command{node_exporter}.
  17843. @table @asis
  17844. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  17845. The prometheus-node-exporter package to use.
  17846. @item @code{web-listen-address} (default: @code{":9100"})
  17847. Bind the web interface to the specified address.
  17848. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  17849. This directory can be used to export metrics specific to this machine.
  17850. Files containing metrics in the text format, with the filename ending in
  17851. @code{.prom} should be placed in this directory.
  17852. @item @code{extra-options} (default: @code{'()})
  17853. Extra options to pass to the Prometheus node exporter.
  17854. @end table
  17855. @end deftp
  17856. @subsubheading Zabbix server
  17857. @cindex zabbix zabbix-server
  17858. Zabbix provides monitoring metrics, among others network utilization, CPU load
  17859. and disk space consumption:
  17860. @itemize
  17861. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  17862. @item Auto-discovery of servers and network devices and interfaces.
  17863. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  17864. @item Distributed monitoring with centralized web administration.
  17865. @item Native high performance agents.
  17866. @item SLA, and ITIL KPI metrics on reporting.
  17867. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  17868. @item Remote command execution through Zabbix proxies.
  17869. @end itemize
  17870. @c %start of fragment
  17871. Available @code{zabbix-server-configuration} fields are:
  17872. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  17873. The zabbix-server package.
  17874. @end deftypevr
  17875. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  17876. User who will run the Zabbix server.
  17877. Defaults to @samp{"zabbix"}.
  17878. @end deftypevr
  17879. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  17880. Group who will run the Zabbix server.
  17881. Defaults to @samp{"zabbix"}.
  17882. @end deftypevr
  17883. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  17884. Database host name.
  17885. Defaults to @samp{"127.0.0.1"}.
  17886. @end deftypevr
  17887. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  17888. Database name.
  17889. Defaults to @samp{"zabbix"}.
  17890. @end deftypevr
  17891. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  17892. Database user.
  17893. Defaults to @samp{"zabbix"}.
  17894. @end deftypevr
  17895. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  17896. Database password. Please, use @code{include-files} with
  17897. @code{DBPassword=SECRET} inside a specified file instead.
  17898. Defaults to @samp{""}.
  17899. @end deftypevr
  17900. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  17901. Database port.
  17902. Defaults to @samp{5432}.
  17903. @end deftypevr
  17904. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  17905. Specifies where log messages are written to:
  17906. @itemize @bullet
  17907. @item
  17908. @code{system} - syslog.
  17909. @item
  17910. @code{file} - file specified with @code{log-file} parameter.
  17911. @item
  17912. @code{console} - standard output.
  17913. @end itemize
  17914. Defaults to @samp{""}.
  17915. @end deftypevr
  17916. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  17917. Log file name for @code{log-type} @code{file} parameter.
  17918. Defaults to @samp{"/var/log/zabbix/server.log"}.
  17919. @end deftypevr
  17920. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  17921. Name of PID file.
  17922. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  17923. @end deftypevr
  17924. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  17925. The location of certificate authority (CA) files for SSL server
  17926. certificate verification.
  17927. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  17928. @end deftypevr
  17929. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  17930. Location of SSL client certificates.
  17931. Defaults to @samp{"/etc/ssl/certs"}.
  17932. @end deftypevr
  17933. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  17934. Extra options will be appended to Zabbix server configuration file.
  17935. Defaults to @samp{""}.
  17936. @end deftypevr
  17937. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  17938. You may include individual files or all files in a directory in the
  17939. configuration file.
  17940. Defaults to @samp{()}.
  17941. @end deftypevr
  17942. @c %end of fragment
  17943. @subsubheading Zabbix agent
  17944. @cindex zabbix zabbix-agent
  17945. Zabbix agent gathers information for Zabbix server.
  17946. @c %start of fragment
  17947. Available @code{zabbix-agent-configuration} fields are:
  17948. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  17949. The zabbix-agent package.
  17950. @end deftypevr
  17951. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  17952. User who will run the Zabbix agent.
  17953. Defaults to @samp{"zabbix"}.
  17954. @end deftypevr
  17955. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  17956. Group who will run the Zabbix agent.
  17957. Defaults to @samp{"zabbix"}.
  17958. @end deftypevr
  17959. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  17960. Unique, case sensitive hostname which is required for active checks and
  17961. must match hostname as configured on the server.
  17962. Defaults to @samp{""}.
  17963. @end deftypevr
  17964. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  17965. Specifies where log messages are written to:
  17966. @itemize @bullet
  17967. @item
  17968. @code{system} - syslog.
  17969. @item
  17970. @code{file} - file specified with @code{log-file} parameter.
  17971. @item
  17972. @code{console} - standard output.
  17973. @end itemize
  17974. Defaults to @samp{""}.
  17975. @end deftypevr
  17976. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  17977. Log file name for @code{log-type} @code{file} parameter.
  17978. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  17979. @end deftypevr
  17980. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  17981. Name of PID file.
  17982. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  17983. @end deftypevr
  17984. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  17985. List of IP addresses, optionally in CIDR notation, or hostnames of
  17986. Zabbix servers and Zabbix proxies. Incoming connections will be
  17987. accepted only from the hosts listed here.
  17988. Defaults to @samp{("127.0.0.1")}.
  17989. @end deftypevr
  17990. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  17991. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  17992. proxies for active checks. If port is not specified, default port is
  17993. used. If this parameter is not specified, active checks are disabled.
  17994. Defaults to @samp{("127.0.0.1")}.
  17995. @end deftypevr
  17996. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  17997. Extra options will be appended to Zabbix server configuration file.
  17998. Defaults to @samp{""}.
  17999. @end deftypevr
  18000. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  18001. You may include individual files or all files in a directory in the
  18002. configuration file.
  18003. Defaults to @samp{()}.
  18004. @end deftypevr
  18005. @c %end of fragment
  18006. @subsubheading Zabbix front-end
  18007. @cindex zabbix zabbix-front-end
  18008. This service provides a WEB interface to Zabbix server.
  18009. @c %start of fragment
  18010. Available @code{zabbix-front-end-configuration} fields are:
  18011. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  18012. NGINX configuration.
  18013. @end deftypevr
  18014. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  18015. Database host name.
  18016. Defaults to @samp{"localhost"}.
  18017. @end deftypevr
  18018. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  18019. Database port.
  18020. Defaults to @samp{5432}.
  18021. @end deftypevr
  18022. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  18023. Database name.
  18024. Defaults to @samp{"zabbix"}.
  18025. @end deftypevr
  18026. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  18027. Database user.
  18028. Defaults to @samp{"zabbix"}.
  18029. @end deftypevr
  18030. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  18031. Database password. Please, use @code{db-secret-file} instead.
  18032. Defaults to @samp{""}.
  18033. @end deftypevr
  18034. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  18035. Secret file containing the credentials for the Zabbix front-end. The value
  18036. must be a local file name, not a G-expression. You are expected to create
  18037. this file manually. Its contents will be copied into @file{zabbix.conf.php}
  18038. as the value of @code{$DB['PASSWORD']}.
  18039. Defaults to @samp{""}.
  18040. @end deftypevr
  18041. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  18042. Zabbix server hostname.
  18043. Defaults to @samp{"localhost"}.
  18044. @end deftypevr
  18045. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  18046. Zabbix server port.
  18047. Defaults to @samp{10051}.
  18048. @end deftypevr
  18049. @c %end of fragment
  18050. @node Kerberos Services
  18051. @subsection Kerberos Services
  18052. @cindex Kerberos
  18053. The @code{(gnu services kerberos)} module provides services relating to
  18054. the authentication protocol @dfn{Kerberos}.
  18055. @subsubheading Krb5 Service
  18056. Programs using a Kerberos client library normally
  18057. expect a configuration file in @file{/etc/krb5.conf}.
  18058. This service generates such a file from a definition provided in the
  18059. operating system declaration.
  18060. It does not cause any daemon to be started.
  18061. No ``keytab'' files are provided by this service---you must explicitly create them.
  18062. This service is known to work with the MIT client library, @code{mit-krb5}.
  18063. Other implementations have not been tested.
  18064. @defvr {Scheme Variable} krb5-service-type
  18065. A service type for Kerberos 5 clients.
  18066. @end defvr
  18067. @noindent
  18068. Here is an example of its use:
  18069. @lisp
  18070. (service krb5-service-type
  18071. (krb5-configuration
  18072. (default-realm "EXAMPLE.COM")
  18073. (allow-weak-crypto? #t)
  18074. (realms (list
  18075. (krb5-realm
  18076. (name "EXAMPLE.COM")
  18077. (admin-server "groucho.example.com")
  18078. (kdc "karl.example.com"))
  18079. (krb5-realm
  18080. (name "ARGRX.EDU")
  18081. (admin-server "kerb-admin.argrx.edu")
  18082. (kdc "keys.argrx.edu"))))))
  18083. @end lisp
  18084. @noindent
  18085. This example provides a Kerberos@tie{}5 client configuration which:
  18086. @itemize
  18087. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  18088. of which have distinct administration servers and key distribution centers;
  18089. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  18090. specified by clients;
  18091. @item Accepts services which only support encryption types known to be weak.
  18092. @end itemize
  18093. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  18094. Only the most commonly used ones are described here.
  18095. For a full list, and more detailed explanation of each, see the MIT
  18096. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  18097. documentation.
  18098. @deftp {Data Type} krb5-realm
  18099. @cindex realm, kerberos
  18100. @table @asis
  18101. @item @code{name}
  18102. This field is a string identifying the name of the realm.
  18103. A common convention is to use the fully qualified DNS name of your organization,
  18104. converted to upper case.
  18105. @item @code{admin-server}
  18106. This field is a string identifying the host where the administration server is
  18107. running.
  18108. @item @code{kdc}
  18109. This field is a string identifying the key distribution center
  18110. for the realm.
  18111. @end table
  18112. @end deftp
  18113. @deftp {Data Type} krb5-configuration
  18114. @table @asis
  18115. @item @code{allow-weak-crypto?} (default: @code{#f})
  18116. If this flag is @code{#t} then services which only offer encryption algorithms
  18117. known to be weak will be accepted.
  18118. @item @code{default-realm} (default: @code{#f})
  18119. This field should be a string identifying the default Kerberos
  18120. realm for the client.
  18121. You should set this field to the name of your Kerberos realm.
  18122. If this value is @code{#f}
  18123. then a realm must be specified with every Kerberos principal when invoking programs
  18124. such as @command{kinit}.
  18125. @item @code{realms}
  18126. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  18127. access.
  18128. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  18129. field.
  18130. @end table
  18131. @end deftp
  18132. @subsubheading PAM krb5 Service
  18133. @cindex pam-krb5
  18134. The @code{pam-krb5} service allows for login authentication and password
  18135. management via Kerberos.
  18136. You will need this service if you want PAM enabled applications to authenticate
  18137. users using Kerberos.
  18138. @defvr {Scheme Variable} pam-krb5-service-type
  18139. A service type for the Kerberos 5 PAM module.
  18140. @end defvr
  18141. @deftp {Data Type} pam-krb5-configuration
  18142. Data type representing the configuration of the Kerberos 5 PAM module.
  18143. This type has the following parameters:
  18144. @table @asis
  18145. @item @code{pam-krb5} (default: @code{pam-krb5})
  18146. The pam-krb5 package to use.
  18147. @item @code{minimum-uid} (default: @code{1000})
  18148. The smallest user ID for which Kerberos authentications should be attempted.
  18149. Local accounts with lower values will silently fail to authenticate.
  18150. @end table
  18151. @end deftp
  18152. @node LDAP Services
  18153. @subsection LDAP Services
  18154. @cindex LDAP
  18155. @cindex nslcd, LDAP service
  18156. The @code{(gnu services authentication)} module provides the
  18157. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  18158. server. In addition to configuring the service itself, you may want to add
  18159. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  18160. Switch} for detailed information.
  18161. Here is a simple operating system declaration with a default configuration of
  18162. the @code{nslcd-service-type} and a Name Service Switch configuration that
  18163. consults the @code{ldap} name service last:
  18164. @lisp
  18165. (use-service-modules authentication)
  18166. (use-modules (gnu system nss))
  18167. ...
  18168. (operating-system
  18169. ...
  18170. (services
  18171. (cons*
  18172. (service nslcd-service-type)
  18173. (service dhcp-client-service-type)
  18174. %base-services))
  18175. (name-service-switch
  18176. (let ((services (list (name-service (name "db"))
  18177. (name-service (name "files"))
  18178. (name-service (name "ldap")))))
  18179. (name-service-switch
  18180. (inherit %mdns-host-lookup-nss)
  18181. (password services)
  18182. (shadow services)
  18183. (group services)
  18184. (netgroup services)
  18185. (gshadow services)))))
  18186. @end lisp
  18187. @c %start of generated documentation for nslcd-configuration
  18188. Available @code{nslcd-configuration} fields are:
  18189. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  18190. The @code{nss-pam-ldapd} package to use.
  18191. @end deftypevr
  18192. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  18193. The number of threads to start that can handle requests and perform LDAP
  18194. queries. Each thread opens a separate connection to the LDAP server.
  18195. The default is to start 5 threads.
  18196. Defaults to @samp{disabled}.
  18197. @end deftypevr
  18198. @deftypevr {@code{nslcd-configuration} parameter} string uid
  18199. This specifies the user id with which the daemon should be run.
  18200. Defaults to @samp{"nslcd"}.
  18201. @end deftypevr
  18202. @deftypevr {@code{nslcd-configuration} parameter} string gid
  18203. This specifies the group id with which the daemon should be run.
  18204. Defaults to @samp{"nslcd"}.
  18205. @end deftypevr
  18206. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  18207. This option controls the way logging is done via a list containing
  18208. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  18209. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  18210. argument is optional and specifies the log level. The log level may be
  18211. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  18212. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  18213. specified log level or higher are logged.
  18214. Defaults to @samp{("/var/log/nslcd" info)}.
  18215. @end deftypevr
  18216. @deftypevr {@code{nslcd-configuration} parameter} list uri
  18217. The list of LDAP server URIs. Normally, only the first server will be
  18218. used with the following servers as fall-back.
  18219. Defaults to @samp{("ldap://localhost:389/")}.
  18220. @end deftypevr
  18221. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  18222. The version of the LDAP protocol to use. The default is to use the
  18223. maximum version supported by the LDAP library.
  18224. Defaults to @samp{disabled}.
  18225. @end deftypevr
  18226. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  18227. Specifies the distinguished name with which to bind to the directory
  18228. server for lookups. The default is to bind anonymously.
  18229. Defaults to @samp{disabled}.
  18230. @end deftypevr
  18231. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  18232. Specifies the credentials with which to bind. This option is only
  18233. applicable when used with binddn.
  18234. Defaults to @samp{disabled}.
  18235. @end deftypevr
  18236. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  18237. Specifies the distinguished name to use when the root user tries to
  18238. modify a user's password using the PAM module.
  18239. Defaults to @samp{disabled}.
  18240. @end deftypevr
  18241. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  18242. Specifies the credentials with which to bind if the root user tries to
  18243. change a user's password. This option is only applicable when used with
  18244. rootpwmoddn
  18245. Defaults to @samp{disabled}.
  18246. @end deftypevr
  18247. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  18248. Specifies the SASL mechanism to be used when performing SASL
  18249. authentication.
  18250. Defaults to @samp{disabled}.
  18251. @end deftypevr
  18252. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  18253. Specifies the SASL realm to be used when performing SASL authentication.
  18254. Defaults to @samp{disabled}.
  18255. @end deftypevr
  18256. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  18257. Specifies the authentication identity to be used when performing SASL
  18258. authentication.
  18259. Defaults to @samp{disabled}.
  18260. @end deftypevr
  18261. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  18262. Specifies the authorization identity to be used when performing SASL
  18263. authentication.
  18264. Defaults to @samp{disabled}.
  18265. @end deftypevr
  18266. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  18267. Determines whether the LDAP server host name should be canonicalised. If
  18268. this is enabled the LDAP library will do a reverse host name lookup. By
  18269. default, it is left up to the LDAP library whether this check is
  18270. performed or not.
  18271. Defaults to @samp{disabled}.
  18272. @end deftypevr
  18273. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  18274. Set the name for the GSS-API Kerberos credentials cache.
  18275. Defaults to @samp{disabled}.
  18276. @end deftypevr
  18277. @deftypevr {@code{nslcd-configuration} parameter} string base
  18278. The directory search base.
  18279. Defaults to @samp{"dc=example,dc=com"}.
  18280. @end deftypevr
  18281. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  18282. Specifies the search scope (subtree, onelevel, base or children). The
  18283. default scope is subtree; base scope is almost never useful for name
  18284. service lookups; children scope is not supported on all servers.
  18285. Defaults to @samp{(subtree)}.
  18286. @end deftypevr
  18287. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  18288. Specifies the policy for dereferencing aliases. The default policy is
  18289. to never dereference aliases.
  18290. Defaults to @samp{disabled}.
  18291. @end deftypevr
  18292. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  18293. Specifies whether automatic referral chasing should be enabled. The
  18294. default behaviour is to chase referrals.
  18295. Defaults to @samp{disabled}.
  18296. @end deftypevr
  18297. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  18298. This option allows for custom attributes to be looked up instead of the
  18299. default RFC 2307 attributes. It is a list of maps, each consisting of
  18300. the name of a map, the RFC 2307 attribute to match and the query
  18301. expression for the attribute as it is available in the directory.
  18302. Defaults to @samp{()}.
  18303. @end deftypevr
  18304. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  18305. A list of filters consisting of the name of a map to which the filter
  18306. applies and an LDAP search filter expression.
  18307. Defaults to @samp{()}.
  18308. @end deftypevr
  18309. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  18310. Specifies the time limit in seconds to use when connecting to the
  18311. directory server. The default value is 10 seconds.
  18312. Defaults to @samp{disabled}.
  18313. @end deftypevr
  18314. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  18315. Specifies the time limit (in seconds) to wait for a response from the
  18316. LDAP server. A value of zero, which is the default, is to wait
  18317. indefinitely for searches to be completed.
  18318. Defaults to @samp{disabled}.
  18319. @end deftypevr
  18320. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  18321. Specifies the period if inactivity (in seconds) after which the con‐
  18322. nection to the LDAP server will be closed. The default is not to time
  18323. out connections.
  18324. Defaults to @samp{disabled}.
  18325. @end deftypevr
  18326. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  18327. Specifies the number of seconds to sleep when connecting to all LDAP
  18328. servers fails. By default one second is waited between the first
  18329. failure and the first retry.
  18330. Defaults to @samp{disabled}.
  18331. @end deftypevr
  18332. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  18333. Specifies the time after which the LDAP server is considered to be
  18334. permanently unavailable. Once this time is reached retries will be done
  18335. only once per this time period. The default value is 10 seconds.
  18336. Defaults to @samp{disabled}.
  18337. @end deftypevr
  18338. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  18339. Specifies whether to use SSL/TLS or not (the default is not to). If
  18340. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  18341. SSL.
  18342. Defaults to @samp{disabled}.
  18343. @end deftypevr
  18344. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  18345. Specifies what checks to perform on a server-supplied certificate. The
  18346. meaning of the values is described in the ldap.conf(5) manual page.
  18347. Defaults to @samp{disabled}.
  18348. @end deftypevr
  18349. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  18350. Specifies the directory containing X.509 certificates for peer authen‐
  18351. tication. This parameter is ignored when using GnuTLS.
  18352. Defaults to @samp{disabled}.
  18353. @end deftypevr
  18354. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  18355. Specifies the path to the X.509 certificate for peer authentication.
  18356. Defaults to @samp{disabled}.
  18357. @end deftypevr
  18358. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  18359. Specifies the path to an entropy source. This parameter is ignored when
  18360. using GnuTLS.
  18361. Defaults to @samp{disabled}.
  18362. @end deftypevr
  18363. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  18364. Specifies the ciphers to use for TLS as a string.
  18365. Defaults to @samp{disabled}.
  18366. @end deftypevr
  18367. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  18368. Specifies the path to the file containing the local certificate for
  18369. client TLS authentication.
  18370. Defaults to @samp{disabled}.
  18371. @end deftypevr
  18372. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  18373. Specifies the path to the file containing the private key for client TLS
  18374. authentication.
  18375. Defaults to @samp{disabled}.
  18376. @end deftypevr
  18377. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  18378. Set this to a number greater than 0 to request paged results from the
  18379. LDAP server in accordance with RFC2696. The default (0) is to not
  18380. request paged results.
  18381. Defaults to @samp{disabled}.
  18382. @end deftypevr
  18383. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  18384. This option prevents group membership lookups through LDAP for the
  18385. specified users. Alternatively, the value 'all-local may be used. With
  18386. that value nslcd builds a full list of non-LDAP users on startup.
  18387. Defaults to @samp{disabled}.
  18388. @end deftypevr
  18389. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  18390. This option ensures that LDAP users with a numeric user id lower than
  18391. the specified value are ignored.
  18392. Defaults to @samp{disabled}.
  18393. @end deftypevr
  18394. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  18395. This option specifies an offset that is added to all LDAP numeric user
  18396. ids. This can be used to avoid user id collisions with local users.
  18397. Defaults to @samp{disabled}.
  18398. @end deftypevr
  18399. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  18400. This option specifies an offset that is added to all LDAP numeric group
  18401. ids. This can be used to avoid user id collisions with local groups.
  18402. Defaults to @samp{disabled}.
  18403. @end deftypevr
  18404. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  18405. If this option is set, the member attribute of a group may point to
  18406. another group. Members of nested groups are also returned in the higher
  18407. level group and parent groups are returned when finding groups for a
  18408. specific user. The default is not to perform extra searches for nested
  18409. groups.
  18410. Defaults to @samp{disabled}.
  18411. @end deftypevr
  18412. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  18413. If this option is set, the group member list is not retrieved when
  18414. looking up groups. Lookups for finding which groups a user belongs to
  18415. will remain functional so the user will likely still get the correct
  18416. groups assigned on login.
  18417. Defaults to @samp{disabled}.
  18418. @end deftypevr
  18419. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  18420. If this option is set, functions which cause all user/group entries to
  18421. be loaded from the directory will not succeed in doing so. This can
  18422. dramatically reduce LDAP server load in situations where there are a
  18423. great number of users and/or groups. This option is not recommended for
  18424. most configurations.
  18425. Defaults to @samp{disabled}.
  18426. @end deftypevr
  18427. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  18428. This option can be used to specify how user and group names are verified
  18429. within the system. This pattern is used to check all user and group
  18430. names that are requested and returned from LDAP.
  18431. Defaults to @samp{disabled}.
  18432. @end deftypevr
  18433. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  18434. This specifies whether or not to perform searches using case-insensitive
  18435. matching. Enabling this could open up the system to authorization
  18436. bypass vulnerabilities and introduce nscd cache poisoning
  18437. vulnerabilities which allow denial of service.
  18438. Defaults to @samp{disabled}.
  18439. @end deftypevr
  18440. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  18441. This option specifies whether password policy controls are requested and
  18442. handled from the LDAP server when performing user authentication.
  18443. Defaults to @samp{disabled}.
  18444. @end deftypevr
  18445. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  18446. By default nslcd performs an LDAP search with the user's credentials
  18447. after BIND (authentication) to ensure that the BIND operation was
  18448. successful. The default search is a simple check to see if the user's
  18449. DN exists. A search filter can be specified that will be used instead.
  18450. It should return at least one entry.
  18451. Defaults to @samp{disabled}.
  18452. @end deftypevr
  18453. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  18454. This option allows flexible fine tuning of the authorisation check that
  18455. should be performed. The search filter specified is executed and if any
  18456. entries match, access is granted, otherwise access is denied.
  18457. Defaults to @samp{disabled}.
  18458. @end deftypevr
  18459. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  18460. If this option is set password modification using pam_ldap will be
  18461. denied and the specified message will be presented to the user instead.
  18462. The message can be used to direct the user to an alternative means of
  18463. changing their password.
  18464. Defaults to @samp{disabled}.
  18465. @end deftypevr
  18466. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  18467. List of pam service names for which LDAP authentication should suffice.
  18468. Defaults to @samp{()}.
  18469. @end deftypevr
  18470. @c %end of generated documentation for nslcd-configuration
  18471. @node Web Services
  18472. @subsection Web Services
  18473. @cindex web
  18474. @cindex www
  18475. @cindex HTTP
  18476. The @code{(gnu services web)} module provides the Apache HTTP Server,
  18477. the nginx web server, and also a fastcgi wrapper daemon.
  18478. @subsubheading Apache HTTP Server
  18479. @deffn {Scheme Variable} httpd-service-type
  18480. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  18481. (@dfn{httpd}). The value for this service type is a
  18482. @code{httpd-configuration} record.
  18483. A simple example configuration is given below.
  18484. @lisp
  18485. (service httpd-service-type
  18486. (httpd-configuration
  18487. (config
  18488. (httpd-config-file
  18489. (server-name "www.example.com")
  18490. (document-root "/srv/http/www.example.com")))))
  18491. @end lisp
  18492. Other services can also extend the @code{httpd-service-type} to add to
  18493. the configuration.
  18494. @lisp
  18495. (simple-service 'www.example.com-server httpd-service-type
  18496. (list
  18497. (httpd-virtualhost
  18498. "*:80"
  18499. (list (string-join '("ServerName www.example.com"
  18500. "DocumentRoot /srv/http/www.example.com")
  18501. "\n")))))
  18502. @end lisp
  18503. @end deffn
  18504. The details for the @code{httpd-configuration}, @code{httpd-module},
  18505. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  18506. given below.
  18507. @deffn {Data Type} httpd-configuration
  18508. This data type represents the configuration for the httpd service.
  18509. @table @asis
  18510. @item @code{package} (default: @code{httpd})
  18511. The httpd package to use.
  18512. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  18513. The pid file used by the shepherd-service.
  18514. @item @code{config} (default: @code{(httpd-config-file)})
  18515. The configuration file to use with the httpd service. The default value
  18516. is a @code{httpd-config-file} record, but this can also be a different
  18517. G-expression that generates a file, for example a @code{plain-file}. A
  18518. file outside of the store can also be specified through a string.
  18519. @end table
  18520. @end deffn
  18521. @deffn {Data Type} httpd-module
  18522. This data type represents a module for the httpd service.
  18523. @table @asis
  18524. @item @code{name}
  18525. The name of the module.
  18526. @item @code{file}
  18527. The file for the module. This can be relative to the httpd package being
  18528. used, the absolute location of a file, or a G-expression for a file
  18529. within the store, for example @code{(file-append mod-wsgi
  18530. "/modules/mod_wsgi.so")}.
  18531. @end table
  18532. @end deffn
  18533. @defvr {Scheme Variable} %default-httpd-modules
  18534. A default list of @code{httpd-module} objects.
  18535. @end defvr
  18536. @deffn {Data Type} httpd-config-file
  18537. This data type represents a configuration file for the httpd service.
  18538. @table @asis
  18539. @item @code{modules} (default: @code{%default-httpd-modules})
  18540. The modules to load. Additional modules can be added here, or loaded by
  18541. additional configuration.
  18542. For example, in order to handle requests for PHP files, you can use Apache’s
  18543. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  18544. @lisp
  18545. (service httpd-service-type
  18546. (httpd-configuration
  18547. (config
  18548. (httpd-config-file
  18549. (modules (cons*
  18550. (httpd-module
  18551. (name "proxy_module")
  18552. (file "modules/mod_proxy.so"))
  18553. (httpd-module
  18554. (name "proxy_fcgi_module")
  18555. (file "modules/mod_proxy_fcgi.so"))
  18556. %default-httpd-modules))
  18557. (extra-config (list "\
  18558. <FilesMatch \\.php$>
  18559. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  18560. </FilesMatch>"))))))
  18561. (service php-fpm-service-type
  18562. (php-fpm-configuration
  18563. (socket "/var/run/php-fpm.sock")
  18564. (socket-group "httpd")))
  18565. @end lisp
  18566. @item @code{server-root} (default: @code{httpd})
  18567. The @code{ServerRoot} in the configuration file, defaults to the httpd
  18568. package. Directives including @code{Include} and @code{LoadModule} are
  18569. taken as relative to the server root.
  18570. @item @code{server-name} (default: @code{#f})
  18571. The @code{ServerName} in the configuration file, used to specify the
  18572. request scheme, hostname and port that the server uses to identify
  18573. itself.
  18574. This doesn't need to be set in the server config, and can be specified
  18575. in virtual hosts. The default is @code{#f} to not specify a
  18576. @code{ServerName}.
  18577. @item @code{document-root} (default: @code{"/srv/http"})
  18578. The @code{DocumentRoot} from which files will be served.
  18579. @item @code{listen} (default: @code{'("80")})
  18580. The list of values for the @code{Listen} directives in the config
  18581. file. The value should be a list of strings, when each string can
  18582. specify the port number to listen on, and optionally the IP address and
  18583. protocol to use.
  18584. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  18585. The @code{PidFile} to use. This should match the @code{pid-file} set in
  18586. the @code{httpd-configuration} so that the Shepherd service is
  18587. configured correctly.
  18588. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  18589. The @code{ErrorLog} to which the server will log errors.
  18590. @item @code{user} (default: @code{"httpd"})
  18591. The @code{User} which the server will answer requests as.
  18592. @item @code{group} (default: @code{"httpd"})
  18593. The @code{Group} which the server will answer requests as.
  18594. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  18595. A flat list of strings and G-expressions which will be added to the end
  18596. of the configuration file.
  18597. Any values which the service is extended with will be appended to this
  18598. list.
  18599. @end table
  18600. @end deffn
  18601. @deffn {Data Type} httpd-virtualhost
  18602. This data type represents a virtualhost configuration block for the httpd service.
  18603. These should be added to the extra-config for the httpd-service.
  18604. @lisp
  18605. (simple-service 'www.example.com-server httpd-service-type
  18606. (list
  18607. (httpd-virtualhost
  18608. "*:80"
  18609. (list (string-join '("ServerName www.example.com"
  18610. "DocumentRoot /srv/http/www.example.com")
  18611. "\n")))))
  18612. @end lisp
  18613. @table @asis
  18614. @item @code{addresses-and-ports}
  18615. The addresses and ports for the @code{VirtualHost} directive.
  18616. @item @code{contents}
  18617. The contents of the @code{VirtualHost} directive, this should be a list
  18618. of strings and G-expressions.
  18619. @end table
  18620. @end deffn
  18621. @subsubheading NGINX
  18622. @deffn {Scheme Variable} nginx-service-type
  18623. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  18624. value for this service type is a @code{<nginx-configuration>} record.
  18625. A simple example configuration is given below.
  18626. @lisp
  18627. (service nginx-service-type
  18628. (nginx-configuration
  18629. (server-blocks
  18630. (list (nginx-server-configuration
  18631. (server-name '("www.example.com"))
  18632. (root "/srv/http/www.example.com"))))))
  18633. @end lisp
  18634. In addition to adding server blocks to the service configuration
  18635. directly, this service can be extended by other services to add server
  18636. blocks, as in this example:
  18637. @lisp
  18638. (simple-service 'my-extra-server nginx-service-type
  18639. (list (nginx-server-configuration
  18640. (root "/srv/http/extra-website")
  18641. (try-files (list "$uri" "$uri/index.html")))))
  18642. @end lisp
  18643. @end deffn
  18644. At startup, @command{nginx} has not yet read its configuration file, so
  18645. it uses a default file to log error messages. If it fails to load its
  18646. configuration file, that is where error messages are logged. After the
  18647. configuration file is loaded, the default error log file changes as per
  18648. configuration. In our case, startup error messages can be found in
  18649. @file{/var/run/nginx/logs/error.log}, and after configuration in
  18650. @file{/var/log/nginx/error.log}. The second location can be changed
  18651. with the @var{log-directory} configuration option.
  18652. @deffn {Data Type} nginx-configuration
  18653. This data type represents the configuration for NGinx. Some
  18654. configuration can be done through this and the other provided record
  18655. types, or alternatively, a config file can be provided.
  18656. @table @asis
  18657. @item @code{nginx} (default: @code{nginx})
  18658. The nginx package to use.
  18659. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  18660. The directory to which NGinx will write log files.
  18661. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  18662. The directory in which NGinx will create a pid file, and write temporary
  18663. files.
  18664. @item @code{server-blocks} (default: @code{'()})
  18665. A list of @dfn{server blocks} to create in the generated configuration
  18666. file, the elements should be of type
  18667. @code{<nginx-server-configuration>}.
  18668. The following example would setup NGinx to serve @code{www.example.com}
  18669. from the @code{/srv/http/www.example.com} directory, without using
  18670. HTTPS.
  18671. @lisp
  18672. (service nginx-service-type
  18673. (nginx-configuration
  18674. (server-blocks
  18675. (list (nginx-server-configuration
  18676. (server-name '("www.example.com"))
  18677. (root "/srv/http/www.example.com"))))))
  18678. @end lisp
  18679. @item @code{upstream-blocks} (default: @code{'()})
  18680. A list of @dfn{upstream blocks} to create in the generated configuration
  18681. file, the elements should be of type
  18682. @code{<nginx-upstream-configuration>}.
  18683. Configuring upstreams through the @code{upstream-blocks} can be useful
  18684. when combined with @code{locations} in the
  18685. @code{<nginx-server-configuration>} records. The following example
  18686. creates a server configuration with one location configuration, that
  18687. will proxy requests to a upstream configuration, which will handle
  18688. requests with two servers.
  18689. @lisp
  18690. (service
  18691. nginx-service-type
  18692. (nginx-configuration
  18693. (server-blocks
  18694. (list (nginx-server-configuration
  18695. (server-name '("www.example.com"))
  18696. (root "/srv/http/www.example.com")
  18697. (locations
  18698. (list
  18699. (nginx-location-configuration
  18700. (uri "/path1")
  18701. (body '("proxy_pass http://server-proxy;"))))))))
  18702. (upstream-blocks
  18703. (list (nginx-upstream-configuration
  18704. (name "server-proxy")
  18705. (servers (list "server1.example.com"
  18706. "server2.example.com")))))))
  18707. @end lisp
  18708. @item @code{file} (default: @code{#f})
  18709. If a configuration @var{file} is provided, this will be used, rather than
  18710. generating a configuration file from the provided @code{log-directory},
  18711. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  18712. proper operation, these arguments should match what is in @var{file} to ensure
  18713. that the directories are created when the service is activated.
  18714. This can be useful if you have an existing configuration file, or it's
  18715. not possible to do what is required through the other parts of the
  18716. nginx-configuration record.
  18717. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  18718. Bucket size for the server names hash tables, defaults to @code{#f} to
  18719. use the size of the processors cache line.
  18720. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  18721. Maximum bucket size for the server names hash tables.
  18722. @item @code{modules} (default: @code{'()})
  18723. List of nginx dynamic modules to load. This should be a list of file
  18724. names of loadable modules, as in this example:
  18725. @lisp
  18726. (modules
  18727. (list
  18728. (file-append nginx-accept-language-module "\
  18729. /etc/nginx/modules/ngx_http_accept_language_module.so")
  18730. (file-append nginx-lua-module "\
  18731. /etc/nginx/modules/ngx_http_lua_module.so")))
  18732. @end lisp
  18733. @item @code{lua-package-path} (default: @code{'()})
  18734. List of nginx lua packages to load. This should be a list of package
  18735. names of loadable lua modules, as in this example:
  18736. @lisp
  18737. (lua-package-path (list lua-resty-core
  18738. lua-resty-lrucache
  18739. lua-resty-signal
  18740. lua-tablepool
  18741. lua-resty-shell))
  18742. @end lisp
  18743. @item @code{lua-package-cpath} (default: @code{'()})
  18744. List of nginx lua C packages to load. This should be a list of package
  18745. names of loadable lua C modules, as in this example:
  18746. @lisp
  18747. (lua-package-cpath (list lua-resty-signal))
  18748. @end lisp
  18749. @item @code{global-directives} (default: @code{'((events . ()))})
  18750. Association list of global directives for the top level of the nginx
  18751. configuration. Values may themselves be association lists.
  18752. @lisp
  18753. (global-directives
  18754. `((worker_processes . 16)
  18755. (pcre_jit . on)
  18756. (events . ((worker_connections . 1024)))))
  18757. @end lisp
  18758. @item @code{extra-content} (default: @code{""})
  18759. Extra content for the @code{http} block. Should be string or a string
  18760. valued G-expression.
  18761. @end table
  18762. @end deffn
  18763. @deftp {Data Type} nginx-server-configuration
  18764. Data type representing the configuration of an nginx server block.
  18765. This type has the following parameters:
  18766. @table @asis
  18767. @item @code{listen} (default: @code{'("80" "443 ssl")})
  18768. Each @code{listen} directive sets the address and port for IP, or the
  18769. path for a UNIX-domain socket on which the server will accept requests.
  18770. Both address and port, or only address or only port can be specified.
  18771. An address may also be a hostname, for example:
  18772. @lisp
  18773. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  18774. @end lisp
  18775. @item @code{server-name} (default: @code{(list 'default)})
  18776. A list of server names this server represents. @code{'default} represents the
  18777. default server for connections matching no other server.
  18778. @item @code{root} (default: @code{"/srv/http"})
  18779. Root of the website nginx will serve.
  18780. @item @code{locations} (default: @code{'()})
  18781. A list of @dfn{nginx-location-configuration} or
  18782. @dfn{nginx-named-location-configuration} records to use within this
  18783. server block.
  18784. @item @code{index} (default: @code{(list "index.html")})
  18785. Index files to look for when clients ask for a directory. If it cannot be found,
  18786. Nginx will send the list of files in the directory.
  18787. @item @code{try-files} (default: @code{'()})
  18788. A list of files whose existence is checked in the specified order.
  18789. @code{nginx} will use the first file it finds to process the request.
  18790. @item @code{ssl-certificate} (default: @code{#f})
  18791. Where to find the certificate for secure connections. Set it to @code{#f} if
  18792. you don't have a certificate or you don't want to use HTTPS.
  18793. @item @code{ssl-certificate-key} (default: @code{#f})
  18794. Where to find the private key for secure connections. Set it to @code{#f} if
  18795. you don't have a key or you don't want to use HTTPS.
  18796. @item @code{server-tokens?} (default: @code{#f})
  18797. Whether the server should add its configuration to response.
  18798. @item @code{raw-content} (default: @code{'()})
  18799. A list of raw lines added to the server block.
  18800. @end table
  18801. @end deftp
  18802. @deftp {Data Type} nginx-upstream-configuration
  18803. Data type representing the configuration of an nginx @code{upstream}
  18804. block. This type has the following parameters:
  18805. @table @asis
  18806. @item @code{name}
  18807. Name for this group of servers.
  18808. @item @code{servers}
  18809. Specify the addresses of the servers in the group. The address can be
  18810. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  18811. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  18812. prefix @samp{unix:}. For addresses using an IP address or domain name,
  18813. the default port is 80, and a different port can be specified
  18814. explicitly.
  18815. @end table
  18816. @end deftp
  18817. @deftp {Data Type} nginx-location-configuration
  18818. Data type representing the configuration of an nginx @code{location}
  18819. block. This type has the following parameters:
  18820. @table @asis
  18821. @item @code{uri}
  18822. URI which this location block matches.
  18823. @anchor{nginx-location-configuration body}
  18824. @item @code{body}
  18825. Body of the location block, specified as a list of strings. This can contain
  18826. many
  18827. configuration directives. For example, to pass requests to a upstream
  18828. server group defined using an @code{nginx-upstream-configuration} block,
  18829. the following directive would be specified in the body @samp{(list "proxy_pass
  18830. http://upstream-name;")}.
  18831. @end table
  18832. @end deftp
  18833. @deftp {Data Type} nginx-named-location-configuration
  18834. Data type representing the configuration of an nginx named location
  18835. block. Named location blocks are used for request redirection, and not
  18836. used for regular request processing. This type has the following
  18837. parameters:
  18838. @table @asis
  18839. @item @code{name}
  18840. Name to identify this location block.
  18841. @item @code{body}
  18842. @xref{nginx-location-configuration body}, as the body for named location
  18843. blocks can be used in a similar way to the
  18844. @code{nginx-location-configuration body}. One restriction is that the
  18845. body of a named location block cannot contain location blocks.
  18846. @end table
  18847. @end deftp
  18848. @subsubheading Varnish Cache
  18849. @cindex Varnish
  18850. Varnish is a fast cache server that sits in between web applications
  18851. and end users. It proxies requests from clients and caches the
  18852. accessed URLs such that multiple requests for the same resource only
  18853. creates one request to the back-end.
  18854. @defvr {Scheme Variable} varnish-service-type
  18855. Service type for the Varnish daemon.
  18856. @end defvr
  18857. @deftp {Data Type} varnish-configuration
  18858. Data type representing the @code{varnish} service configuration.
  18859. This type has the following parameters:
  18860. @table @asis
  18861. @item @code{package} (default: @code{varnish})
  18862. The Varnish package to use.
  18863. @item @code{name} (default: @code{"default"})
  18864. A name for this Varnish instance. Varnish will create a directory in
  18865. @file{/var/varnish/} with this name and keep temporary files there. If
  18866. the name starts with a forward slash, it is interpreted as an absolute
  18867. directory name.
  18868. Pass the @code{-n} argument to other Varnish programs to connect to the
  18869. named instance, e.g.@: @command{varnishncsa -n default}.
  18870. @item @code{backend} (default: @code{"localhost:8080"})
  18871. The backend to use. This option has no effect if @code{vcl} is set.
  18872. @item @code{vcl} (default: #f)
  18873. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  18874. is @code{#f}, Varnish will proxy @code{backend} using the default
  18875. configuration. Otherwise this must be a file-like object with valid
  18876. VCL syntax.
  18877. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  18878. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  18879. can do something along these lines:
  18880. @lisp
  18881. (define %gnu-mirror
  18882. (plain-file "gnu.vcl"
  18883. "vcl 4.1;
  18884. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  18885. (operating-system
  18886. ;; @dots{}
  18887. (services (cons (service varnish-service-type
  18888. (varnish-configuration
  18889. (listen '(":80"))
  18890. (vcl %gnu-mirror)))
  18891. %base-services)))
  18892. @end lisp
  18893. The configuration of an already running Varnish instance can be inspected
  18894. and changed using the @command{varnishadm} program.
  18895. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  18896. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  18897. comprehensive documentation on Varnish and its configuration language.
  18898. @item @code{listen} (default: @code{'("localhost:80")})
  18899. List of addresses Varnish will listen on.
  18900. @item @code{storage} (default: @code{'("malloc,128m")})
  18901. List of storage backends that will be available in VCL.
  18902. @item @code{parameters} (default: @code{'()})
  18903. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  18904. @item @code{extra-options} (default: @code{'()})
  18905. Additional arguments to pass to the @command{varnishd} process.
  18906. @end table
  18907. @end deftp
  18908. @subsubheading Patchwork
  18909. @cindex Patchwork
  18910. Patchwork is a patch tracking system. It can collect patches sent to a
  18911. mailing list, and display them in a web interface.
  18912. @defvr {Scheme Variable} patchwork-service-type
  18913. Service type for Patchwork.
  18914. @end defvr
  18915. The following example is an example of a minimal service for Patchwork, for
  18916. the @code{patchwork.example.com} domain.
  18917. @lisp
  18918. (service patchwork-service-type
  18919. (patchwork-configuration
  18920. (domain "patchwork.example.com")
  18921. (settings-module
  18922. (patchwork-settings-module
  18923. (allowed-hosts (list domain))
  18924. (default-from-email "patchwork@@patchwork.example.com")))
  18925. (getmail-retriever-config
  18926. (getmail-retriever-configuration
  18927. (type "SimpleIMAPSSLRetriever")
  18928. (server "imap.example.com")
  18929. (port 993)
  18930. (username "patchwork")
  18931. (password-command
  18932. (list (file-append coreutils "/bin/cat")
  18933. "/etc/getmail-patchwork-imap-password"))
  18934. (extra-parameters
  18935. '((mailboxes . ("Patches"))))))))
  18936. @end lisp
  18937. There are three records for configuring the Patchwork service. The
  18938. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  18939. within the HTTPD service.
  18940. The @code{settings-module} field within the @code{<patchwork-configuration>}
  18941. record can be populated with the @code{<patchwork-settings-module>} record,
  18942. which describes a settings module that is generated within the Guix store.
  18943. For the @code{database-configuration} field within the
  18944. @code{<patchwork-settings-module>}, the
  18945. @code{<patchwork-database-configuration>} must be used.
  18946. @deftp {Data Type} patchwork-configuration
  18947. Data type representing the Patchwork service configuration. This type has the
  18948. following parameters:
  18949. @table @asis
  18950. @item @code{patchwork} (default: @code{patchwork})
  18951. The Patchwork package to use.
  18952. @item @code{domain}
  18953. The domain to use for Patchwork, this is used in the HTTPD service virtual
  18954. host.
  18955. @item @code{settings-module}
  18956. The settings module to use for Patchwork. As a Django application, Patchwork
  18957. is configured with a Python module containing the settings. This can either be
  18958. an instance of the @code{<patchwork-settings-module>} record, any other record
  18959. that represents the settings in the store, or a directory outside of the
  18960. store.
  18961. @item @code{static-path} (default: @code{"/static/"})
  18962. The path under which the HTTPD service should serve the static files.
  18963. @item @code{getmail-retriever-config}
  18964. The getmail-retriever-configuration record value to use with
  18965. Patchwork. Getmail will be configured with this value, the messages will be
  18966. delivered to Patchwork.
  18967. @end table
  18968. @end deftp
  18969. @deftp {Data Type} patchwork-settings-module
  18970. Data type representing a settings module for Patchwork. Some of these
  18971. settings relate directly to Patchwork, but others relate to Django, the web
  18972. framework used by Patchwork, or the Django Rest Framework library. This type
  18973. has the following parameters:
  18974. @table @asis
  18975. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  18976. The database connection settings used for Patchwork. See the
  18977. @code{<patchwork-database-configuration>} record type for more information.
  18978. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  18979. Patchwork, as a Django web application uses a secret key for cryptographically
  18980. signing values. This file should contain a unique unpredictable value.
  18981. If this file does not exist, it will be created and populated with a random
  18982. value by the patchwork-setup shepherd service.
  18983. This setting relates to Django.
  18984. @item @code{allowed-hosts}
  18985. A list of valid hosts for this Patchwork service. This should at least include
  18986. the domain specified in the @code{<patchwork-configuration>} record.
  18987. This is a Django setting.
  18988. @item @code{default-from-email}
  18989. The email address from which Patchwork should send email by default.
  18990. This is a Patchwork setting.
  18991. @item @code{static-url} (default: @code{#f})
  18992. The URL to use when serving static assets. It can be part of a URL, or a full
  18993. URL, but must end in a @code{/}.
  18994. If the default value is used, the @code{static-path} value from the
  18995. @code{<patchwork-configuration>} record will be used.
  18996. This is a Django setting.
  18997. @item @code{admins} (default: @code{'()})
  18998. Email addresses to send the details of errors that occur. Each value should
  18999. be a list containing two elements, the name and then the email address.
  19000. This is a Django setting.
  19001. @item @code{debug?} (default: @code{#f})
  19002. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  19003. messages will be shown.
  19004. This is a Django setting.
  19005. @item @code{enable-rest-api?} (default: @code{#t})
  19006. Whether to enable the Patchwork REST API.
  19007. This is a Patchwork setting.
  19008. @item @code{enable-xmlrpc?} (default: @code{#t})
  19009. Whether to enable the XML RPC API.
  19010. This is a Patchwork setting.
  19011. @item @code{force-https-links?} (default: @code{#t})
  19012. Whether to use HTTPS links on Patchwork pages.
  19013. This is a Patchwork setting.
  19014. @item @code{extra-settings} (default: @code{""})
  19015. Extra code to place at the end of the Patchwork settings module.
  19016. @end table
  19017. @end deftp
  19018. @deftp {Data Type} patchwork-database-configuration
  19019. Data type representing the database configuration for Patchwork.
  19020. @table @asis
  19021. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  19022. The database engine to use.
  19023. @item @code{name} (default: @code{"patchwork"})
  19024. The name of the database to use.
  19025. @item @code{user} (default: @code{"httpd"})
  19026. The user to connect to the database as.
  19027. @item @code{password} (default: @code{""})
  19028. The password to use when connecting to the database.
  19029. @item @code{host} (default: @code{""})
  19030. The host to make the database connection to.
  19031. @item @code{port} (default: @code{""})
  19032. The port on which to connect to the database.
  19033. @end table
  19034. @end deftp
  19035. @subsubheading Mumi
  19036. @cindex Mumi, Debbugs Web interface
  19037. @cindex Debbugs, Mumi Web interface
  19038. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  19039. Web interface to the Debbugs bug tracker, by default for
  19040. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  19041. but it also fetches and indexes mail retrieved from Debbugs.
  19042. @defvr {Scheme Variable} mumi-service-type
  19043. This is the service type for Mumi.
  19044. @end defvr
  19045. @deftp {Data Type} mumi-configuration
  19046. Data type representing the Mumi service configuration. This type has the
  19047. following fields:
  19048. @table @asis
  19049. @item @code{mumi} (default: @code{mumi})
  19050. The Mumi package to use.
  19051. @item @code{mailer?} (default: @code{#true})
  19052. Whether to enable or disable the mailer component.
  19053. @item @code{mumi-configuration-sender}
  19054. The email address used as the sender for comments.
  19055. @item @code{mumi-configuration-smtp}
  19056. A URI to configure the SMTP settings for Mailutils. This could be
  19057. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  19058. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  19059. mailutils, GNU@tie{}Mailutils}.
  19060. @end table
  19061. @end deftp
  19062. @subsubheading FastCGI
  19063. @cindex fastcgi
  19064. @cindex fcgiwrap
  19065. FastCGI is an interface between the front-end and the back-end of a web
  19066. service. It is a somewhat legacy facility; new web services should
  19067. generally just talk HTTP between the front-end and the back-end.
  19068. However there are a number of back-end services such as PHP or the
  19069. optimized HTTP Git repository access that use FastCGI, so we have
  19070. support for it in Guix.
  19071. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  19072. dispatch some subset of its requests to the fastcgi backend, which
  19073. listens on a local TCP or UNIX socket. There is an intermediary
  19074. @code{fcgiwrap} program that sits between the actual backend process and
  19075. the web server. The front-end indicates which backend program to run,
  19076. passing that information to the @code{fcgiwrap} process.
  19077. @defvr {Scheme Variable} fcgiwrap-service-type
  19078. A service type for the @code{fcgiwrap} FastCGI proxy.
  19079. @end defvr
  19080. @deftp {Data Type} fcgiwrap-configuration
  19081. Data type representing the configuration of the @code{fcgiwrap} service.
  19082. This type has the following parameters:
  19083. @table @asis
  19084. @item @code{package} (default: @code{fcgiwrap})
  19085. The fcgiwrap package to use.
  19086. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  19087. The socket on which the @code{fcgiwrap} process should listen, as a
  19088. string. Valid @var{socket} values include
  19089. @code{unix:@var{/path/to/unix/socket}},
  19090. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  19091. @code{tcp6:[@var{ipv6_addr}]:port}.
  19092. @item @code{user} (default: @code{fcgiwrap})
  19093. @itemx @code{group} (default: @code{fcgiwrap})
  19094. The user and group names, as strings, under which to run the
  19095. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  19096. the user asks for the specific user or group names @code{fcgiwrap} that
  19097. the corresponding user and/or group is present on the system.
  19098. It is possible to configure a FastCGI-backed web service to pass HTTP
  19099. authentication information from the front-end to the back-end, and to
  19100. allow @code{fcgiwrap} to run the back-end process as a corresponding
  19101. local user. To enable this capability on the back-end, run
  19102. @code{fcgiwrap} as the @code{root} user and group. Note that this
  19103. capability also has to be configured on the front-end as well.
  19104. @end table
  19105. @end deftp
  19106. @cindex php-fpm
  19107. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  19108. with some additional features useful for sites of any size.
  19109. These features include:
  19110. @itemize @bullet
  19111. @item Adaptive process spawning
  19112. @item Basic statistics (similar to Apache's mod_status)
  19113. @item Advanced process management with graceful stop/start
  19114. @item Ability to start workers with different uid/gid/chroot/environment
  19115. and different php.ini (replaces safe_mode)
  19116. @item Stdout & stderr logging
  19117. @item Emergency restart in case of accidental opcode cache destruction
  19118. @item Accelerated upload support
  19119. @item Support for a "slowlog"
  19120. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  19121. a special function to finish request & flush all data while continuing to do
  19122. something time-consuming (video converting, stats processing, etc.)
  19123. @end itemize
  19124. ...@: and much more.
  19125. @defvr {Scheme Variable} php-fpm-service-type
  19126. A Service type for @code{php-fpm}.
  19127. @end defvr
  19128. @deftp {Data Type} php-fpm-configuration
  19129. Data Type for php-fpm service configuration.
  19130. @table @asis
  19131. @item @code{php} (default: @code{php})
  19132. The php package to use.
  19133. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  19134. The address on which to accept FastCGI requests. Valid syntaxes are:
  19135. @table @asis
  19136. @item @code{"ip.add.re.ss:port"}
  19137. Listen on a TCP socket to a specific address on a specific port.
  19138. @item @code{"port"}
  19139. Listen on a TCP socket to all addresses on a specific port.
  19140. @item @code{"/path/to/unix/socket"}
  19141. Listen on a unix socket.
  19142. @end table
  19143. @item @code{user} (default: @code{php-fpm})
  19144. User who will own the php worker processes.
  19145. @item @code{group} (default: @code{php-fpm})
  19146. Group of the worker processes.
  19147. @item @code{socket-user} (default: @code{php-fpm})
  19148. User who can speak to the php-fpm socket.
  19149. @item @code{socket-group} (default: @code{nginx})
  19150. Group that can speak to the php-fpm socket.
  19151. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  19152. The process id of the php-fpm process is written to this file
  19153. once the service has started.
  19154. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  19155. Log for the php-fpm master process.
  19156. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  19157. Detailed settings for the php-fpm process manager.
  19158. Must be one of:
  19159. @table @asis
  19160. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  19161. @item @code{<php-fpm-static-process-manager-configuration>}
  19162. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  19163. @end table
  19164. @item @code{display-errors} (default @code{#f})
  19165. Determines whether php errors and warning should be sent to clients
  19166. and displayed in their browsers.
  19167. This is useful for local php development, but a security risk for public sites,
  19168. as error messages can reveal passwords and personal data.
  19169. @item @code{timezone} (default @code{#f})
  19170. Specifies @code{php_admin_value[date.timezone]} parameter.
  19171. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  19172. This file will log the @code{stderr} outputs of php worker processes.
  19173. Can be set to @code{#f} to disable logging.
  19174. @item @code{file} (default @code{#f})
  19175. An optional override of the whole configuration.
  19176. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  19177. @item @code{php-ini-file} (default @code{#f})
  19178. An optional override of the default php settings.
  19179. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  19180. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  19181. For local development it is useful to set a higher timeout and memory
  19182. limit for spawned php processes. This be accomplished with the
  19183. following operating system configuration snippet:
  19184. @lisp
  19185. (define %local-php-ini
  19186. (plain-file "php.ini"
  19187. "memory_limit = 2G
  19188. max_execution_time = 1800"))
  19189. (operating-system
  19190. ;; @dots{}
  19191. (services (cons (service php-fpm-service-type
  19192. (php-fpm-configuration
  19193. (php-ini-file %local-php-ini)))
  19194. %base-services)))
  19195. @end lisp
  19196. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  19197. directives} for comprehensive documentation on the acceptable
  19198. @file{php.ini} directives.
  19199. @end table
  19200. @end deftp
  19201. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  19202. Data Type for the @code{dynamic} php-fpm process manager. With the
  19203. @code{dynamic} process manager, spare worker processes are kept around
  19204. based on it's configured limits.
  19205. @table @asis
  19206. @item @code{max-children} (default: @code{5})
  19207. Maximum of worker processes.
  19208. @item @code{start-servers} (default: @code{2})
  19209. How many worker processes should be started on start-up.
  19210. @item @code{min-spare-servers} (default: @code{1})
  19211. How many spare worker processes should be kept around at minimum.
  19212. @item @code{max-spare-servers} (default: @code{3})
  19213. How many spare worker processes should be kept around at maximum.
  19214. @end table
  19215. @end deftp
  19216. @deftp {Data type} php-fpm-static-process-manager-configuration
  19217. Data Type for the @code{static} php-fpm process manager. With the
  19218. @code{static} process manager, an unchanging number of worker processes
  19219. are created.
  19220. @table @asis
  19221. @item @code{max-children} (default: @code{5})
  19222. Maximum of worker processes.
  19223. @end table
  19224. @end deftp
  19225. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  19226. Data Type for the @code{on-demand} php-fpm process manager. With the
  19227. @code{on-demand} process manager, worker processes are only created as
  19228. requests arrive.
  19229. @table @asis
  19230. @item @code{max-children} (default: @code{5})
  19231. Maximum of worker processes.
  19232. @item @code{process-idle-timeout} (default: @code{10})
  19233. The time in seconds after which a process with no requests is killed.
  19234. @end table
  19235. @end deftp
  19236. @deffn {Scheme Procedure} nginx-php-location @
  19237. [#:nginx-package nginx] @
  19238. [socket (string-append "/var/run/php" @
  19239. (version-major (package-version php)) @
  19240. "-fpm.sock")]
  19241. A helper function to quickly add php to an @code{nginx-server-configuration}.
  19242. @end deffn
  19243. A simple services setup for nginx with php can look like this:
  19244. @lisp
  19245. (services (cons* (service dhcp-client-service-type)
  19246. (service php-fpm-service-type)
  19247. (service nginx-service-type
  19248. (nginx-server-configuration
  19249. (server-name '("example.com"))
  19250. (root "/srv/http/")
  19251. (locations
  19252. (list (nginx-php-location)))
  19253. (listen '("80"))
  19254. (ssl-certificate #f)
  19255. (ssl-certificate-key #f)))
  19256. %base-services))
  19257. @end lisp
  19258. @cindex cat-avatar-generator
  19259. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  19260. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  19261. the hash of a user's email address.
  19262. @deffn {Scheme Procedure} cat-avatar-generator-service @
  19263. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  19264. [#:package cat-avatar-generator] @
  19265. [#:configuration (nginx-server-configuration)]
  19266. Returns an nginx-server-configuration that inherits @code{configuration}. It
  19267. extends the nginx configuration to add a server block that serves @code{package},
  19268. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  19269. be able to use @code{cache-dir} as its cache directory.
  19270. @end deffn
  19271. A simple setup for cat-avatar-generator can look like this:
  19272. @lisp
  19273. (services (cons* (cat-avatar-generator-service
  19274. #:configuration
  19275. (nginx-server-configuration
  19276. (server-name '("example.com"))))
  19277. ...
  19278. %base-services))
  19279. @end lisp
  19280. @subsubheading Hpcguix-web
  19281. @cindex hpcguix-web
  19282. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  19283. program is a customizable web interface to browse Guix packages,
  19284. initially designed for users of high-performance computing (HPC)
  19285. clusters.
  19286. @defvr {Scheme Variable} hpcguix-web-service-type
  19287. The service type for @code{hpcguix-web}.
  19288. @end defvr
  19289. @deftp {Data Type} hpcguix-web-configuration
  19290. Data type for the hpcguix-web service configuration.
  19291. @table @asis
  19292. @item @code{specs}
  19293. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  19294. configuration. The main items available in this spec are:
  19295. @table @asis
  19296. @item @code{title-prefix} (default: @code{"hpcguix | "})
  19297. The page title prefix.
  19298. @item @code{guix-command} (default: @code{"guix"})
  19299. The @command{guix} command.
  19300. @item @code{package-filter-proc} (default: @code{(const #t)})
  19301. A procedure specifying how to filter packages that are displayed.
  19302. @item @code{package-page-extension-proc} (default: @code{(const '())})
  19303. Extension package for @code{hpcguix-web}.
  19304. @item @code{menu} (default: @code{'()})
  19305. Additional entry in page @code{menu}.
  19306. @item @code{channels} (default: @code{%default-channels})
  19307. List of channels from which the package list is built (@pxref{Channels}).
  19308. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  19309. The expiration time, in seconds, after which the package list is rebuilt from
  19310. the latest instances of the given channels.
  19311. @end table
  19312. See the hpcguix-web repository for a
  19313. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  19314. complete example}.
  19315. @item @code{package} (default: @code{hpcguix-web})
  19316. The hpcguix-web package to use.
  19317. @end table
  19318. @end deftp
  19319. A typical hpcguix-web service declaration looks like this:
  19320. @lisp
  19321. (service hpcguix-web-service-type
  19322. (hpcguix-web-configuration
  19323. (specs
  19324. #~(define site-config
  19325. (hpcweb-configuration
  19326. (title-prefix "Guix-HPC - ")
  19327. (menu '(("/about" "ABOUT"))))))))
  19328. @end lisp
  19329. @quotation Note
  19330. The hpcguix-web service periodically updates the package list it publishes by
  19331. pulling channels from Git. To that end, it needs to access X.509 certificates
  19332. so that it can authenticate Git servers when communicating over HTTPS, and it
  19333. assumes that @file{/etc/ssl/certs} contains those certificates.
  19334. Thus, make sure to add @code{nss-certs} or another certificate package to the
  19335. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  19336. more information on X.509 certificates.
  19337. @end quotation
  19338. @subsubheading gmnisrv
  19339. @cindex gmnisrv
  19340. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  19341. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  19342. @deffn {Scheme Variable} gmnisrv-service-type
  19343. This is the type of the gmnisrv service, whose value should be a
  19344. @code{gmnisrv-configuration} object, as in this example:
  19345. @lisp
  19346. (service gmnisrv-service-type
  19347. (gmnisrv-configuration
  19348. (config-file (local-file "./my-gmnisrv.ini"))))
  19349. @end lisp
  19350. @end deffn
  19351. @deftp {Data Type} gmnisrv-configuration
  19352. Data type representing the configuration of gmnisrv.
  19353. @table @asis
  19354. @item @code{package} (default: @var{gmnisrv})
  19355. Package object of the gmnisrv server.
  19356. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  19357. File-like object of the gmnisrv configuration file to use. The default
  19358. configuration listens on port 1965 and serves files from
  19359. @file{/srv/gemini}. Certificates are stored in
  19360. @file{/var/lib/gemini/certs}. For more information, run @command{man
  19361. gmnisrv} and @command{man gmnisrv.ini}.
  19362. @end table
  19363. @end deftp
  19364. @node Certificate Services
  19365. @subsection Certificate Services
  19366. @cindex Web
  19367. @cindex HTTP, HTTPS
  19368. @cindex Let's Encrypt
  19369. @cindex TLS certificates
  19370. The @code{(gnu services certbot)} module provides a service to
  19371. automatically obtain a valid TLS certificate from the Let's Encrypt
  19372. certificate authority. These certificates can then be used to serve
  19373. content securely over HTTPS or other TLS-based protocols, with the
  19374. knowledge that the client will be able to verify the server's
  19375. authenticity.
  19376. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  19377. @code{certbot} tool to automate the certification process. This tool
  19378. first securely generates a key on the server. It then makes a request
  19379. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  19380. checks that the request originates from the host in question by using a
  19381. challenge-response protocol, requiring the server to provide its
  19382. response over HTTP@. If that protocol completes successfully, the CA
  19383. signs the key, resulting in a certificate. That certificate is valid
  19384. for a limited period of time, and therefore to continue to provide TLS
  19385. services, the server needs to periodically ask the CA to renew its
  19386. signature.
  19387. The certbot service automates this process: the initial key
  19388. generation, the initial certification request to the Let's Encrypt
  19389. service, the web server challenge/response integration, writing the
  19390. certificate to disk, the automated periodic renewals, and the deployment
  19391. tasks associated with the renewal (e.g.@: reloading services, copying keys
  19392. with different permissions).
  19393. Certbot is run twice a day, at a random minute within the hour. It
  19394. won't do anything until your certificates are due for renewal or
  19395. revoked, but running it regularly would give your service a chance of
  19396. staying online in case a Let's Encrypt-initiated revocation happened for
  19397. some reason.
  19398. By using this service, you agree to the ACME Subscriber Agreement, which
  19399. can be found there:
  19400. @url{https://acme-v01.api.letsencrypt.org/directory}.
  19401. @defvr {Scheme Variable} certbot-service-type
  19402. A service type for the @code{certbot} Let's Encrypt client. Its value
  19403. must be a @code{certbot-configuration} record as in this example:
  19404. @lisp
  19405. (define %nginx-deploy-hook
  19406. (program-file
  19407. "nginx-deploy-hook"
  19408. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  19409. (kill pid SIGHUP))))
  19410. (service certbot-service-type
  19411. (certbot-configuration
  19412. (email "foo@@example.net")
  19413. (certificates
  19414. (list
  19415. (certificate-configuration
  19416. (domains '("example.net" "www.example.net"))
  19417. (deploy-hook %nginx-deploy-hook))
  19418. (certificate-configuration
  19419. (domains '("bar.example.net")))))))
  19420. @end lisp
  19421. See below for details about @code{certbot-configuration}.
  19422. @end defvr
  19423. @deftp {Data Type} certbot-configuration
  19424. Data type representing the configuration of the @code{certbot} service.
  19425. This type has the following parameters:
  19426. @table @asis
  19427. @item @code{package} (default: @code{certbot})
  19428. The certbot package to use.
  19429. @item @code{webroot} (default: @code{/var/www})
  19430. The directory from which to serve the Let's Encrypt challenge/response
  19431. files.
  19432. @item @code{certificates} (default: @code{()})
  19433. A list of @code{certificates-configuration}s for which to generate
  19434. certificates and request signatures. Each certificate has a @code{name}
  19435. and several @code{domains}.
  19436. @item @code{email} (default: @code{#f})
  19437. Optional email address used for registration and recovery contact.
  19438. Setting this is encouraged as it allows you to receive important
  19439. notifications about the account and issued certificates.
  19440. @item @code{server} (default: @code{#f})
  19441. Optional URL of ACME server. Setting this overrides certbot's default,
  19442. which is the Let's Encrypt server.
  19443. @item @code{rsa-key-size} (default: @code{2048})
  19444. Size of the RSA key.
  19445. @item @code{default-location} (default: @i{see below})
  19446. The default @code{nginx-location-configuration}. Because @code{certbot}
  19447. needs to be able to serve challenges and responses, it needs to be able
  19448. to run a web server. It does so by extending the @code{nginx} web
  19449. service with an @code{nginx-server-configuration} listening on the
  19450. @var{domains} on port 80, and which has a
  19451. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  19452. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  19453. these nginx configuration data types.
  19454. Requests to other URL paths will be matched by the
  19455. @code{default-location}, which if present is added to all
  19456. @code{nginx-server-configuration}s.
  19457. By default, the @code{default-location} will issue a redirect from
  19458. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  19459. you to define what to serve on your site via @code{https}.
  19460. Pass @code{#f} to not issue a default location.
  19461. @end table
  19462. @end deftp
  19463. @deftp {Data Type} certificate-configuration
  19464. Data type representing the configuration of a certificate.
  19465. This type has the following parameters:
  19466. @table @asis
  19467. @item @code{name} (default: @i{see below})
  19468. This name is used by Certbot for housekeeping and in file paths; it
  19469. doesn't affect the content of the certificate itself. To see
  19470. certificate names, run @code{certbot certificates}.
  19471. Its default is the first provided domain.
  19472. @item @code{domains} (default: @code{()})
  19473. The first domain provided will be the subject CN of the certificate, and
  19474. all domains will be Subject Alternative Names on the certificate.
  19475. @item @code{challenge} (default: @code{#f})
  19476. The challenge type that has to be run by certbot. If @code{#f} is specified,
  19477. default to the HTTP challenge. If a value is specified, defaults to the
  19478. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  19479. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  19480. and gives Let's Encrypt permission to log the public IP address of the
  19481. requesting machine.
  19482. @item @code{authentication-hook} (default: @code{#f})
  19483. Command to be run in a shell once for each certificate challenge to be
  19484. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  19485. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  19486. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  19487. file name of the resource requested when performing an HTTP-01 challenge.
  19488. @item @code{cleanup-hook} (default: @code{#f})
  19489. Command to be run in a shell once for each certificate challenge that
  19490. have been answered by the @code{auth-hook}. For this command, the shell
  19491. variables available in the @code{auth-hook} script are still available, and
  19492. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  19493. of the @code{auth-hook} script.
  19494. @item @code{deploy-hook} (default: @code{#f})
  19495. Command to be run in a shell once for each successfully issued
  19496. certificate. For this command, the shell variable
  19497. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  19498. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  19499. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  19500. contain a space-delimited list of renewed certificate domains (for
  19501. example, @samp{"example.com www.example.com"}.
  19502. @end table
  19503. @end deftp
  19504. For each @code{certificate-configuration}, the certificate is saved to
  19505. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  19506. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  19507. @node DNS Services
  19508. @subsection DNS Services
  19509. @cindex DNS (domain name system)
  19510. @cindex domain name system (DNS)
  19511. The @code{(gnu services dns)} module provides services related to the
  19512. @dfn{domain name system} (DNS). It provides a server service for hosting
  19513. an @emph{authoritative} DNS server for multiple zones, slave or master.
  19514. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  19515. caching and forwarding DNS server for the LAN, which uses
  19516. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  19517. @subsubheading Knot Service
  19518. An example configuration of an authoritative server for two zones, one master
  19519. and one slave, is:
  19520. @lisp
  19521. (define-zone-entries example.org.zone
  19522. ;; Name TTL Class Type Data
  19523. ("@@" "" "IN" "A" "127.0.0.1")
  19524. ("@@" "" "IN" "NS" "ns")
  19525. ("ns" "" "IN" "A" "127.0.0.1"))
  19526. (define master-zone
  19527. (knot-zone-configuration
  19528. (domain "example.org")
  19529. (zone (zone-file
  19530. (origin "example.org")
  19531. (entries example.org.zone)))))
  19532. (define slave-zone
  19533. (knot-zone-configuration
  19534. (domain "plop.org")
  19535. (dnssec-policy "default")
  19536. (master (list "plop-master"))))
  19537. (define plop-master
  19538. (knot-remote-configuration
  19539. (id "plop-master")
  19540. (address (list "208.76.58.171"))))
  19541. (operating-system
  19542. ;; ...
  19543. (services (cons* (service knot-service-type
  19544. (knot-configuration
  19545. (remotes (list plop-master))
  19546. (zones (list master-zone slave-zone))))
  19547. ;; ...
  19548. %base-services)))
  19549. @end lisp
  19550. @deffn {Scheme Variable} knot-service-type
  19551. This is the type for the Knot DNS server.
  19552. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  19553. zones, that is to say domain names you would buy from a registrar. This server
  19554. is not a resolver, meaning that it can only resolve names for which it is
  19555. authoritative. This server can be configured to serve zones as a master server
  19556. or a slave server as a per-zone basis. Slave zones will get their data from
  19557. masters, and will serve it as an authoritative server. From the point of view
  19558. of a resolver, there is no difference between master and slave.
  19559. The following data types are used to configure the Knot DNS server:
  19560. @end deffn
  19561. @deftp {Data Type} knot-key-configuration
  19562. Data type representing a key.
  19563. This type has the following parameters:
  19564. @table @asis
  19565. @item @code{id} (default: @code{""})
  19566. An identifier for other configuration fields to refer to this key. IDs must
  19567. be unique and must not be empty.
  19568. @item @code{algorithm} (default: @code{#f})
  19569. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  19570. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  19571. and @code{'hmac-sha512}.
  19572. @item @code{secret} (default: @code{""})
  19573. The secret key itself.
  19574. @end table
  19575. @end deftp
  19576. @deftp {Data Type} knot-acl-configuration
  19577. Data type representing an Access Control List (ACL) configuration.
  19578. This type has the following parameters:
  19579. @table @asis
  19580. @item @code{id} (default: @code{""})
  19581. An identifier for other configuration fields to refer to this key. IDs must be
  19582. unique and must not be empty.
  19583. @item @code{address} (default: @code{'()})
  19584. An ordered list of IP addresses, network subnets, or network ranges represented
  19585. with strings. The query must match one of them. Empty value means that
  19586. address match is not required.
  19587. @item @code{key} (default: @code{'()})
  19588. An ordered list of references to keys represented with strings. The string
  19589. must match a key ID defined in a @code{knot-key-configuration}. No key means
  19590. that a key is not require to match that ACL.
  19591. @item @code{action} (default: @code{'()})
  19592. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  19593. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  19594. and @code{'update}.
  19595. @item @code{deny?} (default: @code{#f})
  19596. When true, the ACL defines restrictions. Listed actions are forbidden. When
  19597. false, listed actions are allowed.
  19598. @end table
  19599. @end deftp
  19600. @deftp {Data Type} zone-entry
  19601. Data type representing a record entry in a zone file.
  19602. This type has the following parameters:
  19603. @table @asis
  19604. @item @code{name} (default: @code{"@@"})
  19605. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  19606. are relative to the origin of the zone. For example, in the @code{example.org}
  19607. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  19608. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  19609. refers to @code{ns.example.org}.
  19610. @item @code{ttl} (default: @code{""})
  19611. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  19612. @item @code{class} (default: @code{"IN"})
  19613. The class of the record. Knot currently supports only @code{"IN"} and
  19614. partially @code{"CH"}.
  19615. @item @code{type} (default: @code{"A"})
  19616. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  19617. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  19618. defined.
  19619. @item @code{data} (default: @code{""})
  19620. The data contained in the record. For instance an IP address associated with
  19621. an A record, or a domain name associated with an NS record. Remember that
  19622. domain names are relative to the origin unless they end with a dot.
  19623. @end table
  19624. @end deftp
  19625. @deftp {Data Type} zone-file
  19626. Data type representing the content of a zone file.
  19627. This type has the following parameters:
  19628. @table @asis
  19629. @item @code{entries} (default: @code{'()})
  19630. The list of entries. The SOA record is taken care of, so you don't need to
  19631. put it in the list of entries. This list should probably contain an entry
  19632. for your primary authoritative DNS server. Other than using a list of entries
  19633. directly, you can use @code{define-zone-entries} to define a object containing
  19634. the list of entries more easily, that you can later pass to the @code{entries}
  19635. field of the @code{zone-file}.
  19636. @item @code{origin} (default: @code{""})
  19637. The name of your zone. This parameter cannot be empty.
  19638. @item @code{ns} (default: @code{"ns"})
  19639. The domain of your primary authoritative DNS server. The name is relative to
  19640. the origin, unless it ends with a dot. It is mandatory that this primary
  19641. DNS server corresponds to an NS record in the zone and that it is associated
  19642. to an IP address in the list of entries.
  19643. @item @code{mail} (default: @code{"hostmaster"})
  19644. An email address people can contact you at, as the owner of the zone. This
  19645. is translated as @code{<mail>@@<origin>}.
  19646. @item @code{serial} (default: @code{1})
  19647. The serial number of the zone. As this is used to keep track of changes by
  19648. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  19649. Always increment it when you make a change in your zone.
  19650. @item @code{refresh} (default: @code{(* 2 24 3600)})
  19651. The frequency at which slaves will do a zone transfer. This value is a number
  19652. of seconds. It can be computed by multiplications or with
  19653. @code{(string->duration)}.
  19654. @item @code{retry} (default: @code{(* 15 60)})
  19655. The period after which a slave will retry to contact its master when it fails
  19656. to do so a first time.
  19657. @item @code{expiry} (default: @code{(* 14 24 3600)})
  19658. Default TTL of records. Existing records are considered correct for at most
  19659. this amount of time. After this period, resolvers will invalidate their cache
  19660. and check again that it still exists.
  19661. @item @code{nx} (default: @code{3600})
  19662. Default TTL of inexistant records. This delay is usually short because you want
  19663. your new domains to reach everyone quickly.
  19664. @end table
  19665. @end deftp
  19666. @deftp {Data Type} knot-remote-configuration
  19667. Data type representing a remote configuration.
  19668. This type has the following parameters:
  19669. @table @asis
  19670. @item @code{id} (default: @code{""})
  19671. An identifier for other configuration fields to refer to this remote. IDs must
  19672. be unique and must not be empty.
  19673. @item @code{address} (default: @code{'()})
  19674. An ordered list of destination IP addresses. Addresses are tried in sequence.
  19675. An optional port can be given with the @@ separator. For instance:
  19676. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  19677. @item @code{via} (default: @code{'()})
  19678. An ordered list of source IP addresses. An empty list will have Knot choose
  19679. an appropriate source IP@. An optional port can be given with the @@ separator.
  19680. The default is to choose at random.
  19681. @item @code{key} (default: @code{#f})
  19682. A reference to a key, that is a string containing the identifier of a key
  19683. defined in a @code{knot-key-configuration} field.
  19684. @end table
  19685. @end deftp
  19686. @deftp {Data Type} knot-keystore-configuration
  19687. Data type representing a keystore to hold dnssec keys.
  19688. This type has the following parameters:
  19689. @table @asis
  19690. @item @code{id} (default: @code{""})
  19691. The id of the keystore. It must not be empty.
  19692. @item @code{backend} (default: @code{'pem})
  19693. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  19694. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  19695. The configuration string of the backend. An example for the PKCS#11 is:
  19696. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  19697. For the pem backend, the string represents a path in the file system.
  19698. @end table
  19699. @end deftp
  19700. @deftp {Data Type} knot-policy-configuration
  19701. Data type representing a dnssec policy. Knot DNS is able to automatically
  19702. sign your zones. It can either generate and manage your keys automatically or
  19703. use keys that you generate.
  19704. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  19705. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  19706. zone. In order to be trusted, the KSK needs to be present in the parent zone
  19707. (usually a top-level domain). If your registrar supports dnssec, you will
  19708. have to send them your KSK's hash so they can add a DS record in their zone.
  19709. This is not automated and need to be done each time you change your KSK.
  19710. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  19711. easily and use weaker cryptographic functions (they use lower parameters) in
  19712. order to sign records quickly, so they are changed often. The KSK however
  19713. requires manual interaction with the registrar, so they are changed less often
  19714. and use stronger parameters because they sign only one record.
  19715. This type has the following parameters:
  19716. @table @asis
  19717. @item @code{id} (default: @code{""})
  19718. The id of the policy. It must not be empty.
  19719. @item @code{keystore} (default: @code{"default"})
  19720. A reference to a keystore, that is a string containing the identifier of a
  19721. keystore defined in a @code{knot-keystore-configuration} field. The
  19722. @code{"default"} identifier means the default keystore (a kasp database that
  19723. was setup by this service).
  19724. @item @code{manual?} (default: @code{#f})
  19725. Whether the key management is manual or automatic.
  19726. @item @code{single-type-signing?} (default: @code{#f})
  19727. When @code{#t}, use the Single-Type Signing Scheme.
  19728. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  19729. An algorithm of signing keys and issued signatures.
  19730. @item @code{ksk-size} (default: @code{256})
  19731. The length of the KSK@. Note that this value is correct for the default
  19732. algorithm, but would be unsecure for other algorithms.
  19733. @item @code{zsk-size} (default: @code{256})
  19734. The length of the ZSK@. Note that this value is correct for the default
  19735. algorithm, but would be unsecure for other algorithms.
  19736. @item @code{dnskey-ttl} (default: @code{'default})
  19737. The TTL value for DNSKEY records added into zone apex. The special
  19738. @code{'default} value means same as the zone SOA TTL.
  19739. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  19740. The period between ZSK publication and the next rollover initiation.
  19741. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  19742. An extra delay added for each key rollover step. This value should be high
  19743. enough to cover propagation of data from the master server to all slaves.
  19744. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  19745. A validity period of newly issued signatures.
  19746. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  19747. A period how long before a signature expiration the signature will be refreshed.
  19748. @item @code{nsec3?} (default: @code{#f})
  19749. When @code{#t}, NSEC3 will be used instead of NSEC.
  19750. @item @code{nsec3-iterations} (default: @code{5})
  19751. The number of additional times the hashing is performed.
  19752. @item @code{nsec3-salt-length} (default: @code{8})
  19753. The length of a salt field in octets, which is appended to the original owner
  19754. name before hashing.
  19755. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  19756. The validity period of newly issued salt field.
  19757. @end table
  19758. @end deftp
  19759. @deftp {Data Type} knot-zone-configuration
  19760. Data type representing a zone served by Knot.
  19761. This type has the following parameters:
  19762. @table @asis
  19763. @item @code{domain} (default: @code{""})
  19764. The domain served by this configuration. It must not be empty.
  19765. @item @code{file} (default: @code{""})
  19766. The file where this zone is saved. This parameter is ignored by master zones.
  19767. Empty means default location that depends on the domain name.
  19768. @item @code{zone} (default: @code{(zone-file)})
  19769. The content of the zone file. This parameter is ignored by slave zones. It
  19770. must contain a zone-file record.
  19771. @item @code{master} (default: @code{'()})
  19772. A list of master remotes. When empty, this zone is a master. When set, this
  19773. zone is a slave. This is a list of remotes identifiers.
  19774. @item @code{ddns-master} (default: @code{#f})
  19775. The main master. When empty, it defaults to the first master in the list of
  19776. masters.
  19777. @item @code{notify} (default: @code{'()})
  19778. A list of slave remote identifiers.
  19779. @item @code{acl} (default: @code{'()})
  19780. A list of acl identifiers.
  19781. @item @code{semantic-checks?} (default: @code{#f})
  19782. When set, this adds more semantic checks to the zone.
  19783. @item @code{disable-any?} (default: @code{#f})
  19784. When set, this forbids queries of the ANY type.
  19785. @item @code{zonefile-sync} (default: @code{0})
  19786. The delay between a modification in memory and on disk. 0 means immediate
  19787. synchronization.
  19788. @item @code{zonefile-load} (default: @code{#f})
  19789. The way the zone file contents are applied during zone load. Possible values
  19790. are:
  19791. @itemize
  19792. @item @code{#f} for using the default value from Knot,
  19793. @item @code{'none} for not using the zone file at all,
  19794. @item @code{'difference} for computing the difference between already available
  19795. contents and zone contents and applying it to the current zone contents,
  19796. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  19797. ignoring the SOA serial in the zone file, while the server takes care of it
  19798. automatically.
  19799. @item @code{'whole} for loading zone contents from the zone file.
  19800. @end itemize
  19801. @item @code{journal-content} (default: @code{#f})
  19802. The way the journal is used to store zone and its changes. Possible values
  19803. are @code{'none} to not use it at all, @code{'changes} to store changes and
  19804. @code{'all} to store contents. @code{#f} does not set this option, so the
  19805. default value from Knot is used.
  19806. @item @code{max-journal-usage} (default: @code{#f})
  19807. The maximum size for the journal on disk. @code{#f} does not set this option,
  19808. so the default value from Knot is used.
  19809. @item @code{max-journal-depth} (default: @code{#f})
  19810. The maximum size of the history. @code{#f} does not set this option, so the
  19811. default value from Knot is used.
  19812. @item @code{max-zone-size} (default: @code{#f})
  19813. The maximum size of the zone file. This limit is enforced for incoming
  19814. transfer and updates. @code{#f} does not set this option, so the default
  19815. value from Knot is used.
  19816. @item @code{dnssec-policy} (default: @code{#f})
  19817. A reference to a @code{knot-policy-configuration} record, or the special
  19818. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  19819. on this zone.
  19820. @item @code{serial-policy} (default: @code{'increment})
  19821. A policy between @code{'increment} and @code{'unixtime}.
  19822. @end table
  19823. @end deftp
  19824. @deftp {Data Type} knot-configuration
  19825. Data type representing the Knot configuration.
  19826. This type has the following parameters:
  19827. @table @asis
  19828. @item @code{knot} (default: @code{knot})
  19829. The Knot package.
  19830. @item @code{run-directory} (default: @code{"/var/run/knot"})
  19831. The run directory. This directory will be used for pid file and sockets.
  19832. @item @code{includes} (default: @code{'()})
  19833. A list of strings or file-like objects denoting other files that must be
  19834. included at the top of the configuration file.
  19835. @cindex secrets, Knot service
  19836. This can be used to manage secrets out-of-band. For example, secret
  19837. keys may be stored in an out-of-band file not managed by Guix, and
  19838. thus not visible in @file{/gnu/store}---e.g., you could store secret
  19839. key configuration in @file{/etc/knot/secrets.conf} and add this file
  19840. to the @code{includes} list.
  19841. One can generate a secret tsig key (for nsupdate and zone transfers with the
  19842. keymgr command from the knot package. Note that the package is not automatically
  19843. installed by the service. The following example shows how to generate a new
  19844. tsig key:
  19845. @example
  19846. keymgr -t mysecret > /etc/knot/secrets.conf
  19847. chmod 600 /etc/knot/secrets.conf
  19848. @end example
  19849. Also note that the generated key will be named @var{mysecret}, so it is the
  19850. name that needs to be used in the @var{key} field of the
  19851. @code{knot-acl-configuration} record and in other places that need to refer
  19852. to that key.
  19853. It can also be used to add configuration not supported by this interface.
  19854. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  19855. An ip address on which to listen.
  19856. @item @code{listen-v6} (default: @code{"::"})
  19857. An ip address on which to listen.
  19858. @item @code{listen-port} (default: @code{53})
  19859. A port on which to listen.
  19860. @item @code{keys} (default: @code{'()})
  19861. The list of knot-key-configuration used by this configuration.
  19862. @item @code{acls} (default: @code{'()})
  19863. The list of knot-acl-configuration used by this configuration.
  19864. @item @code{remotes} (default: @code{'()})
  19865. The list of knot-remote-configuration used by this configuration.
  19866. @item @code{zones} (default: @code{'()})
  19867. The list of knot-zone-configuration used by this configuration.
  19868. @end table
  19869. @end deftp
  19870. @subsubheading Knot Resolver Service
  19871. @deffn {Scheme Variable} knot-resolver-service-type
  19872. This is the type of the knot resolver service, whose value should be
  19873. an @code{knot-resolver-configuration} object as in this example:
  19874. @lisp
  19875. (service knot-resolver-service-type
  19876. (knot-resolver-configuration
  19877. (kresd-config-file (plain-file "kresd.conf" "
  19878. net.listen('192.168.0.1', 5353)
  19879. user('knot-resolver', 'knot-resolver')
  19880. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  19881. cache.size = 100 * MB
  19882. "))))
  19883. @end lisp
  19884. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  19885. @end deffn
  19886. @deftp {Data Type} knot-resolver-configuration
  19887. Data type representing the configuration of knot-resolver.
  19888. @table @asis
  19889. @item @code{package} (default: @var{knot-resolver})
  19890. Package object of the knot DNS resolver.
  19891. @item @code{kresd-config-file} (default: %kresd.conf)
  19892. File-like object of the kresd configuration file to use, by default it
  19893. will listen on @code{127.0.0.1} and @code{::1}.
  19894. @item @code{garbage-collection-interval} (default: 1000)
  19895. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  19896. @end table
  19897. @end deftp
  19898. @subsubheading Dnsmasq Service
  19899. @deffn {Scheme Variable} dnsmasq-service-type
  19900. This is the type of the dnsmasq service, whose value should be an
  19901. @code{dnsmasq-configuration} object as in this example:
  19902. @lisp
  19903. (service dnsmasq-service-type
  19904. (dnsmasq-configuration
  19905. (no-resolv? #t)
  19906. (servers '("192.168.1.1"))))
  19907. @end lisp
  19908. @end deffn
  19909. @deftp {Data Type} dnsmasq-configuration
  19910. Data type representing the configuration of dnsmasq.
  19911. @table @asis
  19912. @item @code{package} (default: @var{dnsmasq})
  19913. Package object of the dnsmasq server.
  19914. @item @code{no-hosts?} (default: @code{#f})
  19915. When true, don't read the hostnames in /etc/hosts.
  19916. @item @code{port} (default: @code{53})
  19917. The port to listen on. Setting this to zero completely disables DNS
  19918. responses, leaving only DHCP and/or TFTP functions.
  19919. @item @code{local-service?} (default: @code{#t})
  19920. Accept DNS queries only from hosts whose address is on a local subnet,
  19921. ie a subnet for which an interface exists on the server.
  19922. @item @code{listen-addresses} (default: @code{'()})
  19923. Listen on the given IP addresses.
  19924. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  19925. The file to read the IP address of the upstream nameservers from.
  19926. @item @code{no-resolv?} (default: @code{#f})
  19927. When true, don't read @var{resolv-file}.
  19928. @item @code{servers} (default: @code{'()})
  19929. Specify IP address of upstream servers directly.
  19930. @item @code{addresses} (default: @code{'()})
  19931. For each entry, specify an IP address to return for any host in the
  19932. given domains. Queries in the domains are never forwarded and always
  19933. replied to with the specified IP address.
  19934. This is useful for redirecting hosts locally, for example:
  19935. @lisp
  19936. (service dnsmasq-service-type
  19937. (dnsmasq-configuration
  19938. (addresses
  19939. '(; Redirect to a local web-server.
  19940. "/example.org/127.0.0.1"
  19941. ; Redirect subdomain to a specific IP.
  19942. "/subdomain.example.org/192.168.1.42"))))
  19943. @end lisp
  19944. Note that rules in @file{/etc/hosts} take precedence over this.
  19945. @item @code{cache-size} (default: @code{150})
  19946. Set the size of dnsmasq's cache. Setting the cache size to zero
  19947. disables caching.
  19948. @item @code{negative-cache?} (default: @code{#t})
  19949. When false, disable negative caching.
  19950. @item @code{tftp-enable?} (default: @code{#f})
  19951. Whether to enable the built-in TFTP server.
  19952. @item @code{tftp-no-fail?} (default: @code{#f})
  19953. If true, does not fail dnsmasq if the TFTP server could not start up.
  19954. @item @code{tftp-single-port?} (default: @code{#f})
  19955. Whether to use only one single port for TFTP.
  19956. @item @code{tftp-secure?} (default: @code{#f})
  19957. If true, only files owned by the user running the dnsmasq process are accessible.
  19958. If dnsmasq is being run as root, different rules apply:
  19959. @code{tftp-secure?} has no effect, but only files which have the
  19960. world-readable bit set are accessible.
  19961. @item @code{tftp-max} (default: @code{#f})
  19962. If set, sets the maximal number of concurrent connections allowed.
  19963. @item @code{tftp-mtu} (default: @code{#f})
  19964. If set, sets the MTU for TFTP packets to that value.
  19965. @item @code{tftp-no-blocksize?} (default: @code{#f})
  19966. If true, stops the TFTP server from negotiating the blocksize with a client.
  19967. @item @code{tftp-lowercase?} (default: @code{#f})
  19968. Whether to convert all filenames in TFTP requests to lowercase.
  19969. @item @code{tftp-port-range} (default: @code{#f})
  19970. If set, fixes the dynamical ports (one per client) to the given range
  19971. (@code{"<start>,<end>"}).
  19972. @item @code{tftp-root} (default: @code{/var/empty,lo})
  19973. Look for files to transfer using TFTP relative to the given directory.
  19974. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  19975. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  19976. allowed, but they must be within the TFTP-root. If the optional interface
  19977. argument is given, the directory is only used for TFTP requests via that
  19978. interface.
  19979. @item @code{tftp-unique-root} (default: @code{#f})
  19980. If set, add the IP or hardware address of the TFTP client as a path component
  19981. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  19982. directory exists. Defaults to adding IP address (in standard dotted-quad
  19983. format).
  19984. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  19985. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  19986. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  19987. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  19988. append the MAC address instead, using lowercase zero padded digits
  19989. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  19990. resolving MAC addresses is only possible if the client is in the local
  19991. network or obtained a DHCP lease from dnsmasq.
  19992. @end table
  19993. @end deftp
  19994. @subsubheading ddclient Service
  19995. @cindex ddclient
  19996. The ddclient service described below runs the ddclient daemon, which takes
  19997. care of automatically updating DNS entries for service providers such as
  19998. @uref{https://dyn.com/dns/, Dyn}.
  19999. The following example show instantiates the service with its default
  20000. configuration:
  20001. @lisp
  20002. (service ddclient-service-type)
  20003. @end lisp
  20004. Note that ddclient needs to access credentials that are stored in a
  20005. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  20006. @code{secret-file} below). You are expected to create this file manually, in
  20007. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  20008. service configuration, for instance by using @code{plain-file}, but it will be
  20009. world-readable @i{via} @file{/gnu/store}). See the examples in the
  20010. @file{share/ddclient} directory of the @code{ddclient} package.
  20011. @c %start of fragment
  20012. Available @code{ddclient-configuration} fields are:
  20013. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  20014. The ddclient package.
  20015. @end deftypevr
  20016. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  20017. The period after which ddclient will retry to check IP and domain name.
  20018. Defaults to @samp{300}.
  20019. @end deftypevr
  20020. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  20021. Use syslog for the output.
  20022. Defaults to @samp{#t}.
  20023. @end deftypevr
  20024. @deftypevr {@code{ddclient-configuration} parameter} string mail
  20025. Mail to user.
  20026. Defaults to @samp{"root"}.
  20027. @end deftypevr
  20028. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  20029. Mail failed update to user.
  20030. Defaults to @samp{"root"}.
  20031. @end deftypevr
  20032. @deftypevr {@code{ddclient-configuration} parameter} string pid
  20033. The ddclient PID file.
  20034. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  20035. @end deftypevr
  20036. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  20037. Enable SSL support.
  20038. Defaults to @samp{#t}.
  20039. @end deftypevr
  20040. @deftypevr {@code{ddclient-configuration} parameter} string user
  20041. Specifies the user name or ID that is used when running ddclient
  20042. program.
  20043. Defaults to @samp{"ddclient"}.
  20044. @end deftypevr
  20045. @deftypevr {@code{ddclient-configuration} parameter} string group
  20046. Group of the user who will run the ddclient program.
  20047. Defaults to @samp{"ddclient"}.
  20048. @end deftypevr
  20049. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  20050. Secret file which will be appended to @file{ddclient.conf} file. This
  20051. file contains credentials for use by ddclient. You are expected to
  20052. create it manually.
  20053. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  20054. @end deftypevr
  20055. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  20056. Extra options will be appended to @file{ddclient.conf} file.
  20057. Defaults to @samp{()}.
  20058. @end deftypevr
  20059. @c %end of fragment
  20060. @node VPN Services
  20061. @subsection VPN Services
  20062. @cindex VPN (virtual private network)
  20063. @cindex virtual private network (VPN)
  20064. The @code{(gnu services vpn)} module provides services related to
  20065. @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
  20066. your machine to connect to a VPN, and a @emph{server} service for your machine
  20067. to host a VPN@. Both services use @uref{https://openvpn.net/, OpenVPN}.
  20068. @deffn {Scheme Procedure} openvpn-client-service @
  20069. [#:config (openvpn-client-configuration)]
  20070. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  20071. @end deffn
  20072. @deffn {Scheme Procedure} openvpn-server-service @
  20073. [#:config (openvpn-server-configuration)]
  20074. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  20075. Both can be run simultaneously.
  20076. @end deffn
  20077. @c %automatically generated documentation
  20078. Available @code{openvpn-client-configuration} fields are:
  20079. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  20080. The OpenVPN package.
  20081. @end deftypevr
  20082. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  20083. The OpenVPN pid file.
  20084. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  20085. @end deftypevr
  20086. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  20087. The protocol (UDP or TCP) used to open a channel between clients and
  20088. servers.
  20089. Defaults to @samp{udp}.
  20090. @end deftypevr
  20091. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  20092. The device type used to represent the VPN connection.
  20093. Defaults to @samp{tun}.
  20094. @end deftypevr
  20095. If you do not have some of these files (eg.@: you use a username and
  20096. password), you can disable any of the following three fields by setting
  20097. it to @code{'disabled}.
  20098. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  20099. The certificate authority to check connections against.
  20100. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  20101. @end deftypevr
  20102. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  20103. The certificate of the machine the daemon is running on. It should be
  20104. signed by the authority given in @code{ca}.
  20105. Defaults to @samp{"/etc/openvpn/client.crt"}.
  20106. @end deftypevr
  20107. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  20108. The key of the machine the daemon is running on. It must be the key whose
  20109. certificate is @code{cert}.
  20110. Defaults to @samp{"/etc/openvpn/client.key"}.
  20111. @end deftypevr
  20112. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  20113. Whether to use the lzo compression algorithm.
  20114. Defaults to @samp{#t}.
  20115. @end deftypevr
  20116. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  20117. Don't re-read key files across SIGUSR1 or --ping-restart.
  20118. Defaults to @samp{#t}.
  20119. @end deftypevr
  20120. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  20121. Don't close and reopen TUN/TAP device or run up/down scripts across
  20122. SIGUSR1 or --ping-restart restarts.
  20123. Defaults to @samp{#t}.
  20124. @end deftypevr
  20125. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  20126. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  20127. poll/epoll/select prior to the write operation.
  20128. Defaults to @samp{#f}.
  20129. @end deftypevr
  20130. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  20131. Verbosity level.
  20132. Defaults to @samp{3}.
  20133. @end deftypevr
  20134. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  20135. Add an additional layer of HMAC authentication on top of the TLS control
  20136. channel to protect against DoS attacks.
  20137. Defaults to @samp{#f}.
  20138. @end deftypevr
  20139. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  20140. Authenticate with server using username/password. The option is a file
  20141. containing username/password on 2 lines. Do not use a file-like object as it
  20142. would be added to the store and readable by any user.
  20143. Defaults to @samp{'disabled}.
  20144. @end deftypevr
  20145. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  20146. Whether to check the server certificate has server usage extension.
  20147. Defaults to @samp{#t}.
  20148. @end deftypevr
  20149. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  20150. Bind to a specific local port number.
  20151. Defaults to @samp{#f}.
  20152. @end deftypevr
  20153. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  20154. Retry resolving server address.
  20155. Defaults to @samp{#t}.
  20156. @end deftypevr
  20157. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  20158. A list of remote servers to connect to.
  20159. Defaults to @samp{()}.
  20160. Available @code{openvpn-remote-configuration} fields are:
  20161. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  20162. Server name.
  20163. Defaults to @samp{"my-server"}.
  20164. @end deftypevr
  20165. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  20166. Port number the server listens to.
  20167. Defaults to @samp{1194}.
  20168. @end deftypevr
  20169. @end deftypevr
  20170. @c %end of automatic openvpn-client documentation
  20171. @c %automatically generated documentation
  20172. Available @code{openvpn-server-configuration} fields are:
  20173. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  20174. The OpenVPN package.
  20175. @end deftypevr
  20176. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  20177. The OpenVPN pid file.
  20178. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  20179. @end deftypevr
  20180. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  20181. The protocol (UDP or TCP) used to open a channel between clients and
  20182. servers.
  20183. Defaults to @samp{udp}.
  20184. @end deftypevr
  20185. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  20186. The device type used to represent the VPN connection.
  20187. Defaults to @samp{tun}.
  20188. @end deftypevr
  20189. If you do not have some of these files (eg.@: you use a username and
  20190. password), you can disable any of the following three fields by setting
  20191. it to @code{'disabled}.
  20192. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  20193. The certificate authority to check connections against.
  20194. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  20195. @end deftypevr
  20196. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  20197. The certificate of the machine the daemon is running on. It should be
  20198. signed by the authority given in @code{ca}.
  20199. Defaults to @samp{"/etc/openvpn/client.crt"}.
  20200. @end deftypevr
  20201. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  20202. The key of the machine the daemon is running on. It must be the key whose
  20203. certificate is @code{cert}.
  20204. Defaults to @samp{"/etc/openvpn/client.key"}.
  20205. @end deftypevr
  20206. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  20207. Whether to use the lzo compression algorithm.
  20208. Defaults to @samp{#t}.
  20209. @end deftypevr
  20210. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  20211. Don't re-read key files across SIGUSR1 or --ping-restart.
  20212. Defaults to @samp{#t}.
  20213. @end deftypevr
  20214. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  20215. Don't close and reopen TUN/TAP device or run up/down scripts across
  20216. SIGUSR1 or --ping-restart restarts.
  20217. Defaults to @samp{#t}.
  20218. @end deftypevr
  20219. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  20220. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  20221. poll/epoll/select prior to the write operation.
  20222. Defaults to @samp{#f}.
  20223. @end deftypevr
  20224. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  20225. Verbosity level.
  20226. Defaults to @samp{3}.
  20227. @end deftypevr
  20228. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  20229. Add an additional layer of HMAC authentication on top of the TLS control
  20230. channel to protect against DoS attacks.
  20231. Defaults to @samp{#f}.
  20232. @end deftypevr
  20233. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  20234. Specifies the port number on which the server listens.
  20235. Defaults to @samp{1194}.
  20236. @end deftypevr
  20237. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  20238. An ip and mask specifying the subnet inside the virtual network.
  20239. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  20240. @end deftypevr
  20241. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  20242. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  20243. Defaults to @samp{#f}.
  20244. @end deftypevr
  20245. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  20246. The Diffie-Hellman parameters file.
  20247. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  20248. @end deftypevr
  20249. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  20250. The file that records client IPs.
  20251. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  20252. @end deftypevr
  20253. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  20254. When true, the server will act as a gateway for its clients.
  20255. Defaults to @samp{#f}.
  20256. @end deftypevr
  20257. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  20258. When true, clients are allowed to talk to each other inside the VPN.
  20259. Defaults to @samp{#f}.
  20260. @end deftypevr
  20261. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  20262. Causes ping-like messages to be sent back and forth over the link so
  20263. that each side knows when the other side has gone down. @code{keepalive}
  20264. requires a pair. The first element is the period of the ping sending,
  20265. and the second element is the timeout before considering the other side
  20266. down.
  20267. @end deftypevr
  20268. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  20269. The maximum number of clients.
  20270. Defaults to @samp{100}.
  20271. @end deftypevr
  20272. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  20273. The status file. This file shows a small report on current connection.
  20274. It is truncated and rewritten every minute.
  20275. Defaults to @samp{"/var/run/openvpn/status"}.
  20276. @end deftypevr
  20277. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  20278. The list of configuration for some clients.
  20279. Defaults to @samp{()}.
  20280. Available @code{openvpn-ccd-configuration} fields are:
  20281. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  20282. Client name.
  20283. Defaults to @samp{"client"}.
  20284. @end deftypevr
  20285. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  20286. Client own network
  20287. Defaults to @samp{#f}.
  20288. @end deftypevr
  20289. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  20290. Client VPN IP.
  20291. Defaults to @samp{#f}.
  20292. @end deftypevr
  20293. @end deftypevr
  20294. @c %end of automatic openvpn-server documentation
  20295. @node Network File System
  20296. @subsection Network File System
  20297. @cindex NFS
  20298. The @code{(gnu services nfs)} module provides the following services,
  20299. which are most commonly used in relation to mounting or exporting
  20300. directory trees as @dfn{network file systems} (NFS).
  20301. While it is possible to use the individual components that together make
  20302. up a Network File System service, we recommended to configure an NFS
  20303. server with the @code{nfs-service-type}.
  20304. @subsubheading NFS Service
  20305. @cindex NFS, server
  20306. The NFS service takes care of setting up all NFS component services,
  20307. kernel configuration file systems, and installs configuration files in
  20308. the locations that NFS expects.
  20309. @defvr {Scheme Variable} nfs-service-type
  20310. A service type for a complete NFS server.
  20311. @end defvr
  20312. @deftp {Data Type} nfs-configuration
  20313. This data type represents the configuration of the NFS service and all
  20314. of its subsystems.
  20315. It has the following parameters:
  20316. @table @asis
  20317. @item @code{nfs-utils} (default: @code{nfs-utils})
  20318. The nfs-utils package to use.
  20319. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  20320. If a list of string values is provided, the @command{rpc.nfsd} daemon
  20321. will be limited to supporting the given versions of the NFS protocol.
  20322. @item @code{exports} (default: @code{'()})
  20323. This is a list of directories the NFS server should export. Each entry
  20324. is a list consisting of two elements: a directory name and a string
  20325. containing all options. This is an example in which the directory
  20326. @file{/export} is served to all NFS clients as a read-only share:
  20327. @lisp
  20328. (nfs-configuration
  20329. (exports
  20330. '(("/export"
  20331. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  20332. @end lisp
  20333. @item @code{rpcmountd-port} (default: @code{#f})
  20334. The network port that the @command{rpc.mountd} daemon should use.
  20335. @item @code{rpcstatd-port} (default: @code{#f})
  20336. The network port that the @command{rpc.statd} daemon should use.
  20337. @item @code{rpcbind} (default: @code{rpcbind})
  20338. The rpcbind package to use.
  20339. @item @code{idmap-domain} (default: @code{"localdomain"})
  20340. The local NFSv4 domain name.
  20341. @item @code{nfsd-port} (default: @code{2049})
  20342. The network port that the @command{nfsd} daemon should use.
  20343. @item @code{nfsd-threads} (default: @code{8})
  20344. The number of threads used by the @command{nfsd} daemon.
  20345. @item @code{nfsd-tcp?} (default: @code{#t})
  20346. Whether the @command{nfsd} daemon should listen on a TCP socket.
  20347. @item @code{nfsd-udp?} (default: @code{#f})
  20348. Whether the @command{nfsd} daemon should listen on a UDP socket.
  20349. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  20350. The directory where the pipefs file system is mounted.
  20351. @item @code{debug} (default: @code{'()"})
  20352. A list of subsystems for which debugging output should be enabled. This
  20353. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  20354. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  20355. @end table
  20356. @end deftp
  20357. If you don't need a complete NFS service or prefer to build it yourself
  20358. you can use the individual component services that are documented below.
  20359. @subsubheading RPC Bind Service
  20360. @cindex rpcbind
  20361. The RPC Bind service provides a facility to map program numbers into
  20362. universal addresses.
  20363. Many NFS related services use this facility. Hence it is automatically
  20364. started when a dependent service starts.
  20365. @defvr {Scheme Variable} rpcbind-service-type
  20366. A service type for the RPC portmapper daemon.
  20367. @end defvr
  20368. @deftp {Data Type} rpcbind-configuration
  20369. Data type representing the configuration of the RPC Bind Service.
  20370. This type has the following parameters:
  20371. @table @asis
  20372. @item @code{rpcbind} (default: @code{rpcbind})
  20373. The rpcbind package to use.
  20374. @item @code{warm-start?} (default: @code{#t})
  20375. If this parameter is @code{#t}, then the daemon will read a
  20376. state file on startup thus reloading state information saved by a previous
  20377. instance.
  20378. @end table
  20379. @end deftp
  20380. @subsubheading Pipefs Pseudo File System
  20381. @cindex pipefs
  20382. @cindex rpc_pipefs
  20383. The pipefs file system is used to transfer NFS related data
  20384. between the kernel and user space programs.
  20385. @defvr {Scheme Variable} pipefs-service-type
  20386. A service type for the pipefs pseudo file system.
  20387. @end defvr
  20388. @deftp {Data Type} pipefs-configuration
  20389. Data type representing the configuration of the pipefs pseudo file system service.
  20390. This type has the following parameters:
  20391. @table @asis
  20392. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  20393. The directory to which the file system is to be attached.
  20394. @end table
  20395. @end deftp
  20396. @subsubheading GSS Daemon Service
  20397. @cindex GSSD
  20398. @cindex GSS
  20399. @cindex global security system
  20400. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  20401. based protocols.
  20402. Before exchanging RPC requests an RPC client must establish a security
  20403. context. Typically this is done using the Kerberos command @command{kinit}
  20404. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  20405. @defvr {Scheme Variable} gss-service-type
  20406. A service type for the Global Security System (GSS) daemon.
  20407. @end defvr
  20408. @deftp {Data Type} gss-configuration
  20409. Data type representing the configuration of the GSS daemon service.
  20410. This type has the following parameters:
  20411. @table @asis
  20412. @item @code{nfs-utils} (default: @code{nfs-utils})
  20413. The package in which the @command{rpc.gssd} command is to be found.
  20414. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  20415. The directory where the pipefs file system is mounted.
  20416. @end table
  20417. @end deftp
  20418. @subsubheading IDMAP Daemon Service
  20419. @cindex idmapd
  20420. @cindex name mapper
  20421. The idmap daemon service provides mapping between user IDs and user names.
  20422. Typically it is required in order to access file systems mounted via NFSv4.
  20423. @defvr {Scheme Variable} idmap-service-type
  20424. A service type for the Identity Mapper (IDMAP) daemon.
  20425. @end defvr
  20426. @deftp {Data Type} idmap-configuration
  20427. Data type representing the configuration of the IDMAP daemon service.
  20428. This type has the following parameters:
  20429. @table @asis
  20430. @item @code{nfs-utils} (default: @code{nfs-utils})
  20431. The package in which the @command{rpc.idmapd} command is to be found.
  20432. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  20433. The directory where the pipefs file system is mounted.
  20434. @item @code{domain} (default: @code{#f})
  20435. The local NFSv4 domain name.
  20436. This must be a string or @code{#f}.
  20437. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  20438. @item @code{verbosity} (default: @code{0})
  20439. The verbosity level of the daemon.
  20440. @end table
  20441. @end deftp
  20442. @node Continuous Integration
  20443. @subsection Continuous Integration
  20444. @cindex continuous integration
  20445. @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
  20446. continuous integration tool for Guix. It can be used both for development and
  20447. for providing substitutes to others (@pxref{Substitutes}).
  20448. The @code{(gnu services cuirass)} module provides the following service.
  20449. @defvr {Scheme Procedure} cuirass-service-type
  20450. The type of the Cuirass service. Its value must be a
  20451. @code{cuirass-configuration} object, as described below.
  20452. @end defvr
  20453. To add build jobs, you have to set the @code{specifications} field of the
  20454. configuration. Here is an example of a service that polls the Guix repository
  20455. and builds the packages from a manifest. Some of the packages are defined in
  20456. the @code{"custom-packages"} input, which is the equivalent of
  20457. @env{GUIX_PACKAGE_PATH}.
  20458. @lisp
  20459. (define %cuirass-specs
  20460. #~(list
  20461. '((#:name . "my-manifest")
  20462. (#:load-path-inputs . ("guix"))
  20463. (#:package-path-inputs . ("custom-packages"))
  20464. (#:proc-input . "guix")
  20465. (#:proc-file . "build-aux/cuirass/gnu-system.scm")
  20466. (#:proc . cuirass-jobs)
  20467. (#:proc-args . ((subset . "manifests")
  20468. (systems . ("x86_64-linux"))
  20469. (manifests . (("config" . "guix/manifest.scm")))))
  20470. (#:inputs . (((#:name . "guix")
  20471. (#:url . "git://git.savannah.gnu.org/guix.git")
  20472. (#:load-path . ".")
  20473. (#:branch . "master")
  20474. (#:no-compile? . #t))
  20475. ((#:name . "config")
  20476. (#:url . "https://git.example.org/config.git")
  20477. (#:load-path . ".")
  20478. (#:branch . "master")
  20479. (#:no-compile? . #t))
  20480. ((#:name . "custom-packages")
  20481. (#:url . "https://git.example.org/custom-packages.git")
  20482. (#:load-path . ".")
  20483. (#:branch . "master")
  20484. (#:no-compile? . #t)))))))
  20485. (service cuirass-service-type
  20486. (cuirass-configuration
  20487. (specifications %cuirass-specs)))
  20488. @end lisp
  20489. While information related to build jobs is located directly in the
  20490. specifications, global settings for the @command{cuirass} process are
  20491. accessible in other @code{cuirass-configuration} fields.
  20492. @deftp {Data Type} cuirass-configuration
  20493. Data type representing the configuration of Cuirass.
  20494. @table @asis
  20495. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  20496. Location of the log file.
  20497. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  20498. Location of the log file used by the web interface.
  20499. @item @code{queries-log-file} (default: @code{#f})
  20500. Location of the SQL queries log file. By default, SQL queries logging is
  20501. disabled.
  20502. @item @code{web-queries-log-file} (default: @code{#f})
  20503. Location of the web SQL queries log file. By default, web SQL queries
  20504. logging is disabled.
  20505. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  20506. Location of the repository cache.
  20507. @item @code{user} (default: @code{"cuirass"})
  20508. Owner of the @code{cuirass} process.
  20509. @item @code{group} (default: @code{"cuirass"})
  20510. Owner's group of the @code{cuirass} process.
  20511. @item @code{interval} (default: @code{60})
  20512. Number of seconds between the poll of the repositories followed by the
  20513. Cuirass jobs.
  20514. @item @code{queue-size} (default: @code{1})
  20515. Size of the database writer queue.
  20516. @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
  20517. Location of sqlite database which contains the build results and previously
  20518. added specifications.
  20519. @item @code{ttl} (default: @code{(* 30 24 3600)})
  20520. Specifies the time-to-live (TTL) in seconds of garbage collector roots that
  20521. are registered for build results. This means that build results are protected
  20522. from garbage collection for at least @var{ttl} seconds.
  20523. @item @code{port} (default: @code{8081})
  20524. Port number used by the HTTP server.
  20525. @item @code{host} (default: @code{"localhost"})
  20526. Listen on the network interface for @var{host}. The default is to
  20527. accept connections from localhost.
  20528. @item @code{specifications} (default: @code{#~'()})
  20529. A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
  20530. where a specification is an association list
  20531. (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
  20532. keys are keywords (@code{#:keyword-example}) as shown in the example
  20533. above.
  20534. @item @code{use-substitutes?} (default: @code{#f})
  20535. This allows using substitutes to avoid building every dependencies of a job
  20536. from source.
  20537. @item @code{one-shot?} (default: @code{#f})
  20538. Only evaluate specifications and build derivations once.
  20539. @item @code{fallback?} (default: @code{#f})
  20540. When substituting a pre-built binary fails, fall back to building
  20541. packages locally.
  20542. @item @code{extra-options} (default: @code{'()})
  20543. Extra options to pass when running the Cuirass processes.
  20544. @item @code{cuirass} (default: @code{cuirass})
  20545. The Cuirass package to use.
  20546. @end table
  20547. @end deftp
  20548. @node Power Management Services
  20549. @subsection Power Management Services
  20550. @cindex tlp
  20551. @cindex power management with TLP
  20552. @subsubheading TLP daemon
  20553. The @code{(gnu services pm)} module provides a Guix service definition
  20554. for the Linux power management tool TLP.
  20555. TLP enables various powersaving modes in userspace and kernel.
  20556. Contrary to @code{upower-service}, it is not a passive,
  20557. monitoring tool, as it will apply custom settings each time a new power
  20558. source is detected. More information can be found at
  20559. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  20560. @deffn {Scheme Variable} tlp-service-type
  20561. The service type for the TLP tool. The default settings are optimised
  20562. for battery life on most systems, but you can tweak them to your heart's
  20563. content by adding a valid @code{tlp-configuration}:
  20564. @lisp
  20565. (service tlp-service-type
  20566. (tlp-configuration
  20567. (cpu-scaling-governor-on-ac (list "performance"))
  20568. (sched-powersave-on-bat? #t)))
  20569. @end lisp
  20570. @end deffn
  20571. Each parameter definition is preceded by its type; for example,
  20572. @samp{boolean foo} indicates that the @code{foo} parameter
  20573. should be specified as a boolean. Types starting with
  20574. @code{maybe-} denote parameters that won't show up in TLP config file
  20575. when their value is @code{'disabled}.
  20576. @c The following documentation was initially generated by
  20577. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  20578. @c documentation is better, so we shouldn't hesitate to edit below as
  20579. @c needed. However if the change you want to make to this documentation
  20580. @c can be done in an automated way, it's probably easier to change
  20581. @c (generate-documentation) than to make it below and have to deal with
  20582. @c the churn as TLP updates.
  20583. Available @code{tlp-configuration} fields are:
  20584. @deftypevr {@code{tlp-configuration} parameter} package tlp
  20585. The TLP package.
  20586. @end deftypevr
  20587. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  20588. Set to true if you wish to enable TLP.
  20589. Defaults to @samp{#t}.
  20590. @end deftypevr
  20591. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  20592. Default mode when no power supply can be detected. Alternatives are AC
  20593. and BAT.
  20594. Defaults to @samp{"AC"}.
  20595. @end deftypevr
  20596. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  20597. Number of seconds Linux kernel has to wait after the disk goes idle,
  20598. before syncing on AC.
  20599. Defaults to @samp{0}.
  20600. @end deftypevr
  20601. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  20602. Same as @code{disk-idle-ac} but on BAT mode.
  20603. Defaults to @samp{2}.
  20604. @end deftypevr
  20605. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  20606. Dirty pages flushing periodicity, expressed in seconds.
  20607. Defaults to @samp{15}.
  20608. @end deftypevr
  20609. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  20610. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  20611. Defaults to @samp{60}.
  20612. @end deftypevr
  20613. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  20614. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  20615. alternatives are powersave and performance. With acpi-cpufreq driver,
  20616. alternatives are ondemand, powersave, performance and conservative.
  20617. Defaults to @samp{disabled}.
  20618. @end deftypevr
  20619. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  20620. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  20621. Defaults to @samp{disabled}.
  20622. @end deftypevr
  20623. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  20624. Set the min available frequency for the scaling governor on AC.
  20625. Defaults to @samp{disabled}.
  20626. @end deftypevr
  20627. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  20628. Set the max available frequency for the scaling governor on AC.
  20629. Defaults to @samp{disabled}.
  20630. @end deftypevr
  20631. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  20632. Set the min available frequency for the scaling governor on BAT.
  20633. Defaults to @samp{disabled}.
  20634. @end deftypevr
  20635. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  20636. Set the max available frequency for the scaling governor on BAT.
  20637. Defaults to @samp{disabled}.
  20638. @end deftypevr
  20639. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  20640. Limit the min P-state to control the power dissipation of the CPU, in AC
  20641. mode. Values are stated as a percentage of the available performance.
  20642. Defaults to @samp{disabled}.
  20643. @end deftypevr
  20644. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  20645. Limit the max P-state to control the power dissipation of the CPU, in AC
  20646. mode. Values are stated as a percentage of the available performance.
  20647. Defaults to @samp{disabled}.
  20648. @end deftypevr
  20649. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  20650. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  20651. Defaults to @samp{disabled}.
  20652. @end deftypevr
  20653. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  20654. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  20655. Defaults to @samp{disabled}.
  20656. @end deftypevr
  20657. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  20658. Enable CPU turbo boost feature on AC mode.
  20659. Defaults to @samp{disabled}.
  20660. @end deftypevr
  20661. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  20662. Same as @code{cpu-boost-on-ac?} on BAT mode.
  20663. Defaults to @samp{disabled}.
  20664. @end deftypevr
  20665. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  20666. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  20667. used under light load conditions.
  20668. Defaults to @samp{#f}.
  20669. @end deftypevr
  20670. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  20671. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  20672. Defaults to @samp{#t}.
  20673. @end deftypevr
  20674. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  20675. Enable Linux kernel NMI watchdog.
  20676. Defaults to @samp{#f}.
  20677. @end deftypevr
  20678. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  20679. For Linux kernels with PHC patch applied, change CPU voltages. An
  20680. example value would be @samp{"F:V F:V F:V F:V"}.
  20681. Defaults to @samp{disabled}.
  20682. @end deftypevr
  20683. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  20684. Set CPU performance versus energy saving policy on AC@. Alternatives are
  20685. performance, normal, powersave.
  20686. Defaults to @samp{"performance"}.
  20687. @end deftypevr
  20688. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  20689. Same as @code{energy-perf-policy-ac} but on BAT mode.
  20690. Defaults to @samp{"powersave"}.
  20691. @end deftypevr
  20692. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  20693. Hard disk devices.
  20694. @end deftypevr
  20695. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  20696. Hard disk advanced power management level.
  20697. @end deftypevr
  20698. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  20699. Same as @code{disk-apm-bat} but on BAT mode.
  20700. @end deftypevr
  20701. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  20702. Hard disk spin down timeout. One value has to be specified for each
  20703. declared hard disk.
  20704. Defaults to @samp{disabled}.
  20705. @end deftypevr
  20706. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  20707. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  20708. Defaults to @samp{disabled}.
  20709. @end deftypevr
  20710. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  20711. Select IO scheduler for disk devices. One value has to be specified for
  20712. each declared hard disk. Example alternatives are cfq, deadline and
  20713. noop.
  20714. Defaults to @samp{disabled}.
  20715. @end deftypevr
  20716. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  20717. SATA aggressive link power management (ALPM) level. Alternatives are
  20718. min_power, medium_power, max_performance.
  20719. Defaults to @samp{"max_performance"}.
  20720. @end deftypevr
  20721. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  20722. Same as @code{sata-linkpwr-ac} but on BAT mode.
  20723. Defaults to @samp{"min_power"}.
  20724. @end deftypevr
  20725. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  20726. Exclude specified SATA host devices for link power management.
  20727. Defaults to @samp{disabled}.
  20728. @end deftypevr
  20729. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  20730. Enable Runtime Power Management for AHCI controller and disks on AC
  20731. mode.
  20732. Defaults to @samp{disabled}.
  20733. @end deftypevr
  20734. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  20735. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  20736. Defaults to @samp{disabled}.
  20737. @end deftypevr
  20738. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  20739. Seconds of inactivity before disk is suspended.
  20740. Defaults to @samp{15}.
  20741. @end deftypevr
  20742. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  20743. PCI Express Active State Power Management level. Alternatives are
  20744. default, performance, powersave.
  20745. Defaults to @samp{"performance"}.
  20746. @end deftypevr
  20747. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  20748. Same as @code{pcie-aspm-ac} but on BAT mode.
  20749. Defaults to @samp{"powersave"}.
  20750. @end deftypevr
  20751. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  20752. Radeon graphics clock speed level. Alternatives are low, mid, high,
  20753. auto, default.
  20754. Defaults to @samp{"high"}.
  20755. @end deftypevr
  20756. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  20757. Same as @code{radeon-power-ac} but on BAT mode.
  20758. Defaults to @samp{"low"}.
  20759. @end deftypevr
  20760. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  20761. Radeon dynamic power management method (DPM). Alternatives are battery,
  20762. performance.
  20763. Defaults to @samp{"performance"}.
  20764. @end deftypevr
  20765. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  20766. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  20767. Defaults to @samp{"battery"}.
  20768. @end deftypevr
  20769. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  20770. Radeon DPM performance level. Alternatives are auto, low, high.
  20771. Defaults to @samp{"auto"}.
  20772. @end deftypevr
  20773. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  20774. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  20775. Defaults to @samp{"auto"}.
  20776. @end deftypevr
  20777. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  20778. Wifi power saving mode.
  20779. Defaults to @samp{#f}.
  20780. @end deftypevr
  20781. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  20782. Same as @code{wifi-power-ac?} but on BAT mode.
  20783. Defaults to @samp{#t}.
  20784. @end deftypevr
  20785. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  20786. Disable wake on LAN.
  20787. Defaults to @samp{#t}.
  20788. @end deftypevr
  20789. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  20790. Timeout duration in seconds before activating audio power saving on
  20791. Intel HDA and AC97 devices. A value of 0 disables power saving.
  20792. Defaults to @samp{0}.
  20793. @end deftypevr
  20794. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  20795. Same as @code{sound-powersave-ac} but on BAT mode.
  20796. Defaults to @samp{1}.
  20797. @end deftypevr
  20798. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  20799. Disable controller in powersaving mode on Intel HDA devices.
  20800. Defaults to @samp{#t}.
  20801. @end deftypevr
  20802. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  20803. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  20804. powered on again by releasing (and reinserting) the eject lever or by
  20805. pressing the disc eject button on newer models.
  20806. Defaults to @samp{#f}.
  20807. @end deftypevr
  20808. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  20809. Name of the optical drive device to power off.
  20810. Defaults to @samp{"sr0"}.
  20811. @end deftypevr
  20812. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  20813. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  20814. and auto.
  20815. Defaults to @samp{"on"}.
  20816. @end deftypevr
  20817. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  20818. Same as @code{runtime-pm-ac} but on BAT mode.
  20819. Defaults to @samp{"auto"}.
  20820. @end deftypevr
  20821. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  20822. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  20823. ones.
  20824. Defaults to @samp{#t}.
  20825. @end deftypevr
  20826. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  20827. Exclude specified PCI(e) device addresses from Runtime Power Management.
  20828. Defaults to @samp{disabled}.
  20829. @end deftypevr
  20830. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  20831. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  20832. Power Management.
  20833. @end deftypevr
  20834. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  20835. Enable USB autosuspend feature.
  20836. Defaults to @samp{#t}.
  20837. @end deftypevr
  20838. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  20839. Exclude specified devices from USB autosuspend.
  20840. Defaults to @samp{disabled}.
  20841. @end deftypevr
  20842. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  20843. Exclude WWAN devices from USB autosuspend.
  20844. Defaults to @samp{#t}.
  20845. @end deftypevr
  20846. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  20847. Include specified devices into USB autosuspend, even if they are already
  20848. excluded by the driver or via @code{usb-blacklist-wwan?}.
  20849. Defaults to @samp{disabled}.
  20850. @end deftypevr
  20851. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  20852. Enable USB autosuspend before shutdown.
  20853. Defaults to @samp{disabled}.
  20854. @end deftypevr
  20855. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  20856. Restore radio device state (bluetooth, wifi, wwan) from previous
  20857. shutdown on system startup.
  20858. Defaults to @samp{#f}.
  20859. @end deftypevr
  20860. @cindex thermald
  20861. @cindex CPU frequency scaling with thermald
  20862. @subsubheading Thermald daemon
  20863. The @code{(gnu services pm)} module provides an interface to
  20864. thermald, a CPU frequency scaling service which helps prevent overheating.
  20865. @defvr {Scheme Variable} thermald-service-type
  20866. This is the service type for
  20867. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  20868. Thermal Daemon, which is responsible for controlling the thermal state
  20869. of processors and preventing overheating.
  20870. @end defvr
  20871. @deftp {Data Type} thermald-configuration
  20872. Data type representing the configuration of @code{thermald-service-type}.
  20873. @table @asis
  20874. @item @code{ignore-cpuid-check?} (default: @code{#f})
  20875. Ignore cpuid check for supported CPU models.
  20876. @item @code{thermald} (default: @var{thermald})
  20877. Package object of thermald.
  20878. @end table
  20879. @end deftp
  20880. @node Audio Services
  20881. @subsection Audio Services
  20882. The @code{(gnu services audio)} module provides a service to start MPD
  20883. (the Music Player Daemon).
  20884. @cindex mpd
  20885. @subsubheading Music Player Daemon
  20886. The Music Player Daemon (MPD) is a service that can play music while
  20887. being controlled from the local machine or over the network by a variety
  20888. of clients.
  20889. The following example shows how one might run @code{mpd} as user
  20890. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  20891. @lisp
  20892. (service mpd-service-type
  20893. (mpd-configuration
  20894. (user "bob")
  20895. (port "6666")))
  20896. @end lisp
  20897. @defvr {Scheme Variable} mpd-service-type
  20898. The service type for @command{mpd}
  20899. @end defvr
  20900. @deftp {Data Type} mpd-configuration
  20901. Data type representing the configuration of @command{mpd}.
  20902. @table @asis
  20903. @item @code{user} (default: @code{"mpd"})
  20904. The user to run mpd as.
  20905. @item @code{music-dir} (default: @code{"~/Music"})
  20906. The directory to scan for music files.
  20907. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  20908. The directory to store playlists.
  20909. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  20910. The location of the music database.
  20911. @item @code{state-file} (default: @code{"~/.mpd/state"})
  20912. The location of the file that stores current MPD's state.
  20913. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  20914. The location of the sticker database.
  20915. @item @code{port} (default: @code{"6600"})
  20916. The port to run mpd on.
  20917. @item @code{address} (default: @code{"any"})
  20918. The address that mpd will bind to. To use a Unix domain socket,
  20919. an absolute path can be specified here.
  20920. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  20921. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  20922. @end table
  20923. @end deftp
  20924. @deftp {Data Type} mpd-output
  20925. Data type representing an @command{mpd} audio output.
  20926. @table @asis
  20927. @item @code{name} (default: @code{"MPD"})
  20928. The name of the audio output.
  20929. @item @code{type} (default: @code{"pulse"})
  20930. The type of audio output.
  20931. @item @code{enabled?} (default: @code{#t})
  20932. Specifies whether this audio output is enabled when MPD is started. By
  20933. default, all audio outputs are enabled. This is just the default
  20934. setting when there is no state file; with a state file, the previous
  20935. state is restored.
  20936. @item @code{tags?} (default: @code{#t})
  20937. If set to @code{#f}, then MPD will not send tags to this output. This
  20938. is only useful for output plugins that can receive tags, for example the
  20939. @code{httpd} output plugin.
  20940. @item @code{always-on?} (default: @code{#f})
  20941. If set to @code{#t}, then MPD attempts to keep this audio output always
  20942. open. This may be useful for streaming servers, when you don’t want to
  20943. disconnect all listeners even when playback is accidentally stopped.
  20944. @item @code{mixer-type}
  20945. This field accepts a symbol that specifies which mixer should be used
  20946. for this audio output: the @code{hardware} mixer, the @code{software}
  20947. mixer, the @code{null} mixer (allows setting the volume, but with no
  20948. effect; this can be used as a trick to implement an external mixer
  20949. External Mixer) or no mixer (@code{none}).
  20950. @item @code{extra-options} (default: @code{'()})
  20951. An association list of option symbols to string values to be appended to
  20952. the audio output configuration.
  20953. @end table
  20954. @end deftp
  20955. The following example shows a configuration of @code{mpd} that provides
  20956. an HTTP audio streaming output.
  20957. @lisp
  20958. (service mpd-service-type
  20959. (mpd-configuration
  20960. (outputs
  20961. (list (mpd-output
  20962. (name "streaming")
  20963. (type "httpd")
  20964. (mixer-type 'null)
  20965. (extra-options
  20966. `((encoder . "vorbis")
  20967. (port . "8080"))))))))
  20968. @end lisp
  20969. @node Virtualization Services
  20970. @subsection Virtualization Services
  20971. The @code{(gnu services virtualization)} module provides services for
  20972. the libvirt and virtlog daemons, as well as other virtualization-related
  20973. services.
  20974. @subsubheading Libvirt daemon
  20975. @code{libvirtd} is the server side daemon component of the libvirt
  20976. virtualization management system. This daemon runs on host servers
  20977. and performs required management tasks for virtualized guests.
  20978. @deffn {Scheme Variable} libvirt-service-type
  20979. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  20980. Its value must be a @code{libvirt-configuration}.
  20981. @lisp
  20982. (service libvirt-service-type
  20983. (libvirt-configuration
  20984. (unix-sock-group "libvirt")
  20985. (tls-port "16555")))
  20986. @end lisp
  20987. @end deffn
  20988. @c Auto-generated with (generate-libvirt-documentation)
  20989. Available @code{libvirt-configuration} fields are:
  20990. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  20991. Libvirt package.
  20992. @end deftypevr
  20993. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  20994. Flag listening for secure TLS connections on the public TCP/IP port.
  20995. You must set @code{listen} for this to have any effect.
  20996. It is necessary to setup a CA and issue server certificates before using
  20997. this capability.
  20998. Defaults to @samp{#t}.
  20999. @end deftypevr
  21000. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  21001. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  21002. set @code{listen} for this to have any effect.
  21003. Using the TCP socket requires SASL authentication by default. Only SASL
  21004. mechanisms which support data encryption are allowed. This is
  21005. DIGEST_MD5 and GSSAPI (Kerberos5).
  21006. Defaults to @samp{#f}.
  21007. @end deftypevr
  21008. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  21009. Port for accepting secure TLS connections. This can be a port number,
  21010. or service name.
  21011. Defaults to @samp{"16514"}.
  21012. @end deftypevr
  21013. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  21014. Port for accepting insecure TCP connections. This can be a port number,
  21015. or service name.
  21016. Defaults to @samp{"16509"}.
  21017. @end deftypevr
  21018. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  21019. IP address or hostname used for client connections.
  21020. Defaults to @samp{"0.0.0.0"}.
  21021. @end deftypevr
  21022. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  21023. Flag toggling mDNS advertisement of the libvirt service.
  21024. Alternatively can disable for all services on a host by stopping the
  21025. Avahi daemon.
  21026. Defaults to @samp{#f}.
  21027. @end deftypevr
  21028. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  21029. Default mDNS advertisement name. This must be unique on the immediate
  21030. broadcast network.
  21031. Defaults to @samp{"Virtualization Host <hostname>"}.
  21032. @end deftypevr
  21033. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  21034. UNIX domain socket group ownership. This can be used to allow a
  21035. 'trusted' set of users access to management capabilities without
  21036. becoming root.
  21037. Defaults to @samp{"root"}.
  21038. @end deftypevr
  21039. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  21040. UNIX socket permissions for the R/O socket. This is used for monitoring
  21041. VM status only.
  21042. Defaults to @samp{"0777"}.
  21043. @end deftypevr
  21044. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  21045. UNIX socket permissions for the R/W socket. Default allows only root.
  21046. If PolicyKit is enabled on the socket, the default will change to allow
  21047. everyone (eg, 0777)
  21048. Defaults to @samp{"0770"}.
  21049. @end deftypevr
  21050. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  21051. UNIX socket permissions for the admin socket. Default allows only owner
  21052. (root), do not change it unless you are sure to whom you are exposing
  21053. the access to.
  21054. Defaults to @samp{"0777"}.
  21055. @end deftypevr
  21056. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  21057. The directory in which sockets will be found/created.
  21058. Defaults to @samp{"/var/run/libvirt"}.
  21059. @end deftypevr
  21060. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  21061. Authentication scheme for UNIX read-only sockets. By default socket
  21062. permissions allow anyone to connect
  21063. Defaults to @samp{"polkit"}.
  21064. @end deftypevr
  21065. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  21066. Authentication scheme for UNIX read-write sockets. By default socket
  21067. permissions only allow root. If PolicyKit support was compiled into
  21068. libvirt, the default will be to use 'polkit' auth.
  21069. Defaults to @samp{"polkit"}.
  21070. @end deftypevr
  21071. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  21072. Authentication scheme for TCP sockets. If you don't enable SASL, then
  21073. all TCP traffic is cleartext. Don't do this outside of a dev/test
  21074. scenario.
  21075. Defaults to @samp{"sasl"}.
  21076. @end deftypevr
  21077. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  21078. Authentication scheme for TLS sockets. TLS sockets already have
  21079. encryption provided by the TLS layer, and limited authentication is done
  21080. by certificates.
  21081. It is possible to make use of any SASL authentication mechanism as well,
  21082. by using 'sasl' for this option
  21083. Defaults to @samp{"none"}.
  21084. @end deftypevr
  21085. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  21086. API access control scheme.
  21087. By default an authenticated user is allowed access to all APIs. Access
  21088. drivers can place restrictions on this.
  21089. Defaults to @samp{()}.
  21090. @end deftypevr
  21091. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  21092. Server key file path. If set to an empty string, then no private key is
  21093. loaded.
  21094. Defaults to @samp{""}.
  21095. @end deftypevr
  21096. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  21097. Server key file path. If set to an empty string, then no certificate is
  21098. loaded.
  21099. Defaults to @samp{""}.
  21100. @end deftypevr
  21101. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  21102. Server key file path. If set to an empty string, then no CA certificate
  21103. is loaded.
  21104. Defaults to @samp{""}.
  21105. @end deftypevr
  21106. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  21107. Certificate revocation list path. If set to an empty string, then no
  21108. CRL is loaded.
  21109. Defaults to @samp{""}.
  21110. @end deftypevr
  21111. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  21112. Disable verification of our own server certificates.
  21113. When libvirtd starts it performs some sanity checks against its own
  21114. certificates.
  21115. Defaults to @samp{#f}.
  21116. @end deftypevr
  21117. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  21118. Disable verification of client certificates.
  21119. Client certificate verification is the primary authentication mechanism.
  21120. Any client which does not present a certificate signed by the CA will be
  21121. rejected.
  21122. Defaults to @samp{#f}.
  21123. @end deftypevr
  21124. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  21125. Whitelist of allowed x509 Distinguished Name.
  21126. Defaults to @samp{()}.
  21127. @end deftypevr
  21128. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  21129. Whitelist of allowed SASL usernames. The format for username depends on
  21130. the SASL authentication mechanism.
  21131. Defaults to @samp{()}.
  21132. @end deftypevr
  21133. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  21134. Override the compile time default TLS priority string. The default is
  21135. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  21136. is desired for libvirt to deviate from the global default settings.
  21137. Defaults to @samp{"NORMAL"}.
  21138. @end deftypevr
  21139. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  21140. Maximum number of concurrent client connections to allow over all
  21141. sockets combined.
  21142. Defaults to @samp{5000}.
  21143. @end deftypevr
  21144. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  21145. Maximum length of queue of connections waiting to be accepted by the
  21146. daemon. Note, that some protocols supporting retransmission may obey
  21147. this so that a later reattempt at connection succeeds.
  21148. Defaults to @samp{1000}.
  21149. @end deftypevr
  21150. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  21151. Maximum length of queue of accepted but not yet authenticated clients.
  21152. Set this to zero to turn this feature off
  21153. Defaults to @samp{20}.
  21154. @end deftypevr
  21155. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  21156. Number of workers to start up initially.
  21157. Defaults to @samp{5}.
  21158. @end deftypevr
  21159. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  21160. Maximum number of worker threads.
  21161. If the number of active clients exceeds @code{min-workers}, then more
  21162. threads are spawned, up to max_workers limit. Typically you'd want
  21163. max_workers to equal maximum number of clients allowed.
  21164. Defaults to @samp{20}.
  21165. @end deftypevr
  21166. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  21167. Number of priority workers. If all workers from above pool are stuck,
  21168. some calls marked as high priority (notably domainDestroy) can be
  21169. executed in this pool.
  21170. Defaults to @samp{5}.
  21171. @end deftypevr
  21172. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  21173. Total global limit on concurrent RPC calls.
  21174. Defaults to @samp{20}.
  21175. @end deftypevr
  21176. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  21177. Limit on concurrent requests from a single client connection. To avoid
  21178. one client monopolizing the server this should be a small fraction of
  21179. the global max_requests and max_workers parameter.
  21180. Defaults to @samp{5}.
  21181. @end deftypevr
  21182. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  21183. Same as @code{min-workers} but for the admin interface.
  21184. Defaults to @samp{1}.
  21185. @end deftypevr
  21186. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  21187. Same as @code{max-workers} but for the admin interface.
  21188. Defaults to @samp{5}.
  21189. @end deftypevr
  21190. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  21191. Same as @code{max-clients} but for the admin interface.
  21192. Defaults to @samp{5}.
  21193. @end deftypevr
  21194. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  21195. Same as @code{max-queued-clients} but for the admin interface.
  21196. Defaults to @samp{5}.
  21197. @end deftypevr
  21198. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  21199. Same as @code{max-client-requests} but for the admin interface.
  21200. Defaults to @samp{5}.
  21201. @end deftypevr
  21202. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  21203. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  21204. Defaults to @samp{3}.
  21205. @end deftypevr
  21206. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  21207. Logging filters.
  21208. A filter allows to select a different logging level for a given category
  21209. of logs. The format for a filter is one of:
  21210. @itemize @bullet
  21211. @item
  21212. x:name
  21213. @item
  21214. x:+name
  21215. @end itemize
  21216. where @code{name} is a string which is matched against the category
  21217. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  21218. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  21219. name in the filter can be a substring of the full category name, in
  21220. order to match multiple similar categories), the optional @samp{"+"}
  21221. prefix tells libvirt to log stack trace for each message matching name,
  21222. and @code{x} is the minimal level where matching messages should be
  21223. logged:
  21224. @itemize @bullet
  21225. @item
  21226. 1: DEBUG
  21227. @item
  21228. 2: INFO
  21229. @item
  21230. 3: WARNING
  21231. @item
  21232. 4: ERROR
  21233. @end itemize
  21234. Multiple filters can be defined in a single filters statement, they just
  21235. need to be separated by spaces.
  21236. Defaults to @samp{"3:remote 4:event"}.
  21237. @end deftypevr
  21238. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  21239. Logging outputs.
  21240. An output is one of the places to save logging information. The format
  21241. for an output can be:
  21242. @table @code
  21243. @item x:stderr
  21244. output goes to stderr
  21245. @item x:syslog:name
  21246. use syslog for the output and use the given name as the ident
  21247. @item x:file:file_path
  21248. output to a file, with the given filepath
  21249. @item x:journald
  21250. output to journald logging system
  21251. @end table
  21252. In all case the x prefix is the minimal level, acting as a filter
  21253. @itemize @bullet
  21254. @item
  21255. 1: DEBUG
  21256. @item
  21257. 2: INFO
  21258. @item
  21259. 3: WARNING
  21260. @item
  21261. 4: ERROR
  21262. @end itemize
  21263. Multiple outputs can be defined, they just need to be separated by
  21264. spaces.
  21265. Defaults to @samp{"3:stderr"}.
  21266. @end deftypevr
  21267. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  21268. Allows usage of the auditing subsystem to be altered
  21269. @itemize @bullet
  21270. @item
  21271. 0: disable all auditing
  21272. @item
  21273. 1: enable auditing, only if enabled on host
  21274. @item
  21275. 2: enable auditing, and exit if disabled on host.
  21276. @end itemize
  21277. Defaults to @samp{1}.
  21278. @end deftypevr
  21279. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  21280. Send audit messages via libvirt logging infrastructure.
  21281. Defaults to @samp{#f}.
  21282. @end deftypevr
  21283. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  21284. Host UUID@. UUID must not have all digits be the same.
  21285. Defaults to @samp{""}.
  21286. @end deftypevr
  21287. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  21288. Source to read host UUID.
  21289. @itemize @bullet
  21290. @item
  21291. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  21292. @item
  21293. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  21294. @end itemize
  21295. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  21296. be generated.
  21297. Defaults to @samp{"smbios"}.
  21298. @end deftypevr
  21299. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  21300. A keepalive message is sent to a client after @code{keepalive_interval}
  21301. seconds of inactivity to check if the client is still responding. If
  21302. set to -1, libvirtd will never send keepalive requests; however clients
  21303. can still send them and the daemon will send responses.
  21304. Defaults to @samp{5}.
  21305. @end deftypevr
  21306. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  21307. Maximum number of keepalive messages that are allowed to be sent to the
  21308. client without getting any response before the connection is considered
  21309. broken.
  21310. In other words, the connection is automatically closed approximately
  21311. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  21312. the last message received from the client. When @code{keepalive-count}
  21313. is set to 0, connections will be automatically closed after
  21314. @code{keepalive-interval} seconds of inactivity without sending any
  21315. keepalive messages.
  21316. Defaults to @samp{5}.
  21317. @end deftypevr
  21318. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  21319. Same as above but for admin interface.
  21320. Defaults to @samp{5}.
  21321. @end deftypevr
  21322. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  21323. Same as above but for admin interface.
  21324. Defaults to @samp{5}.
  21325. @end deftypevr
  21326. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  21327. Timeout for Open vSwitch calls.
  21328. The @code{ovs-vsctl} utility is used for the configuration and its
  21329. timeout option is set by default to 5 seconds to avoid potential
  21330. infinite waits blocking libvirt.
  21331. Defaults to @samp{5}.
  21332. @end deftypevr
  21333. @c %end of autogenerated docs
  21334. @subsubheading Virtlog daemon
  21335. The virtlogd service is a server side daemon component of libvirt that is
  21336. used to manage logs from virtual machine consoles.
  21337. This daemon is not used directly by libvirt client applications, rather it
  21338. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  21339. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  21340. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  21341. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  21342. @deffn {Scheme Variable} virtlog-service-type
  21343. This is the type of the virtlog daemon.
  21344. Its value must be a @code{virtlog-configuration}.
  21345. @lisp
  21346. (service virtlog-service-type
  21347. (virtlog-configuration
  21348. (max-clients 1000)))
  21349. @end lisp
  21350. @end deffn
  21351. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  21352. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  21353. Defaults to @samp{3}.
  21354. @end deftypevr
  21355. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  21356. Logging filters.
  21357. A filter allows to select a different logging level for a given category
  21358. of logs The format for a filter is one of:
  21359. @itemize @bullet
  21360. @item
  21361. x:name
  21362. @item
  21363. x:+name
  21364. @end itemize
  21365. where @code{name} is a string which is matched against the category
  21366. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  21367. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  21368. be a substring of the full category name, in order to match multiple
  21369. similar categories), the optional "+" prefix tells libvirt to log stack
  21370. trace for each message matching name, and @code{x} is the minimal level
  21371. where matching messages should be logged:
  21372. @itemize @bullet
  21373. @item
  21374. 1: DEBUG
  21375. @item
  21376. 2: INFO
  21377. @item
  21378. 3: WARNING
  21379. @item
  21380. 4: ERROR
  21381. @end itemize
  21382. Multiple filters can be defined in a single filters statement, they just
  21383. need to be separated by spaces.
  21384. Defaults to @samp{"3:remote 4:event"}.
  21385. @end deftypevr
  21386. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  21387. Logging outputs.
  21388. An output is one of the places to save logging information The format
  21389. for an output can be:
  21390. @table @code
  21391. @item x:stderr
  21392. output goes to stderr
  21393. @item x:syslog:name
  21394. use syslog for the output and use the given name as the ident
  21395. @item x:file:file_path
  21396. output to a file, with the given filepath
  21397. @item x:journald
  21398. output to journald logging system
  21399. @end table
  21400. In all case the x prefix is the minimal level, acting as a filter
  21401. @itemize @bullet
  21402. @item
  21403. 1: DEBUG
  21404. @item
  21405. 2: INFO
  21406. @item
  21407. 3: WARNING
  21408. @item
  21409. 4: ERROR
  21410. @end itemize
  21411. Multiple outputs can be defined, they just need to be separated by
  21412. spaces.
  21413. Defaults to @samp{"3:stderr"}.
  21414. @end deftypevr
  21415. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  21416. Maximum number of concurrent client connections to allow over all
  21417. sockets combined.
  21418. Defaults to @samp{1024}.
  21419. @end deftypevr
  21420. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  21421. Maximum file size before rolling over.
  21422. Defaults to @samp{2MB}
  21423. @end deftypevr
  21424. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  21425. Maximum number of backup files to keep.
  21426. Defaults to @samp{3}
  21427. @end deftypevr
  21428. @anchor{transparent-emulation-qemu}
  21429. @subsubheading Transparent Emulation with QEMU
  21430. @cindex emulation
  21431. @cindex @code{binfmt_misc}
  21432. @code{qemu-binfmt-service-type} provides support for transparent
  21433. emulation of program binaries built for different architectures---e.g.,
  21434. it allows you to transparently execute an ARMv7 program on an x86_64
  21435. machine. It achieves this by combining the @uref{https://www.qemu.org,
  21436. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  21437. This feature only allows you to emulate GNU/Linux on a different
  21438. architecture, but see below for GNU/Hurd support.
  21439. @defvr {Scheme Variable} qemu-binfmt-service-type
  21440. This is the type of the QEMU/binfmt service for transparent emulation.
  21441. Its value must be a @code{qemu-binfmt-configuration} object, which
  21442. specifies the QEMU package to use as well as the architecture we want to
  21443. emulated:
  21444. @lisp
  21445. (service qemu-binfmt-service-type
  21446. (qemu-binfmt-configuration
  21447. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  21448. @end lisp
  21449. In this example, we enable transparent emulation for the ARM and aarch64
  21450. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  21451. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  21452. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  21453. @end defvr
  21454. @deftp {Data Type} qemu-binfmt-configuration
  21455. This is the configuration for the @code{qemu-binfmt} service.
  21456. @table @asis
  21457. @item @code{platforms} (default: @code{'()})
  21458. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  21459. object} as returned by @code{lookup-qemu-platforms} (see below).
  21460. @item @code{guix-support?} (default: @code{#t})
  21461. When it is true, QEMU and all its dependencies are added to the build
  21462. environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
  21463. @option{--chroot-directory} option}). This allows the @code{binfmt_misc}
  21464. handlers to be used within the build environment, which in turn means
  21465. that you can transparently build programs for another architecture.
  21466. For example, let's suppose you're on an x86_64 machine and you have this
  21467. service:
  21468. @lisp
  21469. (service qemu-binfmt-service-type
  21470. (qemu-binfmt-configuration
  21471. (platforms (lookup-qemu-platforms "arm"))
  21472. (guix-support? #t)))
  21473. @end lisp
  21474. You can run:
  21475. @example
  21476. guix build -s armhf-linux inkscape
  21477. @end example
  21478. @noindent
  21479. and it will build Inkscape for ARMv7 @emph{as if it were a native
  21480. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  21481. if you'd like to test a package build for an architecture you don't have
  21482. access to!
  21483. When @code{guix-support?} is set to @code{#f}, programs for other
  21484. architectures can still be executed transparently, but invoking commands
  21485. like @command{guix build -s armhf-linux @dots{}} will fail.
  21486. @item @code{qemu} (default: @code{qemu})
  21487. The QEMU package to use.
  21488. @end table
  21489. @end deftp
  21490. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  21491. Return the list of QEMU platform objects corresponding to
  21492. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  21493. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  21494. @code{"mips64el"}, and so on.
  21495. @end deffn
  21496. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  21497. Return true if @var{obj} is a platform object.
  21498. @end deffn
  21499. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  21500. Return the name of @var{platform}---a string such as @code{"arm"}.
  21501. @end deffn
  21502. @subsubheading The Hurd in a Virtual Machine
  21503. @cindex @code{hurd}
  21504. @cindex the Hurd
  21505. @cindex childhurd
  21506. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  21507. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  21508. to be used on GNU/Linux and the given GNU/Hurd operating system
  21509. configuration is cross-compiled. The virtual machine is a Shepherd
  21510. service that can be referred to by the names @code{hurd-vm} and
  21511. @code{childhurd} and be controlled with commands such as:
  21512. @example
  21513. herd start hurd-vm
  21514. herd stop childhurd
  21515. @end example
  21516. When the service is running, you can view its console by connecting to
  21517. it with a VNC client, for example with:
  21518. @example
  21519. guix environment --ad-hoc tigervnc-client -- \
  21520. vncviewer localhost:5900
  21521. @end example
  21522. The default configuration (see @code{hurd-vm-configuration} below)
  21523. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  21524. (the virtual machine emulator) redirects to port 10222 on the host.
  21525. Thus, you can connect over SSH to the childhurd with:
  21526. @example
  21527. ssh root@@localhost -p 10022
  21528. @end example
  21529. The childhurd is volatile and stateless: it starts with a fresh root
  21530. file system every time you restart it. By default though, all the files
  21531. under @file{/etc/childhurd} on the host are copied as is to the root
  21532. file system of the childhurd when it boots. This allows you to
  21533. initialize ``secrets'' inside the VM: SSH host keys, authorized
  21534. substitute keys, and so on---see the explanation of @code{secret-root}
  21535. below.
  21536. @defvr {Scheme Variable} hurd-vm-service-type
  21537. This is the type of the Hurd in a Virtual Machine service. Its value
  21538. must be a @code{hurd-vm-configuration} object, which specifies the
  21539. operating system (@pxref{operating-system Reference}) and the disk size
  21540. for the Hurd Virtual Machine, the QEMU package to use as well as the
  21541. options for running it.
  21542. For example:
  21543. @lisp
  21544. (service hurd-vm-service-type
  21545. (hurd-vm-configuration
  21546. (disk-size (* 5000 (expt 2 20))) ;5G
  21547. (memory-size 1024))) ;1024MiB
  21548. @end lisp
  21549. would create a disk image big enough to build GNU@tie{}Hello, with some
  21550. extra memory.
  21551. @end defvr
  21552. @deftp {Data Type} hurd-vm-configuration
  21553. The data type representing the configuration for
  21554. @code{hurd-vm-service-type}.
  21555. @table @asis
  21556. @item @code{os} (default: @var{%hurd-vm-operating-system})
  21557. The operating system to instantiate. This default is bare-bones with a
  21558. permissive OpenSSH secure shell daemon listening on port 2222
  21559. (@pxref{Networking Services, @code{openssh-service-type}}).
  21560. @item @code{qemu} (default: @code{qemu-minimal})
  21561. The QEMU package to use.
  21562. @item @code{image} (default: @var{hurd-vm-disk-image})
  21563. The procedure used to build the disk-image built from this
  21564. configuration.
  21565. @item @code{disk-size} (default: @code{'guess})
  21566. The size of the disk image.
  21567. @item @code{memory-size} (default: @code{512})
  21568. The memory size of the Virtual Machine in mebibytes.
  21569. @item @code{options} (default: @code{'("--snapshot")})
  21570. The extra options for running QEMU.
  21571. @item @code{id} (default: @code{#f})
  21572. If set, a non-zero positive integer used to parameterize Childhurd
  21573. instances. It is appended to the service's name,
  21574. e.g. @code{childhurd1}.
  21575. @item @code{net-options} (default: @var{hurd-vm-net-options})
  21576. The procedure used to produce the list of QEMU networking options.
  21577. By default, it produces
  21578. @lisp
  21579. '("--device" "rtl8139,netdev=net0"
  21580. "--netdev" "user,id=net0\
  21581. ,hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004\
  21582. ,hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222\
  21583. ,hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900")
  21584. @end lisp
  21585. with forwarded ports:
  21586. @example
  21587. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  21588. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  21589. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  21590. @end example
  21591. @item @code{secret-root} (default: @file{/etc/childhurd})
  21592. The root directory with out-of-band secrets to be installed into the
  21593. childhurd once it runs. Childhurds are volatile which means that on
  21594. every startup, secrets such as the SSH host keys and Guix signing key
  21595. are recreated.
  21596. If the @file{/etc/childhurd} directory does not exist, the
  21597. @code{secret-service} running in the Childhurd will be sent an empty
  21598. list of secrets.
  21599. By default, the service automatically populates @file{/etc/childhurd}
  21600. with the following non-volatile secrets, unless they already exist:
  21601. @example
  21602. /etc/childhurd/etc/guix/acl
  21603. /etc/childhurd/etc/guix/signing-key.pub
  21604. /etc/childhurd/etc/guix/signing-key.sec
  21605. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  21606. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  21607. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  21608. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  21609. @end example
  21610. These files are automatically sent to the guest Hurd VM when it boots,
  21611. including permissions.
  21612. @cindex childhurd, offloading
  21613. @cindex Hurd, offloading
  21614. Having these files in place means that only a couple of things are
  21615. missing to allow the host to offload @code{i586-gnu} builds to the
  21616. childhurd:
  21617. @enumerate
  21618. @item
  21619. Authorizing the childhurd's key on the host so that the host accepts
  21620. build results coming from the childhurd, which can be done like so:
  21621. @example
  21622. guix archive --authorize < \
  21623. /etc/childhurd/etc/guix/signing-key.pub
  21624. @end example
  21625. @item
  21626. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  21627. Offload Setup}).
  21628. @end enumerate
  21629. We're working towards making that happen automatically---get in touch
  21630. with us at @email{guix-devel@@gnu.org} to discuss it!
  21631. @end table
  21632. @end deftp
  21633. Note that by default the VM image is volatile, i.e., once stopped the
  21634. contents are lost. If you want a stateful image instead, override the
  21635. configuration's @code{image} and @code{options} without
  21636. the @code{--snapshot} flag using something along these lines:
  21637. @lisp
  21638. (service hurd-vm-service-type
  21639. (hurd-vm-configuration
  21640. (image (const "/out/of/store/writable/hurd.img"))
  21641. (options '())))
  21642. @end lisp
  21643. @subsubheading Ganeti
  21644. @cindex ganeti
  21645. @quotation Note
  21646. This service is considered experimental. Configuration options may be changed
  21647. in a backwards-incompatible manner, and not all features have been thorougly
  21648. tested. Users of this service are encouraged to share their experience at
  21649. @email{guix-devel@@gnu.org}.
  21650. @end quotation
  21651. Ganeti is a virtual machine management system. It is designed to keep virtual
  21652. machines running on a cluster of servers even in the event of hardware failures,
  21653. and to make maintenance and recovery tasks easy. It consists of multiple
  21654. services which are described later in this section. In addition to the Ganeti
  21655. service, you will need the OpenSSH service (@pxref{Networking Services,
  21656. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  21657. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  21658. and address (or use a DNS server).
  21659. All nodes participating in a Ganeti cluster should have the same Ganeti and
  21660. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  21661. cluster node that supports multiple storage backends, and installs the
  21662. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  21663. @lisp
  21664. (use-package-modules virtualization)
  21665. (use-service-modules base ganeti networking ssh)
  21666. (operating-system
  21667. ;; @dots{}
  21668. (host-name "node1")
  21669. (hosts-file (plain-file "hosts" (format #f "
  21670. 127.0.0.1 localhost
  21671. ::1 localhost
  21672. 192.168.1.200 ganeti.example.com
  21673. 192.168.1.201 node1.example.com node1
  21674. 192.168.1.202 node2.example.com node2
  21675. ")))
  21676. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  21677. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  21678. (packages (append (map specification->package
  21679. '("qemu" "lvm2" "drbd-utils" "ceph"
  21680. ;; Add the debootstrap and guix OS providers.
  21681. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  21682. %base-packages))
  21683. (services
  21684. (append (list (static-networking-service "eth0" "192.168.1.201"
  21685. #:netmask "255.255.255.0"
  21686. #:gateway "192.168.1.254"
  21687. #:name-servers '("192.168.1.252"
  21688. "192.168.1.253"))
  21689. ;; Ganeti uses SSH to communicate between nodes.
  21690. (service openssh-service-type
  21691. (openssh-configuration
  21692. (permit-root-login 'without-password)))
  21693. (service ganeti-service-type
  21694. (ganeti-configuration
  21695. ;; This list specifies allowed file system paths
  21696. ;; for storing virtual machine images.
  21697. (file-storage-paths '("/srv/ganeti/file-storage"))
  21698. ;; This variable configures a single "variant" for
  21699. ;; both Debootstrap and Guix that works with KVM.
  21700. (os %default-ganeti-os))))
  21701. %base-services)))
  21702. @end lisp
  21703. Users are advised to read the
  21704. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  21705. administrators guide} to learn about the various cluster options and
  21706. day-to-day operations. There is also a
  21707. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  21708. describing how to configure and initialize a small cluster.
  21709. @defvr {Scheme Variable} ganeti-service-type
  21710. This is a service type that includes all the various services that Ganeti
  21711. nodes should run.
  21712. Its value is a @code{ganeti-configuration} object that defines the package
  21713. to use for CLI operations, as well as configuration for the various daemons.
  21714. Allowed file storage paths and available guest operating systems are also
  21715. configured through this data type.
  21716. @end defvr
  21717. @deftp {Data Type} ganeti-configuration
  21718. The @code{ganeti} service takes the following configuration options:
  21719. @table @asis
  21720. @item @code{ganeti} (default: @code{ganeti})
  21721. The @code{ganeti} package to use. It will be installed to the system profile
  21722. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  21723. that the value specified here does not affect the other services as each refer
  21724. to a specific @code{ganeti} package (see below).
  21725. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  21726. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  21727. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  21728. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  21729. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  21730. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  21731. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  21732. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  21733. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  21734. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  21735. These options control the various daemons and cron jobs that are distributed
  21736. with Ganeti. The possible values for these are described in detail below.
  21737. To override a setting, you must use the configuration type for that service:
  21738. @lisp
  21739. (service ganeti-service-type
  21740. (ganeti-configuration
  21741. (rapi-configuration
  21742. (ganeti-rapi-configuration
  21743. (interface "eth1"))))
  21744. (watcher-configuration
  21745. (ganeti-watcher-configuration
  21746. (rapi-ip "10.0.0.1"))))
  21747. @end lisp
  21748. @item @code{file-storage-paths} (default: @code{'()})
  21749. List of allowed directories for file storage backend.
  21750. @item @code{os} (default: @code{%default-ganeti-os})
  21751. List of @code{<ganeti-os>} records.
  21752. @end table
  21753. In essence @code{ganeti-service-type} is shorthand for declaring each service
  21754. individually:
  21755. @lisp
  21756. (service ganeti-noded-service-type)
  21757. (service ganeti-confd-service-type)
  21758. (service ganeti-wconfd-service-type)
  21759. (service ganeti-luxid-service-type)
  21760. (service ganeti-kvmd-service-type)
  21761. (service ganeti-mond-service-type)
  21762. (service ganeti-metad-service-type)
  21763. (service ganeti-watcher-service-type)
  21764. (service ganeti-cleaner-service-type)
  21765. @end lisp
  21766. Plus a service extension for @code{etc-service-type} that configures the file
  21767. storage backend and OS variants.
  21768. @end deftp
  21769. @deftp {Data Type} ganeti-os
  21770. This data type is suitable for passing to the @code{os} parameter of
  21771. @code{ganeti-configuration}. It takes the following parameters:
  21772. @table @asis
  21773. @item @code{name}
  21774. The name for this OS provider. It is only used to specify where the
  21775. configuration ends up. Setting it to ``debootstrap'' will create
  21776. @file{/etc/ganeti/instance-debootstrap}.
  21777. @item @code{extension}
  21778. The file extension for variants of this OS type. For example
  21779. @file{.conf} or @file{.scm}.
  21780. @item @code{variants} (default: @code{'()})
  21781. List of @code{ganeti-os-variant} objects for this OS.
  21782. @end table
  21783. @end deftp
  21784. @deftp {Data Type} ganeti-os-variant
  21785. This is the data type for a Ganeti OS variant. It takes the following
  21786. parameters:
  21787. @table @asis
  21788. @item @code{name}
  21789. The name of this variant.
  21790. @item @code{configuration}
  21791. A configuration file for this variant.
  21792. @end table
  21793. @end deftp
  21794. @defvr {Scheme Variable} %default-debootstrap-hooks
  21795. This variable contains hooks to configure networking and the GRUB bootloader.
  21796. @end defvr
  21797. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  21798. This variable contains a list of packages suitable for a fully-virtualized guest.
  21799. @end defvr
  21800. @deftp {Data Type} debootstrap-configuration
  21801. This data type creates configuration files suitable for the debootstrap OS provider.
  21802. @table @asis
  21803. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  21804. When not @code{#f}, this must be a G-expression that specifies a directory with
  21805. scripts that will run when the OS is installed. It can also be a list of
  21806. @code{(name . file-like)} pairs. For example:
  21807. @lisp
  21808. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  21809. @end lisp
  21810. That will create a directory with one executable named @code{99-hello-world}
  21811. and run it every time this variant is installed. If set to @code{#f}, hooks
  21812. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  21813. @item @code{proxy} (default: @code{#f})
  21814. Optional HTTP proxy to use.
  21815. @item @code{mirror} (default: @code{#f})
  21816. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  21817. The default varies depending on the distribution.
  21818. @item @code{arch} (default: @code{#f})
  21819. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  21820. on an AArch64 host. Default is to use the current system architecture.
  21821. @item @code{suite} (default: @code{"stable"})
  21822. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  21823. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  21824. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  21825. List of extra packages that will get installed by dpkg in addition
  21826. to the minimal system.
  21827. @item @code{components} (default: @code{#f})
  21828. When set, must be a list of Debian repository ``components''. For example
  21829. @code{'("main" "contrib")}.
  21830. @item @code{generate-cache?} (default: @code{#t})
  21831. Whether to automatically cache the generated debootstrap archive.
  21832. @item @code{clean-cache} (default: @code{14})
  21833. Discard the cache after this amount of days. Use @code{#f} to never
  21834. clear the cache.
  21835. @item @code{partition-style} (default: @code{'msdos})
  21836. The type of partition to create. When set, it must be one of
  21837. @code{'msdos}, @code{'none} or a string.
  21838. @item @code{partition-alignment} (default: @code{2048})
  21839. Alignment of the partition in sectors.
  21840. @end table
  21841. @end deftp
  21842. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  21843. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  21844. takes two parameters: a name and a @code{debootstrap-configuration} object.
  21845. @end deffn
  21846. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  21847. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  21848. a list of variants created with @code{debootstrap-variant}.
  21849. @end deffn
  21850. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  21851. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  21852. use with the Guix OS provider. It takes a name and a G-expression that returns
  21853. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  21854. Guix System configuration.
  21855. @end deffn
  21856. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  21857. This is a helper procedure that creates a @code{ganeti-os} record. It
  21858. takes a list of variants produced by @code{guix-variant}.
  21859. @end deffn
  21860. @defvr {Scheme Variable} %default-debootstrap-variants
  21861. This is a convenience variable to make the debootstrap provider work
  21862. ``out of the box'' without users having to declare variants manually. It
  21863. contains a single debootstrap variant with the default configuration:
  21864. @lisp
  21865. (list (debootstrap-variant
  21866. "default"
  21867. (debootstrap-configuration)))
  21868. @end lisp
  21869. @end defvr
  21870. @defvr {Scheme Variable} %default-guix-variants
  21871. This is a convenience variable to make the Guix OS provider work without
  21872. additional configuration. It creates a virtual machine that has an SSH
  21873. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  21874. @lisp
  21875. (list (guix-variant
  21876. "default"
  21877. (file-append ganeti-instance-guix
  21878. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  21879. @end lisp
  21880. @end defvr
  21881. Users can implement support for OS providers unbeknownst to Guix by extending
  21882. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  21883. For example:
  21884. @lisp
  21885. (ganeti-os
  21886. (name "custom")
  21887. (extension ".conf")
  21888. (variants
  21889. (list (ganeti-os-variant
  21890. (name "foo")
  21891. (configuration (plain-file "bar" "this is fine"))))))
  21892. @end lisp
  21893. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  21894. to a file in the store with contents @code{this is fine}. It also creates
  21895. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  21896. Obviously this may not work for all OS providers out there. If you find the
  21897. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  21898. The rest of this section documents the various services that are included by
  21899. @code{ganeti-service-type}.
  21900. @defvr {Scheme Variable} ganeti-noded-service-type
  21901. @command{ganeti-noded} is the daemon responsible for node-specific functions
  21902. within the Ganeti system. The value of this service must be a
  21903. @code{ganeti-noded-configuration} object.
  21904. @end defvr
  21905. @deftp {Data Type} ganeti-noded-configuration
  21906. This is the configuration for the @code{ganeti-noded} service.
  21907. @table @asis
  21908. @item @code{ganeti} (default: @code{ganeti})
  21909. The @code{ganeti} package to use for this service.
  21910. @item @code{port} (default: @code{1811})
  21911. The TCP port on which the node daemon listens for network requests.
  21912. @item @code{address} (default: @code{"0.0.0.0"})
  21913. The network address that the daemon will bind to. The default address means
  21914. bind to all available addresses.
  21915. @item @code{interface} (default: @code{#f})
  21916. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  21917. that the daemon will bind to.
  21918. @item @code{max-clients} (default: @code{20})
  21919. This sets a limit on the maximum number of simultaneous client connections
  21920. that the daemon will handle. Connections above this count are accepted, but
  21921. no responses will be sent until enough connections have closed.
  21922. @item @code{ssl?} (default: @code{#t})
  21923. Whether to use SSL/TLS to encrypt network communications. The certificate
  21924. is automatically provisioned by the cluster and can be rotated with
  21925. @command{gnt-cluster renew-crypto}.
  21926. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  21927. This can be used to provide a specific encryption key for TLS communications.
  21928. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  21929. This can be used to provide a specific certificate for TLS communications.
  21930. @item @code{debug?} (default: @code{#f})
  21931. When true, the daemon performs additional logging for debugging purposes.
  21932. Note that this will leak encryption details to the log files, use with caution.
  21933. @end table
  21934. @end deftp
  21935. @defvr {Scheme Variable} ganeti-confd-service-type
  21936. @command{ganeti-confd} answers queries related to the configuration of a
  21937. Ganeti cluster. The purpose of this daemon is to have a highly available
  21938. and fast way to query cluster configuration values. It is automatically
  21939. active on all @dfn{master candidates}. The value of this service must be a
  21940. @code{ganeti-confd-configuration} object.
  21941. @end defvr
  21942. @deftp {Data Type} ganeti-confd-configuration
  21943. This is the configuration for the @code{ganeti-confd} service.
  21944. @table @asis
  21945. @item @code{ganeti} (default: @code{ganeti})
  21946. The @code{ganeti} package to use for this service.
  21947. @item @code{port} (default: @code{1814})
  21948. The UDP port on which to listen for network requests.
  21949. @item @code{address} (default: @code{"0.0.0.0"})
  21950. Network address that the daemon will bind to.
  21951. @item @code{debug?} (default: @code{#f})
  21952. When true, the daemon performs additional logging for debugging purposes.
  21953. @end table
  21954. @end deftp
  21955. @defvr {Scheme Variable} ganeti-wconfd-service-type
  21956. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  21957. about the cluster configuration and is the only entity that can accept
  21958. changes to it. All jobs that need to modify the configuration will do so
  21959. by sending appropriate requests to this daemon. It only runs on the
  21960. @dfn{master node} and will automatically disable itself on other nodes.
  21961. The value of this service must be a
  21962. @code{ganeti-wconfd-configuration} object.
  21963. @end defvr
  21964. @deftp {Data Type} ganeti-wconfd-configuration
  21965. This is the configuration for the @code{ganeti-wconfd} service.
  21966. @table @asis
  21967. @item @code{ganeti} (default: @code{ganeti})
  21968. The @code{ganeti} package to use for this service.
  21969. @item @code{no-voting?} (default: @code{#f})
  21970. The daemon will refuse to start if the majority of cluster nodes does not
  21971. agree that it is running on the master node. Set to @code{#t} to start
  21972. even if a quorum can not be reached (dangerous, use with caution).
  21973. @item @code{debug?} (default: @code{#f})
  21974. When true, the daemon performs additional logging for debugging purposes.
  21975. @end table
  21976. @end deftp
  21977. @defvr {Scheme Variable} ganeti-luxid-service-type
  21978. @command{ganeti-luxid} is a daemon used to answer queries related to the
  21979. configuration and the current live state of a Ganeti cluster. Additionally,
  21980. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  21981. submitted via this daemon and it schedules and starts them.
  21982. It takes a @code{ganeti-luxid-configuration} object.
  21983. @end defvr
  21984. @deftp {Data Type} ganeti-luxid-configuration
  21985. This is the configuration for the @code{ganeti-wconfd} service.
  21986. @table @asis
  21987. @item @code{ganeti} (default: @code{ganeti})
  21988. The @code{ganeti} package to use for this service.
  21989. @item @code{no-voting?} (default: @code{#f})
  21990. The daemon will refuse to start if it cannot verify that the majority of
  21991. cluster nodes believes that it is running on the master node. Set to
  21992. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  21993. @item @code{debug?} (default: @code{#f})
  21994. When true, the daemon performs additional logging for debugging purposes.
  21995. @end table
  21996. @end deftp
  21997. @defvr {Scheme Variable} ganeti-rapi-service-type
  21998. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  21999. the master node and can be used to perform cluster actions programmatically
  22000. via a JSON-based RPC protocol.
  22001. Most query operations are allowed without authentication (unless
  22002. @var{require-authentication?} is set), whereas write operations require
  22003. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  22004. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  22005. API documentation} for more information.
  22006. The value of this service must be a @code{ganeti-rapi-configuration} object.
  22007. @end defvr
  22008. @deftp {Data Type} ganeti-rapi-configuration
  22009. This is the configuration for the @code{ganeti-rapi} service.
  22010. @table @asis
  22011. @item @code{ganeti} (default: @code{ganeti})
  22012. The @code{ganeti} package to use for this service.
  22013. @item @code{require-authentication?} (default: @code{#f})
  22014. Whether to require authentication even for read-only operations.
  22015. @item @code{port} (default: @code{5080})
  22016. The TCP port on which to listen to API requests.
  22017. @item @code{address} (default: @code{"0.0.0.0"})
  22018. The network address that the service will bind to. By default it listens
  22019. on all configured addresses.
  22020. @item @code{interface} (default: @code{#f})
  22021. When set, it must specify a specific network interface such as @code{eth0}
  22022. that the daemon will bind to.
  22023. @item @code{max-clients} (default: @code{20})
  22024. The maximum number of simultaneous client requests to handle. Further
  22025. connections are allowed, but no responses are sent until enough connections
  22026. have closed.
  22027. @item @code{ssl?} (default: @code{#t})
  22028. Whether to use SSL/TLS encryption on the RAPI port.
  22029. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  22030. This can be used to provide a specific encryption key for TLS communications.
  22031. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  22032. This can be used to provide a specific certificate for TLS communications.
  22033. @item @code{debug?} (default: @code{#f})
  22034. When true, the daemon performs additional logging for debugging purposes.
  22035. Note that this will leak encryption details to the log files, use with caution.
  22036. @end table
  22037. @end deftp
  22038. @defvr {Scheme Variable} ganeti-kvmd-service-type
  22039. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  22040. instance was shut down by an administrator or a user. Normally Ganeti will
  22041. restart an instance that was not stopped through Ganeti itself. If the
  22042. cluster option @code{user_shutdown} is true, this daemon monitors the
  22043. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  22044. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  22045. it shuts down gracefully by itself.
  22046. It takes a @code{ganeti-kvmd-configuration} object.
  22047. @end defvr
  22048. @deftp {Data Type} ganeti-kvmd-configuration
  22049. @table @asis
  22050. @item @code{ganeti} (default: @code{ganeti})
  22051. The @code{ganeti} package to use for this service.
  22052. @item @code{debug?} (default: @code{#f})
  22053. When true, the daemon performs additional logging for debugging purposes.
  22054. @end table
  22055. @end deftp
  22056. @defvr {Scheme Variable} ganeti-mond-service-type
  22057. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  22058. functionality. It is responsible for running data collectors and publish the
  22059. collected information through a HTTP interface.
  22060. It takes a @code{ganeti-mond-configuration} object.
  22061. @end defvr
  22062. @deftp {Data Type} ganeti-mond-configuration
  22063. @table @asis
  22064. @item @code{ganeti} (default: @code{ganeti})
  22065. The @code{ganeti} package to use for this service.
  22066. @item @code{port} (default: @code{1815})
  22067. The port on which the daemon will listen.
  22068. @item @code{address} (default: @code{"0.0.0.0"})
  22069. The network address that the daemon will bind to. By default it binds to all
  22070. available interfaces.
  22071. @item @code{debug?} (default: @code{#f})
  22072. When true, the daemon performs additional logging for debugging purposes.
  22073. @end table
  22074. @end deftp
  22075. @defvr {Scheme Variable} ganeti-metad-service-type
  22076. @command{ganeti-metad} is an optional daemon that can be used to provide
  22077. information about the cluster to instances or OS install scripts.
  22078. It takes a @code{ganeti-metad-configuration} object.
  22079. @end defvr
  22080. @deftp {Data Type} ganeti-metad-configuration
  22081. @table @asis
  22082. @item @code{ganeti} (default: @code{ganeti})
  22083. The @code{ganeti} package to use for this service.
  22084. @item @code{port} (default: @code{80})
  22085. The port on which the daemon will listen.
  22086. @item @code{address} (default: @code{#f})
  22087. If set, the daemon will bind to this address only. If left unset, the behavior
  22088. depends on the cluster configuration.
  22089. @item @code{debug?} (default: @code{#f})
  22090. When true, the daemon performs additional logging for debugging purposes.
  22091. @end table
  22092. @end deftp
  22093. @defvr {Scheme Variable} ganeti-watcher-service-type
  22094. @command{ganeti-watcher} is a script designed to run periodically and ensure
  22095. the health of a cluster. It will automatically restart instances that have
  22096. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  22097. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  22098. that are not running. If the cluster parameter @code{ensure_node_health}
  22099. is set, the watcher will also shutdown instances and DRBD devices if the
  22100. node it is running on is declared offline by known master candidates.
  22101. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  22102. The service takes a @code{ganeti-watcher-configuration} object.
  22103. @end defvr
  22104. @deftp {Data Type} ganeti-watcher-configuration
  22105. @table @asis
  22106. @item @code{ganeti} (default: @code{ganeti})
  22107. The @code{ganeti} package to use for this service.
  22108. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  22109. How often to run the script. The default is every five minutes.
  22110. @item @code{rapi-ip} (default: @code{#f})
  22111. This option needs to be specified only if the RAPI daemon is configured to use
  22112. a particular interface or address. By default the cluster address is used.
  22113. @item @code{job-age} (default: @code{(* 6 3600)})
  22114. Archive cluster jobs older than this age, specified in seconds. The default
  22115. is 6 hours. This keeps @command{gnt-job list} manageable.
  22116. @item @code{verify-disks?} (default: @code{#t})
  22117. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  22118. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  22119. manually instead.
  22120. @item @code{debug?} (default: @code{#f})
  22121. When @code{#t}, the script performs additional logging for debugging purposes.
  22122. @end table
  22123. @end deftp
  22124. @defvr {Scheme Variable} ganeti-cleaner-service-type
  22125. @command{ganeti-cleaner} is a script designed to run periodically and remove
  22126. old files from the cluster. This service type controls two @dfn{cron jobs}:
  22127. one intended for the master node that permanently purges old cluster jobs,
  22128. and one intended for every node that removes expired X509 certificates, keys,
  22129. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  22130. it is safe to include even on non-master nodes as it will disable itself as
  22131. necessary.
  22132. It takes a @code{ganeti-cleaner-configuration} object.
  22133. @end defvr
  22134. @deftp {Data Type} ganeti-cleaner-configuration
  22135. @table @asis
  22136. @item @code{ganeti} (default: @code{ganeti})
  22137. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  22138. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  22139. How often to run the master cleaning job. The default is once per day, at
  22140. 01:45:00.
  22141. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  22142. How often to run the node cleaning job. The default is once per day, at
  22143. 02:45:00.
  22144. @end table
  22145. @end deftp
  22146. @node Version Control Services
  22147. @subsection Version Control Services
  22148. The @code{(gnu services version-control)} module provides a service to
  22149. allow remote access to local Git repositories. There are three options:
  22150. the @code{git-daemon-service}, which provides access to repositories via
  22151. the @code{git://} unsecured TCP-based protocol, extending the
  22152. @code{nginx} web server to proxy some requests to
  22153. @code{git-http-backend}, or providing a web interface with
  22154. @code{cgit-service-type}.
  22155. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  22156. Return a service that runs @command{git daemon}, a simple TCP server to
  22157. expose repositories over the Git protocol for anonymous access.
  22158. The optional @var{config} argument should be a
  22159. @code{<git-daemon-configuration>} object, by default it allows read-only
  22160. access to exported@footnote{By creating the magic file
  22161. @file{git-daemon-export-ok} in the repository directory.} repositories under
  22162. @file{/srv/git}.
  22163. @end deffn
  22164. @deftp {Data Type} git-daemon-configuration
  22165. Data type representing the configuration for @code{git-daemon-service}.
  22166. @table @asis
  22167. @item @code{package} (default: @code{git})
  22168. Package object of the Git distributed version control system.
  22169. @item @code{export-all?} (default: @code{#f})
  22170. Whether to allow access for all Git repositories, even if they do not
  22171. have the @file{git-daemon-export-ok} file.
  22172. @item @code{base-path} (default: @file{/srv/git})
  22173. Whether to remap all the path requests as relative to the given path.
  22174. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  22175. @samp{example.com}, then if you later try to pull
  22176. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  22177. path as @file{/srv/git/hello.git}.
  22178. @item @code{user-path} (default: @code{#f})
  22179. Whether to allow @code{~user} notation to be used in requests. When
  22180. specified with empty string, requests to
  22181. @indicateurl{git://host/~alice/foo} is taken as a request to access
  22182. @code{foo} repository in the home directory of user @code{alice}. If
  22183. @code{(user-path "@var{path}")} is specified, the same request is taken
  22184. as a request to access @file{@var{path}/foo} repository in the home
  22185. directory of user @code{alice}.
  22186. @item @code{listen} (default: @code{'()})
  22187. Whether to listen on specific IP addresses or hostnames, defaults to
  22188. all.
  22189. @item @code{port} (default: @code{#f})
  22190. Whether to listen on an alternative port, which defaults to 9418.
  22191. @item @code{whitelist} (default: @code{'()})
  22192. If not empty, only allow access to this list of directories.
  22193. @item @code{extra-options} (default: @code{'()})
  22194. Extra options will be passed to @command{git daemon}, please run
  22195. @command{man git-daemon} for more information.
  22196. @end table
  22197. @end deftp
  22198. The @code{git://} protocol lacks authentication. When you pull from a
  22199. repository fetched via @code{git://}, you don't know whether the data you
  22200. receive was modified or is even coming from the specified host, and your
  22201. connection is subject to eavesdropping. It's better to use an authenticated
  22202. and encrypted transport, such as @code{https}. Although Git allows you
  22203. to serve repositories using unsophisticated file-based web servers,
  22204. there is a faster protocol implemented by the @code{git-http-backend}
  22205. program. This program is the back-end of a proper Git web service. It
  22206. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  22207. on running the necessary @code{fcgiwrap} daemon.
  22208. Guix has a separate configuration data type for serving Git repositories
  22209. over HTTP.
  22210. @deftp {Data Type} git-http-configuration
  22211. Data type representing the configuration for a future
  22212. @code{git-http-service-type}; can currently be used to configure Nginx
  22213. through @code{git-http-nginx-location-configuration}.
  22214. @table @asis
  22215. @item @code{package} (default: @var{git})
  22216. Package object of the Git distributed version control system.
  22217. @item @code{git-root} (default: @file{/srv/git})
  22218. Directory containing the Git repositories to expose to the world.
  22219. @item @code{export-all?} (default: @code{#f})
  22220. Whether to expose access for all Git repositories in @var{git-root},
  22221. even if they do not have the @file{git-daemon-export-ok} file.
  22222. @item @code{uri-path} (default: @samp{/git/})
  22223. Path prefix for Git access. With the default @samp{/git/} prefix, this
  22224. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  22225. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  22226. with this prefix are not passed on to this Git instance.
  22227. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  22228. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  22229. Services}.
  22230. @end table
  22231. @end deftp
  22232. There is no @code{git-http-service-type}, currently; instead you can
  22233. create an @code{nginx-location-configuration} from a
  22234. @code{git-http-configuration} and then add that location to a web
  22235. server.
  22236. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  22237. [config=(git-http-configuration)]
  22238. Compute an @code{nginx-location-configuration} that corresponds to the
  22239. given Git http configuration. An example nginx service definition to
  22240. serve the default @file{/srv/git} over HTTPS might be:
  22241. @lisp
  22242. (service nginx-service-type
  22243. (nginx-configuration
  22244. (server-blocks
  22245. (list
  22246. (nginx-server-configuration
  22247. (listen '("443 ssl"))
  22248. (server-name "git.my-host.org")
  22249. (ssl-certificate
  22250. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  22251. (ssl-certificate-key
  22252. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  22253. (locations
  22254. (list
  22255. (git-http-nginx-location-configuration
  22256. (git-http-configuration (uri-path "/"))))))))))
  22257. @end lisp
  22258. This example assumes that you are using Let's Encrypt to get your TLS
  22259. certificate. @xref{Certificate Services}. The default @code{certbot}
  22260. service will redirect all HTTP traffic on @code{git.my-host.org} to
  22261. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  22262. system services. @xref{Web Services}.
  22263. @end deffn
  22264. @subsubheading Cgit Service
  22265. @cindex Cgit service
  22266. @cindex Git, web interface
  22267. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  22268. repositories written in C.
  22269. The following example will configure the service with default values.
  22270. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  22271. @lisp
  22272. (service cgit-service-type)
  22273. @end lisp
  22274. The @code{file-object} type designates either a file-like object
  22275. (@pxref{G-Expressions, file-like objects}) or a string.
  22276. @c %start of fragment
  22277. Available @code{cgit-configuration} fields are:
  22278. @deftypevr {@code{cgit-configuration} parameter} package package
  22279. The CGIT package.
  22280. @end deftypevr
  22281. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  22282. NGINX configuration.
  22283. @end deftypevr
  22284. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  22285. Specifies a command which will be invoked to format the content of about
  22286. pages (both top-level and for each repository).
  22287. Defaults to @samp{""}.
  22288. @end deftypevr
  22289. @deftypevr {@code{cgit-configuration} parameter} string agefile
  22290. Specifies a path, relative to each repository path, which can be used to
  22291. specify the date and time of the youngest commit in the repository.
  22292. Defaults to @samp{""}.
  22293. @end deftypevr
  22294. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  22295. Specifies a command that will be invoked for authenticating repository
  22296. access.
  22297. Defaults to @samp{""}.
  22298. @end deftypevr
  22299. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  22300. Flag which, when set to @samp{age}, enables date ordering in the branch
  22301. ref list, and when set @samp{name} enables ordering by branch name.
  22302. Defaults to @samp{"name"}.
  22303. @end deftypevr
  22304. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  22305. Path used to store the cgit cache entries.
  22306. Defaults to @samp{"/var/cache/cgit"}.
  22307. @end deftypevr
  22308. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  22309. Number which specifies the time-to-live, in minutes, for the cached
  22310. version of repository pages accessed with a fixed SHA1.
  22311. Defaults to @samp{-1}.
  22312. @end deftypevr
  22313. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  22314. Number which specifies the time-to-live, in minutes, for the cached
  22315. version of repository pages accessed without a fixed SHA1.
  22316. Defaults to @samp{5}.
  22317. @end deftypevr
  22318. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  22319. Number which specifies the time-to-live, in minutes, for the cached
  22320. version of the repository summary page.
  22321. Defaults to @samp{5}.
  22322. @end deftypevr
  22323. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  22324. Number which specifies the time-to-live, in minutes, for the cached
  22325. version of the repository index page.
  22326. Defaults to @samp{5}.
  22327. @end deftypevr
  22328. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  22329. Number which specifies the time-to-live, in minutes, for the result of
  22330. scanning a path for Git repositories.
  22331. Defaults to @samp{15}.
  22332. @end deftypevr
  22333. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  22334. Number which specifies the time-to-live, in minutes, for the cached
  22335. version of the repository about page.
  22336. Defaults to @samp{15}.
  22337. @end deftypevr
  22338. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  22339. Number which specifies the time-to-live, in minutes, for the cached
  22340. version of snapshots.
  22341. Defaults to @samp{5}.
  22342. @end deftypevr
  22343. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  22344. The maximum number of entries in the cgit cache. When set to @samp{0},
  22345. caching is disabled.
  22346. Defaults to @samp{0}.
  22347. @end deftypevr
  22348. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  22349. Sort items in the repo list case sensitively.
  22350. Defaults to @samp{#t}.
  22351. @end deftypevr
  22352. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  22353. List of common prefixes which, when combined with a repository URL,
  22354. generates valid clone URLs for the repository.
  22355. Defaults to @samp{()}.
  22356. @end deftypevr
  22357. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  22358. List of @code{clone-url} templates.
  22359. Defaults to @samp{()}.
  22360. @end deftypevr
  22361. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  22362. Command which will be invoked to format commit messages.
  22363. Defaults to @samp{""}.
  22364. @end deftypevr
  22365. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  22366. Flag which, when set to @samp{date}, enables strict date ordering in the
  22367. commit log, and when set to @samp{topo} enables strict topological
  22368. ordering.
  22369. Defaults to @samp{"git log"}.
  22370. @end deftypevr
  22371. @deftypevr {@code{cgit-configuration} parameter} file-object css
  22372. URL which specifies the css document to include in all cgit pages.
  22373. Defaults to @samp{"/share/cgit/cgit.css"}.
  22374. @end deftypevr
  22375. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  22376. Specifies a command which will be invoked to format names and email
  22377. address of committers, authors, and taggers, as represented in various
  22378. places throughout the cgit interface.
  22379. Defaults to @samp{""}.
  22380. @end deftypevr
  22381. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  22382. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  22383. fragment suitable for embedding in other HTML pages.
  22384. Defaults to @samp{#f}.
  22385. @end deftypevr
  22386. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  22387. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  22388. commit history graph to the left of the commit messages in the
  22389. repository log page.
  22390. Defaults to @samp{#f}.
  22391. @end deftypevr
  22392. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  22393. Flag which, when set to @samp{#t}, allows all filter settings to be
  22394. overridden in repository-specific cgitrc files.
  22395. Defaults to @samp{#f}.
  22396. @end deftypevr
  22397. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  22398. Flag which, when set to @samp{#t}, allows users to follow a file in the
  22399. log view.
  22400. Defaults to @samp{#f}.
  22401. @end deftypevr
  22402. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  22403. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  22404. clones.
  22405. Defaults to @samp{#t}.
  22406. @end deftypevr
  22407. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  22408. Flag which, when set to @samp{#t}, will make cgit generate extra links
  22409. "summary", "commit", "tree" for each repo in the repository index.
  22410. Defaults to @samp{#f}.
  22411. @end deftypevr
  22412. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  22413. Flag which, when set to @samp{#t}, will make cgit display the owner of
  22414. each repo in the repository index.
  22415. Defaults to @samp{#t}.
  22416. @end deftypevr
  22417. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  22418. Flag which, when set to @samp{#t}, will make cgit print the number of
  22419. modified files for each commit on the repository log page.
  22420. Defaults to @samp{#f}.
  22421. @end deftypevr
  22422. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  22423. Flag which, when set to @samp{#t}, will make cgit print the number of
  22424. added and removed lines for each commit on the repository log page.
  22425. Defaults to @samp{#f}.
  22426. @end deftypevr
  22427. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  22428. Flag which, when set to @code{#t}, will make cgit display remote
  22429. branches in the summary and refs views.
  22430. Defaults to @samp{#f}.
  22431. @end deftypevr
  22432. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  22433. Flag which, when set to @code{1}, will make cgit use the subject of the
  22434. parent commit as link text when generating links to parent commits in
  22435. commit view.
  22436. Defaults to @samp{#f}.
  22437. @end deftypevr
  22438. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  22439. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  22440. parent commit as link text when generating links to parent commits in
  22441. commit view.
  22442. Defaults to @samp{#f}.
  22443. @end deftypevr
  22444. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  22445. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  22446. links for plaintext blobs printed in the tree view.
  22447. Defaults to @samp{#t}.
  22448. @end deftypevr
  22449. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  22450. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  22451. set any repo specific settings.
  22452. Defaults to @samp{#f}.
  22453. @end deftypevr
  22454. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  22455. URL used as link to a shortcut icon for cgit.
  22456. Defaults to @samp{"/favicon.ico"}.
  22457. @end deftypevr
  22458. @deftypevr {@code{cgit-configuration} parameter} string footer
  22459. The content of the file specified with this option will be included
  22460. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  22461. "generated by..."@: message).
  22462. Defaults to @samp{""}.
  22463. @end deftypevr
  22464. @deftypevr {@code{cgit-configuration} parameter} string head-include
  22465. The content of the file specified with this option will be included
  22466. verbatim in the HTML HEAD section on all pages.
  22467. Defaults to @samp{""}.
  22468. @end deftypevr
  22469. @deftypevr {@code{cgit-configuration} parameter} string header
  22470. The content of the file specified with this option will be included
  22471. verbatim at the top of all pages.
  22472. Defaults to @samp{""}.
  22473. @end deftypevr
  22474. @deftypevr {@code{cgit-configuration} parameter} file-object include
  22475. Name of a configfile to include before the rest of the current config-
  22476. file is parsed.
  22477. Defaults to @samp{""}.
  22478. @end deftypevr
  22479. @deftypevr {@code{cgit-configuration} parameter} string index-header
  22480. The content of the file specified with this option will be included
  22481. verbatim above the repository index.
  22482. Defaults to @samp{""}.
  22483. @end deftypevr
  22484. @deftypevr {@code{cgit-configuration} parameter} string index-info
  22485. The content of the file specified with this option will be included
  22486. verbatim below the heading on the repository index page.
  22487. Defaults to @samp{""}.
  22488. @end deftypevr
  22489. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  22490. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  22491. in the servers timezone.
  22492. Defaults to @samp{#f}.
  22493. @end deftypevr
  22494. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  22495. URL which specifies the source of an image which will be used as a logo
  22496. on all cgit pages.
  22497. Defaults to @samp{"/share/cgit/cgit.png"}.
  22498. @end deftypevr
  22499. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  22500. URL loaded when clicking on the cgit logo image.
  22501. Defaults to @samp{""}.
  22502. @end deftypevr
  22503. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  22504. Command which will be invoked to format the Owner column of the main
  22505. page.
  22506. Defaults to @samp{""}.
  22507. @end deftypevr
  22508. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  22509. Number of items to display in atom feeds view.
  22510. Defaults to @samp{10}.
  22511. @end deftypevr
  22512. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  22513. Number of entries to list per page in "log" view.
  22514. Defaults to @samp{50}.
  22515. @end deftypevr
  22516. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  22517. Number of commit message characters to display in "log" view.
  22518. Defaults to @samp{80}.
  22519. @end deftypevr
  22520. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  22521. Specifies the number of entries to list per page on the repository index
  22522. page.
  22523. Defaults to @samp{50}.
  22524. @end deftypevr
  22525. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  22526. Specifies the maximum number of repo description characters to display
  22527. on the repository index page.
  22528. Defaults to @samp{80}.
  22529. @end deftypevr
  22530. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  22531. Specifies the maximum size of a blob to display HTML for in KBytes.
  22532. Defaults to @samp{0}.
  22533. @end deftypevr
  22534. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  22535. Maximum statistics period. Valid values are @samp{week},@samp{month},
  22536. @samp{quarter} and @samp{year}.
  22537. Defaults to @samp{""}.
  22538. @end deftypevr
  22539. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  22540. Mimetype for the specified filename extension.
  22541. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  22542. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  22543. "image/png") (svg "image/svg+xml"))}.
  22544. @end deftypevr
  22545. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  22546. Specifies the file to use for automatic mimetype lookup.
  22547. Defaults to @samp{""}.
  22548. @end deftypevr
  22549. @deftypevr {@code{cgit-configuration} parameter} string module-link
  22550. Text which will be used as the formatstring for a hyperlink when a
  22551. submodule is printed in a directory listing.
  22552. Defaults to @samp{""}.
  22553. @end deftypevr
  22554. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  22555. If set to the value @samp{#t} caching will be disabled.
  22556. Defaults to @samp{#f}.
  22557. @end deftypevr
  22558. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  22559. If set to @samp{#t} showing full author email addresses will be
  22560. disabled.
  22561. Defaults to @samp{#f}.
  22562. @end deftypevr
  22563. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  22564. Flag which, when set to @samp{#t}, will make cgit omit the standard
  22565. header on all pages.
  22566. Defaults to @samp{#f}.
  22567. @end deftypevr
  22568. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  22569. A list of subdirectories inside of @code{repository-directory}, relative
  22570. to it, that should loaded as Git repositories. An empty list means that
  22571. all subdirectories will be loaded.
  22572. Defaults to @samp{()}.
  22573. @end deftypevr
  22574. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  22575. Text which will be used as default value for @code{cgit-repo-readme}.
  22576. Defaults to @samp{""}.
  22577. @end deftypevr
  22578. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  22579. If set to @code{#t} and @code{repository-directory} is enabled, if any
  22580. repositories are found with a suffix of @code{.git}, this suffix will be
  22581. removed for the URL and name.
  22582. Defaults to @samp{#f}.
  22583. @end deftypevr
  22584. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  22585. Maximum number of files to consider when detecting renames.
  22586. Defaults to @samp{-1}.
  22587. @end deftypevr
  22588. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  22589. The way in which repositories in each section are sorted.
  22590. Defaults to @samp{""}.
  22591. @end deftypevr
  22592. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  22593. Text used as content for the @code{robots} meta-tag.
  22594. Defaults to @samp{("noindex" "nofollow")}.
  22595. @end deftypevr
  22596. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  22597. Text printed below the heading on the repository index page.
  22598. Defaults to @samp{"a fast webinterface for the git dscm"}.
  22599. @end deftypevr
  22600. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  22601. The content of the file specified with this option will be included
  22602. verbatim below the ``about'' link on the repository index page.
  22603. Defaults to @samp{""}.
  22604. @end deftypevr
  22605. @deftypevr {@code{cgit-configuration} parameter} string root-title
  22606. Text printed as heading on the repository index page.
  22607. Defaults to @samp{""}.
  22608. @end deftypevr
  22609. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  22610. If set to @samp{#t} and repository-directory is enabled,
  22611. repository-directory will recurse into directories whose name starts
  22612. with a period. Otherwise, repository-directory will stay away from such
  22613. directories, considered as ``hidden''. Note that this does not apply to
  22614. the @file{.git} directory in non-bare repos.
  22615. Defaults to @samp{#f}.
  22616. @end deftypevr
  22617. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  22618. Text which specifies the default set of snapshot formats that cgit
  22619. generates links for.
  22620. Defaults to @samp{()}.
  22621. @end deftypevr
  22622. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  22623. Name of the directory to scan for repositories (represents
  22624. @code{scan-path}).
  22625. Defaults to @samp{"/srv/git"}.
  22626. @end deftypevr
  22627. @deftypevr {@code{cgit-configuration} parameter} string section
  22628. The name of the current repository section - all repositories defined
  22629. after this option will inherit the current section name.
  22630. Defaults to @samp{""}.
  22631. @end deftypevr
  22632. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  22633. Flag which, when set to @samp{1}, will sort the sections on the
  22634. repository listing by name.
  22635. Defaults to @samp{""}.
  22636. @end deftypevr
  22637. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  22638. A number which, if defined prior to repository-directory, specifies how
  22639. many path elements from each repo path to use as a default section name.
  22640. Defaults to @samp{0}.
  22641. @end deftypevr
  22642. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  22643. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  22644. default.
  22645. Defaults to @samp{#f}.
  22646. @end deftypevr
  22647. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  22648. Specifies a command which will be invoked to format plaintext blobs in
  22649. the tree view.
  22650. Defaults to @samp{""}.
  22651. @end deftypevr
  22652. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  22653. Specifies the number of branches to display in the repository ``summary''
  22654. view.
  22655. Defaults to @samp{10}.
  22656. @end deftypevr
  22657. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  22658. Specifies the number of log entries to display in the repository
  22659. ``summary'' view.
  22660. Defaults to @samp{10}.
  22661. @end deftypevr
  22662. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  22663. Specifies the number of tags to display in the repository ``summary''
  22664. view.
  22665. Defaults to @samp{10}.
  22666. @end deftypevr
  22667. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  22668. Filename which, if specified, needs to be present within the repository
  22669. for cgit to allow access to that repository.
  22670. Defaults to @samp{""}.
  22671. @end deftypevr
  22672. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  22673. URL which, if specified, will be used as root for all cgit links.
  22674. Defaults to @samp{"/"}.
  22675. @end deftypevr
  22676. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  22677. A list of @dfn{cgit-repo} records to use with config.
  22678. Defaults to @samp{()}.
  22679. Available @code{repository-cgit-configuration} fields are:
  22680. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  22681. A mask of snapshot formats for this repo that cgit generates links for,
  22682. restricted by the global @code{snapshots} setting.
  22683. Defaults to @samp{()}.
  22684. @end deftypevr
  22685. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  22686. Override the default @code{source-filter}.
  22687. Defaults to @samp{""}.
  22688. @end deftypevr
  22689. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  22690. The relative URL used to access the repository.
  22691. Defaults to @samp{""}.
  22692. @end deftypevr
  22693. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  22694. Override the default @code{about-filter}.
  22695. Defaults to @samp{""}.
  22696. @end deftypevr
  22697. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  22698. Flag which, when set to @samp{age}, enables date ordering in the branch
  22699. ref list, and when set to @samp{name} enables ordering by branch name.
  22700. Defaults to @samp{""}.
  22701. @end deftypevr
  22702. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  22703. A list of URLs which can be used to clone repo.
  22704. Defaults to @samp{()}.
  22705. @end deftypevr
  22706. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  22707. Override the default @code{commit-filter}.
  22708. Defaults to @samp{""}.
  22709. @end deftypevr
  22710. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  22711. Flag which, when set to @samp{date}, enables strict date ordering in the
  22712. commit log, and when set to @samp{topo} enables strict topological
  22713. ordering.
  22714. Defaults to @samp{""}.
  22715. @end deftypevr
  22716. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  22717. The name of the default branch for this repository. If no such branch
  22718. exists in the repository, the first branch name (when sorted) is used as
  22719. default instead. By default branch pointed to by HEAD, or ``master'' if
  22720. there is no suitable HEAD.
  22721. Defaults to @samp{""}.
  22722. @end deftypevr
  22723. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  22724. The value to show as repository description.
  22725. Defaults to @samp{""}.
  22726. @end deftypevr
  22727. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  22728. The value to show as repository homepage.
  22729. Defaults to @samp{""}.
  22730. @end deftypevr
  22731. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  22732. Override the default @code{email-filter}.
  22733. Defaults to @samp{""}.
  22734. @end deftypevr
  22735. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  22736. A flag which can be used to disable the global setting
  22737. @code{enable-commit-graph?}.
  22738. Defaults to @samp{disabled}.
  22739. @end deftypevr
  22740. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  22741. A flag which can be used to disable the global setting
  22742. @code{enable-log-filecount?}.
  22743. Defaults to @samp{disabled}.
  22744. @end deftypevr
  22745. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  22746. A flag which can be used to disable the global setting
  22747. @code{enable-log-linecount?}.
  22748. Defaults to @samp{disabled}.
  22749. @end deftypevr
  22750. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  22751. Flag which, when set to @code{#t}, will make cgit display remote
  22752. branches in the summary and refs views.
  22753. Defaults to @samp{disabled}.
  22754. @end deftypevr
  22755. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  22756. A flag which can be used to override the global setting
  22757. @code{enable-subject-links?}.
  22758. Defaults to @samp{disabled}.
  22759. @end deftypevr
  22760. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  22761. A flag which can be used to override the global setting
  22762. @code{enable-html-serving?}.
  22763. Defaults to @samp{disabled}.
  22764. @end deftypevr
  22765. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  22766. Flag which, when set to @code{#t}, hides the repository from the
  22767. repository index.
  22768. Defaults to @samp{#f}.
  22769. @end deftypevr
  22770. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  22771. Flag which, when set to @samp{#t}, ignores the repository.
  22772. Defaults to @samp{#f}.
  22773. @end deftypevr
  22774. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  22775. URL which specifies the source of an image which will be used as a logo
  22776. on this repo’s pages.
  22777. Defaults to @samp{""}.
  22778. @end deftypevr
  22779. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  22780. URL loaded when clicking on the cgit logo image.
  22781. Defaults to @samp{""}.
  22782. @end deftypevr
  22783. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  22784. Override the default @code{owner-filter}.
  22785. Defaults to @samp{""}.
  22786. @end deftypevr
  22787. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  22788. Text which will be used as the formatstring for a hyperlink when a
  22789. submodule is printed in a directory listing. The arguments for the
  22790. formatstring are the path and SHA1 of the submodule commit.
  22791. Defaults to @samp{""}.
  22792. @end deftypevr
  22793. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  22794. Text which will be used as the formatstring for a hyperlink when a
  22795. submodule with the specified subdirectory path is printed in a directory
  22796. listing.
  22797. Defaults to @samp{()}.
  22798. @end deftypevr
  22799. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  22800. Override the default maximum statistics period.
  22801. Defaults to @samp{""}.
  22802. @end deftypevr
  22803. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  22804. The value to show as repository name.
  22805. Defaults to @samp{""}.
  22806. @end deftypevr
  22807. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  22808. A value used to identify the owner of the repository.
  22809. Defaults to @samp{""}.
  22810. @end deftypevr
  22811. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  22812. An absolute path to the repository directory.
  22813. Defaults to @samp{""}.
  22814. @end deftypevr
  22815. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  22816. A path (relative to repo) which specifies a file to include verbatim as
  22817. the ``About'' page for this repo.
  22818. Defaults to @samp{""}.
  22819. @end deftypevr
  22820. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  22821. The name of the current repository section - all repositories defined
  22822. after this option will inherit the current section name.
  22823. Defaults to @samp{""}.
  22824. @end deftypevr
  22825. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  22826. Extra options will be appended to cgitrc file.
  22827. Defaults to @samp{()}.
  22828. @end deftypevr
  22829. @end deftypevr
  22830. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  22831. Extra options will be appended to cgitrc file.
  22832. Defaults to @samp{()}.
  22833. @end deftypevr
  22834. @c %end of fragment
  22835. However, it could be that you just want to get a @code{cgitrc} up and
  22836. running. In that case, you can pass an @code{opaque-cgit-configuration}
  22837. as a record to @code{cgit-service-type}. As its name indicates, an
  22838. opaque configuration does not have easy reflective capabilities.
  22839. Available @code{opaque-cgit-configuration} fields are:
  22840. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  22841. The cgit package.
  22842. @end deftypevr
  22843. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  22844. The contents of the @code{cgitrc}, as a string.
  22845. @end deftypevr
  22846. For example, if your @code{cgitrc} is just the empty string, you
  22847. could instantiate a cgit service like this:
  22848. @lisp
  22849. (service cgit-service-type
  22850. (opaque-cgit-configuration
  22851. (cgitrc "")))
  22852. @end lisp
  22853. @subsubheading Gitolite Service
  22854. @cindex Gitolite service
  22855. @cindex Git, hosting
  22856. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  22857. repositories on a central server.
  22858. Gitolite can handle multiple repositories and users, and supports flexible
  22859. configuration of the permissions for the users on the repositories.
  22860. The following example will configure Gitolite using the default @code{git}
  22861. user, and the provided SSH public key.
  22862. @lisp
  22863. (service gitolite-service-type
  22864. (gitolite-configuration
  22865. (admin-pubkey (plain-file
  22866. "yourname.pub"
  22867. "ssh-rsa AAAA... guix@@example.com"))))
  22868. @end lisp
  22869. Gitolite is configured through a special admin repository which you can clone,
  22870. for example, if you setup Gitolite on @code{example.com}, you would run the
  22871. following command to clone the admin repository.
  22872. @example
  22873. git clone git@@example.com:gitolite-admin
  22874. @end example
  22875. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  22876. be inserted in to the @file{keydir} directory in the gitolite-admin
  22877. repository. If this results in a change in the repository, it will be
  22878. committed using the message ``gitolite setup by GNU Guix''.
  22879. @deftp {Data Type} gitolite-configuration
  22880. Data type representing the configuration for @code{gitolite-service-type}.
  22881. @table @asis
  22882. @item @code{package} (default: @var{gitolite})
  22883. Gitolite package to use.
  22884. @item @code{user} (default: @var{git})
  22885. User to use for Gitolite. This will be user that you use when accessing
  22886. Gitolite over SSH.
  22887. @item @code{group} (default: @var{git})
  22888. Group to use for Gitolite.
  22889. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  22890. Directory in which to store the Gitolite configuration and repositories.
  22891. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  22892. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  22893. representing the configuration for Gitolite.
  22894. @item @code{admin-pubkey} (default: @var{#f})
  22895. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  22896. setup Gitolite. This will be inserted in to the @file{keydir} directory
  22897. within the gitolite-admin repository.
  22898. To specify the SSH key as a string, use the @code{plain-file} function.
  22899. @lisp
  22900. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  22901. @end lisp
  22902. @end table
  22903. @end deftp
  22904. @deftp {Data Type} gitolite-rc-file
  22905. Data type representing the Gitolite RC file.
  22906. @table @asis
  22907. @item @code{umask} (default: @code{#o0077})
  22908. This controls the permissions Gitolite sets on the repositories and their
  22909. contents.
  22910. A value like @code{#o0027} will give read access to the group used by Gitolite
  22911. (by default: @code{git}). This is necessary when using Gitolite with software
  22912. like cgit or gitweb.
  22913. @item @code{git-config-keys} (default: @code{""})
  22914. Gitolite allows you to set git config values using the @samp{config}
  22915. keyword. This setting allows control over the config keys to accept.
  22916. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  22917. Set the role names allowed to be used by users running the perms command.
  22918. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  22919. This setting controls the commands and features to enable within Gitolite.
  22920. @end table
  22921. @end deftp
  22922. @node Game Services
  22923. @subsection Game Services
  22924. @subsubheading The Battle for Wesnoth Service
  22925. @cindex wesnothd
  22926. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  22927. based tactical strategy game, with several single player campaigns, and
  22928. multiplayer games (both networked and local).
  22929. @defvar {Scheme Variable} wesnothd-service-type
  22930. Service type for the wesnothd service. Its value must be a
  22931. @code{wesnothd-configuration} object. To run wesnothd in the default
  22932. configuration, instantiate it as:
  22933. @lisp
  22934. (service wesnothd-service-type)
  22935. @end lisp
  22936. @end defvar
  22937. @deftp {Data Type} wesnothd-configuration
  22938. Data type representing the configuration of @command{wesnothd}.
  22939. @table @asis
  22940. @item @code{package} (default: @code{wesnoth-server})
  22941. The wesnoth server package to use.
  22942. @item @code{port} (default: @code{15000})
  22943. The port to bind the server to.
  22944. @end table
  22945. @end deftp
  22946. @node PAM Mount Service
  22947. @subsection PAM Mount Service
  22948. @cindex pam-mount
  22949. The @code{(gnu services pam-mount)} module provides a service allowing
  22950. users to mount volumes when they log in. It should be able to mount any
  22951. volume format supported by the system.
  22952. @defvar {Scheme Variable} pam-mount-service-type
  22953. Service type for PAM Mount support.
  22954. @end defvar
  22955. @deftp {Data Type} pam-mount-configuration
  22956. Data type representing the configuration of PAM Mount.
  22957. It takes the following parameters:
  22958. @table @asis
  22959. @item @code{rules}
  22960. The configuration rules that will be used to generate
  22961. @file{/etc/security/pam_mount.conf.xml}.
  22962. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  22963. Guile Reference Manual}), and the default ones don't mount anything for
  22964. anyone at login:
  22965. @lisp
  22966. `((debug (@@ (enable "0")))
  22967. (mntoptions (@@ (allow ,(string-join
  22968. '("nosuid" "nodev" "loop"
  22969. "encryption" "fsck" "nonempty"
  22970. "allow_root" "allow_other")
  22971. ","))))
  22972. (mntoptions (@@ (require "nosuid,nodev")))
  22973. (logout (@@ (wait "0")
  22974. (hup "0")
  22975. (term "no")
  22976. (kill "no")))
  22977. (mkmountpoint (@@ (enable "1")
  22978. (remove "true"))))
  22979. @end lisp
  22980. Some @code{volume} elements must be added to automatically mount volumes
  22981. at login. Here's an example allowing the user @code{alice} to mount her
  22982. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  22983. the partition where he stores his data:
  22984. @lisp
  22985. (define pam-mount-rules
  22986. `((debug (@@ (enable "0")))
  22987. (volume (@@ (user "alice")
  22988. (fstype "crypt")
  22989. (path "/dev/sda2")
  22990. (mountpoint "/home/alice")))
  22991. (volume (@@ (user "bob")
  22992. (fstype "auto")
  22993. (path "/dev/sdb3")
  22994. (mountpoint "/home/bob/data")
  22995. (options "defaults,autodefrag,compress")))
  22996. (mntoptions (@@ (allow ,(string-join
  22997. '("nosuid" "nodev" "loop"
  22998. "encryption" "fsck" "nonempty"
  22999. "allow_root" "allow_other")
  23000. ","))))
  23001. (mntoptions (@@ (require "nosuid,nodev")))
  23002. (logout (@@ (wait "0")
  23003. (hup "0")
  23004. (term "no")
  23005. (kill "no")))
  23006. (mkmountpoint (@@ (enable "1")
  23007. (remove "true")))))
  23008. (service pam-mount-service-type
  23009. (pam-mount-configuration
  23010. (rules pam-mount-rules)))
  23011. @end lisp
  23012. The complete list of possible options can be found in the man page for
  23013. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  23014. @end table
  23015. @end deftp
  23016. @node Guix Services
  23017. @subsection Guix Services
  23018. @subsubheading Guix Build Coordinator
  23019. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  23020. Coordinator} aids in distributing derivation builds among machines
  23021. running an @dfn{agent}. The build daemon is still used to build the
  23022. derivations, but the Guix Build Coordinator manages allocating builds
  23023. and working with the results.
  23024. @quotation Note
  23025. This service is considered experimental. Configuration options may be
  23026. changed in a backwards-incompatible manner, and not all features have
  23027. been thorougly tested.
  23028. @end quotation
  23029. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  23030. more connected @dfn{agent} processes. The coordinator process handles
  23031. clients submitting builds, and allocating builds to agents. The agent
  23032. processes talk to a build daemon to actually perform the builds, then
  23033. send the results back to the coordinator.
  23034. There is a script to run the coordinator component of the Guix Build
  23035. Coordinator, but the Guix service uses a custom Guile script instead, to
  23036. provide better integration with G-expressions used in the configuration.
  23037. @defvar {Scheme Variable} guix-build-coordinator-service-type
  23038. Service type for the Guix Build Coordinator. Its value must be a
  23039. @code{guix-build-coordinator-configuration} object.
  23040. @end defvar
  23041. @deftp {Data Type} guix-build-coordinator-configuration
  23042. Data type representing the configuration of the Guix Build Coordinator.
  23043. @table @asis
  23044. @item @code{package} (default: @code{guix-build-coordinator})
  23045. The Guix Build Coordinator package to use.
  23046. @item @code{user} (default: @code{"guix-build-coordinator"})
  23047. The system user to run the service as.
  23048. @item @code{group} (default: @code{"guix-build-coordinator"})
  23049. The system group to run the service as.
  23050. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  23051. The URI to use for the database.
  23052. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  23053. The URI describing how to listen to requests from agent processes.
  23054. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  23055. The URI describing how to listen to requests from clients. The client
  23056. API allows submitting builds and currently isn't authenticated, so take
  23057. care when configuring this value.
  23058. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  23059. A G-expression for the allocation strategy to be used. This is a
  23060. procedure that takes the datastore as an argument and populates the
  23061. allocation plan in the database.
  23062. @item @code{hooks} (default: @var{'()})
  23063. An association list of hooks. These provide a way to execute arbitrary
  23064. code upon certain events, like a build result being processed.
  23065. @item @code{guile} (default: @code{guile-3.0-latest})
  23066. The Guile package with which to run the Guix Build Coordinator.
  23067. @end table
  23068. @end deftp
  23069. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  23070. Service type for a Guix Build Coordinator agent. Its value must be a
  23071. @code{guix-build-coordinator-agent-configuration} object.
  23072. @end defvar
  23073. @deftp {Data Type} guix-build-coordinator-agent-configuration
  23074. Data type representing the configuration a Guix Build Coordinator agent.
  23075. @table @asis
  23076. @item @code{package} (default: @code{guix-build-coordinator})
  23077. The Guix Build Coordinator package to use.
  23078. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  23079. The system user to run the service as.
  23080. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  23081. The URI to use when connecting to the coordinator.
  23082. @item @code{uuid}
  23083. The UUID of the agent. This should be generated by the coordinator
  23084. process, stored in the coordinator database, and used by the intended
  23085. agent.
  23086. @item @code{password} (default: @code{#f})
  23087. The password to use when connecting to the coordinator. A file to read
  23088. the password from can also be specified, and this is more secure.
  23089. @item @code{password-file} (default: @code{#f})
  23090. A file containing the password to use when connecting to the
  23091. coordinator.
  23092. @item @code{systems} (default: @code{#f})
  23093. The systems for which this agent should fetch builds. The agent process
  23094. will use the current system it's running on as the default.
  23095. @item @code{max-parallel-builds} (default: @code{1})
  23096. The number of builds to perform in parallel.
  23097. @item @code{derivation-substitute-urls} (default: @code{#f})
  23098. URLs from which to attempt to fetch substitutes for derivations, if the
  23099. derivations aren't already available.
  23100. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  23101. URLs from which to attempt to fetch substitutes for build inputs, if the
  23102. input store items aren't already available.
  23103. @end table
  23104. @end deftp
  23105. The Guix Build Coordinator package contains a script to query an
  23106. instance of the Guix Data Service for derivations to build, and then
  23107. submit builds for those derivations to the coordinator. The service
  23108. type below assists in running this script. This is an additional tool
  23109. that may be useful when building derivations contained within an
  23110. instance of the Guix Data Service.
  23111. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  23112. Service type for the
  23113. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  23114. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  23115. object.
  23116. @end defvar
  23117. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  23118. Data type representing the options to the queue builds from guix data
  23119. service script.
  23120. @table @asis
  23121. @item @code{package} (default: @code{guix-build-coordinator})
  23122. The Guix Build Coordinator package to use.
  23123. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  23124. The system user to run the service as.
  23125. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  23126. The URI to use when connecting to the coordinator.
  23127. @item @code{systems} (default: @code{#f})
  23128. The systems for which to fetch derivations to build.
  23129. @item @code{systems-and-targets} (default: @code{#f})
  23130. An association list of system and target pairs for which to fetch
  23131. derivations to build.
  23132. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  23133. The Guix Data Service instance from which to query to find out about
  23134. derivations to build.
  23135. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  23136. A file to record which commits have been processed, to avoid needlessly
  23137. processing them again if the service is restarted.
  23138. @end table
  23139. @end deftp
  23140. @subsubheading Guix Data Service
  23141. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  23142. and provides data about GNU Guix. This includes information about
  23143. packages, derivations and lint warnings.
  23144. The data is stored in a PostgreSQL database, and available through a web
  23145. interface.
  23146. @defvar {Scheme Variable} guix-data-service-type
  23147. Service type for the Guix Data Service. Its value must be a
  23148. @code{guix-data-service-configuration} object. The service optionally
  23149. extends the getmail service, as the guix-commits mailing list is used to
  23150. find out about changes in the Guix git repository.
  23151. @end defvar
  23152. @deftp {Data Type} guix-data-service-configuration
  23153. Data type representing the configuration of the Guix Data Service.
  23154. @table @asis
  23155. @item @code{package} (default: @code{guix-data-service})
  23156. The Guix Data Service package to use.
  23157. @item @code{user} (default: @code{"guix-data-service"})
  23158. The system user to run the service as.
  23159. @item @code{group} (default: @code{"guix-data-service"})
  23160. The system group to run the service as.
  23161. @item @code{port} (default: @code{8765})
  23162. The port to bind the web service to.
  23163. @item @code{host} (default: @code{"127.0.0.1"})
  23164. The host to bind the web service to.
  23165. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  23166. If set, this is the list of mailboxes that the getmail service will be
  23167. configured to listen to.
  23168. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  23169. If set, this is the @code{getmail-retriever-configuration} object with
  23170. which to configure getmail to fetch mail from the guix-commits mailing
  23171. list.
  23172. @item @code{extra-options} (default: @var{'()})
  23173. Extra command line options for @code{guix-data-service}.
  23174. @item @code{extra-process-jobs-options} (default: @var{'()})
  23175. Extra command line options for @code{guix-data-service-process-jobs}.
  23176. @end table
  23177. @end deftp
  23178. @node Linux Services
  23179. @subsection Linux Services
  23180. @cindex oom
  23181. @cindex out of memory killer
  23182. @cindex earlyoom
  23183. @cindex early out of memory daemon
  23184. @subsubheading Early OOM Service
  23185. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  23186. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  23187. space and provides a more responsive and configurable alternative to the
  23188. in-kernel OOM killer. It is useful to prevent the system from becoming
  23189. unresponsive when it runs out of memory.
  23190. @deffn {Scheme Variable} earlyoom-service-type
  23191. The service type for running @command{earlyoom}, the Early OOM daemon.
  23192. Its value must be a @code{earlyoom-configuration} object, described
  23193. below. The service can be instantiated in its default configuration
  23194. with:
  23195. @lisp
  23196. (service earlyoom-service-type)
  23197. @end lisp
  23198. @end deffn
  23199. @deftp {Data Type} earlyoom-configuration
  23200. This is the configuration record for the @code{earlyoom-service-type}.
  23201. @table @asis
  23202. @item @code{earlyoom} (default: @var{earlyoom})
  23203. The Earlyoom package to use.
  23204. @item @code{minimum-available-memory} (default: @code{10})
  23205. The threshold for the minimum @emph{available} memory, in percentages.
  23206. @item @code{minimum-free-swap} (default: @code{10})
  23207. The threshold for the minimum free swap memory, in percentages.
  23208. @item @code{prefer-regexp} (default: @code{#f})
  23209. A regular expression (as a string) to match the names of the processes
  23210. that should be preferably killed.
  23211. @item @code{avoid-regexp} (default: @code{#f})
  23212. A regular expression (as a string) to match the names of the processes
  23213. that should @emph{not} be killed.
  23214. @item @code{memory-report-interval} (default: @code{0})
  23215. The interval in seconds at which a memory report is printed. It is
  23216. disabled by default.
  23217. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  23218. A boolean indicating whether the positive adjustments set in
  23219. @file{/proc/*/oom_score_adj} should be ignored.
  23220. @item @code{show-debug-messages?} (default: @code{#f})
  23221. A boolean indicating whether debug messages should be printed. The logs
  23222. are saved at @file{/var/log/earlyoom.log}.
  23223. @item @code{send-notification-command} (default: @code{#f})
  23224. This can be used to provide a custom command used for sending
  23225. notifications.
  23226. @end table
  23227. @end deftp
  23228. @cindex modprobe
  23229. @cindex kernel module loader
  23230. @subsubheading Kernel Module Loader Service
  23231. The kernel module loader service allows one to load loadable kernel
  23232. modules at boot. This is especially useful for modules that don't
  23233. autoload and need to be manually loaded, as it's the case with
  23234. @code{ddcci}.
  23235. @deffn {Scheme Variable} kernel-module-loader-service-type
  23236. The service type for loading loadable kernel modules at boot with
  23237. @command{modprobe}. Its value must be a list of strings representing
  23238. module names. For example loading the drivers provided by
  23239. @code{ddcci-driver-linux}, in debugging mode by passing some module
  23240. parameters, can be done as follow:
  23241. @lisp
  23242. (use-modules (gnu) (gnu services))
  23243. (use-package-modules linux)
  23244. (use-service-modules linux)
  23245. (define ddcci-config
  23246. (plain-file "ddcci.conf"
  23247. "options ddcci dyndbg delay=120"))
  23248. (operating-system
  23249. ...
  23250. (services (cons* (service kernel-module-loader-service-type
  23251. '("ddcci" "ddcci_backlight"))
  23252. (simple-service 'ddcci-config etc-service-type
  23253. (list `("modprobe.d/ddcci.conf"
  23254. ,ddcci-config)))
  23255. %base-services))
  23256. (kernel-loadable-modules (list ddcci-driver-linux)))
  23257. @end lisp
  23258. @end deffn
  23259. @cindex zram
  23260. @cindex compressed swap
  23261. @cindex Compressed RAM-based block devices
  23262. @subsubheading Zram Device Service
  23263. The Zram device service provides a compressed swap device in system
  23264. memory. The Linux Kernel documentation has more information about
  23265. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  23266. devices.
  23267. @deffn {Scheme Variable} zram-device-service-type
  23268. This service creates the zram block device, formats it as swap and
  23269. enables it as a swap device. The service's value is a
  23270. @code{zram-device-configuration} record.
  23271. @deftp {Data Type} zram-device-configuration
  23272. This is the data type representing the configuration for the zram-device
  23273. service.
  23274. @table @asis
  23275. @item @code{size} (default @code{"1G"})
  23276. This is the amount of space you wish to provide for the zram device. It
  23277. accepts a string and can be a number of bytes or use a suffix, eg.:
  23278. @code{"512M"} or @code{1024000}.
  23279. @item @code{compression-algorithm} (default @code{'lzo})
  23280. This is the compression algorithm you wish to use. It is difficult to
  23281. list all the possible compression options, but common ones supported by
  23282. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  23283. @item @code{memory-limit} (default @code{0})
  23284. This is the maximum amount of memory which the zram device can use.
  23285. Setting it to '0' disables the limit. While it is generally expected
  23286. that compression will be 2:1, it is possible that uncompressable data
  23287. can be written to swap and this is a method to limit how much memory can
  23288. be used. It accepts a string and can be a number of bytes or use a
  23289. suffix, eg.: @code{"2G"}.
  23290. @item @code{priority} (default @code{-1})
  23291. This is the priority of the swap device created from the zram device.
  23292. @code{swapon} accepts values between -1 and 32767, with higher values
  23293. indicating higher priority. Higher priority swap will generally be used
  23294. first.
  23295. @end table
  23296. @end deftp
  23297. @end deffn
  23298. @node Hurd Services
  23299. @subsection Hurd Services
  23300. @defvr {Scheme Variable} hurd-console-service-type
  23301. This service starts the fancy @code{VGA} console client on the Hurd.
  23302. The service's value is a @code{hurd-console-configuration} record.
  23303. @end defvr
  23304. @deftp {Data Type} hurd-console-configuration
  23305. This is the data type representing the configuration for the
  23306. hurd-console-service.
  23307. @table @asis
  23308. @item @code{hurd} (default: @var{hurd})
  23309. The Hurd package to use.
  23310. @end table
  23311. @end deftp
  23312. @defvr {Scheme Variable} hurd-getty-service-type
  23313. This service starts a tty using the Hurd @code{getty} program.
  23314. The service's value is a @code{hurd-getty-configuration} record.
  23315. @end defvr
  23316. @deftp {Data Type} hurd-getty-configuration
  23317. This is the data type representing the configuration for the
  23318. hurd-getty-service.
  23319. @table @asis
  23320. @item @code{hurd} (default: @var{hurd})
  23321. The Hurd package to use.
  23322. @item @code{tty}
  23323. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  23324. @item @code{baud-rate} (default: @code{38400})
  23325. An integer specifying the baud rate of the tty.
  23326. @end table
  23327. @end deftp
  23328. @node Miscellaneous Services
  23329. @subsection Miscellaneous Services
  23330. @cindex fingerprint
  23331. @subsubheading Fingerprint Service
  23332. The @code{(gnu services authentication)} module provides a DBus service to
  23333. read and identify fingerprints via a fingerprint sensor.
  23334. @defvr {Scheme Variable} fprintd-service-type
  23335. The service type for @command{fprintd}, which provides the fingerprint
  23336. reading capability.
  23337. @lisp
  23338. (service fprintd-service-type)
  23339. @end lisp
  23340. @end defvr
  23341. @cindex sysctl
  23342. @subsubheading System Control Service
  23343. The @code{(gnu services sysctl)} provides a service to configure kernel
  23344. parameters at boot.
  23345. @defvr {Scheme Variable} sysctl-service-type
  23346. The service type for @command{sysctl}, which modifies kernel parameters
  23347. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  23348. instantiated as:
  23349. @lisp
  23350. (service sysctl-service-type
  23351. (sysctl-configuration
  23352. (settings '(("net.ipv4.ip_forward" . "1")))))
  23353. @end lisp
  23354. @end defvr
  23355. @deftp {Data Type} sysctl-configuration
  23356. The data type representing the configuration of @command{sysctl}.
  23357. @table @asis
  23358. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  23359. The @command{sysctl} executable to use.
  23360. @item @code{settings} (default: @code{'()})
  23361. An association list specifies kernel parameters and their values.
  23362. @end table
  23363. @end deftp
  23364. @cindex pcscd
  23365. @subsubheading PC/SC Smart Card Daemon Service
  23366. The @code{(gnu services security-token)} module provides the following service
  23367. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  23368. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  23369. manager that coordinates communications with smart card readers, smart cards
  23370. and cryptographic tokens that are connected to the system.
  23371. @defvr {Scheme Variable} pcscd-service-type
  23372. Service type for the @command{pcscd} service. Its value must be a
  23373. @code{pcscd-configuration} object. To run pcscd in the default
  23374. configuration, instantiate it as:
  23375. @lisp
  23376. (service pcscd-service-type)
  23377. @end lisp
  23378. @end defvr
  23379. @deftp {Data Type} pcscd-configuration
  23380. The data type representing the configuration of @command{pcscd}.
  23381. @table @asis
  23382. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  23383. The pcsc-lite package that provides pcscd.
  23384. @item @code{usb-drivers} (default: @code{(list ccid)})
  23385. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  23386. under @file{pcsc/drivers} in the store directory of the package.
  23387. @end table
  23388. @end deftp
  23389. @cindex lirc
  23390. @subsubheading Lirc Service
  23391. The @code{(gnu services lirc)} module provides the following service.
  23392. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  23393. [#:device #f] [#:driver #f] [#:config-file #f] @
  23394. [#:extra-options '()]
  23395. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  23396. decodes infrared signals from remote controls.
  23397. Optionally, @var{device}, @var{driver} and @var{config-file}
  23398. (configuration file name) may be specified. See @command{lircd} manual
  23399. for details.
  23400. Finally, @var{extra-options} is a list of additional command-line options
  23401. passed to @command{lircd}.
  23402. @end deffn
  23403. @cindex spice
  23404. @subsubheading Spice Service
  23405. The @code{(gnu services spice)} module provides the following service.
  23406. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  23407. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  23408. that enables sharing the clipboard with a vm and setting the guest display
  23409. resolution when the graphical console window resizes.
  23410. @end deffn
  23411. @cindex inputattach
  23412. @subsubheading inputattach Service
  23413. @cindex tablet input, for Xorg
  23414. @cindex touchscreen input, for Xorg
  23415. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  23416. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  23417. Xorg display server.
  23418. @deffn {Scheme Variable} inputattach-service-type
  23419. Type of a service that runs @command{inputattach} on a device and
  23420. dispatches events from it.
  23421. @end deffn
  23422. @deftp {Data Type} inputattach-configuration
  23423. @table @asis
  23424. @item @code{device-type} (default: @code{"wacom"})
  23425. The type of device to connect to. Run @command{inputattach --help}, from the
  23426. @code{inputattach} package, to see the list of supported device types.
  23427. @item @code{device} (default: @code{"/dev/ttyS0"})
  23428. The device file to connect to the device.
  23429. @item @code{baud-rate} (default: @code{#f})
  23430. Baud rate to use for the serial connection.
  23431. Should be a number or @code{#f}.
  23432. @item @code{log-file} (default: @code{#f})
  23433. If true, this must be the name of a file to log messages to.
  23434. @end table
  23435. @end deftp
  23436. @subsubheading Dictionary Service
  23437. @cindex dictionary
  23438. The @code{(gnu services dict)} module provides the following service:
  23439. @defvr {Scheme Variable} dicod-service-type
  23440. This is the type of the service that runs the @command{dicod} daemon, an
  23441. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  23442. @end defvr
  23443. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  23444. Return a service that runs the @command{dicod} daemon, an implementation
  23445. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  23446. The optional @var{config} argument specifies the configuration for
  23447. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  23448. default it serves the GNU Collaborative International Dictionary of English.
  23449. You can add @command{open localhost} to your @file{~/.dico} file to make
  23450. @code{localhost} the default server for @command{dico} client
  23451. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  23452. @end deffn
  23453. @deftp {Data Type} dicod-configuration
  23454. Data type representing the configuration of dicod.
  23455. @table @asis
  23456. @item @code{dico} (default: @var{dico})
  23457. Package object of the GNU Dico dictionary server.
  23458. @item @code{interfaces} (default: @var{'("localhost")})
  23459. This is the list of IP addresses and ports and possibly socket file
  23460. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  23461. dico, GNU Dico Manual}).
  23462. @item @code{handlers} (default: @var{'()})
  23463. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  23464. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  23465. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  23466. @end table
  23467. @end deftp
  23468. @deftp {Data Type} dicod-handler
  23469. Data type representing a dictionary handler (module instance).
  23470. @table @asis
  23471. @item @code{name}
  23472. Name of the handler (module instance).
  23473. @item @code{module} (default: @var{#f})
  23474. Name of the dicod module of the handler (instance). If it is @code{#f},
  23475. the module has the same name as the handler.
  23476. (@pxref{Modules,,, dico, GNU Dico Manual}).
  23477. @item @code{options}
  23478. List of strings or gexps representing the arguments for the module handler
  23479. @end table
  23480. @end deftp
  23481. @deftp {Data Type} dicod-database
  23482. Data type representing a dictionary database.
  23483. @table @asis
  23484. @item @code{name}
  23485. Name of the database, will be used in DICT commands.
  23486. @item @code{handler}
  23487. Name of the dicod handler (module instance) used by this database
  23488. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  23489. @item @code{complex?} (default: @var{#f})
  23490. Whether the database configuration complex. The complex configuration
  23491. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  23492. @item @code{options}
  23493. List of strings or gexps representing the arguments for the database
  23494. (@pxref{Databases,,, dico, GNU Dico Manual}).
  23495. @end table
  23496. @end deftp
  23497. @defvr {Scheme Variable} %dicod-database:gcide
  23498. A @code{<dicod-database>} object serving the GNU Collaborative International
  23499. Dictionary of English using the @code{gcide} package.
  23500. @end defvr
  23501. The following is an example @code{dicod-service} configuration.
  23502. @lisp
  23503. (dicod-service #:config
  23504. (dicod-configuration
  23505. (handlers (list (dicod-handler
  23506. (name "wordnet")
  23507. (module "dictorg")
  23508. (options
  23509. (list #~(string-append "dbdir=" #$wordnet))))))
  23510. (databases (list (dicod-database
  23511. (name "wordnet")
  23512. (complex? #t)
  23513. (handler "wordnet")
  23514. (options '("database=wn")))
  23515. %dicod-database:gcide))))
  23516. @end lisp
  23517. @cindex Docker
  23518. @subsubheading Docker Service
  23519. The @code{(gnu services docker)} module provides the following services.
  23520. @defvr {Scheme Variable} docker-service-type
  23521. This is the type of the service that runs @url{https://www.docker.com,Docker},
  23522. a daemon that can execute application bundles (sometimes referred to as
  23523. ``containers'') in isolated environments.
  23524. @end defvr
  23525. @deftp {Data Type} docker-configuration
  23526. This is the data type representing the configuration of Docker and Containerd.
  23527. @table @asis
  23528. @item @code{package} (default: @code{docker})
  23529. The Docker daemon package to use.
  23530. @item @code{package} (default: @code{docker-cli})
  23531. The Docker client package to use.
  23532. @item @code{containerd} (default: @var{containerd})
  23533. The Containerd package to use.
  23534. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  23535. The Docker user-land networking proxy package to use.
  23536. @item @code{enable-proxy?} (default @code{#t})
  23537. Enable or disable the use of the Docker user-land networking proxy.
  23538. @item @code{debug?} (default @code{#f})
  23539. Enable or disable debug output.
  23540. @item @code{enable-iptables?} (default @code{#t})
  23541. Enable or disable the addition of iptables rules.
  23542. @end table
  23543. @end deftp
  23544. @cindex Singularity, container service
  23545. @defvr {Scheme Variable} singularity-service-type
  23546. This is the type of the service that allows you to run
  23547. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  23548. create and run application bundles (aka. ``containers''). The value for this
  23549. service is the Singularity package to use.
  23550. The service does not install a daemon; instead, it installs helper programs as
  23551. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  23552. @command{singularity run} and similar commands.
  23553. @end defvr
  23554. @cindex Audit
  23555. @subsubheading Auditd Service
  23556. The @code{(gnu services auditd)} module provides the following service.
  23557. @defvr {Scheme Variable} auditd-service-type
  23558. This is the type of the service that runs
  23559. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  23560. a daemon that tracks security-relevant information on your system.
  23561. Examples of things that can be tracked:
  23562. @enumerate
  23563. @item
  23564. File accesses
  23565. @item
  23566. System calls
  23567. @item
  23568. Invoked commands
  23569. @item
  23570. Failed login attempts
  23571. @item
  23572. Firewall filtering
  23573. @item
  23574. Network access
  23575. @end enumerate
  23576. @command{auditctl} from the @code{audit} package can be used in order
  23577. to add or remove events to be tracked (until the next reboot).
  23578. In order to permanently track events, put the command line arguments
  23579. of auditctl into a file called @code{audit.rules} in the configuration
  23580. directory (see below).
  23581. @command{aureport} from the @code{audit} package can be used in order
  23582. to view a report of all recorded events.
  23583. The audit daemon by default logs into the file
  23584. @file{/var/log/audit.log}.
  23585. @end defvr
  23586. @deftp {Data Type} auditd-configuration
  23587. This is the data type representing the configuration of auditd.
  23588. @table @asis
  23589. @item @code{audit} (default: @code{audit})
  23590. The audit package to use.
  23591. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  23592. The directory containing the configuration file for the audit package, which
  23593. must be named @code{auditd.conf}, and optionally some audit rules to
  23594. instantiate on startup.
  23595. @end table
  23596. @end deftp
  23597. @cindex rshiny
  23598. @subsubheading R-Shiny service
  23599. The @code{(gnu services science)} module provides the following service.
  23600. @defvr {Scheme Variable} rshiny-service-type
  23601. This is a type of service which is used to run a webapp created with
  23602. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  23603. variable and runs the provided script to call @code{runApp}.
  23604. @deftp {Data Type} rshiny-configuration
  23605. This is the data type representing the configuration of rshiny.
  23606. @table @asis
  23607. @item @code{package} (default: @code{r-shiny})
  23608. The package to use.
  23609. @item @code{binary} (defaunlt @code{"rshiny"})
  23610. The name of the binary or shell script located at @code{package/bin/} to
  23611. run when the service is run.
  23612. The common way to create this file is as follows:
  23613. @lisp
  23614. @dots{}
  23615. (let* ((out (assoc-ref %outputs "out"))
  23616. (targetdir (string-append out "/share/" ,name))
  23617. (app (string-append out "/bin/" ,name))
  23618. (Rbin (string-append (assoc-ref %build-inputs "r-min")
  23619. "/bin/Rscript")))
  23620. ;; @dots{}
  23621. (mkdir-p (string-append out "/bin"))
  23622. (call-with-output-file app
  23623. (lambda (port)
  23624. (format port
  23625. "#!~a
  23626. library(shiny)
  23627. setwd(\"~a\")
  23628. runApp(launch.browser=0, port=4202)~%\n"
  23629. Rbin targetdir))))
  23630. @end lisp
  23631. @end table
  23632. @end deftp
  23633. @end defvr
  23634. @cindex Nix
  23635. @subsubheading Nix service
  23636. The @code{(gnu services nix)} module provides the following service.
  23637. @defvr {Scheme Variable} nix-service-type
  23638. This is the type of the service that runs build daemon of the
  23639. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  23640. how to use it:
  23641. @lisp
  23642. (use-modules (gnu))
  23643. (use-service-modules nix)
  23644. (use-package-modules package-management)
  23645. (operating-system
  23646. ;; @dots{}
  23647. (packages (append (list nix)
  23648. %base-packages))
  23649. (services (append (list (service nix-service-type))
  23650. %base-services)))
  23651. @end lisp
  23652. After @command{guix system reconfigure} configure Nix for your user:
  23653. @itemize
  23654. @item Add a Nix channel and update it. See
  23655. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  23656. @item Create a symlink to your profile and activate Nix profile:
  23657. @end itemize
  23658. @example
  23659. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  23660. $ source /run/current-system/profile/etc/profile.d/nix.sh
  23661. @end example
  23662. @end defvr
  23663. @deftp {Data Type} nix-configuration
  23664. This data type represents the configuration of the Nix daemon.
  23665. @table @asis
  23666. @item @code{nix} (default: @code{nix})
  23667. The Nix package to use.
  23668. @item @code{sandbox} (default: @code{#t})
  23669. Specifies whether builds are sandboxed by default.
  23670. @item @code{build-sandbox-items} (default: @code{'()})
  23671. This is a list of strings or objects appended to the
  23672. @code{build-sandbox-items} field of the configuration file.
  23673. @item @code{extra-config} (default: @code{'()})
  23674. This is a list of strings or objects appended to the configuration file.
  23675. It is used to pass extra text to be added verbatim to the configuration
  23676. file.
  23677. @item @code{extra-options} (default: @code{'()})
  23678. Extra command line options for @code{nix-service-type}.
  23679. @end table
  23680. @end deftp
  23681. @node Setuid Programs
  23682. @section Setuid Programs
  23683. @cindex setuid programs
  23684. Some programs need to run with ``root'' privileges, even when they are
  23685. launched by unprivileged users. A notorious example is the
  23686. @command{passwd} program, which users can run to change their
  23687. password, and which needs to access the @file{/etc/passwd} and
  23688. @file{/etc/shadow} files---something normally restricted to root, for
  23689. obvious security reasons. To address that, these executables are
  23690. @dfn{setuid-root}, meaning that they always run with root privileges
  23691. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  23692. for more info about the setuid mechanism).
  23693. The store itself @emph{cannot} contain setuid programs: that would be a
  23694. security issue since any user on the system can write derivations that
  23695. populate the store (@pxref{The Store}). Thus, a different mechanism is
  23696. used: instead of changing the setuid bit directly on files that are in
  23697. the store, we let the system administrator @emph{declare} which programs
  23698. should be setuid root.
  23699. The @code{setuid-programs} field of an @code{operating-system}
  23700. declaration contains a list of G-expressions denoting the names of
  23701. programs to be setuid-root (@pxref{Using the Configuration System}).
  23702. For instance, the @command{passwd} program, which is part of the Shadow
  23703. package, can be designated by this G-expression (@pxref{G-Expressions}):
  23704. @example
  23705. #~(string-append #$shadow "/bin/passwd")
  23706. @end example
  23707. A default set of setuid programs is defined by the
  23708. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  23709. @defvr {Scheme Variable} %setuid-programs
  23710. A list of G-expressions denoting common programs that are setuid-root.
  23711. The list includes commands such as @command{passwd}, @command{ping},
  23712. @command{su}, and @command{sudo}.
  23713. @end defvr
  23714. Under the hood, the actual setuid programs are created in the
  23715. @file{/run/setuid-programs} directory at system activation time. The
  23716. files in this directory refer to the ``real'' binaries, which are in the
  23717. store.
  23718. @node X.509 Certificates
  23719. @section X.509 Certificates
  23720. @cindex HTTPS, certificates
  23721. @cindex X.509 certificates
  23722. @cindex TLS
  23723. Web servers available over HTTPS (that is, HTTP over the transport-layer
  23724. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  23725. that the client can then use to @emph{authenticate} the server. To do
  23726. that, clients verify that the server's certificate is signed by a
  23727. so-called @dfn{certificate authority} (CA). But to verify the CA's
  23728. signature, clients must have first acquired the CA's certificate.
  23729. Web browsers such as GNU@tie{}IceCat include their own set of CA
  23730. certificates, such that they are able to verify CA signatures
  23731. out-of-the-box.
  23732. However, most other programs that can talk HTTPS---@command{wget},
  23733. @command{git}, @command{w3m}, etc.---need to be told where CA
  23734. certificates can be found.
  23735. @cindex @code{nss-certs}
  23736. In Guix, this is done by adding a package that provides certificates
  23737. to the @code{packages} field of the @code{operating-system} declaration
  23738. (@pxref{operating-system Reference}). Guix includes one such package,
  23739. @code{nss-certs}, which is a set of CA certificates provided as part of
  23740. Mozilla's Network Security Services.
  23741. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  23742. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  23743. most applications and libraries look for certificates by default, points
  23744. to the certificates installed globally.
  23745. Unprivileged users, including users of Guix on a foreign distro,
  23746. can also install their own certificate package in
  23747. their profile. A number of environment variables need to be defined so
  23748. that applications and libraries know where to find them. Namely, the
  23749. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  23750. variables. Some applications add their own environment variables; for
  23751. instance, the Git version control system honors the certificate bundle
  23752. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  23753. would typically run something like:
  23754. @example
  23755. guix install nss-certs
  23756. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  23757. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  23758. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  23759. @end example
  23760. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  23761. variable to point to a certificate bundle, so you would have to run
  23762. something like this:
  23763. @example
  23764. guix install nss-certs
  23765. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  23766. @end example
  23767. For other applications you may want to look up the required environment
  23768. variable in the relevant documentation.
  23769. @node Name Service Switch
  23770. @section Name Service Switch
  23771. @cindex name service switch
  23772. @cindex NSS
  23773. The @code{(gnu system nss)} module provides bindings to the
  23774. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  23775. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  23776. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  23777. extended with new ``name'' lookup methods for system databases, which
  23778. includes host names, service names, user accounts, and more (@pxref{Name
  23779. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  23780. C Library Reference Manual}).
  23781. The NSS configuration specifies, for each system database, which lookup
  23782. method is to be used, and how the various methods are chained
  23783. together---for instance, under which circumstances NSS should try the
  23784. next method in the list. The NSS configuration is given in the
  23785. @code{name-service-switch} field of @code{operating-system} declarations
  23786. (@pxref{operating-system Reference, @code{name-service-switch}}).
  23787. @cindex nss-mdns
  23788. @cindex .local, host name lookup
  23789. As an example, the declaration below configures the NSS to use the
  23790. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  23791. back-end}, which supports host name lookups over multicast DNS (mDNS)
  23792. for host names ending in @code{.local}:
  23793. @lisp
  23794. (name-service-switch
  23795. (hosts (list %files ;first, check /etc/hosts
  23796. ;; If the above did not succeed, try
  23797. ;; with 'mdns_minimal'.
  23798. (name-service
  23799. (name "mdns_minimal")
  23800. ;; 'mdns_minimal' is authoritative for
  23801. ;; '.local'. When it returns "not found",
  23802. ;; no need to try the next methods.
  23803. (reaction (lookup-specification
  23804. (not-found => return))))
  23805. ;; Then fall back to DNS.
  23806. (name-service
  23807. (name "dns"))
  23808. ;; Finally, try with the "full" 'mdns'.
  23809. (name-service
  23810. (name "mdns")))))
  23811. @end lisp
  23812. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  23813. contains this configuration, so you will not have to type it if all you
  23814. want is to have @code{.local} host lookup working.
  23815. Note that, in this case, in addition to setting the
  23816. @code{name-service-switch} of the @code{operating-system} declaration,
  23817. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  23818. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  23819. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  23820. to the name service cache daemon (@pxref{Base Services,
  23821. @code{nscd-service}}).
  23822. For convenience, the following variables provide typical NSS
  23823. configurations.
  23824. @defvr {Scheme Variable} %default-nss
  23825. This is the default name service switch configuration, a
  23826. @code{name-service-switch} object.
  23827. @end defvr
  23828. @defvr {Scheme Variable} %mdns-host-lookup-nss
  23829. This is the name service switch configuration with support for host name
  23830. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  23831. @end defvr
  23832. The reference for name service switch configuration is given below. It
  23833. is a direct mapping of the configuration file format of the C library , so
  23834. please refer to the C library manual for more information (@pxref{NSS
  23835. Configuration File,,, libc, The GNU C Library Reference Manual}).
  23836. Compared to the configuration file format of libc NSS, it has the advantage
  23837. not only of adding this warm parenthetic feel that we like, but also
  23838. static checks: you will know about syntax errors and typos as soon as you
  23839. run @command{guix system}.
  23840. @deftp {Data Type} name-service-switch
  23841. This is the data type representation the configuration of libc's name
  23842. service switch (NSS). Each field below represents one of the supported
  23843. system databases.
  23844. @table @code
  23845. @item aliases
  23846. @itemx ethers
  23847. @itemx group
  23848. @itemx gshadow
  23849. @itemx hosts
  23850. @itemx initgroups
  23851. @itemx netgroup
  23852. @itemx networks
  23853. @itemx password
  23854. @itemx public-key
  23855. @itemx rpc
  23856. @itemx services
  23857. @itemx shadow
  23858. The system databases handled by the NSS@. Each of these fields must be a
  23859. list of @code{<name-service>} objects (see below).
  23860. @end table
  23861. @end deftp
  23862. @deftp {Data Type} name-service
  23863. This is the data type representing an actual name service and the
  23864. associated lookup action.
  23865. @table @code
  23866. @item name
  23867. A string denoting the name service (@pxref{Services in the NSS
  23868. configuration,,, libc, The GNU C Library Reference Manual}).
  23869. Note that name services listed here must be visible to nscd. This is
  23870. achieved by passing the @code{#:name-services} argument to
  23871. @code{nscd-service} the list of packages providing the needed name
  23872. services (@pxref{Base Services, @code{nscd-service}}).
  23873. @item reaction
  23874. An action specified using the @code{lookup-specification} macro
  23875. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  23876. Reference Manual}). For example:
  23877. @lisp
  23878. (lookup-specification (unavailable => continue)
  23879. (success => return))
  23880. @end lisp
  23881. @end table
  23882. @end deftp
  23883. @node Initial RAM Disk
  23884. @section Initial RAM Disk
  23885. @cindex initrd
  23886. @cindex initial RAM disk
  23887. For bootstrapping purposes, the Linux-Libre kernel is passed an
  23888. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  23889. root file system as well as an initialization script. The latter is
  23890. responsible for mounting the real root file system, and for loading any
  23891. kernel modules that may be needed to achieve that.
  23892. The @code{initrd-modules} field of an @code{operating-system}
  23893. declaration allows you to specify Linux-libre kernel modules that must
  23894. be available in the initrd. In particular, this is where you would list
  23895. modules needed to actually drive the hard disk where your root partition
  23896. is---although the default value of @code{initrd-modules} should cover
  23897. most use cases. For example, assuming you need the @code{megaraid_sas}
  23898. module in addition to the default modules to be able to access your root
  23899. file system, you would write:
  23900. @lisp
  23901. (operating-system
  23902. ;; @dots{}
  23903. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  23904. @end lisp
  23905. @defvr {Scheme Variable} %base-initrd-modules
  23906. This is the list of kernel modules included in the initrd by default.
  23907. @end defvr
  23908. Furthermore, if you need lower-level customization, the @code{initrd}
  23909. field of an @code{operating-system} declaration allows
  23910. you to specify which initrd you would like to use. The @code{(gnu
  23911. system linux-initrd)} module provides three ways to build an initrd: the
  23912. high-level @code{base-initrd} procedure and the low-level
  23913. @code{raw-initrd} and @code{expression->initrd} procedures.
  23914. The @code{base-initrd} procedure is intended to cover most common uses.
  23915. For example, if you want to add a bunch of kernel modules to be loaded
  23916. at boot time, you can define the @code{initrd} field of the operating
  23917. system declaration like this:
  23918. @lisp
  23919. (initrd (lambda (file-systems . rest)
  23920. ;; Create a standard initrd but set up networking
  23921. ;; with the parameters QEMU expects by default.
  23922. (apply base-initrd file-systems
  23923. #:qemu-networking? #t
  23924. rest)))
  23925. @end lisp
  23926. The @code{base-initrd} procedure also handles common use cases that
  23927. involves using the system as a QEMU guest, or as a ``live'' system with
  23928. volatile root file system.
  23929. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  23930. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  23931. such as trying to guess which kernel modules and packages should be included
  23932. to the initrd. An example use of @code{raw-initrd} is when a user has
  23933. a custom Linux kernel configuration and default kernel modules included by
  23934. @code{base-initrd} are not available.
  23935. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  23936. honors several options passed on the Linux kernel command line
  23937. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  23938. @code{-append} option of QEMU), notably:
  23939. @table @code
  23940. @item --load=@var{boot}
  23941. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  23942. program, once it has mounted the root file system.
  23943. Guix uses this option to yield control to a boot program that runs the
  23944. service activation programs and then spawns the GNU@tie{}Shepherd, the
  23945. initialization system.
  23946. @item --root=@var{root}
  23947. Mount @var{root} as the root file system. @var{root} can be a device
  23948. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  23949. When unspecified, the device name from the root file system of the
  23950. operating system declaration is used.
  23951. @item --system=@var{system}
  23952. Have @file{/run/booted-system} and @file{/run/current-system} point to
  23953. @var{system}.
  23954. @item modprobe.blacklist=@var{modules}@dots{}
  23955. @cindex module, black-listing
  23956. @cindex black list, of kernel modules
  23957. Instruct the initial RAM disk as well as the @command{modprobe} command
  23958. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  23959. must be a comma-separated list of module names---e.g.,
  23960. @code{usbkbd,9pnet}.
  23961. @item --repl
  23962. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  23963. tries to load kernel modules and to mount the root file system. Our
  23964. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  23965. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  23966. Manual}, for more information on Guile's REPL.
  23967. @end table
  23968. Now that you know all the features that initial RAM disks produced by
  23969. @code{base-initrd} and @code{raw-initrd} provide,
  23970. here is how to use it and customize it further.
  23971. @cindex initrd
  23972. @cindex initial RAM disk
  23973. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  23974. [#:linux-modules '()] [#:mapped-devices '()] @
  23975. [#:keyboard-layout #f] @
  23976. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  23977. Return a derivation that builds a raw initrd. @var{file-systems} is
  23978. a list of file systems to be mounted by the initrd, possibly in addition to
  23979. the root file system specified on the kernel command line via @option{--root}.
  23980. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  23981. @var{mapped-devices} is a list of device mappings to realize before
  23982. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  23983. @var{helper-packages} is a list of packages to be copied in the initrd.
  23984. It may
  23985. include @code{e2fsck/static} or other packages needed by the initrd to check
  23986. the root file system.
  23987. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  23988. the desired console keyboard layout. This is done before @var{mapped-devices}
  23989. are set up and before @var{file-systems} are mounted such that, should the
  23990. user need to enter a passphrase or use the REPL, this happens using the
  23991. intended keyboard layout.
  23992. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  23993. parameters. When @var{virtio?} is true, load additional modules so that the
  23994. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  23995. When @var{volatile-root?} is true, the root file system is writable but any changes
  23996. to it are lost.
  23997. @end deffn
  23998. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  23999. [#:mapped-devices '()] [#:keyboard-layout #f] @
  24000. [#:qemu-networking? #f] [#:volatile-root? #f] @
  24001. [#:linux-modules '()]
  24002. Return as a file-like object a generic initrd, with kernel
  24003. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  24004. mounted by the initrd, possibly in addition to the root file system specified
  24005. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  24006. mappings to realize before @var{file-systems} are mounted.
  24007. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  24008. the desired console keyboard layout. This is done before @var{mapped-devices}
  24009. are set up and before @var{file-systems} are mounted such that, should the
  24010. user need to enter a passphrase or use the REPL, this happens using the
  24011. intended keyboard layout.
  24012. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  24013. The initrd is automatically populated with all the kernel modules necessary
  24014. for @var{file-systems} and for the given options. Additional kernel
  24015. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  24016. loaded at boot time in the order in which they appear.
  24017. @end deffn
  24018. Needless to say, the initrds we produce and use embed a
  24019. statically-linked Guile, and the initialization program is a Guile
  24020. program. That gives a lot of flexibility. The
  24021. @code{expression->initrd} procedure builds such an initrd, given the
  24022. program to run in that initrd.
  24023. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  24024. [#:guile %guile-3.0-static-stripped] [#:name "guile-initrd"]
  24025. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  24026. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  24027. upon booting. All the derivations referenced by @var{exp} are
  24028. automatically copied to the initrd.
  24029. @end deffn
  24030. @node Bootloader Configuration
  24031. @section Bootloader Configuration
  24032. @cindex bootloader
  24033. @cindex boot loader
  24034. The operating system supports multiple bootloaders. The bootloader is
  24035. configured using @code{bootloader-configuration} declaration. All the
  24036. fields of this structure are bootloader agnostic except for one field,
  24037. @code{bootloader} that indicates the bootloader to be configured and
  24038. installed.
  24039. Some of the bootloaders do not honor every field of
  24040. @code{bootloader-configuration}. For instance, the extlinux
  24041. bootloader does not support themes and thus ignores the @code{theme}
  24042. field.
  24043. @deftp {Data Type} bootloader-configuration
  24044. The type of a bootloader configuration declaration.
  24045. @table @asis
  24046. @item @code{bootloader}
  24047. @cindex EFI, bootloader
  24048. @cindex UEFI, bootloader
  24049. @cindex BIOS, bootloader
  24050. The bootloader to use, as a @code{bootloader} object. For now
  24051. @code{grub-bootloader}, @code{grub-efi-bootloader},
  24052. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  24053. @code{u-boot-bootloader} are supported.
  24054. @cindex ARM, bootloaders
  24055. @cindex AArch64, bootloaders
  24056. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  24057. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  24058. of bootloaders for a wide range of ARM and AArch64 systems, using the
  24059. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  24060. @vindex grub-efi-bootloader
  24061. @code{grub-efi-bootloader} allows to boot on modern systems using the
  24062. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  24063. use if the installation image contains a @file{/sys/firmware/efi} directory
  24064. when you boot it on your system.
  24065. @vindex grub-bootloader
  24066. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  24067. in ``legacy'' BIOS mode.
  24068. @vindex grub-efi-netboot-bootloader
  24069. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  24070. through TFTP@. In combination with an NFS root file system this allows you to
  24071. build a diskless Guix system.
  24072. The installation of the @code{grub-efi-netboot-bootloader} generates the content
  24073. of the TFTP root directory at @code{target}
  24074. (@pxref{Bootloader Configuration, @code{target}}), to be served by a TFTP server.
  24075. You may want to mount your TFTP server directory onto @code{target} to move the
  24076. required files to the TFTP server automatically.
  24077. If you plan to use an NFS root file system as well (actually if you mount the
  24078. store from an NFS share), then the TFTP server needs to serve the file
  24079. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  24080. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  24081. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  24082. files from the store will be accessed by GRUB through TFTP with their normal
  24083. store path, for example as
  24084. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  24085. Two symlinks are created to make this possible. The first symlink is
  24086. @code{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  24087. @file{../../../boot/grub/grub.cfg},
  24088. where @code{target} may be @file{/boot}. In this case the link is not leaving
  24089. the served TFTP root directory, but otherwise it does. The second link is
  24090. @code{target}@file{/gnu/store} and points to @file{../gnu/store}. This link
  24091. is leaving the served TFTP root directory.
  24092. The assumption behind all this is that you have an NFS server exporting the root
  24093. file system for your Guix system, and additionally a TFTP server exporting your
  24094. @code{target} directory—usually @file{/boot}—from that same root file system for
  24095. your Guix system. In this constellation the symlinks will work.
  24096. For other constellations you will have to program your own bootloader installer,
  24097. which then takes care to make necessary files from the store accessible through
  24098. TFTP, for example by copying them into the TFTP root directory at @code{target}.
  24099. It is important to note that symlinks pointing outside the TFTP root directory
  24100. may need to be allowed in the configuration of your TFTP server. Further the
  24101. store link exposes the whole store through TFTP@. Both points need to be
  24102. considered carefully for security aspects.
  24103. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  24104. NFS servers, you also need a properly configured DHCP server to make the booting
  24105. over netboot possible. For all this we can currently only recommend you to look
  24106. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  24107. @item @code{target}
  24108. This is a string denoting the target onto which to install the
  24109. bootloader.
  24110. The interpretation depends on the bootloader in question. For
  24111. @code{grub-bootloader}, for example, it should be a device name understood by
  24112. the bootloader @command{installer} command, such as @code{/dev/sda} or
  24113. @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
  24114. @code{grub-efi-bootloader}, it should be the mount point of the EFI file
  24115. system, usually @file{/boot/efi}. For @code{grub-efi-netboot-bootloader},
  24116. @code{target} should be the mount point corresponding to the TFTP root
  24117. directory of your TFTP server.
  24118. @item @code{menu-entries} (default: @code{()})
  24119. A possibly empty list of @code{menu-entry} objects (see below), denoting
  24120. entries to appear in the bootloader menu, in addition to the current
  24121. system entry and the entry pointing to previous system generations.
  24122. @item @code{default-entry} (default: @code{0})
  24123. The index of the default boot menu entry. Index 0 is for the entry of the
  24124. current system.
  24125. @item @code{timeout} (default: @code{5})
  24126. The number of seconds to wait for keyboard input before booting. Set to
  24127. 0 to boot immediately, and to -1 to wait indefinitely.
  24128. @cindex keyboard layout, for the bootloader
  24129. @item @code{keyboard-layout} (default: @code{#f})
  24130. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  24131. layout, usually US@tie{}English (``qwerty'').
  24132. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  24133. Layout}).
  24134. @quotation Note
  24135. This option is currently ignored by bootloaders other than @code{grub} and
  24136. @code{grub-efi}.
  24137. @end quotation
  24138. @item @code{theme} (default: @var{#f})
  24139. The bootloader theme object describing the theme to use. If no theme
  24140. is provided, some bootloaders might use a default theme, that's true
  24141. for GRUB.
  24142. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  24143. The output terminals used for the bootloader boot menu, as a list of
  24144. symbols. GRUB accepts the values: @code{console}, @code{serial},
  24145. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  24146. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  24147. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  24148. configuration,,, grub,GNU GRUB manual}).
  24149. @item @code{terminal-inputs} (default: @code{'()})
  24150. The input terminals used for the bootloader boot menu, as a list of
  24151. symbols. For GRUB, the default is the native platform terminal as
  24152. determined at run-time. GRUB accepts the values: @code{console},
  24153. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  24154. @code{usb_keyboard}. This field corresponds to the GRUB variable
  24155. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  24156. manual}).
  24157. @item @code{serial-unit} (default: @code{#f})
  24158. The serial unit used by the bootloader, as an integer from 0 to 3.
  24159. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  24160. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  24161. @item @code{serial-speed} (default: @code{#f})
  24162. The speed of the serial interface, as an integer. For GRUB, the
  24163. default value is chosen at run-time; currently GRUB chooses
  24164. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  24165. @end table
  24166. @end deftp
  24167. @cindex dual boot
  24168. @cindex boot menu
  24169. Should you want to list additional boot menu entries @i{via} the
  24170. @code{menu-entries} field above, you will need to create them with the
  24171. @code{menu-entry} form. For example, imagine you want to be able to
  24172. boot another distro (hard to imagine!), you can define a menu entry
  24173. along these lines:
  24174. @lisp
  24175. (menu-entry
  24176. (label "The Other Distro")
  24177. (linux "/boot/old/vmlinux-2.6.32")
  24178. (linux-arguments '("root=/dev/sda2"))
  24179. (initrd "/boot/old/initrd"))
  24180. @end lisp
  24181. Details below.
  24182. @deftp {Data Type} menu-entry
  24183. The type of an entry in the bootloader menu.
  24184. @table @asis
  24185. @item @code{label}
  24186. The label to show in the menu---e.g., @code{"GNU"}.
  24187. @item @code{linux} (default: @code{#f})
  24188. The Linux kernel image to boot, for example:
  24189. @lisp
  24190. (file-append linux-libre "/bzImage")
  24191. @end lisp
  24192. For GRUB, it is also possible to specify a device explicitly in the
  24193. file path using GRUB's device naming convention (@pxref{Naming
  24194. convention,,, grub, GNU GRUB manual}), for example:
  24195. @example
  24196. "(hd0,msdos1)/boot/vmlinuz"
  24197. @end example
  24198. If the device is specified explicitly as above, then the @code{device}
  24199. field is ignored entirely.
  24200. @item @code{linux-arguments} (default: @code{()})
  24201. The list of extra Linux kernel command-line arguments---e.g.,
  24202. @code{("console=ttyS0")}.
  24203. @item @code{initrd} (default: @code{#f})
  24204. A G-Expression or string denoting the file name of the initial RAM disk
  24205. to use (@pxref{G-Expressions}).
  24206. @item @code{device} (default: @code{#f})
  24207. The device where the kernel and initrd are to be found---i.e., for GRUB,
  24208. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  24209. This may be a file system label (a string), a file system UUID (a
  24210. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  24211. the bootloader will search the device containing the file specified by
  24212. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  24213. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  24214. @item @code{multiboot-kernel} (default: @code{#f})
  24215. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  24216. manual}). When this field is set, a Multiboot menu-entry is generated.
  24217. For example:
  24218. @lisp
  24219. (file-append mach "/boot/gnumach")
  24220. @end lisp
  24221. @item @code{multiboot-arguments} (default: @code{()})
  24222. The list of extra command-line arguments for the multiboot-kernel.
  24223. @item @code{multiboot-modules} (default: @code{()})
  24224. The list of commands for loading Multiboot modules. For example:
  24225. @lisp
  24226. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  24227. @dots{})
  24228. (list (file-append libc "/lib/ld.so.1") "exec"
  24229. @dots{}))
  24230. @end lisp
  24231. @end table
  24232. @end deftp
  24233. @cindex HDPI
  24234. @cindex HiDPI
  24235. @cindex resolution
  24236. @c FIXME: Write documentation once it's stable.
  24237. For now only GRUB has theme support. GRUB themes are created using
  24238. the @code{grub-theme} form, which is not fully documented yet.
  24239. @deftp {Data Type} grub-theme
  24240. Data type representing the configuration of the GRUB theme.
  24241. @table @asis
  24242. @item @code{gfxmode} (default: @code{'("auto")})
  24243. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  24244. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  24245. @end table
  24246. @end deftp
  24247. @deffn {Scheme Procedure} grub-theme
  24248. Return the default GRUB theme used by the operating system if no
  24249. @code{theme} field is specified in @code{bootloader-configuration}
  24250. record.
  24251. It comes with a fancy background image displaying the GNU and Guix
  24252. logos.
  24253. @end deffn
  24254. For example, to override the default resolution, you may use something
  24255. like
  24256. @lisp
  24257. (bootloader
  24258. (bootloader-configuration
  24259. ;; @dots{}
  24260. (theme (grub-theme
  24261. (inherit (grub-theme))
  24262. (gfxmode '("1024x786x32" "auto"))))))
  24263. @end lisp
  24264. @node Invoking guix system
  24265. @section Invoking @code{guix system}
  24266. Once you have written an operating system declaration as seen in the
  24267. previous section, it can be @dfn{instantiated} using the @command{guix
  24268. system} command. The synopsis is:
  24269. @example
  24270. guix system @var{options}@dots{} @var{action} @var{file}
  24271. @end example
  24272. @var{file} must be the name of a file containing an
  24273. @code{operating-system} declaration. @var{action} specifies how the
  24274. operating system is instantiated. Currently the following values are
  24275. supported:
  24276. @table @code
  24277. @item search
  24278. Display available service type definitions that match the given regular
  24279. expressions, sorted by relevance:
  24280. @cindex HDPI
  24281. @cindex HiDPI
  24282. @cindex resolution
  24283. @example
  24284. $ guix system search console
  24285. name: console-fonts
  24286. location: gnu/services/base.scm:806:2
  24287. extends: shepherd-root
  24288. description: Install the given fonts on the specified ttys (fonts are per
  24289. + virtual console on GNU/Linux). The value of this service is a list of
  24290. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  24291. + package or any valid argument to `setfont', as in this example:
  24292. +
  24293. + '(("tty1" . "LatGrkCyr-8x16")
  24294. + ("tty2" . (file-append
  24295. + font-tamzen
  24296. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  24297. + ("tty3" . (file-append
  24298. + font-terminus
  24299. + "/share/consolefonts/ter-132n"))) ; for HDPI
  24300. relevance: 9
  24301. name: mingetty
  24302. location: gnu/services/base.scm:1190:2
  24303. extends: shepherd-root
  24304. description: Provide console login using the `mingetty' program.
  24305. relevance: 2
  24306. name: login
  24307. location: gnu/services/base.scm:860:2
  24308. extends: pam
  24309. description: Provide a console log-in service as specified by its
  24310. + configuration value, a `login-configuration' object.
  24311. relevance: 2
  24312. @dots{}
  24313. @end example
  24314. As for @command{guix package --search}, the result is written in
  24315. @code{recutils} format, which makes it easy to filter the output
  24316. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  24317. @item reconfigure
  24318. Build the operating system described in @var{file}, activate it, and
  24319. switch to it@footnote{This action (and the related actions
  24320. @code{switch-generation} and @code{roll-back}) are usable only on
  24321. systems already running Guix System.}.
  24322. @quotation Note
  24323. @c The paragraph below refers to the problem discussed at
  24324. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  24325. It is highly recommended to run @command{guix pull} once before you run
  24326. @command{guix system reconfigure} for the first time (@pxref{Invoking
  24327. guix pull}). Failing to do that you would see an older version of Guix
  24328. once @command{reconfigure} has completed.
  24329. @end quotation
  24330. This effects all the configuration specified in @var{file}: user
  24331. accounts, system services, global package list, setuid programs, etc.
  24332. The command starts system services specified in @var{file} that are not
  24333. currently running; if a service is currently running this command will
  24334. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  24335. @code{herd stop X} or @code{herd restart X}).
  24336. This command creates a new generation whose number is one greater than
  24337. the current generation (as reported by @command{guix system
  24338. list-generations}). If that generation already exists, it will be
  24339. overwritten. This behavior mirrors that of @command{guix package}
  24340. (@pxref{Invoking guix package}).
  24341. It also adds a bootloader menu entry for the new OS configuration,
  24342. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  24343. entries for older configurations to a submenu, allowing you to choose
  24344. an older system generation at boot time should you need it.
  24345. @cindex provenance tracking, of the operating system
  24346. Upon completion, the new system is deployed under
  24347. @file{/run/current-system}. This directory contains @dfn{provenance
  24348. meta-data}: the list of channels in use (@pxref{Channels}) and
  24349. @var{file} itself, when available. You can view it by running:
  24350. @example
  24351. guix system describe
  24352. @end example
  24353. This information is useful should you later want to inspect how this
  24354. particular generation was built. In fact, assuming @var{file} is
  24355. self-contained, you can later rebuild generation @var{n} of your
  24356. operating system with:
  24357. @example
  24358. guix time-machine \
  24359. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  24360. system reconfigure \
  24361. /var/guix/profiles/system-@var{n}-link/configuration.scm
  24362. @end example
  24363. You can think of it as some sort of built-in version control! Your
  24364. system is not just a binary artifact: @emph{it carries its own source}.
  24365. @xref{Service Reference, @code{provenance-service-type}}, for more
  24366. information on provenance tracking.
  24367. By default, @command{reconfigure} @emph{prevents you from downgrading
  24368. your system}, which could (re)introduce security vulnerabilities and
  24369. also cause problems with ``stateful'' services such as database
  24370. management systems. You can override that behavior by passing
  24371. @option{--allow-downgrades}.
  24372. @item switch-generation
  24373. @cindex generations
  24374. Switch to an existing system generation. This action atomically
  24375. switches the system profile to the specified system generation. It
  24376. also rearranges the system's existing bootloader menu entries. It
  24377. makes the menu entry for the specified system generation the default,
  24378. and it moves the entries for the other generations to a submenu, if
  24379. supported by the bootloader being used. The next time the system
  24380. boots, it will use the specified system generation.
  24381. The bootloader itself is not being reinstalled when using this
  24382. command. Thus, the installed bootloader is used with an updated
  24383. configuration file.
  24384. The target generation can be specified explicitly by its generation
  24385. number. For example, the following invocation would switch to system
  24386. generation 7:
  24387. @example
  24388. guix system switch-generation 7
  24389. @end example
  24390. The target generation can also be specified relative to the current
  24391. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  24392. ``3 generations ahead of the current generation,'' and @code{-1} means
  24393. ``1 generation prior to the current generation.'' When specifying a
  24394. negative value such as @code{-1}, you must precede it with @code{--} to
  24395. prevent it from being parsed as an option. For example:
  24396. @example
  24397. guix system switch-generation -- -1
  24398. @end example
  24399. Currently, the effect of invoking this action is @emph{only} to switch
  24400. the system profile to an existing generation and rearrange the
  24401. bootloader menu entries. To actually start using the target system
  24402. generation, you must reboot after running this action. In the future,
  24403. it will be updated to do the same things as @command{reconfigure},
  24404. like activating and deactivating services.
  24405. This action will fail if the specified generation does not exist.
  24406. @item roll-back
  24407. @cindex rolling back
  24408. Switch to the preceding system generation. The next time the system
  24409. boots, it will use the preceding system generation. This is the inverse
  24410. of @command{reconfigure}, and it is exactly the same as invoking
  24411. @command{switch-generation} with an argument of @code{-1}.
  24412. Currently, as with @command{switch-generation}, you must reboot after
  24413. running this action to actually start using the preceding system
  24414. generation.
  24415. @item delete-generations
  24416. @cindex deleting system generations
  24417. @cindex saving space
  24418. Delete system generations, making them candidates for garbage collection
  24419. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  24420. collector'').
  24421. This works in the same way as @samp{guix package --delete-generations}
  24422. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  24423. arguments, all system generations but the current one are deleted:
  24424. @example
  24425. guix system delete-generations
  24426. @end example
  24427. You can also select the generations you want to delete. The example below
  24428. deletes all the system generations that are more than two month old:
  24429. @example
  24430. guix system delete-generations 2m
  24431. @end example
  24432. Running this command automatically reinstalls the bootloader with an updated
  24433. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  24434. longer lists the generations that have been deleted.
  24435. @item build
  24436. Build the derivation of the operating system, which includes all the
  24437. configuration files and programs needed to boot and run the system.
  24438. This action does not actually install anything.
  24439. @item init
  24440. Populate the given directory with all the files necessary to run the
  24441. operating system specified in @var{file}. This is useful for first-time
  24442. installations of Guix System. For instance:
  24443. @example
  24444. guix system init my-os-config.scm /mnt
  24445. @end example
  24446. copies to @file{/mnt} all the store items required by the configuration
  24447. specified in @file{my-os-config.scm}. This includes configuration
  24448. files, packages, and so on. It also creates other essential files
  24449. needed for the system to operate correctly---e.g., the @file{/etc},
  24450. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  24451. This command also installs bootloader on the target specified in
  24452. @file{my-os-config}, unless the @option{--no-bootloader} option was
  24453. passed.
  24454. @item vm
  24455. @cindex virtual machine
  24456. @cindex VM
  24457. @anchor{guix system vm}
  24458. Build a virtual machine that contains the operating system declared in
  24459. @var{file}, and return a script to run that virtual machine (VM).
  24460. @quotation Note
  24461. The @code{vm} action and others below
  24462. can use KVM support in the Linux-libre kernel. Specifically, if the
  24463. machine has hardware virtualization support, the corresponding
  24464. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  24465. must exist and be readable and writable by the user and by the
  24466. build users of the daemon (@pxref{Build Environment Setup}).
  24467. @end quotation
  24468. Arguments given to the script are passed to QEMU as in the example
  24469. below, which enables networking and requests 1@tie{}GiB of RAM for the
  24470. emulated machine:
  24471. @example
  24472. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -net user,model=virtio-net-pci
  24473. @end example
  24474. The VM shares its store with the host system.
  24475. Additional file systems can be shared between the host and the VM using
  24476. the @option{--share} and @option{--expose} command-line options: the former
  24477. specifies a directory to be shared with write access, while the latter
  24478. provides read-only access to the shared directory.
  24479. The example below creates a VM in which the user's home directory is
  24480. accessible read-only, and where the @file{/exchange} directory is a
  24481. read-write mapping of @file{$HOME/tmp} on the host:
  24482. @example
  24483. guix system vm my-config.scm \
  24484. --expose=$HOME --share=$HOME/tmp=/exchange
  24485. @end example
  24486. On GNU/Linux, the default is to boot directly to the kernel; this has
  24487. the advantage of requiring only a very tiny root disk image since the
  24488. store of the host can then be mounted.
  24489. The @option{--full-boot} option forces a complete boot sequence, starting
  24490. with the bootloader. This requires more disk space since a root image
  24491. containing at least the kernel, initrd, and bootloader data files must
  24492. be created. The @option{--image-size} option can be used to specify the
  24493. size of the image.
  24494. @cindex System images, creation in various formats
  24495. @cindex Creating system images in various formats
  24496. @item vm-image
  24497. @itemx image
  24498. @itemx docker-image
  24499. Return a virtual machine, disk image, or Docker image of the operating
  24500. system declared in @var{file} that stands alone. By default,
  24501. @command{guix system} estimates the size of the image needed to store
  24502. the system, but you can use the @option{--image-size} option to specify
  24503. a value. Docker images are built to contain exactly what they need, so
  24504. the @option{--image-size} option is ignored in the case of
  24505. @code{docker-image}.
  24506. @cindex image, creating disk images
  24507. The @code{image} command can produce various image types. The
  24508. image type can be selected using the @option{--image-type} option. It
  24509. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  24510. @option{--label} option can be used to specify a volume ID with
  24511. @code{image}. By default, the root file system of a disk image is
  24512. mounted non-volatile; the @option{--volatile} option can be provided to
  24513. make it volatile instead. When using @code{image}, the bootloader
  24514. installed on the generated image is taken from the provided
  24515. @code{operating-system} definition. The following example demonstrates
  24516. how to generate an image that uses the @code{grub-efi-bootloader}
  24517. bootloader and boot it with QEMU:
  24518. @example
  24519. image=$(guix system image --image-type=qcow2 \
  24520. gnu/system/examples/lightweight-desktop.tmpl)
  24521. cp $image /tmp/my-image.qcow2
  24522. chmod +w /tmp/my-image.qcow2
  24523. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  24524. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  24525. @end example
  24526. When using the @code{efi-raw} image type, a raw disk image is produced;
  24527. it can be copied as is to a USB stick, for instance. Assuming
  24528. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  24529. the image to it using the following command:
  24530. @example
  24531. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  24532. @end example
  24533. The @code{--list-image-types} command lists all the available image
  24534. types.
  24535. @cindex vm-image, creating virtual machine images
  24536. When using @code{vm-image}, the returned image is in qcow2 format, which
  24537. the QEMU emulator can efficiently use. @xref{Running Guix in a VM}, for
  24538. more information on how to run the image in a virtual machine. The
  24539. @code{grub-bootloader} bootloader is always used independently of what
  24540. is declared in the @code{operating-system} file passed as argument.
  24541. This is to make it easier to work with QEMU, which uses the SeaBIOS BIOS
  24542. by default, expecting a bootloader to be installed in the Master Boot
  24543. Record (MBR).
  24544. @cindex docker-image, creating docker images
  24545. When using @code{docker-image}, a Docker image is produced. Guix builds
  24546. the image from scratch, not from a pre-existing Docker base image. As a
  24547. result, it contains @emph{exactly} what you define in the operating
  24548. system configuration file. You can then load the image and launch a
  24549. Docker container using commands like the following:
  24550. @example
  24551. image_id="`docker load < guix-system-docker-image.tar.gz`"
  24552. container_id="`docker create $image_id`"
  24553. docker start $container_id
  24554. @end example
  24555. This command starts a new Docker container from the specified image. It
  24556. will boot the Guix system in the usual manner, which means it will
  24557. start any services you have defined in the operating system
  24558. configuration. You can get an interactive shell running in the container
  24559. using @command{docker exec}:
  24560. @example
  24561. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  24562. @end example
  24563. Depending on what you run in the Docker container, it
  24564. may be necessary to give the container additional permissions. For
  24565. example, if you intend to build software using Guix inside of the Docker
  24566. container, you may need to pass the @option{--privileged} option to
  24567. @code{docker create}.
  24568. Last, the @option{--network} option applies to @command{guix system
  24569. docker-image}: it produces an image where network is supposedly shared
  24570. with the host, and thus without services like nscd or NetworkManager.
  24571. @item container
  24572. Return a script to run the operating system declared in @var{file}
  24573. within a container. Containers are a set of lightweight isolation
  24574. mechanisms provided by the kernel Linux-libre. Containers are
  24575. substantially less resource-demanding than full virtual machines since
  24576. the kernel, shared objects, and other resources can be shared with the
  24577. host system; this also means they provide thinner isolation.
  24578. Currently, the script must be run as root in order to support more than
  24579. a single user and group. The container shares its store with the host
  24580. system.
  24581. As with the @code{vm} action (@pxref{guix system vm}), additional file
  24582. systems to be shared between the host and container can be specified
  24583. using the @option{--share} and @option{--expose} options:
  24584. @example
  24585. guix system container my-config.scm \
  24586. --expose=$HOME --share=$HOME/tmp=/exchange
  24587. @end example
  24588. @quotation Note
  24589. This option requires Linux-libre 3.19 or newer.
  24590. @end quotation
  24591. @end table
  24592. @var{options} can contain any of the common build options (@pxref{Common
  24593. Build Options}). In addition, @var{options} can contain one of the
  24594. following:
  24595. @table @option
  24596. @item --expression=@var{expr}
  24597. @itemx -e @var{expr}
  24598. Consider the operating-system @var{expr} evaluates to.
  24599. This is an alternative to specifying a file which evaluates to an
  24600. operating system.
  24601. This is used to generate the Guix system installer @pxref{Building the
  24602. Installation Image}).
  24603. @item --system=@var{system}
  24604. @itemx -s @var{system}
  24605. Attempt to build for @var{system} instead of the host system type.
  24606. This works as per @command{guix build} (@pxref{Invoking guix build}).
  24607. @item --derivation
  24608. @itemx -d
  24609. Return the derivation file name of the given operating system without
  24610. building anything.
  24611. @cindex provenance tracking, of the operating system
  24612. @item --save-provenance
  24613. As discussed above, @command{guix system init} and @command{guix system
  24614. reconfigure} always save provenance information @i{via} a dedicated
  24615. service (@pxref{Service Reference, @code{provenance-service-type}}).
  24616. However, other commands don't do that by default. If you wish to, say,
  24617. create a virtual machine image that contains provenance information, you
  24618. can run:
  24619. @example
  24620. guix system vm-image --save-provenance config.scm
  24621. @end example
  24622. That way, the resulting image will effectively ``embed its own source''
  24623. in the form of meta-data in @file{/run/current-system}. With that
  24624. information, one can rebuild the image to make sure it really contains
  24625. what it pretends to contain; or they could use that to derive a variant
  24626. of the image.
  24627. @item --image-type=@var{type}
  24628. @itemx -t @var{type}
  24629. For the @code{image} action, create an image with given @var{type}.
  24630. When this option is omitted, @command{guix system} uses the
  24631. @code{efi-raw} image type.
  24632. @cindex ISO-9660 format
  24633. @cindex CD image format
  24634. @cindex DVD image format
  24635. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  24636. for burning on CDs and DVDs.
  24637. @item --image-size=@var{size}
  24638. For the @code{vm-image} and @code{image} actions, create an image
  24639. of the given @var{size}. @var{size} may be a number of bytes, or it may
  24640. include a unit as a suffix (@pxref{Block size, size specifications,,
  24641. coreutils, GNU Coreutils}).
  24642. When this option is omitted, @command{guix system} computes an estimate
  24643. of the image size as a function of the size of the system declared in
  24644. @var{file}.
  24645. @item --network
  24646. @itemx -N
  24647. For the @code{container} action, allow containers to access the host network,
  24648. that is, do not create a network namespace.
  24649. @item --root=@var{file}
  24650. @itemx -r @var{file}
  24651. Make @var{file} a symlink to the result, and register it as a garbage
  24652. collector root.
  24653. @item --skip-checks
  24654. Skip pre-installation safety checks.
  24655. By default, @command{guix system init} and @command{guix system
  24656. reconfigure} perform safety checks: they make sure the file systems that
  24657. appear in the @code{operating-system} declaration actually exist
  24658. (@pxref{File Systems}), and that any Linux kernel modules that may be
  24659. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  24660. RAM Disk}). Passing this option skips these tests altogether.
  24661. @item --allow-downgrades
  24662. Instruct @command{guix system reconfigure} to allow system downgrades.
  24663. By default, @command{reconfigure} prevents you from downgrading your
  24664. system. It achieves that by comparing the provenance info of your
  24665. system (shown by @command{guix system describe}) with that of your
  24666. @command{guix} command (shown by @command{guix describe}). If the
  24667. commits for @command{guix} are not descendants of those used for your
  24668. system, @command{guix system reconfigure} errors out. Passing
  24669. @option{--allow-downgrades} allows you to bypass these checks.
  24670. @quotation Note
  24671. Make sure you understand its security implications before using
  24672. @option{--allow-downgrades}.
  24673. @end quotation
  24674. @cindex on-error
  24675. @cindex on-error strategy
  24676. @cindex error strategy
  24677. @item --on-error=@var{strategy}
  24678. Apply @var{strategy} when an error occurs when reading @var{file}.
  24679. @var{strategy} may be one of the following:
  24680. @table @code
  24681. @item nothing-special
  24682. Report the error concisely and exit. This is the default strategy.
  24683. @item backtrace
  24684. Likewise, but also display a backtrace.
  24685. @item debug
  24686. Report the error and enter Guile's debugger. From there, you can run
  24687. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  24688. display local variable values, and more generally inspect the state of the
  24689. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  24690. a list of available debugging commands.
  24691. @end table
  24692. @end table
  24693. Once you have built, configured, re-configured, and re-re-configured
  24694. your Guix installation, you may find it useful to list the operating
  24695. system generations available on disk---and that you can choose from the
  24696. bootloader boot menu:
  24697. @table @code
  24698. @item describe
  24699. Describe the current system generation: its file name, the kernel and
  24700. bootloader used, etc., as well as provenance information when available.
  24701. @item list-generations
  24702. List a summary of each generation of the operating system available on
  24703. disk, in a human-readable way. This is similar to the
  24704. @option{--list-generations} option of @command{guix package}
  24705. (@pxref{Invoking guix package}).
  24706. Optionally, one can specify a pattern, with the same syntax that is used
  24707. in @command{guix package --list-generations}, to restrict the list of
  24708. generations displayed. For instance, the following command displays
  24709. generations that are up to 10 days old:
  24710. @example
  24711. $ guix system list-generations 10d
  24712. @end example
  24713. @end table
  24714. The @command{guix system} command has even more to offer! The following
  24715. sub-commands allow you to visualize how your system services relate to
  24716. each other:
  24717. @anchor{system-extension-graph}
  24718. @table @code
  24719. @item extension-graph
  24720. Emit to standard output the @dfn{service
  24721. extension graph} of the operating system defined in @var{file}
  24722. (@pxref{Service Composition}, for more information on service
  24723. extensions). By default the output is in Dot/Graphviz format, but you
  24724. can choose a different format with @option{--graph-backend}, as with
  24725. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  24726. The command:
  24727. @example
  24728. $ guix system extension-graph @var{file} | xdot -
  24729. @end example
  24730. shows the extension relations among services.
  24731. @anchor{system-shepherd-graph}
  24732. @item shepherd-graph
  24733. Emit to standard output the @dfn{dependency
  24734. graph} of shepherd services of the operating system defined in
  24735. @var{file}. @xref{Shepherd Services}, for more information and for an
  24736. example graph.
  24737. Again, the default output format is Dot/Graphviz, but you can pass
  24738. @option{--graph-backend} to select a different one.
  24739. @end table
  24740. @node Invoking guix deploy
  24741. @section Invoking @code{guix deploy}
  24742. We've already seen @code{operating-system} declarations used to manage a
  24743. machine's configuration locally. Suppose you need to configure multiple
  24744. machines, though---perhaps you're managing a service on the web that's
  24745. comprised of several servers. @command{guix deploy} enables you to use those
  24746. same @code{operating-system} declarations to manage multiple remote hosts at
  24747. once as a logical ``deployment''.
  24748. @quotation Note
  24749. The functionality described in this section is still under development
  24750. and is subject to change. Get in touch with us on
  24751. @email{guix-devel@@gnu.org}!
  24752. @end quotation
  24753. @example
  24754. guix deploy @var{file}
  24755. @end example
  24756. Such an invocation will deploy the machines that the code within @var{file}
  24757. evaluates to. As an example, @var{file} might contain a definition like this:
  24758. @lisp
  24759. ;; This is a Guix deployment of a "bare bones" setup, with
  24760. ;; no X11 display server, to a machine with an SSH daemon
  24761. ;; listening on localhost:2222. A configuration such as this
  24762. ;; may be appropriate for virtual machine with ports
  24763. ;; forwarded to the host's loopback interface.
  24764. (use-service-modules networking ssh)
  24765. (use-package-modules bootloaders)
  24766. (define %system
  24767. (operating-system
  24768. (host-name "gnu-deployed")
  24769. (timezone "Etc/UTC")
  24770. (bootloader (bootloader-configuration
  24771. (bootloader grub-bootloader)
  24772. (target "/dev/vda")
  24773. (terminal-outputs '(console))))
  24774. (file-systems (cons (file-system
  24775. (mount-point "/")
  24776. (device "/dev/vda1")
  24777. (type "ext4"))
  24778. %base-file-systems))
  24779. (services
  24780. (append (list (service dhcp-client-service-type)
  24781. (service openssh-service-type
  24782. (openssh-configuration
  24783. (permit-root-login #t)
  24784. (allow-empty-passwords? #t))))
  24785. %base-services))))
  24786. (list (machine
  24787. (operating-system %system)
  24788. (environment managed-host-environment-type)
  24789. (configuration (machine-ssh-configuration
  24790. (host-name "localhost")
  24791. (system "x86_64-linux")
  24792. (user "alice")
  24793. (identity "./id_rsa")
  24794. (port 2222)))))
  24795. @end lisp
  24796. The file should evaluate to a list of @var{machine} objects. This example,
  24797. upon being deployed, will create a new generation on the remote system
  24798. realizing the @code{operating-system} declaration @code{%system}.
  24799. @code{environment} and @code{configuration} specify how the machine should be
  24800. provisioned---that is, how the computing resources should be created and
  24801. managed. The above example does not create any resources, as a
  24802. @code{'managed-host} is a machine that is already running the Guix system and
  24803. available over the network. This is a particularly simple case; a more
  24804. complex deployment may involve, for example, starting virtual machines through
  24805. a Virtual Private Server (VPS) provider. In such a case, a different
  24806. @var{environment} type would be used.
  24807. Do note that you first need to generate a key pair on the coordinator machine
  24808. to allow the daemon to export signed archives of files from the store
  24809. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  24810. System:
  24811. @example
  24812. # guix archive --generate-key
  24813. @end example
  24814. @noindent
  24815. Each target machine must authorize the key of the master machine so that it
  24816. accepts store items it receives from the coordinator:
  24817. @example
  24818. # guix archive --authorize < coordinator-public-key.txt
  24819. @end example
  24820. @code{user}, in this example, specifies the name of the user account to log in
  24821. as to perform the deployment. Its default value is @code{root}, but root
  24822. login over SSH may be forbidden in some cases. To work around this,
  24823. @command{guix deploy} can log in as an unprivileged user and employ
  24824. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  24825. currently installed on the remote and can be invoked non-interactively as
  24826. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  24827. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  24828. be accomplished with the following operating system configuration snippet:
  24829. @lisp
  24830. (use-modules ...
  24831. (gnu system)) ;for %sudoers-specification
  24832. (define %user "username")
  24833. (operating-system
  24834. ...
  24835. (sudoers-file
  24836. (plain-file "sudoers"
  24837. (string-append (plain-file-content %sudoers-specification)
  24838. (format #f "~a ALL = NOPASSWD: ALL~%"
  24839. %user)))))
  24840. @end lisp
  24841. For more information regarding the format of the @file{sudoers} file,
  24842. consult @command{man sudoers}.
  24843. @deftp {Data Type} machine
  24844. This is the data type representing a single machine in a heterogeneous Guix
  24845. deployment.
  24846. @table @asis
  24847. @item @code{operating-system}
  24848. The object of the operating system configuration to deploy.
  24849. @item @code{environment}
  24850. An @code{environment-type} describing how the machine should be provisioned.
  24851. @item @code{configuration} (default: @code{#f})
  24852. An object describing the configuration for the machine's @code{environment}.
  24853. If the @code{environment} has a default configuration, @code{#f} may be used.
  24854. If @code{#f} is used for an environment with no default configuration,
  24855. however, an error will be thrown.
  24856. @end table
  24857. @end deftp
  24858. @deftp {Data Type} machine-ssh-configuration
  24859. This is the data type representing the SSH client parameters for a machine
  24860. with an @code{environment} of @code{managed-host-environment-type}.
  24861. @table @asis
  24862. @item @code{host-name}
  24863. @item @code{build-locally?} (default: @code{#t})
  24864. If false, system derivations will be built on the machine being deployed to.
  24865. @item @code{system}
  24866. The system type describing the architecture of the machine being deployed
  24867. to---e.g., @code{"x86_64-linux"}.
  24868. @item @code{authorize?} (default: @code{#t})
  24869. If true, the coordinator's signing key will be added to the remote's ACL
  24870. keyring.
  24871. @item @code{port} (default: @code{22})
  24872. @item @code{user} (default: @code{"root"})
  24873. @item @code{identity} (default: @code{#f})
  24874. If specified, the path to the SSH private key to use to authenticate with the
  24875. remote host.
  24876. @item @code{host-key} (default: @code{#f})
  24877. This should be the SSH host key of the machine, which looks like this:
  24878. @example
  24879. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  24880. @end example
  24881. When @code{host-key} is @code{#f}, the server is authenticated against
  24882. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  24883. client does.
  24884. @item @code{allow-downgrades?} (default: @code{#f})
  24885. Whether to allow potential downgrades.
  24886. Like @command{guix system reconfigure}, @command{guix deploy} compares
  24887. the channel commits currently deployed on the remote host (as returned
  24888. by @command{guix system describe}) to those currently in use (as
  24889. returned by @command{guix describe}) to determine whether commits
  24890. currently in use are descendants of those deployed. When this is not
  24891. the case and @code{allow-downgrades?} is false, it raises an error.
  24892. This ensures you do not accidentally downgrade remote machines.
  24893. @end table
  24894. @end deftp
  24895. @deftp {Data Type} digital-ocean-configuration
  24896. This is the data type describing the Droplet that should be created for a
  24897. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  24898. @table @asis
  24899. @item @code{ssh-key}
  24900. The path to the SSH private key to use to authenticate with the remote
  24901. host. In the future, this field may not exist.
  24902. @item @code{tags}
  24903. A list of string ``tags'' that uniquely identify the machine. Must be given
  24904. such that no two machines in the deployment have the same set of tags.
  24905. @item @code{region}
  24906. A Digital Ocean region slug, such as @code{"nyc3"}.
  24907. @item @code{size}
  24908. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  24909. @item @code{enable-ipv6?}
  24910. Whether or not the droplet should be created with IPv6 networking.
  24911. @end table
  24912. @end deftp
  24913. @node Running Guix in a VM
  24914. @section Running Guix in a Virtual Machine
  24915. @cindex virtual machine
  24916. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
  24917. distributed at
  24918. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.xz}.
  24919. This image is a compressed image in QCOW format. You will first need to
  24920. decompress with @command{xz -d}, and then you can pass it to an emulator such
  24921. as QEMU (see below for details).
  24922. This image boots the Xfce graphical environment and it contains some
  24923. commonly used tools. You can install more software in the image by running
  24924. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  24925. also reconfigure the system based on its initial configuration file available
  24926. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  24927. Configuration System}).
  24928. Instead of using this pre-built image, one can also build their own virtual
  24929. machine image using @command{guix system vm-image} (@pxref{Invoking guix
  24930. system}). The returned image is in qcow2 format, which the
  24931. @uref{https://qemu.org/, QEMU emulator} can efficiently use.
  24932. @cindex QEMU
  24933. If you built your own image, you must copy it out of the store
  24934. (@pxref{The Store}) and give yourself permission to write to the copy
  24935. before you can use it. When invoking QEMU, you must choose a system
  24936. emulator that is suitable for your hardware platform. Here is a minimal
  24937. QEMU invocation that will boot the result of @command{guix system
  24938. vm-image} on x86_64 hardware:
  24939. @example
  24940. $ qemu-system-x86_64 \
  24941. -nic user,model=virtio-net-pci \
  24942. -enable-kvm -m 1024 \
  24943. -device virtio-blk,drive=myhd \
  24944. -drive if=none,file=/tmp/qemu-image,id=myhd
  24945. @end example
  24946. Here is what each of these options means:
  24947. @table @code
  24948. @item qemu-system-x86_64
  24949. This specifies the hardware platform to emulate. This should match the
  24950. host.
  24951. @item -nic user,model=virtio-net-pci
  24952. Enable the unprivileged user-mode network stack. The guest OS can
  24953. access the host but not vice versa. This is the simplest way to get the
  24954. guest OS online. @code{model} specifies which network device to emulate:
  24955. @code{virtio-net-pci} is a special device made for virtualized operating
  24956. systems and recommended for most uses. Assuming your hardware platform is
  24957. x86_64, you can get a list of available NIC models by running
  24958. @command{qemu-system-x86_64 -nic model=help}.
  24959. @item -enable-kvm
  24960. If your system has hardware virtualization extensions, enabling the
  24961. virtual machine support (KVM) of the Linux kernel will make things run
  24962. faster.
  24963. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  24964. @item -m 1024
  24965. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  24966. which may be insufficient for some operations.
  24967. @item -device virtio-blk,drive=myhd
  24968. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  24969. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  24970. better performance than if it were emulating a complete disk drive. See the
  24971. QEMU and KVM documentation for more info.
  24972. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  24973. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  24974. store of the ``myhd'' drive.
  24975. @end table
  24976. The default @command{run-vm.sh} script that is returned by an invocation of
  24977. @command{guix system vm} does not add a @command{-nic user} flag by default.
  24978. To get network access from within the vm add the @code{(dhcp-client-service)}
  24979. to your system definition and start the VM using
  24980. @command{`guix system vm config.scm` -nic user}. An important caveat of using
  24981. @command{-nic user} for networking is that @command{ping} will not work, because
  24982. it uses the ICMP protocol. You'll have to use a different command to check for
  24983. network connectivity, for example @command{guix download}.
  24984. @subsection Connecting Through SSH
  24985. @cindex SSH
  24986. @cindex SSH server
  24987. To enable SSH inside a VM you need to add an SSH server like
  24988. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  24989. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  24990. 22 by default, to the host. You can do this with
  24991. @example
  24992. `guix system vm config.scm` -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  24993. @end example
  24994. To connect to the VM you can run
  24995. @example
  24996. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  24997. @end example
  24998. The @command{-p} tells @command{ssh} the port you want to connect to.
  24999. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  25000. every time you modify your @command{config.scm} file and the
  25001. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  25002. connection to an unknown host every time you connect.
  25003. @subsection Using @command{virt-viewer} with Spice
  25004. As an alternative to the default @command{qemu} graphical client you can
  25005. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  25006. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  25007. @command{qemu}. See previous section for further information on how to do this.
  25008. Spice also allows you to do some nice stuff like share your clipboard with your
  25009. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  25010. @example
  25011. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  25012. -chardev spicevmc,name=vdagent,id=vdagent
  25013. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  25014. name=com.redhat.spice.0
  25015. @end example
  25016. You'll also need to add the @code{(spice-vdagent-service)} to your
  25017. system definition (@pxref{Miscellaneous Services, Spice service}).
  25018. @node Defining Services
  25019. @section Defining Services
  25020. The previous sections show the available services and how one can combine
  25021. them in an @code{operating-system} declaration. But how do we define
  25022. them in the first place? And what is a service anyway?
  25023. @menu
  25024. * Service Composition:: The model for composing services.
  25025. * Service Types and Services:: Types and services.
  25026. * Service Reference:: API reference.
  25027. * Shepherd Services:: A particular type of service.
  25028. @end menu
  25029. @node Service Composition
  25030. @subsection Service Composition
  25031. @cindex services
  25032. @cindex daemons
  25033. Here we define a @dfn{service} as, broadly, something that extends the
  25034. functionality of the operating system. Often a service is a process---a
  25035. @dfn{daemon}---started when the system boots: a secure shell server, a
  25036. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  25037. whose execution can be triggered by another daemon---e.g., an FTP server
  25038. started by @command{inetd} or a D-Bus service activated by
  25039. @command{dbus-daemon}. Occasionally, a service does not map to a
  25040. daemon. For instance, the ``account'' service collects user accounts
  25041. and makes sure they exist when the system runs; the ``udev'' service
  25042. collects device management rules and makes them available to the eudev
  25043. daemon; the @file{/etc} service populates the @file{/etc} directory
  25044. of the system.
  25045. @cindex service extensions
  25046. Guix system services are connected by @dfn{extensions}. For instance, the
  25047. secure shell service @emph{extends} the Shepherd---the
  25048. initialization system, running as PID@tie{}1---by giving it the command
  25049. lines to start and stop the secure shell daemon (@pxref{Networking
  25050. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  25051. service by passing it its @file{.service} specification, and extends the
  25052. udev service by passing it device management rules (@pxref{Desktop
  25053. Services, @code{upower-service}}); the Guix daemon service extends the
  25054. Shepherd by passing it the command lines to start and stop the daemon,
  25055. and extends the account service by passing it a list of required build
  25056. user accounts (@pxref{Base Services}).
  25057. All in all, services and their ``extends'' relations form a directed
  25058. acyclic graph (DAG). If we represent services as boxes and extensions
  25059. as arrows, a typical system might provide something like this:
  25060. @image{images/service-graph,,5in,Typical service extension graph.}
  25061. @cindex system service
  25062. At the bottom, we see the @dfn{system service}, which produces the
  25063. directory containing everything to run and boot the system, as returned
  25064. by the @command{guix system build} command. @xref{Service Reference},
  25065. to learn about the other service types shown here.
  25066. @xref{system-extension-graph, the @command{guix system extension-graph}
  25067. command}, for information on how to generate this representation for a
  25068. particular operating system definition.
  25069. @cindex service types
  25070. Technically, developers can define @dfn{service types} to express these
  25071. relations. There can be any number of services of a given type on the
  25072. system---for instance, a system running two instances of the GNU secure
  25073. shell server (lsh) has two instances of @code{lsh-service-type}, with
  25074. different parameters.
  25075. The following section describes the programming interface for service
  25076. types and services.
  25077. @node Service Types and Services
  25078. @subsection Service Types and Services
  25079. A @dfn{service type} is a node in the DAG described above. Let us start
  25080. with a simple example, the service type for the Guix build daemon
  25081. (@pxref{Invoking guix-daemon}):
  25082. @lisp
  25083. (define guix-service-type
  25084. (service-type
  25085. (name 'guix)
  25086. (extensions
  25087. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  25088. (service-extension account-service-type guix-accounts)
  25089. (service-extension activation-service-type guix-activation)))
  25090. (default-value (guix-configuration))))
  25091. @end lisp
  25092. @noindent
  25093. It defines three things:
  25094. @enumerate
  25095. @item
  25096. A name, whose sole purpose is to make inspection and debugging easier.
  25097. @item
  25098. A list of @dfn{service extensions}, where each extension designates the
  25099. target service type and a procedure that, given the parameters of the
  25100. service, returns a list of objects to extend the service of that type.
  25101. Every service type has at least one service extension. The only
  25102. exception is the @dfn{boot service type}, which is the ultimate service.
  25103. @item
  25104. Optionally, a default value for instances of this type.
  25105. @end enumerate
  25106. In this example, @code{guix-service-type} extends three services:
  25107. @table @code
  25108. @item shepherd-root-service-type
  25109. The @code{guix-shepherd-service} procedure defines how the Shepherd
  25110. service is extended. Namely, it returns a @code{<shepherd-service>}
  25111. object that defines how @command{guix-daemon} is started and stopped
  25112. (@pxref{Shepherd Services}).
  25113. @item account-service-type
  25114. This extension for this service is computed by @code{guix-accounts},
  25115. which returns a list of @code{user-group} and @code{user-account}
  25116. objects representing the build user accounts (@pxref{Invoking
  25117. guix-daemon}).
  25118. @item activation-service-type
  25119. Here @code{guix-activation} is a procedure that returns a gexp, which is
  25120. a code snippet to run at ``activation time''---e.g., when the service is
  25121. booted.
  25122. @end table
  25123. A service of this type is instantiated like this:
  25124. @lisp
  25125. (service guix-service-type
  25126. (guix-configuration
  25127. (build-accounts 5)
  25128. (extra-options '("--gc-keep-derivations"))))
  25129. @end lisp
  25130. The second argument to the @code{service} form is a value representing
  25131. the parameters of this specific service instance.
  25132. @xref{guix-configuration-type, @code{guix-configuration}}, for
  25133. information about the @code{guix-configuration} data type. When the
  25134. value is omitted, the default value specified by
  25135. @code{guix-service-type} is used:
  25136. @lisp
  25137. (service guix-service-type)
  25138. @end lisp
  25139. @code{guix-service-type} is quite simple because it extends other
  25140. services but is not extensible itself.
  25141. @c @subsubsubsection Extensible Service Types
  25142. The service type for an @emph{extensible} service looks like this:
  25143. @lisp
  25144. (define udev-service-type
  25145. (service-type (name 'udev)
  25146. (extensions
  25147. (list (service-extension shepherd-root-service-type
  25148. udev-shepherd-service)))
  25149. (compose concatenate) ;concatenate the list of rules
  25150. (extend (lambda (config rules)
  25151. (match config
  25152. (($ <udev-configuration> udev initial-rules)
  25153. (udev-configuration
  25154. (udev udev) ;the udev package to use
  25155. (rules (append initial-rules rules)))))))))
  25156. @end lisp
  25157. This is the service type for the
  25158. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  25159. management daemon}. Compared to the previous example, in addition to an
  25160. extension of @code{shepherd-root-service-type}, we see two new fields:
  25161. @table @code
  25162. @item compose
  25163. This is the procedure to @dfn{compose} the list of extensions to
  25164. services of this type.
  25165. Services can extend the udev service by passing it lists of rules; we
  25166. compose those extensions simply by concatenating them.
  25167. @item extend
  25168. This procedure defines how the value of the service is @dfn{extended} with
  25169. the composition of the extensions.
  25170. Udev extensions are composed into a list of rules, but the udev service
  25171. value is itself a @code{<udev-configuration>} record. So here, we
  25172. extend that record by appending the list of rules it contains to the
  25173. list of contributed rules.
  25174. @item description
  25175. This is a string giving an overview of the service type. The string can
  25176. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  25177. @command{guix system search} command searches these strings and displays
  25178. them (@pxref{Invoking guix system}).
  25179. @end table
  25180. There can be only one instance of an extensible service type such as
  25181. @code{udev-service-type}. If there were more, the
  25182. @code{service-extension} specifications would be ambiguous.
  25183. Still here? The next section provides a reference of the programming
  25184. interface for services.
  25185. @node Service Reference
  25186. @subsection Service Reference
  25187. We have seen an overview of service types (@pxref{Service Types and
  25188. Services}). This section provides a reference on how to manipulate
  25189. services and service types. This interface is provided by the
  25190. @code{(gnu services)} module.
  25191. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  25192. Return a new service of @var{type}, a @code{<service-type>} object (see
  25193. below). @var{value} can be any object; it represents the parameters of
  25194. this particular service instance.
  25195. When @var{value} is omitted, the default value specified by @var{type}
  25196. is used; if @var{type} does not specify a default value, an error is
  25197. raised.
  25198. For instance, this:
  25199. @lisp
  25200. (service openssh-service-type)
  25201. @end lisp
  25202. @noindent
  25203. is equivalent to this:
  25204. @lisp
  25205. (service openssh-service-type
  25206. (openssh-configuration))
  25207. @end lisp
  25208. In both cases the result is an instance of @code{openssh-service-type}
  25209. with the default configuration.
  25210. @end deffn
  25211. @deffn {Scheme Procedure} service? @var{obj}
  25212. Return true if @var{obj} is a service.
  25213. @end deffn
  25214. @deffn {Scheme Procedure} service-kind @var{service}
  25215. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  25216. @end deffn
  25217. @deffn {Scheme Procedure} service-value @var{service}
  25218. Return the value associated with @var{service}. It represents its
  25219. parameters.
  25220. @end deffn
  25221. Here is an example of how a service is created and manipulated:
  25222. @lisp
  25223. (define s
  25224. (service nginx-service-type
  25225. (nginx-configuration
  25226. (nginx nginx)
  25227. (log-directory log-directory)
  25228. (run-directory run-directory)
  25229. (file config-file))))
  25230. (service? s)
  25231. @result{} #t
  25232. (eq? (service-kind s) nginx-service-type)
  25233. @result{} #t
  25234. @end lisp
  25235. The @code{modify-services} form provides a handy way to change the
  25236. parameters of some of the services of a list such as
  25237. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  25238. evaluates to a list of services. Of course, you could always use
  25239. standard list combinators such as @code{map} and @code{fold} to do that
  25240. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  25241. @code{modify-services} simply provides a more concise form for this
  25242. common pattern.
  25243. @deffn {Scheme Syntax} modify-services @var{services} @
  25244. (@var{type} @var{variable} => @var{body}) @dots{}
  25245. Modify the services listed in @var{services} according to the given
  25246. clauses. Each clause has the form:
  25247. @example
  25248. (@var{type} @var{variable} => @var{body})
  25249. @end example
  25250. where @var{type} is a service type---e.g.,
  25251. @code{guix-service-type}---and @var{variable} is an identifier that is
  25252. bound within the @var{body} to the service parameters---e.g., a
  25253. @code{guix-configuration} instance---of the original service of that
  25254. @var{type}.
  25255. The @var{body} should evaluate to the new service parameters, which will
  25256. be used to configure the new service. This new service will replace the
  25257. original in the resulting list. Because a service's service parameters
  25258. are created using @code{define-record-type*}, you can write a succinct
  25259. @var{body} that evaluates to the new service parameters by using the
  25260. @code{inherit} feature that @code{define-record-type*} provides.
  25261. @xref{Using the Configuration System}, for example usage.
  25262. @end deffn
  25263. Next comes the programming interface for service types. This is
  25264. something you want to know when writing new service definitions, but not
  25265. necessarily when simply looking for ways to customize your
  25266. @code{operating-system} declaration.
  25267. @deftp {Data Type} service-type
  25268. @cindex service type
  25269. This is the representation of a @dfn{service type} (@pxref{Service Types
  25270. and Services}).
  25271. @table @asis
  25272. @item @code{name}
  25273. This is a symbol, used only to simplify inspection and debugging.
  25274. @item @code{extensions}
  25275. A non-empty list of @code{<service-extension>} objects (see below).
  25276. @item @code{compose} (default: @code{#f})
  25277. If this is @code{#f}, then the service type denotes services that cannot
  25278. be extended---i.e., services that do not receive ``values'' from other
  25279. services.
  25280. Otherwise, it must be a one-argument procedure. The procedure is called
  25281. by @code{fold-services} and is passed a list of values collected from
  25282. extensions. It may return any single value.
  25283. @item @code{extend} (default: @code{#f})
  25284. If this is @code{#f}, services of this type cannot be extended.
  25285. Otherwise, it must be a two-argument procedure: @code{fold-services}
  25286. calls it, passing it the initial value of the service as the first
  25287. argument and the result of applying @code{compose} to the extension
  25288. values as the second argument. It must return a value that is a valid
  25289. parameter value for the service instance.
  25290. @item @code{description}
  25291. This is a string, possibly using Texinfo markup, describing in a couple
  25292. of sentences what the service is about. This string allows users to
  25293. find about the service through @command{guix system search}
  25294. (@pxref{Invoking guix system}).
  25295. @item @code{default-value} (default: @code{&no-default-value})
  25296. The default value associated for instances of this service type. This
  25297. allows users to use the @code{service} form without its second argument:
  25298. @lisp
  25299. (service @var{type})
  25300. @end lisp
  25301. The returned service in this case has the default value specified by
  25302. @var{type}.
  25303. @end table
  25304. @xref{Service Types and Services}, for examples.
  25305. @end deftp
  25306. @deffn {Scheme Procedure} service-extension @var{target-type} @
  25307. @var{compute}
  25308. Return a new extension for services of type @var{target-type}.
  25309. @var{compute} must be a one-argument procedure: @code{fold-services}
  25310. calls it, passing it the value associated with the service that provides
  25311. the extension; it must return a valid value for the target service.
  25312. @end deffn
  25313. @deffn {Scheme Procedure} service-extension? @var{obj}
  25314. Return true if @var{obj} is a service extension.
  25315. @end deffn
  25316. Occasionally, you might want to simply extend an existing service. This
  25317. involves creating a new service type and specifying the extension of
  25318. interest, which can be verbose; the @code{simple-service} procedure
  25319. provides a shorthand for this.
  25320. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  25321. Return a service that extends @var{target} with @var{value}. This works
  25322. by creating a singleton service type @var{name}, of which the returned
  25323. service is an instance.
  25324. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  25325. an additional job:
  25326. @lisp
  25327. (simple-service 'my-mcron-job mcron-service-type
  25328. #~(job '(next-hour (3)) "guix gc -F 2G"))
  25329. @end lisp
  25330. @end deffn
  25331. At the core of the service abstraction lies the @code{fold-services}
  25332. procedure, which is responsible for ``compiling'' a list of services
  25333. down to a single directory that contains everything needed to boot and
  25334. run the system---the directory shown by the @command{guix system build}
  25335. command (@pxref{Invoking guix system}). In essence, it propagates
  25336. service extensions down the service graph, updating each node parameters
  25337. on the way, until it reaches the root node.
  25338. @deffn {Scheme Procedure} fold-services @var{services} @
  25339. [#:target-type @var{system-service-type}]
  25340. Fold @var{services} by propagating their extensions down to the root of
  25341. type @var{target-type}; return the root service adjusted accordingly.
  25342. @end deffn
  25343. Lastly, the @code{(gnu services)} module also defines several essential
  25344. service types, some of which are listed below.
  25345. @defvr {Scheme Variable} system-service-type
  25346. This is the root of the service graph. It produces the system directory
  25347. as returned by the @command{guix system build} command.
  25348. @end defvr
  25349. @defvr {Scheme Variable} boot-service-type
  25350. The type of the ``boot service'', which produces the @dfn{boot script}.
  25351. The boot script is what the initial RAM disk runs when booting.
  25352. @end defvr
  25353. @defvr {Scheme Variable} etc-service-type
  25354. The type of the @file{/etc} service. This service is used to create
  25355. files under @file{/etc} and can be extended by
  25356. passing it name/file tuples such as:
  25357. @lisp
  25358. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  25359. @end lisp
  25360. In this example, the effect would be to add an @file{/etc/issue} file
  25361. pointing to the given file.
  25362. @end defvr
  25363. @defvr {Scheme Variable} setuid-program-service-type
  25364. Type for the ``setuid-program service''. This service collects lists of
  25365. executable file names, passed as gexps, and adds them to the set of
  25366. setuid-root programs on the system (@pxref{Setuid Programs}).
  25367. @end defvr
  25368. @defvr {Scheme Variable} profile-service-type
  25369. Type of the service that populates the @dfn{system profile}---i.e., the
  25370. programs under @file{/run/current-system/profile}. Other services can
  25371. extend it by passing it lists of packages to add to the system profile.
  25372. @end defvr
  25373. @cindex provenance tracking, of the operating system
  25374. @anchor{provenance-service-type}
  25375. @defvr {Scheme Variable} provenance-service-type
  25376. This is the type of the service that records @dfn{provenance meta-data}
  25377. in the system itself. It creates several files under
  25378. @file{/run/current-system}:
  25379. @table @file
  25380. @item channels.scm
  25381. This is a ``channel file'' that can be passed to @command{guix pull -C}
  25382. or @command{guix time-machine -C}, and which describes the channels used
  25383. to build the system, if that information was available
  25384. (@pxref{Channels}).
  25385. @item configuration.scm
  25386. This is the file that was passed as the value for this
  25387. @code{provenance-service-type} service. By default, @command{guix
  25388. system reconfigure} automatically passes the OS configuration file it
  25389. received on the command line.
  25390. @item provenance
  25391. This contains the same information as the two other files but in a
  25392. format that is more readily processable.
  25393. @end table
  25394. In general, these two pieces of information (channels and configuration
  25395. file) are enough to reproduce the operating system ``from source''.
  25396. @quotation Caveats
  25397. This information is necessary to rebuild your operating system, but it
  25398. is not always sufficient. In particular, @file{configuration.scm}
  25399. itself is insufficient if it is not self-contained---if it refers to
  25400. external Guile modules or to extra files. If you want
  25401. @file{configuration.scm} to be self-contained, we recommend that modules
  25402. or files it refers to be part of a channel.
  25403. Besides, provenance meta-data is ``silent'' in the sense that it does
  25404. not change the bits contained in your system, @emph{except for the
  25405. meta-data bits themselves}. Two different OS configurations or sets of
  25406. channels can lead to the same system, bit-for-bit; when
  25407. @code{provenance-service-type} is used, these two systems will have
  25408. different meta-data and thus different store file names, which makes
  25409. comparison less trivial.
  25410. @end quotation
  25411. This service is automatically added to your operating system
  25412. configuration when you use @command{guix system reconfigure},
  25413. @command{guix system init}, or @command{guix deploy}.
  25414. @end defvr
  25415. @node Shepherd Services
  25416. @subsection Shepherd Services
  25417. @cindex shepherd services
  25418. @cindex PID 1
  25419. @cindex init system
  25420. The @code{(gnu services shepherd)} module provides a way to define
  25421. services managed by the GNU@tie{}Shepherd, which is the
  25422. initialization system---the first process that is started when the
  25423. system boots, also known as PID@tie{}1
  25424. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  25425. Services in the Shepherd can depend on each other. For instance, the
  25426. SSH daemon may need to be started after the syslog daemon has been
  25427. started, which in turn can only happen once all the file systems have
  25428. been mounted. The simple operating system defined earlier (@pxref{Using
  25429. the Configuration System}) results in a service graph like this:
  25430. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  25431. You can actually generate such a graph for any operating system
  25432. definition using the @command{guix system shepherd-graph} command
  25433. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  25434. The @code{%shepherd-root-service} is a service object representing
  25435. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  25436. by passing it lists of @code{<shepherd-service>} objects.
  25437. @deftp {Data Type} shepherd-service
  25438. The data type representing a service managed by the Shepherd.
  25439. @table @asis
  25440. @item @code{provision}
  25441. This is a list of symbols denoting what the service provides.
  25442. These are the names that may be passed to @command{herd start},
  25443. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  25444. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  25445. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  25446. @item @code{requirement} (default: @code{'()})
  25447. List of symbols denoting the Shepherd services this one depends on.
  25448. @cindex one-shot services, for the Shepherd
  25449. @item @code{one-shot?} (default: @code{#f})
  25450. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  25451. after their @code{start} action has completed. @xref{Slots of services,,,
  25452. shepherd, The GNU Shepherd Manual}, for more info.
  25453. @item @code{respawn?} (default: @code{#t})
  25454. Whether to restart the service when it stops, for instance when the
  25455. underlying process dies.
  25456. @item @code{start}
  25457. @itemx @code{stop} (default: @code{#~(const #f)})
  25458. The @code{start} and @code{stop} fields refer to the Shepherd's
  25459. facilities to start and stop processes (@pxref{Service De- and
  25460. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  25461. G-expressions that get expanded in the Shepherd configuration file
  25462. (@pxref{G-Expressions}).
  25463. @item @code{actions} (default: @code{'()})
  25464. @cindex actions, of Shepherd services
  25465. This is a list of @code{shepherd-action} objects (see below) defining
  25466. @dfn{actions} supported by the service, in addition to the standard
  25467. @code{start} and @code{stop} actions. Actions listed here become available as
  25468. @command{herd} sub-commands:
  25469. @example
  25470. herd @var{action} @var{service} [@var{arguments}@dots{}]
  25471. @end example
  25472. @item @code{auto-start?} (default: @code{#t})
  25473. Whether this service should be started automatically by the Shepherd. If it
  25474. is @code{#f} the service has to be started manually with @code{herd start}.
  25475. @item @code{documentation}
  25476. A documentation string, as shown when running:
  25477. @example
  25478. herd doc @var{service-name}
  25479. @end example
  25480. where @var{service-name} is one of the symbols in @code{provision}
  25481. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  25482. @item @code{modules} (default: @code{%default-modules})
  25483. This is the list of modules that must be in scope when @code{start} and
  25484. @code{stop} are evaluated.
  25485. @end table
  25486. @end deftp
  25487. @deftp {Data Type} shepherd-action
  25488. This is the data type that defines additional actions implemented by a
  25489. Shepherd service (see above).
  25490. @table @code
  25491. @item name
  25492. Symbol naming the action.
  25493. @item documentation
  25494. This is a documentation string for the action. It can be viewed by running:
  25495. @example
  25496. herd doc @var{service} action @var{action}
  25497. @end example
  25498. @item procedure
  25499. This should be a gexp that evaluates to a procedure of at least one argument,
  25500. which is the ``running value'' of the service (@pxref{Slots of services,,,
  25501. shepherd, The GNU Shepherd Manual}).
  25502. @end table
  25503. The following example defines an action called @code{say-hello} that kindly
  25504. greets the user:
  25505. @lisp
  25506. (shepherd-action
  25507. (name 'say-hello)
  25508. (documentation "Say hi!")
  25509. (procedure #~(lambda (running . args)
  25510. (format #t "Hello, friend! arguments: ~s\n"
  25511. args)
  25512. #t)))
  25513. @end lisp
  25514. Assuming this action is added to the @code{example} service, then you can do:
  25515. @example
  25516. # herd say-hello example
  25517. Hello, friend! arguments: ()
  25518. # herd say-hello example a b c
  25519. Hello, friend! arguments: ("a" "b" "c")
  25520. @end example
  25521. This, as you can see, is a fairly sophisticated way to say hello.
  25522. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  25523. info on actions.
  25524. @end deftp
  25525. @defvr {Scheme Variable} shepherd-root-service-type
  25526. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  25527. This is the service type that extensions target when they want to create
  25528. shepherd services (@pxref{Service Types and Services}, for an example).
  25529. Each extension must pass a list of @code{<shepherd-service>}.
  25530. @end defvr
  25531. @defvr {Scheme Variable} %shepherd-root-service
  25532. This service represents PID@tie{}1.
  25533. @end defvr
  25534. @node Documentation
  25535. @chapter Documentation
  25536. @cindex documentation, searching for
  25537. @cindex searching for documentation
  25538. @cindex Info, documentation format
  25539. @cindex man pages
  25540. @cindex manual pages
  25541. In most cases packages installed with Guix come with documentation.
  25542. There are two main documentation formats: ``Info'', a browseable
  25543. hypertext format used for GNU software, and ``manual pages'' (or ``man
  25544. pages''), the linear documentation format traditionally found on Unix.
  25545. Info manuals are accessed with the @command{info} command or with Emacs,
  25546. and man pages are accessed using @command{man}.
  25547. You can look for documentation of software installed on your system by
  25548. keyword. For example, the following command searches for information
  25549. about ``TLS'' in Info manuals:
  25550. @example
  25551. $ info -k TLS
  25552. "(emacs)Network Security" -- STARTTLS
  25553. "(emacs)Network Security" -- TLS
  25554. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  25555. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  25556. @dots{}
  25557. @end example
  25558. @noindent
  25559. The command below searches for the same keyword in man pages:
  25560. @example
  25561. $ man -k TLS
  25562. SSL (7) - OpenSSL SSL/TLS library
  25563. certtool (1) - GnuTLS certificate tool
  25564. @dots {}
  25565. @end example
  25566. These searches are purely local to your computer so you have the
  25567. guarantee that documentation you find corresponds to what you have
  25568. actually installed, you can access it off-line, and your privacy is
  25569. respected.
  25570. Once you have these results, you can view the relevant documentation by
  25571. running, say:
  25572. @example
  25573. $ info "(gnutls)Core TLS API"
  25574. @end example
  25575. @noindent
  25576. or:
  25577. @example
  25578. $ man certtool
  25579. @end example
  25580. Info manuals contain sections and indices as well as hyperlinks like
  25581. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  25582. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  25583. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  25584. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  25585. Introduction}, for an introduction to Info navigation.
  25586. @node Installing Debugging Files
  25587. @chapter Installing Debugging Files
  25588. @cindex debugging files
  25589. Program binaries, as produced by the GCC compilers for instance, are
  25590. typically written in the ELF format, with a section containing
  25591. @dfn{debugging information}. Debugging information is what allows the
  25592. debugger, GDB, to map binary code to source code; it is required to
  25593. debug a compiled program in good conditions.
  25594. This chapter explains how to use separate debug info when packages
  25595. provide it, and how to rebuild packages with debug info when it's
  25596. missing.
  25597. @menu
  25598. * Separate Debug Info:: Installing 'debug' outputs.
  25599. * Rebuilding Debug Info:: Building missing debug info.
  25600. @end menu
  25601. @node Separate Debug Info
  25602. @section Separate Debug Info
  25603. The problem with debugging information is that is takes up a fair amount
  25604. of disk space. For example, debugging information for the GNU C Library
  25605. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  25606. debugging info of all the installed programs is usually not an option.
  25607. Yet, space savings should not come at the cost of an impediment to
  25608. debugging---especially in the GNU system, which should make it easier
  25609. for users to exert their computing freedom (@pxref{GNU Distribution}).
  25610. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  25611. mechanism that allows users to get the best of both worlds: debugging
  25612. information can be stripped from the binaries and stored in separate
  25613. files. GDB is then able to load debugging information from those files,
  25614. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  25615. with GDB}).
  25616. The GNU distribution takes advantage of this by storing debugging
  25617. information in the @code{lib/debug} sub-directory of a separate package
  25618. output unimaginatively called @code{debug} (@pxref{Packages with
  25619. Multiple Outputs}). Users can choose to install the @code{debug} output
  25620. of a package when they need it. For instance, the following command
  25621. installs the debugging information for the GNU C Library and for GNU
  25622. Guile:
  25623. @example
  25624. guix install glibc:debug guile:debug
  25625. @end example
  25626. GDB must then be told to look for debug files in the user's profile, by
  25627. setting the @code{debug-file-directory} variable (consider setting it
  25628. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  25629. GDB}):
  25630. @example
  25631. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  25632. @end example
  25633. From there on, GDB will pick up debugging information from the
  25634. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  25635. In addition, you will most likely want GDB to be able to show the source
  25636. code being debugged. To do that, you will have to unpack the source
  25637. code of the package of interest (obtained with @code{guix build
  25638. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  25639. directory using the @code{directory} command (@pxref{Source Path,
  25640. @code{directory},, gdb, Debugging with GDB}).
  25641. @c XXX: keep me up-to-date
  25642. The @code{debug} output mechanism in Guix is implemented by the
  25643. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  25644. opt-in---debugging information is available only for the packages with
  25645. definitions explicitly declaring a @code{debug} output. To check
  25646. whether a package has a @code{debug} output, use @command{guix package
  25647. --list-available} (@pxref{Invoking guix package}).
  25648. Read on for how to deal with packages lacking a @code{debug} output.
  25649. @node Rebuilding Debug Info
  25650. @section Rebuilding Debug Info
  25651. @cindex debugging info, rebuilding
  25652. As we saw above, some packages, but not all, provide debugging info in a
  25653. @code{debug} output. What can you do when debugging info is missing?
  25654. The @option{--with-debug-info} option provides a solution to that: it
  25655. allows you to rebuild the package(s) for which debugging info is
  25656. missing---and only those---and to graft those onto the application
  25657. you're debugging. Thus, while it's not as fast as installing a
  25658. @code{debug} output, it is relatively inexpensive.
  25659. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  25660. and would like to see what's going on in GLib, a library that's deep
  25661. down in its dependency graph. As it turns out, GLib does not have a
  25662. @code{debug} output and the backtrace GDB shows is all sadness:
  25663. @example
  25664. (gdb) bt
  25665. #0 0x00007ffff5f92190 in g_getenv ()
  25666. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  25667. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  25668. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  25669. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  25670. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  25671. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  25672. at dl-init.c:118
  25673. @end example
  25674. To address that, you install Inkscape linked against a variant GLib that
  25675. contains debug info:
  25676. @example
  25677. guix install inkscape --with-debug-info=glib
  25678. @end example
  25679. This time, debugging will be a whole lot nicer:
  25680. @example
  25681. $ gdb --args sh -c 'exec inkscape'
  25682. @dots{}
  25683. (gdb) b g_getenv
  25684. Function "g_getenv" not defined.
  25685. Make breakpoint pending on future shared library load? (y or [n]) y
  25686. Breakpoint 1 (g_getenv) pending.
  25687. (gdb) r
  25688. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  25689. @dots{}
  25690. (gdb) bt
  25691. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  25692. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  25693. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  25694. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  25695. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  25696. @dots{}
  25697. @end example
  25698. Much better!
  25699. Note that there can be packages for which @option{--with-debug-info}
  25700. will not have the desired effect. @xref{Package Transformation Options,
  25701. @option{--with-debug-info}}, for more information.
  25702. @node Security Updates
  25703. @chapter Security Updates
  25704. @cindex security updates
  25705. @cindex security vulnerabilities
  25706. Occasionally, important security vulnerabilities are discovered in software
  25707. packages and must be patched. Guix developers try hard to keep track of
  25708. known vulnerabilities and to apply fixes as soon as possible in the
  25709. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  25710. containing only security updates). The @command{guix lint} tool helps
  25711. developers find out about vulnerable versions of software packages in the
  25712. distribution:
  25713. @smallexample
  25714. $ guix lint -c cve
  25715. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  25716. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  25717. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  25718. @dots{}
  25719. @end smallexample
  25720. @xref{Invoking guix lint}, for more information.
  25721. Guix follows a functional
  25722. package management discipline (@pxref{Introduction}), which implies
  25723. that, when a package is changed, @emph{every package that depends on it}
  25724. must be rebuilt. This can significantly slow down the deployment of
  25725. fixes in core packages such as libc or Bash, since basically the whole
  25726. distribution would need to be rebuilt. Using pre-built binaries helps
  25727. (@pxref{Substitutes}), but deployment may still take more time than
  25728. desired.
  25729. @cindex grafts
  25730. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  25731. for fast deployment of critical updates without the costs associated
  25732. with a whole-distribution rebuild. The idea is to rebuild only the
  25733. package that needs to be patched, and then to ``graft'' it onto packages
  25734. explicitly installed by the user and that were previously referring to
  25735. the original package. The cost of grafting is typically very low, and
  25736. order of magnitudes lower than a full rebuild of the dependency chain.
  25737. @cindex replacements of packages, for grafts
  25738. For instance, suppose a security update needs to be applied to Bash.
  25739. Guix developers will provide a package definition for the ``fixed''
  25740. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  25741. Packages}). Then, the original package definition is augmented with a
  25742. @code{replacement} field pointing to the package containing the bug fix:
  25743. @lisp
  25744. (define bash
  25745. (package
  25746. (name "bash")
  25747. ;; @dots{}
  25748. (replacement bash-fixed)))
  25749. @end lisp
  25750. From there on, any package depending directly or indirectly on Bash---as
  25751. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  25752. gc})---that is installed is automatically ``rewritten'' to refer to
  25753. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  25754. time proportional to the size of the package, usually less than a
  25755. minute for an ``average'' package on a recent machine. Grafting is
  25756. recursive: when an indirect dependency requires grafting, then grafting
  25757. ``propagates'' up to the package that the user is installing.
  25758. Currently, the length of the name and version of the graft and that of
  25759. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  25760. above) must be equal. This restriction mostly comes from the fact that
  25761. grafting works by patching files, including binary files, directly.
  25762. Other restrictions may apply: for instance, when adding a graft to a
  25763. package providing a shared library, the original shared library and its
  25764. replacement must have the same @code{SONAME} and be binary-compatible.
  25765. The @option{--no-grafts} command-line option allows you to forcefully
  25766. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  25767. Thus, the command:
  25768. @example
  25769. guix build bash --no-grafts
  25770. @end example
  25771. @noindent
  25772. returns the store file name of the original Bash, whereas:
  25773. @example
  25774. guix build bash
  25775. @end example
  25776. @noindent
  25777. returns the store file name of the ``fixed'', replacement Bash. This
  25778. allows you to distinguish between the two variants of Bash.
  25779. To verify which Bash your whole profile refers to, you can run
  25780. (@pxref{Invoking guix gc}):
  25781. @example
  25782. guix gc -R `readlink -f ~/.guix-profile` | grep bash
  25783. @end example
  25784. @noindent
  25785. @dots{} and compare the store file names that you get with those above.
  25786. Likewise for a complete Guix system generation:
  25787. @example
  25788. guix gc -R `guix system build my-config.scm` | grep bash
  25789. @end example
  25790. Lastly, to check which Bash running processes are using, you can use the
  25791. @command{lsof} command:
  25792. @example
  25793. lsof | grep /gnu/store/.*bash
  25794. @end example
  25795. @node Bootstrapping
  25796. @chapter Bootstrapping
  25797. @c Adapted from the ELS 2013 paper.
  25798. @cindex bootstrapping
  25799. Bootstrapping in our context refers to how the distribution gets built
  25800. ``from nothing''. Remember that the build environment of a derivation
  25801. contains nothing but its declared inputs (@pxref{Introduction}). So
  25802. there's an obvious chicken-and-egg problem: how does the first package
  25803. get built? How does the first compiler get compiled?
  25804. It is tempting to think of this question as one that only die-hard
  25805. hackers may care about. However, while the answer to that question is
  25806. technical in nature, its implications are wide-ranging. How the
  25807. distribution is bootstrapped defines the extent to which we, as
  25808. individuals and as a collective of users and hackers, can trust the
  25809. software we run. It is a central concern from the standpoint of
  25810. @emph{security} and from a @emph{user freedom} viewpoint.
  25811. @cindex bootstrap binaries
  25812. The GNU system is primarily made of C code, with libc at its core. The
  25813. GNU build system itself assumes the availability of a Bourne shell and
  25814. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  25815. `grep'. Furthermore, build programs---programs that run
  25816. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  25817. (@pxref{Derivations}). Consequently, to be able to build anything at
  25818. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  25819. Binutils, libc, and the other packages mentioned above---the
  25820. @dfn{bootstrap binaries}.
  25821. These bootstrap binaries are ``taken for granted'', though we can also
  25822. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  25823. Binaries}).
  25824. @menu
  25825. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  25826. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  25827. @end menu
  25828. @node Reduced Binary Seed Bootstrap
  25829. @section The Reduced Binary Seed Bootstrap
  25830. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  25831. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  25832. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  25833. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  25834. ``taken for granted.''
  25835. Taking the bootstrap binaries for granted means that we consider them to
  25836. be a correct and trustworthy ``seed'' for building the complete system.
  25837. Therein lies a problem: the combined size of these bootstrap binaries is
  25838. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  25839. or even inspecting these is next to impossible.
  25840. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  25841. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  25842. Source Bootstrap'' and while we are working towards that goal it would
  25843. be hyperbole to use that term for what we do now.}.
  25844. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  25845. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  25846. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  25847. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  25848. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  25849. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  25850. C Library are built from source. From here on the more traditional
  25851. bootstrap process resumes. This approach has reduced the bootstrap
  25852. binaries in size to about 145MB in Guix v1.1.
  25853. The next step that Guix has taken is to replace the shell and all its
  25854. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  25855. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  25856. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  25857. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  25858. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  25859. removed are now built from source.
  25860. Building the GNU System from source is currently only possibly by adding
  25861. some historical GNU packages as intermediate steps@footnote{Packages
  25862. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  25863. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  25864. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  25865. and GNU packages become more bootstrappable again (e.g., new releases of
  25866. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  25867. hard to bootstrap @code{xz}-compression), this set of added packages can
  25868. hopefully be reduced again.
  25869. The graph below shows the resulting dependency graph for
  25870. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  25871. traditional bootstrap of the rest of the Guix System.
  25872. @c ./pre-inst-env guix graph -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' | sed -re 's,((bootstrap-mescc-tools|bootstrap-mes|guile-bootstrap).*shape =) box,\1 ellipse,' > doc/images/gcc-core-mesboot0-graph.dot
  25873. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  25874. The only significant binary bootstrap seeds that remain@footnote{
  25875. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  25876. together with @code{mes}.} are a Scheme intepreter and a Scheme
  25877. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  25878. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  25879. to get Guile running.}.
  25880. This further reduction has brought down the size of the binary seed to
  25881. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  25882. Work is ongoing to remove all binary blobs from our free software
  25883. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  25884. is work to bring these bootstraps to the @code{arm-linux} and
  25885. @code{aarch64-linux} architectures and to the Hurd.
  25886. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  25887. IRC network or discuss on @email{bug-mes@@gnu.org} or
  25888. @email{gash-devel@@nongnu.org}.
  25889. @node Preparing to Use the Bootstrap Binaries
  25890. @section Preparing to Use the Bootstrap Binaries
  25891. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  25892. @c large image, it's hard to scroll. Oh well.
  25893. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  25894. The figure above shows the very beginning of the dependency graph of the
  25895. distribution, corresponding to the package definitions of the @code{(gnu
  25896. packages bootstrap)} module. A similar figure can be generated with
  25897. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  25898. @example
  25899. guix graph -t derivation \
  25900. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  25901. | dot -Tps > gcc.ps
  25902. @end example
  25903. or, for the further Reduced Binary Seed bootstrap
  25904. @example
  25905. guix graph -t derivation \
  25906. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  25907. | dot -Tps > mes.ps
  25908. @end example
  25909. At this level of detail, things are
  25910. slightly complex. First, Guile itself consists of an ELF executable,
  25911. along with many source and compiled Scheme files that are dynamically
  25912. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  25913. tarball shown in this graph. This tarball is part of Guix's ``source''
  25914. distribution, and gets inserted into the store with @code{add-to-store}
  25915. (@pxref{The Store}).
  25916. But how do we write a derivation that unpacks this tarball and adds it
  25917. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  25918. derivation---the first one that gets built---uses @code{bash} as its
  25919. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  25920. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  25921. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  25922. the Guix source distribution, whose sole purpose is to allow the Guile
  25923. tarball to be unpacked.
  25924. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  25925. Guile that can be used to run subsequent build programs. Its first task
  25926. is to download tarballs containing the other pre-built binaries---this
  25927. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  25928. @code{ftp-client.scm} are used for this purpose. The
  25929. @code{module-import.drv} derivations import those modules in a directory
  25930. in the store, using the original layout. The
  25931. @code{module-import-compiled.drv} derivations compile those modules, and
  25932. write them in an output directory with the right layout. This
  25933. corresponds to the @code{#:modules} argument of
  25934. @code{build-expression->derivation} (@pxref{Derivations}).
  25935. Finally, the various tarballs are unpacked by the derivations
  25936. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  25937. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  25938. point we have a working C tool chain.
  25939. @unnumberedsec Building the Build Tools
  25940. Bootstrapping is complete when we have a full tool chain that does not
  25941. depend on the pre-built bootstrap tools discussed above. This
  25942. no-dependency requirement is verified by checking whether the files of
  25943. the final tool chain contain references to the @file{/gnu/store}
  25944. directories of the bootstrap inputs. The process that leads to this
  25945. ``final'' tool chain is described by the package definitions found in
  25946. the @code{(gnu packages commencement)} module.
  25947. The @command{guix graph} command allows us to ``zoom out'' compared to
  25948. the graph above, by looking at the level of package objects instead of
  25949. individual derivations---remember that a package may translate to
  25950. several derivations, typically one derivation to download its source,
  25951. one to build the Guile modules it needs, and one to actually build the
  25952. package from source. The command:
  25953. @example
  25954. guix graph -t bag \
  25955. -e '(@@@@ (gnu packages commencement)
  25956. glibc-final-with-bootstrap-bash)' | xdot -
  25957. @end example
  25958. @noindent
  25959. displays the dependency graph leading to the ``final'' C
  25960. library@footnote{You may notice the @code{glibc-intermediate} label,
  25961. suggesting that it is not @emph{quite} final, but as a good
  25962. approximation, we will consider it final.}, depicted below.
  25963. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  25964. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  25965. The first tool that gets built with the bootstrap binaries is
  25966. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  25967. for all the following packages. From there Findutils and Diffutils get
  25968. built.
  25969. Then come the first-stage Binutils and GCC, built as pseudo cross
  25970. tools---i.e., with @option{--target} equal to @option{--host}. They are
  25971. used to build libc. Thanks to this cross-build trick, this libc is
  25972. guaranteed not to hold any reference to the initial tool chain.
  25973. From there the final Binutils and GCC (not shown above) are built. GCC
  25974. uses @command{ld} from the final Binutils, and links programs against
  25975. the just-built libc. This tool chain is used to build the other
  25976. packages used by Guix and by the GNU Build System: Guile, Bash,
  25977. Coreutils, etc.
  25978. And voilà! At this point we have the complete set of build tools that
  25979. the GNU Build System expects. These are in the @code{%final-inputs}
  25980. variable of the @code{(gnu packages commencement)} module, and are
  25981. implicitly used by any package that uses @code{gnu-build-system}
  25982. (@pxref{Build Systems, @code{gnu-build-system}}).
  25983. @unnumberedsec Building the Bootstrap Binaries
  25984. @cindex bootstrap binaries
  25985. Because the final tool chain does not depend on the bootstrap binaries,
  25986. those rarely need to be updated. Nevertheless, it is useful to have an
  25987. automated way to produce them, should an update occur, and this is what
  25988. the @code{(gnu packages make-bootstrap)} module provides.
  25989. The following command builds the tarballs containing the bootstrap binaries
  25990. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  25991. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  25992. and Guile, and a tarball containing a mixture of Coreutils and other basic
  25993. command-line tools):
  25994. @example
  25995. guix build bootstrap-tarballs
  25996. @end example
  25997. The generated tarballs are those that should be referred to in the
  25998. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  25999. this section.
  26000. Still here? Then perhaps by now you've started to wonder: when do we
  26001. reach a fixed point? That is an interesting question! The answer is
  26002. unknown, but if you would like to investigate further (and have
  26003. significant computational and storage resources to do so), then let us
  26004. know.
  26005. @unnumberedsec Reducing the Set of Bootstrap Binaries
  26006. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  26007. binary code! Why is that a problem? It's a problem because these big chunks
  26008. of binary code are practically non-auditable, which makes it hard to establish
  26009. what source code produced them. Every unauditable binary also leaves us
  26010. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  26011. paper @emph{Reflections on Trusting Trust}.
  26012. This is mitigated by the fact that our bootstrap binaries were generated
  26013. from an earlier Guix revision. Nevertheless it lacks the level of
  26014. transparency that we get in the rest of the package dependency graph,
  26015. where Guix always gives us a source-to-binary mapping. Thus, our goal
  26016. is to reduce the set of bootstrap binaries to the bare minimum.
  26017. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  26018. on-going projects to do that. One of these is about replacing the
  26019. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  26020. of increasing complexity, which could be built from source starting from
  26021. a simple and auditable assembler.
  26022. Our first major achievement is the replacement of of GCC, the GNU C Library
  26023. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  26024. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  26025. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  26026. bootstrapped yet and thus we inject them as binary seeds. We call this the
  26027. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  26028. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  26029. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  26030. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  26031. also looking at any other bootstrap binaries. Your help is welcome!
  26032. @node Porting
  26033. @chapter Porting to a New Platform
  26034. As discussed above, the GNU distribution is self-contained, and
  26035. self-containment is achieved by relying on pre-built ``bootstrap
  26036. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  26037. operating system kernel, CPU architecture, and application binary
  26038. interface (ABI). Thus, to port the distribution to a platform that is
  26039. not yet supported, one must build those bootstrap binaries, and update
  26040. the @code{(gnu packages bootstrap)} module to use them on that platform.
  26041. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  26042. When everything goes well, and assuming the GNU tool chain supports the
  26043. target platform, this can be as simple as running a command like this
  26044. one:
  26045. @example
  26046. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  26047. @end example
  26048. For this to work, the @code{glibc-dynamic-linker} procedure in
  26049. @code{(gnu packages bootstrap)} must be augmented to return the right
  26050. file name for libc's dynamic linker on that platform; likewise,
  26051. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  26052. taught about the new platform.
  26053. Once these are built, the @code{(gnu packages bootstrap)} module needs
  26054. to be updated to refer to these binaries on the target platform. That
  26055. is, the hashes and URLs of the bootstrap tarballs for the new platform
  26056. must be added alongside those of the currently supported platforms. The
  26057. bootstrap Guile tarball is treated specially: it is expected to be
  26058. available locally, and @file{gnu/local.mk} has rules to download it for
  26059. the supported architectures; a rule for the new platform must be added
  26060. as well.
  26061. In practice, there may be some complications. First, it may be that the
  26062. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  26063. above) is not recognized by all the GNU tools. Typically, glibc
  26064. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  26065. configure flag (see @code{gcc.scm} for examples of how to handle this).
  26066. Second, some of the required packages could fail to build for that
  26067. platform. Lastly, the generated binaries could be broken for some
  26068. reason.
  26069. @c *********************************************************************
  26070. @include contributing.texi
  26071. @c *********************************************************************
  26072. @node Acknowledgments
  26073. @chapter Acknowledgments
  26074. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  26075. which was designed and
  26076. implemented by Eelco Dolstra, with contributions from other people (see
  26077. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  26078. management, and promoted unprecedented features, such as transactional
  26079. package upgrades and rollbacks, per-user profiles, and referentially
  26080. transparent build processes. Without this work, Guix would not exist.
  26081. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  26082. an inspiration for Guix.
  26083. GNU@tie{}Guix itself is a collective work with contributions from a
  26084. number of people. See the @file{AUTHORS} file in Guix for more
  26085. information on these fine people. The @file{THANKS} file lists people
  26086. who have helped by reporting bugs, taking care of the infrastructure,
  26087. providing artwork and themes, making suggestions, and more---thank you!
  26088. @c *********************************************************************
  26089. @node GNU Free Documentation License
  26090. @appendix GNU Free Documentation License
  26091. @cindex license, GNU Free Documentation License
  26092. @include fdl-1.3.texi
  26093. @c *********************************************************************
  26094. @node Concept Index
  26095. @unnumbered Concept Index
  26096. @printindex cp
  26097. @node Programming Index
  26098. @unnumbered Programming Index
  26099. @syncodeindex tp fn
  26100. @syncodeindex vr fn
  26101. @printindex fn
  26102. @bye
  26103. @c Local Variables:
  26104. @c ispell-local-dictionary: "american";
  26105. @c End: