guix.texi 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615
  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 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 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 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 Maxime Devos@*
  79. Permission is granted to copy, distribute and/or modify this document
  80. under the terms of the GNU Free Documentation License, Version 1.3 or
  81. any later version published by the Free Software Foundation; with no
  82. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  83. copy of the license is included in the section entitled ``GNU Free
  84. Documentation License''.
  85. @end copying
  86. @dircategory System administration
  87. @direntry
  88. * Guix: (guix). Manage installed software and system configuration.
  89. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  90. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  91. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  92. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  93. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  94. @end direntry
  95. @dircategory Software development
  96. @direntry
  97. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  98. * guix build: (guix)Invoking guix build. Building packages.
  99. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  100. @end direntry
  101. @titlepage
  102. @title GNU Guix Reference Manual
  103. @subtitle Using the GNU Guix Functional Package Manager
  104. @author The GNU Guix Developers
  105. @page
  106. @vskip 0pt plus 1filll
  107. Edition @value{EDITION} @*
  108. @value{UPDATED} @*
  109. @insertcopying
  110. @end titlepage
  111. @contents
  112. @c *********************************************************************
  113. @node Top
  114. @top GNU Guix
  115. This document describes GNU Guix version @value{VERSION}, a functional
  116. package management tool written for the GNU system.
  117. @c TRANSLATORS: You can replace the following paragraph with information on
  118. @c how to join your own translation team and how to report issues with the
  119. @c translation.
  120. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  121. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  122. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  123. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  124. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  125. would like to translate it in your native language, consider joining the
  126. @uref{https://translationproject.org/domain/guix-manual.html, Translation
  127. Project}.
  128. @menu
  129. * Introduction:: What is Guix about?
  130. * Installation:: Installing Guix.
  131. * System Installation:: Installing the whole operating system.
  132. * Getting Started:: Your first steps.
  133. * Package Management:: Package installation, upgrade, etc.
  134. * Channels:: Customizing the package collection.
  135. * Development:: Guix-aided software development.
  136. * Programming Interface:: Using Guix in Scheme.
  137. * Utilities:: Package management commands.
  138. * System Configuration:: Configuring the operating system.
  139. * Documentation:: Browsing software user manuals.
  140. * Installing Debugging Files:: Feeding the debugger.
  141. * Security Updates:: Deploying security fixes quickly.
  142. * Bootstrapping:: GNU/Linux built from scratch.
  143. * Porting:: Targeting another platform or kernel.
  144. * Contributing:: Your help needed!
  145. * Acknowledgments:: Thanks!
  146. * GNU Free Documentation License:: The license of this manual.
  147. * Concept Index:: Concepts.
  148. * Programming Index:: Data types, functions, and variables.
  149. @detailmenu
  150. --- The Detailed Node Listing ---
  151. Introduction
  152. * Managing Software the Guix Way:: What's special.
  153. * GNU Distribution:: The packages and tools.
  154. Installation
  155. * Binary Installation:: Getting Guix running in no time!
  156. * Requirements:: Software needed to build and run Guix.
  157. * Running the Test Suite:: Testing Guix.
  158. * Setting Up the Daemon:: Preparing the build daemon's environment.
  159. * Invoking guix-daemon:: Running the build daemon.
  160. * Application Setup:: Application-specific setup.
  161. * Upgrading Guix:: Upgrading Guix and its build daemon.
  162. Setting Up the Daemon
  163. * Build Environment Setup:: Preparing the isolated build environment.
  164. * Daemon Offload Setup:: Offloading builds to remote machines.
  165. * SELinux Support:: Using an SELinux policy for the daemon.
  166. System Installation
  167. * Limitations:: What you can expect.
  168. * Hardware Considerations:: Supported hardware.
  169. * USB Stick and DVD Installation:: Preparing the installation medium.
  170. * Preparing for Installation:: Networking, partitioning, etc.
  171. * Guided Graphical Installation:: Easy graphical installation.
  172. * Manual Installation:: Manual installation for wizards.
  173. * After System Installation:: When installation succeeded.
  174. * Installing Guix in a VM:: Guix System playground.
  175. * Building the Installation Image:: How this comes to be.
  176. Manual Installation
  177. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  178. * Proceeding with the Installation:: Installing.
  179. Package Management
  180. * Features:: How Guix will make your life brighter.
  181. * Invoking guix package:: Package installation, removal, etc.
  182. * Substitutes:: Downloading pre-built binaries.
  183. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  184. * Invoking guix gc:: Running the garbage collector.
  185. * Invoking guix pull:: Fetching the latest Guix and distribution.
  186. * Invoking guix time-machine:: Running an older revision of Guix.
  187. * Inferiors:: Interacting with another revision of Guix.
  188. * Invoking guix describe:: Display information about your Guix revision.
  189. * Invoking guix archive:: Exporting and importing store files.
  190. Substitutes
  191. * Official Substitute Server:: One particular source of substitutes.
  192. * Substitute Server Authorization:: How to enable or disable substitutes.
  193. * Substitute Authentication:: How Guix verifies substitutes.
  194. * Proxy Settings:: How to get substitutes via proxy.
  195. * Substitution Failure:: What happens when substitution fails.
  196. * On Trusting Binaries:: How can you trust that binary blob?
  197. Channels
  198. * Specifying Additional Channels:: Extending the package collection.
  199. * Using a Custom Guix Channel:: Using a customized Guix.
  200. * Replicating Guix:: Running the @emph{exact same} Guix.
  201. * Channel Authentication:: How Guix verifies what it fetches.
  202. * Creating a Channel:: How to write your custom channel.
  203. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  204. * Declaring Channel Dependencies:: How to depend on other channels.
  205. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  206. * Primary URL:: Distinguishing mirror to original.
  207. * Writing Channel News:: Communicating information to channel's users.
  208. Development
  209. * Invoking guix environment:: Setting up development environments.
  210. * Invoking guix pack:: Creating software bundles.
  211. * The GCC toolchain:: Working with languages supported by GCC.
  212. * Invoking guix git authenticate:: Authenticating Git repositories.
  213. Programming Interface
  214. * Package Modules:: Packages from the programmer's viewpoint.
  215. * Defining Packages:: Defining new packages.
  216. * Build Systems:: Specifying how packages are built.
  217. * The Store:: Manipulating the package store.
  218. * Derivations:: Low-level interface to package derivations.
  219. * The Store Monad:: Purely functional interface to the store.
  220. * G-Expressions:: Manipulating build expressions.
  221. * Invoking guix repl:: Programming Guix in Guile
  222. Defining Packages
  223. * package Reference:: The package data type.
  224. * origin Reference:: The origin data type.
  225. Utilities
  226. * Invoking guix build:: Building packages from the command line.
  227. * Invoking guix edit:: Editing package definitions.
  228. * Invoking guix download:: Downloading a file and printing its hash.
  229. * Invoking guix hash:: Computing the cryptographic hash of a file.
  230. * Invoking guix import:: Importing package definitions.
  231. * Invoking guix refresh:: Updating package definitions.
  232. * Invoking guix lint:: Finding errors in package definitions.
  233. * Invoking guix size:: Profiling disk usage.
  234. * Invoking guix graph:: Visualizing the graph of packages.
  235. * Invoking guix publish:: Sharing substitutes.
  236. * Invoking guix challenge:: Challenging substitute servers.
  237. * Invoking guix copy:: Copying to and from a remote store.
  238. * Invoking guix container:: Process isolation.
  239. * Invoking guix weather:: Assessing substitute availability.
  240. * Invoking guix processes:: Listing client processes.
  241. Invoking @command{guix build}
  242. * Common Build Options:: Build options for most commands.
  243. * Package Transformation Options:: Creating variants of packages.
  244. * Additional Build Options:: Options specific to 'guix build'.
  245. * Debugging Build Failures:: Real life packaging experience.
  246. System Configuration
  247. * Using the Configuration System:: Customizing your GNU system.
  248. * operating-system Reference:: Detail of operating-system declarations.
  249. * File Systems:: Configuring file system mounts.
  250. * Mapped Devices:: Block device extra processing.
  251. * User Accounts:: Specifying user accounts.
  252. * Keyboard Layout:: How the system interprets key strokes.
  253. * Locales:: Language and cultural convention settings.
  254. * Services:: Specifying system services.
  255. * Setuid Programs:: Programs running with root privileges.
  256. * X.509 Certificates:: Authenticating HTTPS servers.
  257. * Name Service Switch:: Configuring libc's name service switch.
  258. * Initial RAM Disk:: Linux-Libre bootstrapping.
  259. * Bootloader Configuration:: Configuring the boot loader.
  260. * Invoking guix system:: Instantiating a system configuration.
  261. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  262. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  263. * Defining Services:: Adding new service definitions.
  264. Services
  265. * Base Services:: Essential system services.
  266. * Scheduled Job Execution:: The mcron service.
  267. * Log Rotation:: The rottlog service.
  268. * Networking Services:: Network setup, SSH daemon, etc.
  269. * Unattended Upgrades:: Automated system upgrades.
  270. * X Window:: Graphical display.
  271. * Printing Services:: Local and remote printer support.
  272. * Desktop Services:: D-Bus and desktop services.
  273. * Sound Services:: ALSA and Pulseaudio services.
  274. * Database Services:: SQL databases, key-value stores, etc.
  275. * Mail Services:: IMAP, POP3, SMTP, and all that.
  276. * Messaging Services:: Messaging services.
  277. * Telephony Services:: Telephony services.
  278. * Monitoring Services:: Monitoring services.
  279. * Kerberos Services:: Kerberos services.
  280. * LDAP Services:: LDAP services.
  281. * Web Services:: Web servers.
  282. * Certificate Services:: TLS certificates via Let's Encrypt.
  283. * DNS Services:: DNS daemons.
  284. * VPN Services:: VPN daemons.
  285. * Network File System:: NFS related services.
  286. * Continuous Integration:: The Cuirass service.
  287. * Power Management Services:: Extending battery life.
  288. * Audio Services:: The MPD.
  289. * Virtualization Services:: Virtualization services.
  290. * Version Control Services:: Providing remote access to Git repositories.
  291. * Game Services:: Game servers.
  292. * PAM Mount Service:: Service to mount volumes when logging in.
  293. * Guix Services:: Services relating specifically to Guix.
  294. * Linux Services:: Services tied to the Linux kernel.
  295. * Hurd Services:: Services specific for a Hurd System.
  296. * Miscellaneous Services:: Other services.
  297. Defining Services
  298. * Service Composition:: The model for composing services.
  299. * Service Types and Services:: Types and services.
  300. * Service Reference:: API reference.
  301. * Shepherd Services:: A particular type of service.
  302. Bootstrapping
  303. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  304. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  305. @end detailmenu
  306. @end menu
  307. @c *********************************************************************
  308. @node Introduction
  309. @chapter Introduction
  310. @cindex purpose
  311. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  312. using the international phonetic alphabet (IPA).} is a package
  313. management tool for and distribution of the GNU system.
  314. Guix makes it easy for unprivileged
  315. users to install, upgrade, or remove software packages, to roll back to a
  316. previous package set, to build packages from source, and generally
  317. assists with the creation and maintenance of software environments.
  318. @cindex Guix System
  319. @cindex GuixSD, now Guix System
  320. @cindex Guix System Distribution, now Guix System
  321. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  322. complements the available tools without interference (@pxref{Installation}),
  323. or you can use it as a standalone operating system distribution,
  324. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  325. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  326. group everything under the ``Guix'' banner since, after all, Guix System is
  327. readily available through the @command{guix system} command, even if you're
  328. using a different distro underneath!}. @xref{GNU Distribution}.
  329. @menu
  330. * Managing Software the Guix Way:: What's special.
  331. * GNU Distribution:: The packages and tools.
  332. @end menu
  333. @node Managing Software the Guix Way
  334. @section Managing Software the Guix Way
  335. @cindex user interfaces
  336. Guix provides a command-line package management interface
  337. (@pxref{Package Management}), tools to help with software development
  338. (@pxref{Development}), command-line utilities for more advanced usage,
  339. (@pxref{Utilities}), as well as Scheme programming interfaces
  340. (@pxref{Programming Interface}).
  341. @cindex build daemon
  342. Its @dfn{build daemon} is responsible for building packages on behalf of
  343. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  344. binaries from authorized sources (@pxref{Substitutes}).
  345. @cindex extensibility of the distribution
  346. @cindex customization, of packages
  347. Guix includes package definitions for many GNU and non-GNU packages, all
  348. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  349. user's computing freedom}. It is @emph{extensible}: users can write
  350. their own package definitions (@pxref{Defining Packages}) and make them
  351. available as independent package modules (@pxref{Package Modules}). It
  352. is also @emph{customizable}: users can @emph{derive} specialized package
  353. definitions from existing ones, including from the command line
  354. (@pxref{Package Transformation Options}).
  355. @cindex functional package management
  356. @cindex isolation
  357. Under the hood, Guix implements the @dfn{functional package management}
  358. discipline pioneered by Nix (@pxref{Acknowledgments}).
  359. In Guix, the package build and installation process is seen
  360. as a @emph{function}, in the mathematical sense. That function takes inputs,
  361. such as build scripts, a compiler, and libraries, and
  362. returns an installed package. As a pure function, its result depends
  363. solely on its inputs---for instance, it cannot refer to software or
  364. scripts that were not explicitly passed as inputs. A build function
  365. always produces the same result when passed a given set of inputs. It
  366. cannot alter the environment of the running system in
  367. any way; for instance, it cannot create, modify, or delete files outside
  368. of its build and installation directories. This is achieved by running
  369. build processes in isolated environments (or @dfn{containers}), where only their
  370. explicit inputs are visible.
  371. @cindex store
  372. The result of package build functions is @dfn{cached} in the file
  373. system, in a special directory called @dfn{the store} (@pxref{The
  374. Store}). Each package is installed in a directory of its own in the
  375. store---by default under @file{/gnu/store}. The directory name contains
  376. a hash of all the inputs used to build that package; thus, changing an
  377. input yields a different directory name.
  378. This approach is the foundation for the salient features of Guix: support
  379. for transactional package upgrade and rollback, per-user installation, and
  380. garbage collection of packages (@pxref{Features}).
  381. @node GNU Distribution
  382. @section GNU Distribution
  383. @cindex Guix System
  384. Guix comes with a distribution of the GNU system consisting entirely of
  385. free software@footnote{The term ``free'' here refers to the
  386. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  387. users of that software}.}. The
  388. distribution can be installed on its own (@pxref{System Installation}),
  389. but it is also possible to install Guix as a package manager on top of
  390. an installed GNU/Linux system (@pxref{Installation}). When we need to
  391. distinguish between the two, we refer to the standalone distribution as
  392. Guix@tie{}System.
  393. The distribution provides core GNU packages such as GNU libc, GCC, and
  394. Binutils, as well as many GNU and non-GNU applications. The complete
  395. list of available packages can be browsed
  396. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  397. running @command{guix package} (@pxref{Invoking guix package}):
  398. @example
  399. guix package --list-available
  400. @end example
  401. Our goal is to provide a practical 100% free software distribution of
  402. Linux-based and other variants of GNU, with a focus on the promotion and
  403. tight integration of GNU components, and an emphasis on programs and
  404. tools that help users exert that freedom.
  405. Packages are currently available on the following platforms:
  406. @table @code
  407. @item x86_64-linux
  408. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
  409. @item i686-linux
  410. Intel 32-bit architecture (IA32), Linux-Libre kernel;
  411. @item armhf-linux
  412. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  413. using the EABI hard-float application binary interface (ABI),
  414. and Linux-Libre kernel.
  415. @item aarch64-linux
  416. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  417. @item mips64el-linux (deprecated)
  418. little-endian 64-bit MIPS processors, specifically the Loongson series,
  419. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  420. supported; in particular, there is no ongoing work to ensure that this
  421. architecture still works. Should someone decide they wish to revive this
  422. architecture then the code is still available.
  423. @end table
  424. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  425. configuration and Guix takes care of instantiating the configuration in a
  426. transactional, reproducible, and stateless fashion (@pxref{System
  427. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  428. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  429. Manual}), the well-known GNU utilities and tool chain, as well as the
  430. graphical environment or system services of your choice.
  431. Guix System is available on all the above platforms except
  432. @code{mips64el-linux}.
  433. @noindent
  434. For information on porting to other architectures or kernels,
  435. @pxref{Porting}.
  436. Building this distribution is a cooperative effort, and you are invited
  437. to join! @xref{Contributing}, for information about how you can help.
  438. @c *********************************************************************
  439. @node Installation
  440. @chapter Installation
  441. @cindex installing Guix
  442. @quotation Note
  443. We recommend the use of this
  444. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  445. shell installer script} to install Guix on top of a running GNU/Linux system,
  446. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  447. with the installation of the package manager, which can be done on top of a
  448. running GNU/Linux system. If, instead, you want to install the complete GNU
  449. operating system, @pxref{System Installation}.} The script automates the
  450. download, installation, and initial configuration of Guix. It should be run
  451. as the root user.
  452. @end quotation
  453. @cindex foreign distro
  454. @cindex directories related to foreign distro
  455. When installed on a foreign distro, GNU@tie{}Guix complements the available
  456. tools without interference. Its data lives exclusively in two directories,
  457. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  458. such as @file{/etc}, are left untouched.
  459. Once installed, Guix can be updated by running @command{guix pull}
  460. (@pxref{Invoking guix pull}).
  461. If you prefer to perform the installation steps manually or want to tweak
  462. them, you may find the following subsections useful. They describe the
  463. software requirements of Guix, as well as how to install it manually and get
  464. ready to use it.
  465. @menu
  466. * Binary Installation:: Getting Guix running in no time!
  467. * Requirements:: Software needed to build and run Guix.
  468. * Running the Test Suite:: Testing Guix.
  469. * Setting Up the Daemon:: Preparing the build daemon's environment.
  470. * Invoking guix-daemon:: Running the build daemon.
  471. * Application Setup:: Application-specific setup.
  472. * Upgrading Guix:: Upgrading Guix and its build daemon.
  473. @end menu
  474. @node Binary Installation
  475. @section Binary Installation
  476. @cindex installing Guix from binaries
  477. @cindex installer script
  478. This section describes how to install Guix on an arbitrary system from a
  479. self-contained tarball providing binaries for Guix and for all its
  480. dependencies. This is often quicker than installing from source, which
  481. is described in the next sections. The only requirement is to have
  482. GNU@tie{}tar and Xz.
  483. @c Note duplicated from the ``Installation'' node.
  484. @quotation Note
  485. We recommend the use of this
  486. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  487. shell installer script}. The script automates the download, installation, and
  488. initial configuration steps described below. It should be run as the root
  489. user. As root, you can thus run this:
  490. @example
  491. cd /tmp
  492. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  493. chmod +x guix-install.sh
  494. ./guix-install.sh
  495. @end example
  496. When you're done, @pxref{Application Setup} for extra configuration you
  497. might need, and @ref{Getting Started} for your first steps!
  498. @end quotation
  499. Installing goes along these lines:
  500. @enumerate
  501. @item
  502. @cindex downloading Guix binary
  503. Download the binary tarball from
  504. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  505. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  506. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  507. (@pxref{GNU Distribution}).
  508. @c The following is somewhat duplicated in ``System Installation''.
  509. Make sure to download the associated @file{.sig} file and to verify the
  510. authenticity of the tarball against it, along these lines:
  511. @example
  512. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  513. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  514. @end example
  515. If that command fails because you do not have the required public key,
  516. then run this command to import it:
  517. @example
  518. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  519. -qO - | gpg --import -
  520. @end example
  521. @noindent
  522. and rerun the @code{gpg --verify} command.
  523. Take note that a warning like ``This key is not certified with a trusted
  524. signature!'' is normal.
  525. @c end authentication part
  526. @item
  527. Now, you need to become the @code{root} user. Depending on your distribution,
  528. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  529. @example
  530. # cd /tmp
  531. # tar --warning=no-timestamp -xf \
  532. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  533. # mv var/guix /var/ && mv gnu /
  534. @end example
  535. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  536. The latter contains a ready-to-use profile for @code{root} (see next
  537. step).
  538. Do @emph{not} unpack the tarball on a working Guix system since that
  539. would overwrite its own essential files.
  540. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  541. not emit warnings about ``implausibly old time stamps'' (such
  542. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  543. versions are fine).
  544. They stem from the fact that all the
  545. files in the archive have their modification time set to zero (which
  546. means January 1st, 1970). This is done on purpose to make sure the
  547. archive content is independent of its creation time, thus making it
  548. reproducible.
  549. @item
  550. Make the profile available under @file{~root/.config/guix/current}, which is
  551. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  552. @example
  553. # mkdir -p ~root/.config/guix
  554. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  555. ~root/.config/guix/current
  556. @end example
  557. Source @file{etc/profile} to augment @env{PATH} and other relevant
  558. environment variables:
  559. @example
  560. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  561. source $GUIX_PROFILE/etc/profile
  562. @end example
  563. @item
  564. Create the group and user accounts for build users as explained below
  565. (@pxref{Build Environment Setup}).
  566. @item
  567. Run the daemon, and set it to automatically start on boot.
  568. If your host distro uses the systemd init system, this can be achieved
  569. with these commands:
  570. @c Versions of systemd that supported symlinked service files are not
  571. @c yet widely deployed, so we should suggest that users copy the service
  572. @c files into place.
  573. @c
  574. @c See this thread for more information:
  575. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  576. @example
  577. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  578. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  579. /etc/systemd/system/
  580. # systemctl enable --now gnu-store.mount guix-daemon
  581. @end example
  582. If your host distro uses the Upstart init system:
  583. @example
  584. # initctl reload-configuration
  585. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  586. /etc/init/
  587. # start guix-daemon
  588. @end example
  589. Otherwise, you can still start the daemon manually with:
  590. @example
  591. # ~root/.config/guix/current/bin/guix-daemon \
  592. --build-users-group=guixbuild
  593. @end example
  594. @item
  595. Make the @command{guix} command available to other users on the machine,
  596. for instance with:
  597. @example
  598. # mkdir -p /usr/local/bin
  599. # cd /usr/local/bin
  600. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  601. @end example
  602. It is also a good idea to make the Info version of this manual available
  603. there:
  604. @example
  605. # mkdir -p /usr/local/share/info
  606. # cd /usr/local/share/info
  607. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  608. do ln -s $i ; done
  609. @end example
  610. That way, assuming @file{/usr/local/share/info} is in the search path,
  611. running @command{info guix} will open this manual (@pxref{Other Info
  612. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  613. Info search path).
  614. @item
  615. @cindex substitutes, authorization thereof
  616. To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
  617. (@pxref{Substitutes}), authorize them:
  618. @example
  619. # guix archive --authorize < \
  620. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
  621. @end example
  622. @item
  623. Each user may need to perform a few additional steps to make their Guix
  624. environment ready for use, @pxref{Application Setup}.
  625. @end enumerate
  626. Voilà, the installation is complete!
  627. You can confirm that Guix is working by installing a sample package into
  628. the root profile:
  629. @example
  630. # guix install hello
  631. @end example
  632. The binary installation tarball can be (re)produced and verified simply
  633. by running the following command in the Guix source tree:
  634. @example
  635. make guix-binary.@var{system}.tar.xz
  636. @end example
  637. @noindent
  638. ...@: which, in turn, runs:
  639. @example
  640. guix pack -s @var{system} --localstatedir \
  641. --profile-name=current-guix guix
  642. @end example
  643. @xref{Invoking guix pack}, for more info on this handy tool.
  644. @node Requirements
  645. @section Requirements
  646. This section lists requirements when building Guix from source. The
  647. build procedure for Guix is the same as for other GNU software, and is
  648. not covered here. Please see the files @file{README} and @file{INSTALL}
  649. in the Guix source tree for additional details.
  650. @cindex official website
  651. GNU Guix is available for download from its website at
  652. @url{https://www.gnu.org/software/guix/}.
  653. GNU Guix depends on the following packages:
  654. @itemize
  655. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x or
  656. 2.2.x;
  657. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  658. 0.1.0 or later;
  659. @item
  660. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  661. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  662. Guile,, gnutls-guile, GnuTLS-Guile});
  663. @item
  664. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  665. or later;
  666. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib};
  667. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  668. @item
  669. @c FIXME: Specify a version number once a release has been made.
  670. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
  671. 2017 or later;
  672. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  673. 4.3.0 or later;
  674. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  675. @end itemize
  676. The following dependencies are optional:
  677. @itemize
  678. @item
  679. @c Note: We need at least 0.13.0 for #:nodelay.
  680. Support for build offloading (@pxref{Daemon Offload Setup}) and
  681. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  682. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  683. version 0.13.0 or later.
  684. @item
  685. When @url{https://www.nongnu.org/lzip/lzlib.html, lzlib} is available, lzlib
  686. substitutes can be used and @command{guix publish} can compress substitutes
  687. with lzlib.
  688. @item
  689. When @url{http://www.bzip.org, libbz2} is available,
  690. @command{guix-daemon} can use it to compress build logs.
  691. @end itemize
  692. Unless @option{--disable-daemon} was passed to @command{configure}, the
  693. following packages are also needed:
  694. @itemize
  695. @item @url{https://gnupg.org/, GNU libgcrypt};
  696. @item @url{https://sqlite.org, SQLite 3};
  697. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  698. C++11 standard.
  699. @end itemize
  700. @cindex state directory
  701. When configuring Guix on a system that already has a Guix installation,
  702. be sure to specify the same state directory as the existing installation
  703. using the @option{--localstatedir} option of the @command{configure}
  704. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  705. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  706. set to the value @file{/var}. The @command{configure} script protects
  707. against unintended misconfiguration of @var{localstatedir} so you do not
  708. inadvertently corrupt your store (@pxref{The Store}).
  709. @node Running the Test Suite
  710. @section Running the Test Suite
  711. @cindex test suite
  712. After a successful @command{configure} and @code{make} run, it is a good
  713. idea to run the test suite. It can help catch issues with the setup or
  714. environment, or bugs in Guix itself---and really, reporting test
  715. failures is a good way to help improve the software. To run the test
  716. suite, type:
  717. @example
  718. make check
  719. @end example
  720. Test cases can run in parallel: you can use the @code{-j} option of
  721. GNU@tie{}make to speed things up. The first run may take a few minutes
  722. on a recent machine; subsequent runs will be faster because the store
  723. that is created for test purposes will already have various things in
  724. cache.
  725. It is also possible to run a subset of the tests by defining the
  726. @code{TESTS} makefile variable as in this example:
  727. @example
  728. make check TESTS="tests/store.scm tests/cpio.scm"
  729. @end example
  730. By default, tests results are displayed at a file level. In order to
  731. see the details of every individual test cases, it is possible to define
  732. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  733. @example
  734. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  735. @end example
  736. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  737. @file{test-suite.log} file. Please specify the Guix version being used
  738. as well as version numbers of the dependencies (@pxref{Requirements}) in
  739. your message.
  740. Guix also comes with a whole-system test suite that tests complete
  741. Guix System instances. It can only run on systems where
  742. Guix is already installed, using:
  743. @example
  744. make check-system
  745. @end example
  746. @noindent
  747. or, again, by defining @code{TESTS} to select a subset of tests to run:
  748. @example
  749. make check-system TESTS="basic mcron"
  750. @end example
  751. These system tests are defined in the @code{(gnu tests @dots{})}
  752. modules. They work by running the operating systems under test with
  753. lightweight instrumentation in a virtual machine (VM). They can be
  754. computationally intensive or rather cheap, depending on whether
  755. substitutes are available for their dependencies (@pxref{Substitutes}).
  756. Some of them require a lot of storage space to hold VM images.
  757. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  758. all the details.
  759. @node Setting Up the Daemon
  760. @section Setting Up the Daemon
  761. @cindex daemon
  762. Operations such as building a package or running the garbage collector
  763. are all performed by a specialized process, the @dfn{build daemon}, on
  764. behalf of clients. Only the daemon may access the store and its
  765. associated database. Thus, any operation that manipulates the store
  766. goes through the daemon. For instance, command-line tools such as
  767. @command{guix package} and @command{guix build} communicate with the
  768. daemon (@i{via} remote procedure calls) to instruct it what to do.
  769. The following sections explain how to prepare the build daemon's
  770. environment. See also @ref{Substitutes}, for information on how to allow
  771. the daemon to download pre-built binaries.
  772. @menu
  773. * Build Environment Setup:: Preparing the isolated build environment.
  774. * Daemon Offload Setup:: Offloading builds to remote machines.
  775. * SELinux Support:: Using an SELinux policy for the daemon.
  776. @end menu
  777. @node Build Environment Setup
  778. @subsection Build Environment Setup
  779. @cindex build environment
  780. In a standard multi-user setup, Guix and its daemon---the
  781. @command{guix-daemon} program---are installed by the system
  782. administrator; @file{/gnu/store} is owned by @code{root} and
  783. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  784. Guix tools to build packages or otherwise access the store, and the
  785. daemon will do it on their behalf, ensuring that the store is kept in a
  786. consistent state, and allowing built packages to be shared among users.
  787. @cindex build users
  788. When @command{guix-daemon} runs as @code{root}, you may not want package
  789. build processes themselves to run as @code{root} too, for obvious
  790. security reasons. To avoid that, a special pool of @dfn{build users}
  791. should be created for use by build processes started by the daemon.
  792. These build users need not have a shell and a home directory: they will
  793. just be used when the daemon drops @code{root} privileges in build
  794. processes. Having several such users allows the daemon to launch
  795. distinct build processes under separate UIDs, which guarantees that they
  796. do not interfere with each other---an essential feature since builds are
  797. regarded as pure functions (@pxref{Introduction}).
  798. On a GNU/Linux system, a build user pool may be created like this (using
  799. Bash syntax and the @code{shadow} commands):
  800. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  801. @c for why `-G' is needed.
  802. @example
  803. # groupadd --system guixbuild
  804. # for i in `seq -w 1 10`;
  805. do
  806. useradd -g guixbuild -G guixbuild \
  807. -d /var/empty -s `which nologin` \
  808. -c "Guix build user $i" --system \
  809. guixbuilder$i;
  810. done
  811. @end example
  812. @noindent
  813. The number of build users determines how many build jobs may run in
  814. parallel, as specified by the @option{--max-jobs} option
  815. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  816. @command{guix system vm} and related commands, you may need to add the
  817. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  818. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  819. (@pxref{Invoking guix system}).
  820. The @code{guix-daemon} program may then be run as @code{root} with the
  821. following command@footnote{If your machine uses the systemd init system,
  822. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  823. file in @file{/etc/systemd/system} will ensure that
  824. @command{guix-daemon} is automatically started. Similarly, if your
  825. machine uses the Upstart init system, drop the
  826. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  827. file in @file{/etc/init}.}:
  828. @example
  829. # guix-daemon --build-users-group=guixbuild
  830. @end example
  831. @cindex chroot
  832. @noindent
  833. This way, the daemon starts build processes in a chroot, under one of
  834. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  835. environment contains nothing but:
  836. @c Keep this list in sync with libstore/build.cc! -----------------------
  837. @itemize
  838. @item
  839. a minimal @code{/dev} directory, created mostly independently from the
  840. host @code{/dev}@footnote{``Mostly'', because while the set of files
  841. that appear in the chroot's @code{/dev} is fixed, most of these files
  842. can only be created if the host has them.};
  843. @item
  844. the @code{/proc} directory; it only shows the processes of the container
  845. since a separate PID name space is used;
  846. @item
  847. @file{/etc/passwd} with an entry for the current user and an entry for
  848. user @file{nobody};
  849. @item
  850. @file{/etc/group} with an entry for the user's group;
  851. @item
  852. @file{/etc/hosts} with an entry that maps @code{localhost} to
  853. @code{127.0.0.1};
  854. @item
  855. a writable @file{/tmp} directory.
  856. @end itemize
  857. You can influence the directory where the daemon stores build trees
  858. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  859. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  860. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  861. This way, the value of @env{TMPDIR} does not leak inside build
  862. environments, which avoids discrepancies in cases where build processes
  863. capture the name of their build tree.
  864. @vindex http_proxy
  865. @vindex https_proxy
  866. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  867. environment variables for HTTP and HTTPS downloads it performs, be it
  868. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  869. (@pxref{Substitutes}).
  870. If you are installing Guix as an unprivileged user, it is still possible
  871. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  872. However, build processes will not be isolated from one another, and not
  873. from the rest of the system. Thus, build processes may interfere with
  874. each other, and may access programs, libraries, and other files
  875. available on the system---making it much harder to view them as
  876. @emph{pure} functions.
  877. @node Daemon Offload Setup
  878. @subsection Using the Offload Facility
  879. @cindex offloading
  880. @cindex build hook
  881. When desired, the build daemon can @dfn{offload} derivation builds to
  882. other machines running Guix, using the @code{offload} @dfn{build
  883. hook}@footnote{This feature is available only when
  884. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  885. present.}. When that feature is enabled, a list of user-specified build
  886. machines is read from @file{/etc/guix/machines.scm}; every time a build
  887. is requested, for instance via @code{guix build}, the daemon attempts to
  888. offload it to one of the machines that satisfy the constraints of the
  889. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  890. A single machine can have multiple system types, either because its
  891. architecture natively supports it, via emulation (@pxref{Transparent
  892. Emulation with QEMU}), or both. Missing prerequisites for the build are
  893. copied over SSH to the target machine, which then proceeds with the
  894. build; upon success the output(s) of the build are copied back to the
  895. initial machine. The offload facility comes with a basic scheduler that
  896. attempts to select the best machine. The best machine is chosen among
  897. the available machines based on criteria such as:
  898. @enumerate
  899. @item
  900. The availability of a build slot. A build machine can have as many
  901. build slots (connections) as the value of the @code{parallel-builds}
  902. field of its @code{build-machine} object.
  903. @item
  904. Its relative speed, as defined via the @code{speed} field of its
  905. @code{build-machine} object.
  906. @item
  907. Its load. The normalized machine load must be lower than a threshold
  908. value, configurable via the @code{overload-threshold} field of its
  909. @code{build-machine} object.
  910. @item
  911. Disk space availability. More than a 100 MiB must be available.
  912. @end enumerate
  913. The @file{/etc/guix/machines.scm} file typically looks like this:
  914. @lisp
  915. (list (build-machine
  916. (name "eightysix.example.org")
  917. (systems (list "x86_64-linux" "i686-linux"))
  918. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  919. (user "bob")
  920. (speed 2.)) ;incredibly fast!
  921. (build-machine
  922. (name "armeight.example.org")
  923. (systems (list "aarch64-linux"))
  924. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  925. (user "alice")
  926. (private-key
  927. (string-append (getenv "HOME")
  928. "/.ssh/identity-for-guix"))))
  929. @end lisp
  930. @noindent
  931. In the example above we specify a list of two build machines, one for
  932. the @code{x86_64} and @code{i686} architectures and one for the
  933. @code{aarch64} architecture.
  934. In fact, this file is---not surprisingly!---a Scheme file that is
  935. evaluated when the @code{offload} hook is started. Its return value
  936. must be a list of @code{build-machine} objects. While this example
  937. shows a fixed list of build machines, one could imagine, say, using
  938. DNS-SD to return a list of potential build machines discovered in the
  939. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  940. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  941. detailed below.
  942. @deftp {Data Type} build-machine
  943. This data type represents build machines to which the daemon may offload
  944. builds. The important fields are:
  945. @table @code
  946. @item name
  947. The host name of the remote machine.
  948. @item systems
  949. The system types the remote machine supports---e.g., @code{(list
  950. "x86_64-linux" "i686-linux")}.
  951. @item user
  952. The user account to use when connecting to the remote machine over SSH.
  953. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  954. allow non-interactive logins.
  955. @item host-key
  956. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  957. This is used to authenticate the machine when we connect to it. It is a
  958. long string that looks like this:
  959. @example
  960. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  961. @end example
  962. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  963. key can be found in a file such as
  964. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  965. If the machine is running the SSH daemon of GNU@tie{}lsh,
  966. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  967. similar file. It can be converted to the OpenSSH format using
  968. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  969. @example
  970. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  971. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  972. @end example
  973. @end table
  974. A number of optional fields may be specified:
  975. @table @asis
  976. @item @code{port} (default: @code{22})
  977. Port number of SSH server on the machine.
  978. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  979. The SSH private key file to use when connecting to the machine, in
  980. OpenSSH format. This key must not be protected with a passphrase.
  981. Note that the default value is the private key @emph{of the root
  982. account}. Make sure it exists if you use the default.
  983. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  984. @itemx @code{compression-level} (default: @code{3})
  985. The SSH-level compression methods and compression level requested.
  986. Note that offloading relies on SSH compression to reduce bandwidth usage
  987. when transferring files to and from build machines.
  988. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  989. File name of the Unix-domain socket @command{guix-daemon} is listening
  990. to on that machine.
  991. @item @code{overload-threshold} (default: @code{0.6})
  992. The load threshold above which a potential offload machine is
  993. disregarded by the offload scheduler. The value roughly translates to
  994. the total processor usage of the build machine, ranging from 0.0 (0%) to
  995. 1.0 (100%). It can also be disabled by setting
  996. @code{overload-threshold} to @code{#f}.
  997. @item @code{parallel-builds} (default: @code{1})
  998. The number of builds that may run in parallel on the machine.
  999. @item @code{speed} (default: @code{1.0})
  1000. A ``relative speed factor''. The offload scheduler will tend to prefer
  1001. machines with a higher speed factor.
  1002. @item @code{features} (default: @code{'()})
  1003. A list of strings denoting specific features supported by the machine.
  1004. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1005. and corresponding hardware support. Derivations can request features by
  1006. name, and they will be scheduled on matching build machines.
  1007. @end table
  1008. @end deftp
  1009. The @command{guix} command must be in the search path on the build
  1010. machines. You can check whether this is the case by running:
  1011. @example
  1012. ssh build-machine guix repl --version
  1013. @end example
  1014. There is one last thing to do once @file{machines.scm} is in place. As
  1015. explained above, when offloading, files are transferred back and forth
  1016. between the machine stores. For this to work, you first need to
  1017. generate a key pair on each machine to allow the daemon to export signed
  1018. archives of files from the store (@pxref{Invoking guix archive}):
  1019. @example
  1020. # guix archive --generate-key
  1021. @end example
  1022. @noindent
  1023. Each build machine must authorize the key of the master machine so that
  1024. it accepts store items it receives from the master:
  1025. @example
  1026. # guix archive --authorize < master-public-key.txt
  1027. @end example
  1028. @noindent
  1029. Likewise, the master machine must authorize the key of each build machine.
  1030. All the fuss with keys is here to express pairwise mutual trust
  1031. relations between the master and the build machines. Concretely, when
  1032. the master receives files from a build machine (and @i{vice versa}), its
  1033. build daemon can make sure they are genuine, have not been tampered
  1034. with, and that they are signed by an authorized key.
  1035. @cindex offload test
  1036. To test whether your setup is operational, run this command on the
  1037. master node:
  1038. @example
  1039. # guix offload test
  1040. @end example
  1041. This will attempt to connect to each of the build machines specified in
  1042. @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
  1043. available on each machine, attempt to export to the machine and import
  1044. from it, and report any error in the process.
  1045. If you want to test a different machine file, just specify it on the
  1046. command line:
  1047. @example
  1048. # guix offload test machines-qualif.scm
  1049. @end example
  1050. Last, you can test the subset of the machines whose name matches a
  1051. regular expression like this:
  1052. @example
  1053. # guix offload test machines.scm '\.gnu\.org$'
  1054. @end example
  1055. @cindex offload status
  1056. To display the current load of all build hosts, run this command on the
  1057. main node:
  1058. @example
  1059. # guix offload status
  1060. @end example
  1061. @node SELinux Support
  1062. @subsection SELinux Support
  1063. @cindex SELinux, daemon policy
  1064. @cindex mandatory access control, SELinux
  1065. @cindex security, guix-daemon
  1066. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1067. can be installed on a system where SELinux is enabled, in order to label
  1068. Guix files and to specify the expected behavior of the daemon. Since
  1069. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1070. be used on Guix System.
  1071. @subsubsection Installing the SELinux policy
  1072. @cindex SELinux, policy installation
  1073. To install the policy run this command as root:
  1074. @example
  1075. semodule -i etc/guix-daemon.cil
  1076. @end example
  1077. Then relabel the file system with @code{restorecon} or by a different
  1078. mechanism provided by your system.
  1079. Once the policy is installed, the file system has been relabeled, and
  1080. the daemon has been restarted, it should be running in the
  1081. @code{guix_daemon_t} context. You can confirm this with the following
  1082. command:
  1083. @example
  1084. ps -Zax | grep guix-daemon
  1085. @end example
  1086. Monitor the SELinux log files as you run a command like @code{guix build
  1087. hello} to convince yourself that SELinux permits all necessary
  1088. operations.
  1089. @subsubsection Limitations
  1090. @cindex SELinux, limitations
  1091. This policy is not perfect. Here is a list of limitations or quirks
  1092. that should be considered when deploying the provided SELinux policy for
  1093. the Guix daemon.
  1094. @enumerate
  1095. @item
  1096. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1097. operations involve contexts that have anything to do with
  1098. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1099. but it would be preferrable to define socket rules for only this label.
  1100. @item
  1101. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1102. the file label of the destination of a symlink is independent of the
  1103. file label of the link itself. Although all profiles under
  1104. $localstatedir are labelled, the links to these profiles inherit the
  1105. label of the directory they are in. For links in the user’s home
  1106. directory this will be @code{user_home_t}. But for links from the root
  1107. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1108. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1109. reading and following these links.
  1110. @item
  1111. The daemon’s feature to listen for TCP connections might no longer work.
  1112. This might require extra rules, because SELinux treats network sockets
  1113. differently from files.
  1114. @item
  1115. Currently all files with a name matching the regular expression
  1116. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1117. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1118. that name in any profile would be permitted to run in the
  1119. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1120. build a package that provides this executable and convince a user to
  1121. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1122. At that point SELinux could not prevent it from accessing files that are
  1123. allowed for processes in that domain.
  1124. We could generate a much more restrictive policy at installation time,
  1125. so that only the @emph{exact} file name of the currently installed
  1126. @code{guix-daemon} executable would be labelled with
  1127. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1128. The downside is that root would have to install or upgrade the policy at
  1129. installation time whenever the Guix package that provides the
  1130. effectively running @code{guix-daemon} executable is upgraded.
  1131. @end enumerate
  1132. @node Invoking guix-daemon
  1133. @section Invoking @command{guix-daemon}
  1134. The @command{guix-daemon} program implements all the functionality to
  1135. access the store. This includes launching build processes, running the
  1136. garbage collector, querying the availability of a build result, etc. It
  1137. is normally run as @code{root} like this:
  1138. @example
  1139. # guix-daemon --build-users-group=guixbuild
  1140. @end example
  1141. @noindent
  1142. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1143. @cindex chroot
  1144. @cindex container, build environment
  1145. @cindex build environment
  1146. @cindex reproducible builds
  1147. By default, @command{guix-daemon} launches build processes under
  1148. different UIDs, taken from the build group specified with
  1149. @option{--build-users-group}. In addition, each build process is run in a
  1150. chroot environment that only contains the subset of the store that the
  1151. build process depends on, as specified by its derivation
  1152. (@pxref{Programming Interface, derivation}), plus a set of specific
  1153. system directories. By default, the latter contains @file{/dev} and
  1154. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1155. @dfn{container}: in addition to having its own file system tree, it has
  1156. a separate mount name space, its own PID name space, network name space,
  1157. etc. This helps achieve reproducible builds (@pxref{Features}).
  1158. When the daemon performs a build on behalf of the user, it creates a
  1159. build directory under @file{/tmp} or under the directory specified by
  1160. its @env{TMPDIR} environment variable. This directory is shared with
  1161. the container for the duration of the build, though within the container,
  1162. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1163. The build directory is automatically deleted upon completion, unless the
  1164. build failed and the client specified @option{--keep-failed}
  1165. (@pxref{Invoking guix build, @option{--keep-failed}}).
  1166. The daemon listens for connections and spawns one sub-process for each session
  1167. started by a client (one of the @command{guix} sub-commands). The
  1168. @command{guix processes} command allows you to get an overview of the activity
  1169. on your system by viewing each of the active sessions and clients.
  1170. @xref{Invoking guix processes}, for more information.
  1171. The following command-line options are supported:
  1172. @table @code
  1173. @item --build-users-group=@var{group}
  1174. Take users from @var{group} to run build processes (@pxref{Setting Up
  1175. the Daemon, build users}).
  1176. @item --no-substitutes
  1177. @cindex substitutes
  1178. Do not use substitutes for build products. That is, always build things
  1179. locally instead of allowing downloads of pre-built binaries
  1180. (@pxref{Substitutes}).
  1181. When the daemon runs with @option{--no-substitutes}, clients can still
  1182. explicitly enable substitution @i{via} the @code{set-build-options}
  1183. remote procedure call (@pxref{The Store}).
  1184. @item --substitute-urls=@var{urls}
  1185. @anchor{daemon-substitute-urls}
  1186. Consider @var{urls} the default whitespace-separated list of substitute
  1187. source URLs. When this option is omitted,
  1188. @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
  1189. This means that substitutes may be downloaded from @var{urls}, as long
  1190. as they are signed by a trusted signature (@pxref{Substitutes}).
  1191. @cindex offloading
  1192. @item --no-offload
  1193. Do not use offload builds to other machines (@pxref{Daemon Offload
  1194. Setup}). That is, always build things locally instead of offloading
  1195. builds to remote machines.
  1196. @item --cache-failures
  1197. Cache build failures. By default, only successful builds are cached.
  1198. When this option is used, @command{guix gc --list-failures} can be used
  1199. to query the set of store items marked as failed; @command{guix gc
  1200. --clear-failures} removes store items from the set of cached failures.
  1201. @xref{Invoking guix gc}.
  1202. @item --cores=@var{n}
  1203. @itemx -c @var{n}
  1204. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1205. as available.
  1206. The default value is @code{0}, but it may be overridden by clients, such
  1207. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1208. guix build}).
  1209. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1210. in the build process, which can then use it to exploit internal
  1211. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1212. @item --max-jobs=@var{n}
  1213. @itemx -M @var{n}
  1214. Allow at most @var{n} build jobs in parallel. The default value is
  1215. @code{1}. Setting it to @code{0} means that no builds will be performed
  1216. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1217. Setup}), or simply fail.
  1218. @item --max-silent-time=@var{seconds}
  1219. When the build or substitution process remains silent for more than
  1220. @var{seconds}, terminate it and report a build failure.
  1221. The default value is @code{0}, which disables the timeout.
  1222. The value specified here can be overridden by clients (@pxref{Common
  1223. Build Options, @option{--max-silent-time}}).
  1224. @item --timeout=@var{seconds}
  1225. Likewise, when the build or substitution process lasts for more than
  1226. @var{seconds}, terminate it and report a build failure.
  1227. The default value is @code{0}, which disables the timeout.
  1228. The value specified here can be overridden by clients (@pxref{Common
  1229. Build Options, @option{--timeout}}).
  1230. @item --rounds=@var{N}
  1231. Build each derivation @var{n} times in a row, and raise an error if
  1232. consecutive build results are not bit-for-bit identical. Note that this
  1233. setting can be overridden by clients such as @command{guix build}
  1234. (@pxref{Invoking guix build}).
  1235. When used in conjunction with @option{--keep-failed}, the differing
  1236. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1237. This makes it easy to look for differences between the two results.
  1238. @item --debug
  1239. Produce debugging output.
  1240. This is useful to debug daemon start-up issues, but then it may be
  1241. overridden by clients, for example the @option{--verbosity} option of
  1242. @command{guix build} (@pxref{Invoking guix build}).
  1243. @item --chroot-directory=@var{dir}
  1244. Add @var{dir} to the build chroot.
  1245. Doing this may change the result of build processes---for instance if
  1246. they use optional dependencies found in @var{dir} when it is available,
  1247. and not otherwise. For that reason, it is not recommended to do so.
  1248. Instead, make sure that each derivation declares all the inputs that it
  1249. needs.
  1250. @item --disable-chroot
  1251. Disable chroot builds.
  1252. Using this option is not recommended since, again, it would allow build
  1253. processes to gain access to undeclared dependencies. It is necessary,
  1254. though, when @command{guix-daemon} is running under an unprivileged user
  1255. account.
  1256. @item --log-compression=@var{type}
  1257. Compress build logs according to @var{type}, one of @code{gzip},
  1258. @code{bzip2}, or @code{none}.
  1259. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1260. @var{localstatedir}. To save space, the daemon automatically compresses
  1261. them with Bzip2 by default.
  1262. @item --disable-deduplication
  1263. @cindex deduplication
  1264. Disable automatic file ``deduplication'' in the store.
  1265. By default, files added to the store are automatically ``deduplicated'':
  1266. if a newly added file is identical to another one found in the store,
  1267. the daemon makes the new file a hard link to the other file. This can
  1268. noticeably reduce disk usage, at the expense of slightly increased
  1269. input/output load at the end of a build process. This option disables
  1270. this optimization.
  1271. @item --gc-keep-outputs[=yes|no]
  1272. Tell whether the garbage collector (GC) must keep outputs of live
  1273. derivations.
  1274. @cindex GC roots
  1275. @cindex garbage collector roots
  1276. When set to @code{yes}, the GC will keep the outputs of any live
  1277. derivation available in the store---the @file{.drv} files. The default
  1278. is @code{no}, meaning that derivation outputs are kept only if they are
  1279. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1280. roots.
  1281. @item --gc-keep-derivations[=yes|no]
  1282. Tell whether the garbage collector (GC) must keep derivations
  1283. corresponding to live outputs.
  1284. When set to @code{yes}, as is the case by default, the GC keeps
  1285. derivations---i.e., @file{.drv} files---as long as at least one of their
  1286. outputs is live. This allows users to keep track of the origins of
  1287. items in their store. Setting it to @code{no} saves a bit of disk
  1288. space.
  1289. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1290. liveness to flow from outputs to derivations, and setting
  1291. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1292. derivations to outputs. When both are set to @code{yes}, the effect is
  1293. to keep all the build prerequisites (the sources, compiler, libraries,
  1294. and other build-time tools) of live objects in the store, regardless of
  1295. whether these prerequisites are reachable from a GC root. This is
  1296. convenient for developers since it saves rebuilds or downloads.
  1297. @item --impersonate-linux-2.6
  1298. On Linux-based systems, impersonate Linux 2.6. This means that the
  1299. kernel's @command{uname} system call will report 2.6 as the release number.
  1300. This might be helpful to build programs that (usually wrongfully) depend
  1301. on the kernel version number.
  1302. @item --lose-logs
  1303. Do not keep build logs. By default they are kept under
  1304. @file{@var{localstatedir}/guix/log}.
  1305. @item --system=@var{system}
  1306. Assume @var{system} as the current system type. By default it is the
  1307. architecture/kernel pair found at configure time, such as
  1308. @code{x86_64-linux}.
  1309. @item --listen=@var{endpoint}
  1310. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1311. as the file name of a Unix-domain socket if it starts with
  1312. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1313. host name or host name and port to listen to. Here are a few examples:
  1314. @table @code
  1315. @item --listen=/gnu/var/daemon
  1316. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1317. creating it if needed.
  1318. @item --listen=localhost
  1319. @cindex daemon, remote access
  1320. @cindex remote access to the daemon
  1321. @cindex daemon, cluster setup
  1322. @cindex clusters, daemon setup
  1323. Listen for TCP connections on the network interface corresponding to
  1324. @code{localhost}, on port 44146.
  1325. @item --listen=128.0.0.42:1234
  1326. Listen for TCP connections on the network interface corresponding to
  1327. @code{128.0.0.42}, on port 1234.
  1328. @end table
  1329. This option can be repeated multiple times, in which case
  1330. @command{guix-daemon} accepts connections on all the specified
  1331. endpoints. Users can tell client commands what endpoint to connect to
  1332. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1333. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1334. @quotation Note
  1335. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1336. @option{--listen=@var{host}} is suitable on local networks, such as
  1337. clusters, where only trusted nodes may connect to the build daemon. In
  1338. other cases where remote access to the daemon is needed, we recommend
  1339. using Unix-domain sockets along with SSH.
  1340. @end quotation
  1341. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1342. connections on the Unix-domain socket located at
  1343. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1344. @end table
  1345. @node Application Setup
  1346. @section Application Setup
  1347. @cindex foreign distro
  1348. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1349. so-called @dfn{foreign distro}---a few additional steps are needed to
  1350. get everything in place. Here are some of them.
  1351. @subsection Locales
  1352. @anchor{locales-and-locpath}
  1353. @cindex locales, when not on Guix System
  1354. @vindex LOCPATH
  1355. @vindex GUIX_LOCPATH
  1356. Packages installed @i{via} Guix will not use the locale data of the
  1357. host system. Instead, you must first install one of the locale packages
  1358. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1359. variable:
  1360. @example
  1361. $ guix install glibc-locales
  1362. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1363. @end example
  1364. Note that the @code{glibc-locales} package contains data for all the
  1365. locales supported by the GNU@tie{}libc and weighs in at around
  1366. 917@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1367. limited to a few UTF-8 locales.
  1368. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1369. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1370. Manual}). There are two important differences though:
  1371. @enumerate
  1372. @item
  1373. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1374. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1375. to make sure the programs of the foreign distro will not end up loading
  1376. incompatible locale data.
  1377. @item
  1378. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1379. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1380. should your Guix profile contain a mixture of programs linked against
  1381. different libc version, each libc version will only try to load locale
  1382. data in the right format.
  1383. @end enumerate
  1384. This is important because the locale data format used by different libc
  1385. versions may be incompatible.
  1386. @subsection Name Service Switch
  1387. @cindex name service switch, glibc
  1388. @cindex NSS (name service switch), glibc
  1389. @cindex nscd (name service caching daemon)
  1390. @cindex name service caching daemon (nscd)
  1391. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1392. the system run the GNU C library's @dfn{name service cache daemon},
  1393. @command{nscd}, which should be listening on the
  1394. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1395. installed with Guix may fail to look up host names or user accounts, or
  1396. may even crash. The next paragraphs explain why.
  1397. @cindex @file{nsswitch.conf}
  1398. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1399. an extensible mechanism for ``name lookups'' in general: host name
  1400. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1401. The GNU C Library Reference Manual}).
  1402. @cindex Network information service (NIS)
  1403. @cindex NIS (Network information service)
  1404. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1405. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1406. resolution of @code{.local} host names, the @code{nis} plugin allows
  1407. user account lookup using the Network information service (NIS), and so
  1408. on. These extra ``lookup services'' are configured system-wide in
  1409. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1410. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1411. Reference Manual}).
  1412. When they perform a name lookup---for instance by calling the
  1413. @code{getaddrinfo} function in C---applications first try to connect to
  1414. the nscd; on success, nscd performs name lookups on their behalf. If
  1415. the nscd is not running, then they perform the name lookup by
  1416. themselves, by loading the name lookup services into their own address
  1417. space and running it. These name lookup services---the
  1418. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1419. the host system's C library, rather than from the C library the
  1420. application is linked against (the C library coming from Guix).
  1421. And this is where the problem is: if your application is linked against
  1422. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1423. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1424. likely crash or have its name lookups fail unexpectedly.
  1425. Running @command{nscd} on the system, among other advantages, eliminates
  1426. this binary incompatibility problem because those @code{libnss_*.so}
  1427. files are loaded in the @command{nscd} process, not in applications
  1428. themselves.
  1429. @subsection X11 Fonts
  1430. @cindex fonts
  1431. The majority of graphical applications use Fontconfig to locate and
  1432. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1433. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1434. by default. Thus, to allow graphical applications installed with Guix
  1435. to display fonts, you have to install fonts with Guix as well.
  1436. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1437. @code{font-gnu-freefont}.
  1438. @cindex @code{fc-cache}
  1439. @cindex font cache
  1440. Once you have installed or removed fonts, or when you notice an
  1441. application that does not find fonts, you may need to install Fontconfig
  1442. and to force an update of its font cache by running:
  1443. @example
  1444. guix install fontconfig
  1445. fc-cache -rv
  1446. @end example
  1447. To display text written in Chinese languages, Japanese, or Korean in
  1448. graphical applications, consider installing
  1449. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1450. has multiple outputs, one per language family (@pxref{Packages with
  1451. Multiple Outputs}). For instance, the following command installs fonts
  1452. for Chinese languages:
  1453. @example
  1454. guix install font-adobe-source-han-sans:cn
  1455. @end example
  1456. @cindex @code{xterm}
  1457. Older programs such as @command{xterm} do not use Fontconfig and instead
  1458. rely on server-side font rendering. Such programs require to specify a
  1459. full name of a font using XLFD (X Logical Font Description), like this:
  1460. @example
  1461. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1462. @end example
  1463. To be able to use such full names for the TrueType fonts installed in
  1464. your Guix profile, you need to extend the font path of the X server:
  1465. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1466. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1467. @example
  1468. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1469. @end example
  1470. @cindex @code{xlsfonts}
  1471. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1472. to make sure your TrueType fonts are listed there.
  1473. @subsection X.509 Certificates
  1474. @cindex @code{nss-certs}
  1475. The @code{nss-certs} package provides X.509 certificates, which allow
  1476. programs to authenticate Web servers accessed over HTTPS.
  1477. When using Guix on a foreign distro, you can install this package and
  1478. define the relevant environment variables so that packages know where to
  1479. look for certificates. @xref{X.509 Certificates}, for detailed
  1480. information.
  1481. @subsection Emacs Packages
  1482. @cindex @code{emacs}
  1483. When you install Emacs packages with Guix, the Elisp files are placed
  1484. under the @file{share/emacs/site-lisp/} directory of the profile in
  1485. which they are installed. The Elisp libraries are made available to
  1486. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1487. set when installing Emacs itself.
  1488. Additionally, autoload definitions are automatically evaluated at the
  1489. initialization of Emacs, by the Guix-specific
  1490. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1491. want to avoid auto-loading the Emacs packages installed with Guix, you
  1492. can do so by running Emacs with the @option{--no-site-file} option
  1493. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1494. @node Upgrading Guix
  1495. @section Upgrading Guix
  1496. @cindex Upgrading Guix, on a foreign distro
  1497. To upgrade Guix, run:
  1498. @example
  1499. guix pull
  1500. @end example
  1501. @xref{Invoking guix pull}, for more information.
  1502. @cindex upgrading Guix for the root user, on a foreign distro
  1503. @cindex upgrading the Guix daemon, on a foreign distro
  1504. @cindex @command{guix pull} for the root user, on a foreign distro
  1505. On a foreign distro, you can upgrade the build daemon by running:
  1506. @example
  1507. sudo -i guix pull
  1508. @end example
  1509. @noindent
  1510. followed by (assuming your distro uses the systemd service management
  1511. tool):
  1512. @example
  1513. systemctl restart guix-daemon.service
  1514. @end example
  1515. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1516. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1517. @c TODO What else?
  1518. @c *********************************************************************
  1519. @node System Installation
  1520. @chapter System Installation
  1521. @cindex installing Guix System
  1522. @cindex Guix System, installation
  1523. This section explains how to install Guix System
  1524. on a machine. Guix, as a package manager, can
  1525. also be installed on top of a running GNU/Linux system,
  1526. @pxref{Installation}.
  1527. @ifinfo
  1528. @quotation Note
  1529. @c This paragraph is for people reading this from tty2 of the
  1530. @c installation image.
  1531. You are reading this documentation with an Info reader. For details on
  1532. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1533. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1534. Info}. Hit @kbd{l} afterwards to come back here.
  1535. Alternatively, run @command{info info} in another tty to keep the manual
  1536. available.
  1537. @end quotation
  1538. @end ifinfo
  1539. @menu
  1540. * Limitations:: What you can expect.
  1541. * Hardware Considerations:: Supported hardware.
  1542. * USB Stick and DVD Installation:: Preparing the installation medium.
  1543. * Preparing for Installation:: Networking, partitioning, etc.
  1544. * Guided Graphical Installation:: Easy graphical installation.
  1545. * Manual Installation:: Manual installation for wizards.
  1546. * After System Installation:: When installation succeeded.
  1547. * Installing Guix in a VM:: Guix System playground.
  1548. * Building the Installation Image:: How this comes to be.
  1549. @end menu
  1550. @node Limitations
  1551. @section Limitations
  1552. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1553. use cases. The reliability guarantees it provides---transactional upgrades
  1554. and rollbacks, reproducibility---make it a solid foundation.
  1555. Nevertheless, before you proceed with the installation, be aware of the
  1556. following noteworthy limitations applicable to version @value{VERSION}:
  1557. @itemize
  1558. @item
  1559. Support for the Logical Volume Manager (LVM) is missing.
  1560. @item
  1561. More and more system services are provided (@pxref{Services}), but some
  1562. may be missing.
  1563. @item
  1564. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1565. as well as a number of X11 window managers. However, KDE is currently
  1566. missing.
  1567. @end itemize
  1568. More than a disclaimer, this is an invitation to report issues (and success
  1569. stories!), and to join us in improving it. @xref{Contributing}, for more
  1570. info.
  1571. @node Hardware Considerations
  1572. @section Hardware Considerations
  1573. @cindex hardware support on Guix System
  1574. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1575. builds around the kernel Linux-libre, which means that only hardware for
  1576. which free software drivers and firmware exist is supported. Nowadays,
  1577. a wide range of off-the-shelf hardware is supported on
  1578. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1579. Ethernet controllers. Unfortunately, there are still areas where
  1580. hardware vendors deny users control over their own computing, and such
  1581. hardware is not supported on Guix System.
  1582. @cindex WiFi, hardware support
  1583. One of the main areas where free drivers or firmware are lacking is WiFi
  1584. devices. WiFi devices known to work include those using Atheros chips
  1585. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1586. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1587. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1588. Linux-libre driver. Free firmware exists for both and is available
  1589. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1590. (@pxref{operating-system Reference, @code{firmware}}).
  1591. @cindex RYF, Respects Your Freedom
  1592. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1593. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1594. certification program for hardware products that respect your freedom
  1595. and your privacy and ensure that you have control over your device. We
  1596. encourage you to check the list of RYF-certified devices.
  1597. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1598. web site. It contains a catalog of hardware devices with information
  1599. about their support in GNU/Linux.
  1600. @node USB Stick and DVD Installation
  1601. @section USB Stick and DVD Installation
  1602. An ISO-9660 installation image that can be written to a USB stick or
  1603. burnt to a DVD can be downloaded from
  1604. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz},
  1605. where you can replace @code{x86_64-linux} with one of:
  1606. @table @code
  1607. @item x86_64-linux
  1608. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1609. @item i686-linux
  1610. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1611. @end table
  1612. @c start duplication of authentication part from ``Binary Installation''
  1613. Make sure to download the associated @file{.sig} file and to verify the
  1614. authenticity of the image against it, along these lines:
  1615. @example
  1616. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1617. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1618. @end example
  1619. If that command fails because you do not have the required public key,
  1620. then run this command to import it:
  1621. @example
  1622. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1623. -qO - | gpg --import -
  1624. @end example
  1625. @noindent
  1626. and rerun the @code{gpg --verify} command.
  1627. Take note that a warning like ``This key is not certified with a trusted
  1628. signature!'' is normal.
  1629. @c end duplication
  1630. This image contains the tools necessary for an installation.
  1631. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1632. @unnumberedsubsec Copying to a USB Stick
  1633. To copy the image to a USB stick, follow these steps:
  1634. @enumerate
  1635. @item
  1636. Decompress the image using the @command{xz} command:
  1637. @example
  1638. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1639. @end example
  1640. @item
  1641. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1642. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1643. copy the image with:
  1644. @example
  1645. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1646. sync
  1647. @end example
  1648. Access to @file{/dev/sdX} usually requires root privileges.
  1649. @end enumerate
  1650. @unnumberedsubsec Burning on a DVD
  1651. To copy the image to a DVD, follow these steps:
  1652. @enumerate
  1653. @item
  1654. Decompress the image using the @command{xz} command:
  1655. @example
  1656. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1657. @end example
  1658. @item
  1659. Insert a blank DVD into your machine, and determine
  1660. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1661. copy the image with:
  1662. @example
  1663. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1664. @end example
  1665. Access to @file{/dev/srX} usually requires root privileges.
  1666. @end enumerate
  1667. @unnumberedsubsec Booting
  1668. Once this is done, you should be able to reboot the system and boot from
  1669. the USB stick or DVD. The latter usually requires you to get in the
  1670. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1671. In order to boot from Libreboot, switch to the command mode by pressing
  1672. the @kbd{c} key and type @command{search_grub usb}.
  1673. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1674. Guix System in a virtual machine (VM).
  1675. @node Preparing for Installation
  1676. @section Preparing for Installation
  1677. Once you have booted, you can use the guided graphical installer, which makes
  1678. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1679. if you are already familiar with GNU/Linux and if you want more control than
  1680. what the graphical installer provides, you can choose the ``manual''
  1681. installation process (@pxref{Manual Installation}).
  1682. The graphical installer is available on TTY1. You can obtain root shells on
  1683. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1684. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1685. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1686. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1687. which allows you to select text with the left mouse button and to paste it
  1688. with the middle button.
  1689. @quotation Note
  1690. Installation requires access to the Internet so that any missing
  1691. dependencies of your system configuration can be downloaded. See the
  1692. ``Networking'' section below.
  1693. @end quotation
  1694. @node Guided Graphical Installation
  1695. @section Guided Graphical Installation
  1696. The graphical installer is a text-based user interface. It will guide you,
  1697. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1698. The first dialog boxes allow you to set up the system as you use it during the
  1699. installation: you can choose the language, keyboard layout, and set up
  1700. networking, which will be used during the installation. The image below shows
  1701. the networking dialog.
  1702. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1703. Later steps allow you to partition your hard disk, as shown in the image
  1704. below, to choose whether or not to use encrypted file systems, to enter the
  1705. host name and root password, and to create an additional account, among other
  1706. things.
  1707. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1708. Note that, at any time, the installer allows you to exit the current
  1709. installation step and resume at a previous step, as show in the image below.
  1710. @image{images/installer-resume,5in,, resuming the installation process}
  1711. Once you're done, the installer produces an operating system configuration and
  1712. displays it (@pxref{Using the Configuration System}). At that point you can
  1713. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1714. new system and enjoy. @xref{After System Installation}, for what's next!
  1715. @node Manual Installation
  1716. @section Manual Installation
  1717. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1718. on your machine. This option requires familiarity with GNU/Linux, with the
  1719. shell, and with common administration tools. If you think this is not for
  1720. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1721. Installation}).
  1722. The installation system provides root shells on TTYs 3 to 6; press
  1723. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1724. many common tools needed to install the system. But it is also a full-blown
  1725. Guix System, which means that you can install additional packages, should you
  1726. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1727. @menu
  1728. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1729. * Proceeding with the Installation:: Installing.
  1730. @end menu
  1731. @node Keyboard Layout and Networking and Partitioning
  1732. @subsection Keyboard Layout, Networking, and Partitioning
  1733. Before you can install the system, you may want to adjust the keyboard layout,
  1734. set up networking, and partition your target hard disk. This section will
  1735. guide you through this.
  1736. @subsubsection Keyboard Layout
  1737. @cindex keyboard layout
  1738. The installation image uses the US qwerty keyboard layout. If you want
  1739. to change it, you can use the @command{loadkeys} command. For example,
  1740. the following command selects the Dvorak keyboard layout:
  1741. @example
  1742. loadkeys dvorak
  1743. @end example
  1744. See the files under @file{/run/current-system/profile/share/keymaps} for
  1745. a list of available keyboard layouts. Run @command{man loadkeys} for
  1746. more information.
  1747. @subsubsection Networking
  1748. Run the following command to see what your network interfaces are called:
  1749. @example
  1750. ifconfig -a
  1751. @end example
  1752. @noindent
  1753. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1754. @example
  1755. ip address
  1756. @end example
  1757. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1758. Wired interfaces have a name starting with @samp{e}; for example, the
  1759. interface corresponding to the first on-board Ethernet controller is
  1760. called @samp{eno1}. Wireless interfaces have a name starting with
  1761. @samp{w}, like @samp{w1p2s0}.
  1762. @table @asis
  1763. @item Wired connection
  1764. To configure a wired network run the following command, substituting
  1765. @var{interface} with the name of the wired interface you want to use.
  1766. @example
  1767. ifconfig @var{interface} up
  1768. @end example
  1769. @noindent
  1770. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1771. @example
  1772. ip link set @var{interface} up
  1773. @end example
  1774. @item Wireless connection
  1775. @cindex wireless
  1776. @cindex WiFi
  1777. To configure wireless networking, you can create a configuration file
  1778. for the @command{wpa_supplicant} configuration tool (its location is not
  1779. important) using one of the available text editors such as
  1780. @command{nano}:
  1781. @example
  1782. nano wpa_supplicant.conf
  1783. @end example
  1784. As an example, the following stanza can go to this file and will work
  1785. for many wireless networks, provided you give the actual SSID and
  1786. passphrase for the network you are connecting to:
  1787. @example
  1788. network=@{
  1789. ssid="@var{my-ssid}"
  1790. key_mgmt=WPA-PSK
  1791. psk="the network's secret passphrase"
  1792. @}
  1793. @end example
  1794. Start the wireless service and run it in the background with the
  1795. following command (substitute @var{interface} with the name of the
  1796. network interface you want to use):
  1797. @example
  1798. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1799. @end example
  1800. Run @command{man wpa_supplicant} for more information.
  1801. @end table
  1802. @cindex DHCP
  1803. At this point, you need to acquire an IP address. On a network where IP
  1804. addresses are automatically assigned @i{via} DHCP, you can run:
  1805. @example
  1806. dhclient -v @var{interface}
  1807. @end example
  1808. Try to ping a server to see if networking is up and running:
  1809. @example
  1810. ping -c 3 gnu.org
  1811. @end example
  1812. Setting up network access is almost always a requirement because the
  1813. image does not contain all the software and tools that may be needed.
  1814. @cindex proxy, during system installation
  1815. If you need HTTP and HTTPS access to go through a proxy, run the
  1816. following command:
  1817. @example
  1818. herd set-http-proxy guix-daemon @var{URL}
  1819. @end example
  1820. @noindent
  1821. where @var{URL} is the proxy URL, for example
  1822. @code{http://example.org:8118}.
  1823. @cindex installing over SSH
  1824. If you want to, you can continue the installation remotely by starting
  1825. an SSH server:
  1826. @example
  1827. herd start ssh-daemon
  1828. @end example
  1829. Make sure to either set a password with @command{passwd}, or configure
  1830. OpenSSH public key authentication before logging in.
  1831. @subsubsection Disk Partitioning
  1832. Unless this has already been done, the next step is to partition, and
  1833. then format the target partition(s).
  1834. The installation image includes several partitioning tools, including
  1835. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1836. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1837. the partition layout you want:
  1838. @example
  1839. cfdisk
  1840. @end example
  1841. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1842. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1843. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1844. manual}).
  1845. @cindex EFI, installation
  1846. @cindex UEFI, installation
  1847. @cindex ESP, EFI system partition
  1848. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1849. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1850. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  1851. @example
  1852. parted /dev/sda set 1 esp on
  1853. @end example
  1854. @quotation Note
  1855. @vindex grub-bootloader
  1856. @vindex grub-efi-bootloader
  1857. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  1858. @file{/sys/firmware/efi} exists in the installation image, then you should
  1859. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  1860. Otherwise you should use the BIOS-based GRUB, known as
  1861. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  1862. bootloaders.
  1863. @end quotation
  1864. Once you are done partitioning the target hard disk drive, you have to
  1865. create a file system on the relevant partition(s)@footnote{Currently
  1866. Guix System only supports ext4, btrfs, and JFS file systems. In particular,
  1867. code that reads file system UUIDs and labels only works for these file system
  1868. types.}. For the ESP, if you have one and assuming it is
  1869. @file{/dev/sda1}, run:
  1870. @example
  1871. mkfs.fat -F32 /dev/sda1
  1872. @end example
  1873. For the root file system, ext4 is the most widely used format. Other
  1874. file systems, such as Btrfs, support compression, which is reported to
  1875. nicely complement file deduplication that the daemon performs
  1876. independently of the file system (@pxref{Invoking guix-daemon,
  1877. deduplication}).
  1878. Preferably, assign file systems a label so that you can easily and
  1879. reliably refer to them in @code{file-system} declarations (@pxref{File
  1880. Systems}). This is typically done using the @code{-L} option of
  1881. @command{mkfs.ext4} and related commands. So, assuming the target root
  1882. partition lives at @file{/dev/sda2}, a file system with the label
  1883. @code{my-root} can be created with:
  1884. @example
  1885. mkfs.ext4 -L my-root /dev/sda2
  1886. @end example
  1887. @cindex encrypted disk
  1888. If you are instead planning to encrypt the root partition, you can use
  1889. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  1890. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  1891. @code{man cryptsetup}} for more information). Assuming you want to
  1892. store the root partition on @file{/dev/sda2}, the command sequence would
  1893. be along these lines:
  1894. @example
  1895. cryptsetup luksFormat /dev/sda2
  1896. cryptsetup open --type luks /dev/sda2 my-partition
  1897. mkfs.ext4 -L my-root /dev/mapper/my-partition
  1898. @end example
  1899. Once that is done, mount the target file system under @file{/mnt}
  1900. with a command like (again, assuming @code{my-root} is the label of the
  1901. root file system):
  1902. @example
  1903. mount LABEL=my-root /mnt
  1904. @end example
  1905. Also mount any other file systems you would like to use on the target
  1906. system relative to this path. If you have opted for @file{/boot/efi} as an
  1907. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  1908. found by @code{guix system init} afterwards.
  1909. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  1910. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  1911. sure to initialize them with @command{mkswap}. Assuming you have one
  1912. swap partition on @file{/dev/sda3}, you would run:
  1913. @example
  1914. mkswap /dev/sda3
  1915. swapon /dev/sda3
  1916. @end example
  1917. Alternatively, you may use a swap file. For example, assuming that in
  1918. the new system you want to use the file @file{/swapfile} as a swap file,
  1919. you would run@footnote{This example will work for many types of file
  1920. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  1921. btrfs), the required steps may be different. For details, see the
  1922. manual pages for @command{mkswap} and @command{swapon}.}:
  1923. @example
  1924. # This is 10 GiB of swap space. Adjust "count" to change the size.
  1925. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  1926. # For security, make the file readable and writable only by root.
  1927. chmod 600 /mnt/swapfile
  1928. mkswap /mnt/swapfile
  1929. swapon /mnt/swapfile
  1930. @end example
  1931. Note that if you have encrypted the root partition and created a swap
  1932. file in its file system as described above, then the encryption also
  1933. protects the swap file, just like any other file in that file system.
  1934. @node Proceeding with the Installation
  1935. @subsection Proceeding with the Installation
  1936. With the target partitions ready and the target root mounted on
  1937. @file{/mnt}, we're ready to go. First, run:
  1938. @example
  1939. herd start cow-store /mnt
  1940. @end example
  1941. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  1942. during the installation phase are written to the target disk on @file{/mnt}
  1943. rather than kept in memory. This is necessary because the first phase of
  1944. the @command{guix system init} command (see below) entails downloads or
  1945. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  1946. Next, you have to edit a file and
  1947. provide the declaration of the operating system to be installed. To
  1948. that end, the installation system comes with three text editors. We
  1949. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  1950. supports syntax highlighting and parentheses matching; other editors
  1951. include GNU Zile (an Emacs clone), and
  1952. nvi (a clone of the original BSD @command{vi} editor).
  1953. We strongly recommend storing that file on the target root file system, say,
  1954. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  1955. configuration file once you have rebooted into the newly-installed system.
  1956. @xref{Using the Configuration System}, for an overview of the
  1957. configuration file. The example configurations discussed in that
  1958. section are available under @file{/etc/configuration} in the
  1959. installation image. Thus, to get started with a system configuration
  1960. providing a graphical display server (a ``desktop'' system), you can run
  1961. something along these lines:
  1962. @example
  1963. # mkdir /mnt/etc
  1964. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  1965. # nano /mnt/etc/config.scm
  1966. @end example
  1967. You should pay attention to what your configuration file contains, and
  1968. in particular:
  1969. @itemize
  1970. @item
  1971. Make sure the @code{bootloader-configuration} form refers to the target
  1972. you want to install GRUB on. It should mention @code{grub-bootloader} if
  1973. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  1974. for newer UEFI systems. For legacy systems, the @code{target} field
  1975. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  1976. to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
  1977. currently mounted and a @code{file-system} entry is specified in your
  1978. configuration.
  1979. @item
  1980. Be sure that your file system labels match the value of their respective
  1981. @code{device} fields in your @code{file-system} configuration, assuming
  1982. your @code{file-system} configuration uses the @code{file-system-label}
  1983. procedure in its @code{device} field.
  1984. @item
  1985. If there are encrypted or RAID partitions, make sure to add a
  1986. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  1987. @end itemize
  1988. Once you are done preparing the configuration file, the new system must
  1989. be initialized (remember that the target root file system is mounted
  1990. under @file{/mnt}):
  1991. @example
  1992. guix system init /mnt/etc/config.scm /mnt
  1993. @end example
  1994. @noindent
  1995. This copies all the necessary files and installs GRUB on
  1996. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  1997. more information, @pxref{Invoking guix system}. This command may trigger
  1998. downloads or builds of missing packages, which can take some time.
  1999. Once that command has completed---and hopefully succeeded!---you can run
  2000. @command{reboot} and boot into the new system. The @code{root} password
  2001. in the new system is initially empty; other users' passwords need to be
  2002. initialized by running the @command{passwd} command as @code{root},
  2003. unless your configuration specifies otherwise
  2004. (@pxref{user-account-password, user account passwords}).
  2005. @xref{After System Installation}, for what's next!
  2006. @node After System Installation
  2007. @section After System Installation
  2008. Success, you've now booted into Guix System! From then on, you can update the
  2009. system whenever you want by running, say:
  2010. @example
  2011. guix pull
  2012. sudo guix system reconfigure /etc/config.scm
  2013. @end example
  2014. @noindent
  2015. This builds a new system generation with the latest packages and services
  2016. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2017. your system includes the latest security updates (@pxref{Security Updates}).
  2018. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2019. @quotation Note
  2020. @cindex sudo vs. @command{guix pull}
  2021. Note that @command{sudo guix} runs your user's @command{guix} command and
  2022. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2023. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2024. The difference matters here, because @command{guix pull} updates
  2025. the @command{guix} command and package definitions only for the user it is ran
  2026. as. This means that if you choose to use @command{guix system reconfigure} in
  2027. root's login shell, you'll need to @command{guix pull} separately.
  2028. @end quotation
  2029. Now, @pxref{Getting Started}, and
  2030. join us on @code{#guix} on the Freenode IRC network or on
  2031. @email{guix-devel@@gnu.org} to share your experience!
  2032. @node Installing Guix in a VM
  2033. @section Installing Guix in a Virtual Machine
  2034. @cindex virtual machine, Guix System installation
  2035. @cindex virtual private server (VPS)
  2036. @cindex VPS (virtual private server)
  2037. If you'd like to install Guix System in a virtual machine (VM) or on a
  2038. virtual private server (VPS) rather than on your beloved machine, this
  2039. section is for you.
  2040. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2041. disk image, follow these steps:
  2042. @enumerate
  2043. @item
  2044. First, retrieve and decompress the Guix system installation image as
  2045. described previously (@pxref{USB Stick and DVD Installation}).
  2046. @item
  2047. Create a disk image that will hold the installed system. To make a
  2048. qcow2-formatted disk image, use the @command{qemu-img} command:
  2049. @example
  2050. qemu-img create -f qcow2 guix-system.img 50G
  2051. @end example
  2052. The resulting file will be much smaller than 50 GB (typically less than
  2053. 1 MB), but it will grow as the virtualized storage device is filled up.
  2054. @item
  2055. Boot the USB installation image in an VM:
  2056. @example
  2057. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2058. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2059. -drive file=guix-system.img \
  2060. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2061. @end example
  2062. @code{-enable-kvm} is optional, but significantly improves performance,
  2063. @pxref{Running Guix in a VM}.
  2064. @item
  2065. You're now root in the VM, proceed with the installation process.
  2066. @xref{Preparing for Installation}, and follow the instructions.
  2067. @end enumerate
  2068. Once installation is complete, you can boot the system that's on your
  2069. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2070. that.
  2071. @node Building the Installation Image
  2072. @section Building the Installation Image
  2073. @cindex installation image
  2074. The installation image described above was built using the @command{guix
  2075. system} command, specifically:
  2076. @example
  2077. guix system disk-image -t iso9660 gnu/system/install.scm
  2078. @end example
  2079. Have a look at @file{gnu/system/install.scm} in the source tree,
  2080. and see also @ref{Invoking guix system} for more information
  2081. about the installation image.
  2082. @section Building the Installation Image for ARM Boards
  2083. Many ARM boards require a specific variant of the
  2084. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2085. If you build a disk image and the bootloader is not available otherwise
  2086. (on another boot drive etc), it's advisable to build an image that
  2087. includes the bootloader, specifically:
  2088. @example
  2089. guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2090. @end example
  2091. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2092. board, a list of possible boards will be printed.
  2093. @c *********************************************************************
  2094. @node Getting Started
  2095. @chapter Getting Started
  2096. Presumably, you've reached this section because either you have
  2097. installed Guix on top of another distribution (@pxref{Installation}), or
  2098. you've installed the standalone Guix System (@pxref{System
  2099. Installation}). It's time for you to get started using Guix and this
  2100. section aims to help you do that and give you a feel of what it's like.
  2101. Guix is about installing software, so probably the first thing you'll
  2102. want to do is to actually look for software. Let's say you're looking
  2103. for a text editor, you can run:
  2104. @example
  2105. guix search text editor
  2106. @end example
  2107. This command shows you a number of matching @dfn{packages}, each time
  2108. showing the package's name, version, a description, and additional info.
  2109. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2110. you can go ahead and install it (run this command as a regular user,
  2111. @emph{no need for root privileges}!):
  2112. @example
  2113. guix install emacs
  2114. @end example
  2115. You've installed your first package, congrats! In the process, you've
  2116. probably noticed that Guix downloaded pre-built binaries; or, if you
  2117. explicitly chose to @emph{not} use pre-built binaries, then probably
  2118. Guix is still building software (@pxref{Substitutes}, for more info).
  2119. Unless you're using Guix System, the @command{guix install} command must
  2120. have printed this hint:
  2121. @example
  2122. hint: Consider setting the necessary environment variables by running:
  2123. GUIX_PROFILE="$HOME/.guix-profile"
  2124. . "$GUIX_PROFILE/etc/profile"
  2125. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2126. @end example
  2127. Indeed, you must now tell your shell where @command{emacs} and other
  2128. programs installed with Guix are to be found. Pasting the two lines
  2129. above will do just that: it will add
  2130. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2131. is---to the @code{PATH} environment variable. You can paste these two
  2132. lines in your shell so they take effect right away, but more importantly
  2133. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2134. do not use Bash) so that environment variables are set next time you
  2135. spawn a shell. You only need to do this once and other search paths
  2136. environment variables will be taken care of similarly---e.g., if you
  2137. eventually install @code{python} and Python libraries, @code{PYTHONPATH}
  2138. will be defined.
  2139. You can go on installing packages at your will. To list installed
  2140. packages, run:
  2141. @example
  2142. guix package --list-installed
  2143. @end example
  2144. To remove a package, you would unsurprisingly run @command{guix remove}.
  2145. A distinguishing feature is the ability to @dfn{roll back} any operation
  2146. you made---installation, removal, upgrade---by simply typing:
  2147. @example
  2148. guix package --roll-back
  2149. @end example
  2150. This is because each operation is in fact a @dfn{transaction} that
  2151. creates a new @dfn{generation}. These generations and the difference
  2152. between them can be displayed by running:
  2153. @example
  2154. guix package --list-generations
  2155. @end example
  2156. Now you know the basics of package management!
  2157. @quotation Going further
  2158. @xref{Package Management}, for more about package management. You may
  2159. like @dfn{declarative} package management with @command{guix package
  2160. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2161. deleting old generations, collecting garbage, and other nifty features
  2162. that will come in handy as you become more familiar with Guix. If you
  2163. are a developer, @pxref{Development} for additional tools. And if
  2164. you're curious, @pxref{Features}, to peek under the hood.
  2165. @end quotation
  2166. Once you've installed a set of packages, you will want to periodically
  2167. @emph{upgrade} them to the latest and greatest version. To do that, you
  2168. will first pull the latest revision of Guix and its package collection:
  2169. @example
  2170. guix pull
  2171. @end example
  2172. The end result is a new @command{guix} command, under
  2173. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2174. first time you run @command{guix pull}, be sure to follow the hint that
  2175. the command prints and, similar to what we saw above, paste these two
  2176. lines in your terminal and @file{.bash_profile}:
  2177. @example
  2178. GUIX_PROFILE="$HOME/.config/guix/current/etc/profile"
  2179. . "$GUIX_PROFILE/etc/profile"
  2180. @end example
  2181. @noindent
  2182. You must also instruct your shell to point to this new @command{guix}:
  2183. @example
  2184. hash guix
  2185. @end example
  2186. At this point, you're running a brand new Guix. You can thus go ahead
  2187. and actually upgrade all the packages you previously installed:
  2188. @example
  2189. guix upgrade
  2190. @end example
  2191. As you run this command, you will see that binaries are downloaded (or
  2192. perhaps some packages are built), and eventually you end up with the
  2193. upgraded packages. Should one of these upgraded packages not be to your
  2194. liking, remember you can always roll back!
  2195. You can display the exact revision of Guix you're currently using by
  2196. running:
  2197. @example
  2198. guix describe
  2199. @end example
  2200. The information it displays is @emph{all it takes to reproduce the exact
  2201. same Guix}, be it at a different point in time or on a different
  2202. machine.
  2203. @quotation Going further
  2204. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2205. how to specify additional @dfn{channels} to pull packages from, how to
  2206. replicate Guix, and more. You may also find @command{time-machine}
  2207. handy (@pxref{Invoking guix time-machine}).
  2208. @end quotation
  2209. If you installed Guix System, one of the first things you'll want to do
  2210. is to upgrade your system. Once you've run @command{guix pull} to get
  2211. the latest Guix, you can upgrade the system like this:
  2212. @example
  2213. sudo guix system reconfigure /etc/config.scm
  2214. @end example
  2215. Upon completion, the system runs the latest versions of its software
  2216. packages. When you eventually reboot, you'll notice a sub-menu in the
  2217. bootloader that reads ``Old system generations'': it's what allows you
  2218. to boot @emph{an older generation of your system}, should the latest
  2219. generation be ``broken'' or otherwise unsatisfying. Just like for
  2220. packages, you can always @emph{roll back} to a previous generation
  2221. @emph{of the whole system}:
  2222. @example
  2223. sudo guix system roll-back
  2224. @end example
  2225. There are many things you'll probably want to tweak on your system:
  2226. adding new user accounts, adding new system services, fiddling with the
  2227. configuration of those services, etc. The system configuration is
  2228. @emph{entirely} described in the @file{/etc/config.scm} file.
  2229. @xref{Using the Configuration System}, to learn how to change it.
  2230. Now you know enough to get started!
  2231. @quotation Resources
  2232. The rest of this manual provides a reference for all things Guix. Here
  2233. are some additional resources you may find useful:
  2234. @itemize
  2235. @item
  2236. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2237. ``how-to'' style of recipes for a variety of applications.
  2238. @item
  2239. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2240. Card} lists in two pages most of the commands and options you'll ever
  2241. need.
  2242. @item
  2243. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2244. instructional videos} covering topics such as everyday use of Guix, how
  2245. to get help, and how to become a contributor.
  2246. @item
  2247. @xref{Documentation}, to learn how to access documentation on your
  2248. computer.
  2249. @end itemize
  2250. We hope you will enjoy Guix as much as the community enjoys building it!
  2251. @end quotation
  2252. @c *********************************************************************
  2253. @node Package Management
  2254. @chapter Package Management
  2255. @cindex packages
  2256. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2257. remove software packages, without having to know about their build
  2258. procedures or dependencies. Guix also goes beyond this obvious set of
  2259. features.
  2260. This chapter describes the main features of Guix, as well as the
  2261. package management tools it provides. Along with the command-line
  2262. interface described below (@pxref{Invoking guix package, @code{guix
  2263. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2264. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2265. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2266. with it):
  2267. @example
  2268. guix install emacs-guix
  2269. @end example
  2270. @menu
  2271. * Features:: How Guix will make your life brighter.
  2272. * Invoking guix package:: Package installation, removal, etc.
  2273. * Substitutes:: Downloading pre-built binaries.
  2274. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2275. * Invoking guix gc:: Running the garbage collector.
  2276. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2277. * Invoking guix time-machine:: Running an older revision of Guix.
  2278. * Inferiors:: Interacting with another revision of Guix.
  2279. * Invoking guix describe:: Display information about your Guix revision.
  2280. * Invoking guix archive:: Exporting and importing store files.
  2281. @end menu
  2282. @node Features
  2283. @section Features
  2284. Here we assume you've already made your first steps with Guix
  2285. (@pxref{Getting Started}) and would like to get an overview about what's
  2286. going on under the hood.
  2287. When using Guix, each package ends up in the @dfn{package store}, in its
  2288. own directory---something that resembles
  2289. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2290. Instead of referring to these directories, users have their own
  2291. @dfn{profile}, which points to the packages that they actually want to
  2292. use. These profiles are stored within each user's home directory, at
  2293. @code{$HOME/.guix-profile}.
  2294. For example, @code{alice} installs GCC 4.7.2. As a result,
  2295. @file{/home/alice/.guix-profile/bin/gcc} points to
  2296. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2297. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2298. simply continues to point to
  2299. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2300. coexist on the same system without any interference.
  2301. The @command{guix package} command is the central tool to manage
  2302. packages (@pxref{Invoking guix package}). It operates on the per-user
  2303. profiles, and can be used @emph{with normal user privileges}.
  2304. @cindex transactions
  2305. The command provides the obvious install, remove, and upgrade
  2306. operations. Each invocation is actually a @emph{transaction}: either
  2307. the specified operation succeeds, or nothing happens. Thus, if the
  2308. @command{guix package} process is terminated during the transaction,
  2309. or if a power outage occurs during the transaction, then the user's
  2310. profile remains in its previous state, and remains usable.
  2311. In addition, any package transaction may be @emph{rolled back}. So, if,
  2312. for example, an upgrade installs a new version of a package that turns
  2313. out to have a serious bug, users may roll back to the previous instance
  2314. of their profile, which was known to work well. Similarly, the global
  2315. system configuration on Guix is subject to
  2316. transactional upgrades and roll-back
  2317. (@pxref{Using the Configuration System}).
  2318. All packages in the package store may be @emph{garbage-collected}.
  2319. Guix can determine which packages are still referenced by user
  2320. profiles, and remove those that are provably no longer referenced
  2321. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2322. generations of their profile so that the packages they refer to can be
  2323. collected.
  2324. @cindex reproducibility
  2325. @cindex reproducible builds
  2326. Guix takes a @dfn{purely functional} approach to package
  2327. management, as described in the introduction (@pxref{Introduction}).
  2328. Each @file{/gnu/store} package directory name contains a hash of all the
  2329. inputs that were used to build that package---compiler, libraries, build
  2330. scripts, etc. This direct correspondence allows users to make sure a
  2331. given package installation matches the current state of their
  2332. distribution. It also helps maximize @dfn{build reproducibility}:
  2333. thanks to the isolated build environments that are used, a given build
  2334. is likely to yield bit-identical files when performed on different
  2335. machines (@pxref{Invoking guix-daemon, container}).
  2336. @cindex substitutes
  2337. This foundation allows Guix to support @dfn{transparent binary/source
  2338. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2339. available from an external source---a @dfn{substitute}, Guix just
  2340. downloads it and unpacks it;
  2341. otherwise, it builds the package from source, locally
  2342. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2343. reproducible, users do not have to trust servers that provide
  2344. substitutes: they can force a local build and @emph{challenge} providers
  2345. (@pxref{Invoking guix challenge}).
  2346. Control over the build environment is a feature that is also useful for
  2347. developers. The @command{guix environment} command allows developers of
  2348. a package to quickly set up the right development environment for their
  2349. package, without having to manually install the dependencies of the
  2350. package into their profile (@pxref{Invoking guix environment}).
  2351. @cindex replication, of software environments
  2352. @cindex provenance tracking, of software artifacts
  2353. All of Guix and its package definitions is version-controlled, and
  2354. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2355. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2356. Guix instance on a different machine or at a later point in time, which in
  2357. turn allows you to @emph{replicate complete software environments}, while
  2358. retaining precise @dfn{provenance tracking} of the software.
  2359. @node Invoking guix package
  2360. @section Invoking @command{guix package}
  2361. @cindex installing packages
  2362. @cindex removing packages
  2363. @cindex package installation
  2364. @cindex package removal
  2365. The @command{guix package} command is the tool that allows users to
  2366. install, upgrade, and remove packages, as well as rolling back to
  2367. previous configurations. It operates only on the user's own profile,
  2368. and works with normal user privileges (@pxref{Features}). Its syntax
  2369. is:
  2370. @example
  2371. guix package @var{options}
  2372. @end example
  2373. @cindex transactions
  2374. Primarily, @var{options} specifies the operations to be performed during
  2375. the transaction. Upon completion, a new profile is created, but
  2376. previous @dfn{generations} of the profile remain available, should the user
  2377. want to roll back.
  2378. For example, to remove @code{lua} and install @code{guile} and
  2379. @code{guile-cairo} in a single transaction:
  2380. @example
  2381. guix package -r lua -i guile guile-cairo
  2382. @end example
  2383. @cindex aliases, for @command{guix package}
  2384. For your convenience, we also provide the following aliases:
  2385. @itemize
  2386. @item
  2387. @command{guix search} is an alias for @command{guix package -s},
  2388. @item
  2389. @command{guix install} is an alias for @command{guix package -i},
  2390. @item
  2391. @command{guix remove} is an alias for @command{guix package -r},
  2392. @item
  2393. @command{guix upgrade} is an alias for @command{guix package -u},
  2394. @item
  2395. and @command{guix show} is an alias for @command{guix package --show=}.
  2396. @end itemize
  2397. These aliases are less expressive than @command{guix package} and provide
  2398. fewer options, so in some cases you'll probably want to use @command{guix
  2399. package} directly.
  2400. @command{guix package} also supports a @dfn{declarative approach}
  2401. whereby the user specifies the exact set of packages to be available and
  2402. passes it @i{via} the @option{--manifest} option
  2403. (@pxref{profile-manifest, @option{--manifest}}).
  2404. @cindex profile
  2405. For each user, a symlink to the user's default profile is automatically
  2406. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2407. current generation of the user's default profile. Thus, users can add
  2408. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2409. variable, and so on.
  2410. @cindex search paths
  2411. If you are not using Guix System, consider adding the
  2412. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2413. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2414. shells get all the right environment variable definitions:
  2415. @example
  2416. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2417. source "$HOME/.guix-profile/etc/profile"
  2418. @end example
  2419. In a multi-user setup, user profiles are stored in a place registered as
  2420. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2421. to (@pxref{Invoking guix gc}). That directory is normally
  2422. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2423. @var{localstatedir} is the value passed to @code{configure} as
  2424. @option{--localstatedir}, and @var{user} is the user name. The
  2425. @file{per-user} directory is created when @command{guix-daemon} is
  2426. started, and the @var{user} sub-directory is created by @command{guix
  2427. package}.
  2428. The @var{options} can be among the following:
  2429. @table @code
  2430. @item --install=@var{package} @dots{}
  2431. @itemx -i @var{package} @dots{}
  2432. Install the specified @var{package}s.
  2433. Each @var{package} may specify either a simple package name, such as
  2434. @code{guile}, or a package name followed by an at-sign and version number,
  2435. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2436. case, the newest version prefixed by @code{1.8} is selected).
  2437. If no version number is specified, the
  2438. newest available version will be selected. In addition, @var{package}
  2439. may contain a colon, followed by the name of one of the outputs of the
  2440. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2441. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2442. name (and optionally version) are searched for among the GNU
  2443. distribution modules (@pxref{Package Modules}).
  2444. @cindex propagated inputs
  2445. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2446. that automatically get installed along with the required package
  2447. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2448. @code{package} objects}, for information about propagated inputs in
  2449. package definitions).
  2450. @anchor{package-cmd-propagated-inputs}
  2451. An example is the GNU MPC library: its C header files refer to those of
  2452. the GNU MPFR library, which in turn refer to those of the GMP library.
  2453. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2454. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2455. also been explicitly installed by the user.
  2456. Besides, packages sometimes rely on the definition of environment
  2457. variables for their search paths (see explanation of
  2458. @option{--search-paths} below). Any missing or possibly incorrect
  2459. environment variable definitions are reported here.
  2460. @item --install-from-expression=@var{exp}
  2461. @itemx -e @var{exp}
  2462. Install the package @var{exp} evaluates to.
  2463. @var{exp} must be a Scheme expression that evaluates to a
  2464. @code{<package>} object. This option is notably useful to disambiguate
  2465. between same-named variants of a package, with expressions such as
  2466. @code{(@@ (gnu packages base) guile-final)}.
  2467. Note that this option installs the first output of the specified
  2468. package, which may be insufficient when needing a specific output of a
  2469. multiple-output package.
  2470. @item --install-from-file=@var{file}
  2471. @itemx -f @var{file}
  2472. Install the package that the code within @var{file} evaluates to.
  2473. As an example, @var{file} might contain a definition like this
  2474. (@pxref{Defining Packages}):
  2475. @lisp
  2476. @include package-hello.scm
  2477. @end lisp
  2478. Developers may find it useful to include such a @file{guix.scm} file
  2479. in the root of their project source tree that can be used to test
  2480. development snapshots and create reproducible development environments
  2481. (@pxref{Invoking guix environment}).
  2482. The @var{file} may also contain a JSON representation of one or more
  2483. package definitions. Running @code{guix package -f} on
  2484. @file{hello.json} with the following contents would result in installing
  2485. the package @code{greeter} after building @code{myhello}:
  2486. @example
  2487. @verbatiminclude package-hello.json
  2488. @end example
  2489. @item --remove=@var{package} @dots{}
  2490. @itemx -r @var{package} @dots{}
  2491. Remove the specified @var{package}s.
  2492. As for @option{--install}, each @var{package} may specify a version number
  2493. and/or output name in addition to the package name. For instance,
  2494. @samp{-r glibc:debug} would remove the @code{debug} output of
  2495. @code{glibc}.
  2496. @item --upgrade[=@var{regexp} @dots{}]
  2497. @itemx -u [@var{regexp} @dots{}]
  2498. @cindex upgrading packages
  2499. Upgrade all the installed packages. If one or more @var{regexp}s are
  2500. specified, upgrade only installed packages whose name matches a
  2501. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2502. Note that this upgrades package to the latest version of packages found
  2503. in the distribution currently installed. To update your distribution,
  2504. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2505. pull}).
  2506. @cindex package transformations, upgrades
  2507. When upgrading, package transformations that were originally applied
  2508. when creating the profile are automatically re-applied (@pxref{Package
  2509. Transformation Options}). For example, assume you first installed Emacs
  2510. from the tip of its development branch with:
  2511. @example
  2512. guix install emacs-next --with-branch=emacs-next=master
  2513. @end example
  2514. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2515. of the Emacs development branch and build @code{emacs-next} from that
  2516. checkout.
  2517. Note that transformation options such as @option{--with-branch} and
  2518. @option{--with-source} depend on external state; it is up to you to
  2519. ensure that they work as expected. You can also discard a
  2520. transformations that apply to a package by running:
  2521. @example
  2522. guix install @var{package}
  2523. @end example
  2524. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2525. When used together with the @option{--upgrade} option, do @emph{not}
  2526. upgrade any packages whose name matches a @var{regexp}. For example, to
  2527. upgrade all packages in the current profile except those containing the
  2528. substring ``emacs'':
  2529. @example
  2530. $ guix package --upgrade . --do-not-upgrade emacs
  2531. @end example
  2532. @item @anchor{profile-manifest}--manifest=@var{file}
  2533. @itemx -m @var{file}
  2534. @cindex profile declaration
  2535. @cindex profile manifest
  2536. Create a new generation of the profile from the manifest object
  2537. returned by the Scheme code in @var{file}. This option can be repeated
  2538. several times, in which case the manifests are concatenated.
  2539. This allows you to @emph{declare} the profile's contents rather than
  2540. constructing it through a sequence of @option{--install} and similar
  2541. commands. The advantage is that @var{file} can be put under version
  2542. control, copied to different machines to reproduce the same profile, and
  2543. so on.
  2544. @c FIXME: Add reference to (guix profile) documentation when available.
  2545. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2546. of packages:
  2547. @findex packages->manifest
  2548. @lisp
  2549. (use-package-modules guile emacs)
  2550. (packages->manifest
  2551. (list emacs
  2552. guile-2.0
  2553. ;; Use a specific package output.
  2554. (list guile-2.0 "debug")))
  2555. @end lisp
  2556. @findex specifications->manifest
  2557. In this example we have to know which modules define the @code{emacs}
  2558. and @code{guile-2.0} variables to provide the right
  2559. @code{use-package-modules} line, which can be cumbersome. We can
  2560. instead provide regular package specifications and let
  2561. @code{specifications->manifest} look up the corresponding package
  2562. objects, like this:
  2563. @lisp
  2564. (specifications->manifest
  2565. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2566. @end lisp
  2567. @item --roll-back
  2568. @cindex rolling back
  2569. @cindex undoing transactions
  2570. @cindex transactions, undoing
  2571. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2572. the last transaction.
  2573. When combined with options such as @option{--install}, roll back occurs
  2574. before any other actions.
  2575. When rolling back from the first generation that actually contains
  2576. installed packages, the profile is made to point to the @dfn{zeroth
  2577. generation}, which contains no files apart from its own metadata.
  2578. After having rolled back, installing, removing, or upgrading packages
  2579. overwrites previous future generations. Thus, the history of the
  2580. generations in a profile is always linear.
  2581. @item --switch-generation=@var{pattern}
  2582. @itemx -S @var{pattern}
  2583. @cindex generations
  2584. Switch to a particular generation defined by @var{pattern}.
  2585. @var{pattern} may be either a generation number or a number prefixed
  2586. with ``+'' or ``-''. The latter means: move forward/backward by a
  2587. specified number of generations. For example, if you want to return to
  2588. the latest generation after @option{--roll-back}, use
  2589. @option{--switch-generation=+1}.
  2590. The difference between @option{--roll-back} and
  2591. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2592. not make a zeroth generation, so if a specified generation does not
  2593. exist, the current generation will not be changed.
  2594. @item --search-paths[=@var{kind}]
  2595. @cindex search paths
  2596. Report environment variable definitions, in Bash syntax, that may be
  2597. needed in order to use the set of installed packages. These environment
  2598. variables are used to specify @dfn{search paths} for files used by some
  2599. of the installed packages.
  2600. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2601. environment variables to be defined so it can look for headers and
  2602. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2603. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2604. library are installed in the profile, then @option{--search-paths} will
  2605. suggest setting these variables to @file{@var{profile}/include} and
  2606. @file{@var{profile}/lib}, respectively.
  2607. The typical use case is to define these environment variables in the
  2608. shell:
  2609. @example
  2610. $ eval `guix package --search-paths`
  2611. @end example
  2612. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2613. meaning that the returned environment variable definitions will either
  2614. be exact settings, or prefixes or suffixes of the current value of these
  2615. variables. When omitted, @var{kind} defaults to @code{exact}.
  2616. This option can also be used to compute the @emph{combined} search paths
  2617. of several profiles. Consider this example:
  2618. @example
  2619. $ guix package -p foo -i guile
  2620. $ guix package -p bar -i guile-json
  2621. $ guix package -p foo -p bar --search-paths
  2622. @end example
  2623. The last command above reports about the @env{GUILE_LOAD_PATH}
  2624. variable, even though, taken individually, neither @file{foo} nor
  2625. @file{bar} would lead to that recommendation.
  2626. @item --profile=@var{profile}
  2627. @itemx -p @var{profile}
  2628. Use @var{profile} instead of the user's default profile.
  2629. @var{profile} must be the name of a file that will be created upon
  2630. completion. Concretely, @var{profile} will be a mere symbolic link
  2631. (``symlink'') pointing to the actual profile where packages are
  2632. installed:
  2633. @example
  2634. $ guix install hello -p ~/code/my-profile
  2635. @dots{}
  2636. $ ~/code/my-profile/bin/hello
  2637. Hello, world!
  2638. @end example
  2639. All it takes to get rid of the profile is to remove this symlink and its
  2640. siblings that point to specific generations:
  2641. @example
  2642. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2643. @end example
  2644. @item --list-profiles
  2645. List all the user's profiles:
  2646. @example
  2647. $ guix package --list-profiles
  2648. /home/charlie/.guix-profile
  2649. /home/charlie/code/my-profile
  2650. /home/charlie/code/devel-profile
  2651. /home/charlie/tmp/test
  2652. @end example
  2653. When running as root, list all the profiles of all the users.
  2654. @cindex collisions, in a profile
  2655. @cindex colliding packages in profiles
  2656. @cindex profile collisions
  2657. @item --allow-collisions
  2658. Allow colliding packages in the new profile. Use at your own risk!
  2659. By default, @command{guix package} reports as an error @dfn{collisions}
  2660. in the profile. Collisions happen when two or more different versions
  2661. or variants of a given package end up in the profile.
  2662. @item --bootstrap
  2663. Use the bootstrap Guile to build the profile. This option is only
  2664. useful to distribution developers.
  2665. @end table
  2666. In addition to these actions, @command{guix package} supports the
  2667. following options to query the current state of a profile, or the
  2668. availability of packages:
  2669. @table @option
  2670. @item --search=@var{regexp}
  2671. @itemx -s @var{regexp}
  2672. @anchor{guix-search}
  2673. @cindex searching for packages
  2674. List the available packages whose name, synopsis, or description matches
  2675. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2676. Print all the metadata of matching packages in
  2677. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2678. GNU recutils manual}).
  2679. This allows specific fields to be extracted using the @command{recsel}
  2680. command, for instance:
  2681. @example
  2682. $ guix package -s malloc | recsel -p name,version,relevance
  2683. name: jemalloc
  2684. version: 4.5.0
  2685. relevance: 6
  2686. name: glibc
  2687. version: 2.25
  2688. relevance: 1
  2689. name: libgc
  2690. version: 7.6.0
  2691. relevance: 1
  2692. @end example
  2693. Similarly, to show the name of all the packages available under the
  2694. terms of the GNU@tie{}LGPL version 3:
  2695. @example
  2696. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2697. name: elfutils
  2698. name: gmp
  2699. @dots{}
  2700. @end example
  2701. It is also possible to refine search results using several @code{-s} flags to
  2702. @command{guix package}, or several arguments to @command{guix search}. For
  2703. example, the following command returns a list of board games (this time using
  2704. the @command{guix search} alias):
  2705. @example
  2706. $ guix search '\<board\>' game | recsel -p name
  2707. name: gnubg
  2708. @dots{}
  2709. @end example
  2710. If we were to omit @code{-s game}, we would also get software packages
  2711. that deal with printed circuit boards; removing the angle brackets
  2712. around @code{board} would further add packages that have to do with
  2713. keyboards.
  2714. And now for a more elaborate example. The following command searches
  2715. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2716. libraries, and prints the name and synopsis of the matching packages:
  2717. @example
  2718. $ guix search crypto library | \
  2719. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2720. @end example
  2721. @noindent
  2722. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2723. information on @dfn{selection expressions} for @code{recsel -e}.
  2724. @item --show=@var{package}
  2725. Show details about @var{package}, taken from the list of available packages, in
  2726. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2727. recutils manual}).
  2728. @example
  2729. $ guix package --show=python | recsel -p name,version
  2730. name: python
  2731. version: 2.7.6
  2732. name: python
  2733. version: 3.3.5
  2734. @end example
  2735. You may also specify the full name of a package to only get details about a
  2736. specific version of it (this time using the @command{guix show} alias):
  2737. @example
  2738. $ guix show python@@3.4 | recsel -p name,version
  2739. name: python
  2740. version: 3.4.3
  2741. @end example
  2742. @item --list-installed[=@var{regexp}]
  2743. @itemx -I [@var{regexp}]
  2744. List the currently installed packages in the specified profile, with the
  2745. most recently installed packages shown last. When @var{regexp} is
  2746. specified, list only installed packages whose name matches @var{regexp}.
  2747. For each installed package, print the following items, separated by
  2748. tabs: the package name, its version string, the part of the package that
  2749. is installed (for instance, @code{out} for the default output,
  2750. @code{include} for its headers, etc.), and the path of this package in
  2751. the store.
  2752. @item --list-available[=@var{regexp}]
  2753. @itemx -A [@var{regexp}]
  2754. List packages currently available in the distribution for this system
  2755. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2756. available packages whose name matches @var{regexp}.
  2757. For each package, print the following items separated by tabs: its name,
  2758. its version string, the parts of the package (@pxref{Packages with
  2759. Multiple Outputs}), and the source location of its definition.
  2760. @item --list-generations[=@var{pattern}]
  2761. @itemx -l [@var{pattern}]
  2762. @cindex generations
  2763. Return a list of generations along with their creation dates; for each
  2764. generation, show the installed packages, with the most recently
  2765. installed packages shown last. Note that the zeroth generation is never
  2766. shown.
  2767. For each installed package, print the following items, separated by
  2768. tabs: the name of a package, its version string, the part of the package
  2769. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2770. location of this package in the store.
  2771. When @var{pattern} is used, the command returns only matching
  2772. generations. Valid patterns include:
  2773. @itemize
  2774. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2775. generation numbers. For instance, @option{--list-generations=1} returns
  2776. the first one.
  2777. And @option{--list-generations=1,8,2} outputs three generations in the
  2778. specified order. Neither spaces nor trailing commas are allowed.
  2779. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2780. specified generations and everything in between. Note that the start of
  2781. a range must be smaller than its end.
  2782. It is also possible to omit the endpoint. For example,
  2783. @option{--list-generations=2..}, returns all generations starting from the
  2784. second one.
  2785. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2786. or months by passing an integer along with the first letter of the
  2787. duration. For example, @option{--list-generations=20d} lists generations
  2788. that are up to 20 days old.
  2789. @end itemize
  2790. @item --delete-generations[=@var{pattern}]
  2791. @itemx -d [@var{pattern}]
  2792. When @var{pattern} is omitted, delete all generations except the current
  2793. one.
  2794. This command accepts the same patterns as @option{--list-generations}.
  2795. When @var{pattern} is specified, delete the matching generations. When
  2796. @var{pattern} specifies a duration, generations @emph{older} than the
  2797. specified duration match. For instance, @option{--delete-generations=1m}
  2798. deletes generations that are more than one month old.
  2799. If the current generation matches, it is @emph{not} deleted. Also, the
  2800. zeroth generation is never deleted.
  2801. Note that deleting generations prevents rolling back to them.
  2802. Consequently, this command must be used with care.
  2803. @end table
  2804. Finally, since @command{guix package} may actually start build
  2805. processes, it supports all the common build options (@pxref{Common Build
  2806. Options}). It also supports package transformation options, such as
  2807. @option{--with-source} (@pxref{Package Transformation Options}).
  2808. However, note that package transformations are lost when upgrading; to
  2809. preserve transformations across upgrades, you should define your own
  2810. package variant in a Guile module and add it to @env{GUIX_PACKAGE_PATH}
  2811. (@pxref{Defining Packages}).
  2812. @node Substitutes
  2813. @section Substitutes
  2814. @cindex substitutes
  2815. @cindex pre-built binaries
  2816. Guix supports transparent source/binary deployment, which means that it
  2817. can either build things locally, or download pre-built items from a
  2818. server, or both. We call these pre-built items @dfn{substitutes}---they
  2819. are substitutes for local build results. In many cases, downloading a
  2820. substitute is much faster than building things locally.
  2821. Substitutes can be anything resulting from a derivation build
  2822. (@pxref{Derivations}). Of course, in the common case, they are
  2823. pre-built package binaries, but source tarballs, for instance, which
  2824. also result from derivation builds, can be available as substitutes.
  2825. @menu
  2826. * Official Substitute Server:: One particular source of substitutes.
  2827. * Substitute Server Authorization:: How to enable or disable substitutes.
  2828. * Substitute Authentication:: How Guix verifies substitutes.
  2829. * Proxy Settings:: How to get substitutes via proxy.
  2830. * Substitution Failure:: What happens when substitution fails.
  2831. * On Trusting Binaries:: How can you trust that binary blob?
  2832. @end menu
  2833. @node Official Substitute Server
  2834. @subsection Official Substitute Server
  2835. @cindex build farm
  2836. The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
  2837. that builds packages from Guix continuously for some
  2838. architectures, and makes them available as substitutes. This is the
  2839. default source of substitutes; it can be overridden by passing the
  2840. @option{--substitute-urls} option either to @command{guix-daemon}
  2841. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  2842. or to client tools such as @command{guix package}
  2843. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  2844. option}).
  2845. Substitute URLs can be either HTTP or HTTPS.
  2846. HTTPS is recommended because communications are encrypted; conversely,
  2847. using HTTP makes all communications visible to an eavesdropper, who
  2848. could use the information gathered to determine, for instance, whether
  2849. your system has unpatched security vulnerabilities.
  2850. Substitutes from the official build farm are enabled by default when
  2851. using Guix System (@pxref{GNU Distribution}). However,
  2852. they are disabled by default when using Guix on a foreign distribution,
  2853. unless you have explicitly enabled them via one of the recommended
  2854. installation steps (@pxref{Installation}). The following paragraphs
  2855. describe how to enable or disable substitutes for the official build
  2856. farm; the same procedure can also be used to enable substitutes for any
  2857. other substitute server.
  2858. @node Substitute Server Authorization
  2859. @subsection Substitute Server Authorization
  2860. @cindex security
  2861. @cindex substitutes, authorization thereof
  2862. @cindex access control list (ACL), for substitutes
  2863. @cindex ACL (access control list), for substitutes
  2864. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
  2865. mirror thereof, you
  2866. must add its public key to the access control list (ACL) of archive
  2867. imports, using the @command{guix archive} command (@pxref{Invoking guix
  2868. archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
  2869. be compromised and to serve genuine substitutes.
  2870. The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
  2871. @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
  2872. the installation prefix of Guix. If you installed Guix from source,
  2873. make sure you checked the GPG signature of
  2874. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  2875. Then, you can run something like this:
  2876. @example
  2877. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
  2878. @end example
  2879. Once this is in place, the output of a command like @code{guix build}
  2880. should change from something like:
  2881. @example
  2882. $ guix build emacs --dry-run
  2883. The following derivations would be built:
  2884. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  2885. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  2886. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  2887. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  2888. @dots{}
  2889. @end example
  2890. @noindent
  2891. to something like:
  2892. @example
  2893. $ guix build emacs --dry-run
  2894. 112.3 MB would be downloaded:
  2895. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  2896. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  2897. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  2898. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  2899. @dots{}
  2900. @end example
  2901. @noindent
  2902. The text changed from ``The following derivations would be built'' to
  2903. ``112.3 MB would be downloaded''. This indicates that substitutes from
  2904. @code{@value{SUBSTITUTE-SERVER}} are usable and will be downloaded, when
  2905. possible, for future builds.
  2906. @cindex substitutes, how to disable
  2907. The substitute mechanism can be disabled globally by running
  2908. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  2909. guix-daemon}). It can also be disabled temporarily by passing the
  2910. @option{--no-substitutes} option to @command{guix package},
  2911. @command{guix build}, and other command-line tools.
  2912. @node Substitute Authentication
  2913. @subsection Substitute Authentication
  2914. @cindex digital signatures
  2915. Guix detects and raises an error when attempting to use a substitute
  2916. that has been tampered with. Likewise, it ignores substitutes that are
  2917. not signed, or that are not signed by one of the keys listed in the ACL.
  2918. There is one exception though: if an unauthorized server provides
  2919. substitutes that are @emph{bit-for-bit identical} to those provided by
  2920. an authorized server, then the unauthorized server becomes eligible for
  2921. downloads. For example, assume we have chosen two substitute servers
  2922. with this option:
  2923. @example
  2924. --substitute-urls="https://a.example.org https://b.example.org"
  2925. @end example
  2926. @noindent
  2927. @cindex reproducible builds
  2928. If the ACL contains only the key for @samp{b.example.org}, and if
  2929. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  2930. then Guix will download substitutes from @samp{a.example.org} because it
  2931. comes first in the list and can be considered a mirror of
  2932. @samp{b.example.org}. In practice, independent build machines usually
  2933. produce the same binaries, thanks to bit-reproducible builds (see
  2934. below).
  2935. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  2936. (in other words, the server is not authenticated), contrary to what
  2937. HTTPS clients such as Web browsers usually do. This is because Guix
  2938. authenticates substitute information itself, as explained above, which
  2939. is what we care about (whereas X.509 certificates are about
  2940. authenticating bindings between domain names and public keys).
  2941. @node Proxy Settings
  2942. @subsection Proxy Settings
  2943. @vindex http_proxy
  2944. @vindex https_proxy
  2945. Substitutes are downloaded over HTTP or HTTPS. The @env{http_proxy} and
  2946. @env{https_proxy} environment variables can be set in the environment of
  2947. @command{guix-daemon} and are honored for downloads of substitutes.
  2948. Note that the value of those environment variables in the environment
  2949. where @command{guix build}, @command{guix package}, and other client
  2950. commands are run has @emph{absolutely no effect}.
  2951. @node Substitution Failure
  2952. @subsection Substitution Failure
  2953. Even when a substitute for a derivation is available, sometimes the
  2954. substitution attempt will fail. This can happen for a variety of
  2955. reasons: the substitute server might be offline, the substitute may
  2956. recently have been deleted, the connection might have been interrupted,
  2957. etc.
  2958. When substitutes are enabled and a substitute for a derivation is
  2959. available, but the substitution attempt fails, Guix will attempt to
  2960. build the derivation locally depending on whether or not
  2961. @option{--fallback} was given (@pxref{fallback-option,, common build
  2962. option @option{--fallback}}). Specifically, if @option{--fallback} was
  2963. omitted, then no local build will be performed, and the derivation is
  2964. considered to have failed. However, if @option{--fallback} was given,
  2965. then Guix will attempt to build the derivation locally, and the success
  2966. or failure of the derivation depends on the success or failure of the
  2967. local build. Note that when substitutes are disabled or no substitute
  2968. is available for the derivation in question, a local build will
  2969. @emph{always} be performed, regardless of whether or not
  2970. @option{--fallback} was given.
  2971. To get an idea of how many substitutes are available right now, you can
  2972. try running the @command{guix weather} command (@pxref{Invoking guix
  2973. weather}). This command provides statistics on the substitutes provided
  2974. by a server.
  2975. @node On Trusting Binaries
  2976. @subsection On Trusting Binaries
  2977. @cindex trust, of pre-built binaries
  2978. Today, each individual's control over their own computing is at the
  2979. mercy of institutions, corporations, and groups with enough power and
  2980. determination to subvert the computing infrastructure and exploit its
  2981. weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
  2982. convenient, we encourage users to also build on their own, or even run
  2983. their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
  2984. interesting target. One way to help is by publishing the software you
  2985. build using @command{guix publish} so that others have one more choice
  2986. of server to download substitutes from (@pxref{Invoking guix publish}).
  2987. Guix has the foundations to maximize build reproducibility
  2988. (@pxref{Features}). In most cases, independent builds of a given
  2989. package or derivation should yield bit-identical results. Thus, through
  2990. a diverse set of independent package builds, we can strengthen the
  2991. integrity of our systems. The @command{guix challenge} command aims to
  2992. help users assess substitute servers, and to assist developers in
  2993. finding out about non-deterministic package builds (@pxref{Invoking guix
  2994. challenge}). Similarly, the @option{--check} option of @command{guix
  2995. build} allows users to check whether previously-installed substitutes
  2996. are genuine by rebuilding them locally (@pxref{build-check,
  2997. @command{guix build --check}}).
  2998. In the future, we want Guix to have support to publish and retrieve
  2999. binaries to/from other users, in a peer-to-peer fashion. If you would
  3000. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3001. @node Packages with Multiple Outputs
  3002. @section Packages with Multiple Outputs
  3003. @cindex multiple-output packages
  3004. @cindex package outputs
  3005. @cindex outputs
  3006. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3007. source package leads to exactly one directory in the store. When running
  3008. @command{guix install glibc}, one installs the default output of the
  3009. GNU libc package; the default output is called @code{out}, but its name
  3010. can be omitted as shown in this command. In this particular case, the
  3011. default output of @code{glibc} contains all the C header files, shared
  3012. libraries, static libraries, Info documentation, and other supporting
  3013. files.
  3014. Sometimes it is more appropriate to separate the various types of files
  3015. produced from a single source package into separate outputs. For
  3016. instance, the GLib C library (used by GTK+ and related packages)
  3017. installs more than 20 MiB of reference documentation as HTML pages.
  3018. To save space for users who do not need it, the documentation goes to a
  3019. separate output, called @code{doc}. To install the main GLib output,
  3020. which contains everything but the documentation, one would run:
  3021. @example
  3022. guix install glib
  3023. @end example
  3024. @cindex documentation
  3025. The command to install its documentation is:
  3026. @example
  3027. guix install glib:doc
  3028. @end example
  3029. Some packages install programs with different ``dependency footprints''.
  3030. For instance, the WordNet package installs both command-line tools and
  3031. graphical user interfaces (GUIs). The former depend solely on the C
  3032. library, whereas the latter depend on Tcl/Tk and the underlying X
  3033. libraries. In this case, we leave the command-line tools in the default
  3034. output, whereas the GUIs are in a separate output. This allows users
  3035. who do not need the GUIs to save space. The @command{guix size} command
  3036. can help find out about such situations (@pxref{Invoking guix size}).
  3037. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3038. There are several such multiple-output packages in the GNU distribution.
  3039. Other conventional output names include @code{lib} for libraries and
  3040. possibly header files, @code{bin} for stand-alone programs, and
  3041. @code{debug} for debugging information (@pxref{Installing Debugging
  3042. Files}). The outputs of a packages are listed in the third column of
  3043. the output of @command{guix package --list-available} (@pxref{Invoking
  3044. guix package}).
  3045. @node Invoking guix gc
  3046. @section Invoking @command{guix gc}
  3047. @cindex garbage collector
  3048. @cindex disk space
  3049. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3050. The @command{guix gc} command allows users to explicitly run the garbage
  3051. collector to reclaim space from the @file{/gnu/store} directory. It is
  3052. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3053. files or directories manually may break it beyond repair!
  3054. @cindex GC roots
  3055. @cindex garbage collector roots
  3056. The garbage collector has a set of known @dfn{roots}: any file under
  3057. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3058. cannot be deleted; any other file is considered @dfn{dead} and may be
  3059. deleted. The set of garbage collector roots (``GC roots'' for short)
  3060. includes default user profiles; by default, the symlinks under
  3061. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3062. added with @command{guix build --root}, for example (@pxref{Invoking
  3063. guix build}). The @command{guix gc --list-roots} command lists them.
  3064. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3065. often useful to remove old generations from user profiles; that way, old
  3066. package builds referenced by those generations can be reclaimed. This
  3067. is achieved by running @code{guix package --delete-generations}
  3068. (@pxref{Invoking guix package}).
  3069. Our recommendation is to run a garbage collection periodically, or when
  3070. you are short on disk space. For instance, to guarantee that at least
  3071. 5@tie{}GB are available on your disk, simply run:
  3072. @example
  3073. guix gc -F 5G
  3074. @end example
  3075. It is perfectly safe to run as a non-interactive periodic job
  3076. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3077. Running @command{guix gc} with no arguments will collect as
  3078. much garbage as it can, but that is often inconvenient: you may find
  3079. yourself having to rebuild or re-download software that is ``dead'' from
  3080. the GC viewpoint but that is necessary to build other pieces of
  3081. software---e.g., the compiler tool chain.
  3082. The @command{guix gc} command has three modes of operation: it can be
  3083. used to garbage-collect any dead files (the default), to delete specific
  3084. files (the @option{--delete} option), to print garbage-collector
  3085. information, or for more advanced queries. The garbage collection
  3086. options are as follows:
  3087. @table @code
  3088. @item --collect-garbage[=@var{min}]
  3089. @itemx -C [@var{min}]
  3090. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3091. sub-directories. This is the default operation when no option is
  3092. specified.
  3093. When @var{min} is given, stop once @var{min} bytes have been collected.
  3094. @var{min} may be a number of bytes, or it may include a unit as a
  3095. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3096. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3097. When @var{min} is omitted, collect all the garbage.
  3098. @item --free-space=@var{free}
  3099. @itemx -F @var{free}
  3100. Collect garbage until @var{free} space is available under
  3101. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3102. as @code{500MiB}, as described above.
  3103. When @var{free} or more is already available in @file{/gnu/store}, do
  3104. nothing and exit immediately.
  3105. @item --delete-generations[=@var{duration}]
  3106. @itemx -d [@var{duration}]
  3107. Before starting the garbage collection process, delete all the generations
  3108. older than @var{duration}, for all the user profiles; when run as root, this
  3109. applies to all the profiles @emph{of all the users}.
  3110. For example, this command deletes all the generations of all your profiles
  3111. that are older than 2 months (except generations that are current), and then
  3112. proceeds to free space until at least 10 GiB are available:
  3113. @example
  3114. guix gc -d 2m -F 10G
  3115. @end example
  3116. @item --delete
  3117. @itemx -D
  3118. Attempt to delete all the store files and directories specified as
  3119. arguments. This fails if some of the files are not in the store, or if
  3120. they are still live.
  3121. @item --list-failures
  3122. List store items corresponding to cached build failures.
  3123. This prints nothing unless the daemon was started with
  3124. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3125. @option{--cache-failures}}).
  3126. @item --list-roots
  3127. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3128. roots.
  3129. @item --list-busy
  3130. List store items in use by currently running processes. These store
  3131. items are effectively considered GC roots: they cannot be deleted.
  3132. @item --clear-failures
  3133. Remove the specified store items from the failed-build cache.
  3134. Again, this option only makes sense when the daemon is started with
  3135. @option{--cache-failures}. Otherwise, it does nothing.
  3136. @item --list-dead
  3137. Show the list of dead files and directories still present in the
  3138. store---i.e., files and directories no longer reachable from any root.
  3139. @item --list-live
  3140. Show the list of live store files and directories.
  3141. @end table
  3142. In addition, the references among existing store files can be queried:
  3143. @table @code
  3144. @item --references
  3145. @itemx --referrers
  3146. @cindex package dependencies
  3147. List the references (respectively, the referrers) of store files given
  3148. as arguments.
  3149. @item --requisites
  3150. @itemx -R
  3151. @cindex closure
  3152. List the requisites of the store files passed as arguments. Requisites
  3153. include the store files themselves, their references, and the references
  3154. of these, recursively. In other words, the returned list is the
  3155. @dfn{transitive closure} of the store files.
  3156. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3157. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3158. the graph of references.
  3159. @item --derivers
  3160. @cindex derivation
  3161. Return the derivation(s) leading to the given store items
  3162. (@pxref{Derivations}).
  3163. For example, this command:
  3164. @example
  3165. guix gc --derivers `guix package -I ^emacs$ | cut -f4`
  3166. @end example
  3167. @noindent
  3168. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3169. installed in your profile.
  3170. Note that there may be zero matching @file{.drv} files, for instance
  3171. because these files have been garbage-collected. There can also be more
  3172. than one matching @file{.drv} due to fixed-output derivations.
  3173. @end table
  3174. Lastly, the following options allow you to check the integrity of the
  3175. store and to control disk usage.
  3176. @table @option
  3177. @item --verify[=@var{options}]
  3178. @cindex integrity, of the store
  3179. @cindex integrity checking
  3180. Verify the integrity of the store.
  3181. By default, make sure that all the store items marked as valid in the
  3182. database of the daemon actually exist in @file{/gnu/store}.
  3183. When provided, @var{options} must be a comma-separated list containing one
  3184. or more of @code{contents} and @code{repair}.
  3185. When passing @option{--verify=contents}, the daemon computes the
  3186. content hash of each store item and compares it against its hash in the
  3187. database. Hash mismatches are reported as data corruptions. Because it
  3188. traverses @emph{all the files in the store}, this command can take a
  3189. long time, especially on systems with a slow disk drive.
  3190. @cindex repairing the store
  3191. @cindex corruption, recovering from
  3192. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3193. causes the daemon to try to repair corrupt store items by fetching
  3194. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3195. atomic, and thus potentially dangerous, it is available only to the
  3196. system administrator. A lightweight alternative, when you know exactly
  3197. which items in the store are corrupt, is @command{guix build --repair}
  3198. (@pxref{Invoking guix build}).
  3199. @item --optimize
  3200. @cindex deduplication
  3201. Optimize the store by hard-linking identical files---this is
  3202. @dfn{deduplication}.
  3203. The daemon performs deduplication after each successful build or archive
  3204. import, unless it was started with @option{--disable-deduplication}
  3205. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3206. this option is primarily useful when the daemon was running with
  3207. @option{--disable-deduplication}.
  3208. @end table
  3209. @node Invoking guix pull
  3210. @section Invoking @command{guix pull}
  3211. @cindex upgrading Guix
  3212. @cindex updating Guix
  3213. @cindex @command{guix pull}
  3214. @cindex pull
  3215. @cindex security, @command{guix pull}
  3216. @cindex authenticity, of code obtained with @command{guix pull}
  3217. Packages are installed or upgraded to the latest version available in
  3218. the distribution currently available on your local machine. To update
  3219. that distribution, along with the Guix tools, you must run @command{guix
  3220. pull}: the command downloads the latest Guix source code and package
  3221. descriptions, and deploys it. Source code is downloaded from a
  3222. @uref{https://git-scm.com, Git} repository, by default the official
  3223. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3224. pull} ensures that the code it downloads is @emph{authentic} by
  3225. verifying that commits are signed by Guix developers.
  3226. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3227. (@pxref{Channels}) specified by one of the followings, in this order:
  3228. @enumerate
  3229. @item
  3230. the @option{--channels} option;
  3231. @item
  3232. the user's @file{~/.config/guix/channels.scm} file;
  3233. @item
  3234. the system-wide @file{/etc/guix/channels.scm} file;
  3235. @item
  3236. the built-in default channels specified in the @code{%default-channels}
  3237. variable.
  3238. @end enumerate
  3239. On completion, @command{guix package} will use packages and package
  3240. versions from this just-retrieved copy of Guix. Not only that, but all
  3241. the Guix commands and Scheme modules will also be taken from that latest
  3242. version. New @command{guix} sub-commands added by the update also
  3243. become available.
  3244. Any user can update their Guix copy using @command{guix pull}, and the
  3245. effect is limited to the user who ran @command{guix pull}. For
  3246. instance, when user @code{root} runs @command{guix pull}, this has no
  3247. effect on the version of Guix that user @code{alice} sees, and vice
  3248. versa.
  3249. The result of running @command{guix pull} is a @dfn{profile} available
  3250. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3251. make sure to add it to the beginning of your search path so that you use
  3252. the latest version, and similarly for the Info manual
  3253. (@pxref{Documentation}):
  3254. @example
  3255. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3256. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3257. @end example
  3258. The @option{--list-generations} or @option{-l} option lists past generations
  3259. produced by @command{guix pull}, along with details about their provenance:
  3260. @example
  3261. $ guix pull -l
  3262. Generation 1 Jun 10 2018 00:18:18
  3263. guix 65956ad
  3264. repository URL: https://git.savannah.gnu.org/git/guix.git
  3265. branch: origin/master
  3266. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3267. Generation 2 Jun 11 2018 11:02:49
  3268. guix e0cc7f6
  3269. repository URL: https://git.savannah.gnu.org/git/guix.git
  3270. branch: origin/master
  3271. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3272. 2 new packages: keepalived, libnfnetlink
  3273. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3274. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3275. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3276. Generation 3 Jun 13 2018 23:31:07 (current)
  3277. guix 844cc1c
  3278. repository URL: https://git.savannah.gnu.org/git/guix.git
  3279. branch: origin/master
  3280. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3281. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3282. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3283. @end example
  3284. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3285. describe the current status of Guix.
  3286. This @code{~/.config/guix/current} profile works exactly like the profiles
  3287. created by @command{guix package} (@pxref{Invoking guix package}). That
  3288. is, you can list generations, roll back to the previous
  3289. generation---i.e., the previous Guix---and so on:
  3290. @example
  3291. $ guix pull --roll-back
  3292. switched from generation 3 to 2
  3293. $ guix pull --delete-generations=1
  3294. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3295. @end example
  3296. You can also use @command{guix package} (@pxref{Invoking guix package})
  3297. to manage the profile by naming it explicitly:
  3298. @example
  3299. $ guix package -p ~/.config/guix/current --roll-back
  3300. switched from generation 3 to 2
  3301. $ guix package -p ~/.config/guix/current --delete-generations=1
  3302. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3303. @end example
  3304. The @command{guix pull} command is usually invoked with no arguments,
  3305. but it supports the following options:
  3306. @table @code
  3307. @item --url=@var{url}
  3308. @itemx --commit=@var{commit}
  3309. @itemx --branch=@var{branch}
  3310. Download code for the @code{guix} channel from the specified @var{url}, at the
  3311. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3312. string), or @var{branch}.
  3313. @cindex @file{channels.scm}, configuration file
  3314. @cindex configuration file for channels
  3315. These options are provided for convenience, but you can also specify your
  3316. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3317. @option{--channels} option (see below).
  3318. @item --channels=@var{file}
  3319. @itemx -C @var{file}
  3320. Read the list of channels from @var{file} instead of
  3321. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3322. @var{file} must contain Scheme code that
  3323. evaluates to a list of channel objects. @xref{Channels}, for more
  3324. information.
  3325. @cindex channel news
  3326. @item --news
  3327. @itemx -N
  3328. Display the list of packages added or upgraded since the previous
  3329. generation, as well as, occasionally, news written by channel authors
  3330. for their users (@pxref{Channels, Writing Channel News}).
  3331. The package information is the same as displayed upon @command{guix
  3332. pull} completion, but without ellipses; it is also similar to the output
  3333. of @command{guix pull -l} for the last generation (see below).
  3334. @item --list-generations[=@var{pattern}]
  3335. @itemx -l [@var{pattern}]
  3336. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3337. is provided, the subset of generations that match @var{pattern}.
  3338. The syntax of @var{pattern} is the same as with @code{guix package
  3339. --list-generations} (@pxref{Invoking guix package}).
  3340. @item --roll-back
  3341. @cindex rolling back
  3342. @cindex undoing transactions
  3343. @cindex transactions, undoing
  3344. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3345. undo the last transaction.
  3346. @item --switch-generation=@var{pattern}
  3347. @itemx -S @var{pattern}
  3348. @cindex generations
  3349. Switch to a particular generation defined by @var{pattern}.
  3350. @var{pattern} may be either a generation number or a number prefixed
  3351. with ``+'' or ``-''. The latter means: move forward/backward by a
  3352. specified number of generations. For example, if you want to return to
  3353. the latest generation after @option{--roll-back}, use
  3354. @option{--switch-generation=+1}.
  3355. @item --delete-generations[=@var{pattern}]
  3356. @itemx -d [@var{pattern}]
  3357. When @var{pattern} is omitted, delete all generations except the current
  3358. one.
  3359. This command accepts the same patterns as @option{--list-generations}.
  3360. When @var{pattern} is specified, delete the matching generations. When
  3361. @var{pattern} specifies a duration, generations @emph{older} than the
  3362. specified duration match. For instance, @option{--delete-generations=1m}
  3363. deletes generations that are more than one month old.
  3364. If the current generation matches, it is @emph{not} deleted.
  3365. Note that deleting generations prevents rolling back to them.
  3366. Consequently, this command must be used with care.
  3367. @xref{Invoking guix describe}, for a way to display information about the
  3368. current generation only.
  3369. @item --profile=@var{profile}
  3370. @itemx -p @var{profile}
  3371. Use @var{profile} instead of @file{~/.config/guix/current}.
  3372. @item --dry-run
  3373. @itemx -n
  3374. Show which channel commit(s) would be used and what would be built or
  3375. substituted but do not actually do it.
  3376. @item --allow-downgrades
  3377. Allow pulling older or unrelated revisions of channels than those
  3378. currently in use.
  3379. @cindex downgrade attacks, protection against
  3380. By default, @command{guix pull} protects against so-called ``downgrade
  3381. attacks'' whereby the Git repository of a channel would be reset to an
  3382. earlier or unrelated revision of itself, potentially leading you to
  3383. install older, known-vulnerable versions of software packages.
  3384. @quotation Note
  3385. Make sure you understand its security implications before using
  3386. @option{--allow-downgrades}.
  3387. @end quotation
  3388. @item --disable-authentication
  3389. Allow pulling channel code without authenticating it.
  3390. @cindex authentication, of channel code
  3391. By default, @command{guix pull} authenticates code downloaded from
  3392. channels by verifying that its commits are signed by authorized
  3393. developers, and raises an error if this is not the case. This option
  3394. instructs it to not perform any such verification.
  3395. @quotation Note
  3396. Make sure you understand its security implications before using
  3397. @option{--disable-authentication}.
  3398. @end quotation
  3399. @item --system=@var{system}
  3400. @itemx -s @var{system}
  3401. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3402. the system type of the build host.
  3403. @item --bootstrap
  3404. Use the bootstrap Guile to build the latest Guix. This option is only
  3405. useful to Guix developers.
  3406. @end table
  3407. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3408. repository and branch to pull from, as well as @emph{additional} repositories
  3409. containing package modules that should be deployed. @xref{Channels}, for more
  3410. information.
  3411. In addition, @command{guix pull} supports all the common build options
  3412. (@pxref{Common Build Options}).
  3413. @node Invoking guix time-machine
  3414. @section Invoking @command{guix time-machine}
  3415. @cindex @command{guix time-machine}
  3416. @cindex pinning, channels
  3417. @cindex replicating Guix
  3418. @cindex reproducibility, of Guix
  3419. The @command{guix time-machine} command provides access to other
  3420. revisions of Guix, for example to install older versions of packages,
  3421. or to reproduce a computation in an identical environment. The revision
  3422. of Guix to be used is defined by a commit or by a channel
  3423. description file created by @command{guix describe}
  3424. (@pxref{Invoking guix describe}).
  3425. The general syntax is:
  3426. @example
  3427. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3428. @end example
  3429. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3430. @command{guix} command of the specified revision. The @var{options} that define
  3431. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3432. @table @code
  3433. @item --url=@var{url}
  3434. @itemx --commit=@var{commit}
  3435. @itemx --branch=@var{branch}
  3436. Use the @code{guix} channel from the specified @var{url}, at the
  3437. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3438. string), or @var{branch}.
  3439. @item --channels=@var{file}
  3440. @itemx -C @var{file}
  3441. Read the list of channels from @var{file}. @var{file} must contain
  3442. Scheme code that evaluates to a list of channel objects.
  3443. @xref{Channels} for more information.
  3444. @end table
  3445. As for @command{guix pull}, the absence of any options means that the
  3446. the latest commit on the master branch will be used. The command
  3447. @example
  3448. guix time-machine -- build hello
  3449. @end example
  3450. will thus build the package @code{hello} as defined in the master branch,
  3451. which is in general a newer revision of Guix than you have installed.
  3452. Time travel works in both directions!
  3453. Note that @command{guix time-machine} can trigger builds of channels and
  3454. their dependencies, and these are controlled by the standard build
  3455. options (@pxref{Common Build Options}).
  3456. @node Inferiors
  3457. @section Inferiors
  3458. @c TODO: Remove this once we're more confident about API stability.
  3459. @quotation Note
  3460. The functionality described here is a ``technology preview'' as of version
  3461. @value{VERSION}. As such, the interface is subject to change.
  3462. @end quotation
  3463. @cindex inferiors
  3464. @cindex composition of Guix revisions
  3465. Sometimes you might need to mix packages from the revision of Guix you're
  3466. currently running with packages available in a different revision of Guix.
  3467. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3468. revisions in arbitrary ways.
  3469. @cindex inferior packages
  3470. Technically, an ``inferior'' is essentially a separate Guix process connected
  3471. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3472. @code{(guix inferior)} module allows you to create inferiors and to
  3473. communicate with them. It also provides a high-level interface to browse and
  3474. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3475. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3476. to interact with a separate revision of Guix. For example, let's assume you
  3477. want to install in your profile the current @code{guile} package, along with
  3478. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3479. because the newer @code{guile-json} has an incompatible API and you want to
  3480. run your code against the old API@. To do that, you could write a manifest for
  3481. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3482. manifest, you would create an inferior for that old Guix revision you care
  3483. about, and you would look up the @code{guile-json} package in the inferior:
  3484. @lisp
  3485. (use-modules (guix inferior) (guix channels)
  3486. (srfi srfi-1)) ;for 'first'
  3487. (define channels
  3488. ;; This is the old revision from which we want to
  3489. ;; extract guile-json.
  3490. (list (channel
  3491. (name 'guix)
  3492. (url "https://git.savannah.gnu.org/git/guix.git")
  3493. (commit
  3494. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3495. (define inferior
  3496. ;; An inferior representing the above revision.
  3497. (inferior-for-channels channels))
  3498. ;; Now create a manifest with the current "guile" package
  3499. ;; and the old "guile-json" package.
  3500. (packages->manifest
  3501. (list (first (lookup-inferior-packages inferior "guile-json"))
  3502. (specification->package "guile")))
  3503. @end lisp
  3504. On its first run, @command{guix package --manifest} might have to build the
  3505. channel you specified before it can create the inferior; subsequent runs will
  3506. be much faster because the Guix revision will be cached.
  3507. The @code{(guix inferior)} module provides the following procedures to open an
  3508. inferior:
  3509. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3510. [#:cache-directory] [#:ttl]
  3511. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3512. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3513. This procedure opens a new connection to the build daemon.
  3514. As a side effect, this procedure may build or substitute binaries for
  3515. @var{channels}, which can take time.
  3516. @end deffn
  3517. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3518. [#:command "bin/guix"]
  3519. Open the inferior Guix in @var{directory}, running
  3520. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3521. the inferior could not be launched.
  3522. @end deffn
  3523. @cindex inferior packages
  3524. The procedures listed below allow you to obtain and manipulate inferior
  3525. packages.
  3526. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3527. Return the list of packages known to @var{inferior}.
  3528. @end deffn
  3529. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3530. [@var{version}]
  3531. Return the sorted list of inferior packages matching @var{name} in
  3532. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3533. return only packages with a version number prefixed by @var{version}.
  3534. @end deffn
  3535. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3536. Return true if @var{obj} is an inferior package.
  3537. @end deffn
  3538. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3539. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3540. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3541. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3542. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3543. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3544. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3545. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3546. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3547. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3548. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3549. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3550. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3551. These procedures are the counterpart of package record accessors
  3552. (@pxref{package Reference}). Most of them work by querying the inferior
  3553. @var{package} comes from, so the inferior must still be live when you call
  3554. these procedures.
  3555. @end deffn
  3556. Inferior packages can be used transparently like any other package or
  3557. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3558. transparently handled by the @code{packages->manifest} procedure, which is
  3559. commonly use in manifests (@pxref{Invoking guix package, the
  3560. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3561. an inferior package pretty much anywhere you would insert a regular package:
  3562. in manifests, in the @code{packages} field of your @code{operating-system}
  3563. declaration, and so on.
  3564. @node Invoking guix describe
  3565. @section Invoking @command{guix describe}
  3566. @cindex reproducibility
  3567. @cindex replicating Guix
  3568. Often you may want to answer questions like: ``Which revision of Guix am I
  3569. using?'' or ``Which channels am I using?'' This is useful information in many
  3570. situations: if you want to @emph{replicate} an environment on a different
  3571. machine or user account, if you want to report a bug or to determine what
  3572. change in the channels you are using caused it, or if you want to record your
  3573. system state for reproducibility purposes. The @command{guix describe}
  3574. command answers these questions.
  3575. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3576. displays the channel(s) that it was built from, including their repository URL
  3577. and commit IDs (@pxref{Channels}):
  3578. @example
  3579. $ guix describe
  3580. Generation 10 Sep 03 2018 17:32:44 (current)
  3581. guix e0fa68c
  3582. repository URL: https://git.savannah.gnu.org/git/guix.git
  3583. branch: master
  3584. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3585. @end example
  3586. If you're familiar with the Git version control system, this is similar in
  3587. spirit to @command{git describe}; the output is also similar to that of
  3588. @command{guix pull --list-generations}, but limited to the current generation
  3589. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3590. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3591. information is all it takes to describe the revision of Guix you're using, and
  3592. also to replicate it.
  3593. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3594. to return a list of channels instead of the human-readable description above:
  3595. @example
  3596. $ guix describe -f channels
  3597. (list (channel
  3598. (name 'guix)
  3599. (url "https://git.savannah.gnu.org/git/guix.git")
  3600. (commit
  3601. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3602. (introduction
  3603. (make-channel-introduction
  3604. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3605. (openpgp-fingerprint
  3606. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3607. @end example
  3608. @noindent
  3609. You can save this to a file and feed it to @command{guix pull -C} on some
  3610. other machine or at a later point in time, which will instantiate @emph{this
  3611. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3612. From there on, since you're able to deploy the same revision of Guix, you can
  3613. just as well @emph{replicate a complete software environment}. We humbly
  3614. think that this is @emph{awesome}, and we hope you'll like it too!
  3615. The details of the options supported by @command{guix describe} are as
  3616. follows:
  3617. @table @code
  3618. @item --format=@var{format}
  3619. @itemx -f @var{format}
  3620. Produce output in the specified @var{format}, one of:
  3621. @table @code
  3622. @item human
  3623. produce human-readable output;
  3624. @item channels
  3625. produce a list of channel specifications that can be passed to @command{guix
  3626. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3627. guix pull});
  3628. @item channels-sans-intro
  3629. like @code{channels}, but omit the @code{introduction} field; use it to
  3630. produce a channel specification suitable for Guix version 1.1.0 or
  3631. earlier---the @code{introduction} field has to do with channel
  3632. authentication (@pxref{Channels, Channel Authentication}) and is not
  3633. supported by these older versions;
  3634. @item json
  3635. @cindex JSON
  3636. produce a list of channel specifications in JSON format;
  3637. @item recutils
  3638. produce a list of channel specifications in Recutils format.
  3639. @end table
  3640. @item --list-formats
  3641. Display available formats for @option{--format} option.
  3642. @item --profile=@var{profile}
  3643. @itemx -p @var{profile}
  3644. Display information about @var{profile}.
  3645. @end table
  3646. @node Invoking guix archive
  3647. @section Invoking @command{guix archive}
  3648. @cindex @command{guix archive}
  3649. @cindex archive
  3650. The @command{guix archive} command allows users to @dfn{export} files
  3651. from the store into a single archive, and to later @dfn{import} them on
  3652. a machine that runs Guix.
  3653. In particular, it allows store files to be transferred from one machine
  3654. to the store on another machine.
  3655. @quotation Note
  3656. If you're looking for a way to produce archives in a format suitable for
  3657. tools other than Guix, @pxref{Invoking guix pack}.
  3658. @end quotation
  3659. @cindex exporting store items
  3660. To export store files as an archive to standard output, run:
  3661. @example
  3662. guix archive --export @var{options} @var{specifications}...
  3663. @end example
  3664. @var{specifications} may be either store file names or package
  3665. specifications, as for @command{guix package} (@pxref{Invoking guix
  3666. package}). For instance, the following command creates an archive
  3667. containing the @code{gui} output of the @code{git} package and the main
  3668. output of @code{emacs}:
  3669. @example
  3670. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3671. @end example
  3672. If the specified packages are not built yet, @command{guix archive}
  3673. automatically builds them. The build process may be controlled with the
  3674. common build options (@pxref{Common Build Options}).
  3675. To transfer the @code{emacs} package to a machine connected over SSH,
  3676. one would run:
  3677. @example
  3678. guix archive --export -r emacs | ssh the-machine guix archive --import
  3679. @end example
  3680. @noindent
  3681. Similarly, a complete user profile may be transferred from one machine
  3682. to another like this:
  3683. @example
  3684. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3685. ssh the-machine guix archive --import
  3686. @end example
  3687. @noindent
  3688. However, note that, in both examples, all of @code{emacs} and the
  3689. profile as well as all of their dependencies are transferred (due to
  3690. @option{-r}), regardless of what is already available in the store on
  3691. the target machine. The @option{--missing} option can help figure out
  3692. which items are missing from the target store. The @command{guix copy}
  3693. command simplifies and optimizes this whole process, so this is probably
  3694. what you should use in this case (@pxref{Invoking guix copy}).
  3695. @cindex nar, archive format
  3696. @cindex normalized archive (nar)
  3697. @cindex nar bundle, archive format
  3698. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3699. format (described below), and the output of @command{guix archive
  3700. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3701. bundle}.
  3702. The nar format is
  3703. comparable in spirit to `tar', but with differences
  3704. that make it more appropriate for our purposes. First, rather than
  3705. recording all Unix metadata for each file, the nar format only mentions
  3706. the file type (regular, directory, or symbolic link); Unix permissions
  3707. and owner/group are dismissed. Second, the order in which directory
  3708. entries are stored always follows the order of file names according to
  3709. the C locale collation order. This makes archive production fully
  3710. deterministic.
  3711. That nar bundle format is essentially the concatenation of zero or more
  3712. nars along with metadata for each store item it contains: its file name,
  3713. references, corresponding derivation, and a digital signature.
  3714. When exporting, the daemon digitally signs the contents of the archive,
  3715. and that digital signature is appended. When importing, the daemon
  3716. verifies the signature and rejects the import in case of an invalid
  3717. signature or if the signing key is not authorized.
  3718. @c FIXME: Add xref to daemon doc about signatures.
  3719. The main options are:
  3720. @table @code
  3721. @item --export
  3722. Export the specified store files or packages (see below). Write the
  3723. resulting archive to the standard output.
  3724. Dependencies are @emph{not} included in the output, unless
  3725. @option{--recursive} is passed.
  3726. @item -r
  3727. @itemx --recursive
  3728. When combined with @option{--export}, this instructs @command{guix archive}
  3729. to include dependencies of the given items in the archive. Thus, the
  3730. resulting archive is self-contained: it contains the closure of the
  3731. exported store items.
  3732. @item --import
  3733. Read an archive from the standard input, and import the files listed
  3734. therein into the store. Abort if the archive has an invalid digital
  3735. signature, or if it is signed by a public key not among the authorized
  3736. keys (see @option{--authorize} below).
  3737. @item --missing
  3738. Read a list of store file names from the standard input, one per line,
  3739. and write on the standard output the subset of these files missing from
  3740. the store.
  3741. @item --generate-key[=@var{parameters}]
  3742. @cindex signing, archives
  3743. Generate a new key pair for the daemon. This is a prerequisite before
  3744. archives can be exported with @option{--export}. This
  3745. operation is usually instantaneous but it can take time if the system's
  3746. entropy pool needs to be refilled. On Guix System,
  3747. @code{guix-service-type} takes care of generating this key pair the
  3748. first boot.
  3749. The generated key pair is typically stored under @file{/etc/guix}, in
  3750. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  3751. key, which must be kept secret). When @var{parameters} is omitted,
  3752. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  3753. versions before 1.6.0, it is a 4096-bit RSA key.
  3754. Alternatively, @var{parameters} can specify
  3755. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  3756. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  3757. Libgcrypt Reference Manual}).
  3758. @item --authorize
  3759. @cindex authorizing, archives
  3760. Authorize imports signed by the public key passed on standard input.
  3761. The public key must be in ``s-expression advanced format''---i.e., the
  3762. same format as the @file{signing-key.pub} file.
  3763. The list of authorized keys is kept in the human-editable file
  3764. @file{/etc/guix/acl}. The file contains
  3765. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  3766. s-expressions''} and is structured as an access-control list in the
  3767. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  3768. (SPKI)}.
  3769. @item --extract=@var{directory}
  3770. @itemx -x @var{directory}
  3771. Read a single-item archive as served by substitute servers
  3772. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  3773. low-level operation needed in only very narrow use cases; see below.
  3774. For example, the following command extracts the substitute for Emacs
  3775. served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
  3776. @example
  3777. $ wget -O - \
  3778. https://@value{SUBSTITUTE-SERVER}/nar/gzip/@dots{}-emacs-24.5 \
  3779. | gunzip | guix archive -x /tmp/emacs
  3780. @end example
  3781. Single-item archives are different from multiple-item archives produced
  3782. by @command{guix archive --export}; they contain a single store item,
  3783. and they do @emph{not} embed a signature. Thus this operation does
  3784. @emph{no} signature verification and its output should be considered
  3785. unsafe.
  3786. The primary purpose of this operation is to facilitate inspection of
  3787. archive contents coming from possibly untrusted substitute servers
  3788. (@pxref{Invoking guix challenge}).
  3789. @item --list
  3790. @itemx -t
  3791. Read a single-item archive as served by substitute servers
  3792. (@pxref{Substitutes}) and print the list of files it contains, as in
  3793. this example:
  3794. @example
  3795. $ wget -O - \
  3796. https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-emacs-26.3 \
  3797. | lzip -d | guix archive -t
  3798. @end example
  3799. @end table
  3800. @c *********************************************************************
  3801. @node Channels
  3802. @chapter Channels
  3803. @cindex channels
  3804. @cindex @file{channels.scm}, configuration file
  3805. @cindex configuration file for channels
  3806. @cindex @command{guix pull}, configuration file
  3807. @cindex configuration of @command{guix pull}
  3808. Guix and its package collection are updated by running @command{guix pull}
  3809. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  3810. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  3811. customized by defining @dfn{channels} in the
  3812. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  3813. of a Git repository to be deployed, and @command{guix pull} can be instructed
  3814. to pull from one or more channels. In other words, channels can be used
  3815. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  3816. Guix is able to take into account security concerns and deal with authenticated
  3817. updates.
  3818. @menu
  3819. * Specifying Additional Channels:: Extending the package collection.
  3820. * Using a Custom Guix Channel:: Using a customized Guix.
  3821. * Replicating Guix:: Running the @emph{exact same} Guix.
  3822. * Channel Authentication:: How Guix verifies what it fetches.
  3823. * Creating a Channel:: How to write your custom channel.
  3824. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  3825. * Declaring Channel Dependencies:: How to depend on other channels.
  3826. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  3827. * Primary URL:: Distinguishing mirror to original.
  3828. * Writing Channel News:: Communicating information to channel's users.
  3829. @end menu
  3830. @node Specifying Additional Channels
  3831. @section Specifying Additional Channels
  3832. @cindex extending the package collection (channels)
  3833. @cindex variant packages (channels)
  3834. You can specify @emph{additional channels} to pull from. To use a channel, write
  3835. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  3836. @emph{in addition} to the default Guix channel(s):
  3837. @vindex %default-channels
  3838. @lisp
  3839. ;; Add variant packages to those Guix provides.
  3840. (cons (channel
  3841. (name 'variant-packages)
  3842. (url "https://example.org/variant-packages.git"))
  3843. %default-channels)
  3844. @end lisp
  3845. @noindent
  3846. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  3847. add a channel the list of channels that the variable @code{%default-channels}
  3848. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  3849. Manual}). With this file in place, @command{guix pull} builds not only Guix
  3850. but also the package modules from your own repository. The result in
  3851. @file{~/.config/guix/current} is the union of Guix with your own package
  3852. modules:
  3853. @example
  3854. $ guix pull --list-generations
  3855. @dots{}
  3856. Generation 19 Aug 27 2018 16:20:48
  3857. guix d894ab8
  3858. repository URL: https://git.savannah.gnu.org/git/guix.git
  3859. branch: master
  3860. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  3861. variant-packages dd3df5e
  3862. repository URL: https://example.org/variant-packages.git
  3863. branch: master
  3864. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  3865. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  3866. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  3867. @end example
  3868. @noindent
  3869. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  3870. both Guix and packages from the @code{variant-personal-packages} channel. Among
  3871. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  3872. @code{variant-emacs-with-cool-features} might come from
  3873. @code{variant-packages}, while others come from the Guix default channel.
  3874. @node Using a Custom Guix Channel
  3875. @section Using a Custom Guix Channel
  3876. The channel called @code{guix} specifies where Guix itself---its command-line
  3877. tools as well as its package collection---should be downloaded. For instance,
  3878. suppose you want to update from another copy of the Guix repository at
  3879. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  3880. write in @code{~/.config/guix/channels.scm} this specification:
  3881. @lisp
  3882. ;; Tell 'guix pull' to use another repo.
  3883. (list (channel
  3884. (name 'guix)
  3885. (url "https://example.org/another-guix.git")
  3886. (branch "super-hacks")))
  3887. @end lisp
  3888. @noindent
  3889. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  3890. branch of the repository at @code{example.org}. The authentication concern is
  3891. addressed below ((@pxref{Channel Authentication}).
  3892. @node Replicating Guix
  3893. @section Replicating Guix
  3894. @cindex pinning, channels
  3895. @cindex replicating Guix
  3896. @cindex reproducibility, of Guix
  3897. The @command{guix pull --list-generations} output above shows precisely which
  3898. commits were used to build this instance of Guix. We can thus replicate it,
  3899. say, on another machine, by providing a channel specification in
  3900. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  3901. @lisp
  3902. ;; Deploy specific commits of my channels of interest.
  3903. (list (channel
  3904. (name 'guix)
  3905. (url "https://git.savannah.gnu.org/git/guix.git")
  3906. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  3907. (channel
  3908. (name 'variant-packages)
  3909. (url "https://example.org/variant-packages.git")
  3910. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  3911. @end lisp
  3912. The @command{guix describe --format=channels} command can even generate this
  3913. list of channels directly (@pxref{Invoking guix describe}). The resulting
  3914. file can be used with the -C options of @command{guix pull}
  3915. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  3916. (@pxref{Invoking guix time-machine}).
  3917. At this point the two machines run the @emph{exact same Guix}, with access to
  3918. the @emph{exact same packages}. The output of @command{guix build gimp} on
  3919. one machine will be exactly the same, bit for bit, as the output of the same
  3920. command on the other machine. It also means both machines have access to all
  3921. the source code of Guix and, transitively, to all the source code of every
  3922. package it defines.
  3923. This gives you super powers, allowing you to track the provenance of binary
  3924. artifacts with very fine grain, and to reproduce software environments at
  3925. will---some sort of ``meta reproducibility'' capabilities, if you will.
  3926. @xref{Inferiors}, for another way to take advantage of these super powers.
  3927. @node Channel Authentication
  3928. @section Channel Authentication
  3929. @anchor{channel-authentication}
  3930. @cindex authentication, of channel code
  3931. The @command{guix pull} and @command{guix time-machine} commands
  3932. @dfn{authenticate} the code retrieved from channels: they make sure each
  3933. commit that is fetched is signed by an authorized developer. The goal
  3934. is to protect from unauthorized modifications to the channel that would
  3935. lead users to run malicious code.
  3936. As a user, you must provide a @dfn{channel introduction} in your
  3937. channels file so that Guix knows how to authenticate its first commit.
  3938. A channel specification, including its introduction, looks something
  3939. along these lines:
  3940. @lisp
  3941. (channel
  3942. (name 'some-channel)
  3943. (url "https://example.org/some-channel.git")
  3944. (introduction
  3945. (make-channel-introduction
  3946. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  3947. (openpgp-fingerprint
  3948. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  3949. @end lisp
  3950. The specification above shows the name and URL of the channel. The call
  3951. to @code{make-channel-introduction} above specifies that authentication
  3952. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  3953. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  3954. For the main channel, called @code{guix}, you automatically get that
  3955. information from your Guix installation. For other channels, include
  3956. the channel introduction provided by the channel authors in your
  3957. @file{channels.scm} file. Make sure you retrieve the channel
  3958. introduction from a trusted source since that is the root of your trust.
  3959. If you're curious about the authentication mechanics, read on!
  3960. @node Creating a Channel
  3961. @section Creating a Channel
  3962. @cindex personal packages (channels)
  3963. @cindex channels, for personal packages
  3964. Let's say you have a bunch of custom package variants or personal packages
  3965. that you think would make little sense to contribute to the Guix project, but
  3966. would like to have these packages transparently available to you at the
  3967. command line. You would first write modules containing those package
  3968. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  3969. then you and anyone else can use it as an additional channel to get packages
  3970. from. Neat, no?
  3971. @c What follows stems from discussions at
  3972. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  3973. @c earlier discussions on guix-devel@gnu.org.
  3974. @quotation Warning
  3975. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  3976. publish your personal channel to the world, we would like to share a few words
  3977. of caution:
  3978. @itemize
  3979. @item
  3980. Before publishing a channel, please consider contributing your package
  3981. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  3982. to free software of all sorts, and packages in Guix proper are readily
  3983. available to all Guix users and benefit from the project's quality assurance
  3984. process.
  3985. @item
  3986. When you maintain package definitions outside Guix, we, Guix developers,
  3987. consider that @emph{the compatibility burden is on you}. Remember that
  3988. package modules and package definitions are just Scheme code that uses various
  3989. programming interfaces (APIs). We want to remain free to change these APIs to
  3990. keep improving Guix, possibly in ways that break your channel. We never
  3991. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  3992. either.
  3993. @item
  3994. Corollary: if you're using an external channel and that channel breaks, please
  3995. @emph{report the issue to the channel authors}, not to the Guix project.
  3996. @end itemize
  3997. You've been warned! Having said this, we believe external channels are a
  3998. practical way to exert your freedom to augment Guix' package collection and to
  3999. share your improvements, which are basic tenets of
  4000. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4001. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4002. @end quotation
  4003. To create a channel, create a Git repository containing your own package
  4004. modules and make it available. The repository can contain anything, but a
  4005. useful channel will contain Guile modules that export packages. Once you
  4006. start using a channel, Guix will behave as if the root directory of that
  4007. channel's Git repository has been added to the Guile load path (@pxref{Load
  4008. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4009. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4010. module, then the module will be available under the name @code{(my-packages
  4011. my-tools)}, and you will be able to use it like any other module
  4012. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4013. As a channel author, consider bundling authentication material with your
  4014. channel so that users can authenticate it. @xref{Channel
  4015. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4016. on how to do it.
  4017. @node Package Modules in a Sub-directory
  4018. @section Package Modules in a Sub-directory
  4019. @cindex subdirectory, channels
  4020. As a channel author, you may want to keep your channel modules in a
  4021. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4022. add a meta-data file @file{.guix-channel} that contains:
  4023. @lisp
  4024. (channel
  4025. (version 0)
  4026. (directory "guix"))
  4027. @end lisp
  4028. @node Declaring Channel Dependencies
  4029. @section Declaring Channel Dependencies
  4030. @cindex dependencies, channels
  4031. @cindex meta-data, channels
  4032. Channel authors may decide to augment a package collection provided by other
  4033. channels. They can declare their channel to be dependent on other channels in
  4034. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4035. the channel repository.
  4036. The meta-data file should contain a simple S-expression like this:
  4037. @lisp
  4038. (channel
  4039. (version 0)
  4040. (dependencies
  4041. (channel
  4042. (name 'some-collection)
  4043. (url "https://example.org/first-collection.git")
  4044. ;; The 'introduction' bit below is optional: you would
  4045. ;; provide it for dependencies that can be authenticated.
  4046. (introduction
  4047. (channel-introduction
  4048. (version 0)
  4049. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4050. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4051. (channel
  4052. (name 'some-other-collection)
  4053. (url "https://example.org/second-collection.git")
  4054. (branch "testing"))))
  4055. @end lisp
  4056. In the above example this channel is declared to depend on two other channels,
  4057. which will both be fetched automatically. The modules provided by the channel
  4058. will be compiled in an environment where the modules of all these declared
  4059. channels are available.
  4060. For the sake of reliability and maintainability, you should avoid dependencies
  4061. on channels that you don't control, and you should aim to keep the number of
  4062. dependencies to a minimum.
  4063. @node Specifying Channel Authorizations
  4064. @section Specifying Channel Authorizations
  4065. @cindex channel authorizations
  4066. @anchor{channel-authorizations}
  4067. As we saw above, Guix ensures the source code it pulls from channels
  4068. comes from authorized developers. As a channel author, you need to
  4069. specify the list of authorized developers in the
  4070. @file{.guix-authorizations} file in the channel's Git repository. The
  4071. authentication rule is simple: each commit must be signed by a key
  4072. listed in the @file{.guix-authorizations} file of its parent
  4073. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4074. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4075. have one parent and merge commits have two parent commits. Read
  4076. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4077. for Computer Scientists}} for a great overview.} The
  4078. @file{.guix-authorizations} file looks like this:
  4079. @lisp
  4080. ;; Example '.guix-authorizations' file.
  4081. (authorizations
  4082. (version 0) ;current file format version
  4083. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4084. (name "alice"))
  4085. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4086. (name "bob"))
  4087. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4088. (name "charlie"))))
  4089. @end lisp
  4090. Each fingerprint is followed by optional key/value pairs, as in the
  4091. example above. Currently these key/value pairs are ignored.
  4092. This authentication rule creates a chicken-and-egg issue: how do we
  4093. authenticate the first commit? Related to that: how do we deal with
  4094. channels whose repository history contains unsigned commits and lack
  4095. @file{.guix-authorizations}? And how do we fork existing channels?
  4096. @cindex channel introduction
  4097. Channel introductions answer these questions by describing the first
  4098. commit of a channel that should be authenticated. The first time a
  4099. channel is fetched with @command{guix pull} or @command{guix
  4100. time-machine}, the command looks up the introductory commit and verifies
  4101. that it is signed by the specified OpenPGP key. From then on, it
  4102. authenticates commits according to the rule above.
  4103. Additionally, your channel must provide all the OpenPGP keys that were
  4104. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4105. files, which can be either binary or ``ASCII-armored''. By default,
  4106. those @file{.key} files are searched for in the branch named
  4107. @code{keyring} but you can specify a different branch name in
  4108. @code{.guix-channel} like so:
  4109. @lisp
  4110. (channel
  4111. (version 0)
  4112. (keyring-reference "my-keyring-branch"))
  4113. @end lisp
  4114. To summarize, as the author of a channel, there are three things you have
  4115. to do to allow users to authenticate your code:
  4116. @enumerate
  4117. @item
  4118. Export the OpenPGP keys of past and present committers with @command{gpg
  4119. --export} and store them in @file{.key} files, by default in a branch
  4120. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4121. @item
  4122. Introduce an initial @file{.guix-authorizations} in the channel's
  4123. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4124. information on how to sign Git commits.)
  4125. @item
  4126. Advertise the channel introduction, for instance on your channel's web
  4127. page. The channel introduction, as we saw above, is the commit/key
  4128. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4129. the fingerprint of the OpenPGP used to sign it.
  4130. @end enumerate
  4131. Before pushing to your public Git repository, you can run @command{guix
  4132. git-authenticate} to verify that you did sign all the commits you are
  4133. about to push with an authorized key:
  4134. @example
  4135. guix git authenticate @var{commit} @var{signer}
  4136. @end example
  4137. @noindent
  4138. where @var{commit} and @var{signer} are your channel introduction.
  4139. @xref{Invoking guix git authenticate}, for details.
  4140. Publishing a signed channel requires discipline: any mistake, such as an
  4141. unsigned commit or a commit signed by an unauthorized key, will prevent
  4142. users from pulling from your channel---well, that's the whole point of
  4143. authentication! Pay attention to merges in particular: merge commits
  4144. are considered authentic if and only if they are signed by a key present
  4145. in the @file{.guix-authorizations} file of @emph{both} branches.
  4146. @node Primary URL
  4147. @section Primary URL
  4148. @cindex primary URL, channels
  4149. Channel authors can indicate the primary URL of their channel's Git
  4150. repository in the @file{.guix-channel} file, like so:
  4151. @lisp
  4152. (channel
  4153. (version 0)
  4154. (url "https://example.org/guix.git"))
  4155. @end lisp
  4156. This allows @command{guix pull} to determine whether it is pulling code
  4157. from a mirror of the channel; when that is the case, it warns the user
  4158. that the mirror might be stale and displays the primary URL. That way,
  4159. users cannot be tricked into fetching code from a stale mirror that does
  4160. not receive security updates.
  4161. This feature only makes sense for authenticated repositories, such as
  4162. the official @code{guix} channel, for which @command{guix pull} ensures
  4163. the code it fetches is authentic.
  4164. @node Writing Channel News
  4165. @section Writing Channel News
  4166. @cindex news, for channels
  4167. Channel authors may occasionally want to communicate to their users
  4168. information about important changes in the channel. You'd send them all
  4169. an email, but that's not convenient.
  4170. Instead, channels can provide a @dfn{news file}; when the channel users
  4171. run @command{guix pull}, that news file is automatically read and
  4172. @command{guix pull --news} can display the announcements that correspond
  4173. to the new commits that have been pulled, if any.
  4174. To do that, channel authors must first declare the name of the news file
  4175. in their @file{.guix-channel} file:
  4176. @lisp
  4177. (channel
  4178. (version 0)
  4179. (news-file "etc/news.txt"))
  4180. @end lisp
  4181. The news file itself, @file{etc/news.txt} in this example, must look
  4182. something like this:
  4183. @lisp
  4184. (channel-news
  4185. (version 0)
  4186. (entry (tag "the-bug-fix")
  4187. (title (en "Fixed terrible bug")
  4188. (fr "Oh la la"))
  4189. (body (en "@@emph@{Good news@}! It's fixed!")
  4190. (eo "Certe ĝi pli bone funkcias nun!")))
  4191. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4192. (title (en "Added a great package")
  4193. (ca "Què vol dir guix?"))
  4194. (body (en "Don't miss the @@code@{hello@} package!"))))
  4195. @end lisp
  4196. While the news file is using the Scheme syntax, avoid naming it with a
  4197. @file{.scm} extension or else it will get picked up when building the
  4198. channel and yield an error since it is not a valid module.
  4199. Alternatively, you can move the channel module to a subdirectory and
  4200. store the news file in another directory.
  4201. The file consists of a list of @dfn{news entries}. Each entry is
  4202. associated with a commit or tag: it describes changes made in this
  4203. commit, possibly in preceding commits as well. Users see entries only
  4204. the first time they obtain the commit the entry refers to.
  4205. The @code{title} field should be a one-line summary while @code{body}
  4206. can be arbitrarily long, and both can contain Texinfo markup
  4207. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4208. a list of language tag/message tuples, which allows @command{guix pull}
  4209. to display news in the language that corresponds to the user's locale.
  4210. If you want to translate news using a gettext-based workflow, you can
  4211. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4212. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4213. you write news entries in English first, the command below creates a PO
  4214. file containing the strings to translate:
  4215. @example
  4216. xgettext -o news.po -l scheme -ken etc/news.txt
  4217. @end example
  4218. To sum up, yes, you could use your channel as a blog. But beware, this
  4219. is @emph{not quite} what your users might expect.
  4220. @c *********************************************************************
  4221. @node Development
  4222. @chapter Development
  4223. @cindex software development
  4224. If you are a software developer, Guix provides tools that you should find
  4225. helpful---independently of the language you're developing in. This is what
  4226. this chapter is about.
  4227. The @command{guix environment} command provides a convenient way to set up
  4228. @dfn{development environments} containing all the dependencies and tools
  4229. necessary to work on the software package of your choice. The @command{guix
  4230. pack} command allows you to create @dfn{application bundles} that can be
  4231. easily distributed to users who do not run Guix.
  4232. @menu
  4233. * Invoking guix environment:: Setting up development environments.
  4234. * Invoking guix pack:: Creating software bundles.
  4235. * The GCC toolchain:: Working with languages supported by GCC.
  4236. * Invoking guix git authenticate:: Authenticating Git repositories.
  4237. @end menu
  4238. @node Invoking guix environment
  4239. @section Invoking @command{guix environment}
  4240. @cindex reproducible build environments
  4241. @cindex development environments
  4242. @cindex @command{guix environment}
  4243. @cindex environment, package build environment
  4244. The purpose of @command{guix environment} is to assist hackers in
  4245. creating reproducible development environments without polluting their
  4246. package profile. The @command{guix environment} tool takes one or more
  4247. packages, builds all of their inputs, and creates a shell
  4248. environment to use them.
  4249. The general syntax is:
  4250. @example
  4251. guix environment @var{options} @var{package}@dots{}
  4252. @end example
  4253. The following example spawns a new shell set up for the development of
  4254. GNU@tie{}Guile:
  4255. @example
  4256. guix environment guile
  4257. @end example
  4258. If the needed dependencies are not built yet, @command{guix environment}
  4259. automatically builds them. The environment of the new shell is an
  4260. augmented version of the environment that @command{guix environment} was
  4261. run in. It contains the necessary search paths for building the given
  4262. package added to the existing environment variables. To create
  4263. a ``pure'' environment, in which the original environment variables have
  4264. been unset, use the @option{--pure} option@footnote{Users sometimes
  4265. wrongfully augment environment variables such as @env{PATH} in their
  4266. @file{~/.bashrc} file. As a consequence, when @command{guix
  4267. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4268. introducing ``impurities'' in these environment variables. It is an
  4269. error to define such environment variables in @file{.bashrc}; instead,
  4270. they should be defined in @file{.bash_profile}, which is sourced only by
  4271. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4272. Manual}, for details on Bash start-up files.}.
  4273. @vindex GUIX_ENVIRONMENT
  4274. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4275. variable in the shell it spawns; its value is the file name of the
  4276. profile of this environment. This allows users to, say, define a
  4277. specific prompt for development environments in their @file{.bashrc}
  4278. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4279. @example
  4280. if [ -n "$GUIX_ENVIRONMENT" ]
  4281. then
  4282. export PS1="\u@@\h \w [dev]\$ "
  4283. fi
  4284. @end example
  4285. @noindent
  4286. ...@: or to browse the profile:
  4287. @example
  4288. $ ls "$GUIX_ENVIRONMENT/bin"
  4289. @end example
  4290. Additionally, more than one package may be specified, in which case the
  4291. union of the inputs for the given packages are used. For example, the
  4292. command below spawns a shell where all of the dependencies of both Guile
  4293. and Emacs are available:
  4294. @example
  4295. guix environment guile emacs
  4296. @end example
  4297. Sometimes an interactive shell session is not desired. An arbitrary
  4298. command may be invoked by placing the @code{--} token to separate the
  4299. command from the rest of the arguments:
  4300. @example
  4301. guix environment guile -- make -j4
  4302. @end example
  4303. In other situations, it is more convenient to specify the list of
  4304. packages needed in the environment. For example, the following command
  4305. runs @command{python} from an environment containing Python@tie{}2.7 and
  4306. NumPy:
  4307. @example
  4308. guix environment --ad-hoc python2-numpy python-2.7 -- python
  4309. @end example
  4310. Furthermore, one might want the dependencies of a package and also some
  4311. additional packages that are not build-time or runtime dependencies, but
  4312. are useful when developing nonetheless. Because of this, the
  4313. @option{--ad-hoc} flag is positional. Packages appearing before
  4314. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4315. added to the environment. Packages appearing after are interpreted as
  4316. packages that will be added to the environment directly. For example,
  4317. the following command creates a Guix development environment that
  4318. additionally includes Git and strace:
  4319. @example
  4320. guix environment --pure guix --ad-hoc git strace
  4321. @end example
  4322. @cindex container
  4323. Sometimes it is desirable to isolate the environment as much as
  4324. possible, for maximal purity and reproducibility. In particular, when
  4325. using Guix on a host distro that is not Guix System, it is desirable to
  4326. prevent access to @file{/usr/bin} and other system-wide resources from
  4327. the development environment. For example, the following command spawns
  4328. a Guile REPL in a ``container'' where only the store and the current
  4329. working directory are mounted:
  4330. @example
  4331. guix environment --ad-hoc --container guile -- guile
  4332. @end example
  4333. @quotation Note
  4334. The @option{--container} option requires Linux-libre 3.19 or newer.
  4335. @end quotation
  4336. @cindex certificates
  4337. Another typical use case for containers is to run security-sensitive
  4338. applications such as a web browser. To run Eolie, we must expose and
  4339. share some files and directories; we include @code{nss-certs} and expose
  4340. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4341. the @env{DISPLAY} environment variable since containerized graphical
  4342. applications won't display without it.
  4343. @example
  4344. guix environment --preserve='^DISPLAY$' --container --network \
  4345. --expose=/etc/machine-id \
  4346. --expose=/etc/ssl/certs/ \
  4347. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4348. --ad-hoc eolie nss-certs dbus -- eolie
  4349. @end example
  4350. The available options are summarized below.
  4351. @table @code
  4352. @item --root=@var{file}
  4353. @itemx -r @var{file}
  4354. @cindex persistent environment
  4355. @cindex garbage collector root, for environments
  4356. Make @var{file} a symlink to the profile for this environment, and
  4357. register it as a garbage collector root.
  4358. This is useful if you want to protect your environment from garbage
  4359. collection, to make it ``persistent''.
  4360. When this option is omitted, the environment is protected from garbage
  4361. collection only for the duration of the @command{guix environment}
  4362. session. This means that next time you recreate the same environment,
  4363. you could have to rebuild or re-download packages. @xref{Invoking guix
  4364. gc}, for more on GC roots.
  4365. @item --expression=@var{expr}
  4366. @itemx -e @var{expr}
  4367. Create an environment for the package or list of packages that
  4368. @var{expr} evaluates to.
  4369. For example, running:
  4370. @example
  4371. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4372. @end example
  4373. starts a shell with the environment for this specific variant of the
  4374. PETSc package.
  4375. Running:
  4376. @example
  4377. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4378. @end example
  4379. starts a shell with all the base system packages available.
  4380. The above commands only use the default output of the given packages.
  4381. To select other outputs, two element tuples can be specified:
  4382. @example
  4383. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4384. @end example
  4385. @item --load=@var{file}
  4386. @itemx -l @var{file}
  4387. Create an environment for the package or list of packages that the code
  4388. within @var{file} evaluates to.
  4389. As an example, @var{file} might contain a definition like this
  4390. (@pxref{Defining Packages}):
  4391. @lisp
  4392. @verbatiminclude environment-gdb.scm
  4393. @end lisp
  4394. @item --manifest=@var{file}
  4395. @itemx -m @var{file}
  4396. Create an environment for the packages contained in the manifest object
  4397. returned by the Scheme code in @var{file}. This option can be repeated
  4398. several times, in which case the manifests are concatenated.
  4399. This is similar to the same-named option in @command{guix package}
  4400. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4401. manifest files.
  4402. @item --ad-hoc
  4403. Include all specified packages in the resulting environment, as if an
  4404. @i{ad hoc} package were defined with them as inputs. This option is
  4405. useful for quickly creating an environment without having to write a
  4406. package expression to contain the desired inputs.
  4407. For instance, the command:
  4408. @example
  4409. guix environment --ad-hoc guile guile-sdl -- guile
  4410. @end example
  4411. runs @command{guile} in an environment where Guile and Guile-SDL are
  4412. available.
  4413. Note that this example implicitly asks for the default output of
  4414. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  4415. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  4416. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  4417. This option may be composed with the default behavior of @command{guix
  4418. environment}. Packages appearing before @option{--ad-hoc} are
  4419. interpreted as packages whose dependencies will be added to the
  4420. environment, the default behavior. Packages appearing after are
  4421. interpreted as packages that will be added to the environment directly.
  4422. @item --pure
  4423. Unset existing environment variables when building the new environment, except
  4424. those specified with @option{--preserve} (see below). This has the effect of
  4425. creating an environment in which search paths only contain package inputs.
  4426. @item --preserve=@var{regexp}
  4427. @itemx -E @var{regexp}
  4428. When used alongside @option{--pure}, preserve the environment variables
  4429. matching @var{regexp}---in other words, put them on a ``white list'' of
  4430. environment variables that must be preserved. This option can be repeated
  4431. several times.
  4432. @example
  4433. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  4434. -- mpirun @dots{}
  4435. @end example
  4436. This example runs @command{mpirun} in a context where the only environment
  4437. variables defined are @env{PATH}, environment variables whose name starts
  4438. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4439. @env{USER}, etc.).
  4440. @item --search-paths
  4441. Display the environment variable definitions that make up the
  4442. environment.
  4443. @item --system=@var{system}
  4444. @itemx -s @var{system}
  4445. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4446. @item --container
  4447. @itemx -C
  4448. @cindex container
  4449. Run @var{command} within an isolated container. The current working
  4450. directory outside the container is mapped inside the container.
  4451. Additionally, unless overridden with @option{--user}, a dummy home
  4452. directory is created that matches the current user's home directory, and
  4453. @file{/etc/passwd} is configured accordingly.
  4454. The spawned process runs as the current user outside the container. Inside
  4455. the container, it has the same UID and GID as the current user, unless
  4456. @option{--user} is passed (see below).
  4457. @item --network
  4458. @itemx -N
  4459. For containers, share the network namespace with the host system.
  4460. Containers created without this flag only have access to the loopback
  4461. device.
  4462. @item --link-profile
  4463. @itemx -P
  4464. For containers, link the environment profile to @file{~/.guix-profile}
  4465. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4466. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4467. actual profile within the container.
  4468. Linking will fail and abort the environment if the directory already
  4469. exists, which will certainly be the case if @command{guix environment}
  4470. was invoked in the user's home directory.
  4471. Certain packages are configured to look in @file{~/.guix-profile} for
  4472. configuration files and data;@footnote{For example, the
  4473. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4474. for additional fonts.} @option{--link-profile} allows these programs to
  4475. behave as expected within the environment.
  4476. @item --user=@var{user}
  4477. @itemx -u @var{user}
  4478. For containers, use the username @var{user} in place of the current
  4479. user. The generated @file{/etc/passwd} entry within the container will
  4480. contain the name @var{user}, the home directory will be
  4481. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4482. the UID and GID inside the container are 1000. @var{user}
  4483. need not exist on the system.
  4484. Additionally, any shared or exposed path (see @option{--share} and
  4485. @option{--expose} respectively) whose target is within the current user's
  4486. home directory will be remapped relative to @file{/home/USER}; this
  4487. includes the automatic mapping of the current working directory.
  4488. @example
  4489. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4490. cd $HOME/wd
  4491. guix environment --container --user=foo \
  4492. --expose=$HOME/test \
  4493. --expose=/tmp/target=$HOME/target
  4494. @end example
  4495. While this will limit the leaking of user identity through home paths
  4496. and each of the user fields, this is only one useful component of a
  4497. broader privacy/anonymity solution---not one in and of itself.
  4498. @item --no-cwd
  4499. For containers, the default behavior is to share the current working
  4500. directory with the isolated container and immediately change to that
  4501. directory within the container. If this is undesirable,
  4502. @option{--no-cwd} will cause the current working directory to @emph{not}
  4503. be automatically shared and will change to the user's home directory
  4504. within the container instead. See also @option{--user}.
  4505. @item --expose=@var{source}[=@var{target}]
  4506. @itemx --share=@var{source}[=@var{target}]
  4507. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4508. file system @var{source} from the host system as the read-only
  4509. (resp. writable) file system @var{target} within the container. If
  4510. @var{target} is not specified, @var{source} is used as the target mount
  4511. point in the container.
  4512. The example below spawns a Guile REPL in a container in which the user's
  4513. home directory is accessible read-only via the @file{/exchange}
  4514. directory:
  4515. @example
  4516. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  4517. @end example
  4518. @end table
  4519. @command{guix environment}
  4520. also supports all of the common build options that @command{guix
  4521. build} supports (@pxref{Common Build Options}) as well as package
  4522. transformation options (@pxref{Package Transformation Options}).
  4523. @node Invoking guix pack
  4524. @section Invoking @command{guix pack}
  4525. Occasionally you want to pass software to people who are not (yet!)
  4526. lucky enough to be using Guix. You'd tell them to run @command{guix
  4527. package -i @var{something}}, but that's not possible in this case. This
  4528. is where @command{guix pack} comes in.
  4529. @quotation Note
  4530. If you are looking for ways to exchange binaries among machines that
  4531. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  4532. publish}, and @ref{Invoking guix archive}.
  4533. @end quotation
  4534. @cindex pack
  4535. @cindex bundle
  4536. @cindex application bundle
  4537. @cindex software bundle
  4538. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  4539. @dfn{software bundle}: it creates a tarball or some other archive
  4540. containing the binaries of the software you're interested in, and all
  4541. its dependencies. The resulting archive can be used on any machine that
  4542. does not have Guix, and people can run the exact same binaries as those
  4543. you have with Guix. The pack itself is created in a bit-reproducible
  4544. fashion, so anyone can verify that it really contains the build results
  4545. that you pretend to be shipping.
  4546. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  4547. their dependencies, you can run:
  4548. @example
  4549. $ guix pack guile emacs geiser
  4550. @dots{}
  4551. /gnu/store/@dots{}-pack.tar.gz
  4552. @end example
  4553. The result here is a tarball containing a @file{/gnu/store} directory
  4554. with all the relevant packages. The resulting tarball contains a
  4555. @dfn{profile} with the three packages of interest; the profile is the
  4556. same as would be created by @command{guix package -i}. It is this
  4557. mechanism that is used to create Guix's own standalone binary tarball
  4558. (@pxref{Binary Installation}).
  4559. Users of this pack would have to run
  4560. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  4561. find inconvenient. To work around it, you can create, say, a
  4562. @file{/opt/gnu/bin} symlink to the profile:
  4563. @example
  4564. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  4565. @end example
  4566. @noindent
  4567. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  4568. @cindex relocatable binaries, with @command{guix pack}
  4569. What if the recipient of your pack does not have root privileges on
  4570. their machine, and thus cannot unpack it in the root file system? In
  4571. that case, you will want to use the @option{--relocatable} option (see
  4572. below). This option produces @dfn{relocatable binaries}, meaning they
  4573. they can be placed anywhere in the file system hierarchy: in the example
  4574. above, users can unpack your tarball in their home directory and
  4575. directly run @file{./opt/gnu/bin/guile}.
  4576. @cindex Docker, build an image with guix pack
  4577. Alternatively, you can produce a pack in the Docker image format using
  4578. the following command:
  4579. @example
  4580. guix pack -f docker -S /bin=bin guile guile-readline
  4581. @end example
  4582. @noindent
  4583. The result is a tarball that can be passed to the @command{docker load}
  4584. command, followed by @code{docker run}:
  4585. @example
  4586. docker load < @var{file}
  4587. docker run -ti guile-guile-readline /bin/guile
  4588. @end example
  4589. @noindent
  4590. where @var{file} is the image returned by @var{guix pack}, and
  4591. @code{guile-guile-readline} is its ``image tag''. See the
  4592. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  4593. documentation} for more information.
  4594. @cindex Singularity, build an image with guix pack
  4595. @cindex SquashFS, build an image with guix pack
  4596. Yet another option is to produce a SquashFS image with the following
  4597. command:
  4598. @example
  4599. guix pack -f squashfs bash guile emacs geiser
  4600. @end example
  4601. @noindent
  4602. The result is a SquashFS file system image that can either be mounted or
  4603. directly be used as a file system container image with the
  4604. @uref{https://www.sylabs.io/docs/, Singularity container execution
  4605. environment}, using commands like @command{singularity shell} or
  4606. @command{singularity exec}.
  4607. Several command-line options allow you to customize your pack:
  4608. @table @code
  4609. @item --format=@var{format}
  4610. @itemx -f @var{format}
  4611. Produce a pack in the given @var{format}.
  4612. The available formats are:
  4613. @table @code
  4614. @item tarball
  4615. This is the default format. It produces a tarball containing all the
  4616. specified binaries and symlinks.
  4617. @item docker
  4618. This produces a tarball that follows the
  4619. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  4620. Docker Image Specification}. The ``repository name'' as it appears in
  4621. the output of the @command{docker images} command is computed from
  4622. package names passed on the command line or in the manifest file.
  4623. @item squashfs
  4624. This produces a SquashFS image containing all the specified binaries and
  4625. symlinks, as well as empty mount points for virtual file systems like
  4626. procfs.
  4627. @quotation Note
  4628. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  4629. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  4630. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  4631. with something like:
  4632. @example
  4633. guix pack -f squashfs bash @dots{}
  4634. @end example
  4635. If you forget the @code{bash} (or similar) package, @command{singularity
  4636. run} and @command{singularity exec} will fail with an unhelpful ``no
  4637. such file or directory'' message.
  4638. @end quotation
  4639. @end table
  4640. @cindex relocatable binaries
  4641. @item --relocatable
  4642. @itemx -R
  4643. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  4644. anywhere in the file system hierarchy and run from there.
  4645. When this option is passed once, the resulting binaries require support for
  4646. @dfn{user namespaces} in the kernel Linux; when passed
  4647. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  4648. PRoot support, can be thought of as the abbreviation of ``Really
  4649. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  4650. other techniques if user namespaces are unavailable, and essentially
  4651. work anywhere---see below for the implications.
  4652. For example, if you create a pack containing Bash with:
  4653. @example
  4654. guix pack -RR -S /mybin=bin bash
  4655. @end example
  4656. @noindent
  4657. ...@: you can copy that pack to a machine that lacks Guix, and from your
  4658. home directory as a normal user, run:
  4659. @example
  4660. tar xf pack.tar.gz
  4661. ./mybin/sh
  4662. @end example
  4663. @noindent
  4664. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  4665. @file{/gnu/store} shows up and contains all the dependencies of
  4666. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  4667. altogether! That is probably the simplest way to deploy Guix-built
  4668. software on a non-Guix machine.
  4669. @quotation Note
  4670. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  4671. the kernel Linux, which allows unprivileged users to mount or change root.
  4672. Old versions of Linux did not support it, and some GNU/Linux distributions
  4673. turn it off.
  4674. To produce relocatable binaries that work even in the absence of user
  4675. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  4676. case, binaries will try user namespace support and fall back to another
  4677. @dfn{execution engine} if user namespaces are not supported. The
  4678. following execution engines are supported:
  4679. @table @code
  4680. @item default
  4681. Try user namespaces and fall back to PRoot if user namespaces are not
  4682. supported (see below).
  4683. @item performance
  4684. Try user namespaces and fall back to Fakechroot if user namespaces are
  4685. not supported (see below).
  4686. @item userns
  4687. Run the program through user namespaces and abort if they are not
  4688. supported.
  4689. @item proot
  4690. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  4691. provides the necessary
  4692. support for file system virtualization. It achieves that by using the
  4693. @code{ptrace} system call on the running program. This approach has the
  4694. advantage to work without requiring special kernel support, but it incurs
  4695. run-time overhead every time a system call is made.
  4696. @item fakechroot
  4697. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  4698. Fakechroot} virtualizes file system accesses by intercepting calls to C
  4699. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  4700. on. Unlike PRoot, it incurs very little overhead. However, it does not
  4701. always work: for example, some file system accesses made from within the
  4702. C library are not intercepted, and file system accesses made @i{via}
  4703. direct syscalls are not intercepted either, leading to erratic behavior.
  4704. @end table
  4705. @vindex GUIX_EXECUTION_ENGINE
  4706. When running a wrapped program, you can explicitly request one of the
  4707. execution engines listed above by setting the
  4708. @code{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  4709. @end quotation
  4710. @cindex entry point, for Docker images
  4711. @item --entry-point=@var{command}
  4712. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  4713. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  4714. support it. @var{command} must be relative to the profile contained in the
  4715. pack.
  4716. The entry point specifies the command that tools like @code{docker run} or
  4717. @code{singularity run} automatically start by default. For example, you can
  4718. do:
  4719. @example
  4720. guix pack -f docker --entry-point=bin/guile guile
  4721. @end example
  4722. The resulting pack can easily be loaded and @code{docker run} with no extra
  4723. arguments will spawn @code{bin/guile}:
  4724. @example
  4725. docker load -i pack.tar.gz
  4726. docker run @var{image-id}
  4727. @end example
  4728. @item --expression=@var{expr}
  4729. @itemx -e @var{expr}
  4730. Consider the package @var{expr} evaluates to.
  4731. This has the same purpose as the same-named option in @command{guix
  4732. build} (@pxref{Additional Build Options, @option{--expression} in
  4733. @command{guix build}}).
  4734. @item --manifest=@var{file}
  4735. @itemx -m @var{file}
  4736. Use the packages contained in the manifest object returned by the Scheme
  4737. code in @var{file}. This option can be repeated several times, in which
  4738. case the manifests are concatenated.
  4739. This has a similar purpose as the same-named option in @command{guix
  4740. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  4741. same manifest files. It allows you to define a collection of packages
  4742. once and use it both for creating profiles and for creating archives
  4743. for use on machines that do not have Guix installed. Note that you can
  4744. specify @emph{either} a manifest file @emph{or} a list of packages,
  4745. but not both.
  4746. @item --system=@var{system}
  4747. @itemx -s @var{system}
  4748. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  4749. the system type of the build host.
  4750. @item --target=@var{triplet}
  4751. @cindex cross-compilation
  4752. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  4753. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  4754. configuration triplets,, autoconf, Autoconf}).
  4755. @item --compression=@var{tool}
  4756. @itemx -C @var{tool}
  4757. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  4758. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  4759. compression.
  4760. @item --symlink=@var{spec}
  4761. @itemx -S @var{spec}
  4762. Add the symlinks specified by @var{spec} to the pack. This option can
  4763. appear several times.
  4764. @var{spec} has the form @code{@var{source}=@var{target}}, where
  4765. @var{source} is the symlink that will be created and @var{target} is the
  4766. symlink target.
  4767. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  4768. symlink pointing to the @file{bin} sub-directory of the profile.
  4769. @item --save-provenance
  4770. Save provenance information for the packages passed on the command line.
  4771. Provenance information includes the URL and commit of the channels in use
  4772. (@pxref{Channels}).
  4773. Provenance information is saved in the
  4774. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  4775. usual package metadata---the name and version of each package, their
  4776. propagated inputs, and so on. It is useful information to the recipient of
  4777. the pack, who then knows how the pack was (supposedly) obtained.
  4778. This option is not enabled by default because, like timestamps, provenance
  4779. information contributes nothing to the build process. In other words, there
  4780. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  4781. Recording such ``silent'' metadata in the output thus potentially breaks the
  4782. source-to-binary bitwise reproducibility property.
  4783. @item --root=@var{file}
  4784. @itemx -r @var{file}
  4785. @cindex garbage collector root, for packs
  4786. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  4787. collector root.
  4788. @item --localstatedir
  4789. @itemx --profile-name=@var{name}
  4790. Include the ``local state directory'', @file{/var/guix}, in the resulting
  4791. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  4792. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  4793. @file{~root/.guix-profile}.
  4794. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  4795. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  4796. the pack means that the store is ``complete'' and manageable by Guix;
  4797. not providing it pack means that the store is ``dead'': items cannot be
  4798. added to it or removed from it after extraction of the pack.
  4799. One use case for this is the Guix self-contained binary tarball
  4800. (@pxref{Binary Installation}).
  4801. @item --derivation
  4802. @itemx -d
  4803. Print the name of the derivation that builds the pack.
  4804. @item --bootstrap
  4805. Use the bootstrap binaries to build the pack. This option is only
  4806. useful to Guix developers.
  4807. @end table
  4808. In addition, @command{guix pack} supports all the common build options
  4809. (@pxref{Common Build Options}) and all the package transformation
  4810. options (@pxref{Package Transformation Options}).
  4811. @node The GCC toolchain
  4812. @section The GCC toolchain
  4813. @cindex GCC
  4814. @cindex ld-wrapper
  4815. @cindex linker wrapper
  4816. @cindex toolchain, for C development
  4817. @cindex toolchain, for Fortran development
  4818. If you need a complete toolchain for compiling and linking C or C++
  4819. source code, use the @code{gcc-toolchain} package. This package
  4820. provides a complete GCC toolchain for C/C++ development, including GCC
  4821. itself, the GNU C Library (headers and binaries, plus debugging symbols
  4822. in the @code{debug} output), Binutils, and a linker wrapper.
  4823. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  4824. passed to the linker, add corresponding @code{-rpath} arguments, and
  4825. invoke the actual linker with this new set of arguments. You can instruct the
  4826. wrapper to refuse to link against libraries not in the store by setting the
  4827. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  4828. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  4829. for Fortran development. For other languages, please use
  4830. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  4831. @node Invoking guix git authenticate
  4832. @section Invoking @command{guix git authenticate}
  4833. The @command{guix git authenticate} command authenticates a Git checkout
  4834. following the same rule as for channels (@pxref{channel-authentication,
  4835. channel authentication}). That is, starting from a given commit, it
  4836. ensures that all subsequent commits are signed by an OpenPGP key whose
  4837. fingerprint appears in the @file{.guix-authorizations} file of its
  4838. parent commit(s).
  4839. You will find this command useful if you maintain a channel. But in
  4840. fact, this authentication mechanism is useful in a broader context, so
  4841. you might want to use it for Git repositories that have nothing to do
  4842. with Guix.
  4843. The general syntax is:
  4844. @example
  4845. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  4846. @end example
  4847. By default, this command authenticates the Git checkout in the current
  4848. directory; it outputs nothing and exits with exit code zero on success
  4849. and non-zero on failure. @var{commit} above denotes the first commit
  4850. where authentication takes place, and @var{signer} is the OpenPGP
  4851. fingerprint of public key used to sign @var{commit}. Together, they
  4852. form a ``channel introduction'' (@pxref{channel-authentication, channel
  4853. introduction}). The options below allow you to fine-tune the process.
  4854. @table @code
  4855. @item --repository=@var{directory}
  4856. @itemx -r @var{directory}
  4857. Open the Git repository in @var{directory} instead of the current
  4858. directory.
  4859. @item --keyring=@var{reference}
  4860. @itemx -k @var{reference}
  4861. Load OpenPGP keyring from @var{reference}, the reference of a branch
  4862. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  4863. contain OpenPGP public keys in @file{.key} files, either in binary form
  4864. or ``ASCII-armored''. By default the keyring is loaded from the branch
  4865. named @code{keyring}.
  4866. @item --stats
  4867. Display commit signing statistics upon completion.
  4868. @item --cache-key=@var{key}
  4869. Previously-authenticated commits are cached in a file under
  4870. @file{~/.cache/guix/authentication}. This option forces the cache to be
  4871. stored in file @var{key} in that directory.
  4872. @item --historical-authorizations=@var{file}
  4873. By default, any commit whose parent commit(s) lack the
  4874. @file{.guix-authorizations} file is considered inauthentic. In
  4875. contrast, this option considers the authorizations in @var{file} for any
  4876. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  4877. is the same as that of @file{.guix-authorizations}
  4878. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  4879. @end table
  4880. @c *********************************************************************
  4881. @node Programming Interface
  4882. @chapter Programming Interface
  4883. GNU Guix provides several Scheme programming interfaces (APIs) to
  4884. define, build, and query packages. The first interface allows users to
  4885. write high-level package definitions. These definitions refer to
  4886. familiar packaging concepts, such as the name and version of a package,
  4887. its build system, and its dependencies. These definitions can then be
  4888. turned into concrete build actions.
  4889. Build actions are performed by the Guix daemon, on behalf of users. In a
  4890. standard setup, the daemon has write access to the store---the
  4891. @file{/gnu/store} directory---whereas users do not. The recommended
  4892. setup also has the daemon perform builds in chroots, under specific
  4893. build users, to minimize interference with the rest of the system.
  4894. @cindex derivation
  4895. Lower-level APIs are available to interact with the daemon and the
  4896. store. To instruct the daemon to perform a build action, users actually
  4897. provide it with a @dfn{derivation}. A derivation is a low-level
  4898. representation of the build actions to be taken, and the environment in
  4899. which they should occur---derivations are to package definitions what
  4900. assembly is to C programs. The term ``derivation'' comes from the fact
  4901. that build results @emph{derive} from them.
  4902. This chapter describes all these APIs in turn, starting from high-level
  4903. package definitions.
  4904. @menu
  4905. * Package Modules:: Packages from the programmer's viewpoint.
  4906. * Defining Packages:: Defining new packages.
  4907. * Build Systems:: Specifying how packages are built.
  4908. * The Store:: Manipulating the package store.
  4909. * Derivations:: Low-level interface to package derivations.
  4910. * The Store Monad:: Purely functional interface to the store.
  4911. * G-Expressions:: Manipulating build expressions.
  4912. * Invoking guix repl:: Programming Guix in Guile
  4913. @end menu
  4914. @node Package Modules
  4915. @section Package Modules
  4916. From a programming viewpoint, the package definitions of the
  4917. GNU distribution are provided by Guile modules in the @code{(gnu packages
  4918. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  4919. packages @dots{})} module name space are not necessarily ``GNU
  4920. packages''. This module naming scheme follows the usual Guile module
  4921. naming convention: @code{gnu} means that these modules are distributed
  4922. as part of the GNU system, and @code{packages} identifies modules that
  4923. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  4924. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  4925. module exports a variable named @code{emacs}, which is bound to a
  4926. @code{<package>} object (@pxref{Defining Packages}).
  4927. The @code{(gnu packages @dots{})} module name space is
  4928. automatically scanned for packages by the command-line tools. For
  4929. instance, when running @code{guix install emacs}, all the @code{(gnu
  4930. packages @dots{})} modules are scanned until one that exports a package
  4931. object whose name is @code{emacs} is found. This package search
  4932. facility is implemented in the @code{(gnu packages)} module.
  4933. @cindex customization, of packages
  4934. @cindex package module search path
  4935. Users can store package definitions in modules with different
  4936. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  4937. name and module name must match. For instance, the @code{(my-packages
  4938. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  4939. relative to the load path specified with @option{--load-path} or
  4940. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  4941. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  4942. these package definitions visible to the user interfaces:
  4943. @enumerate
  4944. @item
  4945. By adding the directory containing your package modules to the search path
  4946. with the @code{-L} flag of @command{guix package} and other commands
  4947. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  4948. environment variable described below.
  4949. @item
  4950. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  4951. pulls from it. A channel is essentially a Git repository containing package
  4952. modules. @xref{Channels}, for more information on how to define and use
  4953. channels.
  4954. @end enumerate
  4955. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  4956. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  4957. This is a colon-separated list of directories to search for additional
  4958. package modules. Directories listed in this variable take precedence
  4959. over the own modules of the distribution.
  4960. @end defvr
  4961. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  4962. each package is built based solely on other packages in the
  4963. distribution. The root of this dependency graph is a small set of
  4964. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  4965. bootstrap)} module. For more information on bootstrapping,
  4966. @pxref{Bootstrapping}.
  4967. @node Defining Packages
  4968. @section Defining Packages
  4969. The high-level interface to package definitions is implemented in the
  4970. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  4971. example, the package definition, or @dfn{recipe}, for the GNU Hello
  4972. package looks like this:
  4973. @lisp
  4974. (define-module (gnu packages hello)
  4975. #:use-module (guix packages)
  4976. #:use-module (guix download)
  4977. #:use-module (guix build-system gnu)
  4978. #:use-module (guix licenses)
  4979. #:use-module (gnu packages gawk))
  4980. (define-public hello
  4981. (package
  4982. (name "hello")
  4983. (version "2.10")
  4984. (source (origin
  4985. (method url-fetch)
  4986. (uri (string-append "mirror://gnu/hello/hello-" version
  4987. ".tar.gz"))
  4988. (sha256
  4989. (base32
  4990. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  4991. (build-system gnu-build-system)
  4992. (arguments '(#:configure-flags '("--enable-silent-rules")))
  4993. (inputs `(("gawk" ,gawk)))
  4994. (synopsis "Hello, GNU world: An example GNU package")
  4995. (description "Guess what GNU Hello prints!")
  4996. (home-page "https://www.gnu.org/software/hello/")
  4997. (license gpl3+)))
  4998. @end lisp
  4999. @noindent
  5000. Without being a Scheme expert, the reader may have guessed the meaning
  5001. of the various fields here. This expression binds the variable
  5002. @code{hello} to a @code{<package>} object, which is essentially a record
  5003. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5004. This package object can be inspected using procedures found in the
  5005. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5006. returns---surprise!---@code{"hello"}.
  5007. With luck, you may be able to import part or all of the definition of
  5008. the package you are interested in from another repository, using the
  5009. @code{guix import} command (@pxref{Invoking guix import}).
  5010. In the example above, @var{hello} is defined in a module of its own,
  5011. @code{(gnu packages hello)}. Technically, this is not strictly
  5012. necessary, but it is convenient to do so: all the packages defined in
  5013. modules under @code{(gnu packages @dots{})} are automatically known to
  5014. the command-line tools (@pxref{Package Modules}).
  5015. There are a few points worth noting in the above package definition:
  5016. @itemize
  5017. @item
  5018. The @code{source} field of the package is an @code{<origin>} object
  5019. (@pxref{origin Reference}, for the complete reference).
  5020. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5021. meaning that the source is a file to be downloaded over FTP or HTTP.
  5022. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5023. the GNU mirrors defined in @code{(guix download)}.
  5024. The @code{sha256} field specifies the expected SHA256 hash of the file
  5025. being downloaded. It is mandatory, and allows Guix to check the
  5026. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5027. base32 representation of the hash. You can obtain this information with
  5028. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5029. hash} (@pxref{Invoking guix hash}).
  5030. @cindex patches
  5031. When needed, the @code{origin} form can also have a @code{patches} field
  5032. listing patches to be applied, and a @code{snippet} field giving a
  5033. Scheme expression to modify the source code.
  5034. @item
  5035. @cindex GNU Build System
  5036. The @code{build-system} field specifies the procedure to build the
  5037. package (@pxref{Build Systems}). Here, @var{gnu-build-system}
  5038. represents the familiar GNU Build System, where packages may be
  5039. configured, built, and installed with the usual @code{./configure &&
  5040. make && make check && make install} command sequence.
  5041. @item
  5042. The @code{arguments} field specifies options for the build system
  5043. (@pxref{Build Systems}). Here it is interpreted by
  5044. @var{gnu-build-system} as a request run @file{configure} with the
  5045. @option{--enable-silent-rules} flag.
  5046. @cindex quote
  5047. @cindex quoting
  5048. @findex '
  5049. @findex quote
  5050. What about these quote (@code{'}) characters? They are Scheme syntax to
  5051. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5052. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5053. for details. Here the value of the @code{arguments} field is a list of
  5054. arguments passed to the build system down the road, as with @code{apply}
  5055. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5056. Manual}).
  5057. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5058. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5059. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5060. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5061. Reference Manual}).
  5062. @item
  5063. The @code{inputs} field specifies inputs to the build process---i.e.,
  5064. build-time or run-time dependencies of the package. Here, we define an
  5065. input called @code{"gawk"} whose value is that of the @var{gawk}
  5066. variable; @var{gawk} is itself bound to a @code{<package>} object.
  5067. @cindex backquote (quasiquote)
  5068. @findex `
  5069. @findex quasiquote
  5070. @cindex comma (unquote)
  5071. @findex ,
  5072. @findex unquote
  5073. @findex ,@@
  5074. @findex unquote-splicing
  5075. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  5076. us to introduce a literal list in the @code{inputs} field, while
  5077. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  5078. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  5079. Reference Manual}).
  5080. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5081. be specified as inputs here. Instead, @var{gnu-build-system} takes care
  5082. of ensuring that they are present (@pxref{Build Systems}).
  5083. However, any other dependencies need to be specified in the
  5084. @code{inputs} field. Any dependency not specified here will simply be
  5085. unavailable to the build process, possibly leading to a build failure.
  5086. @end itemize
  5087. @xref{package Reference}, for a full description of possible fields.
  5088. Once a package definition is in place, the
  5089. package may actually be built using the @code{guix build} command-line
  5090. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5091. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5092. package definition using the @command{guix edit} command
  5093. (@pxref{Invoking guix edit}).
  5094. @xref{Packaging Guidelines}, for
  5095. more information on how to test package definitions, and
  5096. @ref{Invoking guix lint}, for information on how to check a definition
  5097. for style conformance.
  5098. @vindex GUIX_PACKAGE_PATH
  5099. Lastly, @pxref{Channels}, for information
  5100. on how to extend the distribution by adding your own package definitions
  5101. in a ``channel''.
  5102. Finally, updating the package definition to a new upstream version
  5103. can be partly automated by the @command{guix refresh} command
  5104. (@pxref{Invoking guix refresh}).
  5105. Behind the scenes, a derivation corresponding to the @code{<package>}
  5106. object is first computed by the @code{package-derivation} procedure.
  5107. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5108. The build actions it prescribes may then be realized by using the
  5109. @code{build-derivations} procedure (@pxref{The Store}).
  5110. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5111. Return the @code{<derivation>} object of @var{package} for @var{system}
  5112. (@pxref{Derivations}).
  5113. @var{package} must be a valid @code{<package>} object, and @var{system}
  5114. must be a string denoting the target system type---e.g.,
  5115. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5116. must be a connection to the daemon, which operates on the store
  5117. (@pxref{The Store}).
  5118. @end deffn
  5119. @noindent
  5120. @cindex cross-compilation
  5121. Similarly, it is possible to compute a derivation that cross-builds a
  5122. package for some other system:
  5123. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5124. @var{package} @var{target} [@var{system}]
  5125. Return the @code{<derivation>} object of @var{package} cross-built from
  5126. @var{system} to @var{target}.
  5127. @var{target} must be a valid GNU triplet denoting the target hardware
  5128. and operating system, such as @code{"aarch64-linux-gnu"}
  5129. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5130. @end deffn
  5131. @cindex package transformations
  5132. @cindex input rewriting
  5133. @cindex dependency tree rewriting
  5134. Packages can be manipulated in arbitrary ways. An example of a useful
  5135. transformation is @dfn{input rewriting}, whereby the dependency tree of
  5136. a package is rewritten by replacing specific inputs by others:
  5137. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  5138. [@var{rewrite-name}] [#:deep? #t]
  5139. Return a procedure that, when passed a package, replaces its direct and
  5140. indirect dependencies, including implicit inputs when @var{deep?} is
  5141. true, according to @var{replacements}. @var{replacements} is a list of
  5142. package pairs; the first element of each pair is the package to replace,
  5143. and the second one is the replacement.
  5144. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  5145. the name of a package and returns its new name after rewrite.
  5146. @end deffn
  5147. @noindent
  5148. Consider this example:
  5149. @lisp
  5150. (define libressl-instead-of-openssl
  5151. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  5152. ;; recursively.
  5153. (package-input-rewriting `((,openssl . ,libressl))))
  5154. (define git-with-libressl
  5155. (libressl-instead-of-openssl git))
  5156. @end lisp
  5157. @noindent
  5158. Here we first define a rewriting procedure that replaces @var{openssl}
  5159. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  5160. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  5161. This is exactly what the @option{--with-input} command-line option does
  5162. (@pxref{Package Transformation Options, @option{--with-input}}).
  5163. The following variant of @code{package-input-rewriting} can match packages to
  5164. be replaced by name rather than by identity.
  5165. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  5166. Return a procedure that, given a package, applies the given
  5167. @var{replacements} to all the package graph, including implicit inputs
  5168. unless @var{deep?} is false. @var{replacements} is a list of
  5169. spec/procedures pair; each spec is a package specification such as
  5170. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  5171. package and returns a replacement for that package.
  5172. @end deffn
  5173. The example above could be rewritten this way:
  5174. @lisp
  5175. (define libressl-instead-of-openssl
  5176. ;; Replace all the packages called "openssl" with LibreSSL.
  5177. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  5178. @end lisp
  5179. The key difference here is that, this time, packages are matched by spec and
  5180. not by identity. In other words, any package in the graph that is called
  5181. @code{openssl} will be replaced.
  5182. A more generic procedure to rewrite a package dependency graph is
  5183. @code{package-mapping}: it supports arbitrary changes to nodes in the
  5184. graph.
  5185. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  5186. Return a procedure that, given a package, applies @var{proc} to all the packages
  5187. depended on and returns the resulting package. The procedure stops recursion
  5188. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  5189. applied to implicit inputs as well.
  5190. @end deffn
  5191. @menu
  5192. * package Reference:: The package data type.
  5193. * origin Reference:: The origin data type.
  5194. @end menu
  5195. @node package Reference
  5196. @subsection @code{package} Reference
  5197. This section summarizes all the options available in @code{package}
  5198. declarations (@pxref{Defining Packages}).
  5199. @deftp {Data Type} package
  5200. This is the data type representing a package recipe.
  5201. @table @asis
  5202. @item @code{name}
  5203. The name of the package, as a string.
  5204. @item @code{version}
  5205. The version of the package, as a string.
  5206. @item @code{source}
  5207. An object telling how the source code for the package should be
  5208. acquired. Most of the time, this is an @code{origin} object, which
  5209. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5210. can also be any other ``file-like'' object such as a @code{local-file},
  5211. which denotes a file from the local file system (@pxref{G-Expressions,
  5212. @code{local-file}}).
  5213. @item @code{build-system}
  5214. The build system that should be used to build the package (@pxref{Build
  5215. Systems}).
  5216. @item @code{arguments} (default: @code{'()})
  5217. The arguments that should be passed to the build system. This is a
  5218. list, typically containing sequential keyword-value pairs.
  5219. @item @code{inputs} (default: @code{'()})
  5220. @itemx @code{native-inputs} (default: @code{'()})
  5221. @itemx @code{propagated-inputs} (default: @code{'()})
  5222. @cindex inputs, of packages
  5223. These fields list dependencies of the package. Each one is a list of
  5224. tuples, where each tuple has a label for the input (a string) as its
  5225. first element, a package, origin, or derivation as its second element,
  5226. and optionally the name of the output thereof that should be used, which
  5227. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  5228. more on package outputs). For example, the list below specifies three
  5229. inputs:
  5230. @lisp
  5231. `(("libffi" ,libffi)
  5232. ("libunistring" ,libunistring)
  5233. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  5234. @end lisp
  5235. @cindex cross compilation, package dependencies
  5236. The distinction between @code{native-inputs} and @code{inputs} is
  5237. necessary when considering cross-compilation. When cross-compiling,
  5238. dependencies listed in @code{inputs} are built for the @emph{target}
  5239. architecture; conversely, dependencies listed in @code{native-inputs}
  5240. are built for the architecture of the @emph{build} machine.
  5241. @code{native-inputs} is typically used to list tools needed at
  5242. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5243. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5244. this area (@pxref{Invoking guix lint}).
  5245. @anchor{package-propagated-inputs}
  5246. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5247. specified packages will be automatically installed to profiles
  5248. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5249. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5250. package}}, for information on how @command{guix package} deals with
  5251. propagated inputs).
  5252. For example this is necessary when packaging a C/C++ library that needs
  5253. headers of another library to compile, or when a pkg-config file refers
  5254. to another one @i{via} its @code{Requires} field.
  5255. Another example where @code{propagated-inputs} is useful is for languages
  5256. that lack a facility to record the run-time search path akin to the
  5257. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5258. more. When packaging libraries written in those languages, ensure they
  5259. can find library code they depend on at run time by listing run-time
  5260. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5261. @item @code{outputs} (default: @code{'("out")})
  5262. The list of output names of the package. @xref{Packages with Multiple
  5263. Outputs}, for typical uses of additional outputs.
  5264. @item @code{native-search-paths} (default: @code{'()})
  5265. @itemx @code{search-paths} (default: @code{'()})
  5266. A list of @code{search-path-specification} objects describing
  5267. search-path environment variables honored by the package.
  5268. @item @code{replacement} (default: @code{#f})
  5269. This must be either @code{#f} or a package object that will be used as a
  5270. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5271. for details.
  5272. @item @code{synopsis}
  5273. A one-line description of the package.
  5274. @item @code{description}
  5275. A more elaborate description of the package.
  5276. @item @code{license}
  5277. @cindex license, of packages
  5278. The license of the package; a value from @code{(guix licenses)},
  5279. or a list of such values.
  5280. @item @code{home-page}
  5281. The URL to the home-page of the package, as a string.
  5282. @item @code{supported-systems} (default: @code{%supported-systems})
  5283. The list of systems supported by the package, as strings of the form
  5284. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5285. @item @code{location} (default: source location of the @code{package} form)
  5286. The source location of the package. It is useful to override this when
  5287. inheriting from another package, in which case this field is not
  5288. automatically corrected.
  5289. @end table
  5290. @end deftp
  5291. @deffn {Scheme Syntax} this-package
  5292. When used in the @emph{lexical scope} of a package field definition, this
  5293. identifier resolves to the package being defined.
  5294. The example below shows how to add a package as a native input of itself when
  5295. cross-compiling:
  5296. @lisp
  5297. (package
  5298. (name "guile")
  5299. ;; ...
  5300. ;; When cross-compiled, Guile, for example, depends on
  5301. ;; a native version of itself. Add it here.
  5302. (native-inputs (if (%current-target-system)
  5303. `(("self" ,this-package))
  5304. '())))
  5305. @end lisp
  5306. It is an error to refer to @code{this-package} outside a package definition.
  5307. @end deffn
  5308. @node origin Reference
  5309. @subsection @code{origin} Reference
  5310. This section summarizes all the options available in @code{origin}
  5311. declarations (@pxref{Defining Packages}).
  5312. @deftp {Data Type} origin
  5313. This is the data type representing a source code origin.
  5314. @table @asis
  5315. @item @code{uri}
  5316. An object containing the URI of the source. The object type depends on
  5317. the @code{method} (see below). For example, when using the
  5318. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5319. values are: a URL represented as a string, or a list thereof.
  5320. @item @code{method}
  5321. A procedure that handles the URI.
  5322. Examples include:
  5323. @table @asis
  5324. @item @var{url-fetch} from @code{(guix download)}
  5325. download a file from the HTTP, HTTPS, or FTP URL specified in the
  5326. @code{uri} field;
  5327. @vindex git-fetch
  5328. @item @var{git-fetch} from @code{(guix git-download)}
  5329. clone the Git version control repository, and check out the revision
  5330. specified in the @code{uri} field as a @code{git-reference} object; a
  5331. @code{git-reference} looks like this:
  5332. @lisp
  5333. (git-reference
  5334. (url "https://git.savannah.gnu.org/git/hello.git")
  5335. (commit "v2.10"))
  5336. @end lisp
  5337. @vindex gnunet-fetch
  5338. @item @var{gnunet-fetch} from @code{(guix gnunet-download)}
  5339. download a file specified by its GNUnet chk-URI. To use
  5340. this method, the GNUnet file-sharing daemon has to be configured
  5341. to accept connections from the loopback networking interface.
  5342. @end table
  5343. @item @code{sha256}
  5344. A bytevector containing the SHA-256 hash of the source. This is
  5345. equivalent to providing a @code{content-hash} SHA256 object in the
  5346. @code{hash} field described below.
  5347. @item @code{hash}
  5348. The @code{content-hash} object of the source---see below for how to use
  5349. @code{content-hash}.
  5350. You can obtain this information using @code{guix download}
  5351. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5352. guix hash}).
  5353. @item @code{file-name} (default: @code{#f})
  5354. The file name under which the source code should be saved. When this is
  5355. @code{#f}, a sensible default value will be used in most cases. In case
  5356. the source is fetched from a URL, the file name from the URL will be
  5357. used. For version control checkouts, it is recommended to provide the
  5358. file name explicitly because the default is not very descriptive.
  5359. @item @code{patches} (default: @code{'()})
  5360. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  5361. file-like objects}) pointing to patches to be applied to the source.
  5362. This list of patches must be unconditional. In particular, it cannot
  5363. depend on the value of @code{%current-system} or
  5364. @code{%current-target-system}.
  5365. @item @code{snippet} (default: @code{#f})
  5366. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  5367. in the source directory. This is a convenient way to modify the source,
  5368. sometimes more convenient than a patch.
  5369. @item @code{patch-flags} (default: @code{'("-p1")})
  5370. A list of command-line flags that should be passed to the @code{patch}
  5371. command.
  5372. @item @code{patch-inputs} (default: @code{#f})
  5373. Input packages or derivations to the patching process. When this is
  5374. @code{#f}, the usual set of inputs necessary for patching are provided,
  5375. such as GNU@tie{}Patch.
  5376. @item @code{modules} (default: @code{'()})
  5377. A list of Guile modules that should be loaded during the patching
  5378. process and while running the code in the @code{snippet} field.
  5379. @item @code{patch-guile} (default: @code{#f})
  5380. The Guile package that should be used in the patching process. When
  5381. this is @code{#f}, a sensible default is used.
  5382. @end table
  5383. @end deftp
  5384. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  5385. Construct a content hash object for the given @var{algorithm}, and with
  5386. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  5387. it is @code{sha256}.
  5388. @var{value} can be a literal string, in which case it is base32-decoded,
  5389. or it can be a bytevector.
  5390. The following forms are all equivalent:
  5391. @lisp
  5392. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  5393. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  5394. sha256)
  5395. (content-hash (base32
  5396. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  5397. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  5398. sha256)
  5399. @end lisp
  5400. Technically, @code{content-hash} is currently implemented as a macro.
  5401. It performs sanity checks at macro-expansion time, when possible, such
  5402. as ensuring that @var{value} has the right size for @var{algorithm}.
  5403. @end deftp
  5404. @node Build Systems
  5405. @section Build Systems
  5406. @cindex build system
  5407. Each package definition specifies a @dfn{build system} and arguments for
  5408. that build system (@pxref{Defining Packages}). This @code{build-system}
  5409. field represents the build procedure of the package, as well as implicit
  5410. dependencies of that build procedure.
  5411. Build systems are @code{<build-system>} objects. The interface to
  5412. create and manipulate them is provided by the @code{(guix build-system)}
  5413. module, and actual build systems are exported by specific modules.
  5414. @cindex bag (low-level package representation)
  5415. Under the hood, build systems first compile package objects to
  5416. @dfn{bags}. A @dfn{bag} is like a package, but with less
  5417. ornamentation---in other words, a bag is a lower-level representation of
  5418. a package, which includes all the inputs of that package, including some
  5419. that were implicitly added by the build system. This intermediate
  5420. representation is then compiled to a derivation (@pxref{Derivations}).
  5421. Build systems accept an optional list of @dfn{arguments}. In package
  5422. definitions, these are passed @i{via} the @code{arguments} field
  5423. (@pxref{Defining Packages}). They are typically keyword arguments
  5424. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  5425. Guile Reference Manual}). The value of these arguments is usually
  5426. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  5427. by the daemon (@pxref{Derivations}).
  5428. The main build system is @code{gnu-build-system}, which implements the
  5429. standard build procedure for GNU and many other packages. It
  5430. is provided by the @code{(guix build-system gnu)} module.
  5431. @defvr {Scheme Variable} gnu-build-system
  5432. @code{gnu-build-system} represents the GNU Build System, and variants
  5433. thereof (@pxref{Configuration, configuration and makefile conventions,,
  5434. standards, GNU Coding Standards}).
  5435. @cindex build phases
  5436. In a nutshell, packages using it are configured, built, and installed with
  5437. the usual @code{./configure && make && make check && make install}
  5438. command sequence. In practice, a few additional steps are often needed.
  5439. All these steps are split up in separate @dfn{phases},
  5440. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  5441. modules for more details about the build phases.}:
  5442. @table @code
  5443. @item unpack
  5444. Unpack the source tarball, and change the current directory to the
  5445. extracted source tree. If the source is actually a directory, copy it
  5446. to the build tree, and enter that directory.
  5447. @item patch-source-shebangs
  5448. Patch shebangs encountered in source files so they refer to the right
  5449. store file names. For instance, this changes @code{#!/bin/sh} to
  5450. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  5451. @item configure
  5452. Run the @file{configure} script with a number of default options, such
  5453. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  5454. by the @code{#:configure-flags} argument.
  5455. @item build
  5456. Run @code{make} with the list of flags specified with
  5457. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  5458. (the default), build with @code{make -j}.
  5459. @item check
  5460. Run @code{make check}, or some other target specified with
  5461. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  5462. @code{#:parallel-tests?} argument is true (the default), run @code{make
  5463. check -j}.
  5464. @item install
  5465. Run @code{make install} with the flags listed in @code{#:make-flags}.
  5466. @item patch-shebangs
  5467. Patch shebangs on the installed executable files.
  5468. @item strip
  5469. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  5470. is false), copying them to the @code{debug} output when available
  5471. (@pxref{Installing Debugging Files}).
  5472. @end table
  5473. @vindex %standard-phases
  5474. The build-side module @code{(guix build gnu-build-system)} defines
  5475. @code{%standard-phases} as the default list of build phases.
  5476. @code{%standard-phases} is a list of symbol/procedure pairs, where the
  5477. procedure implements the actual phase.
  5478. The list of phases used for a particular package can be changed with the
  5479. @code{#:phases} parameter. For instance, passing:
  5480. @example
  5481. #:phases (modify-phases %standard-phases (delete 'configure))
  5482. @end example
  5483. means that all the phases described above will be used, except the
  5484. @code{configure} phase.
  5485. In addition, this build system ensures that the ``standard'' environment
  5486. for GNU packages is available. This includes tools such as GCC, libc,
  5487. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  5488. build-system gnu)} module for a complete list). We call these the
  5489. @dfn{implicit inputs} of a package, because package definitions do not
  5490. have to mention them.
  5491. @end defvr
  5492. Other @code{<build-system>} objects are defined to support other
  5493. conventions and tools used by free software packages. They inherit most
  5494. of @code{gnu-build-system}, and differ mainly in the set of inputs
  5495. implicitly added to the build process, and in the list of phases
  5496. executed. Some of these build systems are listed below.
  5497. @defvr {Scheme Variable} ant-build-system
  5498. This variable is exported by @code{(guix build-system ant)}. It
  5499. implements the build procedure for Java packages that can be built with
  5500. @url{https://ant.apache.org/, Ant build tool}.
  5501. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  5502. provided by the @code{icedtea} package to the set of inputs. Different
  5503. packages can be specified with the @code{#:ant} and @code{#:jdk}
  5504. parameters, respectively.
  5505. When the original package does not provide a suitable Ant build file,
  5506. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  5507. build file @file{build.xml} with tasks to build the specified jar
  5508. archive. In this case the parameter @code{#:source-dir} can be used to
  5509. specify the source sub-directory, defaulting to ``src''.
  5510. The @code{#:main-class} parameter can be used with the minimal ant
  5511. buildfile to specify the main class of the resulting jar. This makes the
  5512. jar file executable. The @code{#:test-include} parameter can be used to
  5513. specify the list of junit tests to run. It defaults to
  5514. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  5515. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  5516. because abstract classes cannot be run as tests.
  5517. The parameter @code{#:build-target} can be used to specify the Ant task
  5518. that should be run during the @code{build} phase. By default the
  5519. ``jar'' task will be run.
  5520. @end defvr
  5521. @defvr {Scheme Variable} android-ndk-build-system
  5522. @cindex Android distribution
  5523. @cindex Android NDK build system
  5524. This variable is exported by @code{(guix build-system android-ndk)}. It
  5525. implements a build procedure for Android NDK (native development kit)
  5526. packages using a Guix-specific build process.
  5527. The build system assumes that packages install their public interface
  5528. (header) files to the subdirectory @file{include} of the @code{out} output and
  5529. their libraries to the subdirectory @file{lib} the @code{out} output.
  5530. It's also assumed that the union of all the dependencies of a package
  5531. has no conflicting files.
  5532. For the time being, cross-compilation is not supported - so right now
  5533. the libraries and header files are assumed to be host tools.
  5534. @end defvr
  5535. @defvr {Scheme Variable} asdf-build-system/source
  5536. @defvrx {Scheme Variable} asdf-build-system/sbcl
  5537. @defvrx {Scheme Variable} asdf-build-system/ecl
  5538. These variables, exported by @code{(guix build-system asdf)}, implement
  5539. build procedures for Common Lisp packages using
  5540. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  5541. definition facility for Common Lisp programs and libraries.
  5542. The @code{asdf-build-system/source} system installs the packages in
  5543. source form, and can be loaded using any common lisp implementation, via
  5544. ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
  5545. systems in the format which a particular implementation understands.
  5546. These build systems can also be used to produce executable programs, or
  5547. lisp images which contain a set of packages pre-loaded.
  5548. The build system uses naming conventions. For binary packages, the
  5549. package name should be prefixed with the lisp implementation, such as
  5550. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  5551. Additionally, the corresponding source package should be labeled using
  5552. the same convention as python packages (see @ref{Python Modules}), using
  5553. the @code{cl-} prefix.
  5554. For binary packages, each system should be defined as a Guix package.
  5555. If one package @code{origin} contains several systems, package variants
  5556. can be created in order to build all the systems. Source packages,
  5557. which use @code{asdf-build-system/source}, may contain several systems.
  5558. In order to create executable programs and images, the build-side
  5559. procedures @code{build-program} and @code{build-image} can be used.
  5560. They should be called in a build phase after the @code{create-symlinks}
  5561. phase, so that the system which was just built can be used within the
  5562. resulting image. @code{build-program} requires a list of Common Lisp
  5563. expressions to be passed as the @code{#:entry-program} argument.
  5564. If the system is not defined within its own @file{.asd} file of the same
  5565. name, then the @code{#:asd-file} parameter should be used to specify
  5566. which file the system is defined in. Furthermore, if the package
  5567. defines a system for its tests in a separate file, it will be loaded
  5568. before the tests are run if it is specified by the
  5569. @code{#:test-asd-file} parameter. If it is not set, the files
  5570. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  5571. and @code{test.asd} will be tried if they exist.
  5572. If for some reason the package must be named in a different way than the
  5573. naming conventions suggest, the @code{#:asd-system-name} parameter can
  5574. be used to specify the name of the system.
  5575. @end defvr
  5576. @defvr {Scheme Variable} cargo-build-system
  5577. @cindex Rust programming language
  5578. @cindex Cargo (Rust build system)
  5579. This variable is exported by @code{(guix build-system cargo)}. It
  5580. supports builds of packages using Cargo, the build tool of the
  5581. @uref{https://www.rust-lang.org, Rust programming language}.
  5582. It adds @code{rustc} and @code{cargo} to the set of inputs.
  5583. A different Rust package can be specified with the @code{#:rust} parameter.
  5584. Regular cargo dependencies should be added to the package definition via the
  5585. @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  5586. spec can be a package or a source definition. Note that the spec must
  5587. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  5588. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  5589. should be added to the package definition via the
  5590. @code{#:cargo-development-inputs} parameter.
  5591. In its @code{configure} phase, this build system will make any source inputs
  5592. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  5593. parameters available to cargo. It will also remove an included
  5594. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  5595. @code{build} phase. The @code{install} phase installs any crate the binaries
  5596. if they are defined by the crate.
  5597. @end defvr
  5598. @defvr {Scheme Variable} copy-build-system
  5599. This variable is exported by @code{(guix build-system copy)}. It
  5600. supports builds of simple packages that don't require much compiling,
  5601. mostly just moving files around.
  5602. It adds much of the @code{gnu-build-system} packages to the set of
  5603. inputs. Because of this, the @code{copy-build-system} does not require
  5604. all the boilerplate code often needed for the
  5605. @code{trivial-build-system}.
  5606. To further simplify the file installation process, an
  5607. @code{#:install-plan} argument is exposed to let the packager specify
  5608. which files go where. The install plan is a list of @code{(@var{source}
  5609. @var{target} [@var{filters}])}. @var{filters} are optional.
  5610. @itemize
  5611. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  5612. @itemize
  5613. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  5614. @item Otherwise install @var{source} as @var{target}.
  5615. @end itemize
  5616. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  5617. the trailing slash of @var{target} is implied with the same meaning
  5618. as above.
  5619. @itemize
  5620. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  5621. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  5622. @code{#:exclude-regexp}, only select files are installed depending on
  5623. the filters. Each filters is specified by a list of strings.
  5624. @itemize
  5625. @item With @code{#:include}, install all the files which the path suffix matches
  5626. at least one of the elements in the given list.
  5627. @item With @code{#:include-regexp}, install all the files which the
  5628. subpaths match at least one of the regular expressions in the given
  5629. list.
  5630. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  5631. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  5632. install all files but those matching the exclusion filters.
  5633. If both inclusions and exclusions are specified, the exclusions are done
  5634. on top of the inclusions.
  5635. @end itemize
  5636. @end itemize
  5637. In all cases, the paths relative to @var{source} are preserved within
  5638. @var{target}.
  5639. @end itemize
  5640. Examples:
  5641. @itemize
  5642. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  5643. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  5644. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  5645. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  5646. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  5647. @file{share/my-app/sub/file}.
  5648. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  5649. @file{share/my-app/file}.
  5650. @end itemize
  5651. @end defvr
  5652. @cindex Clojure (programming language)
  5653. @cindex simple Clojure build system
  5654. @defvr {Scheme Variable} clojure-build-system
  5655. This variable is exported by @code{(guix build-system clojure)}. It implements
  5656. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  5657. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  5658. yet.
  5659. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  5660. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  5661. @code{#:zip} parameters, respectively.
  5662. A list of source directories, test directories and jar names can be specified
  5663. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  5664. parameters, respectively. Compile directory and main class can be specified
  5665. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  5666. Other parameters are documented below.
  5667. This build system is an extension of @code{ant-build-system}, but with the
  5668. following phases changed:
  5669. @table @code
  5670. @item build
  5671. This phase calls @code{compile} in Clojure to compile source files and runs
  5672. @command{jar} to create jars from both source files and compiled files
  5673. according to the include list and exclude list specified in
  5674. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  5675. has priority over the include list. These lists consist of symbols
  5676. representing Clojure libraries or the special keyword @code{#:all} representing
  5677. all Clojure libraries found under the source directories. The parameter
  5678. @code{#:omit-source?} decides if source should be included into the jars.
  5679. @item check
  5680. This phase runs tests according to the include list and exclude list specified
  5681. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  5682. meanings are analogous to that of @code{#:aot-include} and
  5683. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  5684. stands for all Clojure libraries found under the test directories. The
  5685. parameter @code{#:tests?} decides if tests should be run.
  5686. @item install
  5687. This phase installs all jars built previously.
  5688. @end table
  5689. Apart from the above, this build system also contains an additional phase:
  5690. @table @code
  5691. @item install-doc
  5692. This phase installs all top-level files with base name matching
  5693. @code{%doc-regex}. A different regex can be specified with the
  5694. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  5695. directories specified in @code{#:doc-dirs} are installed as well.
  5696. @end table
  5697. @end defvr
  5698. @defvr {Scheme Variable} cmake-build-system
  5699. This variable is exported by @code{(guix build-system cmake)}. It
  5700. implements the build procedure for packages using the
  5701. @url{https://www.cmake.org, CMake build tool}.
  5702. It automatically adds the @code{cmake} package to the set of inputs.
  5703. Which package is used can be specified with the @code{#:cmake}
  5704. parameter.
  5705. The @code{#:configure-flags} parameter is taken as a list of flags
  5706. passed to the @command{cmake} command. The @code{#:build-type}
  5707. parameter specifies in abstract terms the flags passed to the compiler;
  5708. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  5709. debugging information''), which roughly means that code is compiled with
  5710. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  5711. @end defvr
  5712. @defvr {Scheme Variable} dune-build-system
  5713. This variable is exported by @code{(guix build-system dune)}. It
  5714. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  5715. tool for the OCaml programming language. It is implemented as an extension
  5716. of the @code{ocaml-build-system} which is described below. As such, the
  5717. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  5718. system.
  5719. It automatically adds the @code{dune} package to the set of inputs.
  5720. Which package is used can be specified with the @code{#:dune}
  5721. parameter.
  5722. There is no @code{configure} phase because dune packages typically don't
  5723. need to be configured. The @code{#:build-flags} parameter is taken as a
  5724. list of flags passed to the @code{dune} command during the build.
  5725. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  5726. command instead of the more recent @code{dune} command while building
  5727. a package. Its default value is @code{#f}.
  5728. The @code{#:package} parameter can be passed to specify a package name, which
  5729. is useful when a package contains multiple packages and you want to build
  5730. only one of them. This is equivalent to passing the @code{-p} argument to
  5731. @code{dune}.
  5732. @end defvr
  5733. @defvr {Scheme Variable} go-build-system
  5734. This variable is exported by @code{(guix build-system go)}. It
  5735. implements a build procedure for Go packages using the standard
  5736. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  5737. Go build mechanisms}.
  5738. The user is expected to provide a value for the key @code{#:import-path}
  5739. and, in some cases, @code{#:unpack-path}. The
  5740. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  5741. corresponds to the file system path expected by the package's build
  5742. scripts and any referring packages, and provides a unique way to
  5743. refer to a Go package. It is typically based on a combination of the
  5744. package source code's remote URI and file system hierarchy structure. In
  5745. some cases, you will need to unpack the package's source code to a
  5746. different directory structure than the one indicated by the import path,
  5747. and @code{#:unpack-path} should be used in such cases.
  5748. Packages that provide Go libraries should install their source code into
  5749. the built output. The key @code{#:install-source?}, which defaults to
  5750. @code{#t}, controls whether or not the source code is installed. It can
  5751. be set to @code{#f} for packages that only provide executable files.
  5752. @end defvr
  5753. @defvr {Scheme Variable} glib-or-gtk-build-system
  5754. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  5755. is intended for use with packages making use of GLib or GTK+.
  5756. This build system adds the following two phases to the ones defined by
  5757. @code{gnu-build-system}:
  5758. @table @code
  5759. @item glib-or-gtk-wrap
  5760. The phase @code{glib-or-gtk-wrap} ensures that programs in
  5761. @file{bin/} are able to find GLib ``schemas'' and
  5762. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  5763. modules}. This is achieved by wrapping the programs in launch scripts
  5764. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  5765. environment variables.
  5766. It is possible to exclude specific package outputs from that wrapping
  5767. process by listing their names in the
  5768. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  5769. when an output is known not to contain any GLib or GTK+ binaries, and
  5770. where wrapping would gratuitously add a dependency of that output on
  5771. GLib and GTK+.
  5772. @item glib-or-gtk-compile-schemas
  5773. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  5774. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  5775. GSettings schemas} of GLib are compiled. Compilation is performed by the
  5776. @command{glib-compile-schemas} program. It is provided by the package
  5777. @code{glib:bin} which is automatically imported by the build system.
  5778. The @code{glib} package providing @command{glib-compile-schemas} can be
  5779. specified with the @code{#:glib} parameter.
  5780. @end table
  5781. Both phases are executed after the @code{install} phase.
  5782. @end defvr
  5783. @defvr {Scheme Variable} guile-build-system
  5784. This build system is for Guile packages that consist exclusively of Scheme
  5785. code and that are so lean that they don't even have a makefile, let alone a
  5786. @file{configure} script. It compiles Scheme code using @command{guild
  5787. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  5788. installs the @file{.scm} and @file{.go} files in the right place. It also
  5789. installs documentation.
  5790. This build system supports cross-compilation by using the
  5791. @option{--target} option of @samp{guild compile}.
  5792. Packages built with @code{guile-build-system} must provide a Guile package in
  5793. their @code{native-inputs} field.
  5794. @end defvr
  5795. @defvr {Scheme Variable} julia-build-system
  5796. This variable is exported by @code{(guix build-system julia)}. It
  5797. implements the build procedure used by @uref{https://julialang.org/,
  5798. julia} packages, which essentially is similar to running @samp{julia -e
  5799. 'using Pkg; Pkg.add(package)'} in an environment where
  5800. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  5801. Tests are run not run.
  5802. Julia packages require the source @code{file-name} to be the real name of the
  5803. package, correctly capitalized.
  5804. For packages requiring shared library dependencies, you may need to write the
  5805. @file{/deps/deps.jl} file manually. It's usually a line of @code{const
  5806. variable = /gnu/store/library.so} for each dependency, plus a void function
  5807. @code{check_deps() = nothing}.
  5808. Some older packages that aren't using @file{Package.toml} yet, will require
  5809. this file to be created, too. The function @code{julia-create-package-toml}
  5810. helps creating the file. You need to pass the outputs and the source of the
  5811. package, it's name (the same as the @code{file-name} parameter), the package
  5812. uuid, the package version, and a list of dependencies specified by their name
  5813. and their uuid.
  5814. @end defvr
  5815. @defvr {Scheme Variable} maven-build-system
  5816. This variable is exported by @code{(guix build-system maven)}. It implements
  5817. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  5818. is a dependency and lifecycle management tool for Java. A user of Maven
  5819. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  5820. When Maven does not have one of the dependencies or plugins in its repository,
  5821. it will download them and use them to build the package.
  5822. The maven build system ensures that maven will not try to download any
  5823. dependency by running in offline mode. Maven will fail if a dependency is
  5824. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  5825. modified to specify the version of dependencies and plugins that match the
  5826. versions available in the guix build environment. Dependencies and plugins
  5827. must be installed in the fake maven repository at @file{lib/m2}, and are
  5828. symlinked into a proper repository before maven is run. Maven is instructed
  5829. to use that repository for the build and installs built artifacts there.
  5830. Changed files are copied to the @file{lib/m2} directory of the package output.
  5831. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  5832. or let the build system use the default @file{pom.xml} file in the sources.
  5833. In case you need to specify a dependency's version manually, you can use the
  5834. @code{#:local-packages} argument. It takes an association list where the key
  5835. is the groupId of the package and its value is an association list where the
  5836. key is the artifactId of the package and its value is the version you want to
  5837. override in the @file{pom.xml}.
  5838. Some packages use dependencies or plugins that are not useful at runtime nor
  5839. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  5840. using the @code{#:exclude} argument. Its value is an association list where
  5841. the key is the groupId of the plugin or dependency you want to remove, and
  5842. the value is a list of artifactId you want to remove.
  5843. You can override the default @code{jdk} and @code{maven} packages with the
  5844. corresponding argument, @code{#:jdk} and @code{#:maven}.
  5845. The @code{#:maven-plugins} argument is a list of maven plugins used during
  5846. the build, with the same format as the @code{inputs} fields of the package
  5847. declaration. Its default value is @code{(default-maven-plugins)} which is
  5848. also exported.
  5849. @end defvr
  5850. @defvr {Scheme Variable} minify-build-system
  5851. This variable is exported by @code{(guix build-system minify)}. It
  5852. implements a minification procedure for simple JavaScript packages.
  5853. It adds @code{uglify-js} to the set of inputs and uses it to compress
  5854. all JavaScript files in the @file{src} directory. A different minifier
  5855. package can be specified with the @code{#:uglify-js} parameter, but it
  5856. is expected that the package writes the minified code to the standard
  5857. output.
  5858. When the input JavaScript files are not all located in the @file{src}
  5859. directory, the parameter @code{#:javascript-files} can be used to
  5860. specify a list of file names to feed to the minifier.
  5861. @end defvr
  5862. @defvr {Scheme Variable} ocaml-build-system
  5863. This variable is exported by @code{(guix build-system ocaml)}. It implements
  5864. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  5865. of choosing the correct set of commands to run for each package. OCaml
  5866. packages can expect many different commands to be run. This build system will
  5867. try some of them.
  5868. When the package has a @file{setup.ml} file present at the top-level, it will
  5869. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  5870. @code{ocaml setup.ml -install}. The build system will assume that this file
  5871. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  5872. care of setting the prefix and enabling tests if they are not disabled. You
  5873. can pass configure and build flags with the @code{#:configure-flags} and
  5874. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  5875. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  5876. bypass this system in the build and install phases.
  5877. When the package has a @file{configure} file, it is assumed that it is a
  5878. hand-made configure script that requires a different argument format than
  5879. in the @code{gnu-build-system}. You can add more flags with the
  5880. @code{#:configure-flags} key.
  5881. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  5882. @code{#t}), it will be used and more flags can be passed to the build and
  5883. install phases with the @code{#:make-flags} key.
  5884. Finally, some packages do not have these files and use a somewhat standard
  5885. location for its build system. In that case, the build system will run
  5886. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  5887. providing the path to the required findlib module. Additional flags can
  5888. be passed via the @code{#:build-flags} key. Install is taken care of by
  5889. @command{opam-installer}. In this case, the @code{opam} package must
  5890. be added to the @code{native-inputs} field of the package definition.
  5891. Note that most OCaml packages assume they will be installed in the same
  5892. directory as OCaml, which is not what we want in guix. In particular, they
  5893. will install @file{.so} files in their module's directory, which is usually
  5894. fine because it is in the OCaml compiler directory. In guix though, these
  5895. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  5896. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  5897. @file{.so} libraries should be installed.
  5898. @end defvr
  5899. @defvr {Scheme Variable} python-build-system
  5900. This variable is exported by @code{(guix build-system python)}. It
  5901. implements the more or less standard build procedure used by Python
  5902. packages, which consists in running @code{python setup.py build} and
  5903. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  5904. For packages that install stand-alone Python programs under @code{bin/},
  5905. it takes care of wrapping these programs so that their @env{PYTHONPATH}
  5906. environment variable points to all the Python libraries they depend on.
  5907. Which Python package is used to perform the build can be specified with
  5908. the @code{#:python} parameter. This is a useful way to force a package
  5909. to be built for a specific version of the Python interpreter, which
  5910. might be necessary if the package is only compatible with a single
  5911. interpreter version.
  5912. By default guix calls @code{setup.py} under control of
  5913. @code{setuptools}, much like @command{pip} does. Some packages are not
  5914. compatible with setuptools (and pip), thus you can disable this by
  5915. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  5916. @end defvr
  5917. @defvr {Scheme Variable} perl-build-system
  5918. This variable is exported by @code{(guix build-system perl)}. It
  5919. implements the standard build procedure for Perl packages, which either
  5920. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  5921. followed by @code{Build} and @code{Build install}; or in running
  5922. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  5923. @code{make} and @code{make install}, depending on which of
  5924. @code{Build.PL} or @code{Makefile.PL} is present in the package
  5925. distribution. Preference is given to the former if both @code{Build.PL}
  5926. and @code{Makefile.PL} exist in the package distribution. This
  5927. preference can be reversed by specifying @code{#t} for the
  5928. @code{#:make-maker?} parameter.
  5929. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  5930. passes flags specified by the @code{#:make-maker-flags} or
  5931. @code{#:module-build-flags} parameter, respectively.
  5932. Which Perl package is used can be specified with @code{#:perl}.
  5933. @end defvr
  5934. @defvr {Scheme Variable} qt-build-system
  5935. This variable is exported by @code{(guix build-system qt)}. It
  5936. is intended for use with applications using Qt or KDE.
  5937. This build system adds the following two phases to the ones defined by
  5938. @code{cmake-build-system}:
  5939. @table @code
  5940. @item check-setup
  5941. The phase @code{check-setup} prepares the environment for running
  5942. the checks as commonly used by Qt test programs.
  5943. For now this only sets some environment variables:
  5944. @code{QT_QPA_PLATFORM=offscreen},
  5945. @code{DBUS_FATAL_WARNINGS=0} and
  5946. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  5947. This phase is added before the @code{check} phase.
  5948. It's a separate phase to ease adjusting if necessary.
  5949. @item qt-wrap
  5950. The phase @code{qt-wrap}
  5951. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  5952. and output. In case some path is found, all programs in the output's
  5953. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  5954. are wrapped in scripts defining the necessary environment variables.
  5955. It is possible to exclude specific package outputs from that wrapping process
  5956. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  5957. This is useful when an output is known not to contain any Qt binaries, and
  5958. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  5959. or such.
  5960. This phase is added after the @code{install} phase.
  5961. @end table
  5962. @end defvr
  5963. @defvr {Scheme Variable} r-build-system
  5964. This variable is exported by @code{(guix build-system r)}. It
  5965. implements the build procedure used by @uref{https://r-project.org, R}
  5966. packages, which essentially is little more than running @samp{R CMD
  5967. INSTALL --library=/gnu/store/@dots{}} in an environment where
  5968. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  5969. run after installation using the R function
  5970. @code{tools::testInstalledPackage}.
  5971. @end defvr
  5972. @defvr {Scheme Variable} rakudo-build-system
  5973. This variable is exported by @code{(guix build-system rakudo)}. It
  5974. implements the build procedure used by @uref{https://rakudo.org/,
  5975. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  5976. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  5977. installs the binaries, library files and the resources, as well as wrap
  5978. the files under the @code{bin/} directory. Tests can be skipped by
  5979. passing @code{#f} to the @code{tests?} parameter.
  5980. Which rakudo package is used can be specified with @code{rakudo}.
  5981. Which perl6-tap-harness package used for the tests can be specified with
  5982. @code{#:prove6} or removed by passing @code{#f} to the
  5983. @code{with-prove6?} parameter.
  5984. Which perl6-zef package used for tests and installing can be specified
  5985. with @code{#:zef} or removed by passing @code{#f} to the
  5986. @code{with-zef?} parameter.
  5987. @end defvr
  5988. @defvr {Scheme Variable} texlive-build-system
  5989. This variable is exported by @code{(guix build-system texlive)}. It is
  5990. used to build TeX packages in batch mode with a specified engine. The
  5991. build system sets the @env{TEXINPUTS} variable to find all TeX source
  5992. files in the inputs.
  5993. By default it runs @code{luatex} on all files ending on @code{ins}. A
  5994. different engine and format can be specified with the
  5995. @code{#:tex-format} argument. Different build targets can be specified
  5996. with the @code{#:build-targets} argument, which expects a list of file
  5997. names. The build system adds only @code{texlive-bin} and
  5998. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  5999. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  6000. and @code{#:texlive-latex-base}, respectively.
  6001. The @code{#:tex-directory} parameter tells the build system where to
  6002. install the built files under the texmf tree.
  6003. @end defvr
  6004. @defvr {Scheme Variable} ruby-build-system
  6005. This variable is exported by @code{(guix build-system ruby)}. It
  6006. implements the RubyGems build procedure used by Ruby packages, which
  6007. involves running @code{gem build} followed by @code{gem install}.
  6008. The @code{source} field of a package that uses this build system
  6009. typically references a gem archive, since this is the format that Ruby
  6010. developers use when releasing their software. The build system unpacks
  6011. the gem archive, potentially patches the source, runs the test suite,
  6012. repackages the gem, and installs it. Additionally, directories and
  6013. tarballs may be referenced to allow building unreleased gems from Git or
  6014. a traditional source release tarball.
  6015. Which Ruby package is used can be specified with the @code{#:ruby}
  6016. parameter. A list of additional flags to be passed to the @command{gem}
  6017. command can be specified with the @code{#:gem-flags} parameter.
  6018. @end defvr
  6019. @defvr {Scheme Variable} waf-build-system
  6020. This variable is exported by @code{(guix build-system waf)}. It
  6021. implements a build procedure around the @code{waf} script. The common
  6022. phases---@code{configure}, @code{build}, and @code{install}---are
  6023. implemented by passing their names as arguments to the @code{waf}
  6024. script.
  6025. The @code{waf} script is executed by the Python interpreter. Which
  6026. Python package is used to run the script can be specified with the
  6027. @code{#:python} parameter.
  6028. @end defvr
  6029. @defvr {Scheme Variable} scons-build-system
  6030. This variable is exported by @code{(guix build-system scons)}. It
  6031. implements the build procedure used by the SCons software construction
  6032. tool. This build system runs @code{scons} to build the package,
  6033. @code{scons test} to run tests, and then @code{scons install} to install
  6034. the package.
  6035. Additional flags to be passed to @code{scons} can be specified with the
  6036. @code{#:scons-flags} parameter. The default build and install targets
  6037. can be overridden with @code{#:build-targets} and
  6038. @code{#:install-targets} respectively. The version of Python used to
  6039. run SCons can be specified by selecting the appropriate SCons package
  6040. with the @code{#:scons} parameter.
  6041. @end defvr
  6042. @defvr {Scheme Variable} haskell-build-system
  6043. This variable is exported by @code{(guix build-system haskell)}. It
  6044. implements the Cabal build procedure used by Haskell packages, which
  6045. involves running @code{runhaskell Setup.hs configure
  6046. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  6047. Instead of installing the package by running @code{runhaskell Setup.hs
  6048. install}, to avoid trying to register libraries in the read-only
  6049. compiler store directory, the build system uses @code{runhaskell
  6050. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  6051. addition, the build system generates the package documentation by
  6052. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  6053. is passed. Optional Haddock parameters can be passed with the help of
  6054. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  6055. not found, the build system looks for @code{Setup.lhs} instead.
  6056. Which Haskell compiler is used can be specified with the @code{#:haskell}
  6057. parameter which defaults to @code{ghc}.
  6058. @end defvr
  6059. @defvr {Scheme Variable} dub-build-system
  6060. This variable is exported by @code{(guix build-system dub)}. It
  6061. implements the Dub build procedure used by D packages, which
  6062. involves running @code{dub build} and @code{dub run}.
  6063. Installation is done by copying the files manually.
  6064. Which D compiler is used can be specified with the @code{#:ldc}
  6065. parameter which defaults to @code{ldc}.
  6066. @end defvr
  6067. @defvr {Scheme Variable} emacs-build-system
  6068. This variable is exported by @code{(guix build-system emacs)}. It
  6069. implements an installation procedure similar to the packaging system
  6070. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  6071. It first creates the @code{@code{package}-autoloads.el} file, then it
  6072. byte compiles all Emacs Lisp files. Differently from the Emacs
  6073. packaging system, the Info documentation files are moved to the standard
  6074. documentation directory and the @file{dir} file is deleted. The Elisp
  6075. package files are installed directly under @file{share/emacs/site-lisp}.
  6076. @end defvr
  6077. @defvr {Scheme Variable} font-build-system
  6078. This variable is exported by @code{(guix build-system font)}. It
  6079. implements an installation procedure for font packages where upstream
  6080. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  6081. need to be copied into place. It copies font files to standard
  6082. locations in the output directory.
  6083. @end defvr
  6084. @defvr {Scheme Variable} meson-build-system
  6085. This variable is exported by @code{(guix build-system meson)}. It
  6086. implements the build procedure for packages that use
  6087. @url{https://mesonbuild.com, Meson} as their build system.
  6088. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  6089. of inputs, and they can be changed with the parameters @code{#:meson}
  6090. and @code{#:ninja} if needed. The default Meson is
  6091. @code{meson-for-build}, which is special because it doesn't clear the
  6092. @code{RUNPATH} of binaries and libraries when they are installed.
  6093. This build system is an extension of @code{gnu-build-system}, but with the
  6094. following phases changed to some specific for Meson:
  6095. @table @code
  6096. @item configure
  6097. The phase runs @code{meson} with the flags specified in
  6098. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  6099. @code{debugoptimized} unless something else is specified in
  6100. @code{#:build-type}.
  6101. @item build
  6102. The phase runs @code{ninja} to build the package in parallel by default, but
  6103. this can be changed with @code{#:parallel-build?}.
  6104. @item check
  6105. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  6106. which is @code{"test"} by default.
  6107. @item install
  6108. The phase runs @code{ninja install} and can not be changed.
  6109. @end table
  6110. Apart from that, the build system also adds the following phases:
  6111. @table @code
  6112. @item fix-runpath
  6113. This phase ensures that all binaries can find the libraries they need.
  6114. It searches for required libraries in subdirectories of the package being
  6115. built, and adds those to @code{RUNPATH} where needed. It also removes
  6116. references to libraries left over from the build phase by
  6117. @code{meson-for-build}, such as test dependencies, that aren't actually
  6118. required for the program to run.
  6119. @item glib-or-gtk-wrap
  6120. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6121. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6122. @item glib-or-gtk-compile-schemas
  6123. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6124. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6125. @end table
  6126. @end defvr
  6127. @defvr {Scheme Variable} linux-module-build-system
  6128. @code{linux-module-build-system} allows building Linux kernel modules.
  6129. @cindex build phases
  6130. This build system is an extension of @code{gnu-build-system}, but with the
  6131. following phases changed:
  6132. @table @code
  6133. @item configure
  6134. This phase configures the environment so that the Linux kernel's Makefile
  6135. can be used to build the external kernel module.
  6136. @item build
  6137. This phase uses the Linux kernel's Makefile in order to build the external
  6138. kernel module.
  6139. @item install
  6140. This phase uses the Linux kernel's Makefile in order to install the external
  6141. kernel module.
  6142. @end table
  6143. It is possible and useful to specify the Linux kernel to use for building
  6144. the module (in the @code{arguments} form of a package using the
  6145. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  6146. @end defvr
  6147. @defvr {Scheme Variable} node-build-system
  6148. This variable is exported by @code{(guix build-system node)}. It
  6149. implements the build procedure used by @uref{https://nodejs.org,
  6150. Node.js}, which implements an approximation of the @code{npm install}
  6151. command, followed by an @code{npm test} command.
  6152. Which Node.js package is used to interpret the @code{npm} commands can
  6153. be specified with the @code{#:node} parameter which defaults to
  6154. @code{node}.
  6155. @end defvr
  6156. Lastly, for packages that do not need anything as sophisticated, a
  6157. ``trivial'' build system is provided. It is trivial in the sense that
  6158. it provides basically no support: it does not pull any implicit inputs,
  6159. and does not have a notion of build phases.
  6160. @defvr {Scheme Variable} trivial-build-system
  6161. This variable is exported by @code{(guix build-system trivial)}.
  6162. This build system requires a @code{#:builder} argument. This argument
  6163. must be a Scheme expression that builds the package output(s)---as
  6164. with @code{build-expression->derivation} (@pxref{Derivations,
  6165. @code{build-expression->derivation}}).
  6166. @end defvr
  6167. @node The Store
  6168. @section The Store
  6169. @cindex store
  6170. @cindex store items
  6171. @cindex store paths
  6172. Conceptually, the @dfn{store} is the place where derivations that have
  6173. been built successfully are stored---by default, @file{/gnu/store}.
  6174. Sub-directories in the store are referred to as @dfn{store items} or
  6175. sometimes @dfn{store paths}. The store has an associated database that
  6176. contains information such as the store paths referred to by each store
  6177. path, and the list of @emph{valid} store items---results of successful
  6178. builds. This database resides in @file{@var{localstatedir}/guix/db},
  6179. where @var{localstatedir} is the state directory specified @i{via}
  6180. @option{--localstatedir} at configure time, usually @file{/var}.
  6181. The store is @emph{always} accessed by the daemon on behalf of its clients
  6182. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  6183. connect to the daemon over a Unix-domain socket, send requests to it,
  6184. and read the result---these are remote procedure calls, or RPCs.
  6185. @quotation Note
  6186. Users must @emph{never} modify files under @file{/gnu/store} directly.
  6187. This would lead to inconsistencies and break the immutability
  6188. assumptions of Guix's functional model (@pxref{Introduction}).
  6189. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  6190. how to check the integrity of the store and attempt recovery from
  6191. accidental modifications.
  6192. @end quotation
  6193. The @code{(guix store)} module provides procedures to connect to the
  6194. daemon, and to perform RPCs. These are described below. By default,
  6195. @code{open-connection}, and thus all the @command{guix} commands,
  6196. connect to the local daemon or to the URI specified by the
  6197. @env{GUIX_DAEMON_SOCKET} environment variable.
  6198. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  6199. When set, the value of this variable should be a file name or a URI
  6200. designating the daemon endpoint. When it is a file name, it denotes a
  6201. Unix-domain socket to connect to. In addition to file names, the
  6202. supported URI schemes are:
  6203. @table @code
  6204. @item file
  6205. @itemx unix
  6206. These are for Unix-domain sockets.
  6207. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  6208. @file{/var/guix/daemon-socket/socket}.
  6209. @item guix
  6210. @cindex daemon, remote access
  6211. @cindex remote access to the daemon
  6212. @cindex daemon, cluster setup
  6213. @cindex clusters, daemon setup
  6214. These URIs denote connections over TCP/IP, without encryption nor
  6215. authentication of the remote host. The URI must specify the host name
  6216. and optionally a port number (by default port 44146 is used):
  6217. @example
  6218. guix://master.guix.example.org:1234
  6219. @end example
  6220. This setup is suitable on local networks, such as clusters, where only
  6221. trusted nodes may connect to the build daemon at
  6222. @code{master.guix.example.org}.
  6223. The @option{--listen} option of @command{guix-daemon} can be used to
  6224. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  6225. @option{--listen}}).
  6226. @item ssh
  6227. @cindex SSH access to build daemons
  6228. These URIs allow you to connect to a remote daemon over SSH. This
  6229. feature requires Guile-SSH (@pxref{Requirements}) and a working
  6230. @command{guile} binary in @env{PATH} on the destination machine. It
  6231. supports public key and GSSAPI authentication. A typical URL might look
  6232. like this:
  6233. @example
  6234. ssh://charlie@@guix.example.org:22
  6235. @end example
  6236. As for @command{guix copy}, the usual OpenSSH client configuration files
  6237. are honored (@pxref{Invoking guix copy}).
  6238. @end table
  6239. Additional URI schemes may be supported in the future.
  6240. @c XXX: Remove this note when the protocol incurs fewer round trips
  6241. @c and when (guix derivations) no longer relies on file system access.
  6242. @quotation Note
  6243. The ability to connect to remote build daemons is considered
  6244. experimental as of @value{VERSION}. Please get in touch with us to
  6245. share any problems or suggestions you may have (@pxref{Contributing}).
  6246. @end quotation
  6247. @end defvr
  6248. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  6249. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  6250. @var{reserve-space?} is true, instruct it to reserve a little bit of
  6251. extra space on the file system so that the garbage collector can still
  6252. operate should the disk become full. Return a server object.
  6253. @var{file} defaults to @code{%default-socket-path}, which is the normal
  6254. location given the options that were passed to @command{configure}.
  6255. @end deffn
  6256. @deffn {Scheme Procedure} close-connection @var{server}
  6257. Close the connection to @var{server}.
  6258. @end deffn
  6259. @defvr {Scheme Variable} current-build-output-port
  6260. This variable is bound to a SRFI-39 parameter, which refers to the port
  6261. where build and error logs sent by the daemon should be written.
  6262. @end defvr
  6263. Procedures that make RPCs all take a server object as their first
  6264. argument.
  6265. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  6266. @cindex invalid store items
  6267. Return @code{#t} when @var{path} designates a valid store item and
  6268. @code{#f} otherwise (an invalid item may exist on disk but still be
  6269. invalid, for instance because it is the result of an aborted or failed
  6270. build).
  6271. A @code{&store-protocol-error} condition is raised if @var{path} is not
  6272. prefixed by the store directory (@file{/gnu/store}).
  6273. @end deffn
  6274. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  6275. Add @var{text} under file @var{name} in the store, and return its store
  6276. path. @var{references} is the list of store paths referred to by the
  6277. resulting store path.
  6278. @end deffn
  6279. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  6280. [@var{mode}]
  6281. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  6282. file names, or derivation/output pairs, using the specified
  6283. @var{mode}---@code{(build-mode normal)} by default.
  6284. @end deffn
  6285. Note that the @code{(guix monads)} module provides a monad as well as
  6286. monadic versions of the above procedures, with the goal of making it
  6287. more convenient to work with code that accesses the store (@pxref{The
  6288. Store Monad}).
  6289. @c FIXME
  6290. @i{This section is currently incomplete.}
  6291. @node Derivations
  6292. @section Derivations
  6293. @cindex derivations
  6294. Low-level build actions and the environment in which they are performed
  6295. are represented by @dfn{derivations}. A derivation contains the
  6296. following pieces of information:
  6297. @itemize
  6298. @item
  6299. The outputs of the derivation---derivations produce at least one file or
  6300. directory in the store, but may produce more.
  6301. @item
  6302. @cindex build-time dependencies
  6303. @cindex dependencies, build-time
  6304. The inputs of the derivations---i.e., its build-time dependencies---which may
  6305. be other derivations or plain files in the store (patches, build scripts,
  6306. etc.).
  6307. @item
  6308. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  6309. @item
  6310. The file name of a build script in the store, along with the arguments
  6311. to be passed.
  6312. @item
  6313. A list of environment variables to be defined.
  6314. @end itemize
  6315. @cindex derivation path
  6316. Derivations allow clients of the daemon to communicate build actions to
  6317. the store. They exist in two forms: as an in-memory representation,
  6318. both on the client- and daemon-side, and as files in the store whose
  6319. name end in @file{.drv}---these files are referred to as @dfn{derivation
  6320. paths}. Derivations paths can be passed to the @code{build-derivations}
  6321. procedure to perform the build actions they prescribe (@pxref{The
  6322. Store}).
  6323. @cindex fixed-output derivations
  6324. Operations such as file downloads and version-control checkouts for
  6325. which the expected content hash is known in advance are modeled as
  6326. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  6327. of a fixed-output derivation are independent of its inputs---e.g., a
  6328. source code download produces the same result regardless of the download
  6329. method and tools being used.
  6330. @cindex references
  6331. @cindex run-time dependencies
  6332. @cindex dependencies, run-time
  6333. The outputs of derivations---i.e., the build results---have a set of
  6334. @dfn{references}, as reported by the @code{references} RPC or the
  6335. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  6336. are the set of run-time dependencies of the build results. References are a
  6337. subset of the inputs of the derivation; this subset is automatically computed
  6338. by the build daemon by scanning all the files in the outputs.
  6339. The @code{(guix derivations)} module provides a representation of
  6340. derivations as Scheme objects, along with procedures to create and
  6341. otherwise manipulate derivations. The lowest-level primitive to create
  6342. a derivation is the @code{derivation} procedure:
  6343. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  6344. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  6345. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  6346. [#:system (%current-system)] [#:references-graphs #f] @
  6347. [#:allowed-references #f] [#:disallowed-references #f] @
  6348. [#:leaked-env-vars #f] [#:local-build? #f] @
  6349. [#:substitutable? #t] [#:properties '()]
  6350. Build a derivation with the given arguments, and return the resulting
  6351. @code{<derivation>} object.
  6352. When @var{hash} and @var{hash-algo} are given, a
  6353. @dfn{fixed-output derivation} is created---i.e., one whose result is
  6354. known in advance, such as a file download. If, in addition,
  6355. @var{recursive?} is true, then that fixed output may be an executable
  6356. file or a directory and @var{hash} must be the hash of an archive
  6357. containing this output.
  6358. When @var{references-graphs} is true, it must be a list of file
  6359. name/store path pairs. In that case, the reference graph of each store
  6360. path is exported in the build environment in the corresponding file, in
  6361. a simple text format.
  6362. When @var{allowed-references} is true, it must be a list of store items
  6363. or outputs that the derivation's output may refer to. Likewise,
  6364. @var{disallowed-references}, if true, must be a list of things the
  6365. outputs may @emph{not} refer to.
  6366. When @var{leaked-env-vars} is true, it must be a list of strings
  6367. denoting environment variables that are allowed to ``leak'' from the
  6368. daemon's environment to the build environment. This is only applicable
  6369. to fixed-output derivations---i.e., when @var{hash} is true. The main
  6370. use is to allow variables such as @code{http_proxy} to be passed to
  6371. derivations that download files.
  6372. When @var{local-build?} is true, declare that the derivation is not a
  6373. good candidate for offloading and should rather be built locally
  6374. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  6375. where the costs of data transfers would outweigh the benefits.
  6376. When @var{substitutable?} is false, declare that substitutes of the
  6377. derivation's output should not be used (@pxref{Substitutes}). This is
  6378. useful, for instance, when building packages that capture details of the
  6379. host CPU instruction set.
  6380. @var{properties} must be an association list describing ``properties'' of the
  6381. derivation. It is kept as-is, uninterpreted, in the derivation.
  6382. @end deffn
  6383. @noindent
  6384. Here's an example with a shell script as its builder, assuming
  6385. @var{store} is an open connection to the daemon, and @var{bash} points
  6386. to a Bash executable in the store:
  6387. @lisp
  6388. (use-modules (guix utils)
  6389. (guix store)
  6390. (guix derivations))
  6391. (let ((builder ; add the Bash script to the store
  6392. (add-text-to-store store "my-builder.sh"
  6393. "echo hello world > $out\n" '())))
  6394. (derivation store "foo"
  6395. bash `("-e" ,builder)
  6396. #:inputs `((,bash) (,builder))
  6397. #:env-vars '(("HOME" . "/homeless"))))
  6398. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  6399. @end lisp
  6400. As can be guessed, this primitive is cumbersome to use directly. A
  6401. better approach is to write build scripts in Scheme, of course! The
  6402. best course of action for that is to write the build code as a
  6403. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  6404. information, @pxref{G-Expressions}.
  6405. Once upon a time, @code{gexp->derivation} did not exist and constructing
  6406. derivations with build code written in Scheme was achieved with
  6407. @code{build-expression->derivation}, documented below. This procedure
  6408. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  6409. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  6410. @var{name} @var{exp} @
  6411. [#:system (%current-system)] [#:inputs '()] @
  6412. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  6413. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  6414. [#:references-graphs #f] [#:allowed-references #f] @
  6415. [#:disallowed-references #f] @
  6416. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  6417. Return a derivation that executes Scheme expression @var{exp} as a
  6418. builder for derivation @var{name}. @var{inputs} must be a list of
  6419. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  6420. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  6421. modules from the current search path to be copied in the store,
  6422. compiled, and made available in the load path during the execution of
  6423. @var{exp}---e.g., @code{((guix build utils) (guix build
  6424. gnu-build-system))}.
  6425. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  6426. to a list of output/path pairs, and where @code{%build-inputs} is bound
  6427. to a list of string/output-path pairs made from @var{inputs}.
  6428. Optionally, @var{env-vars} is a list of string pairs specifying the name
  6429. and value of environment variables visible to the builder. The builder
  6430. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  6431. @var{exp} returns @code{#f}, the build is considered to have failed.
  6432. @var{exp} is built using @var{guile-for-build} (a derivation). When
  6433. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  6434. @code{%guile-for-build} fluid is used instead.
  6435. See the @code{derivation} procedure for the meaning of
  6436. @var{references-graphs}, @var{allowed-references},
  6437. @var{disallowed-references}, @var{local-build?}, and
  6438. @var{substitutable?}.
  6439. @end deffn
  6440. @noindent
  6441. Here's an example of a single-output derivation that creates a directory
  6442. containing one file:
  6443. @lisp
  6444. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  6445. (mkdir out) ; create /gnu/store/@dots{}-goo
  6446. (call-with-output-file (string-append out "/test")
  6447. (lambda (p)
  6448. (display '(hello guix) p))))))
  6449. (build-expression->derivation store "goo" builder))
  6450. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  6451. @end lisp
  6452. @node The Store Monad
  6453. @section The Store Monad
  6454. @cindex monad
  6455. The procedures that operate on the store described in the previous
  6456. sections all take an open connection to the build daemon as their first
  6457. argument. Although the underlying model is functional, they either have
  6458. side effects or depend on the current state of the store.
  6459. The former is inconvenient: the connection to the build daemon has to be
  6460. carried around in all those functions, making it impossible to compose
  6461. functions that do not take that parameter with functions that do. The
  6462. latter can be problematic: since store operations have side effects
  6463. and/or depend on external state, they have to be properly sequenced.
  6464. @cindex monadic values
  6465. @cindex monadic functions
  6466. This is where the @code{(guix monads)} module comes in. This module
  6467. provides a framework for working with @dfn{monads}, and a particularly
  6468. useful monad for our uses, the @dfn{store monad}. Monads are a
  6469. construct that allows two things: associating ``context'' with values
  6470. (in our case, the context is the store), and building sequences of
  6471. computations (here computations include accesses to the store). Values
  6472. in a monad---values that carry this additional context---are called
  6473. @dfn{monadic values}; procedures that return such values are called
  6474. @dfn{monadic procedures}.
  6475. Consider this ``normal'' procedure:
  6476. @lisp
  6477. (define (sh-symlink store)
  6478. ;; Return a derivation that symlinks the 'bash' executable.
  6479. (let* ((drv (package-derivation store bash))
  6480. (out (derivation->output-path drv))
  6481. (sh (string-append out "/bin/bash")))
  6482. (build-expression->derivation store "sh"
  6483. `(symlink ,sh %output))))
  6484. @end lisp
  6485. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  6486. as a monadic function:
  6487. @lisp
  6488. (define (sh-symlink)
  6489. ;; Same, but return a monadic value.
  6490. (mlet %store-monad ((drv (package->derivation bash)))
  6491. (gexp->derivation "sh"
  6492. #~(symlink (string-append #$drv "/bin/bash")
  6493. #$output))))
  6494. @end lisp
  6495. There are several things to note in the second version: the @code{store}
  6496. parameter is now implicit and is ``threaded'' in the calls to the
  6497. @code{package->derivation} and @code{gexp->derivation} monadic
  6498. procedures, and the monadic value returned by @code{package->derivation}
  6499. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  6500. As it turns out, the call to @code{package->derivation} can even be
  6501. omitted since it will take place implicitly, as we will see later
  6502. (@pxref{G-Expressions}):
  6503. @lisp
  6504. (define (sh-symlink)
  6505. (gexp->derivation "sh"
  6506. #~(symlink (string-append #$bash "/bin/bash")
  6507. #$output)))
  6508. @end lisp
  6509. @c See
  6510. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  6511. @c for the funny quote.
  6512. Calling the monadic @code{sh-symlink} has no effect. As someone once
  6513. said, ``you exit a monad like you exit a building on fire: by running''.
  6514. So, to exit the monad and get the desired effect, one must use
  6515. @code{run-with-store}:
  6516. @lisp
  6517. (run-with-store (open-connection) (sh-symlink))
  6518. @result{} /gnu/store/...-sh-symlink
  6519. @end lisp
  6520. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  6521. new ``meta-commands'' to make it easier to deal with monadic procedures:
  6522. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  6523. to ``run'' a single monadic value through the store:
  6524. @example
  6525. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  6526. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  6527. @end example
  6528. The latter enters a recursive REPL, where all the return values are
  6529. automatically run through the store:
  6530. @example
  6531. scheme@@(guile-user)> ,enter-store-monad
  6532. store-monad@@(guile-user) [1]> (package->derivation hello)
  6533. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  6534. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  6535. $3 = "/gnu/store/@dots{}-foo"
  6536. store-monad@@(guile-user) [1]> ,q
  6537. scheme@@(guile-user)>
  6538. @end example
  6539. @noindent
  6540. Note that non-monadic values cannot be returned in the
  6541. @code{store-monad} REPL.
  6542. The main syntactic forms to deal with monads in general are provided by
  6543. the @code{(guix monads)} module and are described below.
  6544. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  6545. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  6546. in @var{monad}.
  6547. @end deffn
  6548. @deffn {Scheme Syntax} return @var{val}
  6549. Return a monadic value that encapsulates @var{val}.
  6550. @end deffn
  6551. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  6552. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  6553. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  6554. referred to as ``bind'', but that name denotes an unrelated procedure in
  6555. Guile. Thus we use this somewhat cryptic symbol inherited from the
  6556. Haskell language.}. There can be one @var{mproc} or several of them, as
  6557. in this example:
  6558. @lisp
  6559. (run-with-state
  6560. (with-monad %state-monad
  6561. (>>= (return 1)
  6562. (lambda (x) (return (+ 1 x)))
  6563. (lambda (x) (return (* 2 x)))))
  6564. 'some-state)
  6565. @result{} 4
  6566. @result{} some-state
  6567. @end lisp
  6568. @end deffn
  6569. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  6570. @var{body} ...
  6571. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  6572. @var{body} ...
  6573. Bind the variables @var{var} to the monadic values @var{mval} in
  6574. @var{body}, which is a sequence of expressions. As with the bind
  6575. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  6576. value ``contained'' in @var{mval} and making @var{var} refer to that
  6577. raw, non-monadic value within the scope of the @var{body}. The form
  6578. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  6579. @var{val}, as per @code{let}. The binding operations occur in sequence
  6580. from left to right. The last expression of @var{body} must be a monadic
  6581. expression, and its result will become the result of the @code{mlet} or
  6582. @code{mlet*} when run in the @var{monad}.
  6583. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  6584. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  6585. @end deffn
  6586. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  6587. Bind @var{mexp} and the following monadic expressions in sequence,
  6588. returning the result of the last expression. Every expression in the
  6589. sequence must be a monadic expression.
  6590. This is akin to @code{mlet}, except that the return values of the
  6591. monadic expressions are ignored. In that sense, it is analogous to
  6592. @code{begin}, but applied to monadic expressions.
  6593. @end deffn
  6594. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  6595. When @var{condition} is true, evaluate the sequence of monadic
  6596. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  6597. @var{condition} is false, return @code{*unspecified*} in the current
  6598. monad. Every expression in the sequence must be a monadic expression.
  6599. @end deffn
  6600. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  6601. When @var{condition} is false, evaluate the sequence of monadic
  6602. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  6603. @var{condition} is true, return @code{*unspecified*} in the current
  6604. monad. Every expression in the sequence must be a monadic expression.
  6605. @end deffn
  6606. @cindex state monad
  6607. The @code{(guix monads)} module provides the @dfn{state monad}, which
  6608. allows an additional value---the state---to be @emph{threaded} through
  6609. monadic procedure calls.
  6610. @defvr {Scheme Variable} %state-monad
  6611. The state monad. Procedures in the state monad can access and change
  6612. the state that is threaded.
  6613. Consider the example below. The @code{square} procedure returns a value
  6614. in the state monad. It returns the square of its argument, but also
  6615. increments the current state value:
  6616. @lisp
  6617. (define (square x)
  6618. (mlet %state-monad ((count (current-state)))
  6619. (mbegin %state-monad
  6620. (set-current-state (+ 1 count))
  6621. (return (* x x)))))
  6622. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  6623. @result{} (0 1 4)
  6624. @result{} 3
  6625. @end lisp
  6626. When ``run'' through @code{%state-monad}, we obtain that additional state
  6627. value, which is the number of @code{square} calls.
  6628. @end defvr
  6629. @deffn {Monadic Procedure} current-state
  6630. Return the current state as a monadic value.
  6631. @end deffn
  6632. @deffn {Monadic Procedure} set-current-state @var{value}
  6633. Set the current state to @var{value} and return the previous state as a
  6634. monadic value.
  6635. @end deffn
  6636. @deffn {Monadic Procedure} state-push @var{value}
  6637. Push @var{value} to the current state, which is assumed to be a list,
  6638. and return the previous state as a monadic value.
  6639. @end deffn
  6640. @deffn {Monadic Procedure} state-pop
  6641. Pop a value from the current state and return it as a monadic value.
  6642. The state is assumed to be a list.
  6643. @end deffn
  6644. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  6645. Run monadic value @var{mval} starting with @var{state} as the initial
  6646. state. Return two values: the resulting value, and the resulting state.
  6647. @end deffn
  6648. The main interface to the store monad, provided by the @code{(guix
  6649. store)} module, is as follows.
  6650. @defvr {Scheme Variable} %store-monad
  6651. The store monad---an alias for @code{%state-monad}.
  6652. Values in the store monad encapsulate accesses to the store. When its
  6653. effect is needed, a value of the store monad must be ``evaluated'' by
  6654. passing it to the @code{run-with-store} procedure (see below).
  6655. @end defvr
  6656. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  6657. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  6658. open store connection.
  6659. @end deffn
  6660. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  6661. Return as a monadic value the absolute file name in the store of the file
  6662. containing @var{text}, a string. @var{references} is a list of store items that the
  6663. resulting text file refers to; it defaults to the empty list.
  6664. @end deffn
  6665. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  6666. Return as a monadic value the absolute file name in the store of the file
  6667. containing @var{data}, a bytevector. @var{references} is a list of store
  6668. items that the resulting binary file refers to; it defaults to the empty list.
  6669. @end deffn
  6670. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  6671. [#:recursive? #t] [#:select? (const #t)]
  6672. Return the name of @var{file} once interned in the store. Use
  6673. @var{name} as its store name, or the basename of @var{file} if
  6674. @var{name} is omitted.
  6675. When @var{recursive?} is true, the contents of @var{file} are added
  6676. recursively; if @var{file} designates a flat file and @var{recursive?}
  6677. is true, its contents are added, and its permission bits are kept.
  6678. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  6679. @var{stat})} for each directory entry, where @var{file} is the entry's
  6680. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  6681. entries for which @var{select?} does not return true.
  6682. The example below adds a file to the store, under two different names:
  6683. @lisp
  6684. (run-with-store (open-connection)
  6685. (mlet %store-monad ((a (interned-file "README"))
  6686. (b (interned-file "README" "LEGU-MIN")))
  6687. (return (list a b))))
  6688. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  6689. @end lisp
  6690. @end deffn
  6691. The @code{(guix packages)} module exports the following package-related
  6692. monadic procedures:
  6693. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  6694. [#:system (%current-system)] [#:target #f] @
  6695. [#:output "out"]
  6696. Return as a monadic
  6697. value in the absolute file name of @var{file} within the @var{output}
  6698. directory of @var{package}. When @var{file} is omitted, return the name
  6699. of the @var{output} directory of @var{package}. When @var{target} is
  6700. true, use it as a cross-compilation target triplet.
  6701. Note that this procedure does @emph{not} build @var{package}. Thus, the
  6702. result might or might not designate an existing file. We recommend not
  6703. using this procedure unless you know what you are doing.
  6704. @end deffn
  6705. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  6706. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  6707. @var{target} [@var{system}]
  6708. Monadic version of @code{package-derivation} and
  6709. @code{package-cross-derivation} (@pxref{Defining Packages}).
  6710. @end deffn
  6711. @node G-Expressions
  6712. @section G-Expressions
  6713. @cindex G-expression
  6714. @cindex build code quoting
  6715. So we have ``derivations'', which represent a sequence of build actions
  6716. to be performed to produce an item in the store (@pxref{Derivations}).
  6717. These build actions are performed when asking the daemon to actually
  6718. build the derivations; they are run by the daemon in a container
  6719. (@pxref{Invoking guix-daemon}).
  6720. @cindex strata of code
  6721. It should come as no surprise that we like to write these build actions
  6722. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  6723. code@footnote{The term @dfn{stratum} in this context was coined by
  6724. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  6725. Kiselyov, who has written insightful
  6726. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  6727. on this topic}, refers to this kind of code generation as
  6728. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  6729. to the daemon, etc.---and the ``build code''---code that actually
  6730. performs build actions, such as making directories, invoking
  6731. @command{make}, etc.
  6732. To describe a derivation and its build actions, one typically needs to
  6733. embed build code inside host code. It boils down to manipulating build
  6734. code as data, and the homoiconicity of Scheme---code has a direct
  6735. representation as data---comes in handy for that. But we need more than
  6736. the normal @code{quasiquote} mechanism in Scheme to construct build
  6737. expressions.
  6738. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  6739. S-expressions adapted to build expressions. G-expressions, or
  6740. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  6741. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  6742. @code{#$}, and @code{#$@@}), which are comparable to
  6743. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  6744. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  6745. GNU Guile Reference Manual}). However, there are major differences:
  6746. @itemize
  6747. @item
  6748. Gexps are meant to be written to a file and run or manipulated by other
  6749. processes.
  6750. @item
  6751. When a high-level object such as a package or derivation is unquoted
  6752. inside a gexp, the result is as if its output file name had been
  6753. introduced.
  6754. @item
  6755. Gexps carry information about the packages or derivations they refer to,
  6756. and these dependencies are automatically added as inputs to the build
  6757. processes that use them.
  6758. @end itemize
  6759. @cindex lowering, of high-level objects in gexps
  6760. This mechanism is not limited to package and derivation
  6761. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  6762. derivations or files in the store can be defined,
  6763. such that these objects can also be inserted
  6764. into gexps. For example, a useful type of high-level objects that can be
  6765. inserted in a gexp is ``file-like objects'', which make it easy to
  6766. add files to the store and to refer to them in
  6767. derivations and such (see @code{local-file} and @code{plain-file}
  6768. below).
  6769. To illustrate the idea, here is an example of a gexp:
  6770. @lisp
  6771. (define build-exp
  6772. #~(begin
  6773. (mkdir #$output)
  6774. (chdir #$output)
  6775. (symlink (string-append #$coreutils "/bin/ls")
  6776. "list-files")))
  6777. @end lisp
  6778. This gexp can be passed to @code{gexp->derivation}; we obtain a
  6779. derivation that builds a directory containing exactly one symlink to
  6780. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  6781. @lisp
  6782. (gexp->derivation "the-thing" build-exp)
  6783. @end lisp
  6784. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  6785. substituted to the reference to the @var{coreutils} package in the
  6786. actual build code, and @var{coreutils} is automatically made an input to
  6787. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  6788. output)}) is replaced by a string containing the directory name of the
  6789. output of the derivation.
  6790. @cindex cross compilation
  6791. In a cross-compilation context, it is useful to distinguish between
  6792. references to the @emph{native} build of a package---that can run on the
  6793. host---versus references to cross builds of a package. To that end, the
  6794. @code{#+} plays the same role as @code{#$}, but is a reference to a
  6795. native package build:
  6796. @lisp
  6797. (gexp->derivation "vi"
  6798. #~(begin
  6799. (mkdir #$output)
  6800. (mkdir (string-append #$output "/bin"))
  6801. (system* (string-append #+coreutils "/bin/ln")
  6802. "-s"
  6803. (string-append #$emacs "/bin/emacs")
  6804. (string-append #$output "/bin/vi")))
  6805. #:target "aarch64-linux-gnu")
  6806. @end lisp
  6807. @noindent
  6808. In the example above, the native build of @var{coreutils} is used, so
  6809. that @command{ln} can actually run on the host; but then the
  6810. cross-compiled build of @var{emacs} is referenced.
  6811. @cindex imported modules, for gexps
  6812. @findex with-imported-modules
  6813. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  6814. able to use certain Guile modules from the ``host environment'' in the
  6815. gexp, so those modules should be imported in the ``build environment''.
  6816. The @code{with-imported-modules} form allows you to express that:
  6817. @lisp
  6818. (let ((build (with-imported-modules '((guix build utils))
  6819. #~(begin
  6820. (use-modules (guix build utils))
  6821. (mkdir-p (string-append #$output "/bin"))))))
  6822. (gexp->derivation "empty-dir"
  6823. #~(begin
  6824. #$build
  6825. (display "success!\n")
  6826. #t)))
  6827. @end lisp
  6828. @noindent
  6829. In this example, the @code{(guix build utils)} module is automatically
  6830. pulled into the isolated build environment of our gexp, such that
  6831. @code{(use-modules (guix build utils))} works as expected.
  6832. @cindex module closure
  6833. @findex source-module-closure
  6834. Usually you want the @emph{closure} of the module to be imported---i.e.,
  6835. the module itself and all the modules it depends on---rather than just
  6836. the module; failing to do that, attempts to use the module will fail
  6837. because of missing dependent modules. The @code{source-module-closure}
  6838. procedure computes the closure of a module by looking at its source file
  6839. headers, which comes in handy in this case:
  6840. @lisp
  6841. (use-modules (guix modules)) ;for 'source-module-closure'
  6842. (with-imported-modules (source-module-closure
  6843. '((guix build utils)
  6844. (gnu build vm)))
  6845. (gexp->derivation "something-with-vms"
  6846. #~(begin
  6847. (use-modules (guix build utils)
  6848. (gnu build vm))
  6849. @dots{})))
  6850. @end lisp
  6851. @cindex extensions, for gexps
  6852. @findex with-extensions
  6853. In the same vein, sometimes you want to import not just pure-Scheme
  6854. modules, but also ``extensions'' such as Guile bindings to C libraries
  6855. or other ``full-blown'' packages. Say you need the @code{guile-json}
  6856. package available on the build side, here's how you would do it:
  6857. @lisp
  6858. (use-modules (gnu packages guile)) ;for 'guile-json'
  6859. (with-extensions (list guile-json)
  6860. (gexp->derivation "something-with-json"
  6861. #~(begin
  6862. (use-modules (json))
  6863. @dots{})))
  6864. @end lisp
  6865. The syntactic form to construct gexps is summarized below.
  6866. @deffn {Scheme Syntax} #~@var{exp}
  6867. @deffnx {Scheme Syntax} (gexp @var{exp})
  6868. Return a G-expression containing @var{exp}. @var{exp} may contain one
  6869. or more of the following forms:
  6870. @table @code
  6871. @item #$@var{obj}
  6872. @itemx (ungexp @var{obj})
  6873. Introduce a reference to @var{obj}. @var{obj} may have one of the
  6874. supported types, for example a package or a
  6875. derivation, in which case the @code{ungexp} form is replaced by its
  6876. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  6877. If @var{obj} is a list, it is traversed and references to supported
  6878. objects are substituted similarly.
  6879. If @var{obj} is another gexp, its contents are inserted and its
  6880. dependencies are added to those of the containing gexp.
  6881. If @var{obj} is another kind of object, it is inserted as is.
  6882. @item #$@var{obj}:@var{output}
  6883. @itemx (ungexp @var{obj} @var{output})
  6884. This is like the form above, but referring explicitly to the
  6885. @var{output} of @var{obj}---this is useful when @var{obj} produces
  6886. multiple outputs (@pxref{Packages with Multiple Outputs}).
  6887. @item #+@var{obj}
  6888. @itemx #+@var{obj}:output
  6889. @itemx (ungexp-native @var{obj})
  6890. @itemx (ungexp-native @var{obj} @var{output})
  6891. Same as @code{ungexp}, but produces a reference to the @emph{native}
  6892. build of @var{obj} when used in a cross compilation context.
  6893. @item #$output[:@var{output}]
  6894. @itemx (ungexp output [@var{output}])
  6895. Insert a reference to derivation output @var{output}, or to the main
  6896. output when @var{output} is omitted.
  6897. This only makes sense for gexps passed to @code{gexp->derivation}.
  6898. @item #$@@@var{lst}
  6899. @itemx (ungexp-splicing @var{lst})
  6900. Like the above, but splices the contents of @var{lst} inside the
  6901. containing list.
  6902. @item #+@@@var{lst}
  6903. @itemx (ungexp-native-splicing @var{lst})
  6904. Like the above, but refers to native builds of the objects listed in
  6905. @var{lst}.
  6906. @end table
  6907. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  6908. of the @code{gexp?} type (see below).
  6909. @end deffn
  6910. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  6911. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  6912. in their execution environment.
  6913. Each item in @var{modules} can be the name of a module, such as
  6914. @code{(guix build utils)}, or it can be a module name, followed by an
  6915. arrow, followed by a file-like object:
  6916. @lisp
  6917. `((guix build utils)
  6918. (guix gcrypt)
  6919. ((guix config) => ,(scheme-file "config.scm"
  6920. #~(define-module @dots{}))))
  6921. @end lisp
  6922. @noindent
  6923. In the example above, the first two modules are taken from the search
  6924. path, and the last one is created from the given file-like object.
  6925. This form has @emph{lexical} scope: it has an effect on the gexps
  6926. directly defined in @var{body}@dots{}, but not on those defined, say, in
  6927. procedures called from @var{body}@dots{}.
  6928. @end deffn
  6929. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  6930. Mark the gexps defined in @var{body}@dots{} as requiring
  6931. @var{extensions} in their build and execution environment.
  6932. @var{extensions} is typically a list of package objects such as those
  6933. defined in the @code{(gnu packages guile)} module.
  6934. Concretely, the packages listed in @var{extensions} are added to the
  6935. load path while compiling imported modules in @var{body}@dots{}; they
  6936. are also added to the load path of the gexp returned by
  6937. @var{body}@dots{}.
  6938. @end deffn
  6939. @deffn {Scheme Procedure} gexp? @var{obj}
  6940. Return @code{#t} if @var{obj} is a G-expression.
  6941. @end deffn
  6942. G-expressions are meant to be written to disk, either as code building
  6943. some derivation, or as plain files in the store. The monadic procedures
  6944. below allow you to do that (@pxref{The Store Monad}, for more
  6945. information about monads).
  6946. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  6947. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  6948. [#:hash #f] [#:hash-algo #f] @
  6949. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  6950. [#:module-path @code{%load-path}] @
  6951. [#:effective-version "2.2"] @
  6952. [#:references-graphs #f] [#:allowed-references #f] @
  6953. [#:disallowed-references #f] @
  6954. [#:leaked-env-vars #f] @
  6955. [#:script-name (string-append @var{name} "-builder")] @
  6956. [#:deprecation-warnings #f] @
  6957. [#:local-build? #f] [#:substitutable? #t] @
  6958. [#:properties '()] [#:guile-for-build #f]
  6959. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  6960. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  6961. stored in a file called @var{script-name}. When @var{target} is true,
  6962. it is used as the cross-compilation target triplet for packages referred
  6963. to by @var{exp}.
  6964. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  6965. Its meaning is to
  6966. make @var{modules} available in the evaluation context of @var{exp};
  6967. @var{modules} is a list of names of Guile modules searched in
  6968. @var{module-path} to be copied in the store, compiled, and made available in
  6969. the load path during the execution of @var{exp}---e.g., @code{((guix
  6970. build utils) (guix build gnu-build-system))}.
  6971. @var{effective-version} determines the string to use when adding extensions of
  6972. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  6973. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  6974. applicable.
  6975. When @var{references-graphs} is true, it must be a list of tuples of one of the
  6976. following forms:
  6977. @example
  6978. (@var{file-name} @var{package})
  6979. (@var{file-name} @var{package} @var{output})
  6980. (@var{file-name} @var{derivation})
  6981. (@var{file-name} @var{derivation} @var{output})
  6982. (@var{file-name} @var{store-item})
  6983. @end example
  6984. The right-hand-side of each element of @var{references-graphs} is automatically made
  6985. an input of the build process of @var{exp}. In the build environment, each
  6986. @var{file-name} contains the reference graph of the corresponding item, in a simple
  6987. text format.
  6988. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  6989. In the latter case, the list denotes store items that the result is allowed to
  6990. refer to. Any reference to another store item will lead to a build error.
  6991. Similarly for @var{disallowed-references}, which can list items that must not be
  6992. referenced by the outputs.
  6993. @var{deprecation-warnings} determines whether to show deprecation warnings while
  6994. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  6995. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  6996. @end deffn
  6997. @cindex file-like objects
  6998. The @code{local-file}, @code{plain-file}, @code{computed-file},
  6999. @code{program-file}, and @code{scheme-file} procedures below return
  7000. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  7001. these objects lead to a file in the store. Consider this G-expression:
  7002. @lisp
  7003. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  7004. #$(local-file "/tmp/my-nscd.conf"))
  7005. @end lisp
  7006. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  7007. to the store. Once expanded, for instance @i{via}
  7008. @code{gexp->derivation}, the G-expression refers to that copy under
  7009. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  7010. does not have any effect on what the G-expression does.
  7011. @code{plain-file} can be used similarly; it differs in that the file
  7012. content is directly passed as a string.
  7013. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  7014. [#:recursive? #f] [#:select? (const #t)]
  7015. Return an object representing local file @var{file} to add to the store;
  7016. this object can be used in a gexp. If @var{file} is a literal string
  7017. denoting a relative file name, it is looked up relative to the source
  7018. file where it appears; if @var{file} is not a literal string, it is
  7019. looked up relative to the current working directory at run time.
  7020. @var{file} will be added to the store under @var{name}--by default the
  7021. base name of @var{file}.
  7022. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  7023. designates a flat file and @var{recursive?} is true, its contents are added, and its
  7024. permission bits are kept.
  7025. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7026. @var{stat})} for each directory entry, where @var{file} is the entry's
  7027. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7028. entries for which @var{select?} does not return true.
  7029. This is the declarative counterpart of the @code{interned-file} monadic
  7030. procedure (@pxref{The Store Monad, @code{interned-file}}).
  7031. @end deffn
  7032. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  7033. Return an object representing a text file called @var{name} with the given
  7034. @var{content} (a string or a bytevector) to be added to the store.
  7035. This is the declarative counterpart of @code{text-file}.
  7036. @end deffn
  7037. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  7038. [#:local-build? #t]
  7039. [#:options '()]
  7040. Return an object representing the store item @var{name}, a file or
  7041. directory computed by @var{gexp}. When @var{local-build?} is true (the
  7042. default), the derivation is built locally. @var{options} is a list of
  7043. additional arguments to pass to @code{gexp->derivation}.
  7044. This is the declarative counterpart of @code{gexp->derivation}.
  7045. @end deffn
  7046. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  7047. [#:guile (default-guile)] [#:module-path %load-path] @
  7048. [#:system (%current-system)] [#:target #f]
  7049. Return an executable script @var{name} that runs @var{exp} using
  7050. @var{guile}, with @var{exp}'s imported modules in its search path.
  7051. Look up @var{exp}'s modules in @var{module-path}.
  7052. The example below builds a script that simply invokes the @command{ls}
  7053. command:
  7054. @lisp
  7055. (use-modules (guix gexp) (gnu packages base))
  7056. (gexp->script "list-files"
  7057. #~(execl #$(file-append coreutils "/bin/ls")
  7058. "ls"))
  7059. @end lisp
  7060. When ``running'' it through the store (@pxref{The Store Monad,
  7061. @code{run-with-store}}), we obtain a derivation that produces an
  7062. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  7063. @example
  7064. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  7065. !#
  7066. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  7067. @end example
  7068. @end deffn
  7069. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  7070. [#:guile #f] [#:module-path %load-path]
  7071. Return an object representing the executable store item @var{name} that
  7072. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  7073. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  7074. This is the declarative counterpart of @code{gexp->script}.
  7075. @end deffn
  7076. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  7077. [#:set-load-path? #t] [#:module-path %load-path] @
  7078. [#:splice? #f] @
  7079. [#:guile (default-guile)]
  7080. Return a derivation that builds a file @var{name} containing @var{exp}.
  7081. When @var{splice?} is true, @var{exp} is considered to be a list of
  7082. expressions that will be spliced in the resulting file.
  7083. When @var{set-load-path?} is true, emit code in the resulting file to
  7084. set @code{%load-path} and @code{%load-compiled-path} to honor
  7085. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  7086. @var{module-path}.
  7087. The resulting file holds references to all the dependencies of @var{exp}
  7088. or a subset thereof.
  7089. @end deffn
  7090. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  7091. [#:splice? #f] [#:set-load-path? #t]
  7092. Return an object representing the Scheme file @var{name} that contains
  7093. @var{exp}.
  7094. This is the declarative counterpart of @code{gexp->file}.
  7095. @end deffn
  7096. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  7097. Return as a monadic value a derivation that builds a text file
  7098. containing all of @var{text}. @var{text} may list, in addition to
  7099. strings, objects of any type that can be used in a gexp: packages,
  7100. derivations, local file objects, etc. The resulting store file holds
  7101. references to all these.
  7102. This variant should be preferred over @code{text-file} anytime the file
  7103. to create will reference items from the store. This is typically the
  7104. case when building a configuration file that embeds store file names,
  7105. like this:
  7106. @lisp
  7107. (define (profile.sh)
  7108. ;; Return the name of a shell script in the store that
  7109. ;; initializes the 'PATH' environment variable.
  7110. (text-file* "profile.sh"
  7111. "export PATH=" coreutils "/bin:"
  7112. grep "/bin:" sed "/bin\n"))
  7113. @end lisp
  7114. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  7115. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  7116. preventing them from being garbage-collected during its lifetime.
  7117. @end deffn
  7118. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  7119. Return an object representing store file @var{name} containing
  7120. @var{text}. @var{text} is a sequence of strings and file-like objects,
  7121. as in:
  7122. @lisp
  7123. (mixed-text-file "profile"
  7124. "export PATH=" coreutils "/bin:" grep "/bin")
  7125. @end lisp
  7126. This is the declarative counterpart of @code{text-file*}.
  7127. @end deffn
  7128. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  7129. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  7130. Each item in @var{files} must be a two-element list where the first element is the
  7131. file name to use in the new directory, and the second element is a gexp
  7132. denoting the target file. Here's an example:
  7133. @lisp
  7134. (file-union "etc"
  7135. `(("hosts" ,(plain-file "hosts"
  7136. "127.0.0.1 localhost"))
  7137. ("bashrc" ,(plain-file "bashrc"
  7138. "alias ls='ls --color=auto'"))))
  7139. @end lisp
  7140. This yields an @code{etc} directory containing these two files.
  7141. @end deffn
  7142. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  7143. Return a directory that is the union of @var{things}, where @var{things} is a list of
  7144. file-like objects denoting directories. For example:
  7145. @lisp
  7146. (directory-union "guile+emacs" (list guile emacs))
  7147. @end lisp
  7148. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  7149. @end deffn
  7150. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  7151. Return a file-like object that expands to the concatenation of @var{obj}
  7152. and @var{suffix}, where @var{obj} is a lowerable object and each
  7153. @var{suffix} is a string.
  7154. As an example, consider this gexp:
  7155. @lisp
  7156. (gexp->script "run-uname"
  7157. #~(system* #$(file-append coreutils
  7158. "/bin/uname")))
  7159. @end lisp
  7160. The same effect could be achieved with:
  7161. @lisp
  7162. (gexp->script "run-uname"
  7163. #~(system* (string-append #$coreutils
  7164. "/bin/uname")))
  7165. @end lisp
  7166. There is one difference though: in the @code{file-append} case, the
  7167. resulting script contains the absolute file name as a string, whereas in
  7168. the second case, the resulting script contains a @code{(string-append
  7169. @dots{})} expression to construct the file name @emph{at run time}.
  7170. @end deffn
  7171. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  7172. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  7173. Bind @var{system} to the currently targeted system---e.g.,
  7174. @code{"x86_64-linux"}---within @var{body}.
  7175. In the second case, additionally bind @var{target} to the current
  7176. cross-compilation target---a GNU triplet such as
  7177. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  7178. cross-compiling.
  7179. @code{let-system} is useful in the occasional case where the object
  7180. spliced into the gexp depends on the target system, as in this example:
  7181. @example
  7182. #~(system*
  7183. #+(let-system system
  7184. (cond ((string-prefix? "armhf-" system)
  7185. (file-append qemu "/bin/qemu-system-arm"))
  7186. ((string-prefix? "x86_64-" system)
  7187. (file-append qemu "/bin/qemu-system-x86_64"))
  7188. (else
  7189. (error "dunno!"))))
  7190. "-net" "user" #$image)
  7191. @end example
  7192. @end deffn
  7193. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  7194. This macro is similar to the @code{parameterize} form for
  7195. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  7196. Guile Reference Manual}). The key difference is that it takes effect
  7197. when the file-like object returned by @var{exp} is lowered to a
  7198. derivation or store item.
  7199. A typical use of @code{with-parameters} is to force the system in effect
  7200. for a given object:
  7201. @lisp
  7202. (with-parameters ((%current-system "i686-linux"))
  7203. coreutils)
  7204. @end lisp
  7205. The example above returns an object that corresponds to the i686 build
  7206. of Coreutils, regardless of the current value of @code{%current-system}.
  7207. @end deffn
  7208. Of course, in addition to gexps embedded in ``host'' code, there are
  7209. also modules containing build tools. To make it clear that they are
  7210. meant to be used in the build stratum, these modules are kept in the
  7211. @code{(guix build @dots{})} name space.
  7212. @cindex lowering, of high-level objects in gexps
  7213. Internally, high-level objects are @dfn{lowered}, using their compiler,
  7214. to either derivations or store items. For instance, lowering a package
  7215. yields a derivation, and lowering a @code{plain-file} yields a store
  7216. item. This is achieved using the @code{lower-object} monadic procedure.
  7217. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  7218. [#:target #f]
  7219. Return as a value in @code{%store-monad} the derivation or store item
  7220. corresponding to @var{obj} for @var{system}, cross-compiling for
  7221. @var{target} if @var{target} is true. @var{obj} must be an object that
  7222. has an associated gexp compiler, such as a @code{<package>}.
  7223. @end deffn
  7224. @node Invoking guix repl
  7225. @section Invoking @command{guix repl}
  7226. @cindex REPL, read-eval-print loop, script
  7227. The @command{guix repl} command makes it easier to program Guix in Guile
  7228. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  7229. programming (@pxref{Using Guile Interactively,,, guile,
  7230. GNU Guile Reference Manual}), or by running Guile scripts
  7231. (@pxref{Running Guile Scripts,,, guile,
  7232. GNU Guile Reference Manual}).
  7233. Compared to just launching the @command{guile}
  7234. command, @command{guix repl} guarantees that all the Guix modules and all its
  7235. dependencies are available in the search path.
  7236. The general syntax is:
  7237. @example
  7238. guix repl @var{options} [@var{file} @var{args}]
  7239. @end example
  7240. When a @var{file} argument is provided, @var{file} is
  7241. executed as a Guile scripts:
  7242. @example
  7243. guix repl my-script.scm
  7244. @end example
  7245. To pass arguments to the script, use @code{--} to prevent them from
  7246. being interpreted as arguments to @command{guix repl} itself:
  7247. @example
  7248. guix repl -- my-script.scm --input=foo.txt
  7249. @end example
  7250. To make a script executable directly from the shell, using the guix
  7251. executable that is on the user's search path, add the following two
  7252. lines at the top of the script:
  7253. @example
  7254. @code{#!/usr/bin/env -S guix repl --}
  7255. @code{!#}
  7256. @end example
  7257. Without a file name argument, a Guile REPL is started:
  7258. @example
  7259. $ guix repl
  7260. scheme@@(guile-user)> ,use (gnu packages base)
  7261. scheme@@(guile-user)> coreutils
  7262. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  7263. @end example
  7264. @cindex inferiors
  7265. In addition, @command{guix repl} implements a simple machine-readable REPL
  7266. protocol for use by @code{(guix inferior)}, a facility to interact with
  7267. @dfn{inferiors}, separate processes running a potentially different revision
  7268. of Guix.
  7269. The available options are as follows:
  7270. @table @code
  7271. @item --type=@var{type}
  7272. @itemx -t @var{type}
  7273. Start a REPL of the given @var{TYPE}, which can be one of the following:
  7274. @table @code
  7275. @item guile
  7276. This is default, and it spawns a standard full-featured Guile REPL.
  7277. @item machine
  7278. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  7279. that the @code{(guix inferior)} module speaks.
  7280. @end table
  7281. @item --listen=@var{endpoint}
  7282. By default, @command{guix repl} reads from standard input and writes to
  7283. standard output. When this option is passed, it will instead listen for
  7284. connections on @var{endpoint}. Here are examples of valid options:
  7285. @table @code
  7286. @item --listen=tcp:37146
  7287. Accept connections on localhost on port 37146.
  7288. @item --listen=unix:/tmp/socket
  7289. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  7290. @end table
  7291. @item --load-path=@var{directory}
  7292. @itemx -L @var{directory}
  7293. Add @var{directory} to the front of the package module search path
  7294. (@pxref{Package Modules}).
  7295. This allows users to define their own packages and make them visible to
  7296. the script or REPL.
  7297. @item -q
  7298. Inhibit loading of the @file{~/.guile} file. By default, that
  7299. configuration file is loaded when spawning a @code{guile} REPL.
  7300. @end table
  7301. @c *********************************************************************
  7302. @node Utilities
  7303. @chapter Utilities
  7304. This section describes Guix command-line utilities. Some of them are
  7305. primarily targeted at developers and users who write new package
  7306. definitions, while others are more generally useful. They complement
  7307. the Scheme programming interface of Guix in a convenient way.
  7308. @menu
  7309. * Invoking guix build:: Building packages from the command line.
  7310. * Invoking guix edit:: Editing package definitions.
  7311. * Invoking guix download:: Downloading a file and printing its hash.
  7312. * Invoking guix hash:: Computing the cryptographic hash of a file.
  7313. * Invoking guix import:: Importing package definitions.
  7314. * Invoking guix refresh:: Updating package definitions.
  7315. * Invoking guix lint:: Finding errors in package definitions.
  7316. * Invoking guix size:: Profiling disk usage.
  7317. * Invoking guix graph:: Visualizing the graph of packages.
  7318. * Invoking guix publish:: Sharing substitutes.
  7319. * Invoking guix challenge:: Challenging substitute servers.
  7320. * Invoking guix copy:: Copying to and from a remote store.
  7321. * Invoking guix container:: Process isolation.
  7322. * Invoking guix weather:: Assessing substitute availability.
  7323. * Invoking guix processes:: Listing client processes.
  7324. @end menu
  7325. @node Invoking guix build
  7326. @section Invoking @command{guix build}
  7327. @cindex package building
  7328. @cindex @command{guix build}
  7329. The @command{guix build} command builds packages or derivations and
  7330. their dependencies, and prints the resulting store paths. Note that it
  7331. does not modify the user's profile---this is the job of the
  7332. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  7333. it is mainly useful for distribution developers.
  7334. The general syntax is:
  7335. @example
  7336. guix build @var{options} @var{package-or-derivation}@dots{}
  7337. @end example
  7338. As an example, the following command builds the latest versions of Emacs
  7339. and of Guile, displays their build logs, and finally displays the
  7340. resulting directories:
  7341. @example
  7342. guix build emacs guile
  7343. @end example
  7344. Similarly, the following command builds all the available packages:
  7345. @example
  7346. guix build --quiet --keep-going \
  7347. `guix package -A | cut -f1,2 --output-delimiter=@@`
  7348. @end example
  7349. @var{package-or-derivation} may be either the name of a package found in
  7350. the software distribution such as @code{coreutils} or
  7351. @code{coreutils@@8.20}, or a derivation such as
  7352. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  7353. package with the corresponding name (and optionally version) is searched
  7354. for among the GNU distribution modules (@pxref{Package Modules}).
  7355. Alternatively, the @option{--expression} option may be used to specify a
  7356. Scheme expression that evaluates to a package; this is useful when
  7357. disambiguating among several same-named packages or package variants is
  7358. needed.
  7359. There may be zero or more @var{options}. The available options are
  7360. described in the subsections below.
  7361. @menu
  7362. * Common Build Options:: Build options for most commands.
  7363. * Package Transformation Options:: Creating variants of packages.
  7364. * Additional Build Options:: Options specific to 'guix build'.
  7365. * Debugging Build Failures:: Real life packaging experience.
  7366. @end menu
  7367. @node Common Build Options
  7368. @subsection Common Build Options
  7369. A number of options that control the build process are common to
  7370. @command{guix build} and other commands that can spawn builds, such as
  7371. @command{guix package} or @command{guix archive}. These are the
  7372. following:
  7373. @table @code
  7374. @item --load-path=@var{directory}
  7375. @itemx -L @var{directory}
  7376. Add @var{directory} to the front of the package module search path
  7377. (@pxref{Package Modules}).
  7378. This allows users to define their own packages and make them visible to
  7379. the command-line tools.
  7380. @item --keep-failed
  7381. @itemx -K
  7382. Keep the build tree of failed builds. Thus, if a build fails, its build
  7383. tree is kept under @file{/tmp}, in a directory whose name is shown at
  7384. the end of the build log. This is useful when debugging build issues.
  7385. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  7386. build issues.
  7387. This option implies @option{--no-offload}, and it has no effect when
  7388. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  7389. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  7390. @item --keep-going
  7391. @itemx -k
  7392. Keep going when some of the derivations fail to build; return only once
  7393. all the builds have either completed or failed.
  7394. The default behavior is to stop as soon as one of the specified
  7395. derivations has failed.
  7396. @item --dry-run
  7397. @itemx -n
  7398. Do not build the derivations.
  7399. @anchor{fallback-option}
  7400. @item --fallback
  7401. When substituting a pre-built binary fails, fall back to building
  7402. packages locally (@pxref{Substitution Failure}).
  7403. @item --substitute-urls=@var{urls}
  7404. @anchor{client-substitute-urls}
  7405. Consider @var{urls} the whitespace-separated list of substitute source
  7406. URLs, overriding the default list of URLs of @command{guix-daemon}
  7407. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  7408. This means that substitutes may be downloaded from @var{urls}, provided
  7409. they are signed by a key authorized by the system administrator
  7410. (@pxref{Substitutes}).
  7411. When @var{urls} is the empty string, substitutes are effectively
  7412. disabled.
  7413. @item --no-substitutes
  7414. Do not use substitutes for build products. That is, always build things
  7415. locally instead of allowing downloads of pre-built binaries
  7416. (@pxref{Substitutes}).
  7417. @item --no-grafts
  7418. Do not ``graft'' packages. In practice, this means that package updates
  7419. available as grafts are not applied. @xref{Security Updates}, for more
  7420. information on grafts.
  7421. @item --rounds=@var{n}
  7422. Build each derivation @var{n} times in a row, and raise an error if
  7423. consecutive build results are not bit-for-bit identical.
  7424. This is a useful way to detect non-deterministic builds processes.
  7425. Non-deterministic build processes are a problem because they make it
  7426. practically impossible for users to @emph{verify} whether third-party
  7427. binaries are genuine. @xref{Invoking guix challenge}, for more.
  7428. When used in conjunction with @option{--keep-failed}, the differing
  7429. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  7430. This makes it easy to look for differences between the two results.
  7431. @item --no-offload
  7432. Do not use offload builds to other machines (@pxref{Daemon Offload
  7433. Setup}). That is, always build things locally instead of offloading
  7434. builds to remote machines.
  7435. @item --max-silent-time=@var{seconds}
  7436. When the build or substitution process remains silent for more than
  7437. @var{seconds}, terminate it and report a build failure.
  7438. By default, the daemon's setting is honored (@pxref{Invoking
  7439. guix-daemon, @option{--max-silent-time}}).
  7440. @item --timeout=@var{seconds}
  7441. Likewise, when the build or substitution process lasts for more than
  7442. @var{seconds}, terminate it and report a build failure.
  7443. By default, the daemon's setting is honored (@pxref{Invoking
  7444. guix-daemon, @option{--timeout}}).
  7445. @c Note: This option is actually not part of %standard-build-options but
  7446. @c most programs honor it.
  7447. @cindex verbosity, of the command-line tools
  7448. @cindex build logs, verbosity
  7449. @item -v @var{level}
  7450. @itemx --verbosity=@var{level}
  7451. Use the given verbosity @var{level}, an integer. Choosing 0 means that no
  7452. output is produced, 1 is for quiet output, and 2 shows all the build log
  7453. output on standard error.
  7454. @item --cores=@var{n}
  7455. @itemx -c @var{n}
  7456. Allow the use of up to @var{n} CPU cores for the build. The special
  7457. value @code{0} means to use as many CPU cores as available.
  7458. @item --max-jobs=@var{n}
  7459. @itemx -M @var{n}
  7460. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  7461. guix-daemon, @option{--max-jobs}}, for details about this option and the
  7462. equivalent @command{guix-daemon} option.
  7463. @item --debug=@var{level}
  7464. Produce debugging output coming from the build daemon. @var{level} must be an
  7465. integer between 0 and 5; higher means more verbose output. Setting a level of
  7466. 4 or more may be helpful when debugging setup issues with the build daemon.
  7467. @end table
  7468. Behind the scenes, @command{guix build} is essentially an interface to
  7469. the @code{package-derivation} procedure of the @code{(guix packages)}
  7470. module, and to the @code{build-derivations} procedure of the @code{(guix
  7471. derivations)} module.
  7472. In addition to options explicitly passed on the command line,
  7473. @command{guix build} and other @command{guix} commands that support
  7474. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  7475. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  7476. Users can define this variable to a list of command line options that
  7477. will automatically be used by @command{guix build} and other
  7478. @command{guix} commands that can perform builds, as in the example
  7479. below:
  7480. @example
  7481. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  7482. @end example
  7483. These options are parsed independently, and the result is appended to
  7484. the parsed command-line options.
  7485. @end defvr
  7486. @node Package Transformation Options
  7487. @subsection Package Transformation Options
  7488. @cindex package variants
  7489. Another set of command-line options supported by @command{guix build}
  7490. and also @command{guix package} are @dfn{package transformation
  7491. options}. These are options that make it possible to define @dfn{package
  7492. variants}---for instance, packages built from different source code.
  7493. This is a convenient way to create customized packages on the fly
  7494. without having to type in the definitions of package variants
  7495. (@pxref{Defining Packages}).
  7496. Package transformation options are preserved across upgrades:
  7497. @command{guix upgrade} attempts to apply transformation options
  7498. initially used when creating the profile to the upgraded packages.
  7499. @table @code
  7500. @item --with-source=@var{source}
  7501. @itemx --with-source=@var{package}=@var{source}
  7502. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  7503. Use @var{source} as the source of @var{package}, and @var{version} as
  7504. its version number.
  7505. @var{source} must be a file name or a URL, as for @command{guix
  7506. download} (@pxref{Invoking guix download}).
  7507. When @var{package} is omitted,
  7508. it is taken to be the package name specified on the
  7509. command line that matches the base of @var{source}---e.g.,
  7510. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  7511. package is @code{guile}.
  7512. Likewise, when @var{version} is omitted, the version string is inferred from
  7513. @var{source}; in the previous example, it is @code{2.0.10}.
  7514. This option allows users to try out versions of packages other than the
  7515. one provided by the distribution. The example below downloads
  7516. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  7517. the @code{ed} package:
  7518. @example
  7519. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  7520. @end example
  7521. As a developer, @option{--with-source} makes it easy to test release
  7522. candidates:
  7523. @example
  7524. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  7525. @end example
  7526. @dots{} or to build from a checkout in a pristine environment:
  7527. @example
  7528. $ git clone git://git.sv.gnu.org/guix.git
  7529. $ guix build guix --with-source=guix@@1.0=./guix
  7530. @end example
  7531. @item --with-input=@var{package}=@var{replacement}
  7532. Replace dependency on @var{package} by a dependency on
  7533. @var{replacement}. @var{package} must be a package name, and
  7534. @var{replacement} must be a package specification such as @code{guile}
  7535. or @code{guile@@1.8}.
  7536. For instance, the following command builds Guix, but replaces its
  7537. dependency on the current stable version of Guile with a dependency on
  7538. the legacy version of Guile, @code{guile@@2.0}:
  7539. @example
  7540. guix build --with-input=guile=guile@@2.0 guix
  7541. @end example
  7542. This is a recursive, deep replacement. So in this example, both
  7543. @code{guix} and its dependency @code{guile-json} (which also depends on
  7544. @code{guile}) get rebuilt against @code{guile@@2.0}.
  7545. This is implemented using the @code{package-input-rewriting} Scheme
  7546. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  7547. @item --with-graft=@var{package}=@var{replacement}
  7548. This is similar to @option{--with-input} but with an important difference:
  7549. instead of rebuilding the whole dependency chain, @var{replacement} is
  7550. built and then @dfn{grafted} onto the binaries that were initially
  7551. referring to @var{package}. @xref{Security Updates}, for more
  7552. information on grafts.
  7553. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  7554. and all its dependencies, replacing references to the version of GnuTLS
  7555. they currently refer to:
  7556. @example
  7557. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  7558. @end example
  7559. This has the advantage of being much faster than rebuilding everything.
  7560. But there is a caveat: it works if and only if @var{package} and
  7561. @var{replacement} are strictly compatible---for example, if they provide
  7562. a library, the application binary interface (ABI) of those libraries
  7563. must be compatible. If @var{replacement} is somehow incompatible with
  7564. @var{package}, then the resulting package may be unusable. Use with
  7565. care!
  7566. @item --with-git-url=@var{package}=@var{url}
  7567. @cindex Git, using the latest commit
  7568. @cindex latest commit, building
  7569. Build @var{package} from the latest commit of the @code{master} branch of the
  7570. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  7571. recursively.
  7572. For example, the following command builds the NumPy Python library against the
  7573. latest commit of the master branch of Python itself:
  7574. @example
  7575. guix build python-numpy \
  7576. --with-git-url=python=https://github.com/python/cpython
  7577. @end example
  7578. This option can also be combined with @option{--with-branch} or
  7579. @option{--with-commit} (see below).
  7580. @cindex continuous integration
  7581. Obviously, since it uses the latest commit of the given branch, the result of
  7582. such a command varies over time. Nevertheless it is a convenient way to
  7583. rebuild entire software stacks against the latest commit of one or more
  7584. packages. This is particularly useful in the context of continuous
  7585. integration (CI).
  7586. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  7587. consecutive accesses to the same repository. You may want to clean it up once
  7588. in a while to save disk space.
  7589. @item --with-branch=@var{package}=@var{branch}
  7590. Build @var{package} from the latest commit of @var{branch}. If the
  7591. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  7592. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  7593. repository URL is taken from that @code{source}. Otherwise you have to use
  7594. @option{--with-git-url} to specify the URL of the Git repository.
  7595. For instance, the following command builds @code{guile-sqlite3} from the
  7596. latest commit of its @code{master} branch, and then builds @code{guix} (which
  7597. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  7598. specific @code{guile-sqlite3} build:
  7599. @example
  7600. guix build --with-branch=guile-sqlite3=master cuirass
  7601. @end example
  7602. @item --with-commit=@var{package}=@var{commit}
  7603. This is similar to @option{--with-branch}, except that it builds from
  7604. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  7605. Git commit SHA1 identifier or a tag.
  7606. @cindex test suite, skipping
  7607. @item --without-tests=@var{package}
  7608. Build @var{package} without running its tests. This can be useful in
  7609. situations where you want to skip the lengthy test suite of a
  7610. intermediate package, or if a package's test suite fails in a
  7611. non-deterministic fashion. It should be used with care because running
  7612. the test suite is a good way to ensure a package is working as intended.
  7613. Turning off tests leads to a different store item. Consequently, when
  7614. using this option, anything that depends on @var{package} must be
  7615. rebuilt, as in this example:
  7616. @example
  7617. guix install --without-tests=python python-notebook
  7618. @end example
  7619. The command above installs @code{python-notebook} on top of
  7620. @code{python} built without running its test suite. To do so, it also
  7621. rebuilds everything that depends on @code{python}, including
  7622. @code{python-notebook} itself.
  7623. Internally, @option{--without-tests} relies on changing the
  7624. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  7625. Systems}). Note that some packages use a customized @code{check} phase
  7626. that does not respect a @code{#:tests? #f} setting. Therefore,
  7627. @option{--without-tests} has no effect on these packages.
  7628. @end table
  7629. @node Additional Build Options
  7630. @subsection Additional Build Options
  7631. The command-line options presented below are specific to @command{guix
  7632. build}.
  7633. @table @code
  7634. @item --quiet
  7635. @itemx -q
  7636. Build quietly, without displaying the build log; this is equivalent to
  7637. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  7638. (or similar) and can always be retrieved using the @option{--log-file} option.
  7639. @item --file=@var{file}
  7640. @itemx -f @var{file}
  7641. Build the package, derivation, or other file-like object that the code within
  7642. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  7643. As an example, @var{file} might contain a package definition like this
  7644. (@pxref{Defining Packages}):
  7645. @lisp
  7646. @include package-hello.scm
  7647. @end lisp
  7648. The @var{file} may also contain a JSON representation of one or more
  7649. package definitions. Running @code{guix build -f} on @file{hello.json}
  7650. with the following contents would result in building the packages
  7651. @code{myhello} and @code{greeter}:
  7652. @example
  7653. @verbatiminclude package-hello.json
  7654. @end example
  7655. @item --manifest=@var{manifest}
  7656. @itemx -m @var{manifest}
  7657. Build all packages listed in the given @var{manifest}
  7658. (@pxref{profile-manifest, @option{--manifest}}).
  7659. @item --expression=@var{expr}
  7660. @itemx -e @var{expr}
  7661. Build the package or derivation @var{expr} evaluates to.
  7662. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  7663. guile-1.8)}, which unambiguously designates this specific variant of
  7664. version 1.8 of Guile.
  7665. Alternatively, @var{expr} may be a G-expression, in which case it is used
  7666. as a build program passed to @code{gexp->derivation}
  7667. (@pxref{G-Expressions}).
  7668. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  7669. (@pxref{The Store Monad}). The procedure must return a derivation as a
  7670. monadic value, which is then passed through @code{run-with-store}.
  7671. @item --source
  7672. @itemx -S
  7673. Build the source derivations of the packages, rather than the packages
  7674. themselves.
  7675. For instance, @code{guix build -S gcc} returns something like
  7676. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  7677. source tarball.
  7678. The returned source tarball is the result of applying any patches and
  7679. code snippets specified in the package @code{origin} (@pxref{Defining
  7680. Packages}).
  7681. Note that @command{guix build -S} compiles the sources only of the
  7682. specified packages. They do not include the sources of statically
  7683. linked dependencies and by themselves are insufficient for reproducing
  7684. the packages.
  7685. @item --sources
  7686. Fetch and return the source of @var{package-or-derivation} and all their
  7687. dependencies, recursively. This is a handy way to obtain a local copy
  7688. of all the source code needed to build @var{packages}, allowing you to
  7689. eventually build them even without network access. It is an extension
  7690. of the @option{--source} option and can accept one of the following
  7691. optional argument values:
  7692. @table @code
  7693. @item package
  7694. This value causes the @option{--sources} option to behave in the same way
  7695. as the @option{--source} option.
  7696. @item all
  7697. Build the source derivations of all packages, including any source that
  7698. might be listed as @code{inputs}. This is the default value.
  7699. @example
  7700. $ guix build --sources tzdata
  7701. The following derivations will be built:
  7702. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  7703. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  7704. @end example
  7705. @item transitive
  7706. Build the source derivations of all packages, as well of all transitive
  7707. inputs to the packages. This can be used e.g.@: to
  7708. prefetch package source for later offline building.
  7709. @example
  7710. $ guix build --sources=transitive tzdata
  7711. The following derivations will be built:
  7712. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  7713. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  7714. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  7715. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  7716. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  7717. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  7718. @dots{}
  7719. @end example
  7720. @end table
  7721. @item --system=@var{system}
  7722. @itemx -s @var{system}
  7723. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  7724. the system type of the build host. The @command{guix build} command allows
  7725. you to repeat this option several times, in which case it builds for all the
  7726. specified systems; other commands ignore extraneous @option{-s} options.
  7727. @quotation Note
  7728. The @option{--system} flag is for @emph{native} compilation and must not
  7729. be confused with cross-compilation. See @option{--target} below for
  7730. information on cross-compilation.
  7731. @end quotation
  7732. An example use of this is on Linux-based systems, which can emulate
  7733. different personalities. For instance, passing
  7734. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  7735. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  7736. you to build packages in a complete 32-bit environment.
  7737. @quotation Note
  7738. Building for an @code{armhf-linux} system is unconditionally enabled on
  7739. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  7740. allow for this functionality, notably the ThunderX.
  7741. @end quotation
  7742. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  7743. is enabled (@pxref{Virtualization Services,
  7744. @code{qemu-binfmt-service-type}}), you can build for any system for
  7745. which a QEMU @code{binfmt_misc} handler is installed.
  7746. Builds for a system other than that of the machine you are using can
  7747. also be offloaded to a remote machine of the right architecture.
  7748. @xref{Daemon Offload Setup}, for more information on offloading.
  7749. @item --target=@var{triplet}
  7750. @cindex cross-compilation
  7751. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  7752. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  7753. configuration triplets,, autoconf, Autoconf}).
  7754. @anchor{build-check}
  7755. @item --check
  7756. @cindex determinism, checking
  7757. @cindex reproducibility, checking
  7758. Rebuild @var{package-or-derivation}, which are already available in the
  7759. store, and raise an error if the build results are not bit-for-bit
  7760. identical.
  7761. This mechanism allows you to check whether previously installed
  7762. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  7763. of a package is deterministic. @xref{Invoking guix challenge}, for more
  7764. background information and tools.
  7765. When used in conjunction with @option{--keep-failed}, the differing
  7766. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  7767. This makes it easy to look for differences between the two results.
  7768. @item --repair
  7769. @cindex repairing store items
  7770. @cindex corruption, recovering from
  7771. Attempt to repair the specified store items, if they are corrupt, by
  7772. re-downloading or rebuilding them.
  7773. This operation is not atomic and thus restricted to @code{root}.
  7774. @item --derivations
  7775. @itemx -d
  7776. Return the derivation paths, not the output paths, of the given
  7777. packages.
  7778. @item --root=@var{file}
  7779. @itemx -r @var{file}
  7780. @cindex GC roots, adding
  7781. @cindex garbage collector roots, adding
  7782. Make @var{file} a symlink to the result, and register it as a garbage
  7783. collector root.
  7784. Consequently, the results of this @command{guix build} invocation are
  7785. protected from garbage collection until @var{file} is removed. When
  7786. that option is omitted, build results are eligible for garbage
  7787. collection as soon as the build completes. @xref{Invoking guix gc}, for
  7788. more on GC roots.
  7789. @item --log-file
  7790. @cindex build logs, access
  7791. Return the build log file names or URLs for the given
  7792. @var{package-or-derivation}, or raise an error if build logs are
  7793. missing.
  7794. This works regardless of how packages or derivations are specified. For
  7795. instance, the following invocations are equivalent:
  7796. @example
  7797. guix build --log-file `guix build -d guile`
  7798. guix build --log-file `guix build guile`
  7799. guix build --log-file guile
  7800. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  7801. @end example
  7802. If a log is unavailable locally, and unless @option{--no-substitutes} is
  7803. passed, the command looks for a corresponding log on one of the
  7804. substitute servers (as specified with @option{--substitute-urls}).
  7805. So for instance, imagine you want to see the build log of GDB on MIPS,
  7806. but you are actually on an @code{x86_64} machine:
  7807. @example
  7808. $ guix build --log-file gdb -s aarch64-linux
  7809. https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
  7810. @end example
  7811. You can freely access a huge library of build logs!
  7812. @end table
  7813. @node Debugging Build Failures
  7814. @subsection Debugging Build Failures
  7815. @cindex build failures, debugging
  7816. When defining a new package (@pxref{Defining Packages}), you will
  7817. probably find yourself spending some time debugging and tweaking the
  7818. build until it succeeds. To do that, you need to operate the build
  7819. commands yourself in an environment as close as possible to the one the
  7820. build daemon uses.
  7821. To that end, the first thing to do is to use the @option{--keep-failed}
  7822. or @option{-K} option of @command{guix build}, which will keep the
  7823. failed build tree in @file{/tmp} or whatever directory you specified as
  7824. @env{TMPDIR} (@pxref{Invoking guix build, @option{--keep-failed}}).
  7825. From there on, you can @command{cd} to the failed build tree and source
  7826. the @file{environment-variables} file, which contains all the
  7827. environment variable definitions that were in place when the build
  7828. failed. So let's say you're debugging a build failure in package
  7829. @code{foo}; a typical session would look like this:
  7830. @example
  7831. $ guix build foo -K
  7832. @dots{} @i{build fails}
  7833. $ cd /tmp/guix-build-foo.drv-0
  7834. $ source ./environment-variables
  7835. $ cd foo-1.2
  7836. @end example
  7837. Now, you can invoke commands as if you were the daemon (almost) and
  7838. troubleshoot your build process.
  7839. Sometimes it happens that, for example, a package's tests pass when you
  7840. run them manually but they fail when the daemon runs them. This can
  7841. happen because the daemon runs builds in containers where, unlike in our
  7842. environment above, network access is missing, @file{/bin/sh} does not
  7843. exist, etc. (@pxref{Build Environment Setup}).
  7844. In such cases, you may need to run inspect the build process from within
  7845. a container similar to the one the build daemon creates:
  7846. @example
  7847. $ guix build -K foo
  7848. @dots{}
  7849. $ cd /tmp/guix-build-foo.drv-0
  7850. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  7851. [env]# source ./environment-variables
  7852. [env]# cd foo-1.2
  7853. @end example
  7854. Here, @command{guix environment -C} creates a container and spawns a new
  7855. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  7856. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  7857. the container, which you may find handy while debugging. The
  7858. @option{--no-grafts} option makes sure we get the exact same
  7859. environment, with ungrafted packages (@pxref{Security Updates}, for more
  7860. info on grafts).
  7861. To get closer to a container like that used by the build daemon, we can
  7862. remove @file{/bin/sh}:
  7863. @example
  7864. [env]# rm /bin/sh
  7865. @end example
  7866. (Don't worry, this is harmless: this is all happening in the throw-away
  7867. container created by @command{guix environment}.)
  7868. The @command{strace} command is probably not in the search path, but we
  7869. can run:
  7870. @example
  7871. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  7872. @end example
  7873. In this way, not only you will have reproduced the environment variables
  7874. the daemon uses, you will also be running the build process in a container
  7875. similar to the one the daemon uses.
  7876. @node Invoking guix edit
  7877. @section Invoking @command{guix edit}
  7878. @cindex @command{guix edit}
  7879. @cindex package definition, editing
  7880. So many packages, so many source files! The @command{guix edit} command
  7881. facilitates the life of users and packagers by pointing their editor at
  7882. the source file containing the definition of the specified packages.
  7883. For instance:
  7884. @example
  7885. guix edit gcc@@4.9 vim
  7886. @end example
  7887. @noindent
  7888. launches the program specified in the @env{VISUAL} or in the
  7889. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  7890. and that of Vim.
  7891. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  7892. have created your own packages on @env{GUIX_PACKAGE_PATH}
  7893. (@pxref{Package Modules}), you will be able to edit the package
  7894. recipes. In other cases, you will be able to examine the read-only recipes
  7895. for packages currently in the store.
  7896. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  7897. @option{--load-path=@var{directory}} (or in short @option{-L
  7898. @var{directory}}) allows you to add @var{directory} to the front of the
  7899. package module search path and so make your own packages visible.
  7900. @node Invoking guix download
  7901. @section Invoking @command{guix download}
  7902. @cindex @command{guix download}
  7903. @cindex downloading package sources
  7904. When writing a package definition, developers typically need to download
  7905. a source tarball, compute its SHA256 hash, and write that
  7906. hash in the package definition (@pxref{Defining Packages}). The
  7907. @command{guix download} tool helps with this task: it downloads a file
  7908. from the given URI, adds it to the store, and prints both its file name
  7909. in the store and its SHA256 hash.
  7910. The fact that the downloaded file is added to the store saves bandwidth:
  7911. when the developer eventually tries to build the newly defined package
  7912. with @command{guix build}, the source tarball will not have to be
  7913. downloaded again because it is already in the store. It is also a
  7914. convenient way to temporarily stash files, which may be deleted
  7915. eventually (@pxref{Invoking guix gc}).
  7916. The @command{guix download} command supports the same URIs as used in
  7917. package definitions. In particular, it supports @code{mirror://} URIs.
  7918. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  7919. Guile bindings for GnuTLS are available in the user's environment; when
  7920. they are not available, an error is raised. @xref{Guile Preparations,
  7921. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  7922. GnuTLS-Guile}, for more information.
  7923. @command{guix download} verifies HTTPS server certificates by loading
  7924. the certificates of X.509 authorities from the directory pointed to by
  7925. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  7926. Certificates}), unless @option{--no-check-certificate} is used.
  7927. The following options are available:
  7928. @table @code
  7929. @item --hash=@var{algorithm}
  7930. @itemx -H @var{algorithm}
  7931. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  7932. hash}, for more information.
  7933. @item --format=@var{fmt}
  7934. @itemx -f @var{fmt}
  7935. Write the hash in the format specified by @var{fmt}. For more
  7936. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  7937. @item --no-check-certificate
  7938. Do not validate the X.509 certificates of HTTPS servers.
  7939. When using this option, you have @emph{absolutely no guarantee} that you
  7940. are communicating with the authentic server responsible for the given
  7941. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  7942. @item --output=@var{file}
  7943. @itemx -o @var{file}
  7944. Save the downloaded file to @var{file} instead of adding it to the
  7945. store.
  7946. @end table
  7947. @node Invoking guix hash
  7948. @section Invoking @command{guix hash}
  7949. @cindex @command{guix hash}
  7950. The @command{guix hash} command computes the hash of a file.
  7951. It is primarily a convenience tool for anyone contributing to the
  7952. distribution: it computes the cryptographic hash of a file, which can be
  7953. used in the definition of a package (@pxref{Defining Packages}).
  7954. The general syntax is:
  7955. @example
  7956. guix hash @var{option} @var{file}
  7957. @end example
  7958. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  7959. hash of data read from standard input. @command{guix hash} has the
  7960. following options:
  7961. @table @code
  7962. @item --hash=@var{algorithm}
  7963. @itemx -H @var{algorithm}
  7964. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  7965. default.
  7966. @var{algorithm} must the name of a cryptographic hash algorithm
  7967. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  7968. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  7969. Reference Manual}).
  7970. @item --format=@var{fmt}
  7971. @itemx -f @var{fmt}
  7972. Write the hash in the format specified by @var{fmt}.
  7973. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  7974. (@code{hex} and @code{hexadecimal} can be used as well).
  7975. If the @option{--format} option is not specified, @command{guix hash}
  7976. will output the hash in @code{nix-base32}. This representation is used
  7977. in the definitions of packages.
  7978. @item --recursive
  7979. @itemx -r
  7980. Compute the hash on @var{file} recursively.
  7981. In this case, the hash is computed on an archive containing @var{file},
  7982. including its children if it is a directory. Some of the metadata of
  7983. @var{file} is part of the archive; for instance, when @var{file} is a
  7984. regular file, the hash is different depending on whether @var{file} is
  7985. executable or not. Metadata such as time stamps has no impact on the
  7986. hash (@pxref{Invoking guix archive}).
  7987. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  7988. @c it exists.
  7989. @item --exclude-vcs
  7990. @itemx -x
  7991. When combined with @option{--recursive}, exclude version control system
  7992. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  7993. @vindex git-fetch
  7994. As an example, here is how you would compute the hash of a Git checkout,
  7995. which is useful when using the @code{git-fetch} method (@pxref{origin
  7996. Reference}):
  7997. @example
  7998. $ git clone http://example.org/foo.git
  7999. $ cd foo
  8000. $ guix hash -rx .
  8001. @end example
  8002. @end table
  8003. @node Invoking guix import
  8004. @section Invoking @command{guix import}
  8005. @cindex importing packages
  8006. @cindex package import
  8007. @cindex package conversion
  8008. @cindex Invoking @command{guix import}
  8009. The @command{guix import} command is useful for people who would like to
  8010. add a package to the distribution with as little work as
  8011. possible---a legitimate demand. The command knows of a few
  8012. repositories from which it can ``import'' package metadata. The result
  8013. is a package definition, or a template thereof, in the format we know
  8014. (@pxref{Defining Packages}).
  8015. The general syntax is:
  8016. @example
  8017. guix import @var{importer} @var{options}@dots{}
  8018. @end example
  8019. @var{importer} specifies the source from which to import package
  8020. metadata, and @var{options} specifies a package identifier and other
  8021. options specific to @var{importer}.
  8022. Some of the importers rely on the ability to run the @command{gpgv} command.
  8023. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  8024. gnupg} if needed.
  8025. Currently, the available ``importers'' are:
  8026. @table @code
  8027. @item gnu
  8028. Import metadata for the given GNU package. This provides a template
  8029. for the latest version of that GNU package, including the hash of its
  8030. source tarball, and its canonical synopsis and description.
  8031. Additional information such as the package dependencies and its
  8032. license needs to be figured out manually.
  8033. For example, the following command returns a package definition for
  8034. GNU@tie{}Hello:
  8035. @example
  8036. guix import gnu hello
  8037. @end example
  8038. Specific command-line options are:
  8039. @table @code
  8040. @item --key-download=@var{policy}
  8041. As for @command{guix refresh}, specify the policy to handle missing
  8042. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  8043. refresh, @option{--key-download}}.
  8044. @end table
  8045. @item pypi
  8046. @cindex pypi
  8047. Import metadata from the @uref{https://pypi.python.org/, Python Package
  8048. Index}. Information is taken from the JSON-formatted description
  8049. available at @code{pypi.python.org} and usually includes all the relevant
  8050. information, including package dependencies. For maximum efficiency, it
  8051. is recommended to install the @command{unzip} utility, so that the
  8052. importer can unzip Python wheels and gather data from them.
  8053. The command below imports metadata for the @code{itsdangerous} Python
  8054. package:
  8055. @example
  8056. guix import pypi itsdangerous
  8057. @end example
  8058. @table @code
  8059. @item --recursive
  8060. @itemx -r
  8061. Traverse the dependency graph of the given upstream package recursively
  8062. and generate package expressions for all those packages that are not yet
  8063. in Guix.
  8064. @end table
  8065. @item gem
  8066. @cindex gem
  8067. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  8068. is taken from the JSON-formatted description available at
  8069. @code{rubygems.org} and includes most relevant information, including
  8070. runtime dependencies. There are some caveats, however. The metadata
  8071. doesn't distinguish between synopses and descriptions, so the same string
  8072. is used for both fields. Additionally, the details of non-Ruby
  8073. dependencies required to build native extensions is unavailable and left
  8074. as an exercise to the packager.
  8075. The command below imports metadata for the @code{rails} Ruby package:
  8076. @example
  8077. guix import gem rails
  8078. @end example
  8079. @table @code
  8080. @item --recursive
  8081. @itemx -r
  8082. Traverse the dependency graph of the given upstream package recursively
  8083. and generate package expressions for all those packages that are not yet
  8084. in Guix.
  8085. @end table
  8086. @item cpan
  8087. @cindex CPAN
  8088. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  8089. Information is taken from the JSON-formatted metadata provided through
  8090. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  8091. relevant information, such as module dependencies. License information
  8092. should be checked closely. If Perl is available in the store, then the
  8093. @code{corelist} utility will be used to filter core modules out of the
  8094. list of dependencies.
  8095. The command command below imports metadata for the Acme::Boolean Perl
  8096. module:
  8097. @example
  8098. guix import cpan Acme::Boolean
  8099. @end example
  8100. @item cran
  8101. @cindex CRAN
  8102. @cindex Bioconductor
  8103. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  8104. central repository for the @uref{https://r-project.org, GNU@tie{}R
  8105. statistical and graphical environment}.
  8106. Information is extracted from the @file{DESCRIPTION} file of the package.
  8107. The command command below imports metadata for the Cairo R package:
  8108. @example
  8109. guix import cran Cairo
  8110. @end example
  8111. When @option{--recursive} is added, the importer will traverse the
  8112. dependency graph of the given upstream package recursively and generate
  8113. package expressions for all those packages that are not yet in Guix.
  8114. When @option{--archive=bioconductor} is added, metadata is imported from
  8115. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  8116. packages for for the analysis and comprehension of high-throughput
  8117. genomic data in bioinformatics.
  8118. Information is extracted from the @file{DESCRIPTION} file contained in the
  8119. package archive.
  8120. The command below imports metadata for the GenomicRanges R package:
  8121. @example
  8122. guix import cran --archive=bioconductor GenomicRanges
  8123. @end example
  8124. Finally, you can also import R packages that have not yet been published on
  8125. CRAN or Bioconductor as long as they are in a git repository. Use
  8126. @option{--archive=git} followed by the URL of the git repository:
  8127. @example
  8128. guix import cran --archive=git https://github.com/immunogenomics/harmony
  8129. @end example
  8130. @item texlive
  8131. @cindex TeX Live
  8132. @cindex CTAN
  8133. Import metadata from @uref{https://www.ctan.org/, CTAN}, the
  8134. comprehensive TeX archive network for TeX packages that are part of the
  8135. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  8136. Information about the package is obtained through the XML API provided
  8137. by CTAN, while the source code is downloaded from the SVN repository of
  8138. the Tex Live project. This is done because the CTAN does not keep
  8139. versioned archives.
  8140. The command command below imports metadata for the @code{fontspec}
  8141. TeX package:
  8142. @example
  8143. guix import texlive fontspec
  8144. @end example
  8145. When @option{--archive=@var{directory}} is added, the source code is
  8146. downloaded not from the @file{latex} sub-directory of the
  8147. @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
  8148. the specified sibling @var{directory} under the same root.
  8149. The command below imports metadata for the @code{ifxetex} package from
  8150. CTAN while fetching the sources from the directory
  8151. @file{texmf/source/generic}:
  8152. @example
  8153. guix import texlive --archive=generic ifxetex
  8154. @end example
  8155. @item json
  8156. @cindex JSON, import
  8157. Import package metadata from a local JSON file. Consider the following
  8158. example package definition in JSON format:
  8159. @example
  8160. @{
  8161. "name": "hello",
  8162. "version": "2.10",
  8163. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  8164. "build-system": "gnu",
  8165. "home-page": "https://www.gnu.org/software/hello/",
  8166. "synopsis": "Hello, GNU world: An example GNU package",
  8167. "description": "GNU Hello prints a greeting.",
  8168. "license": "GPL-3.0+",
  8169. "native-inputs": ["gettext"]
  8170. @}
  8171. @end example
  8172. The field names are the same as for the @code{<package>} record
  8173. (@xref{Defining Packages}). References to other packages are provided
  8174. as JSON lists of quoted package specification strings such as
  8175. @code{guile} or @code{guile@@2.0}.
  8176. The importer also supports a more explicit source definition using the
  8177. common fields for @code{<origin>} records:
  8178. @example
  8179. @{
  8180. @dots{}
  8181. "source": @{
  8182. "method": "url-fetch",
  8183. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  8184. "sha256": @{
  8185. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  8186. @}
  8187. @}
  8188. @dots{}
  8189. @}
  8190. @end example
  8191. The command below reads metadata from the JSON file @code{hello.json}
  8192. and outputs a package expression:
  8193. @example
  8194. guix import json hello.json
  8195. @end example
  8196. @item nix
  8197. Import metadata from a local copy of the source of the
  8198. @uref{https://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  8199. relies on the @command{nix-instantiate} command of
  8200. @uref{https://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  8201. typically written in a mixture of Nix-language and Bash code. This
  8202. command only imports the high-level package structure that is written in
  8203. the Nix language. It normally includes all the basic fields of a
  8204. package definition.
  8205. When importing a GNU package, the synopsis and descriptions are replaced
  8206. by their canonical upstream variant.
  8207. Usually, you will first need to do:
  8208. @example
  8209. export NIX_REMOTE=daemon
  8210. @end example
  8211. @noindent
  8212. so that @command{nix-instantiate} does not try to open the Nix database.
  8213. As an example, the command below imports the package definition of
  8214. LibreOffice (more precisely, it imports the definition of the package
  8215. bound to the @code{libreoffice} top-level attribute):
  8216. @example
  8217. guix import nix ~/path/to/nixpkgs libreoffice
  8218. @end example
  8219. @item hackage
  8220. @cindex hackage
  8221. Import metadata from the Haskell community's central package archive
  8222. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  8223. Cabal files and includes all the relevant information, including package
  8224. dependencies.
  8225. Specific command-line options are:
  8226. @table @code
  8227. @item --stdin
  8228. @itemx -s
  8229. Read a Cabal file from standard input.
  8230. @item --no-test-dependencies
  8231. @itemx -t
  8232. Do not include dependencies required only by the test suites.
  8233. @item --cabal-environment=@var{alist}
  8234. @itemx -e @var{alist}
  8235. @var{alist} is a Scheme alist defining the environment in which the
  8236. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  8237. @code{arch}, @code{impl} and a string representing the name of a flag.
  8238. The value associated with a flag has to be either the symbol
  8239. @code{true} or @code{false}. The value associated with other keys
  8240. has to conform to the Cabal file format definition. The default value
  8241. associated with the keys @code{os}, @code{arch} and @code{impl} is
  8242. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  8243. @item --recursive
  8244. @itemx -r
  8245. Traverse the dependency graph of the given upstream package recursively
  8246. and generate package expressions for all those packages that are not yet
  8247. in Guix.
  8248. @end table
  8249. The command below imports metadata for the latest version of the
  8250. HTTP Haskell package without including test dependencies and
  8251. specifying the value of the flag @samp{network-uri} as @code{false}:
  8252. @example
  8253. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  8254. @end example
  8255. A specific package version may optionally be specified by following the
  8256. package name by an at-sign and a version number as in the following example:
  8257. @example
  8258. guix import hackage mtl@@2.1.3.1
  8259. @end example
  8260. @item stackage
  8261. @cindex stackage
  8262. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  8263. It takes a package name, looks up the package version included in a
  8264. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  8265. release and uses the @code{hackage} importer to retrieve its metadata.
  8266. Note that it is up to you to select an LTS release compatible with the
  8267. GHC compiler used by Guix.
  8268. Specific command-line options are:
  8269. @table @code
  8270. @item --no-test-dependencies
  8271. @itemx -t
  8272. Do not include dependencies required only by the test suites.
  8273. @item --lts-version=@var{version}
  8274. @itemx -l @var{version}
  8275. @var{version} is the desired LTS release version. If omitted the latest
  8276. release is used.
  8277. @item --recursive
  8278. @itemx -r
  8279. Traverse the dependency graph of the given upstream package recursively
  8280. and generate package expressions for all those packages that are not yet
  8281. in Guix.
  8282. @end table
  8283. The command below imports metadata for the HTTP Haskell package
  8284. included in the LTS Stackage release version 7.18:
  8285. @example
  8286. guix import stackage --lts-version=7.18 HTTP
  8287. @end example
  8288. @item elpa
  8289. @cindex elpa
  8290. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  8291. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  8292. Specific command-line options are:
  8293. @table @code
  8294. @item --archive=@var{repo}
  8295. @itemx -a @var{repo}
  8296. @var{repo} identifies the archive repository from which to retrieve the
  8297. information. Currently the supported repositories and their identifiers
  8298. are:
  8299. @itemize -
  8300. @item
  8301. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  8302. identifier. This is the default.
  8303. Packages from @code{elpa.gnu.org} are signed with one of the keys
  8304. contained in the GnuPG keyring at
  8305. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  8306. @code{emacs} package (@pxref{Package Installation, ELPA package
  8307. signatures,, emacs, The GNU Emacs Manual}).
  8308. @item
  8309. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  8310. @code{melpa-stable} identifier.
  8311. @item
  8312. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  8313. identifier.
  8314. @end itemize
  8315. @item --recursive
  8316. @itemx -r
  8317. Traverse the dependency graph of the given upstream package recursively
  8318. and generate package expressions for all those packages that are not yet
  8319. in Guix.
  8320. @end table
  8321. @item crate
  8322. @cindex crate
  8323. Import metadata from the crates.io Rust package repository
  8324. @uref{https://crates.io, crates.io}, as in this example:
  8325. @example
  8326. guix import crate blake2-rfc
  8327. @end example
  8328. The crate importer also allows you to specify a version string:
  8329. @example
  8330. guix import crate constant-time-eq@@0.1.0
  8331. @end example
  8332. Additional options include:
  8333. @table @code
  8334. @item --recursive
  8335. @itemx -r
  8336. Traverse the dependency graph of the given upstream package recursively
  8337. and generate package expressions for all those packages that are not yet
  8338. in Guix.
  8339. @end table
  8340. @item opam
  8341. @cindex OPAM
  8342. @cindex OCaml
  8343. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  8344. repository used by the OCaml community.
  8345. @end table
  8346. The structure of the @command{guix import} code is modular. It would be
  8347. useful to have more importers for other package formats, and your help
  8348. is welcome here (@pxref{Contributing}).
  8349. @node Invoking guix refresh
  8350. @section Invoking @command{guix refresh}
  8351. @cindex @command {guix refresh}
  8352. The primary audience of the @command{guix refresh} command is developers
  8353. of the GNU software distribution. By default, it reports any packages
  8354. provided by the distribution that are outdated compared to the latest
  8355. upstream version, like this:
  8356. @example
  8357. $ guix refresh
  8358. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  8359. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  8360. @end example
  8361. Alternatively, one can specify packages to consider, in which case a
  8362. warning is emitted for packages that lack an updater:
  8363. @example
  8364. $ guix refresh coreutils guile guile-ssh
  8365. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  8366. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  8367. @end example
  8368. @command{guix refresh} browses the upstream repository of each package and determines
  8369. the highest version number of the releases therein. The command
  8370. knows how to update specific types of packages: GNU packages, ELPA
  8371. packages, etc.---see the documentation for @option{--type} below. There
  8372. are many packages, though, for which it lacks a method to determine
  8373. whether a new upstream release is available. However, the mechanism is
  8374. extensible, so feel free to get in touch with us to add a new method!
  8375. @table @code
  8376. @item --recursive
  8377. Consider the packages specified, and all the packages upon which they depend.
  8378. @example
  8379. $ guix refresh --recursive coreutils
  8380. gnu/packages/acl.scm:35:2: warning: no updater for acl
  8381. gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
  8382. gnu/packages/xml.scm:68:2: warning: no updater for expat
  8383. gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
  8384. @dots{}
  8385. @end example
  8386. @end table
  8387. Sometimes the upstream name differs from the package name used in Guix,
  8388. and @command{guix refresh} needs a little help. Most updaters honor the
  8389. @code{upstream-name} property in package definitions, which can be used
  8390. to that effect:
  8391. @lisp
  8392. (define-public network-manager
  8393. (package
  8394. (name "network-manager")
  8395. ;; @dots{}
  8396. (properties '((upstream-name . "NetworkManager")))))
  8397. @end lisp
  8398. When passed @option{--update}, it modifies distribution source files to
  8399. update the version numbers and source tarball hashes of those package
  8400. recipes (@pxref{Defining Packages}). This is achieved by downloading
  8401. each package's latest source tarball and its associated OpenPGP
  8402. signature, authenticating the downloaded tarball against its signature
  8403. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  8404. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  8405. When the public
  8406. key used to sign the tarball is missing from the user's keyring, an
  8407. attempt is made to automatically retrieve it from a public key server;
  8408. when this is successful, the key is added to the user's keyring; otherwise,
  8409. @command{guix refresh} reports an error.
  8410. The following options are supported:
  8411. @table @code
  8412. @item --expression=@var{expr}
  8413. @itemx -e @var{expr}
  8414. Consider the package @var{expr} evaluates to.
  8415. This is useful to precisely refer to a package, as in this example:
  8416. @example
  8417. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  8418. @end example
  8419. This command lists the dependents of the ``final'' libc (essentially all
  8420. the packages).
  8421. @item --update
  8422. @itemx -u
  8423. Update distribution source files (package recipes) in place. This is
  8424. usually run from a checkout of the Guix source tree (@pxref{Running
  8425. Guix Before It Is Installed}):
  8426. @example
  8427. $ ./pre-inst-env guix refresh -s non-core -u
  8428. @end example
  8429. @xref{Defining Packages}, for more information on package definitions.
  8430. @item --select=[@var{subset}]
  8431. @itemx -s @var{subset}
  8432. Select all the packages in @var{subset}, one of @code{core} or
  8433. @code{non-core}.
  8434. The @code{core} subset refers to all the packages at the core of the
  8435. distribution---i.e., packages that are used to build ``everything
  8436. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  8437. changing one of these packages in the distribution entails a rebuild of
  8438. all the others. Thus, such updates are an inconvenience to users in
  8439. terms of build time or bandwidth used to achieve the upgrade.
  8440. The @code{non-core} subset refers to the remaining packages. It is
  8441. typically useful in cases where an update of the core packages would be
  8442. inconvenient.
  8443. @item --manifest=@var{file}
  8444. @itemx -m @var{file}
  8445. Select all the packages from the manifest in @var{file}. This is useful to
  8446. check if any packages of the user manifest can be updated.
  8447. @item --type=@var{updater}
  8448. @itemx -t @var{updater}
  8449. Select only packages handled by @var{updater} (may be a comma-separated
  8450. list of updaters). Currently, @var{updater} may be one of:
  8451. @table @code
  8452. @item gnu
  8453. the updater for GNU packages;
  8454. @item savannah
  8455. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  8456. @item gnome
  8457. the updater for GNOME packages;
  8458. @item kde
  8459. the updater for KDE packages;
  8460. @item xorg
  8461. the updater for X.org packages;
  8462. @item kernel.org
  8463. the updater for packages hosted on kernel.org;
  8464. @item elpa
  8465. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  8466. @item cran
  8467. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  8468. @item bioconductor
  8469. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  8470. @item cpan
  8471. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  8472. @item pypi
  8473. the updater for @uref{https://pypi.python.org, PyPI} packages.
  8474. @item gem
  8475. the updater for @uref{https://rubygems.org, RubyGems} packages.
  8476. @item github
  8477. the updater for @uref{https://github.com, GitHub} packages.
  8478. @item hackage
  8479. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  8480. @item stackage
  8481. the updater for @uref{https://www.stackage.org, Stackage} packages.
  8482. @item crate
  8483. the updater for @uref{https://crates.io, Crates} packages.
  8484. @item launchpad
  8485. the updater for @uref{https://launchpad.net, Launchpad} packages.
  8486. @end table
  8487. For instance, the following command only checks for updates of Emacs
  8488. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  8489. @example
  8490. $ guix refresh --type=elpa,cran
  8491. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  8492. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  8493. @end example
  8494. @end table
  8495. In addition, @command{guix refresh} can be passed one or more package
  8496. names, as in this example:
  8497. @example
  8498. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  8499. @end example
  8500. @noindent
  8501. The command above specifically updates the @code{emacs} and
  8502. @code{idutils} packages. The @option{--select} option would have no
  8503. effect in this case.
  8504. When considering whether to upgrade a package, it is sometimes
  8505. convenient to know which packages would be affected by the upgrade and
  8506. should be checked for compatibility. For this the following option may
  8507. be used when passing @command{guix refresh} one or more package names:
  8508. @table @code
  8509. @item --list-updaters
  8510. @itemx -L
  8511. List available updaters and exit (see @option{--type} above).
  8512. For each updater, display the fraction of packages it covers; at the
  8513. end, display the fraction of packages covered by all these updaters.
  8514. @item --list-dependent
  8515. @itemx -l
  8516. List top-level dependent packages that would need to be rebuilt as a
  8517. result of upgrading one or more packages.
  8518. @xref{Invoking guix graph, the @code{reverse-package} type of
  8519. @command{guix graph}}, for information on how to visualize the list of
  8520. dependents of a package.
  8521. @end table
  8522. Be aware that the @option{--list-dependent} option only
  8523. @emph{approximates} the rebuilds that would be required as a result of
  8524. an upgrade. More rebuilds might be required under some circumstances.
  8525. @example
  8526. $ guix refresh --list-dependent flex
  8527. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  8528. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  8529. @end example
  8530. The command above lists a set of packages that could be built to check
  8531. for compatibility with an upgraded @code{flex} package.
  8532. @table @code
  8533. @item --list-transitive
  8534. List all the packages which one or more packages depend upon.
  8535. @example
  8536. $ guix refresh --list-transitive flex
  8537. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  8538. 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{}
  8539. @end example
  8540. @end table
  8541. The command above lists a set of packages which, when changed, would cause
  8542. @code{flex} to be rebuilt.
  8543. The following options can be used to customize GnuPG operation:
  8544. @table @code
  8545. @item --gpg=@var{command}
  8546. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  8547. for in @code{$PATH}.
  8548. @item --keyring=@var{file}
  8549. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  8550. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  8551. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  8552. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  8553. information on a tool to manipulate keybox files).
  8554. When this option is omitted, @command{guix refresh} uses
  8555. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  8556. signing keys. OpenPGP signatures are checked against keys from this keyring;
  8557. missing keys are downloaded to this keyring as well (see
  8558. @option{--key-download} below).
  8559. You can export keys from your default GPG keyring into a keybox file using
  8560. commands like this one:
  8561. @example
  8562. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  8563. @end example
  8564. Likewise, you can fetch keys to a specific keybox file like this:
  8565. @example
  8566. gpg --no-default-keyring --keyring mykeyring.kbx \
  8567. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  8568. @end example
  8569. @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  8570. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  8571. @item --key-download=@var{policy}
  8572. Handle missing OpenPGP keys according to @var{policy}, which may be one
  8573. of:
  8574. @table @code
  8575. @item always
  8576. Always download missing OpenPGP keys from the key server, and add them
  8577. to the user's GnuPG keyring.
  8578. @item never
  8579. Never try to download missing OpenPGP keys. Instead just bail out.
  8580. @item interactive
  8581. When a package signed with an unknown OpenPGP key is encountered, ask
  8582. the user whether to download it or not. This is the default behavior.
  8583. @end table
  8584. @item --key-server=@var{host}
  8585. Use @var{host} as the OpenPGP key server when importing a public key.
  8586. @item --load-path=@var{directory}
  8587. Add @var{directory} to the front of the package module search path
  8588. (@pxref{Package Modules}).
  8589. This allows users to define their own packages and make them visible to
  8590. the command-line tools.
  8591. @end table
  8592. The @code{github} updater uses the
  8593. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  8594. releases. When used repeatedly e.g.@: when refreshing all packages,
  8595. GitHub will eventually refuse to answer any further API requests. By
  8596. default 60 API requests per hour are allowed, and a full refresh on all
  8597. GitHub packages in Guix requires more than this. Authentication with
  8598. GitHub through the use of an API token alleviates these limits. To use
  8599. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  8600. token procured from @uref{https://github.com/settings/tokens} or
  8601. otherwise.
  8602. @node Invoking guix lint
  8603. @section Invoking @command{guix lint}
  8604. @cindex @command{guix lint}
  8605. @cindex package, checking for errors
  8606. The @command{guix lint} command is meant to help package developers avoid
  8607. common errors and use a consistent style. It runs a number of checks on
  8608. a given set of packages in order to find common mistakes in their
  8609. definitions. Available @dfn{checkers} include (see
  8610. @option{--list-checkers} for a complete list):
  8611. @table @code
  8612. @item synopsis
  8613. @itemx description
  8614. Validate certain typographical and stylistic rules about package
  8615. descriptions and synopses.
  8616. @item inputs-should-be-native
  8617. Identify inputs that should most likely be native inputs.
  8618. @item source
  8619. @itemx home-page
  8620. @itemx mirror-url
  8621. @itemx github-url
  8622. @itemx source-file-name
  8623. Probe @code{home-page} and @code{source} URLs and report those that are
  8624. invalid. Suggest a @code{mirror://} URL when applicable. If the
  8625. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  8626. URL. Check that the source file name is meaningful, e.g.@: is not just a
  8627. version number or ``git-checkout'', without a declared @code{file-name}
  8628. (@pxref{origin Reference}).
  8629. @item source-unstable-tarball
  8630. Parse the @code{source} URL to determine if a tarball from GitHub is
  8631. autogenerated or if it is a release tarball. Unfortunately GitHub's
  8632. autogenerated tarballs are sometimes regenerated.
  8633. @item derivation
  8634. Check that the derivation of the given packages can be successfully
  8635. computed for all the supported systems (@pxref{Derivations}).
  8636. @item profile-collisions
  8637. Check whether installing the given packages in a profile would lead to
  8638. collisions. Collisions occur when several packages with the same name
  8639. but a different version or a different store file name are propagated.
  8640. @xref{package Reference, @code{propagated-inputs}}, for more information
  8641. on propagated inputs.
  8642. @item archival
  8643. @cindex Software Heritage, source code archive
  8644. @cindex archival of source code, Software Heritage
  8645. Checks whether the package's source code is archived at
  8646. @uref{https://www.softwareheritage.org, Software Heritage}.
  8647. When the source code that is not archived comes from a version-control system
  8648. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  8649. ``save'' request so that it eventually archives it. This ensures that the
  8650. source will remain available in the long term, and that Guix can fall back to
  8651. Software Heritage should the source code disappear from its original host.
  8652. The status of recent ``save'' requests can be
  8653. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  8654. When source code is a tarball obtained with @code{url-fetch}, simply print a
  8655. message when it is not archived. As of this writing, Software Heritage does
  8656. not allow requests to save arbitrary tarballs; we are working on ways to
  8657. ensure that non-VCS source code is also archived.
  8658. Software Heritage
  8659. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  8660. request rate per IP address}. When the limit is reached, @command{guix lint}
  8661. prints a message and the @code{archival} checker stops doing anything until
  8662. that limit has been reset.
  8663. @item cve
  8664. @cindex security vulnerabilities
  8665. @cindex CVE, Common Vulnerabilities and Exposures
  8666. Report known vulnerabilities found in the Common Vulnerabilities and
  8667. Exposures (CVE) databases of the current and past year
  8668. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  8669. NIST}.
  8670. To view information about a particular vulnerability, visit pages such as:
  8671. @itemize
  8672. @item
  8673. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  8674. @item
  8675. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  8676. @end itemize
  8677. @noindent
  8678. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  8679. @code{CVE-2015-7554}.
  8680. Package developers can specify in package recipes the
  8681. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  8682. name and version of the package when they differ from the name or version
  8683. that Guix uses, as in this example:
  8684. @lisp
  8685. (package
  8686. (name "grub")
  8687. ;; @dots{}
  8688. ;; CPE calls this package "grub2".
  8689. (properties '((cpe-name . "grub2")
  8690. (cpe-version . "2.3"))))
  8691. @end lisp
  8692. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  8693. Some entries in the CVE database do not specify which version of a
  8694. package they apply to, and would thus ``stick around'' forever. Package
  8695. developers who found CVE alerts and verified they can be ignored can
  8696. declare them as in this example:
  8697. @lisp
  8698. (package
  8699. (name "t1lib")
  8700. ;; @dots{}
  8701. ;; These CVEs no longer apply and can be safely ignored.
  8702. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  8703. "CVE-2011-1553"
  8704. "CVE-2011-1554"
  8705. "CVE-2011-5244")))))
  8706. @end lisp
  8707. @item formatting
  8708. Warn about obvious source code formatting issues: trailing white space,
  8709. use of tabulations, etc.
  8710. @end table
  8711. The general syntax is:
  8712. @example
  8713. guix lint @var{options} @var{package}@dots{}
  8714. @end example
  8715. If no package is given on the command line, then all packages are checked.
  8716. The @var{options} may be zero or more of the following:
  8717. @table @code
  8718. @item --list-checkers
  8719. @itemx -l
  8720. List and describe all the available checkers that will be run on packages
  8721. and exit.
  8722. @item --checkers
  8723. @itemx -c
  8724. Only enable the checkers specified in a comma-separated list using the
  8725. names returned by @option{--list-checkers}.
  8726. @item --load-path=@var{directory}
  8727. @itemx -L @var{directory}
  8728. Add @var{directory} to the front of the package module search path
  8729. (@pxref{Package Modules}).
  8730. This allows users to define their own packages and make them visible to
  8731. the command-line tools.
  8732. @end table
  8733. @node Invoking guix size
  8734. @section Invoking @command{guix size}
  8735. @cindex size
  8736. @cindex package size
  8737. @cindex closure
  8738. @cindex @command{guix size}
  8739. The @command{guix size} command helps package developers profile the
  8740. disk usage of packages. It is easy to overlook the impact of an
  8741. additional dependency added to a package, or the impact of using a
  8742. single output for a package that could easily be split (@pxref{Packages
  8743. with Multiple Outputs}). Such are the typical issues that
  8744. @command{guix size} can highlight.
  8745. The command can be passed one or more package specifications
  8746. such as @code{gcc@@4.8}
  8747. or @code{guile:debug}, or a file name in the store. Consider this
  8748. example:
  8749. @example
  8750. $ guix size coreutils
  8751. store item total self
  8752. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  8753. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  8754. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  8755. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  8756. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  8757. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  8758. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  8759. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  8760. total: 78.9 MiB
  8761. @end example
  8762. @cindex closure
  8763. The store items listed here constitute the @dfn{transitive closure} of
  8764. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  8765. would be returned by:
  8766. @example
  8767. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  8768. @end example
  8769. Here the output shows three columns next to store items. The first column,
  8770. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  8771. the store item---that is, its own size plus the size of all its
  8772. dependencies. The next column, labeled ``self'', shows the size of the
  8773. item itself. The last column shows the ratio of the size of the item
  8774. itself to the space occupied by all the items listed here.
  8775. In this example, we see that the closure of Coreutils weighs in at
  8776. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  8777. libraries. (That libc and GCC's libraries represent a large fraction of
  8778. the closure is not a problem @i{per se} because they are always available
  8779. on the system anyway.)
  8780. Since the command also accepts store file names, assessing the size of
  8781. a build result is straightforward:
  8782. @example
  8783. guix size $(guix system build config.scm)
  8784. @end example
  8785. When the package(s) passed to @command{guix size} are available in the
  8786. store@footnote{More precisely, @command{guix size} looks for the
  8787. @emph{ungrafted} variant of the given package(s), as returned by
  8788. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  8789. for information on grafts.}, @command{guix size} queries the daemon to determine its
  8790. dependencies, and measures its size in the store, similar to @command{du
  8791. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  8792. Coreutils}).
  8793. When the given packages are @emph{not} in the store, @command{guix size}
  8794. reports information based on the available substitutes
  8795. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  8796. store items that are not even on disk, only available remotely.
  8797. You can also specify several package names:
  8798. @example
  8799. $ guix size coreutils grep sed bash
  8800. store item total self
  8801. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  8802. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  8803. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  8804. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  8805. @dots{}
  8806. total: 102.3 MiB
  8807. @end example
  8808. @noindent
  8809. In this example we see that the combination of the four packages takes
  8810. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  8811. since they have a lot of dependencies in common.
  8812. When looking at the profile returned by @command{guix size}, you may
  8813. find yourself wondering why a given package shows up in the profile at
  8814. all. To understand it, you can use @command{guix graph --path -t
  8815. references} to display the shortest path between the two packages
  8816. (@pxref{Invoking guix graph}).
  8817. The available options are:
  8818. @table @option
  8819. @item --substitute-urls=@var{urls}
  8820. Use substitute information from @var{urls}.
  8821. @xref{client-substitute-urls, the same option for @code{guix build}}.
  8822. @item --sort=@var{key}
  8823. Sort lines according to @var{key}, one of the following options:
  8824. @table @code
  8825. @item self
  8826. the size of each item (the default);
  8827. @item closure
  8828. the total size of the item's closure.
  8829. @end table
  8830. @item --map-file=@var{file}
  8831. Write a graphical map of disk usage in PNG format to @var{file}.
  8832. For the example above, the map looks like this:
  8833. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  8834. produced by @command{guix size}}
  8835. This option requires that
  8836. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  8837. installed and visible in Guile's module search path. When that is not
  8838. the case, @command{guix size} fails as it tries to load it.
  8839. @item --system=@var{system}
  8840. @itemx -s @var{system}
  8841. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  8842. @item --load-path=@var{directory}
  8843. @itemx -L @var{directory}
  8844. Add @var{directory} to the front of the package module search path
  8845. (@pxref{Package Modules}).
  8846. This allows users to define their own packages and make them visible to
  8847. the command-line tools.
  8848. @end table
  8849. @node Invoking guix graph
  8850. @section Invoking @command{guix graph}
  8851. @cindex DAG
  8852. @cindex @command{guix graph}
  8853. @cindex package dependencies
  8854. Packages and their dependencies form a @dfn{graph}, specifically a
  8855. directed acyclic graph (DAG). It can quickly become difficult to have a
  8856. mental model of the package DAG, so the @command{guix graph} command
  8857. provides a visual representation of the DAG. By default,
  8858. @command{guix graph} emits a DAG representation in the input format of
  8859. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  8860. directly to the @command{dot} command of Graphviz. It can also emit an
  8861. HTML page with embedded JavaScript code to display a ``chord diagram''
  8862. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  8863. emit Cypher queries to construct a graph in a graph database supporting
  8864. the @uref{https://www.opencypher.org/, openCypher} query language. With
  8865. @option{--path}, it simply displays the shortest path between two
  8866. packages. The general syntax is:
  8867. @example
  8868. guix graph @var{options} @var{package}@dots{}
  8869. @end example
  8870. For example, the following command generates a PDF file representing the
  8871. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  8872. dependencies:
  8873. @example
  8874. guix graph coreutils | dot -Tpdf > dag.pdf
  8875. @end example
  8876. The output looks like this:
  8877. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  8878. Nice little graph, no?
  8879. You may find it more pleasant to navigate the graph interactively with
  8880. @command{xdot} (from the @code{xdot} package):
  8881. @example
  8882. guix graph coreutils | xdot -
  8883. @end example
  8884. But there is more than one graph! The one above is concise: it is the
  8885. graph of package objects, omitting implicit inputs such as GCC, libc,
  8886. grep, etc. It is often useful to have such a concise graph, but
  8887. sometimes one may want to see more details. @command{guix graph} supports
  8888. several types of graphs, allowing you to choose the level of detail:
  8889. @table @code
  8890. @item package
  8891. This is the default type used in the example above. It shows the DAG of
  8892. package objects, excluding implicit dependencies. It is concise, but
  8893. filters out many details.
  8894. @item reverse-package
  8895. This shows the @emph{reverse} DAG of packages. For example:
  8896. @example
  8897. guix graph --type=reverse-package ocaml
  8898. @end example
  8899. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  8900. you are also interested in cases where OCaml is an implicit dependency, see
  8901. @code{reverse-bag} below).
  8902. Note that for core packages this can yield huge graphs. If all you want
  8903. is to know the number of packages that depend on a given package, use
  8904. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  8905. @option{--list-dependent}}).
  8906. @item bag-emerged
  8907. This is the package DAG, @emph{including} implicit inputs.
  8908. For instance, the following command:
  8909. @example
  8910. guix graph --type=bag-emerged coreutils
  8911. @end example
  8912. ...@: yields this bigger graph:
  8913. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  8914. At the bottom of the graph, we see all the implicit inputs of
  8915. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  8916. Now, note that the dependencies of these implicit inputs---that is, the
  8917. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  8918. here, for conciseness.
  8919. @item bag
  8920. Similar to @code{bag-emerged}, but this time including all the bootstrap
  8921. dependencies.
  8922. @item bag-with-origins
  8923. Similar to @code{bag}, but also showing origins and their dependencies.
  8924. @item reverse-bag
  8925. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  8926. it also takes implicit dependencies into account. For example:
  8927. @example
  8928. guix graph -t reverse-bag dune
  8929. @end example
  8930. @noindent
  8931. ...@: yields the graph of all packages that depend on Dune, directly or
  8932. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  8933. @i{via} @code{dune-build-system}, this shows a large number of packages,
  8934. whereas @code{reverse-package} would show very few if any.
  8935. @item derivation
  8936. This is the most detailed representation: It shows the DAG of
  8937. derivations (@pxref{Derivations}) and plain store items. Compared to
  8938. the above representation, many additional nodes are visible, including
  8939. build scripts, patches, Guile modules, etc.
  8940. For this type of graph, it is also possible to pass a @file{.drv} file
  8941. name instead of a package name, as in:
  8942. @example
  8943. guix graph -t derivation `guix system build -d my-config.scm`
  8944. @end example
  8945. @item module
  8946. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  8947. For example, the following command shows the graph for the package
  8948. module that defines the @code{guile} package:
  8949. @example
  8950. guix graph -t module guile | xdot -
  8951. @end example
  8952. @end table
  8953. All the types above correspond to @emph{build-time dependencies}. The
  8954. following graph type represents the @emph{run-time dependencies}:
  8955. @table @code
  8956. @item references
  8957. This is the graph of @dfn{references} of a package output, as returned
  8958. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  8959. If the given package output is not available in the store, @command{guix
  8960. graph} attempts to obtain dependency information from substitutes.
  8961. Here you can also pass a store file name instead of a package name. For
  8962. example, the command below produces the reference graph of your profile
  8963. (which can be big!):
  8964. @example
  8965. guix graph -t references `readlink -f ~/.guix-profile`
  8966. @end example
  8967. @item referrers
  8968. This is the graph of the @dfn{referrers} of a store item, as returned by
  8969. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  8970. This relies exclusively on local information from your store. For
  8971. instance, let us suppose that the current Inkscape is available in 10
  8972. profiles on your machine; @command{guix graph -t referrers inkscape}
  8973. will show a graph rooted at Inkscape and with those 10 profiles linked
  8974. to it.
  8975. It can help determine what is preventing a store item from being garbage
  8976. collected.
  8977. @end table
  8978. @cindex shortest path, between packages
  8979. Often, the graph of the package you are interested in does not fit on
  8980. your screen, and anyway all you want to know is @emph{why} that package
  8981. actually depends on some seemingly unrelated package. The
  8982. @option{--path} option instructs @command{guix graph} to display the
  8983. shortest path between two packages (or derivations, or store items,
  8984. etc.):
  8985. @example
  8986. $ guix graph --path emacs libunistring
  8987. emacs@@26.3
  8988. mailutils@@3.9
  8989. libunistring@@0.9.10
  8990. $ guix graph --path -t derivation emacs libunistring
  8991. /gnu/store/@dots{}-emacs-26.3.drv
  8992. /gnu/store/@dots{}-mailutils-3.9.drv
  8993. /gnu/store/@dots{}-libunistring-0.9.10.drv
  8994. $ guix graph --path -t references emacs libunistring
  8995. /gnu/store/@dots{}-emacs-26.3
  8996. /gnu/store/@dots{}-libidn2-2.2.0
  8997. /gnu/store/@dots{}-libunistring-0.9.10
  8998. @end example
  8999. The available options are the following:
  9000. @table @option
  9001. @item --type=@var{type}
  9002. @itemx -t @var{type}
  9003. Produce a graph output of @var{type}, where @var{type} must be one of
  9004. the values listed above.
  9005. @item --list-types
  9006. List the supported graph types.
  9007. @item --backend=@var{backend}
  9008. @itemx -b @var{backend}
  9009. Produce a graph using the selected @var{backend}.
  9010. @item --list-backends
  9011. List the supported graph backends.
  9012. Currently, the available backends are Graphviz and d3.js.
  9013. @item --path
  9014. Display the shortest path between two nodes of the type specified by
  9015. @option{--type}. The example below shows the shortest path between
  9016. @code{libreoffice} and @code{llvm} according to the references of
  9017. @code{libreoffice}:
  9018. @example
  9019. $ guix graph --path -t references libreoffice llvm
  9020. /gnu/store/@dots{}-libreoffice-6.4.2.2
  9021. /gnu/store/@dots{}-libepoxy-1.5.4
  9022. /gnu/store/@dots{}-mesa-19.3.4
  9023. /gnu/store/@dots{}-llvm-9.0.1
  9024. @end example
  9025. @item --expression=@var{expr}
  9026. @itemx -e @var{expr}
  9027. Consider the package @var{expr} evaluates to.
  9028. This is useful to precisely refer to a package, as in this example:
  9029. @example
  9030. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  9031. @end example
  9032. @item --system=@var{system}
  9033. @itemx -s @var{system}
  9034. Display the graph for @var{system}---e.g., @code{i686-linux}.
  9035. The package dependency graph is largely architecture-independent, but there
  9036. are some architecture-dependent bits that this option allows you to visualize.
  9037. @item --load-path=@var{directory}
  9038. @itemx -L @var{directory}
  9039. Add @var{directory} to the front of the package module search path
  9040. (@pxref{Package Modules}).
  9041. This allows users to define their own packages and make them visible to
  9042. the command-line tools.
  9043. @end table
  9044. On top of that, @command{guix graph} supports all the usual package
  9045. transformation options (@pxref{Package Transformation Options}). This
  9046. makes it easy to view the effect of a graph-rewriting transformation
  9047. such as @option{--with-input}. For example, the command below outputs
  9048. the graph of @code{git} once @code{openssl} has been replaced by
  9049. @code{libressl} everywhere in the graph:
  9050. @example
  9051. guix graph git --with-input=openssl=libressl
  9052. @end example
  9053. So many possibilities, so much fun!
  9054. @node Invoking guix publish
  9055. @section Invoking @command{guix publish}
  9056. @cindex @command{guix publish}
  9057. The purpose of @command{guix publish} is to enable users to easily share
  9058. their store with others, who can then use it as a substitute server
  9059. (@pxref{Substitutes}).
  9060. When @command{guix publish} runs, it spawns an HTTP server which allows
  9061. anyone with network access to obtain substitutes from it. This means
  9062. that any machine running Guix can also act as if it were a build farm,
  9063. since the HTTP interface is compatible with Cuirass, the software behind
  9064. the @code{@value{SUBSTITUTE-SERVER}} build farm.
  9065. For security, each substitute is signed, allowing recipients to check
  9066. their authenticity and integrity (@pxref{Substitutes}). Because
  9067. @command{guix publish} uses the signing key of the system, which is only
  9068. readable by the system administrator, it must be started as root; the
  9069. @option{--user} option makes it drop root privileges early on.
  9070. The signing key pair must be generated before @command{guix publish} is
  9071. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  9072. guix archive}).
  9073. The general syntax is:
  9074. @example
  9075. guix publish @var{options}@dots{}
  9076. @end example
  9077. Running @command{guix publish} without any additional arguments will
  9078. spawn an HTTP server on port 8080:
  9079. @example
  9080. guix publish
  9081. @end example
  9082. Once a publishing server has been authorized (@pxref{Invoking guix
  9083. archive}), the daemon may download substitutes from it:
  9084. @example
  9085. guix-daemon --substitute-urls=http://example.org:8080
  9086. @end example
  9087. By default, @command{guix publish} compresses archives on the fly as it
  9088. serves them. This ``on-the-fly'' mode is convenient in that it requires
  9089. no setup and is immediately available. However, when serving lots of
  9090. clients, we recommend using the @option{--cache} option, which enables
  9091. caching of the archives before they are sent to clients---see below for
  9092. details. The @command{guix weather} command provides a handy way to
  9093. check what a server provides (@pxref{Invoking guix weather}).
  9094. As a bonus, @command{guix publish} also serves as a content-addressed
  9095. mirror for source files referenced in @code{origin} records
  9096. (@pxref{origin Reference}). For instance, assuming @command{guix
  9097. publish} is running on @code{example.org}, the following URL returns the
  9098. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  9099. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  9100. @example
  9101. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  9102. @end example
  9103. Obviously, these URLs only work for files that are in the store; in
  9104. other cases, they return 404 (``Not Found'').
  9105. @cindex build logs, publication
  9106. Build logs are available from @code{/log} URLs like:
  9107. @example
  9108. http://example.org/log/gwspk@dots{}-guile-2.2.3
  9109. @end example
  9110. @noindent
  9111. When @command{guix-daemon} is configured to save compressed build logs,
  9112. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  9113. URLs return the compressed log as-is, with an appropriate
  9114. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  9115. running @command{guix-daemon} with @option{--log-compression=gzip} since
  9116. Web browsers can automatically decompress it, which is not the case with
  9117. Bzip2 compression.
  9118. The following options are available:
  9119. @table @code
  9120. @item --port=@var{port}
  9121. @itemx -p @var{port}
  9122. Listen for HTTP requests on @var{port}.
  9123. @item --listen=@var{host}
  9124. Listen on the network interface for @var{host}. The default is to
  9125. accept connections from any interface.
  9126. @item --user=@var{user}
  9127. @itemx -u @var{user}
  9128. Change privileges to @var{user} as soon as possible---i.e., once the
  9129. server socket is open and the signing key has been read.
  9130. @item --compression[=@var{method}[:@var{level}]]
  9131. @itemx -C [@var{method}[:@var{level}]]
  9132. Compress data using the given @var{method} and @var{level}. @var{method} is
  9133. one of @code{lzip} and @code{gzip}; when @var{method} is omitted, @code{gzip}
  9134. is used.
  9135. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  9136. to different compression levels: 1 is the fastest, and 9 is the best
  9137. (CPU-intensive). The default is 3.
  9138. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a small
  9139. increase in CPU usage; see
  9140. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip Web
  9141. page}.
  9142. Unless @option{--cache} is used, compression occurs on the fly and
  9143. the compressed streams are not
  9144. cached. Thus, to reduce load on the machine that runs @command{guix
  9145. publish}, it may be a good idea to choose a low compression level, to
  9146. run @command{guix publish} behind a caching proxy, or to use
  9147. @option{--cache}. Using @option{--cache} has the advantage that it
  9148. allows @command{guix publish} to add @code{Content-Length} HTTP header
  9149. to its responses.
  9150. This option can be repeated, in which case every substitute gets compressed
  9151. using all the selected methods, and all of them are advertised. This is
  9152. useful when users may not support all the compression methods: they can select
  9153. the one they support.
  9154. @item --cache=@var{directory}
  9155. @itemx -c @var{directory}
  9156. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  9157. and only serve archives that are in cache.
  9158. When this option is omitted, archives and meta-data are created
  9159. on-the-fly. This can reduce the available bandwidth, especially when
  9160. compression is enabled, since this may become CPU-bound. Another
  9161. drawback of the default mode is that the length of archives is not known
  9162. in advance, so @command{guix publish} does not add a
  9163. @code{Content-Length} HTTP header to its responses, which in turn
  9164. prevents clients from knowing the amount of data being downloaded.
  9165. Conversely, when @option{--cache} is used, the first request for a store
  9166. item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
  9167. background process to @dfn{bake} the archive---computing its
  9168. @code{.narinfo} and compressing the archive, if needed. Once the
  9169. archive is cached in @var{directory}, subsequent requests succeed and
  9170. are served directly from the cache, which guarantees that clients get
  9171. the best possible bandwidth.
  9172. The ``baking'' process is performed by worker threads. By default, one
  9173. thread per CPU core is created, but this can be customized. See
  9174. @option{--workers} below.
  9175. When @option{--ttl} is used, cached entries are automatically deleted
  9176. when they have expired.
  9177. @item --workers=@var{N}
  9178. When @option{--cache} is used, request the allocation of @var{N} worker
  9179. threads to ``bake'' archives.
  9180. @item --ttl=@var{ttl}
  9181. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  9182. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  9183. days, @code{1m} means 1 month, and so on.
  9184. This allows the user's Guix to keep substitute information in cache for
  9185. @var{ttl}. However, note that @code{guix publish} does not itself
  9186. guarantee that the store items it provides will indeed remain available
  9187. for as long as @var{ttl}.
  9188. Additionally, when @option{--cache} is used, cached entries that have
  9189. not been accessed for @var{ttl} and that no longer have a corresponding
  9190. item in the store, may be deleted.
  9191. @item --nar-path=@var{path}
  9192. Use @var{path} as the prefix for the URLs of ``nar'' files
  9193. (@pxref{Invoking guix archive, normalized archives}).
  9194. By default, nars are served at a URL such as
  9195. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  9196. change the @code{/nar} part to @var{path}.
  9197. @item --public-key=@var{file}
  9198. @itemx --private-key=@var{file}
  9199. Use the specific @var{file}s as the public/private key pair used to sign
  9200. the store items being published.
  9201. The files must correspond to the same key pair (the private key is used
  9202. for signing and the public key is merely advertised in the signature
  9203. metadata). They must contain keys in the canonical s-expression format
  9204. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  9205. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  9206. @file{/etc/guix/signing-key.sec} are used.
  9207. @item --repl[=@var{port}]
  9208. @itemx -r [@var{port}]
  9209. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  9210. Reference Manual}) on @var{port} (37146 by default). This is used
  9211. primarily for debugging a running @command{guix publish} server.
  9212. @end table
  9213. Enabling @command{guix publish} on Guix System is a one-liner: just
  9214. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  9215. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  9216. @code{guix-publish-service-type}}).
  9217. If you are instead running Guix on a ``foreign distro'', follow these
  9218. instructions:
  9219. @itemize
  9220. @item
  9221. If your host distro uses the systemd init system:
  9222. @example
  9223. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  9224. /etc/systemd/system/
  9225. # systemctl start guix-publish && systemctl enable guix-publish
  9226. @end example
  9227. @item
  9228. If your host distro uses the Upstart init system:
  9229. @example
  9230. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  9231. # start guix-publish
  9232. @end example
  9233. @item
  9234. Otherwise, proceed similarly with your distro's init system.
  9235. @end itemize
  9236. @node Invoking guix challenge
  9237. @section Invoking @command{guix challenge}
  9238. @cindex reproducible builds
  9239. @cindex verifiable builds
  9240. @cindex @command{guix challenge}
  9241. @cindex challenge
  9242. Do the binaries provided by this server really correspond to the source
  9243. code it claims to build? Is a package build process deterministic?
  9244. These are the questions the @command{guix challenge} command attempts to
  9245. answer.
  9246. The former is obviously an important question: Before using a substitute
  9247. server (@pxref{Substitutes}), one had better @emph{verify} that it
  9248. provides the right binaries, and thus @emph{challenge} it. The latter
  9249. is what enables the former: If package builds are deterministic, then
  9250. independent builds of the package should yield the exact same result,
  9251. bit for bit; if a server provides a binary different from the one
  9252. obtained locally, it may be either corrupt or malicious.
  9253. We know that the hash that shows up in @file{/gnu/store} file names is
  9254. the hash of all the inputs of the process that built the file or
  9255. directory---compilers, libraries, build scripts,
  9256. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  9257. one store file name should map to exactly one build output.
  9258. @command{guix challenge} checks whether there is, indeed, a single
  9259. mapping by comparing the build outputs of several independent builds of
  9260. any given store item.
  9261. The command output looks like this:
  9262. @smallexample
  9263. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  9264. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
  9265. updating list of substitutes from 'https://guix.example.org'... 100.0%
  9266. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  9267. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  9268. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  9269. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  9270. differing files:
  9271. /lib/libcrypto.so.1.1
  9272. /lib/libssl.so.1.1
  9273. /gnu/store/@dots{}-git-2.5.0 contents differ:
  9274. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  9275. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  9276. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  9277. differing file:
  9278. /libexec/git-core/git-fsck
  9279. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  9280. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  9281. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  9282. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  9283. differing file:
  9284. /share/man/man1/pius.1.gz
  9285. @dots{}
  9286. 6,406 store items were analyzed:
  9287. - 4,749 (74.1%) were identical
  9288. - 525 (8.2%) differed
  9289. - 1,132 (17.7%) were inconclusive
  9290. @end smallexample
  9291. @noindent
  9292. In this example, @command{guix challenge} first scans the store to
  9293. determine the set of locally-built derivations---as opposed to store
  9294. items that were downloaded from a substitute server---and then queries
  9295. all the substitute servers. It then reports those store items for which
  9296. the servers obtained a result different from the local build.
  9297. @cindex non-determinism, in package builds
  9298. As an example, @code{guix.example.org} always gets a different answer.
  9299. Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
  9300. case of Git. This might indicate that the build process of Git is
  9301. non-deterministic, meaning that its output varies as a function of
  9302. various things that Guix does not fully control, in spite of building
  9303. packages in isolated environments (@pxref{Features}). Most common
  9304. sources of non-determinism include the addition of timestamps in build
  9305. results, the inclusion of random numbers, and directory listings sorted
  9306. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  9307. more information.
  9308. To find out what is wrong with this Git binary, the easiest approach is
  9309. to run:
  9310. @example
  9311. guix challenge git \
  9312. --diff=diffoscope \
  9313. --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  9314. @end example
  9315. This automatically invokes @command{diffoscope}, which displays detailed
  9316. information about files that differ.
  9317. Alternatively, we can do something along these lines (@pxref{Invoking guix
  9318. archive}):
  9319. @example
  9320. $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-git-2.5.0 \
  9321. | lzip -d | guix archive -x /tmp/git
  9322. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  9323. @end example
  9324. This command shows the difference between the files resulting from the
  9325. local build, and the files resulting from the build on
  9326. @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
  9327. diffutils, Comparing and Merging Files}). The @command{diff} command
  9328. works great for text files. When binary files differ, a better option
  9329. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  9330. visualize differences for all kinds of files.
  9331. Once you have done that work, you can tell whether the differences are due
  9332. to a non-deterministic build process or to a malicious server. We try
  9333. hard to remove sources of non-determinism in packages to make it easier
  9334. to verify substitutes, but of course, this is a process that
  9335. involves not just Guix, but a large part of the free software community.
  9336. In the meantime, @command{guix challenge} is one tool to help address
  9337. the problem.
  9338. If you are writing packages for Guix, you are encouraged to check
  9339. whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
  9340. same build result as you did with:
  9341. @example
  9342. $ guix challenge @var{package}
  9343. @end example
  9344. @noindent
  9345. where @var{package} is a package specification such as
  9346. @code{guile@@2.0} or @code{glibc:debug}.
  9347. The general syntax is:
  9348. @example
  9349. guix challenge @var{options} [@var{packages}@dots{}]
  9350. @end example
  9351. When a difference is found between the hash of a locally-built item and
  9352. that of a server-provided substitute, or among substitutes provided by
  9353. different servers, the command displays it as in the example above and
  9354. its exit code is 2 (other non-zero exit codes denote other kinds of
  9355. errors).
  9356. The one option that matters is:
  9357. @table @code
  9358. @item --substitute-urls=@var{urls}
  9359. Consider @var{urls} the whitespace-separated list of substitute source
  9360. URLs to compare to.
  9361. @item --diff=@var{mode}
  9362. Upon mismatches, show differences according to @var{mode}, one of:
  9363. @table @asis
  9364. @item @code{simple} (the default)
  9365. Show the list of files that differ.
  9366. @item @code{diffoscope}
  9367. @itemx @var{command}
  9368. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  9369. two directories whose contents do not match.
  9370. When @var{command} is an absolute file name, run @var{command} instead
  9371. of Diffoscope.
  9372. @item @code{none}
  9373. Do not show further details about the differences.
  9374. @end table
  9375. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  9376. downloads the store items from the given substitute servers so that it
  9377. can compare them.
  9378. @item --verbose
  9379. @itemx -v
  9380. Show details about matches (identical contents) in addition to
  9381. information about mismatches.
  9382. @end table
  9383. @node Invoking guix copy
  9384. @section Invoking @command{guix copy}
  9385. @cindex copy, of store items, over SSH
  9386. @cindex SSH, copy of store items
  9387. @cindex sharing store items across machines
  9388. @cindex transferring store items across machines
  9389. The @command{guix copy} command copies items from the store of one
  9390. machine to that of another machine over a secure shell (SSH)
  9391. connection@footnote{This command is available only when Guile-SSH was
  9392. found. @xref{Requirements}, for details.}. For example, the following
  9393. command copies the @code{coreutils} package, the user's profile, and all
  9394. their dependencies over to @var{host}, logged in as @var{user}:
  9395. @example
  9396. guix copy --to=@var{user}@@@var{host} \
  9397. coreutils `readlink -f ~/.guix-profile`
  9398. @end example
  9399. If some of the items to be copied are already present on @var{host},
  9400. they are not actually sent.
  9401. The command below retrieves @code{libreoffice} and @code{gimp} from
  9402. @var{host}, assuming they are available there:
  9403. @example
  9404. guix copy --from=@var{host} libreoffice gimp
  9405. @end example
  9406. The SSH connection is established using the Guile-SSH client, which is
  9407. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  9408. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  9409. The key used to sign items that are sent must be accepted by the remote
  9410. machine. Likewise, the key used by the remote machine to sign items you
  9411. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  9412. own daemon. @xref{Invoking guix archive}, for more information about
  9413. store item authentication.
  9414. The general syntax is:
  9415. @example
  9416. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  9417. @end example
  9418. You must always specify one of the following options:
  9419. @table @code
  9420. @item --to=@var{spec}
  9421. @itemx --from=@var{spec}
  9422. Specify the host to send to or receive from. @var{spec} must be an SSH
  9423. spec such as @code{example.org}, @code{charlie@@example.org}, or
  9424. @code{charlie@@example.org:2222}.
  9425. @end table
  9426. The @var{items} can be either package names, such as @code{gimp}, or
  9427. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  9428. When specifying the name of a package to send, it is first built if
  9429. needed, unless @option{--dry-run} was specified. Common build options
  9430. are supported (@pxref{Common Build Options}).
  9431. @node Invoking guix container
  9432. @section Invoking @command{guix container}
  9433. @cindex container
  9434. @cindex @command{guix container}
  9435. @quotation Note
  9436. As of version @value{VERSION}, this tool is experimental. The interface
  9437. is subject to radical change in the future.
  9438. @end quotation
  9439. The purpose of @command{guix container} is to manipulate processes
  9440. running within an isolated environment, commonly known as a
  9441. ``container'', typically created by the @command{guix environment}
  9442. (@pxref{Invoking guix environment}) and @command{guix system container}
  9443. (@pxref{Invoking guix system}) commands.
  9444. The general syntax is:
  9445. @example
  9446. guix container @var{action} @var{options}@dots{}
  9447. @end example
  9448. @var{action} specifies the operation to perform with a container, and
  9449. @var{options} specifies the context-specific arguments for the action.
  9450. The following actions are available:
  9451. @table @code
  9452. @item exec
  9453. Execute a command within the context of a running container.
  9454. The syntax is:
  9455. @example
  9456. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  9457. @end example
  9458. @var{pid} specifies the process ID of the running container.
  9459. @var{program} specifies an executable file name within the root file
  9460. system of the container. @var{arguments} are the additional options that
  9461. will be passed to @var{program}.
  9462. The following command launches an interactive login shell inside a
  9463. Guix system container, started by @command{guix system container}, and whose
  9464. process ID is 9001:
  9465. @example
  9466. guix container exec 9001 /run/current-system/profile/bin/bash --login
  9467. @end example
  9468. Note that the @var{pid} cannot be the parent process of a container. It
  9469. must be PID 1 of the container or one of its child processes.
  9470. @end table
  9471. @node Invoking guix weather
  9472. @section Invoking @command{guix weather}
  9473. Occasionally you're grumpy because substitutes are lacking and you end
  9474. up building packages by yourself (@pxref{Substitutes}). The
  9475. @command{guix weather} command reports on substitute availability on the
  9476. specified servers so you can have an idea of whether you'll be grumpy
  9477. today. It can sometimes be useful info as a user, but it is primarily
  9478. useful to people running @command{guix publish} (@pxref{Invoking guix
  9479. publish}).
  9480. @cindex statistics, for substitutes
  9481. @cindex availability of substitutes
  9482. @cindex substitute availability
  9483. @cindex weather, substitute availability
  9484. Here's a sample run:
  9485. @example
  9486. $ guix weather --substitute-urls=https://guix.example.org
  9487. computing 5,872 package derivations for x86_64-linux...
  9488. looking for 6,128 store items on https://guix.example.org..
  9489. updating list of substitutes from 'https://guix.example.org'... 100.0%
  9490. https://guix.example.org
  9491. 43.4% substitutes available (2,658 out of 6,128)
  9492. 7,032.5 MiB of nars (compressed)
  9493. 19,824.2 MiB on disk (uncompressed)
  9494. 0.030 seconds per request (182.9 seconds in total)
  9495. 33.5 requests per second
  9496. 9.8% (342 out of 3,470) of the missing items are queued
  9497. 867 queued builds
  9498. x86_64-linux: 518 (59.7%)
  9499. i686-linux: 221 (25.5%)
  9500. aarch64-linux: 128 (14.8%)
  9501. build rate: 23.41 builds per hour
  9502. x86_64-linux: 11.16 builds per hour
  9503. i686-linux: 6.03 builds per hour
  9504. aarch64-linux: 6.41 builds per hour
  9505. @end example
  9506. @cindex continuous integration, statistics
  9507. As you can see, it reports the fraction of all the packages for which
  9508. substitutes are available on the server---regardless of whether
  9509. substitutes are enabled, and regardless of whether this server's signing
  9510. key is authorized. It also reports the size of the compressed archives
  9511. (``nars'') provided by the server, the size the corresponding store
  9512. items occupy in the store (assuming deduplication is turned off), and
  9513. the server's throughput. The second part gives continuous integration
  9514. (CI) statistics, if the server supports it. In addition, using the
  9515. @option{--coverage} option, @command{guix weather} can list ``important''
  9516. package substitutes missing on the server (see below).
  9517. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  9518. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  9519. challenge}, it ignores signatures on those substitutes, which is
  9520. innocuous since the command only gathers statistics and cannot install
  9521. those substitutes.
  9522. The general syntax is:
  9523. @example
  9524. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  9525. @end example
  9526. When @var{packages} is omitted, @command{guix weather} checks the availability
  9527. of substitutes for @emph{all} the packages, or for those specified with
  9528. @option{--manifest}; otherwise it only considers the specified packages. It
  9529. is also possible to query specific system types with @option{--system}.
  9530. @command{guix weather} exits with a non-zero code when the fraction of
  9531. available substitutes is below 100%.
  9532. The available options are listed below.
  9533. @table @code
  9534. @item --substitute-urls=@var{urls}
  9535. @var{urls} is the space-separated list of substitute server URLs to
  9536. query. When this option is omitted, the default set of substitute
  9537. servers is queried.
  9538. @item --system=@var{system}
  9539. @itemx -s @var{system}
  9540. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  9541. option can be repeated, in which case @command{guix weather} will query
  9542. substitutes for several system types.
  9543. @item --manifest=@var{file}
  9544. Instead of querying substitutes for all the packages, only ask for those
  9545. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  9546. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  9547. guix package}).
  9548. This option can be repeated several times, in which case the manifests
  9549. are concatenated.
  9550. @item --coverage[=@var{count}]
  9551. @itemx -c [@var{count}]
  9552. Report on substitute coverage for packages: list packages with at least
  9553. @var{count} dependents (zero by default) for which substitutes are
  9554. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  9555. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  9556. @var{b} usually lacks substitutes as well. The result looks like this:
  9557. @example
  9558. $ guix weather --substitute-urls=@value{SUBSTITUTE-URL} -c 10
  9559. computing 8,983 package derivations for x86_64-linux...
  9560. looking for 9,343 store items on @value{SUBSTITUTE-URL}...
  9561. updating substitutes from '@value{SUBSTITUTE-URL}'... 100.0%
  9562. @value{SUBSTITUTE-URL}
  9563. 64.7% substitutes available (6,047 out of 9,343)
  9564. @dots{}
  9565. 2502 packages are missing from '@value{SUBSTITUTE-URL}' for 'x86_64-linux', among which:
  9566. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  9567. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  9568. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  9569. @dots{}
  9570. @end example
  9571. What this example shows is that @code{kcoreaddons} and presumably the 58
  9572. packages that depend on it have no substitutes at @code{ci.guix.info};
  9573. likewise for @code{qgpgme} and the 46 packages that depend on it.
  9574. If you are a Guix developer, or if you are taking care of this build farm,
  9575. you'll probably want to have a closer look at these packages: they may simply
  9576. fail to build.
  9577. @item --display-missing
  9578. Display the list of store items for which substitutes are missing.
  9579. @end table
  9580. @node Invoking guix processes
  9581. @section Invoking @command{guix processes}
  9582. The @command{guix processes} command can be useful to developers and system
  9583. administrators, especially on multi-user machines and on build farms: it lists
  9584. the current sessions (connections to the daemon), as well as information about
  9585. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  9586. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  9587. listed.}. Here's an example of the information it returns:
  9588. @example
  9589. $ sudo guix processes
  9590. SessionPID: 19002
  9591. ClientPID: 19090
  9592. ClientCommand: guix environment --ad-hoc python
  9593. SessionPID: 19402
  9594. ClientPID: 19367
  9595. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  9596. SessionPID: 19444
  9597. ClientPID: 19419
  9598. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  9599. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  9600. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  9601. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  9602. ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
  9603. ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
  9604. ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
  9605. @end example
  9606. In this example we see that @command{guix-daemon} has three clients:
  9607. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  9608. integration tool; their process identifier (PID) is given by the
  9609. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  9610. @command{guix-daemon} sub-process of this particular session.
  9611. The @code{LockHeld} fields show which store items are currently locked by this
  9612. session, which corresponds to store items being built or substituted (the
  9613. @code{LockHeld} field is not displayed when @command{guix processes} is not
  9614. running as root). Last, by looking at the @code{ChildProcess} field, we
  9615. understand that these three builds are being offloaded (@pxref{Daemon Offload
  9616. Setup}).
  9617. The output is in Recutils format so we can use the handy @command{recsel}
  9618. command to select sessions of interest (@pxref{Selection Expressions,,,
  9619. recutils, GNU recutils manual}). As an example, the command shows the command
  9620. line and PID of the client that triggered the build of a Perl package:
  9621. @example
  9622. $ sudo guix processes | \
  9623. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  9624. ClientPID: 19419
  9625. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  9626. @end example
  9627. @node System Configuration
  9628. @chapter System Configuration
  9629. @cindex system configuration
  9630. Guix System supports a consistent whole-system configuration
  9631. mechanism. By that we mean that all aspects of the global system
  9632. configuration---such as the available system services, timezone and
  9633. locale settings, user accounts---are declared in a single place. Such
  9634. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  9635. One of the advantages of putting all the system configuration under the
  9636. control of Guix is that it supports transactional system upgrades, and
  9637. makes it possible to roll back to a previous system instantiation,
  9638. should something go wrong with the new one (@pxref{Features}). Another
  9639. advantage is that it makes it easy to replicate the exact same configuration
  9640. across different machines, or at different points in time, without
  9641. having to resort to additional administration tools layered on top of
  9642. the own tools of the system.
  9643. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  9644. This section describes this mechanism. First we focus on the system
  9645. administrator's viewpoint---explaining how the system is configured and
  9646. instantiated. Then we show how this mechanism can be extended, for
  9647. instance to support new system services.
  9648. @menu
  9649. * Using the Configuration System:: Customizing your GNU system.
  9650. * operating-system Reference:: Detail of operating-system declarations.
  9651. * File Systems:: Configuring file system mounts.
  9652. * Mapped Devices:: Block device extra processing.
  9653. * User Accounts:: Specifying user accounts.
  9654. * Keyboard Layout:: How the system interprets key strokes.
  9655. * Locales:: Language and cultural convention settings.
  9656. * Services:: Specifying system services.
  9657. * Setuid Programs:: Programs running with root privileges.
  9658. * X.509 Certificates:: Authenticating HTTPS servers.
  9659. * Name Service Switch:: Configuring libc's name service switch.
  9660. * Initial RAM Disk:: Linux-Libre bootstrapping.
  9661. * Bootloader Configuration:: Configuring the boot loader.
  9662. * Invoking guix system:: Instantiating a system configuration.
  9663. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  9664. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  9665. * Defining Services:: Adding new service definitions.
  9666. @end menu
  9667. @node Using the Configuration System
  9668. @section Using the Configuration System
  9669. The operating system is configured by providing an
  9670. @code{operating-system} declaration in a file that can then be passed to
  9671. the @command{guix system} command (@pxref{Invoking guix system}). A
  9672. simple setup, with the default system services, the default Linux-Libre
  9673. kernel, initial RAM disk, and boot loader looks like this:
  9674. @findex operating-system
  9675. @lisp
  9676. @include os-config-bare-bones.texi
  9677. @end lisp
  9678. This example should be self-describing. Some of the fields defined
  9679. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  9680. Others, such as @code{packages} and @code{services}, can be omitted, in
  9681. which case they get a default value.
  9682. Below we discuss the effect of some of the most important fields
  9683. (@pxref{operating-system Reference}, for details about all the available
  9684. fields), and how to @dfn{instantiate} the operating system using
  9685. @command{guix system}.
  9686. @unnumberedsubsec Bootloader
  9687. @cindex legacy boot, on Intel machines
  9688. @cindex BIOS boot, on Intel machines
  9689. @cindex UEFI boot
  9690. @cindex EFI boot
  9691. The @code{bootloader} field describes the method that will be used to boot
  9692. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  9693. mode, as in the example above. However, more recent machines rely instead on
  9694. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  9695. the @code{bootloader} field should contain something along these lines:
  9696. @lisp
  9697. (bootloader-configuration
  9698. (bootloader grub-efi-bootloader)
  9699. (target "/boot/efi"))
  9700. @end lisp
  9701. @xref{Bootloader Configuration}, for more information on the available
  9702. configuration options.
  9703. @unnumberedsubsec Globally-Visible Packages
  9704. @vindex %base-packages
  9705. The @code{packages} field lists packages that will be globally visible
  9706. on the system, for all user accounts---i.e., in every user's @env{PATH}
  9707. environment variable---in addition to the per-user profiles
  9708. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  9709. provides all the tools one would expect for basic user and administrator
  9710. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  9711. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  9712. etc. The example above adds GNU@tie{}Screen to those,
  9713. taken from the @code{(gnu packages screen)}
  9714. module (@pxref{Package Modules}). The
  9715. @code{(list package output)} syntax can be used to add a specific output
  9716. of a package:
  9717. @lisp
  9718. (use-modules (gnu packages))
  9719. (use-modules (gnu packages dns))
  9720. (operating-system
  9721. ;; ...
  9722. (packages (cons (list bind "utils")
  9723. %base-packages)))
  9724. @end lisp
  9725. @findex specification->package
  9726. Referring to packages by variable name, like @code{bind} above, has
  9727. the advantage of being unambiguous; it also allows typos and such to be
  9728. diagnosed right away as ``unbound variables''. The downside is that one
  9729. needs to know which module defines which package, and to augment the
  9730. @code{use-package-modules} line accordingly. To avoid that, one can use
  9731. the @code{specification->package} procedure of the @code{(gnu packages)}
  9732. module, which returns the best package for a given name or name and
  9733. version:
  9734. @lisp
  9735. (use-modules (gnu packages))
  9736. (operating-system
  9737. ;; ...
  9738. (packages (append (map specification->package
  9739. '("tcpdump" "htop" "gnupg@@2.0"))
  9740. %base-packages)))
  9741. @end lisp
  9742. @unnumberedsubsec System Services
  9743. @cindex services
  9744. @vindex %base-services
  9745. The @code{services} field lists @dfn{system services} to be made
  9746. available when the system starts (@pxref{Services}).
  9747. The @code{operating-system} declaration above specifies that, in
  9748. addition to the basic services, we want the OpenSSH secure shell
  9749. daemon listening on port 2222 (@pxref{Networking Services,
  9750. @code{openssh-service-type}}). Under the hood,
  9751. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  9752. right command-line options, possibly with supporting configuration files
  9753. generated as needed (@pxref{Defining Services}).
  9754. @cindex customization, of services
  9755. @findex modify-services
  9756. Occasionally, instead of using the base services as is, you will want to
  9757. customize them. To do this, use @code{modify-services} (@pxref{Service
  9758. Reference, @code{modify-services}}) to modify the list.
  9759. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  9760. (the console log-in) in the @code{%base-services} list (@pxref{Base
  9761. Services, @code{%base-services}}). To do that, you can write the
  9762. following in your operating system declaration:
  9763. @lisp
  9764. (define %my-services
  9765. ;; My very own list of services.
  9766. (modify-services %base-services
  9767. (guix-service-type config =>
  9768. (guix-configuration
  9769. (inherit config)
  9770. ;; Fetch substitutes from example.org.
  9771. (substitute-urls
  9772. (list "https://example.org/guix"
  9773. "https://ci.guix.gnu.org"))))
  9774. (mingetty-service-type config =>
  9775. (mingetty-configuration
  9776. (inherit config)
  9777. ;; Automatially log in as "guest".
  9778. (auto-login "guest")))))
  9779. (operating-system
  9780. ;; @dots{}
  9781. (services %my-services))
  9782. @end lisp
  9783. This changes the configuration---i.e., the service parameters---of the
  9784. @code{guix-service-type} instance, and that of all the
  9785. @code{mingetty-service-type} instances in the @code{%base-services} list.
  9786. Observe how this is accomplished: first, we arrange for the original
  9787. configuration to be bound to the identifier @code{config} in the
  9788. @var{body}, and then we write the @var{body} so that it evaluates to the
  9789. desired configuration. In particular, notice how we use @code{inherit}
  9790. to create a new configuration which has the same values as the old
  9791. configuration, but with a few modifications.
  9792. @cindex encrypted disk
  9793. The configuration for a typical ``desktop'' usage, with an encrypted
  9794. root partition, the X11 display
  9795. server, GNOME and Xfce (users can choose which of these desktop
  9796. environments to use at the log-in screen by pressing @kbd{F1}), network
  9797. management, power management, and more, would look like this:
  9798. @lisp
  9799. @include os-config-desktop.texi
  9800. @end lisp
  9801. A graphical system with a choice of lightweight window managers
  9802. instead of full-blown desktop environments would look like this:
  9803. @lisp
  9804. @include os-config-lightweight-desktop.texi
  9805. @end lisp
  9806. This example refers to the @file{/boot/efi} file system by its UUID,
  9807. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  9808. as returned by the @command{blkid} command.
  9809. @xref{Desktop Services}, for the exact list of services provided by
  9810. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  9811. information about the @code{nss-certs} package that is used here.
  9812. Again, @code{%desktop-services} is just a list of service objects. If
  9813. you want to remove services from there, you can do so using the
  9814. procedures for list filtering (@pxref{SRFI-1 Filtering and
  9815. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  9816. following expression returns a list that contains all the services in
  9817. @code{%desktop-services} minus the Avahi service:
  9818. @lisp
  9819. (remove (lambda (service)
  9820. (eq? (service-kind service) avahi-service-type))
  9821. %desktop-services)
  9822. @end lisp
  9823. @unnumberedsubsec Instantiating the System
  9824. Assuming the @code{operating-system} declaration
  9825. is stored in the @file{my-system-config.scm}
  9826. file, the @command{guix system reconfigure my-system-config.scm} command
  9827. instantiates that configuration, and makes it the default GRUB boot
  9828. entry (@pxref{Invoking guix system}).
  9829. The normal way to change the system configuration is by updating this
  9830. file and re-running @command{guix system reconfigure}. One should never
  9831. have to touch files in @file{/etc} or to run commands that modify the
  9832. system state such as @command{useradd} or @command{grub-install}. In
  9833. fact, you must avoid that since that would not only void your warranty
  9834. but also prevent you from rolling back to previous versions of your
  9835. system, should you ever need to.
  9836. @cindex roll-back, of the operating system
  9837. Speaking of roll-back, each time you run @command{guix system
  9838. reconfigure}, a new @dfn{generation} of the system is created---without
  9839. modifying or deleting previous generations. Old system generations get
  9840. an entry in the bootloader boot menu, allowing you to boot them in case
  9841. something went wrong with the latest generation. Reassuring, no? The
  9842. @command{guix system list-generations} command lists the system
  9843. generations available on disk. It is also possible to roll back the
  9844. system via the commands @command{guix system roll-back} and
  9845. @command{guix system switch-generation}.
  9846. Although the @command{guix system reconfigure} command will not modify
  9847. previous generations, you must take care when the current generation is not
  9848. the latest (e.g., after invoking @command{guix system roll-back}), since
  9849. the operation might overwrite a later generation (@pxref{Invoking guix
  9850. system}).
  9851. @unnumberedsubsec The Programming Interface
  9852. At the Scheme level, the bulk of an @code{operating-system} declaration
  9853. is instantiated with the following monadic procedure (@pxref{The Store
  9854. Monad}):
  9855. @deffn {Monadic Procedure} operating-system-derivation os
  9856. Return a derivation that builds @var{os}, an @code{operating-system}
  9857. object (@pxref{Derivations}).
  9858. The output of the derivation is a single directory that refers to all
  9859. the packages, configuration files, and other supporting files needed to
  9860. instantiate @var{os}.
  9861. @end deffn
  9862. This procedure is provided by the @code{(gnu system)} module. Along
  9863. with @code{(gnu services)} (@pxref{Services}), this module contains the
  9864. guts of Guix System. Make sure to visit it!
  9865. @node operating-system Reference
  9866. @section @code{operating-system} Reference
  9867. This section summarizes all the options available in
  9868. @code{operating-system} declarations (@pxref{Using the Configuration
  9869. System}).
  9870. @deftp {Data Type} operating-system
  9871. This is the data type representing an operating system configuration.
  9872. By that, we mean all the global system configuration, not per-user
  9873. configuration (@pxref{Using the Configuration System}).
  9874. @table @asis
  9875. @item @code{kernel} (default: @code{linux-libre})
  9876. The package object of the operating system kernel to
  9877. use@footnote{Currently only the Linux-libre kernel is fully supported.
  9878. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  9879. available when building a virtual machine disk image.}.
  9880. @cindex hurd
  9881. @item @code{hurd} (default: @code{#f})
  9882. The package object of the hurd to be started by the kernel. When this
  9883. field is set, produce a GNU/Hurd operating system. In that case,
  9884. @code{kernel} must also be set to the @code{gnumach} package---the
  9885. microkernel the Hurd runs on.
  9886. @quotation Warning
  9887. This feature is experimental and only supported for disk images.
  9888. @end quotation
  9889. @item @code{kernel-loadable-modules} (default: '())
  9890. A list of objects (usually packages) to collect loadable kernel modules
  9891. from--e.g. @code{(list ddcci-driver-linux)}.
  9892. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  9893. List of strings or gexps representing additional arguments to pass on
  9894. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  9895. @item @code{bootloader}
  9896. The system bootloader configuration object. @xref{Bootloader Configuration}.
  9897. @item @code{label}
  9898. This is the label (a string) as it appears in the bootloader's menu entry.
  9899. The default label includes the kernel name and version.
  9900. @item @code{keyboard-layout} (default: @code{#f})
  9901. This field specifies the keyboard layout to use in the console. It can be
  9902. either @code{#f}, in which case the default keyboard layout is used (usually
  9903. US English), or a @code{<keyboard-layout>} record.
  9904. This keyboard layout is in effect as soon as the kernel has booted. For
  9905. instance, it is the keyboard layout in effect when you type a passphrase if
  9906. your root file system is on a @code{luks-device-mapping} mapped device
  9907. (@pxref{Mapped Devices}).
  9908. @quotation Note
  9909. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  9910. that used by the graphical display server. @xref{Bootloader Configuration},
  9911. for information on how to specify the bootloader's keyboard layout. @xref{X
  9912. Window}, for information on how to specify the keyboard layout used by the X
  9913. Window System.
  9914. @end quotation
  9915. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  9916. @cindex initrd
  9917. @cindex initial RAM disk
  9918. The list of Linux kernel modules that need to be available in the
  9919. initial RAM disk. @xref{Initial RAM Disk}.
  9920. @item @code{initrd} (default: @code{base-initrd})
  9921. A procedure that returns an initial RAM disk for the Linux
  9922. kernel. This field is provided to support low-level customization and
  9923. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  9924. @item @code{firmware} (default: @code{%base-firmware})
  9925. @cindex firmware
  9926. List of firmware packages loadable by the operating system kernel.
  9927. The default includes firmware needed for Atheros- and Broadcom-based
  9928. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  9929. respectively). @xref{Hardware Considerations}, for more info on
  9930. supported hardware.
  9931. @item @code{host-name}
  9932. The host name.
  9933. @item @code{hosts-file}
  9934. @cindex hosts file
  9935. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  9936. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  9937. Reference Manual}). The default is a file with entries for
  9938. @code{localhost} and @var{host-name}.
  9939. @item @code{mapped-devices} (default: @code{'()})
  9940. A list of mapped devices. @xref{Mapped Devices}.
  9941. @item @code{file-systems}
  9942. A list of file systems. @xref{File Systems}.
  9943. @item @code{swap-devices} (default: @code{'()})
  9944. @cindex swap devices
  9945. A list of strings identifying devices or files to be used for ``swap
  9946. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  9947. Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
  9948. It is possible to specify a swap file in a file system on a mapped
  9949. device, provided that the necessary device mapping and file system are
  9950. also specified. @xref{Mapped Devices} and @ref{File Systems}.
  9951. @item @code{users} (default: @code{%base-user-accounts})
  9952. @itemx @code{groups} (default: @code{%base-groups})
  9953. List of user accounts and groups. @xref{User Accounts}.
  9954. If the @code{users} list lacks a user account with UID@tie{}0, a
  9955. ``root'' account with UID@tie{}0 is automatically added.
  9956. @item @code{skeletons} (default: @code{(default-skeletons)})
  9957. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  9958. file-like objects}). These are the skeleton files that will be added to
  9959. the home directory of newly-created user accounts.
  9960. For instance, a valid value may look like this:
  9961. @lisp
  9962. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  9963. (".guile" ,(plain-file "guile"
  9964. "(use-modules (ice-9 readline))
  9965. (activate-readline)")))
  9966. @end lisp
  9967. @item @code{issue} (default: @code{%default-issue})
  9968. A string denoting the contents of the @file{/etc/issue} file, which is
  9969. displayed when users log in on a text console.
  9970. @item @code{packages} (default: @code{%base-packages})
  9971. A list of packages to be installed in the global profile, which is accessible
  9972. at @file{/run/current-system/profile}. Each element is either a package
  9973. variable or a package/output tuple. Here's a simple example of both:
  9974. @lisp
  9975. (cons* git ; the default "out" output
  9976. (list git "send-email") ; another output of git
  9977. %base-packages) ; the default set
  9978. @end lisp
  9979. The default set includes core utilities and it is good practice to
  9980. install non-core utilities in user profiles (@pxref{Invoking guix
  9981. package}).
  9982. @item @code{timezone}
  9983. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  9984. You can run the @command{tzselect} command to find out which timezone
  9985. string corresponds to your region. Choosing an invalid timezone name
  9986. causes @command{guix system} to fail.
  9987. @item @code{locale} (default: @code{"en_US.utf8"})
  9988. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  9989. Library Reference Manual}). @xref{Locales}, for more information.
  9990. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  9991. The list of locale definitions to be compiled and that may be used at
  9992. run time. @xref{Locales}.
  9993. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  9994. The list of GNU@tie{}libc packages whose locale data and tools are used
  9995. to build the locale definitions. @xref{Locales}, for compatibility
  9996. considerations that justify this option.
  9997. @item @code{name-service-switch} (default: @code{%default-nss})
  9998. Configuration of the libc name service switch (NSS)---a
  9999. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  10000. details.
  10001. @item @code{services} (default: @code{%base-services})
  10002. A list of service objects denoting system services. @xref{Services}.
  10003. @cindex essential services
  10004. @item @code{essential-services} (default: ...)
  10005. The list of ``essential services''---i.e., things like instances of
  10006. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  10007. Reference}), which are derived from the operating system definition itself.
  10008. As a user you should @emph{never} need to touch this field.
  10009. @item @code{pam-services} (default: @code{(base-pam-services)})
  10010. @cindex PAM
  10011. @cindex pluggable authentication modules
  10012. Linux @dfn{pluggable authentication module} (PAM) services.
  10013. @c FIXME: Add xref to PAM services section.
  10014. @item @code{setuid-programs} (default: @code{%setuid-programs})
  10015. List of string-valued G-expressions denoting setuid programs.
  10016. @xref{Setuid Programs}.
  10017. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  10018. @cindex sudoers file
  10019. The contents of the @file{/etc/sudoers} file as a file-like object
  10020. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  10021. This file specifies which users can use the @command{sudo} command, what
  10022. they are allowed to do, and what privileges they may gain. The default
  10023. is that only @code{root} and members of the @code{wheel} group may use
  10024. @code{sudo}.
  10025. @end table
  10026. @deffn {Scheme Syntax} this-operating-system
  10027. When used in the @emph{lexical scope} of an operating system field definition,
  10028. this identifier resolves to the operating system being defined.
  10029. The example below shows how to refer to the operating system being defined in
  10030. the definition of the @code{label} field:
  10031. @lisp
  10032. (use-modules (gnu) (guix))
  10033. (operating-system
  10034. ;; ...
  10035. (label (package-full-name
  10036. (operating-system-kernel this-operating-system))))
  10037. @end lisp
  10038. It is an error to refer to @code{this-operating-system} outside an operating
  10039. system definition.
  10040. @end deffn
  10041. @end deftp
  10042. @node File Systems
  10043. @section File Systems
  10044. The list of file systems to be mounted is specified in the
  10045. @code{file-systems} field of the operating system declaration
  10046. (@pxref{Using the Configuration System}). Each file system is declared
  10047. using the @code{file-system} form, like this:
  10048. @lisp
  10049. (file-system
  10050. (mount-point "/home")
  10051. (device "/dev/sda3")
  10052. (type "ext4"))
  10053. @end lisp
  10054. As usual, some of the fields are mandatory---those shown in the example
  10055. above---while others can be omitted. These are described below.
  10056. @deftp {Data Type} file-system
  10057. Objects of this type represent file systems to be mounted. They
  10058. contain the following members:
  10059. @table @asis
  10060. @item @code{type}
  10061. This is a string specifying the type of the file system---e.g.,
  10062. @code{"ext4"}.
  10063. @item @code{mount-point}
  10064. This designates the place where the file system is to be mounted.
  10065. @item @code{device}
  10066. This names the ``source'' of the file system. It can be one of three
  10067. things: a file system label, a file system UUID, or the name of a
  10068. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  10069. systems without having to hard-code their actual device
  10070. name@footnote{Note that, while it is tempting to use
  10071. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  10072. result, this is not recommended: These special device nodes are created
  10073. by the udev daemon and may be unavailable at the time the device is
  10074. mounted.}.
  10075. @findex file-system-label
  10076. File system labels are created using the @code{file-system-label}
  10077. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  10078. plain strings. Here's an example of a file system referred to by its
  10079. label, as shown by the @command{e2label} command:
  10080. @lisp
  10081. (file-system
  10082. (mount-point "/home")
  10083. (type "ext4")
  10084. (device (file-system-label "my-home")))
  10085. @end lisp
  10086. @findex uuid
  10087. UUIDs are converted from their string representation (as shown by the
  10088. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  10089. @code{uuid} form expects 16-byte UUIDs as defined in
  10090. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  10091. form of UUID used by the ext2 family of file systems and others, but it
  10092. is different from ``UUIDs'' found in FAT file systems, for instance.},
  10093. like this:
  10094. @lisp
  10095. (file-system
  10096. (mount-point "/home")
  10097. (type "ext4")
  10098. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  10099. @end lisp
  10100. When the source of a file system is a mapped device (@pxref{Mapped
  10101. Devices}), its @code{device} field @emph{must} refer to the mapped
  10102. device name---e.g., @file{"/dev/mapper/root-partition"}.
  10103. This is required so that
  10104. the system knows that mounting the file system depends on having the
  10105. corresponding device mapping established.
  10106. @item @code{flags} (default: @code{'()})
  10107. This is a list of symbols denoting mount flags. Recognized flags
  10108. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  10109. access to special files), @code{no-suid} (ignore setuid and setgid
  10110. bits), @code{no-atime} (do not update file access times),
  10111. @code{strict-atime} (update file access time), @code{lazy-time} (only
  10112. update time on the in-memory version of the file inode), and
  10113. @code{no-exec} (disallow program execution).
  10114. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  10115. Manual}, for more information on these flags.
  10116. @item @code{options} (default: @code{#f})
  10117. This is either @code{#f}, or a string denoting mount options passed to
  10118. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  10119. Library Reference Manual}, for details and run @command{man 8 mount} for
  10120. options for various file systems. Note that the
  10121. @code{file-system-options->alist} and @code{alist->file-system-options}
  10122. procedures from @code{(gnu system file-systems)} can be used to convert
  10123. file system options given as an association list to the string
  10124. representation, and vice-versa.
  10125. @item @code{mount?} (default: @code{#t})
  10126. This value indicates whether to automatically mount the file system when
  10127. the system is brought up. When set to @code{#f}, the file system gets
  10128. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  10129. is not automatically mounted.
  10130. @item @code{needed-for-boot?} (default: @code{#f})
  10131. This Boolean value indicates whether the file system is needed when
  10132. booting. If that is true, then the file system is mounted when the
  10133. initial RAM disk (initrd) is loaded. This is always the case, for
  10134. instance, for the root file system.
  10135. @item @code{check?} (default: @code{#t})
  10136. This Boolean indicates whether the file system needs to be checked for
  10137. errors before being mounted.
  10138. @item @code{create-mount-point?} (default: @code{#f})
  10139. When true, the mount point is created if it does not exist yet.
  10140. @item @code{mount-may-fail?} (default: @code{#f})
  10141. When true, this indicates that mounting this file system can fail but
  10142. that should not be considered an error. This is useful in unusual
  10143. cases; an example of this is @code{efivarfs}, a file system that can
  10144. only be mounted on EFI/UEFI systems.
  10145. @item @code{dependencies} (default: @code{'()})
  10146. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  10147. representing file systems that must be mounted or mapped devices that
  10148. must be opened before (and unmounted or closed after) this one.
  10149. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  10150. a dependency of @file{/sys/fs/cgroup/cpu} and
  10151. @file{/sys/fs/cgroup/memory}.
  10152. Another example is a file system that depends on a mapped device, for
  10153. example for an encrypted partition (@pxref{Mapped Devices}).
  10154. @end table
  10155. @end deftp
  10156. @deffn {Scheme Procedure} file-system-label @var{str}
  10157. This procedure returns an opaque file system label from @var{str}, a
  10158. string:
  10159. @lisp
  10160. (file-system-label "home")
  10161. @result{} #<file-system-label "home">
  10162. @end lisp
  10163. File system labels are used to refer to file systems by label rather
  10164. than by device name. See above for examples.
  10165. @end deffn
  10166. The @code{(gnu system file-systems)} exports the following useful
  10167. variables.
  10168. @defvr {Scheme Variable} %base-file-systems
  10169. These are essential file systems that are required on normal systems,
  10170. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  10171. below). Operating system declarations should always contain at least
  10172. these.
  10173. @end defvr
  10174. @defvr {Scheme Variable} %pseudo-terminal-file-system
  10175. This is the file system to be mounted as @file{/dev/pts}. It supports
  10176. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  10177. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  10178. Manual}). Pseudo-terminals are used by terminal emulators such as
  10179. @command{xterm}.
  10180. @end defvr
  10181. @defvr {Scheme Variable} %shared-memory-file-system
  10182. This file system is mounted as @file{/dev/shm} and is used to support
  10183. memory sharing across processes (@pxref{Memory-mapped I/O,
  10184. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  10185. @end defvr
  10186. @defvr {Scheme Variable} %immutable-store
  10187. This file system performs a read-only ``bind mount'' of
  10188. @file{/gnu/store}, making it read-only for all the users including
  10189. @code{root}. This prevents against accidental modification by software
  10190. running as @code{root} or by system administrators.
  10191. The daemon itself is still able to write to the store: it remounts it
  10192. read-write in its own ``name space.''
  10193. @end defvr
  10194. @defvr {Scheme Variable} %binary-format-file-system
  10195. The @code{binfmt_misc} file system, which allows handling of arbitrary
  10196. executable file types to be delegated to user space. This requires the
  10197. @code{binfmt.ko} kernel module to be loaded.
  10198. @end defvr
  10199. @defvr {Scheme Variable} %fuse-control-file-system
  10200. The @code{fusectl} file system, which allows unprivileged users to mount
  10201. and unmount user-space FUSE file systems. This requires the
  10202. @code{fuse.ko} kernel module to be loaded.
  10203. @end defvr
  10204. The @code{(gnu system uuid)} module provides tools to deal with file
  10205. system ``unique identifiers'' (UUIDs).
  10206. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  10207. Return an opaque UUID (unique identifier) object of the given @var{type}
  10208. (a symbol) by parsing @var{str} (a string):
  10209. @lisp
  10210. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  10211. @result{} #<<uuid> type: dce bv: @dots{}>
  10212. (uuid "1234-ABCD" 'fat)
  10213. @result{} #<<uuid> type: fat bv: @dots{}>
  10214. @end lisp
  10215. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  10216. @code{ntfs}, or one of the commonly found synonyms for these.
  10217. UUIDs are another way to unambiguously refer to file systems in
  10218. operating system configuration. See the examples above.
  10219. @end deffn
  10220. @node Btrfs file system
  10221. @subsection Btrfs file system
  10222. The Btrfs has special features, such as subvolumes, that merit being
  10223. explained in more details. The following section attempts to cover
  10224. basic as well as complex uses of a Btrfs file system with the Guix
  10225. System.
  10226. In its simplest usage, a Btrfs file system can be described, for
  10227. example, by:
  10228. @lisp
  10229. (file-system
  10230. (mount-point "/home")
  10231. (type "btrfs")
  10232. (device (file-system-label "my-home")))
  10233. @end lisp
  10234. The example below is more complex, as it makes use of a Btrfs
  10235. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  10236. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  10237. dependency on @code{mapped-devices}):
  10238. @lisp
  10239. (file-system
  10240. (device (file-system-label "my-btrfs-pool"))
  10241. (mount-point "/")
  10242. (type "btrfs")
  10243. (options "subvol=rootfs")
  10244. (dependencies mapped-devices))
  10245. @end lisp
  10246. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  10247. top level during the early boot, and rely on their configuration to
  10248. refer to the correct subvolume path within that top level. The
  10249. bootloaders operating in this way typically produce their configuration
  10250. on a running system where the Btrfs partitions are already mounted and
  10251. where the subvolume information is readily available. As an example,
  10252. @command{grub-mkconfig}, the configuration generator command shipped
  10253. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  10254. path of a subvolume.
  10255. The Guix System produces a bootloader configuration using the operating
  10256. system configuration as its sole input; it is therefore necessary to
  10257. extract the subvolume name on which @file{/gnu/store} lives (if any)
  10258. from that operating system configuration. To better illustrate,
  10259. consider a subvolume named 'rootfs' which contains the root file system
  10260. data. In such situation, the GRUB bootloader would only see the top
  10261. level of the root Btrfs partition, e.g.:
  10262. @example
  10263. / (top level)
  10264. ├── rootfs (subvolume directory)
  10265. ├── gnu (normal directory)
  10266. ├── store (normal directory)
  10267. [...]
  10268. @end example
  10269. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  10270. of the kernel, initrd binaries and any other files referred to in the
  10271. GRUB configuration that must be found during the early boot.
  10272. The next example shows a nested hierarchy of subvolumes and
  10273. directories:
  10274. @example
  10275. / (top level)
  10276. ├── rootfs (subvolume)
  10277. ├── gnu (normal directory)
  10278. ├── store (subvolume)
  10279. [...]
  10280. @end example
  10281. This scenario would work without mounting the 'store' subvolume.
  10282. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  10283. intended mount point in the file system hierarchy. Alternatively, the
  10284. 'store' subvolume could be referred to by setting the @code{subvol}
  10285. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  10286. Finally, a more contrived example of nested subvolumes:
  10287. @example
  10288. / (top level)
  10289. ├── root-snapshots (subvolume)
  10290. ├── root-current (subvolume)
  10291. ├── guix-store (subvolume)
  10292. [...]
  10293. @end example
  10294. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  10295. so it is necessary to mount it. The subvolume must be fully specified,
  10296. by passing its file name to the @code{subvol} option. To illustrate,
  10297. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  10298. a file system declaration such as:
  10299. @lisp
  10300. (file-system
  10301. (device (file-system-label "btrfs-pool-1"))
  10302. (mount-point "/gnu/store")
  10303. (type "btrfs")
  10304. (options "subvol=root-snapshots/root-current/guix-store,\
  10305. compress-force=zstd,space_cache=v2"))
  10306. @end lisp
  10307. @node Mapped Devices
  10308. @section Mapped Devices
  10309. @cindex device mapping
  10310. @cindex mapped devices
  10311. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  10312. such as a hard disk partition, can be @dfn{mapped} into another device,
  10313. usually in @code{/dev/mapper/},
  10314. with additional processing over the data that flows through
  10315. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  10316. concept of a ``mapped device'' and that of a file system: both boil down
  10317. to @emph{translating} input/output operations made on a file to
  10318. operations on its backing store. Thus, the Hurd implements mapped
  10319. devices, like file systems, using the generic @dfn{translator} mechanism
  10320. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  10321. typical example is encryption device mapping: all writes to the mapped
  10322. device are encrypted, and all reads are deciphered, transparently.
  10323. Guix extends this notion by considering any device or set of devices that
  10324. are @dfn{transformed} in some way to create a new device; for instance,
  10325. RAID devices are obtained by @dfn{assembling} several other devices, such
  10326. as hard disks or partitions, into a new one that behaves as one partition.
  10327. Other examples, not yet implemented, are LVM logical volumes.
  10328. Mapped devices are declared using the @code{mapped-device} form,
  10329. defined as follows; for examples, see below.
  10330. @deftp {Data Type} mapped-device
  10331. Objects of this type represent device mappings that will be made when
  10332. the system boots up.
  10333. @table @code
  10334. @item source
  10335. This is either a string specifying the name of the block device to be mapped,
  10336. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  10337. need to be assembled for creating a new one.
  10338. @item target
  10339. This string specifies the name of the resulting mapped device. For
  10340. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  10341. specifying @code{"my-partition"} leads to the creation of
  10342. the @code{"/dev/mapper/my-partition"} device.
  10343. For RAID devices of type @code{raid-device-mapping}, the full device name
  10344. such as @code{"/dev/md0"} needs to be given.
  10345. @item type
  10346. This must be a @code{mapped-device-kind} object, which specifies how
  10347. @var{source} is mapped to @var{target}.
  10348. @end table
  10349. @end deftp
  10350. @defvr {Scheme Variable} luks-device-mapping
  10351. This defines LUKS block device encryption using the @command{cryptsetup}
  10352. command from the package with the same name. It relies on the
  10353. @code{dm-crypt} Linux kernel module.
  10354. @end defvr
  10355. @defvr {Scheme Variable} raid-device-mapping
  10356. This defines a RAID device, which is assembled using the @code{mdadm}
  10357. command from the package with the same name. It requires a Linux kernel
  10358. module for the appropriate RAID level to be loaded, such as @code{raid456}
  10359. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  10360. @end defvr
  10361. @cindex disk encryption
  10362. @cindex LUKS
  10363. The following example specifies a mapping from @file{/dev/sda3} to
  10364. @file{/dev/mapper/home} using LUKS---the
  10365. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  10366. standard mechanism for disk encryption.
  10367. The @file{/dev/mapper/home}
  10368. device can then be used as the @code{device} of a @code{file-system}
  10369. declaration (@pxref{File Systems}).
  10370. @lisp
  10371. (mapped-device
  10372. (source "/dev/sda3")
  10373. (target "home")
  10374. (type luks-device-mapping))
  10375. @end lisp
  10376. Alternatively, to become independent of device numbering, one may obtain
  10377. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  10378. command like:
  10379. @example
  10380. cryptsetup luksUUID /dev/sda3
  10381. @end example
  10382. and use it as follows:
  10383. @lisp
  10384. (mapped-device
  10385. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  10386. (target "home")
  10387. (type luks-device-mapping))
  10388. @end lisp
  10389. @cindex swap encryption
  10390. It is also desirable to encrypt swap space, since swap space may contain
  10391. sensitive data. One way to accomplish that is to use a swap file in a
  10392. file system on a device mapped via LUKS encryption. In this way, the
  10393. swap file is encrypted because the entire device is encrypted.
  10394. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  10395. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  10396. may be declared as follows:
  10397. @lisp
  10398. (mapped-device
  10399. (source (list "/dev/sda1" "/dev/sdb1"))
  10400. (target "/dev/md0")
  10401. (type raid-device-mapping))
  10402. @end lisp
  10403. The @file{/dev/md0} device can then be used as the @code{device} of a
  10404. @code{file-system} declaration (@pxref{File Systems}).
  10405. Note that the RAID level need not be given; it is chosen during the
  10406. initial creation and formatting of the RAID device and is determined
  10407. automatically later.
  10408. @node User Accounts
  10409. @section User Accounts
  10410. @cindex users
  10411. @cindex accounts
  10412. @cindex user accounts
  10413. User accounts and groups are entirely managed through the
  10414. @code{operating-system} declaration. They are specified with the
  10415. @code{user-account} and @code{user-group} forms:
  10416. @lisp
  10417. (user-account
  10418. (name "alice")
  10419. (group "users")
  10420. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  10421. "audio" ;sound card
  10422. "video" ;video devices such as webcams
  10423. "cdrom")) ;the good ol' CD-ROM
  10424. (comment "Bob's sister"))
  10425. @end lisp
  10426. Here's a user account that uses a different shell and a custom home
  10427. directory (the default would be @file{"/home/bob"}):
  10428. @lisp
  10429. (user-account
  10430. (name "bob")
  10431. (group "users")
  10432. (comment "Alice's bro")
  10433. (shell (file-append zsh "/bin/zsh"))
  10434. (home-directory "/home/robert"))
  10435. @end lisp
  10436. When booting or upon completion of @command{guix system reconfigure},
  10437. the system ensures that only the user accounts and groups specified in
  10438. the @code{operating-system} declaration exist, and with the specified
  10439. properties. Thus, account or group creations or modifications made by
  10440. directly invoking commands such as @command{useradd} are lost upon
  10441. reconfiguration or reboot. This ensures that the system remains exactly
  10442. as declared.
  10443. @deftp {Data Type} user-account
  10444. Objects of this type represent user accounts. The following members may
  10445. be specified:
  10446. @table @asis
  10447. @item @code{name}
  10448. The name of the user account.
  10449. @item @code{group}
  10450. @cindex groups
  10451. This is the name (a string) or identifier (a number) of the user group
  10452. this account belongs to.
  10453. @item @code{supplementary-groups} (default: @code{'()})
  10454. Optionally, this can be defined as a list of group names that this
  10455. account belongs to.
  10456. @item @code{uid} (default: @code{#f})
  10457. This is the user ID for this account (a number), or @code{#f}. In the
  10458. latter case, a number is automatically chosen by the system when the
  10459. account is created.
  10460. @item @code{comment} (default: @code{""})
  10461. A comment about the account, such as the account owner's full name.
  10462. @item @code{home-directory}
  10463. This is the name of the home directory for the account.
  10464. @item @code{create-home-directory?} (default: @code{#t})
  10465. Indicates whether the home directory of this account should be created
  10466. if it does not exist yet.
  10467. @item @code{shell} (default: Bash)
  10468. This is a G-expression denoting the file name of a program to be used as
  10469. the shell (@pxref{G-Expressions}). For example, you would refer to the
  10470. Bash executable like this:
  10471. @lisp
  10472. (file-append bash "/bin/bash")
  10473. @end lisp
  10474. @noindent
  10475. ... and to the Zsh executable like that:
  10476. @lisp
  10477. (file-append zsh "/bin/zsh")
  10478. @end lisp
  10479. @item @code{system?} (default: @code{#f})
  10480. This Boolean value indicates whether the account is a ``system''
  10481. account. System accounts are sometimes treated specially; for instance,
  10482. graphical login managers do not list them.
  10483. @anchor{user-account-password}
  10484. @cindex password, for user accounts
  10485. @item @code{password} (default: @code{#f})
  10486. You would normally leave this field to @code{#f}, initialize user
  10487. passwords as @code{root} with the @command{passwd} command, and then let
  10488. users change it with @command{passwd}. Passwords set with
  10489. @command{passwd} are of course preserved across reboot and
  10490. reconfiguration.
  10491. If you @emph{do} want to set an initial password for an account, then
  10492. this field must contain the encrypted password, as a string. You can use the
  10493. @code{crypt} procedure for this purpose:
  10494. @lisp
  10495. (user-account
  10496. (name "charlie")
  10497. (group "users")
  10498. ;; Specify a SHA-512-hashed initial password.
  10499. (password (crypt "InitialPassword!" "$6$abc")))
  10500. @end lisp
  10501. @quotation Note
  10502. The hash of this initial password will be available in a file in
  10503. @file{/gnu/store}, readable by all the users, so this method must be used with
  10504. care.
  10505. @end quotation
  10506. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  10507. more information on password encryption, and @ref{Encryption,,, guile, GNU
  10508. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  10509. @end table
  10510. @end deftp
  10511. @cindex groups
  10512. User group declarations are even simpler:
  10513. @lisp
  10514. (user-group (name "students"))
  10515. @end lisp
  10516. @deftp {Data Type} user-group
  10517. This type is for, well, user groups. There are just a few fields:
  10518. @table @asis
  10519. @item @code{name}
  10520. The name of the group.
  10521. @item @code{id} (default: @code{#f})
  10522. The group identifier (a number). If @code{#f}, a new number is
  10523. automatically allocated when the group is created.
  10524. @item @code{system?} (default: @code{#f})
  10525. This Boolean value indicates whether the group is a ``system'' group.
  10526. System groups have low numerical IDs.
  10527. @item @code{password} (default: @code{#f})
  10528. What, user groups can have a password? Well, apparently yes. Unless
  10529. @code{#f}, this field specifies the password of the group.
  10530. @end table
  10531. @end deftp
  10532. For convenience, a variable lists all the basic user groups one may
  10533. expect:
  10534. @defvr {Scheme Variable} %base-groups
  10535. This is the list of basic user groups that users and/or packages expect
  10536. to be present on the system. This includes groups such as ``root'',
  10537. ``wheel'', and ``users'', as well as groups used to control access to
  10538. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  10539. @end defvr
  10540. @defvr {Scheme Variable} %base-user-accounts
  10541. This is the list of basic system accounts that programs may expect to
  10542. find on a GNU/Linux system, such as the ``nobody'' account.
  10543. Note that the ``root'' account is not included here. It is a
  10544. special-case and is automatically added whether or not it is specified.
  10545. @end defvr
  10546. @node Keyboard Layout
  10547. @section Keyboard Layout
  10548. @cindex keyboard layout
  10549. @cindex keymap
  10550. To specify what each key of your keyboard does, you need to tell the operating
  10551. system what @dfn{keyboard layout} you want to use. The default, when nothing
  10552. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  10553. However, German speakers will usually prefer the German QWERTZ layout, French
  10554. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  10555. or bépo, and they might even want to further customize the effect of some of
  10556. the keys. This section explains how to get that done.
  10557. @cindex keyboard layout, definition
  10558. There are three components that will want to know about your keyboard layout:
  10559. @itemize
  10560. @item
  10561. The @emph{bootloader} may want to know what keyboard layout you want to use
  10562. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  10563. you want, for instance, to make sure that you can type the passphrase of your
  10564. encrypted root partition using the right layout.
  10565. @item
  10566. The @emph{operating system kernel}, Linux, will need that so that the console
  10567. is properly configured (@pxref{operating-system Reference,
  10568. @code{keyboard-layout}}).
  10569. @item
  10570. The @emph{graphical display server}, usually Xorg, also has its own idea of
  10571. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  10572. @end itemize
  10573. Guix allows you to configure all three separately but, fortunately, it allows
  10574. you to share the same keyboard layout for all three components.
  10575. @cindex XKB, keyboard layouts
  10576. Keyboard layouts are represented by records created by the
  10577. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  10578. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  10579. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  10580. optional variant name, an optional keyboard model name, and a possibly empty
  10581. list of additional options. In most cases the layout name is all you care
  10582. about. Here are a few example:
  10583. @lisp
  10584. ;; The German QWERTZ layout. Here we assume a standard
  10585. ;; "pc105" keyboard model.
  10586. (keyboard-layout "de")
  10587. ;; The bépo variant of the French layout.
  10588. (keyboard-layout "fr" "bepo")
  10589. ;; The Catalan layout.
  10590. (keyboard-layout "es" "cat")
  10591. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  10592. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  10593. ;; The Latin American Spanish layout. In addition, the
  10594. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  10595. ;; and the "Menu" key is used as a "Compose" key to enter
  10596. ;; accented letters.
  10597. (keyboard-layout "latam"
  10598. #:options '("ctrl:nocaps" "compose:menu"))
  10599. ;; The Russian layout for a ThinkPad keyboard.
  10600. (keyboard-layout "ru" #:model "thinkpad")
  10601. ;; The "US international" layout, which is the US layout plus
  10602. ;; dead keys to enter accented characters. This is for an
  10603. ;; Apple MacBook keyboard.
  10604. (keyboard-layout "us" "intl" #:model "macbook78")
  10605. @end lisp
  10606. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  10607. for a complete list of supported layouts, variants, and models.
  10608. @cindex keyboard layout, configuration
  10609. Let's say you want your system to use the Turkish keyboard layout throughout
  10610. your system---bootloader, console, and Xorg. Here's what your system
  10611. configuration would look like:
  10612. @findex set-xorg-configuration
  10613. @lisp
  10614. ;; Using the Turkish layout for the bootloader, the console,
  10615. ;; and for Xorg.
  10616. (operating-system
  10617. ;; ...
  10618. (keyboard-layout (keyboard-layout "tr")) ;for the console
  10619. (bootloader (bootloader-configuration
  10620. (bootloader grub-efi-bootloader)
  10621. (target "/boot/efi")
  10622. (keyboard-layout keyboard-layout))) ;for GRUB
  10623. (services (cons (set-xorg-configuration
  10624. (xorg-configuration ;for Xorg
  10625. (keyboard-layout keyboard-layout)))
  10626. %desktop-services)))
  10627. @end lisp
  10628. In the example above, for GRUB and for Xorg, we just refer to the
  10629. @code{keyboard-layout} field defined above, but we could just as well refer to
  10630. a different layout. The @code{set-xorg-configuration} procedure communicates
  10631. the desired Xorg configuration to the graphical log-in manager, by default
  10632. GDM.
  10633. We've discussed how to specify the @emph{default} keyboard layout of your
  10634. system when it starts, but you can also adjust it at run time:
  10635. @itemize
  10636. @item
  10637. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  10638. where you can select one or more keyboard layouts.
  10639. @item
  10640. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  10641. allows you to change the current layout. For example, this is how you would
  10642. change the layout to US Dvorak:
  10643. @example
  10644. setxkbmap us dvorak
  10645. @end example
  10646. @item
  10647. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  10648. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  10649. keyboard layout categorization described above. The command below loads the
  10650. French bépo layout:
  10651. @example
  10652. loadkeys fr-bepo
  10653. @end example
  10654. @end itemize
  10655. @node Locales
  10656. @section Locales
  10657. @cindex locale
  10658. A @dfn{locale} defines cultural conventions for a particular language
  10659. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  10660. Reference Manual}). Each locale has a name that typically has the form
  10661. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  10662. @code{fr_LU.utf8} designates the locale for the French language, with
  10663. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  10664. @cindex locale definition
  10665. Usually, you will want to specify the default locale for the machine
  10666. using the @code{locale} field of the @code{operating-system} declaration
  10667. (@pxref{operating-system Reference, @code{locale}}).
  10668. The selected locale is automatically added to the @dfn{locale
  10669. definitions} known to the system if needed, with its codeset inferred
  10670. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  10671. @code{UTF-8} codeset. Additional locale definitions can be specified in
  10672. the @code{locale-definitions} slot of @code{operating-system}---this is
  10673. useful, for instance, if the codeset could not be inferred from the
  10674. locale name. The default set of locale definitions includes some widely
  10675. used locales, but not all the available locales, in order to save space.
  10676. For instance, to add the North Frisian locale for Germany, the value of
  10677. that field may be:
  10678. @lisp
  10679. (cons (locale-definition
  10680. (name "fy_DE.utf8") (source "fy_DE"))
  10681. %default-locale-definitions)
  10682. @end lisp
  10683. Likewise, to save space, one might want @code{locale-definitions} to
  10684. list only the locales that are actually used, as in:
  10685. @lisp
  10686. (list (locale-definition
  10687. (name "ja_JP.eucjp") (source "ja_JP")
  10688. (charset "EUC-JP")))
  10689. @end lisp
  10690. @vindex LOCPATH
  10691. The compiled locale definitions are available at
  10692. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  10693. version, which is the default location where the GNU@tie{}libc provided
  10694. by Guix looks for locale data. This can be overridden using the
  10695. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  10696. @env{LOCPATH} and locale packages}).
  10697. The @code{locale-definition} form is provided by the @code{(gnu system
  10698. locale)} module. Details are given below.
  10699. @deftp {Data Type} locale-definition
  10700. This is the data type of a locale definition.
  10701. @table @asis
  10702. @item @code{name}
  10703. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  10704. Reference Manual}, for more information on locale names.
  10705. @item @code{source}
  10706. The name of the source for that locale. This is typically the
  10707. @code{@var{language}_@var{territory}} part of the locale name.
  10708. @item @code{charset} (default: @code{"UTF-8"})
  10709. The ``character set'' or ``code set'' for that locale,
  10710. @uref{https://www.iana.org/assignments/character-sets, as defined by
  10711. IANA}.
  10712. @end table
  10713. @end deftp
  10714. @defvr {Scheme Variable} %default-locale-definitions
  10715. A list of commonly used UTF-8 locales, used as the default
  10716. value of the @code{locale-definitions} field of @code{operating-system}
  10717. declarations.
  10718. @cindex locale name
  10719. @cindex normalized codeset in locale names
  10720. These locale definitions use the @dfn{normalized codeset} for the part
  10721. that follows the dot in the name (@pxref{Using gettextized software,
  10722. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  10723. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  10724. @code{uk_UA.UTF-8}.
  10725. @end defvr
  10726. @subsection Locale Data Compatibility Considerations
  10727. @cindex incompatibility, of locale data
  10728. @code{operating-system} declarations provide a @code{locale-libcs} field
  10729. to specify the GNU@tie{}libc packages that are used to compile locale
  10730. declarations (@pxref{operating-system Reference}). ``Why would I
  10731. care?'', you may ask. Well, it turns out that the binary format of
  10732. locale data is occasionally incompatible from one libc version to
  10733. another.
  10734. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  10735. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  10736. For instance, a program linked against libc version 2.21 is unable to
  10737. read locale data produced with libc 2.22; worse, that program
  10738. @emph{aborts} instead of simply ignoring the incompatible locale
  10739. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  10740. the incompatible locale data, which is already an improvement.}.
  10741. Similarly, a program linked against libc 2.22 can read most, but not
  10742. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  10743. data is incompatible); thus calls to @code{setlocale} may fail, but
  10744. programs will not abort.
  10745. The ``problem'' with Guix is that users have a lot of freedom: They can
  10746. choose whether and when to upgrade software in their profiles, and might
  10747. be using a libc version different from the one the system administrator
  10748. used to build the system-wide locale data.
  10749. Fortunately, unprivileged users can also install their own locale data
  10750. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  10751. @env{GUIX_LOCPATH} and locale packages}).
  10752. Still, it is best if the system-wide locale data at
  10753. @file{/run/current-system/locale} is built for all the libc versions
  10754. actually in use on the system, so that all the programs can access
  10755. it---this is especially crucial on a multi-user system. To do that, the
  10756. administrator can specify several libc packages in the
  10757. @code{locale-libcs} field of @code{operating-system}:
  10758. @lisp
  10759. (use-package-modules base)
  10760. (operating-system
  10761. ;; @dots{}
  10762. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  10763. @end lisp
  10764. This example would lead to a system containing locale definitions for
  10765. both libc 2.21 and the current version of libc in
  10766. @file{/run/current-system/locale}.
  10767. @node Services
  10768. @section Services
  10769. @cindex system services
  10770. An important part of preparing an @code{operating-system} declaration is
  10771. listing @dfn{system services} and their configuration (@pxref{Using the
  10772. Configuration System}). System services are typically daemons launched
  10773. when the system boots, or other actions needed at that time---e.g.,
  10774. configuring network access.
  10775. Guix has a broad definition of ``service'' (@pxref{Service
  10776. Composition}), but many services are managed by the GNU@tie{}Shepherd
  10777. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  10778. command allows you to list the available services, show their status,
  10779. start and stop them, or do other specific operations (@pxref{Jump
  10780. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  10781. @example
  10782. # herd status
  10783. @end example
  10784. The above command, run as @code{root}, lists the currently defined
  10785. services. The @command{herd doc} command shows a synopsis of the given
  10786. service and its associated actions:
  10787. @example
  10788. # herd doc nscd
  10789. Run libc's name service cache daemon (nscd).
  10790. # herd doc nscd action invalidate
  10791. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  10792. @end example
  10793. The @command{start}, @command{stop}, and @command{restart} sub-commands
  10794. have the effect you would expect. For instance, the commands below stop
  10795. the nscd service and restart the Xorg display server:
  10796. @example
  10797. # herd stop nscd
  10798. Service nscd has been stopped.
  10799. # herd restart xorg-server
  10800. Service xorg-server has been stopped.
  10801. Service xorg-server has been started.
  10802. @end example
  10803. The following sections document the available services, starting with
  10804. the core services, that may be used in an @code{operating-system}
  10805. declaration.
  10806. @menu
  10807. * Base Services:: Essential system services.
  10808. * Scheduled Job Execution:: The mcron service.
  10809. * Log Rotation:: The rottlog service.
  10810. * Networking Services:: Network setup, SSH daemon, etc.
  10811. * Unattended Upgrades:: Automated system upgrades.
  10812. * X Window:: Graphical display.
  10813. * Printing Services:: Local and remote printer support.
  10814. * Desktop Services:: D-Bus and desktop services.
  10815. * Sound Services:: ALSA and Pulseaudio services.
  10816. * Database Services:: SQL databases, key-value stores, etc.
  10817. * Mail Services:: IMAP, POP3, SMTP, and all that.
  10818. * Messaging Services:: Messaging services.
  10819. * Telephony Services:: Telephony services.
  10820. * Monitoring Services:: Monitoring services.
  10821. * Kerberos Services:: Kerberos services.
  10822. * LDAP Services:: LDAP services.
  10823. * Web Services:: Web servers.
  10824. * Certificate Services:: TLS certificates via Let's Encrypt.
  10825. * DNS Services:: DNS daemons.
  10826. * VPN Services:: VPN daemons.
  10827. * Network File System:: NFS related services.
  10828. * Continuous Integration:: The Cuirass service.
  10829. * Power Management Services:: Extending battery life.
  10830. * Audio Services:: The MPD.
  10831. * Virtualization Services:: Virtualization services.
  10832. * Version Control Services:: Providing remote access to Git repositories.
  10833. * Game Services:: Game servers.
  10834. * PAM Mount Service:: Service to mount volumes when logging in.
  10835. * Guix Services:: Services relating specifically to Guix.
  10836. * Linux Services:: Services tied to the Linux kernel.
  10837. * Hurd Services:: Services specific for a Hurd System.
  10838. * Miscellaneous Services:: Other services.
  10839. @end menu
  10840. @node Base Services
  10841. @subsection Base Services
  10842. The @code{(gnu services base)} module provides definitions for the basic
  10843. services that one expects from the system. The services exported by
  10844. this module are listed below.
  10845. @defvr {Scheme Variable} %base-services
  10846. This variable contains a list of basic services (@pxref{Service Types
  10847. and Services}, for more information on service objects) one would
  10848. expect from the system: a login service (mingetty) on each tty, syslogd,
  10849. the libc name service cache daemon (nscd), the udev device manager, and
  10850. more.
  10851. This is the default value of the @code{services} field of
  10852. @code{operating-system} declarations. Usually, when customizing a
  10853. system, you will want to append services to @code{%base-services}, like
  10854. this:
  10855. @lisp
  10856. (append (list (service avahi-service-type)
  10857. (service openssh-service-type))
  10858. %base-services)
  10859. @end lisp
  10860. @end defvr
  10861. @defvr {Scheme Variable} special-files-service-type
  10862. This is the service that sets up ``special files'' such as
  10863. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  10864. The value associated with @code{special-files-service-type} services
  10865. must be a list of tuples where the first element is the ``special file''
  10866. and the second element is its target. By default it is:
  10867. @cindex @file{/bin/sh}
  10868. @cindex @file{sh}, in @file{/bin}
  10869. @lisp
  10870. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  10871. @end lisp
  10872. @cindex @file{/usr/bin/env}
  10873. @cindex @file{env}, in @file{/usr/bin}
  10874. If you want to add, say, @code{/usr/bin/env} to your system, you can
  10875. change it to:
  10876. @lisp
  10877. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  10878. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  10879. @end lisp
  10880. Since this is part of @code{%base-services}, you can use
  10881. @code{modify-services} to customize the set of special files
  10882. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  10883. to add a special file is @i{via} the @code{extra-special-file} procedure
  10884. (see below).
  10885. @end defvr
  10886. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  10887. Use @var{target} as the ``special file'' @var{file}.
  10888. For example, adding the following lines to the @code{services} field of
  10889. your operating system declaration leads to a @file{/usr/bin/env}
  10890. symlink:
  10891. @lisp
  10892. (extra-special-file "/usr/bin/env"
  10893. (file-append coreutils "/bin/env"))
  10894. @end lisp
  10895. @end deffn
  10896. @deffn {Scheme Procedure} host-name-service @var{name}
  10897. Return a service that sets the host name to @var{name}.
  10898. @end deffn
  10899. @defvr {Scheme Variable} console-font-service-type
  10900. Install the given fonts on the specified ttys (fonts are per
  10901. virtual console on the kernel Linux). The value of this service is a list of
  10902. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  10903. package or any valid argument to @command{setfont}, as in this example:
  10904. @lisp
  10905. `(("tty1" . "LatGrkCyr-8x16")
  10906. ("tty2" . ,(file-append
  10907. font-tamzen
  10908. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  10909. ("tty3" . ,(file-append
  10910. font-terminus
  10911. "/share/consolefonts/ter-132n"))) ; for HDPI
  10912. @end lisp
  10913. @end defvr
  10914. @deffn {Scheme Procedure} login-service @var{config}
  10915. Return a service to run login according to @var{config}, a
  10916. @code{<login-configuration>} object, which specifies the message of the day,
  10917. among other things.
  10918. @end deffn
  10919. @deftp {Data Type} login-configuration
  10920. This is the data type representing the configuration of login.
  10921. @table @asis
  10922. @item @code{motd}
  10923. @cindex message of the day
  10924. A file-like object containing the ``message of the day''.
  10925. @item @code{allow-empty-passwords?} (default: @code{#t})
  10926. Allow empty passwords by default so that first-time users can log in when
  10927. the 'root' account has just been created.
  10928. @end table
  10929. @end deftp
  10930. @deffn {Scheme Procedure} mingetty-service @var{config}
  10931. Return a service to run mingetty according to @var{config}, a
  10932. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  10933. other things.
  10934. @end deffn
  10935. @deftp {Data Type} mingetty-configuration
  10936. This is the data type representing the configuration of Mingetty, which
  10937. provides the default implementation of virtual console log-in.
  10938. @table @asis
  10939. @item @code{tty}
  10940. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  10941. @item @code{auto-login} (default: @code{#f})
  10942. When true, this field must be a string denoting the user name under
  10943. which the system automatically logs in. When it is @code{#f}, a
  10944. user name and password must be entered to log in.
  10945. @item @code{login-program} (default: @code{#f})
  10946. This must be either @code{#f}, in which case the default log-in program
  10947. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  10948. the name of the log-in program.
  10949. @item @code{login-pause?} (default: @code{#f})
  10950. When set to @code{#t} in conjunction with @var{auto-login}, the user
  10951. will have to press a key before the log-in shell is launched.
  10952. @item @code{mingetty} (default: @var{mingetty})
  10953. The Mingetty package to use.
  10954. @end table
  10955. @end deftp
  10956. @deffn {Scheme Procedure} agetty-service @var{config}
  10957. Return a service to run agetty according to @var{config}, an
  10958. @code{<agetty-configuration>} object, which specifies the tty to run,
  10959. among other things.
  10960. @end deffn
  10961. @deftp {Data Type} agetty-configuration
  10962. This is the data type representing the configuration of agetty, which
  10963. implements virtual and serial console log-in. See the @code{agetty(8)}
  10964. man page for more information.
  10965. @table @asis
  10966. @item @code{tty}
  10967. The name of the console this agetty runs on, as a string---e.g.,
  10968. @code{"ttyS0"}. This argument is optional, it will default to
  10969. a reasonable default serial port used by the kernel Linux.
  10970. For this, if there is a value for an option @code{agetty.tty} in the kernel
  10971. command line, agetty will extract the device name of the serial port
  10972. from it and use that.
  10973. If not and if there is a value for an option @code{console} with a tty in
  10974. the Linux command line, agetty will extract the device name of the
  10975. serial port from it and use that.
  10976. In both cases, agetty will leave the other serial device settings
  10977. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  10978. correct values.
  10979. @item @code{baud-rate} (default: @code{#f})
  10980. A string containing a comma-separated list of one or more baud rates, in
  10981. descending order.
  10982. @item @code{term} (default: @code{#f})
  10983. A string containing the value used for the @env{TERM} environment
  10984. variable.
  10985. @item @code{eight-bits?} (default: @code{#f})
  10986. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  10987. disabled.
  10988. @item @code{auto-login} (default: @code{#f})
  10989. When passed a login name, as a string, the specified user will be logged
  10990. in automatically without prompting for their login name or password.
  10991. @item @code{no-reset?} (default: @code{#f})
  10992. When @code{#t}, don't reset terminal cflags (control modes).
  10993. @item @code{host} (default: @code{#f})
  10994. This accepts a string containing the ``login_host'', which will be written
  10995. into the @file{/var/run/utmpx} file.
  10996. @item @code{remote?} (default: @code{#f})
  10997. When set to @code{#t} in conjunction with @var{host}, this will add an
  10998. @code{-r} fakehost option to the command line of the login program
  10999. specified in @var{login-program}.
  11000. @item @code{flow-control?} (default: @code{#f})
  11001. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  11002. @item @code{no-issue?} (default: @code{#f})
  11003. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  11004. not be displayed before presenting the login prompt.
  11005. @item @code{init-string} (default: @code{#f})
  11006. This accepts a string that will be sent to the tty or modem before
  11007. sending anything else. It can be used to initialize a modem.
  11008. @item @code{no-clear?} (default: @code{#f})
  11009. When set to @code{#t}, agetty will not clear the screen before showing
  11010. the login prompt.
  11011. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  11012. This must be either a gexp denoting the name of a log-in program, or
  11013. unset, in which case the default value is the @command{login} from the
  11014. Shadow tool suite.
  11015. @item @code{local-line} (default: @code{#f})
  11016. Control the CLOCAL line flag. This accepts one of three symbols as
  11017. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  11018. the default value chosen by agetty is @code{'auto}.
  11019. @item @code{extract-baud?} (default: @code{#f})
  11020. When set to @code{#t}, instruct agetty to try to extract the baud rate
  11021. from the status messages produced by certain types of modems.
  11022. @item @code{skip-login?} (default: @code{#f})
  11023. When set to @code{#t}, do not prompt the user for a login name. This
  11024. can be used with @var{login-program} field to use non-standard login
  11025. systems.
  11026. @item @code{no-newline?} (default: @code{#f})
  11027. When set to @code{#t}, do not print a newline before printing the
  11028. @file{/etc/issue} file.
  11029. @c Is this dangerous only when used with login-program, or always?
  11030. @item @code{login-options} (default: @code{#f})
  11031. This option accepts a string containing options that are passed to the
  11032. login program. When used with the @var{login-program}, be aware that a
  11033. malicious user could try to enter a login name containing embedded
  11034. options that could be parsed by the login program.
  11035. @item @code{login-pause} (default: @code{#f})
  11036. When set to @code{#t}, wait for any key before showing the login prompt.
  11037. This can be used in conjunction with @var{auto-login} to save memory by
  11038. lazily spawning shells.
  11039. @item @code{chroot} (default: @code{#f})
  11040. Change root to the specified directory. This option accepts a directory
  11041. path as a string.
  11042. @item @code{hangup?} (default: @code{#f})
  11043. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  11044. specified terminal.
  11045. @item @code{keep-baud?} (default: @code{#f})
  11046. When set to @code{#t}, try to keep the existing baud rate. The baud
  11047. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  11048. character.
  11049. @item @code{timeout} (default: @code{#f})
  11050. When set to an integer value, terminate if no user name could be read
  11051. within @var{timeout} seconds.
  11052. @item @code{detect-case?} (default: @code{#f})
  11053. When set to @code{#t}, turn on support for detecting an uppercase-only
  11054. terminal. This setting will detect a login name containing only
  11055. uppercase letters as indicating an uppercase-only terminal and turn on
  11056. some upper-to-lower case conversions. Note that this will not support
  11057. Unicode characters.
  11058. @item @code{wait-cr?} (default: @code{#f})
  11059. When set to @code{#t}, wait for the user or modem to send a
  11060. carriage-return or linefeed character before displaying
  11061. @file{/etc/issue} or login prompt. This is typically used with the
  11062. @var{init-string} option.
  11063. @item @code{no-hints?} (default: @code{#f})
  11064. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  11065. locks.
  11066. @item @code{no-hostname?} (default: @code{#f})
  11067. By default, the hostname is printed. When this option is set to
  11068. @code{#t}, no hostname will be shown at all.
  11069. @item @code{long-hostname?} (default: @code{#f})
  11070. By default, the hostname is only printed until the first dot. When this
  11071. option is set to @code{#t}, the fully qualified hostname by
  11072. @code{gethostname} or @code{getaddrinfo} is shown.
  11073. @item @code{erase-characters} (default: @code{#f})
  11074. This option accepts a string of additional characters that should be
  11075. interpreted as backspace when the user types their login name.
  11076. @item @code{kill-characters} (default: @code{#f})
  11077. This option accepts a string that should be interpreted to mean ``ignore
  11078. all previous characters'' (also called a ``kill'' character) when the user
  11079. types their login name.
  11080. @item @code{chdir} (default: @code{#f})
  11081. This option accepts, as a string, a directory path that will be changed
  11082. to before login.
  11083. @item @code{delay} (default: @code{#f})
  11084. This options accepts, as an integer, the number of seconds to sleep
  11085. before opening the tty and displaying the login prompt.
  11086. @item @code{nice} (default: @code{#f})
  11087. This option accepts, as an integer, the nice value with which to run the
  11088. @command{login} program.
  11089. @item @code{extra-options} (default: @code{'()})
  11090. This option provides an ``escape hatch'' for the user to provide arbitrary
  11091. command-line arguments to @command{agetty} as a list of strings.
  11092. @end table
  11093. @end deftp
  11094. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  11095. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  11096. according to @var{config}, a @code{<kmscon-configuration>} object, which
  11097. specifies the tty to run, among other things.
  11098. @end deffn
  11099. @deftp {Data Type} kmscon-configuration
  11100. This is the data type representing the configuration of Kmscon, which
  11101. implements virtual console log-in.
  11102. @table @asis
  11103. @item @code{virtual-terminal}
  11104. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  11105. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  11106. A gexp denoting the name of the log-in program. The default log-in program is
  11107. @command{login} from the Shadow tool suite.
  11108. @item @code{login-arguments} (default: @code{'("-p")})
  11109. A list of arguments to pass to @command{login}.
  11110. @item @code{auto-login} (default: @code{#f})
  11111. When passed a login name, as a string, the specified user will be logged
  11112. in automatically without prompting for their login name or password.
  11113. @item @code{hardware-acceleration?} (default: #f)
  11114. Whether to use hardware acceleration.
  11115. @item @code{kmscon} (default: @var{kmscon})
  11116. The Kmscon package to use.
  11117. @end table
  11118. @end deftp
  11119. @cindex name service cache daemon
  11120. @cindex nscd
  11121. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  11122. [#:name-services '()]
  11123. Return a service that runs the libc name service cache daemon (nscd) with the
  11124. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  11125. Service Switch}, for an example.
  11126. For convenience, the Shepherd service for nscd provides the following actions:
  11127. @table @code
  11128. @item invalidate
  11129. @cindex cache invalidation, nscd
  11130. @cindex nscd, cache invalidation
  11131. This invalidate the given cache. For instance, running:
  11132. @example
  11133. herd invalidate nscd hosts
  11134. @end example
  11135. @noindent
  11136. invalidates the host name lookup cache of nscd.
  11137. @item statistics
  11138. Running @command{herd statistics nscd} displays information about nscd usage
  11139. and caches.
  11140. @end table
  11141. @end deffn
  11142. @defvr {Scheme Variable} %nscd-default-configuration
  11143. This is the default @code{<nscd-configuration>} value (see below) used
  11144. by @code{nscd-service}. It uses the caches defined by
  11145. @code{%nscd-default-caches}; see below.
  11146. @end defvr
  11147. @deftp {Data Type} nscd-configuration
  11148. This is the data type representing the name service cache daemon (nscd)
  11149. configuration.
  11150. @table @asis
  11151. @item @code{name-services} (default: @code{'()})
  11152. List of packages denoting @dfn{name services} that must be visible to
  11153. the nscd---e.g., @code{(list @var{nss-mdns})}.
  11154. @item @code{glibc} (default: @var{glibc})
  11155. Package object denoting the GNU C Library providing the @command{nscd}
  11156. command.
  11157. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  11158. Name of the nscd log file. This is where debugging output goes when
  11159. @code{debug-level} is strictly positive.
  11160. @item @code{debug-level} (default: @code{0})
  11161. Integer denoting the debugging levels. Higher numbers mean that more
  11162. debugging output is logged.
  11163. @item @code{caches} (default: @code{%nscd-default-caches})
  11164. List of @code{<nscd-cache>} objects denoting things to be cached; see
  11165. below.
  11166. @end table
  11167. @end deftp
  11168. @deftp {Data Type} nscd-cache
  11169. Data type representing a cache database of nscd and its parameters.
  11170. @table @asis
  11171. @item @code{database}
  11172. This is a symbol representing the name of the database to be cached.
  11173. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  11174. @code{services}, which designate the corresponding NSS database
  11175. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  11176. @item @code{positive-time-to-live}
  11177. @itemx @code{negative-time-to-live} (default: @code{20})
  11178. A number representing the number of seconds during which a positive or
  11179. negative lookup result remains in cache.
  11180. @item @code{check-files?} (default: @code{#t})
  11181. Whether to check for updates of the files corresponding to
  11182. @var{database}.
  11183. For instance, when @var{database} is @code{hosts}, setting this flag
  11184. instructs nscd to check for updates in @file{/etc/hosts} and to take
  11185. them into account.
  11186. @item @code{persistent?} (default: @code{#t})
  11187. Whether the cache should be stored persistently on disk.
  11188. @item @code{shared?} (default: @code{#t})
  11189. Whether the cache should be shared among users.
  11190. @item @code{max-database-size} (default: 32@tie{}MiB)
  11191. Maximum size in bytes of the database cache.
  11192. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  11193. @c settings, so leave them out.
  11194. @end table
  11195. @end deftp
  11196. @defvr {Scheme Variable} %nscd-default-caches
  11197. List of @code{<nscd-cache>} objects used by default by
  11198. @code{nscd-configuration} (see above).
  11199. It enables persistent and aggressive caching of service and host name
  11200. lookups. The latter provides better host name lookup performance,
  11201. resilience in the face of unreliable name servers, and also better
  11202. privacy---often the result of host name lookups is in local cache, so
  11203. external name servers do not even need to be queried.
  11204. @end defvr
  11205. @anchor{syslog-configuration-type}
  11206. @cindex syslog
  11207. @cindex logging
  11208. @deftp {Data Type} syslog-configuration
  11209. This data type represents the configuration of the syslog daemon.
  11210. @table @asis
  11211. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  11212. The syslog daemon to use.
  11213. @item @code{config-file} (default: @code{%default-syslog.conf})
  11214. The syslog configuration file to use.
  11215. @end table
  11216. @end deftp
  11217. @anchor{syslog-service}
  11218. @cindex syslog
  11219. @deffn {Scheme Procedure} syslog-service @var{config}
  11220. Return a service that runs a syslog daemon according to @var{config}.
  11221. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  11222. information on the configuration file syntax.
  11223. @end deffn
  11224. @defvr {Scheme Variable} guix-service-type
  11225. This is the type of the service that runs the build daemon,
  11226. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  11227. @code{guix-configuration} record as described below.
  11228. @end defvr
  11229. @anchor{guix-configuration-type}
  11230. @deftp {Data Type} guix-configuration
  11231. This data type represents the configuration of the Guix build daemon.
  11232. @xref{Invoking guix-daemon}, for more information.
  11233. @table @asis
  11234. @item @code{guix} (default: @var{guix})
  11235. The Guix package to use.
  11236. @item @code{build-group} (default: @code{"guixbuild"})
  11237. Name of the group for build user accounts.
  11238. @item @code{build-accounts} (default: @code{10})
  11239. Number of build user accounts to create.
  11240. @item @code{authorize-key?} (default: @code{#t})
  11241. @cindex substitutes, authorization thereof
  11242. Whether to authorize the substitute keys listed in
  11243. @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
  11244. (@pxref{Substitutes}).
  11245. @vindex %default-authorized-guix-keys
  11246. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  11247. The list of authorized key files for archive imports, as a list of
  11248. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  11249. contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
  11250. @item @code{use-substitutes?} (default: @code{#t})
  11251. Whether to use substitutes.
  11252. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  11253. The list of URLs where to look for substitutes by default.
  11254. @item @code{max-silent-time} (default: @code{0})
  11255. @itemx @code{timeout} (default: @code{0})
  11256. The number of seconds of silence and the number of seconds of activity,
  11257. respectively, after which a build process times out. A value of zero
  11258. disables the timeout.
  11259. @item @code{log-compression} (default: @code{'bzip2})
  11260. The type of compression used for build logs---one of @code{gzip},
  11261. @code{bzip2}, or @code{none}.
  11262. @item @code{extra-options} (default: @code{'()})
  11263. List of extra command-line options for @command{guix-daemon}.
  11264. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  11265. File where @command{guix-daemon}'s standard output and standard error
  11266. are written.
  11267. @cindex HTTP proxy, for @code{guix-daemon}
  11268. @cindex proxy, for @code{guix-daemon} HTTP access
  11269. @item @code{http-proxy} (default: @code{#f})
  11270. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  11271. derivations and substitutes.
  11272. It is also possible to change the daemon's proxy at run time through the
  11273. @code{set-http-proxy} action, which restarts it:
  11274. @example
  11275. herd set-http-proxy guix-daemon http://localhost:8118
  11276. @end example
  11277. To clear the proxy settings, run:
  11278. @example
  11279. herd set-http-proxy guix-daemon
  11280. @end example
  11281. @item @code{tmpdir} (default: @code{#f})
  11282. A directory path where the @command{guix-daemon} will perform builds.
  11283. @end table
  11284. @end deftp
  11285. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  11286. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  11287. udev rules can be provided as a list of files through the @var{rules}
  11288. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  11289. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  11290. creation of such rule files.
  11291. The @command{herd rules udev} command, as root, returns the name of the
  11292. directory containing all the active udev rules.
  11293. @end deffn
  11294. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  11295. Return a udev-rule file named @var{file-name} containing the rules
  11296. defined by the @var{contents} literal.
  11297. In the following example, a rule for a USB device is defined to be
  11298. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  11299. upon detecting a USB device with a given product identifier.
  11300. @lisp
  11301. (define %example-udev-rule
  11302. (udev-rule
  11303. "90-usb-thing.rules"
  11304. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  11305. "ATTR@{product@}==\"Example\", "
  11306. "RUN+=\"/path/to/script\"")))
  11307. @end lisp
  11308. @end deffn
  11309. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  11310. [#:groups @var{groups}]
  11311. Return a service that extends @code{udev-service-type } with @var{rules}
  11312. and @code{account-service-type} with @var{groups} as system groups.
  11313. This works by creating a singleton service type
  11314. @code{@var{name}-udev-rules}, of which the returned service is an
  11315. instance.
  11316. Here we show how it can be used to extend @code{udev-service-type} with the
  11317. previously defined rule @code{%example-udev-rule}.
  11318. @lisp
  11319. (operating-system
  11320. ;; @dots{}
  11321. (services
  11322. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  11323. %desktop-services)))
  11324. @end lisp
  11325. @end deffn
  11326. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  11327. Return a udev file named @var{file-name} containing the rules defined
  11328. within @var{file}, a file-like object.
  11329. The following example showcases how we can use an existing rule file.
  11330. @lisp
  11331. (use-modules (guix download) ;for url-fetch
  11332. (guix packages) ;for origin
  11333. @dots{})
  11334. (define %android-udev-rules
  11335. (file->udev-rule
  11336. "51-android-udev.rules"
  11337. (let ((version "20170910"))
  11338. (origin
  11339. (method url-fetch)
  11340. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  11341. "android-udev-rules/" version "/51-android.rules"))
  11342. (sha256
  11343. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  11344. @end lisp
  11345. @end deffn
  11346. Additionally, Guix package definitions can be included in @var{rules} in
  11347. order to extend the udev rules with the definitions found under their
  11348. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  11349. @var{file->udev-rule} example, we could have used the
  11350. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  11351. packages android)} module.
  11352. The following example shows how to use the @var{android-udev-rules}
  11353. package so that the Android tool @command{adb} can detect devices
  11354. without root privileges. It also details how to create the
  11355. @code{adbusers} group, which is required for the proper functioning of
  11356. the rules defined within the @code{android-udev-rules} package. To
  11357. create such a group, we must define it both as part of the
  11358. @code{supplementary-groups} of our @code{user-account} declaration, as
  11359. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  11360. @lisp
  11361. (use-modules (gnu packages android) ;for android-udev-rules
  11362. (gnu system shadow) ;for user-group
  11363. @dots{})
  11364. (operating-system
  11365. ;; @dots{}
  11366. (users (cons (user-account
  11367. ;; @dots{}
  11368. (supplementary-groups
  11369. '("adbusers" ;for adb
  11370. "wheel" "netdev" "audio" "video")))))
  11371. ;; @dots{}
  11372. (services
  11373. (cons (udev-rules-service 'android android-udev-rules
  11374. #:groups '("adbusers"))
  11375. %desktop-services)))
  11376. @end lisp
  11377. @defvr {Scheme Variable} urandom-seed-service-type
  11378. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  11379. when rebooting. It also tries to seed @file{/dev/urandom} from
  11380. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  11381. readable.
  11382. @end defvr
  11383. @defvr {Scheme Variable} %random-seed-file
  11384. This is the name of the file where some random bytes are saved by
  11385. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  11386. It defaults to @file{/var/lib/random-seed}.
  11387. @end defvr
  11388. @cindex mouse
  11389. @cindex gpm
  11390. @defvr {Scheme Variable} gpm-service-type
  11391. This is the type of the service that runs GPM, the @dfn{general-purpose
  11392. mouse daemon}, which provides mouse support to the Linux console. GPM
  11393. allows users to use the mouse in the console, notably to select, copy,
  11394. and paste text.
  11395. The value for services of this type must be a @code{gpm-configuration}
  11396. (see below). This service is not part of @code{%base-services}.
  11397. @end defvr
  11398. @deftp {Data Type} gpm-configuration
  11399. Data type representing the configuration of GPM.
  11400. @table @asis
  11401. @item @code{options} (default: @code{%default-gpm-options})
  11402. Command-line options passed to @command{gpm}. The default set of
  11403. options instruct @command{gpm} to listen to mouse events on
  11404. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  11405. more information.
  11406. @item @code{gpm} (default: @code{gpm})
  11407. The GPM package to use.
  11408. @end table
  11409. @end deftp
  11410. @anchor{guix-publish-service-type}
  11411. @deffn {Scheme Variable} guix-publish-service-type
  11412. This is the service type for @command{guix publish} (@pxref{Invoking
  11413. guix publish}). Its value must be a @code{guix-publish-configuration}
  11414. object, as described below.
  11415. This assumes that @file{/etc/guix} already contains a signing key pair as
  11416. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  11417. archive}). If that is not the case, the service will fail to start.
  11418. @end deffn
  11419. @deftp {Data Type} guix-publish-configuration
  11420. Data type representing the configuration of the @code{guix publish}
  11421. service.
  11422. @table @asis
  11423. @item @code{guix} (default: @code{guix})
  11424. The Guix package to use.
  11425. @item @code{port} (default: @code{80})
  11426. The TCP port to listen for connections.
  11427. @item @code{host} (default: @code{"localhost"})
  11428. The host (and thus, network interface) to listen to. Use
  11429. @code{"0.0.0.0"} to listen on all the network interfaces.
  11430. @item @code{compression} (default: @code{'(("gzip" 3))})
  11431. This is a list of compression method/level tuple used when compressing
  11432. substitutes. For example, to compress all substitutes with @emph{both} lzip
  11433. at level 7 and gzip at level 9, write:
  11434. @lisp
  11435. '(("lzip" 7) ("gzip" 9))
  11436. @end lisp
  11437. Level 9 achieves the best compression ratio at the expense of increased CPU
  11438. usage, whereas level 1 achieves fast compression.
  11439. An empty list disables compression altogether.
  11440. @item @code{nar-path} (default: @code{"nar"})
  11441. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  11442. publish, @option{--nar-path}}, for details.
  11443. @item @code{cache} (default: @code{#f})
  11444. When it is @code{#f}, disable caching and instead generate archives on
  11445. demand. Otherwise, this should be the name of a directory---e.g.,
  11446. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  11447. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  11448. @option{--cache}}, for more information on the tradeoffs involved.
  11449. @item @code{workers} (default: @code{#f})
  11450. When it is an integer, this is the number of worker threads used for
  11451. caching; when @code{#f}, the number of processors is used.
  11452. @xref{Invoking guix publish, @option{--workers}}, for more information.
  11453. @item @code{ttl} (default: @code{#f})
  11454. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  11455. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  11456. for more information.
  11457. @end table
  11458. @end deftp
  11459. @anchor{rngd-service}
  11460. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  11461. [#:device "/dev/hwrng"]
  11462. Return a service that runs the @command{rngd} program from @var{rng-tools}
  11463. to add @var{device} to the kernel's entropy pool. The service will fail if
  11464. @var{device} does not exist.
  11465. @end deffn
  11466. @anchor{pam-limits-service}
  11467. @cindex session limits
  11468. @cindex ulimit
  11469. @cindex priority
  11470. @cindex realtime
  11471. @cindex jackd
  11472. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  11473. Return a service that installs a configuration file for the
  11474. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  11475. @code{pam_limits} module}. The procedure optionally takes a list of
  11476. @code{pam-limits-entry} values, which can be used to specify
  11477. @code{ulimit} limits and nice priority limits to user sessions.
  11478. The following limits definition sets two hard and soft limits for all
  11479. login sessions of users in the @code{realtime} group:
  11480. @lisp
  11481. (pam-limits-service
  11482. (list
  11483. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  11484. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  11485. @end lisp
  11486. The first entry increases the maximum realtime priority for
  11487. non-privileged processes; the second entry lifts any restriction of the
  11488. maximum address space that can be locked in memory. These settings are
  11489. commonly used for real-time audio systems.
  11490. @end deffn
  11491. @node Scheduled Job Execution
  11492. @subsection Scheduled Job Execution
  11493. @cindex cron
  11494. @cindex mcron
  11495. @cindex scheduling jobs
  11496. The @code{(gnu services mcron)} module provides an interface to
  11497. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  11498. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  11499. Unix @command{cron} daemon; the main difference is that it is
  11500. implemented in Guile Scheme, which provides a lot of flexibility when
  11501. specifying the scheduling of jobs and their actions.
  11502. The example below defines an operating system that runs the
  11503. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  11504. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  11505. well as the @command{mkid} command on behalf of an unprivileged user
  11506. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  11507. gexps to introduce job definitions that are passed to mcron
  11508. (@pxref{G-Expressions}).
  11509. @lisp
  11510. (use-modules (guix) (gnu) (gnu services mcron))
  11511. (use-package-modules base idutils)
  11512. (define updatedb-job
  11513. ;; Run 'updatedb' at 3AM every day. Here we write the
  11514. ;; job's action as a Scheme procedure.
  11515. #~(job '(next-hour '(3))
  11516. (lambda ()
  11517. (execl (string-append #$findutils "/bin/updatedb")
  11518. "updatedb"
  11519. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  11520. (define garbage-collector-job
  11521. ;; Collect garbage 5 minutes after midnight every day.
  11522. ;; The job's action is a shell command.
  11523. #~(job "5 0 * * *" ;Vixie cron syntax
  11524. "guix gc -F 1G"))
  11525. (define idutils-job
  11526. ;; Update the index database as user "charlie" at 12:15PM
  11527. ;; and 19:15PM. This runs from the user's home directory.
  11528. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  11529. (string-append #$idutils "/bin/mkid src")
  11530. #:user "charlie"))
  11531. (operating-system
  11532. ;; @dots{}
  11533. (services (cons (service mcron-service-type
  11534. (mcron-configuration
  11535. (jobs (list garbage-collector-job
  11536. updatedb-job
  11537. idutils-job))))
  11538. %base-services)))
  11539. @end lisp
  11540. For more complex jobs defined in Scheme where you need control over the top
  11541. level, for instance to introduce a @code{use-modules} form, you can move your
  11542. code to a separate program using the @code{program-file} procedure of the
  11543. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  11544. illustrates that.
  11545. @lisp
  11546. (define %battery-alert-job
  11547. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  11548. #~(job
  11549. '(next-minute (range 0 60 1))
  11550. #$(program-file
  11551. "battery-alert.scm"
  11552. (with-imported-modules (source-module-closure
  11553. '((guix build utils)))
  11554. #~(begin
  11555. (use-modules (guix build utils)
  11556. (ice-9 popen)
  11557. (ice-9 regex)
  11558. (ice-9 textual-ports)
  11559. (srfi srfi-2))
  11560. (define %min-level 20)
  11561. (setenv "LC_ALL" "C") ;ensure English output
  11562. (and-let* ((input-pipe (open-pipe*
  11563. OPEN_READ
  11564. #$(file-append acpi "/bin/acpi")))
  11565. (output (get-string-all input-pipe))
  11566. (m (string-match "Discharging, ([0-9]+)%" output))
  11567. (level (string->number (match:substring m 1)))
  11568. ((< level %min-level)))
  11569. (format #t "warning: Battery level is low (~a%)~%" level)
  11570. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  11571. @end lisp
  11572. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  11573. for more information on mcron job specifications. Below is the
  11574. reference of the mcron service.
  11575. On a running system, you can use the @code{schedule} action of the service to
  11576. visualize the mcron jobs that will be executed next:
  11577. @example
  11578. # herd schedule mcron
  11579. @end example
  11580. @noindent
  11581. The example above lists the next five tasks that will be executed, but you can
  11582. also specify the number of tasks to display:
  11583. @example
  11584. # herd schedule mcron 10
  11585. @end example
  11586. @defvr {Scheme Variable} mcron-service-type
  11587. This is the type of the @code{mcron} service, whose value is an
  11588. @code{mcron-configuration} object.
  11589. This service type can be the target of a service extension that provides
  11590. it additional job specifications (@pxref{Service Composition}). In
  11591. other words, it is possible to define services that provide additional
  11592. mcron jobs to run.
  11593. @end defvr
  11594. @deftp {Data Type} mcron-configuration
  11595. Data type representing the configuration of mcron.
  11596. @table @asis
  11597. @item @code{mcron} (default: @var{mcron})
  11598. The mcron package to use.
  11599. @item @code{jobs}
  11600. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  11601. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  11602. specifications,, mcron, GNU@tie{}mcron}).
  11603. @end table
  11604. @end deftp
  11605. @node Log Rotation
  11606. @subsection Log Rotation
  11607. @cindex rottlog
  11608. @cindex log rotation
  11609. @cindex logging
  11610. Log files such as those found in @file{/var/log} tend to grow endlessly,
  11611. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  11612. their contents in separate files, possibly compressed. The @code{(gnu
  11613. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  11614. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  11615. This service is part of @code{%base-services}, and thus enabled by
  11616. default, with the default settings, for commonly encountered log files.
  11617. The example below shows how to extend it with an additional
  11618. @dfn{rotation}, should you need to do that (usually, services that
  11619. produce log files already take care of that):
  11620. @lisp
  11621. (use-modules (guix) (gnu))
  11622. (use-service-modules admin)
  11623. (define my-log-files
  11624. ;; Log files that I want to rotate.
  11625. '("/var/log/something.log" "/var/log/another.log"))
  11626. (operating-system
  11627. ;; @dots{}
  11628. (services (cons (simple-service 'rotate-my-stuff
  11629. rottlog-service-type
  11630. (list (log-rotation
  11631. (frequency 'daily)
  11632. (files my-log-files))))
  11633. %base-services)))
  11634. @end lisp
  11635. @defvr {Scheme Variable} rottlog-service-type
  11636. This is the type of the Rottlog service, whose value is a
  11637. @code{rottlog-configuration} object.
  11638. Other services can extend this one with new @code{log-rotation} objects
  11639. (see below), thereby augmenting the set of files to be rotated.
  11640. This service type can define mcron jobs (@pxref{Scheduled Job
  11641. Execution}) to run the rottlog service.
  11642. @end defvr
  11643. @deftp {Data Type} rottlog-configuration
  11644. Data type representing the configuration of rottlog.
  11645. @table @asis
  11646. @item @code{rottlog} (default: @code{rottlog})
  11647. The Rottlog package to use.
  11648. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  11649. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  11650. rottlog, GNU Rot[t]log Manual}).
  11651. @item @code{rotations} (default: @code{%default-rotations})
  11652. A list of @code{log-rotation} objects as defined below.
  11653. @item @code{jobs}
  11654. This is a list of gexps where each gexp corresponds to an mcron job
  11655. specification (@pxref{Scheduled Job Execution}).
  11656. @end table
  11657. @end deftp
  11658. @deftp {Data Type} log-rotation
  11659. Data type representing the rotation of a group of log files.
  11660. Taking an example from the Rottlog manual (@pxref{Period Related File
  11661. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  11662. defined like this:
  11663. @lisp
  11664. (log-rotation
  11665. (frequency 'daily)
  11666. (files '("/var/log/apache/*"))
  11667. (options '("storedir apache-archives"
  11668. "rotate 6"
  11669. "notifempty"
  11670. "nocompress")))
  11671. @end lisp
  11672. The list of fields is as follows:
  11673. @table @asis
  11674. @item @code{frequency} (default: @code{'weekly})
  11675. The log rotation frequency, a symbol.
  11676. @item @code{files}
  11677. The list of files or file glob patterns to rotate.
  11678. @item @code{options} (default: @code{'()})
  11679. The list of rottlog options for this rotation (@pxref{Configuration
  11680. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  11681. @item @code{post-rotate} (default: @code{#f})
  11682. Either @code{#f} or a gexp to execute once the rotation has completed.
  11683. @end table
  11684. @end deftp
  11685. @defvr {Scheme Variable} %default-rotations
  11686. Specifies weekly rotation of @code{%rotated-files} and of
  11687. @file{/var/log/guix-daemon.log}.
  11688. @end defvr
  11689. @defvr {Scheme Variable} %rotated-files
  11690. The list of syslog-controlled files to be rotated. By default it is:
  11691. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  11692. "/var/log/maillog")}.
  11693. @end defvr
  11694. @node Networking Services
  11695. @subsection Networking Services
  11696. The @code{(gnu services networking)} module provides services to configure
  11697. the network interface.
  11698. @cindex DHCP, networking service
  11699. @defvr {Scheme Variable} dhcp-client-service-type
  11700. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  11701. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  11702. is the DHCP client package to use, @code{isc-dhcp} by default.
  11703. @end defvr
  11704. @deffn {Scheme Procedure} dhcpd-service-type
  11705. This type defines a service that runs a DHCP daemon. To create a
  11706. service of this type, you must supply a @code{<dhcpd-configuration>}.
  11707. For example:
  11708. @lisp
  11709. (service dhcpd-service-type
  11710. (dhcpd-configuration
  11711. (config-file (local-file "my-dhcpd.conf"))
  11712. (interfaces '("enp0s25"))))
  11713. @end lisp
  11714. @end deffn
  11715. @deftp {Data Type} dhcpd-configuration
  11716. @table @asis
  11717. @item @code{package} (default: @code{isc-dhcp})
  11718. The package that provides the DHCP daemon. This package is expected to
  11719. provide the daemon at @file{sbin/dhcpd} relative to its output
  11720. directory. The default package is the
  11721. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  11722. @item @code{config-file} (default: @code{#f})
  11723. The configuration file to use. This is required. It will be passed to
  11724. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  11725. object (@pxref{G-Expressions, file-like objects}). See @code{man
  11726. dhcpd.conf} for details on the configuration file syntax.
  11727. @item @code{version} (default: @code{"4"})
  11728. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  11729. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  11730. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  11731. details.
  11732. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  11733. The run directory to use. At service activation time, this directory
  11734. will be created if it does not exist.
  11735. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  11736. The PID file to use. This corresponds to the @code{-pf} option of
  11737. @code{dhcpd}. See @code{man dhcpd} for details.
  11738. @item @code{interfaces} (default: @code{'()})
  11739. The names of the network interfaces on which dhcpd should listen for
  11740. broadcasts. If this list is not empty, then its elements (which must be
  11741. strings) will be appended to the @code{dhcpd} invocation when starting
  11742. the daemon. It may not be necessary to explicitly specify any
  11743. interfaces here; see @code{man dhcpd} for details.
  11744. @end table
  11745. @end deftp
  11746. @defvr {Scheme Variable} static-networking-service-type
  11747. This is the type for statically-configured network interfaces.
  11748. @c TODO Document <static-networking> data structures.
  11749. @end defvr
  11750. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  11751. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  11752. [#:requirement @code{'(udev)}]
  11753. Return a service that starts @var{interface} with address @var{ip}. If
  11754. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  11755. it must be a string specifying the default network gateway. @var{requirement}
  11756. can be used to declare a dependency on another service before configuring the
  11757. interface.
  11758. This procedure can be called several times, one for each network
  11759. interface of interest. Behind the scenes what it does is extend
  11760. @code{static-networking-service-type} with additional network interfaces
  11761. to handle.
  11762. For example:
  11763. @lisp
  11764. (static-networking-service "eno1" "192.168.1.82"
  11765. #:gateway "192.168.1.2"
  11766. #:name-servers '("192.168.1.2"))
  11767. @end lisp
  11768. @end deffn
  11769. @cindex wicd
  11770. @cindex wireless
  11771. @cindex WiFi
  11772. @cindex network management
  11773. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  11774. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  11775. management daemon that aims to simplify wired and wireless networking.
  11776. This service adds the @var{wicd} package to the global profile, providing
  11777. several commands to interact with the daemon and configure networking:
  11778. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  11779. and @command{wicd-curses} user interfaces.
  11780. @end deffn
  11781. @cindex ModemManager
  11782. @defvr {Scheme Variable} modem-manager-service-type
  11783. This is the service type for the
  11784. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  11785. service. The value for this service type is a
  11786. @code{modem-manager-configuration} record.
  11787. This service is part of @code{%desktop-services} (@pxref{Desktop
  11788. Services}).
  11789. @end defvr
  11790. @deftp {Data Type} modem-manager-configuration
  11791. Data type representing the configuration of ModemManager.
  11792. @table @asis
  11793. @item @code{modem-manager} (default: @code{modem-manager})
  11794. The ModemManager package to use.
  11795. @end table
  11796. @end deftp
  11797. @cindex USB_ModeSwitch
  11798. @cindex Modeswitching
  11799. @defvr {Scheme Variable} usb-modeswitch-service-type
  11800. This is the service type for the
  11801. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} service. The
  11802. value for this service type is a @code{usb-modeswitch-configuration} record.
  11803. When plugged in, some USB modems (and other USB devices) initially present
  11804. themselves as a read-only storage medium and not as a modem. They need to be
  11805. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  11806. installs udev rules to automatically modeswitch these devices when they are
  11807. plugged in.
  11808. This service is part of @code{%desktop-services} (@pxref{Desktop
  11809. Services}).
  11810. @end defvr
  11811. @deftp {Data Type} usb-modeswitch-configuration
  11812. Data type representing the configuration of USB_ModeSwitch.
  11813. @table @asis
  11814. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  11815. The USB_ModeSwitch package providing the binaries for modeswitching.
  11816. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  11817. The package providing the device data and udev rules file used by
  11818. USB_ModeSwitch.
  11819. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  11820. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  11821. config file shipped with USB_ModeSwitch is used which disables logging to
  11822. @file{/var/log} among other default settings. If set to @code{#f}, no config
  11823. file is used.
  11824. @end table
  11825. @end deftp
  11826. @cindex NetworkManager
  11827. @defvr {Scheme Variable} network-manager-service-type
  11828. This is the service type for the
  11829. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  11830. service. The value for this service type is a
  11831. @code{network-manager-configuration} record.
  11832. This service is part of @code{%desktop-services} (@pxref{Desktop
  11833. Services}).
  11834. @end defvr
  11835. @deftp {Data Type} network-manager-configuration
  11836. Data type representing the configuration of NetworkManager.
  11837. @table @asis
  11838. @item @code{network-manager} (default: @code{network-manager})
  11839. The NetworkManager package to use.
  11840. @item @code{dns} (default: @code{"default"})
  11841. Processing mode for DNS, which affects how NetworkManager uses the
  11842. @code{resolv.conf} configuration file.
  11843. @table @samp
  11844. @item default
  11845. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  11846. provided by currently active connections.
  11847. @item dnsmasq
  11848. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  11849. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  11850. then update @code{resolv.conf} to point to the local nameserver.
  11851. With this setting, you can share your network connection. For example when
  11852. you want to share your network connection to another laptop @i{via} an
  11853. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  11854. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  11855. and reestablish the connection (or reboot).
  11856. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  11857. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  11858. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  11859. browser on your host system, or connect to the VM @i{via} SSH
  11860. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  11861. host-to-guest connection, run this command once:
  11862. @example
  11863. nmcli connection add type tun \
  11864. connection.interface-name tap0 \
  11865. tun.mode tap tun.owner $(id -u) \
  11866. ipv4.method shared \
  11867. ipv4.addresses 172.28.112.1/24
  11868. @end example
  11869. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  11870. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  11871. @command{qemu-system-...}.
  11872. @item none
  11873. NetworkManager will not modify @code{resolv.conf}.
  11874. @end table
  11875. @item @code{vpn-plugins} (default: @code{'()})
  11876. This is the list of available plugins for virtual private networks
  11877. (VPNs). An example of this is the @code{network-manager-openvpn}
  11878. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  11879. @end table
  11880. @end deftp
  11881. @cindex Connman
  11882. @deffn {Scheme Variable} connman-service-type
  11883. This is the service type to run @url{https://01.org/connman,Connman},
  11884. a network connection manager.
  11885. Its value must be an
  11886. @code{connman-configuration} record as in this example:
  11887. @lisp
  11888. (service connman-service-type
  11889. (connman-configuration
  11890. (disable-vpn? #t)))
  11891. @end lisp
  11892. See below for details about @code{connman-configuration}.
  11893. @end deffn
  11894. @deftp {Data Type} connman-configuration
  11895. Data Type representing the configuration of connman.
  11896. @table @asis
  11897. @item @code{connman} (default: @var{connman})
  11898. The connman package to use.
  11899. @item @code{disable-vpn?} (default: @code{#f})
  11900. When true, disable connman's vpn plugin.
  11901. @end table
  11902. @end deftp
  11903. @cindex WPA Supplicant
  11904. @defvr {Scheme Variable} wpa-supplicant-service-type
  11905. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  11906. supplicant}, an authentication daemon required to authenticate against
  11907. encrypted WiFi or ethernet networks.
  11908. @end defvr
  11909. @deftp {Data Type} wpa-supplicant-configuration
  11910. Data type representing the configuration of WPA Supplicant.
  11911. It takes the following parameters:
  11912. @table @asis
  11913. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  11914. The WPA Supplicant package to use.
  11915. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  11916. List of services that should be started before WPA Supplicant starts.
  11917. @item @code{dbus?} (default: @code{#t})
  11918. Whether to listen for requests on D-Bus.
  11919. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  11920. Where to store the PID file.
  11921. @item @code{interface} (default: @code{#f})
  11922. If this is set, it must specify the name of a network interface that
  11923. WPA supplicant will control.
  11924. @item @code{config-file} (default: @code{#f})
  11925. Optional configuration file to use.
  11926. @item @code{extra-options} (default: @code{'()})
  11927. List of additional command-line arguments to pass to the daemon.
  11928. @end table
  11929. @end deftp
  11930. @cindex hostapd service, for Wi-Fi access points
  11931. @cindex Wi-Fi access points, hostapd service
  11932. @defvr {Scheme Variable} hostapd-service-type
  11933. This is the service type to run the @uref{https://w1.fi/hostapd/,
  11934. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  11935. authentication servers. Its associated value must be a
  11936. @code{hostapd-configuration} as shown below:
  11937. @lisp
  11938. ;; Use wlan1 to run the access point for "My Network".
  11939. (service hostapd-service-type
  11940. (hostapd-configuration
  11941. (interface "wlan1")
  11942. (ssid "My Network")
  11943. (channel 12)))
  11944. @end lisp
  11945. @end defvr
  11946. @deftp {Data Type} hostapd-configuration
  11947. This data type represents the configuration of the hostapd service, with
  11948. the following fields:
  11949. @table @asis
  11950. @item @code{package} (default: @code{hostapd})
  11951. The hostapd package to use.
  11952. @item @code{interface} (default: @code{"wlan0"})
  11953. The network interface to run the WiFi access point.
  11954. @item @code{ssid}
  11955. The SSID (@dfn{service set identifier}), a string that identifies this
  11956. network.
  11957. @item @code{broadcast-ssid?} (default: @code{#t})
  11958. Whether to broadcast this SSID.
  11959. @item @code{channel} (default: @code{1})
  11960. The WiFi channel to use.
  11961. @item @code{driver} (default: @code{"nl80211"})
  11962. The driver interface type. @code{"nl80211"} is used with all Linux
  11963. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  11964. RADIUS server that does # not control any wireless/wired driver.
  11965. @item @code{extra-settings} (default: @code{""})
  11966. Extra settings to append as-is to the hostapd configuration file. See
  11967. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  11968. configuration file reference.
  11969. @end table
  11970. @end deftp
  11971. @defvr {Scheme Variable} simulated-wifi-service-type
  11972. This is the type of a service to simulate WiFi networking, which can be
  11973. useful in virtual machines for testing purposes. The service loads the
  11974. Linux kernel
  11975. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  11976. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  11977. network that can be seen on @code{wlan0}, by default.
  11978. The service's value is a @code{hostapd-configuration} record.
  11979. @end defvr
  11980. @cindex iptables
  11981. @defvr {Scheme Variable} iptables-service-type
  11982. This is the service type to set up an iptables configuration. iptables is a
  11983. packet filtering framework supported by the Linux kernel. This service
  11984. supports configuring iptables for both IPv4 and IPv6. A simple example
  11985. configuration rejecting all incoming connections except those to the ssh port
  11986. 22 is shown below.
  11987. @lisp
  11988. (service iptables-service-type
  11989. (iptables-configuration
  11990. (ipv4-rules (plain-file "iptables.rules" "*filter
  11991. :INPUT ACCEPT
  11992. :FORWARD ACCEPT
  11993. :OUTPUT ACCEPT
  11994. -A INPUT -p tcp --dport 22 -j ACCEPT
  11995. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  11996. COMMIT
  11997. "))
  11998. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  11999. :INPUT ACCEPT
  12000. :FORWARD ACCEPT
  12001. :OUTPUT ACCEPT
  12002. -A INPUT -p tcp --dport 22 -j ACCEPT
  12003. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  12004. COMMIT
  12005. "))))
  12006. @end lisp
  12007. @end defvr
  12008. @deftp {Data Type} iptables-configuration
  12009. The data type representing the configuration of iptables.
  12010. @table @asis
  12011. @item @code{iptables} (default: @code{iptables})
  12012. The iptables package that provides @code{iptables-restore} and
  12013. @code{ip6tables-restore}.
  12014. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  12015. The iptables rules to use. It will be passed to @code{iptables-restore}.
  12016. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  12017. objects}).
  12018. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  12019. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  12020. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  12021. objects}).
  12022. @end table
  12023. @end deftp
  12024. @cindex nftables
  12025. @defvr {Scheme Variable} nftables-service-type
  12026. This is the service type to set up a nftables configuration. nftables is a
  12027. netfilter project that aims to replace the existing iptables, ip6tables,
  12028. arptables and ebtables framework. It provides a new packet filtering
  12029. framework, a new user-space utility @command{nft}, and a compatibility layer
  12030. for iptables. This service comes with a default ruleset
  12031. @code{%default-nftables-ruleset} that rejecting all incomming connections
  12032. except those to the ssh port 22. To use it, simply write:
  12033. @lisp
  12034. (service nftables-service-type)
  12035. @end lisp
  12036. @end defvr
  12037. @deftp {Data Type} nftables-configuration
  12038. The data type representing the configuration of nftables.
  12039. @table @asis
  12040. @item @code{package} (default: @code{nftables})
  12041. The nftables package that provides @command{nft}.
  12042. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  12043. The nftables ruleset to use. This may be any ``file-like'' object
  12044. (@pxref{G-Expressions, file-like objects}).
  12045. @end table
  12046. @end deftp
  12047. @cindex NTP (Network Time Protocol), service
  12048. @cindex ntpd, service for the Network Time Protocol daemon
  12049. @cindex real time clock
  12050. @defvr {Scheme Variable} ntp-service-type
  12051. This is the type of the service running the @uref{https://www.ntp.org,
  12052. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  12053. system clock synchronized with that of the specified NTP servers.
  12054. The value of this service is an @code{ntpd-configuration} object, as described
  12055. below.
  12056. @end defvr
  12057. @deftp {Data Type} ntp-configuration
  12058. This is the data type for the NTP service configuration.
  12059. @table @asis
  12060. @item @code{servers} (default: @code{%ntp-servers})
  12061. This is the list of servers (@code{<ntp-server>} records) with which
  12062. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  12063. definition below.
  12064. @item @code{allow-large-adjustment?} (default: @code{#t})
  12065. This determines whether @command{ntpd} is allowed to make an initial
  12066. adjustment of more than 1,000 seconds.
  12067. @item @code{ntp} (default: @code{ntp})
  12068. The NTP package to use.
  12069. @end table
  12070. @end deftp
  12071. @defvr {Scheme Variable} %ntp-servers
  12072. List of host names used as the default NTP servers. These are servers of the
  12073. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  12074. @end defvr
  12075. @deftp {Data Type} ntp-server
  12076. The data type representing the configuration of a NTP server.
  12077. @table @asis
  12078. @item @code{type} (default: @code{'server})
  12079. The type of the NTP server, given as a symbol. One of @code{'pool},
  12080. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  12081. @item @code{address}
  12082. The address of the server, as a string.
  12083. @item @code{options}
  12084. NTPD options to use with that specific server, given as a list of option names
  12085. and/or of option names and values tuples. The following example define a server
  12086. to use with the options @option{iburst} and @option{prefer}, as well as
  12087. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  12088. @example
  12089. (ntp-server
  12090. (type 'server)
  12091. (address "some.ntp.server.org")
  12092. (options `(iburst (version 3) (maxpoll 16) prefer))))
  12093. @end example
  12094. @end table
  12095. @end deftp
  12096. @cindex OpenNTPD
  12097. @deffn {Scheme Procedure} openntpd-service-type
  12098. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  12099. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  12100. clock synchronized with that of the given servers.
  12101. @lisp
  12102. (service
  12103. openntpd-service-type
  12104. (openntpd-configuration
  12105. (listen-on '("127.0.0.1" "::1"))
  12106. (sensor '("udcf0 correction 70000"))
  12107. (constraint-from '("www.gnu.org"))
  12108. (constraints-from '("https://www.google.com/"))
  12109. (allow-large-adjustment? #t)))
  12110. @end lisp
  12111. @end deffn
  12112. @defvr {Scheme Variable} %openntpd-servers
  12113. This variable is a list of the server addresses defined in
  12114. @code{%ntp-servers}.
  12115. @end defvr
  12116. @deftp {Data Type} openntpd-configuration
  12117. @table @asis
  12118. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  12119. The openntpd executable to use.
  12120. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  12121. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  12122. @item @code{query-from} (default: @code{'()})
  12123. A list of local IP address the ntpd daemon should use for outgoing queries.
  12124. @item @code{sensor} (default: @code{'()})
  12125. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  12126. will listen to each sensor that actually exists and ignore non-existent ones.
  12127. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  12128. information.
  12129. @item @code{server} (default: @code{'()})
  12130. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  12131. @item @code{servers} (default: @code{%openntp-servers})
  12132. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  12133. @item @code{constraint-from} (default: @code{'()})
  12134. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  12135. This time information is not used for precision but acts as an authenticated
  12136. constraint, thereby reducing the impact of unauthenticated NTP
  12137. man-in-the-middle attacks.
  12138. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  12139. a constraint.
  12140. @item @code{constraints-from} (default: @code{'()})
  12141. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  12142. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  12143. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  12144. @item @code{allow-large-adjustment?} (default: @code{#f})
  12145. Determines if @code{ntpd} is allowed to make an initial adjustment of more
  12146. than 180 seconds.
  12147. @end table
  12148. @end deftp
  12149. @cindex inetd
  12150. @deffn {Scheme variable} inetd-service-type
  12151. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  12152. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  12153. connections on internet sockets, and lazily starts the specified server
  12154. program when a connection is made on one of these sockets.
  12155. The value of this service is an @code{inetd-configuration} object. The
  12156. following example configures the @command{inetd} daemon to provide the
  12157. built-in @command{echo} service, as well as an smtp service which
  12158. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  12159. gateway @code{hostname}:
  12160. @lisp
  12161. (service
  12162. inetd-service-type
  12163. (inetd-configuration
  12164. (entries (list
  12165. (inetd-entry
  12166. (name "echo")
  12167. (socket-type 'stream)
  12168. (protocol "tcp")
  12169. (wait? #f)
  12170. (user "root"))
  12171. (inetd-entry
  12172. (node "127.0.0.1")
  12173. (name "smtp")
  12174. (socket-type 'stream)
  12175. (protocol "tcp")
  12176. (wait? #f)
  12177. (user "root")
  12178. (program (file-append openssh "/bin/ssh"))
  12179. (arguments
  12180. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  12181. "-W" "smtp-server:25" "user@@hostname")))))))
  12182. @end lisp
  12183. See below for more details about @code{inetd-configuration}.
  12184. @end deffn
  12185. @deftp {Data Type} inetd-configuration
  12186. Data type representing the configuration of @command{inetd}.
  12187. @table @asis
  12188. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  12189. The @command{inetd} executable to use.
  12190. @item @code{entries} (default: @code{'()})
  12191. A list of @command{inetd} service entries. Each entry should be created
  12192. by the @code{inetd-entry} constructor.
  12193. @end table
  12194. @end deftp
  12195. @deftp {Data Type} inetd-entry
  12196. Data type representing an entry in the @command{inetd} configuration.
  12197. Each entry corresponds to a socket where @command{inetd} will listen for
  12198. requests.
  12199. @table @asis
  12200. @item @code{node} (default: @code{#f})
  12201. Optional string, a comma-separated list of local addresses
  12202. @command{inetd} should use when listening for this service.
  12203. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  12204. description of all options.
  12205. @item @code{name}
  12206. A string, the name must correspond to an entry in @code{/etc/services}.
  12207. @item @code{socket-type}
  12208. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  12209. @code{'seqpacket}.
  12210. @item @code{protocol}
  12211. A string, must correspond to an entry in @code{/etc/protocols}.
  12212. @item @code{wait?} (default: @code{#t})
  12213. Whether @command{inetd} should wait for the server to exit before
  12214. listening to new service requests.
  12215. @item @code{user}
  12216. A string containing the user (and, optionally, group) name of the user
  12217. as whom the server should run. The group name can be specified in a
  12218. suffix, separated by a colon or period, i.e.@: @code{"user"},
  12219. @code{"user:group"} or @code{"user.group"}.
  12220. @item @code{program} (default: @code{"internal"})
  12221. The server program which will serve the requests, or @code{"internal"}
  12222. if @command{inetd} should use a built-in service.
  12223. @item @code{arguments} (default: @code{'()})
  12224. A list strings or file-like objects, which are the server program's
  12225. arguments, starting with the zeroth argument, i.e.@: the name of the
  12226. program itself. For @command{inetd}'s internal services, this entry
  12227. must be @code{'()} or @code{'("internal")}.
  12228. @end table
  12229. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  12230. detailed discussion of each configuration field.
  12231. @end deftp
  12232. @cindex Tor
  12233. @defvr {Scheme Variable} tor-service-type
  12234. This is the type for a service that runs the @uref{https://torproject.org,
  12235. Tor} anonymous networking daemon. The service is configured using a
  12236. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  12237. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  12238. @end defvr
  12239. @deftp {Data Type} tor-configuration
  12240. @table @asis
  12241. @item @code{tor} (default: @code{tor})
  12242. The package that provides the Tor daemon. This package is expected to provide
  12243. the daemon at @file{bin/tor} relative to its output directory. The default
  12244. package is the @uref{https://www.torproject.org, Tor Project's}
  12245. implementation.
  12246. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  12247. The configuration file to use. It will be appended to a default configuration
  12248. file, and the final configuration file will be passed to @code{tor} via its
  12249. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  12250. file-like objects}). See @code{man tor} for details on the configuration file
  12251. syntax.
  12252. @item @code{hidden-services} (default: @code{'()})
  12253. The list of @code{<hidden-service>} records to use. For any hidden service
  12254. you include in this list, appropriate configuration to enable the hidden
  12255. service will be automatically added to the default configuration file. You
  12256. may conveniently create @code{<hidden-service>} records using the
  12257. @code{tor-hidden-service} procedure described below.
  12258. @item @code{socks-socket-type} (default: @code{'tcp})
  12259. The default socket type that Tor should use for its SOCKS socket. This must
  12260. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  12261. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  12262. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  12263. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  12264. @code{tor} group.
  12265. If you want to customize the SOCKS socket in more detail, leave
  12266. @code{socks-socket-type} at its default value of @code{'tcp} and use
  12267. @code{config-file} to override the default by providing your own
  12268. @code{SocksPort} option.
  12269. @end table
  12270. @end deftp
  12271. @cindex hidden service
  12272. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  12273. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  12274. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  12275. @example
  12276. '((22 "127.0.0.1:22")
  12277. (80 "127.0.0.1:8080"))
  12278. @end example
  12279. In this example, port 22 of the hidden service is mapped to local port 22, and
  12280. port 80 is mapped to local port 8080.
  12281. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  12282. the @file{hostname} file contains the @code{.onion} host name for the hidden
  12283. service.
  12284. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  12285. project's documentation} for more information.
  12286. @end deffn
  12287. The @code{(gnu services rsync)} module provides the following services:
  12288. You might want an rsync daemon if you have files that you want available
  12289. so anyone (or just yourself) can download existing files or upload new
  12290. files.
  12291. @deffn {Scheme Variable} rsync-service-type
  12292. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  12293. The value for this service type is a
  12294. @command{rsync-configuration} record as in this example:
  12295. @lisp
  12296. (service rsync-service-type)
  12297. @end lisp
  12298. See below for details about @code{rsync-configuration}.
  12299. @end deffn
  12300. @deftp {Data Type} rsync-configuration
  12301. Data type representing the configuration for @code{rsync-service}.
  12302. @table @asis
  12303. @item @code{package} (default: @var{rsync})
  12304. @code{rsync} package to use.
  12305. @item @code{port-number} (default: @code{873})
  12306. TCP port on which @command{rsync} listens for incoming connections. If port
  12307. is less than @code{1024} @command{rsync} needs to be started as the
  12308. @code{root} user and group.
  12309. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  12310. Name of the file where @command{rsync} writes its PID.
  12311. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  12312. Name of the file where @command{rsync} writes its lock file.
  12313. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  12314. Name of the file where @command{rsync} writes its log file.
  12315. @item @code{use-chroot?} (default: @var{#t})
  12316. Whether to use chroot for @command{rsync} shared directory.
  12317. @item @code{share-path} (default: @file{/srv/rsync})
  12318. Location of the @command{rsync} shared directory.
  12319. @item @code{share-comment} (default: @code{"Rsync share"})
  12320. Comment of the @command{rsync} shared directory.
  12321. @item @code{read-only?} (default: @var{#f})
  12322. Read-write permissions to shared directory.
  12323. @item @code{timeout} (default: @code{300})
  12324. I/O timeout in seconds.
  12325. @item @code{user} (default: @var{"root"})
  12326. Owner of the @code{rsync} process.
  12327. @item @code{group} (default: @var{"root"})
  12328. Group of the @code{rsync} process.
  12329. @item @code{uid} (default: @var{"rsyncd"})
  12330. User name or user ID that file transfers to and from that module should take
  12331. place as when the daemon was run as @code{root}.
  12332. @item @code{gid} (default: @var{"rsyncd"})
  12333. Group name or group ID that will be used when accessing the module.
  12334. @end table
  12335. @end deftp
  12336. Furthermore, @code{(gnu services ssh)} provides the following services.
  12337. @cindex SSH
  12338. @cindex SSH server
  12339. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  12340. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  12341. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  12342. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  12343. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  12344. [#:public-key-authentication? #t] [#:initialize? #t]
  12345. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  12346. @var{host-key} must designate a file containing the host key, and readable
  12347. only by root.
  12348. When @var{daemonic?} is true, @command{lshd} will detach from the
  12349. controlling terminal and log its output to syslogd, unless one sets
  12350. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  12351. depend on existence of syslogd service. When @var{pid-file?} is true,
  12352. @command{lshd} writes its PID to the file called @var{pid-file}.
  12353. When @var{initialize?} is true, automatically create the seed and host key
  12354. upon service activation if they do not exist yet. This may take long and
  12355. require interaction.
  12356. When @var{initialize?} is false, it is up to the user to initialize the
  12357. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  12358. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  12359. basics,,, lsh, LSH Manual}).
  12360. When @var{interfaces} is empty, lshd listens for connections on all the
  12361. network interfaces; otherwise, @var{interfaces} must be a list of host names
  12362. or addresses.
  12363. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  12364. passwords, and @var{root-login?} specifies whether to accept log-ins as
  12365. root.
  12366. The other options should be self-descriptive.
  12367. @end deffn
  12368. @cindex SSH
  12369. @cindex SSH server
  12370. @deffn {Scheme Variable} openssh-service-type
  12371. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  12372. shell daemon, @command{sshd}. Its value must be an
  12373. @code{openssh-configuration} record as in this example:
  12374. @lisp
  12375. (service openssh-service-type
  12376. (openssh-configuration
  12377. (x11-forwarding? #t)
  12378. (permit-root-login 'without-password)
  12379. (authorized-keys
  12380. `(("alice" ,(local-file "alice.pub"))
  12381. ("bob" ,(local-file "bob.pub"))))))
  12382. @end lisp
  12383. See below for details about @code{openssh-configuration}.
  12384. This service can be extended with extra authorized keys, as in this
  12385. example:
  12386. @lisp
  12387. (service-extension openssh-service-type
  12388. (const `(("charlie"
  12389. ,(local-file "charlie.pub")))))
  12390. @end lisp
  12391. @end deffn
  12392. @deftp {Data Type} openssh-configuration
  12393. This is the configuration record for OpenSSH's @command{sshd}.
  12394. @table @asis
  12395. @item @code{openssh} (default @var{openssh})
  12396. The Openssh package to use.
  12397. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  12398. Name of the file where @command{sshd} writes its PID.
  12399. @item @code{port-number} (default: @code{22})
  12400. TCP port on which @command{sshd} listens for incoming connections.
  12401. @item @code{permit-root-login} (default: @code{#f})
  12402. This field determines whether and when to allow logins as root. If
  12403. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  12404. If it's the symbol @code{'without-password}, then root logins are
  12405. permitted but not with password-based authentication.
  12406. @item @code{allow-empty-passwords?} (default: @code{#f})
  12407. When true, users with empty passwords may log in. When false, they may
  12408. not.
  12409. @item @code{password-authentication?} (default: @code{#t})
  12410. When true, users may log in with their password. When false, they have
  12411. other authentication methods.
  12412. @item @code{public-key-authentication?} (default: @code{#t})
  12413. When true, users may log in using public key authentication. When
  12414. false, users have to use other authentication method.
  12415. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  12416. This is used only by protocol version 2.
  12417. @item @code{x11-forwarding?} (default: @code{#f})
  12418. When true, forwarding of X11 graphical client connections is
  12419. enabled---in other words, @command{ssh} options @option{-X} and
  12420. @option{-Y} will work.
  12421. @item @code{allow-agent-forwarding?} (default: @code{#t})
  12422. Whether to allow agent forwarding.
  12423. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  12424. Whether to allow TCP forwarding.
  12425. @item @code{gateway-ports?} (default: @code{#f})
  12426. Whether to allow gateway ports.
  12427. @item @code{challenge-response-authentication?} (default: @code{#f})
  12428. Specifies whether challenge response authentication is allowed (e.g.@: via
  12429. PAM).
  12430. @item @code{use-pam?} (default: @code{#t})
  12431. Enables the Pluggable Authentication Module interface. If set to
  12432. @code{#t}, this will enable PAM authentication using
  12433. @code{challenge-response-authentication?} and
  12434. @code{password-authentication?}, in addition to PAM account and session
  12435. module processing for all authentication types.
  12436. Because PAM challenge response authentication usually serves an
  12437. equivalent role to password authentication, you should disable either
  12438. @code{challenge-response-authentication?} or
  12439. @code{password-authentication?}.
  12440. @item @code{print-last-log?} (default: @code{#t})
  12441. Specifies whether @command{sshd} should print the date and time of the
  12442. last user login when a user logs in interactively.
  12443. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  12444. Configures external subsystems (e.g.@: file transfer daemon).
  12445. This is a list of two-element lists, each of which containing the
  12446. subsystem name and a command (with optional arguments) to execute upon
  12447. subsystem request.
  12448. The command @command{internal-sftp} implements an in-process SFTP
  12449. server. Alternatively, one can specify the @command{sftp-server} command:
  12450. @lisp
  12451. (service openssh-service-type
  12452. (openssh-configuration
  12453. (subsystems
  12454. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  12455. @end lisp
  12456. @item @code{accepted-environment} (default: @code{'()})
  12457. List of strings describing which environment variables may be exported.
  12458. Each string gets on its own line. See the @code{AcceptEnv} option in
  12459. @code{man sshd_config}.
  12460. This example allows ssh-clients to export the @env{COLORTERM} variable.
  12461. It is set by terminal emulators, which support colors. You can use it in
  12462. your shell's resource file to enable colors for the prompt and commands
  12463. if this variable is set.
  12464. @lisp
  12465. (service openssh-service-type
  12466. (openssh-configuration
  12467. (accepted-environment '("COLORTERM"))))
  12468. @end lisp
  12469. @item @code{authorized-keys} (default: @code{'()})
  12470. @cindex authorized keys, SSH
  12471. @cindex SSH authorized keys
  12472. This is the list of authorized keys. Each element of the list is a user
  12473. name followed by one or more file-like objects that represent SSH public
  12474. keys. For example:
  12475. @lisp
  12476. (openssh-configuration
  12477. (authorized-keys
  12478. `(("rekado" ,(local-file "rekado.pub"))
  12479. ("chris" ,(local-file "chris.pub"))
  12480. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  12481. @end lisp
  12482. @noindent
  12483. registers the specified public keys for user accounts @code{rekado},
  12484. @code{chris}, and @code{root}.
  12485. Additional authorized keys can be specified @i{via}
  12486. @code{service-extension}.
  12487. Note that this does @emph{not} interfere with the use of
  12488. @file{~/.ssh/authorized_keys}.
  12489. @item @code{log-level} (default: @code{'info})
  12490. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  12491. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  12492. page for @file{sshd_config} for the full list of level names.
  12493. @item @code{extra-content} (default: @code{""})
  12494. This field can be used to append arbitrary text to the configuration file. It
  12495. is especially useful for elaborate configurations that cannot be expressed
  12496. otherwise. This configuration, for example, would generally disable root
  12497. logins, but permit them from one specific IP address:
  12498. @lisp
  12499. (openssh-configuration
  12500. (extra-content "\
  12501. Match Address 192.168.0.1
  12502. PermitRootLogin yes"))
  12503. @end lisp
  12504. @end table
  12505. @end deftp
  12506. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  12507. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  12508. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  12509. object.
  12510. For example, to specify a Dropbear service listening on port 1234, add
  12511. this call to the operating system's @code{services} field:
  12512. @lisp
  12513. (dropbear-service (dropbear-configuration
  12514. (port-number 1234)))
  12515. @end lisp
  12516. @end deffn
  12517. @deftp {Data Type} dropbear-configuration
  12518. This data type represents the configuration of a Dropbear SSH daemon.
  12519. @table @asis
  12520. @item @code{dropbear} (default: @var{dropbear})
  12521. The Dropbear package to use.
  12522. @item @code{port-number} (default: 22)
  12523. The TCP port where the daemon waits for incoming connections.
  12524. @item @code{syslog-output?} (default: @code{#t})
  12525. Whether to enable syslog output.
  12526. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  12527. File name of the daemon's PID file.
  12528. @item @code{root-login?} (default: @code{#f})
  12529. Whether to allow @code{root} logins.
  12530. @item @code{allow-empty-passwords?} (default: @code{#f})
  12531. Whether to allow empty passwords.
  12532. @item @code{password-authentication?} (default: @code{#t})
  12533. Whether to enable password-based authentication.
  12534. @end table
  12535. @end deftp
  12536. @cindex AutoSSH
  12537. @deffn {Scheme Variable} autossh-service-type
  12538. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  12539. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  12540. restarting it as necessary should it die or stop passing traffic.
  12541. AutoSSH can be run manually from the command-line by passing arguments
  12542. to the binary @command{autossh} from the package @code{autossh}, but it
  12543. can also be run as a Guix service. This latter use case is documented
  12544. here.
  12545. AutoSSH can be used to forward local traffic to a remote machine using
  12546. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  12547. is run as.
  12548. For example, to specify a service running autossh as the user
  12549. @code{pino} and forwarding all local connections to port @code{8081} to
  12550. @code{remote:8081} using an SSH tunnel, add this call to the operating
  12551. system's @code{services} field:
  12552. @lisp
  12553. (service autossh-service-type
  12554. (autossh-configuration
  12555. (user "pino")
  12556. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  12557. @end lisp
  12558. @end deffn
  12559. @deftp {Data Type} autossh-configuration
  12560. This data type represents the configuration of an AutoSSH service.
  12561. @table @asis
  12562. @item @code{user} (default @code{"autossh"})
  12563. The user as which the AutoSSH service is to be run.
  12564. This assumes that the specified user exists.
  12565. @item @code{poll} (default @code{600})
  12566. Specifies the connection poll time in seconds.
  12567. @item @code{first-poll} (default @code{#f})
  12568. Specifies how many seconds AutoSSH waits before the first connection
  12569. test. After this first test, polling is resumed at the pace defined in
  12570. @code{poll}. When set to @code{#f}, the first poll is not treated
  12571. specially and will also use the connection poll specified in
  12572. @code{poll}.
  12573. @item @code{gate-time} (default @code{30})
  12574. Specifies how many seconds an SSH connection must be active before it is
  12575. considered successful.
  12576. @item @code{log-level} (default @code{1})
  12577. The log level, corresponding to the levels used by syslog---so @code{0}
  12578. is the most silent while @code{7} is the chattiest.
  12579. @item @code{max-start} (default @code{#f})
  12580. The maximum number of times SSH may be (re)started before AutoSSH exits.
  12581. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  12582. @item @code{message} (default @code{""})
  12583. The message to append to the echo message sent when testing connections.
  12584. @item @code{port} (default @code{"0"})
  12585. The ports used for monitoring the connection. When set to @code{"0"},
  12586. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  12587. a positive integer, ports @var{n} and @var{n}+1 are used for
  12588. monitoring the connection, such that port @var{n} is the base
  12589. monitoring port and @code{n+1} is the echo port. When set to
  12590. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  12591. integers, the ports @var{n} and @var{m} are used for monitoring the
  12592. connection, such that port @var{n} is the base monitoring port and
  12593. @var{m} is the echo port.
  12594. @item @code{ssh-options} (default @code{'()})
  12595. The list of command-line arguments to pass to @command{ssh} when it is
  12596. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  12597. may cause undefined behaviour.
  12598. @end table
  12599. @end deftp
  12600. @cindex WebSSH
  12601. @deffn {Scheme Variable} webssh-service-type
  12602. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  12603. program that runs a web SSH client. WebSSH can be run manually from the
  12604. command-line by passing arguments to the binary @command{wssh} from the
  12605. package @code{webssh}, but it can also be run as a Guix service. This
  12606. latter use case is documented here.
  12607. For example, to specify a service running WebSSH on loopback interface
  12608. on port @code{8888} with reject policy with a list of allowed to
  12609. connection hosts, and NGINX as a reverse-proxy to this service listening
  12610. for HTTPS connection, add this call to the operating system's
  12611. @code{services} field:
  12612. @lisp
  12613. (service webssh-service-type
  12614. (webssh-configuration (address "127.0.0.1")
  12615. (port 8888)
  12616. (policy 'reject)
  12617. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  12618. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  12619. (service nginx-service-type
  12620. (nginx-configuration
  12621. (server-blocks
  12622. (list
  12623. (nginx-server-configuration
  12624. (inherit %webssh-configuration-nginx)
  12625. (server-name '("webssh.example.com"))
  12626. (listen '("443 ssl"))
  12627. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  12628. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  12629. (locations
  12630. (cons (nginx-location-configuration
  12631. (uri "/.well-known")
  12632. (body '("root /var/www;")))
  12633. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  12634. @end lisp
  12635. @end deffn
  12636. @deftp {Data Type} webssh-configuration
  12637. Data type representing the configuration for @code{webssh-service}.
  12638. @table @asis
  12639. @item @code{package} (default: @var{webssh})
  12640. @code{webssh} package to use.
  12641. @item @code{user-name} (default: @var{"webssh"})
  12642. User name or user ID that file transfers to and from that module should take
  12643. place.
  12644. @item @code{group-name} (default: @var{"webssh"})
  12645. Group name or group ID that will be used when accessing the module.
  12646. @item @code{address} (default: @var{#f})
  12647. IP address on which @command{webssh} listens for incoming connections.
  12648. @item @code{port} (default: @var{8888})
  12649. TCP port on which @command{webssh} listens for incoming connections.
  12650. @item @code{policy} (default: @var{#f})
  12651. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  12652. @item @code{known-hosts} (default: @var{'()})
  12653. List of hosts which allowed for SSH connection from @command{webssh}.
  12654. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  12655. Name of the file where @command{rsync} writes its log file.
  12656. @item @code{log-level} (default: @var{#f})
  12657. Logging level.
  12658. @end table
  12659. @end deftp
  12660. @defvr {Scheme Variable} %facebook-host-aliases
  12661. This variable contains a string for use in @file{/etc/hosts}
  12662. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  12663. line contains a entry that maps a known server name of the Facebook
  12664. on-line service---e.g., @code{www.facebook.com}---to the local
  12665. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  12666. This variable is typically used in the @code{hosts-file} field of an
  12667. @code{operating-system} declaration (@pxref{operating-system Reference,
  12668. @file{/etc/hosts}}):
  12669. @lisp
  12670. (use-modules (gnu) (guix))
  12671. (operating-system
  12672. (host-name "mymachine")
  12673. ;; ...
  12674. (hosts-file
  12675. ;; Create a /etc/hosts file with aliases for "localhost"
  12676. ;; and "mymachine", as well as for Facebook servers.
  12677. (plain-file "hosts"
  12678. (string-append (local-host-aliases host-name)
  12679. %facebook-host-aliases))))
  12680. @end lisp
  12681. This mechanism can prevent programs running locally, such as Web
  12682. browsers, from accessing Facebook.
  12683. @end defvr
  12684. The @code{(gnu services avahi)} provides the following definition.
  12685. @defvr {Scheme Variable} avahi-service-type
  12686. This is the service that runs @command{avahi-daemon}, a system-wide
  12687. mDNS/DNS-SD responder that allows for service discovery and
  12688. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  12689. Its value must be a @code{zero-configuration} record---see below.
  12690. This service extends the name service cache daemon (nscd) so that it can
  12691. resolve @code{.local} host names using
  12692. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  12693. Service Switch}, for information on host name resolution.
  12694. Additionally, add the @var{avahi} package to the system profile so that
  12695. commands such as @command{avahi-browse} are directly usable.
  12696. @end defvr
  12697. @deftp {Data Type} avahi-configuration
  12698. Data type representation the configuration for Avahi.
  12699. @table @asis
  12700. @item @code{host-name} (default: @code{#f})
  12701. If different from @code{#f}, use that as the host name to
  12702. publish for this machine; otherwise, use the machine's actual host name.
  12703. @item @code{publish?} (default: @code{#t})
  12704. When true, allow host names and services to be published (broadcast) over the
  12705. network.
  12706. @item @code{publish-workstation?} (default: @code{#t})
  12707. When true, @command{avahi-daemon} publishes the machine's host name and IP
  12708. address via mDNS on the local network. To view the host names published on
  12709. your local network, you can run:
  12710. @example
  12711. avahi-browse _workstation._tcp
  12712. @end example
  12713. @item @code{wide-area?} (default: @code{#f})
  12714. When true, DNS-SD over unicast DNS is enabled.
  12715. @item @code{ipv4?} (default: @code{#t})
  12716. @itemx @code{ipv6?} (default: @code{#t})
  12717. These fields determine whether to use IPv4/IPv6 sockets.
  12718. @item @code{domains-to-browse} (default: @code{'()})
  12719. This is a list of domains to browse.
  12720. @end table
  12721. @end deftp
  12722. @deffn {Scheme Variable} openvswitch-service-type
  12723. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  12724. service, whose value should be an @code{openvswitch-configuration}
  12725. object.
  12726. @end deffn
  12727. @deftp {Data Type} openvswitch-configuration
  12728. Data type representing the configuration of Open vSwitch, a multilayer
  12729. virtual switch which is designed to enable massive network automation
  12730. through programmatic extension.
  12731. @table @asis
  12732. @item @code{package} (default: @var{openvswitch})
  12733. Package object of the Open vSwitch.
  12734. @end table
  12735. @end deftp
  12736. @defvr {Scheme Variable} pagekite-service-type
  12737. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  12738. a tunneling solution for making localhost servers publicly visible, even from
  12739. behind restrictive firewalls or NAT without forwarded ports. The value for
  12740. this service type is a @code{pagekite-configuration} record.
  12741. Here's an example exposing the local HTTP and SSH daemons:
  12742. @lisp
  12743. (service pagekite-service-type
  12744. (pagekite-configuration
  12745. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  12746. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  12747. (extra-file "/etc/pagekite.rc")))
  12748. @end lisp
  12749. @end defvr
  12750. @deftp {Data Type} pagekite-configuration
  12751. Data type representing the configuration of PageKite.
  12752. @table @asis
  12753. @item @code{package} (default: @var{pagekite})
  12754. Package object of PageKite.
  12755. @item @code{kitename} (default: @code{#f})
  12756. PageKite name for authenticating to the frontend server.
  12757. @item @code{kitesecret} (default: @code{#f})
  12758. Shared secret for authenticating to the frontend server. You should probably
  12759. put this inside @code{extra-file} instead.
  12760. @item @code{frontend} (default: @code{#f})
  12761. Connect to the named PageKite frontend server instead of the
  12762. @uref{https://pagekite.net,,pagekite.net} service.
  12763. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  12764. List of service kites to use. Exposes HTTP on port 80 by default. The format
  12765. is @code{proto:kitename:host:port:secret}.
  12766. @item @code{extra-file} (default: @code{#f})
  12767. Extra configuration file to read, which you are expected to create manually.
  12768. Use this to add additional options and manage shared secrets out-of-band.
  12769. @end table
  12770. @end deftp
  12771. @node Unattended Upgrades
  12772. @subsection Unattended Upgrades
  12773. @cindex unattended upgrades
  12774. @cindex upgrades, unattended
  12775. Guix provides a service to perform @emph{unattended upgrades}:
  12776. periodically, the system automatically reconfigures itself from the
  12777. latest Guix. Guix System has several properties that make unattended
  12778. upgrades safe:
  12779. @itemize
  12780. @item
  12781. upgrades are transactional (either the upgrade succeeds or it fails, but
  12782. you cannot end up with an ``in-between'' system state);
  12783. @item
  12784. the upgrade log is kept---you can view it with @command{guix system
  12785. list-generations}---and you can roll back to any previous generation,
  12786. should the upgraded system fail to behave as intended;
  12787. @item
  12788. channel code is authenticated so you know you can only run genuine code
  12789. (@pxref{Channels});
  12790. @item
  12791. @command{guix system reconfigure} prevents downgrades, which makes it
  12792. immune to @dfn{downgrade attacks}.
  12793. @end itemize
  12794. To set up unattended upgrades, add an instance of
  12795. @code{unattended-upgrade-service-type} like the one below to the list of
  12796. your operating system services:
  12797. @lisp
  12798. (service unattended-upgrade-service-type)
  12799. @end lisp
  12800. The defaults above set up weekly upgrades: every Sunday at midnight.
  12801. You do not need to provide the operating system configuration file: it
  12802. uses @file{/run/current-system/configuration.scm}, which ensures it
  12803. always uses your latest configuration---@pxref{provenance-service-type},
  12804. for more information about this file.
  12805. There are several things that can be configured, in particular the
  12806. periodicity and services (daemons) to be restarted upon completion.
  12807. When the upgrade is successful, the service takes care of deleting
  12808. system generations older that some threshold, as per @command{guix
  12809. system delete-generations}. See the reference below for details.
  12810. To ensure that upgrades are actually happening, you can run
  12811. @command{guix system describe}. To investigate upgrade failures, visit
  12812. the unattended upgrade log file (see below).
  12813. @defvr {Scheme Variable} unattended-upgrade-service-type
  12814. This is the service type for unattended upgrades. It sets up an mcron
  12815. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  12816. reconfigure} from the latest version of the specified channels.
  12817. Its value must be a @code{unattended-upgrade-configuration} record (see
  12818. below).
  12819. @end defvr
  12820. @deftp {Data Type} unattended-upgrade-configuration
  12821. This data type represents the configuration of the unattended upgrade
  12822. service. The following fields are available:
  12823. @table @asis
  12824. @item @code{schedule} (default: @code{"30 01 * * 0"})
  12825. This is the schedule of upgrades, expressed as a gexp containing an
  12826. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  12827. mcron, GNU@tie{}mcron}).
  12828. @item @code{channels} (default: @code{#~%default-channels})
  12829. This gexp specifies the channels to use for the upgrade
  12830. (@pxref{Channels}). By default, the tip of the official @code{guix}
  12831. channel is used.
  12832. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  12833. This field specifies the operating system configuration file to use.
  12834. The default is to reuse the config file of the current configuration.
  12835. There are cases, though, where referring to
  12836. @file{/run/current-system/configuration.scm} is not enough, for instance
  12837. because that file refers to extra files (SSH public keys, extra
  12838. configuration files, etc.) @i{via} @code{local-file} and similar
  12839. constructs. For those cases, we recommend something along these lines:
  12840. @lisp
  12841. (unattended-upgrade-configuration
  12842. (operating-system-file
  12843. (file-append (local-file "." "config-dir" #:recursive? #t)
  12844. "/config.scm")))
  12845. @end lisp
  12846. The effect here is to import all of the current directory into the
  12847. store, and to refer to @file{config.scm} within that directory.
  12848. Therefore, uses of @code{local-file} within @file{config.scm} will work
  12849. as expected. @xref{G-Expressions}, for information about
  12850. @code{local-file} and @code{file-append}.
  12851. @item @code{services-to-restart} (default: @code{'(mcron)})
  12852. This field specifies the Shepherd services to restart when the upgrade
  12853. completes.
  12854. Those services are restarted right away upon completion, as with
  12855. @command{herd restart}, which ensures that the latest version is
  12856. running---remember that by default @command{guix system reconfigure}
  12857. only restarts services that are not currently running, which is
  12858. conservative: it minimizes disruption but leaves outdated services
  12859. running.
  12860. By default, the @code{mcron} service is restarted. This ensures that
  12861. the latest version of the unattended upgrade job will be used next time.
  12862. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  12863. This is the expiration time in seconds for system generations. System
  12864. generations older that this amount of time are deleted with
  12865. @command{guix system delete-generations} when an upgrade completes.
  12866. @quotation Note
  12867. The unattended upgrade service does not run the garbage collector. You
  12868. will probably want to set up your own mcron job to run @command{guix gc}
  12869. periodically.
  12870. @end quotation
  12871. @item @code{maximum-duration} (default: @code{3600})
  12872. Maximum duration in seconds for the upgrade; past that time, the upgrade
  12873. aborts.
  12874. This is primarily useful to ensure the upgrade does not end up
  12875. rebuilding or re-downloading ``the world''.
  12876. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  12877. File where unattended upgrades are logged.
  12878. @end table
  12879. @end deftp
  12880. @node X Window
  12881. @subsection X Window
  12882. @cindex X11
  12883. @cindex X Window System
  12884. @cindex login manager
  12885. Support for the X Window graphical display system---specifically
  12886. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  12887. there is no @code{xorg-service} procedure. Instead, the X server is
  12888. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  12889. @cindex GDM
  12890. @cindex GNOME, login manager
  12891. GDM of course allows users to log in into window managers and desktop
  12892. environments other than GNOME; for those using GNOME, GDM is required for
  12893. features such as automatic screen locking.
  12894. @cindex window manager
  12895. To use X11, you must install at least one @dfn{window manager}---for
  12896. example the @code{windowmaker} or @code{openbox} packages---preferably
  12897. by adding it to the @code{packages} field of your operating system
  12898. definition (@pxref{operating-system Reference, system-wide packages}).
  12899. @defvr {Scheme Variable} gdm-service-type
  12900. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  12901. Desktop Manager} (GDM), a program that manages graphical display servers and
  12902. handles graphical user logins. Its value must be a @code{gdm-configuration}
  12903. (see below).
  12904. @cindex session types (X11)
  12905. @cindex X11 session types
  12906. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  12907. @file{/run/current-system/profile/share/xsessions} and allows users to choose
  12908. a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
  12909. and @code{i3} provide @file{.desktop} files; adding them to the system-wide
  12910. set of packages automatically makes them available at the log-in screen.
  12911. In addition, @file{~/.xsession} files are honored. When available,
  12912. @file{~/.xsession} must be an executable that starts a window manager
  12913. and/or other X clients.
  12914. @end defvr
  12915. @deftp {Data Type} gdm-configuration
  12916. @table @asis
  12917. @item @code{auto-login?} (default: @code{#f})
  12918. @itemx @code{default-user} (default: @code{#f})
  12919. When @code{auto-login?} is false, GDM presents a log-in screen.
  12920. When @code{auto-login?} is true, GDM logs in directly as
  12921. @code{default-user}.
  12922. @item @code{debug?} (default: @code{#f})
  12923. When true, GDM writes debug messages to its log.
  12924. @item @code{gnome-shell-assets} (default: ...)
  12925. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  12926. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  12927. Configuration of the Xorg graphical server.
  12928. @item @code{xsession} (default: @code{(xinitrc)})
  12929. Script to run before starting a X session.
  12930. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  12931. File name of the @code{dbus-daemon} executable.
  12932. @item @code{gdm} (default: @code{gdm})
  12933. The GDM package to use.
  12934. @end table
  12935. @end deftp
  12936. @defvr {Scheme Variable} slim-service-type
  12937. This is the type for the SLiM graphical login manager for X11.
  12938. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  12939. allows users to choose a session from the log-in screen using @kbd{F1}. It
  12940. also honors @file{~/.xsession} files.
  12941. Unlike GDM, SLiM does not spawn the user session on a different VT after
  12942. logging in, which means that you can only start one graphical session. If you
  12943. want to be able to run multiple graphical sessions at the same time you have
  12944. to add multiple SLiM services to your system services. The following example
  12945. shows how to replace the default GDM service with two SLiM services on tty7
  12946. and tty8.
  12947. @lisp
  12948. (use-modules (gnu services)
  12949. (gnu services desktop)
  12950. (gnu services xorg)
  12951. (srfi srfi-1)) ;for 'remove'
  12952. (operating-system
  12953. ;; ...
  12954. (services (cons* (service slim-service-type (slim-configuration
  12955. (display ":0")
  12956. (vt "vt7")))
  12957. (service slim-service-type (slim-configuration
  12958. (display ":1")
  12959. (vt "vt8")))
  12960. (remove (lambda (service)
  12961. (eq? (service-kind service) gdm-service-type))
  12962. %desktop-services))))
  12963. @end lisp
  12964. @end defvr
  12965. @deftp {Data Type} slim-configuration
  12966. Data type representing the configuration of @code{slim-service-type}.
  12967. @table @asis
  12968. @item @code{allow-empty-passwords?} (default: @code{#t})
  12969. Whether to allow logins with empty passwords.
  12970. @item @code{auto-login?} (default: @code{#f})
  12971. @itemx @code{default-user} (default: @code{""})
  12972. When @code{auto-login?} is false, SLiM presents a log-in screen.
  12973. When @code{auto-login?} is true, SLiM logs in directly as
  12974. @code{default-user}.
  12975. @item @code{theme} (default: @code{%default-slim-theme})
  12976. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  12977. The graphical theme to use and its name.
  12978. @item @code{auto-login-session} (default: @code{#f})
  12979. If true, this must be the name of the executable to start as the default
  12980. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  12981. If false, a session described by one of the available @file{.desktop}
  12982. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  12983. will be used.
  12984. @quotation Note
  12985. You must install at least one window manager in the system profile or in
  12986. your user profile. Failing to do that, if @code{auto-login-session} is
  12987. false, you will be unable to log in.
  12988. @end quotation
  12989. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  12990. Configuration of the Xorg graphical server.
  12991. @item @code{display} (default @code{":0"})
  12992. The display on which to start the Xorg graphical server.
  12993. @item @code{vt} (default @code{"vt7"})
  12994. The VT on which to start the Xorg graphical server.
  12995. @item @code{xauth} (default: @code{xauth})
  12996. The XAuth package to use.
  12997. @item @code{shepherd} (default: @code{shepherd})
  12998. The Shepherd package used when invoking @command{halt} and
  12999. @command{reboot}.
  13000. @item @code{sessreg} (default: @code{sessreg})
  13001. The sessreg package used in order to register the session.
  13002. @item @code{slim} (default: @code{slim})
  13003. The SLiM package to use.
  13004. @end table
  13005. @end deftp
  13006. @defvr {Scheme Variable} %default-theme
  13007. @defvrx {Scheme Variable} %default-theme-name
  13008. The default SLiM theme and its name.
  13009. @end defvr
  13010. @deftp {Data Type} sddm-configuration
  13011. This is the data type representing the SDDM service configuration.
  13012. @table @asis
  13013. @item @code{display-server} (default: "x11")
  13014. Select display server to use for the greeter. Valid values are
  13015. @samp{"x11"} or @samp{"wayland"}.
  13016. @item @code{numlock} (default: "on")
  13017. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  13018. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  13019. Command to run when halting.
  13020. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  13021. Command to run when rebooting.
  13022. @item @code{theme} (default "maldives")
  13023. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  13024. @samp{"maldives"} or @samp{"maya"}.
  13025. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  13026. Directory to look for themes.
  13027. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  13028. Directory to look for faces.
  13029. @item @code{default-path} (default "/run/current-system/profile/bin")
  13030. Default PATH to use.
  13031. @item @code{minimum-uid} (default: 1000)
  13032. Minimum UID displayed in SDDM and allowed for log-in.
  13033. @item @code{maximum-uid} (default: 2000)
  13034. Maximum UID to display in SDDM.
  13035. @item @code{remember-last-user?} (default #t)
  13036. Remember last user.
  13037. @item @code{remember-last-session?} (default #t)
  13038. Remember last session.
  13039. @item @code{hide-users} (default "")
  13040. Usernames to hide from SDDM greeter.
  13041. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  13042. Users with shells listed will be hidden from the SDDM greeter.
  13043. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  13044. Script to run before starting a wayland session.
  13045. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  13046. Directory to look for desktop files starting wayland sessions.
  13047. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  13048. Configuration of the Xorg graphical server.
  13049. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  13050. Path to xauth.
  13051. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  13052. Path to Xephyr.
  13053. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  13054. Script to run after starting xorg-server.
  13055. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  13056. Script to run before stopping xorg-server.
  13057. @item @code{xsession-command} (default: @code{xinitrc})
  13058. Script to run before starting a X session.
  13059. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  13060. Directory to look for desktop files starting X sessions.
  13061. @item @code{minimum-vt} (default: 7)
  13062. Minimum VT to use.
  13063. @item @code{auto-login-user} (default "")
  13064. User to use for auto-login.
  13065. @item @code{auto-login-session} (default "")
  13066. Desktop file to use for auto-login.
  13067. @item @code{relogin?} (default #f)
  13068. Relogin after logout.
  13069. @end table
  13070. @end deftp
  13071. @cindex login manager
  13072. @cindex X11 login
  13073. @defvr {Scheme Variable} sddm-service-type
  13074. This is the type of the service to run the
  13075. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  13076. must be a @code{sddm-configuration} record (see below).
  13077. Here's an example use:
  13078. @lisp
  13079. (service sddm-service-type
  13080. (sddm-configuration
  13081. (auto-login-user "alice")
  13082. (auto-login-session "xfce.desktop")))
  13083. @end lisp
  13084. @end defvr
  13085. @deftp {Data Type} sddm-configuration
  13086. This data type represents the configuration of the SDDM login manager.
  13087. The available fields are:
  13088. @table @asis
  13089. @item @code{sddm} (default: @code{sddm})
  13090. The SDDM package to use.
  13091. @item @code{display-server} (default: @code{"x11"})
  13092. This must be either @code{"x11"} or @code{"wayland"}.
  13093. @c FIXME: Add more fields.
  13094. @item @code{auto-login-user} (default: @code{""})
  13095. If non-empty, this is the user account under which to log in
  13096. automatically.
  13097. @item @code{auto-login-session} (default: @code{""})
  13098. If non-empty, this is the @file{.desktop} file name to use as the
  13099. auto-login session.
  13100. @end table
  13101. @end deftp
  13102. @cindex Xorg, configuration
  13103. @deftp {Data Type} xorg-configuration
  13104. This data type represents the configuration of the Xorg graphical display
  13105. server. Note that there is no Xorg service; instead, the X server is started
  13106. by a ``display manager'' such as GDM, SDDM, and SLiM. Thus, the configuration
  13107. of these display managers aggregates an @code{xorg-configuration} record.
  13108. @table @asis
  13109. @item @code{modules} (default: @code{%default-xorg-modules})
  13110. This is a list of @dfn{module packages} loaded by the Xorg
  13111. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  13112. @item @code{fonts} (default: @code{%default-xorg-fonts})
  13113. This is a list of font directories to add to the server's @dfn{font path}.
  13114. @item @code{drivers} (default: @code{'()})
  13115. This must be either the empty list, in which case Xorg chooses a graphics
  13116. driver automatically, or a list of driver names that will be tried in this
  13117. order---e.g., @code{("modesetting" "vesa")}.
  13118. @item @code{resolutions} (default: @code{'()})
  13119. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  13120. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  13121. 768) (640 480))}.
  13122. @cindex keyboard layout, for Xorg
  13123. @cindex keymap, for Xorg
  13124. @item @code{keyboard-layout} (default: @code{#f})
  13125. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  13126. English (``qwerty'') for a 105-key PC keyboard.
  13127. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  13128. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  13129. information on how to specify the keyboard layout.
  13130. @item @code{extra-config} (default: @code{'()})
  13131. This is a list of strings or objects appended to the configuration file. It
  13132. is used to pass extra text to be added verbatim to the configuration file.
  13133. @item @code{server} (default: @code{xorg-server})
  13134. This is the package providing the Xorg server.
  13135. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  13136. This is the list of command-line arguments to pass to the X server. The
  13137. default is @code{-nolisten tcp}.
  13138. @end table
  13139. @end deftp
  13140. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  13141. [@var{login-manager-service-type}]
  13142. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  13143. @var{config}, an @code{<xorg-configuration>} record.
  13144. Since the Xorg configuration is embedded in the log-in manager's
  13145. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  13146. shorthand to set the Xorg configuration.
  13147. @end deffn
  13148. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  13149. Return a @code{startx} script in which the modules, fonts, etc. specified
  13150. in @var{config}, are available. The result should be used in place of
  13151. @code{startx}.
  13152. Usually the X server is started by a login manager.
  13153. @end deffn
  13154. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  13155. Add @var{package}, a package for a screen locker or screen saver whose
  13156. command is @var{program}, to the set of setuid programs and add a PAM entry
  13157. for it. For example:
  13158. @lisp
  13159. (screen-locker-service xlockmore "xlock")
  13160. @end lisp
  13161. makes the good ol' XlockMore usable.
  13162. @end deffn
  13163. @node Printing Services
  13164. @subsection Printing Services
  13165. @cindex printer support with CUPS
  13166. The @code{(gnu services cups)} module provides a Guix service definition
  13167. for the CUPS printing service. To add printer support to a Guix
  13168. system, add a @code{cups-service} to the operating system definition:
  13169. @deffn {Scheme Variable} cups-service-type
  13170. The service type for the CUPS print server. Its value should be a valid
  13171. CUPS configuration (see below). To use the default settings, simply
  13172. write:
  13173. @lisp
  13174. (service cups-service-type)
  13175. @end lisp
  13176. @end deffn
  13177. The CUPS configuration controls the basic things about your CUPS
  13178. installation: what interfaces it listens on, what to do if a print job
  13179. fails, how much logging to do, and so on. To actually add a printer,
  13180. you have to visit the @url{http://localhost:631} URL, or use a tool such
  13181. as GNOME's printer configuration services. By default, configuring a
  13182. CUPS service will generate a self-signed certificate if needed, for
  13183. secure connections to the print server.
  13184. Suppose you want to enable the Web interface of CUPS and also add
  13185. support for Epson printers @i{via} the @code{escpr} package and for HP
  13186. printers @i{via} the @code{hplip-minimal} package. You can do that directly,
  13187. like this (you need to use the @code{(gnu packages cups)} module):
  13188. @lisp
  13189. (service cups-service-type
  13190. (cups-configuration
  13191. (web-interface? #t)
  13192. (extensions
  13193. (list cups-filters escpr hplip-minimal))))
  13194. @end lisp
  13195. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  13196. package then it is suggested that you install the @code{hplip} package,
  13197. either in your OS configuration file or as your user.
  13198. The available configuration parameters follow. Each parameter
  13199. definition is preceded by its type; for example, @samp{string-list foo}
  13200. indicates that the @code{foo} parameter should be specified as a list of
  13201. strings. There is also a way to specify the configuration as a string,
  13202. if you have an old @code{cupsd.conf} file that you want to port over
  13203. from some other system; see the end for more details.
  13204. @c The following documentation was initially generated by
  13205. @c (generate-documentation) in (gnu services cups). Manually maintained
  13206. @c documentation is better, so we shouldn't hesitate to edit below as
  13207. @c needed. However if the change you want to make to this documentation
  13208. @c can be done in an automated way, it's probably easier to change
  13209. @c (generate-documentation) than to make it below and have to deal with
  13210. @c the churn as CUPS updates.
  13211. Available @code{cups-configuration} fields are:
  13212. @deftypevr {@code{cups-configuration} parameter} package cups
  13213. The CUPS package.
  13214. @end deftypevr
  13215. @deftypevr {@code{cups-configuration} parameter} package-list extensions
  13216. Drivers and other extensions to the CUPS package.
  13217. @end deftypevr
  13218. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  13219. Configuration of where to write logs, what directories to use for print
  13220. spools, and related privileged configuration parameters.
  13221. Available @code{files-configuration} fields are:
  13222. @deftypevr {@code{files-configuration} parameter} log-location access-log
  13223. Defines the access log filename. Specifying a blank filename disables
  13224. access log generation. The value @code{stderr} causes log entries to be
  13225. sent to the standard error file when the scheduler is running in the
  13226. foreground, or to the system log daemon when run in the background. The
  13227. value @code{syslog} causes log entries to be sent to the system log
  13228. daemon. The server name may be included in filenames using the string
  13229. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  13230. Defaults to @samp{"/var/log/cups/access_log"}.
  13231. @end deftypevr
  13232. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  13233. Where CUPS should cache data.
  13234. Defaults to @samp{"/var/cache/cups"}.
  13235. @end deftypevr
  13236. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  13237. Specifies the permissions for all configuration files that the scheduler
  13238. writes.
  13239. Note that the permissions for the printers.conf file are currently
  13240. masked to only allow access from the scheduler user (typically root).
  13241. This is done because printer device URIs sometimes contain sensitive
  13242. authentication information that should not be generally known on the
  13243. system. There is no way to disable this security feature.
  13244. Defaults to @samp{"0640"}.
  13245. @end deftypevr
  13246. @deftypevr {@code{files-configuration} parameter} log-location error-log
  13247. Defines the error log filename. Specifying a blank filename disables
  13248. error log generation. The value @code{stderr} causes log entries to be
  13249. sent to the standard error file when the scheduler is running in the
  13250. foreground, or to the system log daemon when run in the background. The
  13251. value @code{syslog} causes log entries to be sent to the system log
  13252. daemon. The server name may be included in filenames using the string
  13253. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  13254. Defaults to @samp{"/var/log/cups/error_log"}.
  13255. @end deftypevr
  13256. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  13257. Specifies which errors are fatal, causing the scheduler to exit. The
  13258. kind strings are:
  13259. @table @code
  13260. @item none
  13261. No errors are fatal.
  13262. @item all
  13263. All of the errors below are fatal.
  13264. @item browse
  13265. Browsing initialization errors are fatal, for example failed connections
  13266. to the DNS-SD daemon.
  13267. @item config
  13268. Configuration file syntax errors are fatal.
  13269. @item listen
  13270. Listen or Port errors are fatal, except for IPv6 failures on the
  13271. loopback or @code{any} addresses.
  13272. @item log
  13273. Log file creation or write errors are fatal.
  13274. @item permissions
  13275. Bad startup file permissions are fatal, for example shared TLS
  13276. certificate and key files with world-read permissions.
  13277. @end table
  13278. Defaults to @samp{"all -browse"}.
  13279. @end deftypevr
  13280. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  13281. Specifies whether the file pseudo-device can be used for new printer
  13282. queues. The URI @uref{file:///dev/null} is always allowed.
  13283. Defaults to @samp{#f}.
  13284. @end deftypevr
  13285. @deftypevr {@code{files-configuration} parameter} string group
  13286. Specifies the group name or ID that will be used when executing external
  13287. programs.
  13288. Defaults to @samp{"lp"}.
  13289. @end deftypevr
  13290. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  13291. Specifies the permissions for all log files that the scheduler writes.
  13292. Defaults to @samp{"0644"}.
  13293. @end deftypevr
  13294. @deftypevr {@code{files-configuration} parameter} log-location page-log
  13295. Defines the page log filename. Specifying a blank filename disables
  13296. page log generation. The value @code{stderr} causes log entries to be
  13297. sent to the standard error file when the scheduler is running in the
  13298. foreground, or to the system log daemon when run in the background. The
  13299. value @code{syslog} causes log entries to be sent to the system log
  13300. daemon. The server name may be included in filenames using the string
  13301. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  13302. Defaults to @samp{"/var/log/cups/page_log"}.
  13303. @end deftypevr
  13304. @deftypevr {@code{files-configuration} parameter} string remote-root
  13305. Specifies the username that is associated with unauthenticated accesses
  13306. by clients claiming to be the root user. The default is @code{remroot}.
  13307. Defaults to @samp{"remroot"}.
  13308. @end deftypevr
  13309. @deftypevr {@code{files-configuration} parameter} file-name request-root
  13310. Specifies the directory that contains print jobs and other HTTP request
  13311. data.
  13312. Defaults to @samp{"/var/spool/cups"}.
  13313. @end deftypevr
  13314. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  13315. Specifies the level of security sandboxing that is applied to print
  13316. filters, backends, and other child processes of the scheduler; either
  13317. @code{relaxed} or @code{strict}. This directive is currently only
  13318. used/supported on macOS.
  13319. Defaults to @samp{strict}.
  13320. @end deftypevr
  13321. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  13322. Specifies the location of TLS certificates and private keys. CUPS will
  13323. look for public and private keys in this directory: @file{.crt} files
  13324. for PEM-encoded certificates and corresponding @file{.key} files for
  13325. PEM-encoded private keys.
  13326. Defaults to @samp{"/etc/cups/ssl"}.
  13327. @end deftypevr
  13328. @deftypevr {@code{files-configuration} parameter} file-name server-root
  13329. Specifies the directory containing the server configuration files.
  13330. Defaults to @samp{"/etc/cups"}.
  13331. @end deftypevr
  13332. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  13333. Specifies whether the scheduler calls fsync(2) after writing
  13334. configuration or state files.
  13335. Defaults to @samp{#f}.
  13336. @end deftypevr
  13337. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  13338. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  13339. @end deftypevr
  13340. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  13341. Specifies the directory where temporary files are stored.
  13342. Defaults to @samp{"/var/spool/cups/tmp"}.
  13343. @end deftypevr
  13344. @deftypevr {@code{files-configuration} parameter} string user
  13345. Specifies the user name or ID that is used when running external
  13346. programs.
  13347. Defaults to @samp{"lp"}.
  13348. @end deftypevr
  13349. @deftypevr {@code{files-configuration} parameter} string set-env
  13350. Set the specified environment variable to be passed to child processes.
  13351. Defaults to @samp{"variable value"}.
  13352. @end deftypevr
  13353. @end deftypevr
  13354. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  13355. Specifies the logging level for the AccessLog file. The @code{config}
  13356. level logs when printers and classes are added, deleted, or modified and
  13357. when configuration files are accessed or updated. The @code{actions}
  13358. level logs when print jobs are submitted, held, released, modified, or
  13359. canceled, and any of the conditions for @code{config}. The @code{all}
  13360. level logs all requests.
  13361. Defaults to @samp{actions}.
  13362. @end deftypevr
  13363. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  13364. Specifies whether to purge job history data automatically when it is no
  13365. longer required for quotas.
  13366. Defaults to @samp{#f}.
  13367. @end deftypevr
  13368. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  13369. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  13370. For example, @samp{"_cups" "_print"} will tell network clients that both
  13371. CUPS sharing and IPP Everywhere are supported.
  13372. Defaults to @samp{"_cups"}.
  13373. @end deftypevr
  13374. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  13375. Specifies which protocols to use for local printer sharing.
  13376. Defaults to @samp{dnssd}.
  13377. @end deftypevr
  13378. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  13379. Specifies whether the CUPS web interface is advertised.
  13380. Defaults to @samp{#f}.
  13381. @end deftypevr
  13382. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  13383. Specifies whether shared printers are advertised.
  13384. Defaults to @samp{#f}.
  13385. @end deftypevr
  13386. @deftypevr {@code{cups-configuration} parameter} string classification
  13387. Specifies the security classification of the server. Any valid banner
  13388. name can be used, including @samp{"classified"}, @samp{"confidential"},
  13389. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  13390. banner can be omitted to disable secure printing functions.
  13391. Defaults to @samp{""}.
  13392. @end deftypevr
  13393. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  13394. Specifies whether users may override the classification (cover page) of
  13395. individual print jobs using the @code{job-sheets} option.
  13396. Defaults to @samp{#f}.
  13397. @end deftypevr
  13398. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  13399. Specifies the default type of authentication to use.
  13400. Defaults to @samp{Basic}.
  13401. @end deftypevr
  13402. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  13403. Specifies whether encryption will be used for authenticated requests.
  13404. Defaults to @samp{Required}.
  13405. @end deftypevr
  13406. @deftypevr {@code{cups-configuration} parameter} string default-language
  13407. Specifies the default language to use for text and web content.
  13408. Defaults to @samp{"en"}.
  13409. @end deftypevr
  13410. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  13411. Specifies the default paper size for new print queues. @samp{"Auto"}
  13412. uses a locale-specific default, while @samp{"None"} specifies there is
  13413. no default paper size. Specific size names are typically
  13414. @samp{"Letter"} or @samp{"A4"}.
  13415. Defaults to @samp{"Auto"}.
  13416. @end deftypevr
  13417. @deftypevr {@code{cups-configuration} parameter} string default-policy
  13418. Specifies the default access policy to use.
  13419. Defaults to @samp{"default"}.
  13420. @end deftypevr
  13421. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  13422. Specifies whether local printers are shared by default.
  13423. Defaults to @samp{#t}.
  13424. @end deftypevr
  13425. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  13426. Specifies the delay for updating of configuration and state files, in
  13427. seconds. A value of 0 causes the update to happen as soon as possible,
  13428. typically within a few milliseconds.
  13429. Defaults to @samp{30}.
  13430. @end deftypevr
  13431. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  13432. Specifies what to do when an error occurs. Possible values are
  13433. @code{abort-job}, which will discard the failed print job;
  13434. @code{retry-job}, which will retry the job at a later time;
  13435. @code{retry-current-job}, which retries the failed job immediately; and
  13436. @code{stop-printer}, which stops the printer.
  13437. Defaults to @samp{stop-printer}.
  13438. @end deftypevr
  13439. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  13440. Specifies the maximum cost of filters that are run concurrently, which
  13441. can be used to minimize disk, memory, and CPU resource problems. A
  13442. limit of 0 disables filter limiting. An average print to a
  13443. non-PostScript printer needs a filter limit of about 200. A PostScript
  13444. printer needs about half that (100). Setting the limit below these
  13445. thresholds will effectively limit the scheduler to printing a single job
  13446. at any time.
  13447. Defaults to @samp{0}.
  13448. @end deftypevr
  13449. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  13450. Specifies the scheduling priority of filters that are run to print a
  13451. job. The nice value ranges from 0, the highest priority, to 19, the
  13452. lowest priority.
  13453. Defaults to @samp{0}.
  13454. @end deftypevr
  13455. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  13456. Specifies whether to do reverse lookups on connecting clients. The
  13457. @code{double} setting causes @code{cupsd} to verify that the hostname
  13458. resolved from the address matches one of the addresses returned for that
  13459. hostname. Double lookups also prevent clients with unregistered
  13460. addresses from connecting to your server. Only set this option to
  13461. @code{#t} or @code{double} if absolutely required.
  13462. Defaults to @samp{#f}.
  13463. @end deftypevr
  13464. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  13465. Specifies the number of seconds to wait before killing the filters and
  13466. backend associated with a canceled or held job.
  13467. Defaults to @samp{30}.
  13468. @end deftypevr
  13469. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  13470. Specifies the interval between retries of jobs in seconds. This is
  13471. typically used for fax queues but can also be used with normal print
  13472. queues whose error policy is @code{retry-job} or
  13473. @code{retry-current-job}.
  13474. Defaults to @samp{30}.
  13475. @end deftypevr
  13476. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  13477. Specifies the number of retries that are done for jobs. This is
  13478. typically used for fax queues but can also be used with normal print
  13479. queues whose error policy is @code{retry-job} or
  13480. @code{retry-current-job}.
  13481. Defaults to @samp{5}.
  13482. @end deftypevr
  13483. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  13484. Specifies whether to support HTTP keep-alive connections.
  13485. Defaults to @samp{#t}.
  13486. @end deftypevr
  13487. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  13488. Specifies how long an idle client connection remains open, in seconds.
  13489. Defaults to @samp{30}.
  13490. @end deftypevr
  13491. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  13492. Specifies the maximum size of print files, IPP requests, and HTML form
  13493. data. A limit of 0 disables the limit check.
  13494. Defaults to @samp{0}.
  13495. @end deftypevr
  13496. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  13497. Listens on the specified interfaces for connections. Valid values are
  13498. of the form @var{address}:@var{port}, where @var{address} is either an
  13499. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  13500. indicate all addresses. Values can also be file names of local UNIX
  13501. domain sockets. The Listen directive is similar to the Port directive
  13502. but allows you to restrict access to specific interfaces or networks.
  13503. @end deftypevr
  13504. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  13505. Specifies the number of pending connections that will be allowed. This
  13506. normally only affects very busy servers that have reached the MaxClients
  13507. limit, but can also be triggered by large numbers of simultaneous
  13508. connections. When the limit is reached, the operating system will
  13509. refuse additional connections until the scheduler can accept the pending
  13510. ones.
  13511. Defaults to @samp{128}.
  13512. @end deftypevr
  13513. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  13514. Specifies a set of additional access controls.
  13515. Available @code{location-access-controls} fields are:
  13516. @deftypevr {@code{location-access-controls} parameter} file-name path
  13517. Specifies the URI path to which the access control applies.
  13518. @end deftypevr
  13519. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  13520. Access controls for all access to this path, in the same format as the
  13521. @code{access-controls} of @code{operation-access-control}.
  13522. Defaults to @samp{()}.
  13523. @end deftypevr
  13524. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  13525. Access controls for method-specific access to this path.
  13526. Defaults to @samp{()}.
  13527. Available @code{method-access-controls} fields are:
  13528. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  13529. If @code{#t}, apply access controls to all methods except the listed
  13530. methods. Otherwise apply to only the listed methods.
  13531. Defaults to @samp{#f}.
  13532. @end deftypevr
  13533. @deftypevr {@code{method-access-controls} parameter} method-list methods
  13534. Methods to which this access control applies.
  13535. Defaults to @samp{()}.
  13536. @end deftypevr
  13537. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  13538. Access control directives, as a list of strings. Each string should be
  13539. one directive, such as @samp{"Order allow,deny"}.
  13540. Defaults to @samp{()}.
  13541. @end deftypevr
  13542. @end deftypevr
  13543. @end deftypevr
  13544. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  13545. Specifies the number of debugging messages that are retained for logging
  13546. if an error occurs in a print job. Debug messages are logged regardless
  13547. of the LogLevel setting.
  13548. Defaults to @samp{100}.
  13549. @end deftypevr
  13550. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  13551. Specifies the level of logging for the ErrorLog file. The value
  13552. @code{none} stops all logging while @code{debug2} logs everything.
  13553. Defaults to @samp{info}.
  13554. @end deftypevr
  13555. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  13556. Specifies the format of the date and time in the log files. The value
  13557. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  13558. Defaults to @samp{standard}.
  13559. @end deftypevr
  13560. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  13561. Specifies the maximum number of simultaneous clients that are allowed by
  13562. the scheduler.
  13563. Defaults to @samp{100}.
  13564. @end deftypevr
  13565. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  13566. Specifies the maximum number of simultaneous clients that are allowed
  13567. from a single address.
  13568. Defaults to @samp{100}.
  13569. @end deftypevr
  13570. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  13571. Specifies the maximum number of copies that a user can print of each
  13572. job.
  13573. Defaults to @samp{9999}.
  13574. @end deftypevr
  13575. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  13576. Specifies the maximum time a job may remain in the @code{indefinite}
  13577. hold state before it is canceled. A value of 0 disables cancellation of
  13578. held jobs.
  13579. Defaults to @samp{0}.
  13580. @end deftypevr
  13581. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  13582. Specifies the maximum number of simultaneous jobs that are allowed. Set
  13583. to 0 to allow an unlimited number of jobs.
  13584. Defaults to @samp{500}.
  13585. @end deftypevr
  13586. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  13587. Specifies the maximum number of simultaneous jobs that are allowed per
  13588. printer. A value of 0 allows up to MaxJobs jobs per printer.
  13589. Defaults to @samp{0}.
  13590. @end deftypevr
  13591. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  13592. Specifies the maximum number of simultaneous jobs that are allowed per
  13593. user. A value of 0 allows up to MaxJobs jobs per user.
  13594. Defaults to @samp{0}.
  13595. @end deftypevr
  13596. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  13597. Specifies the maximum time a job may take to print before it is
  13598. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  13599. Defaults to @samp{10800}.
  13600. @end deftypevr
  13601. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  13602. Specifies the maximum size of the log files before they are rotated, in
  13603. bytes. The value 0 disables log rotation.
  13604. Defaults to @samp{1048576}.
  13605. @end deftypevr
  13606. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  13607. Specifies the maximum amount of time to allow between files in a
  13608. multiple file print job, in seconds.
  13609. Defaults to @samp{300}.
  13610. @end deftypevr
  13611. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  13612. Specifies the format of PageLog lines. Sequences beginning with percent
  13613. (@samp{%}) characters are replaced with the corresponding information,
  13614. while all other characters are copied literally. The following percent
  13615. sequences are recognized:
  13616. @table @samp
  13617. @item %%
  13618. insert a single percent character
  13619. @item %@{name@}
  13620. insert the value of the specified IPP attribute
  13621. @item %C
  13622. insert the number of copies for the current page
  13623. @item %P
  13624. insert the current page number
  13625. @item %T
  13626. insert the current date and time in common log format
  13627. @item %j
  13628. insert the job ID
  13629. @item %p
  13630. insert the printer name
  13631. @item %u
  13632. insert the username
  13633. @end table
  13634. A value of the empty string disables page logging. The string @code{%p
  13635. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  13636. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  13637. standard items.
  13638. Defaults to @samp{""}.
  13639. @end deftypevr
  13640. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  13641. Passes the specified environment variable(s) to child processes; a list
  13642. of strings.
  13643. Defaults to @samp{()}.
  13644. @end deftypevr
  13645. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  13646. Specifies named access control policies.
  13647. Available @code{policy-configuration} fields are:
  13648. @deftypevr {@code{policy-configuration} parameter} string name
  13649. Name of the policy.
  13650. @end deftypevr
  13651. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  13652. Specifies an access list for a job's private values. @code{@@ACL} maps
  13653. to the printer's requesting-user-name-allowed or
  13654. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  13655. owner. @code{@@SYSTEM} maps to the groups listed for the
  13656. @code{system-group} field of the @code{files-config} configuration,
  13657. which is reified into the @code{cups-files.conf(5)} file. Other
  13658. possible elements of the access list include specific user names, and
  13659. @code{@@@var{group}} to indicate members of a specific group. The
  13660. access list may also be simply @code{all} or @code{default}.
  13661. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  13662. @end deftypevr
  13663. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  13664. Specifies the list of job values to make private, or @code{all},
  13665. @code{default}, or @code{none}.
  13666. Defaults to @samp{"job-name job-originating-host-name
  13667. job-originating-user-name phone"}.
  13668. @end deftypevr
  13669. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  13670. Specifies an access list for a subscription's private values.
  13671. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  13672. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  13673. owner. @code{@@SYSTEM} maps to the groups listed for the
  13674. @code{system-group} field of the @code{files-config} configuration,
  13675. which is reified into the @code{cups-files.conf(5)} file. Other
  13676. possible elements of the access list include specific user names, and
  13677. @code{@@@var{group}} to indicate members of a specific group. The
  13678. access list may also be simply @code{all} or @code{default}.
  13679. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  13680. @end deftypevr
  13681. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  13682. Specifies the list of job values to make private, or @code{all},
  13683. @code{default}, or @code{none}.
  13684. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  13685. notify-subscriber-user-name notify-user-data"}.
  13686. @end deftypevr
  13687. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  13688. Access control by IPP operation.
  13689. Defaults to @samp{()}.
  13690. @end deftypevr
  13691. @end deftypevr
  13692. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  13693. Specifies whether job files (documents) are preserved after a job is
  13694. printed. If a numeric value is specified, job files are preserved for
  13695. the indicated number of seconds after printing. Otherwise a boolean
  13696. value applies indefinitely.
  13697. Defaults to @samp{86400}.
  13698. @end deftypevr
  13699. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  13700. Specifies whether the job history is preserved after a job is printed.
  13701. If a numeric value is specified, the job history is preserved for the
  13702. indicated number of seconds after printing. If @code{#t}, the job
  13703. history is preserved until the MaxJobs limit is reached.
  13704. Defaults to @samp{#t}.
  13705. @end deftypevr
  13706. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  13707. Specifies the amount of time to wait for job completion before
  13708. restarting the scheduler.
  13709. Defaults to @samp{30}.
  13710. @end deftypevr
  13711. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  13712. Specifies the maximum amount of memory to use when converting documents
  13713. into bitmaps for a printer.
  13714. Defaults to @samp{"128m"}.
  13715. @end deftypevr
  13716. @deftypevr {@code{cups-configuration} parameter} string server-admin
  13717. Specifies the email address of the server administrator.
  13718. Defaults to @samp{"root@@localhost.localdomain"}.
  13719. @end deftypevr
  13720. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  13721. The ServerAlias directive is used for HTTP Host header validation when
  13722. clients connect to the scheduler from external interfaces. Using the
  13723. special name @code{*} can expose your system to known browser-based DNS
  13724. rebinding attacks, even when accessing sites through a firewall. If the
  13725. auto-discovery of alternate names does not work, we recommend listing
  13726. each alternate name with a ServerAlias directive instead of using
  13727. @code{*}.
  13728. Defaults to @samp{*}.
  13729. @end deftypevr
  13730. @deftypevr {@code{cups-configuration} parameter} string server-name
  13731. Specifies the fully-qualified host name of the server.
  13732. Defaults to @samp{"localhost"}.
  13733. @end deftypevr
  13734. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  13735. Specifies what information is included in the Server header of HTTP
  13736. responses. @code{None} disables the Server header. @code{ProductOnly}
  13737. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  13738. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  13739. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  13740. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  13741. 2.0.0 (@var{uname}) IPP/2.0}.
  13742. Defaults to @samp{Minimal}.
  13743. @end deftypevr
  13744. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  13745. Listens on the specified interfaces for encrypted connections. Valid
  13746. values are of the form @var{address}:@var{port}, where @var{address} is
  13747. either an IPv6 address enclosed in brackets, an IPv4 address, or
  13748. @code{*} to indicate all addresses.
  13749. Defaults to @samp{()}.
  13750. @end deftypevr
  13751. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  13752. Sets encryption options. By default, CUPS only supports encryption
  13753. using TLS v1.0 or higher using known secure cipher suites. Security is
  13754. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  13755. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  13756. suites, which are required for some older clients. The @code{AllowSSL3} option
  13757. enables SSL v3.0, which is required for some older clients that do not support
  13758. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  13759. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  13760. protocol version to TLS v1.1.
  13761. Defaults to @samp{()}.
  13762. @end deftypevr
  13763. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  13764. Specifies whether the scheduler requires clients to strictly adhere to
  13765. the IPP specifications.
  13766. Defaults to @samp{#f}.
  13767. @end deftypevr
  13768. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  13769. Specifies the HTTP request timeout, in seconds.
  13770. Defaults to @samp{300}.
  13771. @end deftypevr
  13772. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  13773. Specifies whether the web interface is enabled.
  13774. Defaults to @samp{#f}.
  13775. @end deftypevr
  13776. At this point you're probably thinking ``oh dear, Guix manual, I like
  13777. you but you can stop already with the configuration options''. Indeed.
  13778. However, one more point: it could be that you have an existing
  13779. @code{cupsd.conf} that you want to use. In that case, you can pass an
  13780. @code{opaque-cups-configuration} as the configuration of a
  13781. @code{cups-service-type}.
  13782. Available @code{opaque-cups-configuration} fields are:
  13783. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  13784. The CUPS package.
  13785. @end deftypevr
  13786. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  13787. The contents of the @code{cupsd.conf}, as a string.
  13788. @end deftypevr
  13789. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  13790. The contents of the @code{cups-files.conf} file, as a string.
  13791. @end deftypevr
  13792. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  13793. strings of the same name, you could instantiate a CUPS service like
  13794. this:
  13795. @lisp
  13796. (service cups-service-type
  13797. (opaque-cups-configuration
  13798. (cupsd.conf cupsd.conf)
  13799. (cups-files.conf cups-files.conf)))
  13800. @end lisp
  13801. @node Desktop Services
  13802. @subsection Desktop Services
  13803. The @code{(gnu services desktop)} module provides services that are
  13804. usually useful in the context of a ``desktop'' setup---that is, on a
  13805. machine running a graphical display server, possibly with graphical user
  13806. interfaces, etc. It also defines services that provide specific desktop
  13807. environments like GNOME, Xfce or MATE.
  13808. To simplify things, the module defines a variable containing the set of
  13809. services that users typically expect on a machine with a graphical
  13810. environment and networking:
  13811. @defvr {Scheme Variable} %desktop-services
  13812. This is a list of services that builds upon @code{%base-services} and
  13813. adds or adjusts services for a typical ``desktop'' setup.
  13814. In particular, it adds a graphical login manager (@pxref{X Window,
  13815. @code{gdm-service-type}}), screen lockers, a network management tool
  13816. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  13817. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  13818. energy and color management services, the @code{elogind} login and seat
  13819. manager, the Polkit privilege service, the GeoClue location service, the
  13820. AccountsService daemon that allows authorized users change system passwords,
  13821. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  13822. name service switch service configured to be able to use @code{nss-mdns}
  13823. (@pxref{Name Service Switch, mDNS}).
  13824. @end defvr
  13825. The @code{%desktop-services} variable can be used as the @code{services}
  13826. field of an @code{operating-system} declaration (@pxref{operating-system
  13827. Reference, @code{services}}).
  13828. Additionally, the @code{gnome-desktop-service-type},
  13829. @code{xfce-desktop-service}, @code{mate-desktop-service-type} and
  13830. @code{enlightenment-desktop-service-type} procedures can add GNOME, Xfce, MATE
  13831. and/or Enlightenment to a system. To ``add GNOME'' means that system-level
  13832. services like the backlight adjustment helpers and the power management
  13833. utilities are added to the system, extending @code{polkit} and @code{dbus}
  13834. appropriately, allowing GNOME to operate with elevated privileges on a
  13835. limited number of special-purpose system interfaces. Additionally,
  13836. adding a service made by @code{gnome-desktop-service-type} adds the GNOME
  13837. metapackage to the system profile. Likewise, adding the Xfce service
  13838. not only adds the @code{xfce} metapackage to the system profile, but it
  13839. also gives the Thunar file manager the ability to open a ``root-mode''
  13840. file management window, if the user authenticates using the
  13841. administrator's password via the standard polkit graphical interface.
  13842. To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
  13843. appropriately, allowing MATE to operate with elevated privileges on a
  13844. limited number of special-purpose system interfaces. Additionally,
  13845. adding a service of type @code{mate-desktop-service-type} adds the MATE
  13846. metapackage to the system profile. ``Adding Enlightenment'' means that
  13847. @code{dbus} is extended appropriately, and several of Enlightenment's binaries
  13848. are set as setuid, allowing Enlightenment's screen locker and other
  13849. functionality to work as expected.
  13850. The desktop environments in Guix use the Xorg display server by
  13851. default. If you'd like to use the newer display server protocol
  13852. called Wayland, you need to use the @code{sddm-service} instead of
  13853. GDM as the graphical login manager. You should then
  13854. select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
  13855. also try starting GNOME on Wayland manually from a TTY with the
  13856. command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  13857. gnome-session``. Currently only GNOME has support for Wayland.
  13858. @defvr {Scheme Variable} gnome-desktop-service-type
  13859. This is the type of the service that adds the @uref{https://www.gnome.org,
  13860. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  13861. object (see below).
  13862. This service adds the @code{gnome} package to the system profile, and extends
  13863. polkit with the actions from @code{gnome-settings-daemon}.
  13864. @end defvr
  13865. @deftp {Data Type} gnome-desktop-configuration
  13866. Configuration record for the GNOME desktop environment.
  13867. @table @asis
  13868. @item @code{gnome} (default: @code{gnome})
  13869. The GNOME package to use.
  13870. @end table
  13871. @end deftp
  13872. @defvr {Scheme Variable} xfce-desktop-service-type
  13873. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  13874. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  13875. (see below).
  13876. This service adds the @code{xfce} package to the system profile, and
  13877. extends polkit with the ability for @code{thunar} to manipulate the file
  13878. system as root from within a user session, after the user has authenticated
  13879. with the administrator's password.
  13880. @end defvr
  13881. @deftp {Data Type} xfce-desktop-configuration
  13882. Configuration record for the Xfce desktop environment.
  13883. @table @asis
  13884. @item @code{xfce} (default: @code{xfce})
  13885. The Xfce package to use.
  13886. @end table
  13887. @end deftp
  13888. @deffn {Scheme Variable} mate-desktop-service-type
  13889. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  13890. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  13891. object (see below).
  13892. This service adds the @code{mate} package to the system
  13893. profile, and extends polkit with the actions from
  13894. @code{mate-settings-daemon}.
  13895. @end deffn
  13896. @deftp {Data Type} mate-desktop-configuration
  13897. Configuration record for the MATE desktop environment.
  13898. @table @asis
  13899. @item @code{mate} (default: @code{mate})
  13900. The MATE package to use.
  13901. @end table
  13902. @end deftp
  13903. @deffn {Scheme Variable} enlightenment-desktop-service-type
  13904. Return a service that adds the @code{enlightenment} package to the system
  13905. profile, and extends dbus with actions from @code{efl}.
  13906. @end deffn
  13907. @deftp {Data Type} enlightenment-desktop-service-configuration
  13908. @table @asis
  13909. @item @code{enlightenment} (default: @code{enlightenment})
  13910. The enlightenment package to use.
  13911. @end table
  13912. @end deftp
  13913. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  13914. the default @code{%desktop-services} variable doesn't include any of
  13915. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  13916. @code{%desktop-services} in the @code{services} field of your
  13917. @code{operating-system}:
  13918. @lisp
  13919. (use-modules (gnu))
  13920. (use-service-modules desktop)
  13921. (operating-system
  13922. ...
  13923. ;; cons* adds items to the list given as its last argument.
  13924. (services (cons* (service gnome-desktop-service-type)
  13925. (service xfce-desktop-service)
  13926. %desktop-services))
  13927. ...)
  13928. @end lisp
  13929. These desktop environments will then be available as options in the
  13930. graphical login window.
  13931. The actual service definitions included in @code{%desktop-services} and
  13932. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  13933. are described below.
  13934. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  13935. Return a service that runs the ``system bus'', using @var{dbus}, with
  13936. support for @var{services}.
  13937. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  13938. facility. Its system bus is used to allow system services to communicate
  13939. and to be notified of system-wide events.
  13940. @var{services} must be a list of packages that provide an
  13941. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  13942. and policy files. For example, to allow avahi-daemon to use the system bus,
  13943. @var{services} must be equal to @code{(list avahi)}.
  13944. @end deffn
  13945. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  13946. Return a service that runs the @code{elogind} login and
  13947. seat management daemon. @uref{https://github.com/elogind/elogind,
  13948. Elogind} exposes a D-Bus interface that can be used to know which users
  13949. are logged in, know what kind of sessions they have open, suspend the
  13950. system, inhibit system suspend, reboot the system, and other tasks.
  13951. Elogind handles most system-level power events for a computer, for
  13952. example suspending the system when a lid is closed, or shutting it down
  13953. when the power button is pressed.
  13954. The @var{config} keyword argument specifies the configuration for
  13955. elogind, and should be the result of an @code{(elogind-configuration
  13956. (@var{parameter} @var{value})...)} invocation. Available parameters and
  13957. their default values are:
  13958. @table @code
  13959. @item kill-user-processes?
  13960. @code{#f}
  13961. @item kill-only-users
  13962. @code{()}
  13963. @item kill-exclude-users
  13964. @code{("root")}
  13965. @item inhibit-delay-max-seconds
  13966. @code{5}
  13967. @item handle-power-key
  13968. @code{poweroff}
  13969. @item handle-suspend-key
  13970. @code{suspend}
  13971. @item handle-hibernate-key
  13972. @code{hibernate}
  13973. @item handle-lid-switch
  13974. @code{suspend}
  13975. @item handle-lid-switch-docked
  13976. @code{ignore}
  13977. @item handle-lid-switch-external-power
  13978. @code{ignore}
  13979. @item power-key-ignore-inhibited?
  13980. @code{#f}
  13981. @item suspend-key-ignore-inhibited?
  13982. @code{#f}
  13983. @item hibernate-key-ignore-inhibited?
  13984. @code{#f}
  13985. @item lid-switch-ignore-inhibited?
  13986. @code{#t}
  13987. @item holdoff-timeout-seconds
  13988. @code{30}
  13989. @item idle-action
  13990. @code{ignore}
  13991. @item idle-action-seconds
  13992. @code{(* 30 60)}
  13993. @item runtime-directory-size-percent
  13994. @code{10}
  13995. @item runtime-directory-size
  13996. @code{#f}
  13997. @item remove-ipc?
  13998. @code{#t}
  13999. @item suspend-state
  14000. @code{("mem" "standby" "freeze")}
  14001. @item suspend-mode
  14002. @code{()}
  14003. @item hibernate-state
  14004. @code{("disk")}
  14005. @item hibernate-mode
  14006. @code{("platform" "shutdown")}
  14007. @item hybrid-sleep-state
  14008. @code{("disk")}
  14009. @item hybrid-sleep-mode
  14010. @code{("suspend" "platform" "shutdown")}
  14011. @end table
  14012. @end deffn
  14013. @deffn {Scheme Procedure} accountsservice-service @
  14014. [#:accountsservice @var{accountsservice}]
  14015. Return a service that runs AccountsService, a system service that can
  14016. list available accounts, change their passwords, and so on.
  14017. AccountsService integrates with PolicyKit to enable unprivileged users
  14018. to acquire the capability to modify their system configuration.
  14019. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  14020. accountsservice web site} for more information.
  14021. The @var{accountsservice} keyword argument is the @code{accountsservice}
  14022. package to expose as a service.
  14023. @end deffn
  14024. @deffn {Scheme Procedure} polkit-service @
  14025. [#:polkit @var{polkit}]
  14026. Return a service that runs the
  14027. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  14028. management service}, which allows system administrators to grant access to
  14029. privileged operations in a structured way. By querying the Polkit service, a
  14030. privileged system component can know when it should grant additional
  14031. capabilities to ordinary users. For example, an ordinary user can be granted
  14032. the capability to suspend the system if the user is logged in locally.
  14033. @end deffn
  14034. @defvr {Scheme Variable} polkit-wheel-service
  14035. Service that adds the @code{wheel} group as admins to the Polkit
  14036. service. This makes it so that users in the @code{wheel} group are queried
  14037. for their own passwords when performing administrative actions instead of
  14038. @code{root}'s, similar to the behaviour used by @code{sudo}.
  14039. @end defvr
  14040. @defvr {Scheme Variable} upower-service-type
  14041. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  14042. system-wide monitor for power consumption and battery levels, with the given
  14043. configuration settings.
  14044. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  14045. notably used by GNOME.
  14046. @end defvr
  14047. @deftp {Data Type} upower-configuration
  14048. Data type representation the configuration for UPower.
  14049. @table @asis
  14050. @item @code{upower} (default: @var{upower})
  14051. Package to use for @code{upower}.
  14052. @item @code{watts-up-pro?} (default: @code{#f})
  14053. Enable the Watts Up Pro device.
  14054. @item @code{poll-batteries?} (default: @code{#t})
  14055. Enable polling the kernel for battery level changes.
  14056. @item @code{ignore-lid?} (default: @code{#f})
  14057. Ignore the lid state, this can be useful if it's incorrect on a device.
  14058. @item @code{use-percentage-for-policy?} (default: @code{#f})
  14059. Whether battery percentage based policy should be used. The default is to use
  14060. the time left, change to @code{#t} to use the percentage.
  14061. @item @code{percentage-low} (default: @code{10})
  14062. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  14063. at which the battery is considered low.
  14064. @item @code{percentage-critical} (default: @code{3})
  14065. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  14066. at which the battery is considered critical.
  14067. @item @code{percentage-action} (default: @code{2})
  14068. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  14069. at which action will be taken.
  14070. @item @code{time-low} (default: @code{1200})
  14071. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  14072. seconds at which the battery is considered low.
  14073. @item @code{time-critical} (default: @code{300})
  14074. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  14075. seconds at which the battery is considered critical.
  14076. @item @code{time-action} (default: @code{120})
  14077. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  14078. seconds at which action will be taken.
  14079. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  14080. The action taken when @code{percentage-action} or @code{time-action} is
  14081. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  14082. Possible values are:
  14083. @itemize @bullet
  14084. @item
  14085. @code{'power-off}
  14086. @item
  14087. @code{'hibernate}
  14088. @item
  14089. @code{'hybrid-sleep}.
  14090. @end itemize
  14091. @end table
  14092. @end deftp
  14093. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  14094. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  14095. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  14096. with notifications and ways to mount/unmount disks. Programs that talk
  14097. to UDisks include the @command{udisksctl} command, part of UDisks, and
  14098. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  14099. it will only be able to use the file-system utilities installed in the
  14100. system profile. For example if you want to be able to mount NTFS
  14101. file-systems in read and write fashion, you'll need to have
  14102. @code{ntfs-3g} installed system-wide.
  14103. @end deffn
  14104. @deffn {Scheme Variable} colord-service-type
  14105. This is the type of the service that runs @command{colord}, a system
  14106. service with a D-Bus
  14107. interface to manage the color profiles of input and output devices such as
  14108. screens and scanners. It is notably used by the GNOME Color Manager graphical
  14109. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  14110. site} for more information.
  14111. @end deffn
  14112. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  14113. Return a configuration allowing an application to access GeoClue
  14114. location data. @var{name} is the Desktop ID of the application, without
  14115. the @code{.desktop} part. If @var{allowed?} is true, the application
  14116. will have access to location information by default. The boolean
  14117. @var{system?} value indicates whether an application is a system component
  14118. or not. Finally @var{users} is a list of UIDs of all users for which
  14119. this application is allowed location info access. An empty users list
  14120. means that all users are allowed.
  14121. @end deffn
  14122. @cindex scanner access
  14123. @deffn {Scheme Procedure} sane-service-type
  14124. This service provides access to scanners @i{via}
  14125. @uref{http://www.sane-project.org, SANE} by installing the necessary udev
  14126. rules.
  14127. @end deffn
  14128. @defvr {Scheme Variable} %standard-geoclue-applications
  14129. The standard list of well-known GeoClue application configurations,
  14130. granting authority to the GNOME date-and-time utility to ask for the
  14131. current location in order to set the time zone, and allowing the
  14132. IceCat and Epiphany web browsers to request location information.
  14133. IceCat and Epiphany both query the user before allowing a web page to
  14134. know the user's location.
  14135. @end defvr
  14136. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  14137. [#:whitelist '()] @
  14138. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  14139. [#:submit-data? #f]
  14140. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  14141. [#:submission-nick "geoclue"] @
  14142. [#:applications %standard-geoclue-applications]
  14143. Return a service that runs the GeoClue location service. This service
  14144. provides a D-Bus interface to allow applications to request access to a
  14145. user's physical location, and optionally to add information to online
  14146. location databases. See
  14147. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  14148. web site} for more information.
  14149. @end deffn
  14150. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  14151. [@w{#:auto-enable? #f}]
  14152. Return a service that runs the @command{bluetoothd} daemon, which
  14153. manages all the Bluetooth devices and provides a number of D-Bus
  14154. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  14155. powered automatically at boot, which can be useful when using a
  14156. bluetooth keyboard or mouse.
  14157. Users need to be in the @code{lp} group to access the D-Bus service.
  14158. @end deffn
  14159. @defvr {Scheme Variable} gnome-keyring-service-type
  14160. This is the type of the service that adds the
  14161. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  14162. value is a @code{gnome-keyring-configuration} object (see below).
  14163. This service adds the @code{gnome-keyring} package to the system profile
  14164. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  14165. a user's login keyring when they log in or setting its password with passwd.
  14166. @end defvr
  14167. @deftp {Data Type} gnome-keyring-configuration
  14168. Configuration record for the GNOME Keyring service.
  14169. @table @asis
  14170. @item @code{keyring} (default: @code{gnome-keyring})
  14171. The GNOME keyring package to use.
  14172. @item @code{pam-services}
  14173. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  14174. services to extend, where @var{service} is the name of an existing
  14175. service to extend and @var{kind} is one of @code{login} or
  14176. @code{passwd}.
  14177. If @code{login} is given, it adds an optional
  14178. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  14179. the session block with @code{auto_start}. If @code{passwd} is given, it
  14180. adds an optional @code{pam_gnome_keyring.so} to the password block
  14181. without arguments.
  14182. By default, this field contains ``gdm-password'' with the value @code{login}
  14183. and ``passwd'' is with the value @code{passwd}.
  14184. @end table
  14185. @end deftp
  14186. @node Sound Services
  14187. @subsection Sound Services
  14188. @cindex sound support
  14189. @cindex ALSA
  14190. @cindex PulseAudio, sound support
  14191. The @code{(gnu services sound)} module provides a service to configure the
  14192. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  14193. preferred ALSA output driver.
  14194. @deffn {Scheme Variable} alsa-service-type
  14195. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  14196. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  14197. configuration file. The value for this type is a @command{alsa-configuration}
  14198. record as in this example:
  14199. @lisp
  14200. (service alsa-service-type)
  14201. @end lisp
  14202. See below for details about @code{alsa-configuration}.
  14203. @end deffn
  14204. @deftp {Data Type} alsa-configuration
  14205. Data type representing the configuration for @code{alsa-service}.
  14206. @table @asis
  14207. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  14208. @code{alsa-plugins} package to use.
  14209. @item @code{pulseaudio?} (default: @var{#t})
  14210. Whether ALSA applications should transparently be made to use the
  14211. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  14212. Using PulseAudio allows you to run several sound-producing applications
  14213. at the same time and to individual control them @i{via}
  14214. @command{pavucontrol}, among other things.
  14215. @item @code{extra-options} (default: @var{""})
  14216. String to append to the @file{/etc/asound.conf} file.
  14217. @end table
  14218. @end deftp
  14219. Individual users who want to override the system configuration of ALSA can do
  14220. it with the @file{~/.asoundrc} file:
  14221. @example
  14222. # In guix, we have to specify the absolute path for plugins.
  14223. pcm_type.jack @{
  14224. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  14225. @}
  14226. # Routing ALSA to jack:
  14227. # <http://jackaudio.org/faq/routing_alsa.html>.
  14228. pcm.rawjack @{
  14229. type jack
  14230. playback_ports @{
  14231. 0 system:playback_1
  14232. 1 system:playback_2
  14233. @}
  14234. capture_ports @{
  14235. 0 system:capture_1
  14236. 1 system:capture_2
  14237. @}
  14238. @}
  14239. pcm.!default @{
  14240. type plug
  14241. slave @{
  14242. pcm "rawjack"
  14243. @}
  14244. @}
  14245. @end example
  14246. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  14247. details.
  14248. @deffn {Scheme Variable} pulseaudio-service-type
  14249. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  14250. sound server. It exists to allow system overrides of the default settings
  14251. via @code{pulseaudio-configuration}, see below.
  14252. @quotation Warning
  14253. This service overrides per-user configuration files. If you want
  14254. PulseAudio to honor configuraton files in @file{~/.config/pulse} you
  14255. have to unset the environment variables @env{PULSE_CONFIG} and
  14256. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  14257. @end quotation
  14258. @quotation Warning
  14259. This service on its own does not ensure, that the @code{pulseaudio} package
  14260. exists on your machine. It merely adds configuration files for it, as
  14261. detailed below. In the (admittedly unlikely) case, that you find yourself
  14262. without a @code{pulseaudio} package, consider enabling it through the
  14263. @code{alsa-service-type} above.
  14264. @end quotation
  14265. @end deffn
  14266. @deftp {Data Type} pulseaudio-configuration
  14267. Data type representing the configuration for @code{pulseaudio-service}.
  14268. @table @asis
  14269. @item @var{client-conf} (default: @code{'()})
  14270. List of settings to set in @file{client.conf}.
  14271. Accepts a list of strings or a symbol-value pairs. A string will be
  14272. inserted as-is with a newline added. A pair will be formatted as
  14273. ``key = value'', again with a newline added.
  14274. @item @var{daemon-conf} (default: @code{'((flat-volumes . no))})
  14275. List of settings to set in @file{daemon.conf}, formatted just like
  14276. @var{client-conf}.
  14277. @item @var{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  14278. Script file to use as as @file{default.pa}.
  14279. @item @var{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  14280. Script file to use as as @file{system.pa}.
  14281. @end table
  14282. @end deftp
  14283. @deffn {Scheme Variable} ladspa-service-type
  14284. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  14285. respect it, e.g. PulseAudio, can load LADSPA plugins.
  14286. The following example will setup the service to enable modules from the
  14287. @code{swh-plugins} package:
  14288. @lisp
  14289. (service ladspa-service-type
  14290. (ladspa-configuration (plugins (list swh-plugins))))
  14291. @end lisp
  14292. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  14293. details.
  14294. @end deffn
  14295. @node Database Services
  14296. @subsection Database Services
  14297. @cindex database
  14298. @cindex SQL
  14299. The @code{(gnu services databases)} module provides the following services.
  14300. @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
  14301. [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
  14302. [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
  14303. Return a service that runs @var{postgresql}, the PostgreSQL database
  14304. server.
  14305. The PostgreSQL daemon loads its runtime configuration from @var{config-file},
  14306. creates a database cluster with @var{locale} as the default
  14307. locale, stored in @var{data-directory}. It then listens on @var{port}.
  14308. If the services fails to start, it may be due to an incompatible
  14309. cluster already present in @var{data-directory}. Adjust it (or, if you
  14310. don't need the cluster anymore, delete @var{data-directory}), then
  14311. restart the service.
  14312. Peer authentication is used by default and the @code{postgres} user
  14313. account has no shell, which prevents the direct execution of @code{psql}
  14314. commands as this user. To use @code{psql}, you can temporarily log in
  14315. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  14316. same name as one of the system users and then create the associated
  14317. database.
  14318. @example
  14319. sudo -u postgres -s /bin/sh
  14320. createuser --interactive
  14321. createdb $MY_USER_LOGIN # Replace appropriately.
  14322. @end example
  14323. @cindex postgresql extension-packages
  14324. Additional extensions are loaded from packages listed in
  14325. @var{extension-packages}. Extensions are available at runtime. For instance,
  14326. to create a geographic database using the @code{postgis} extension, a user can
  14327. configure the postgresql-service as in this example:
  14328. @cindex postgis
  14329. @lisp
  14330. (use-package-modules databases geo)
  14331. (operating-system
  14332. ...
  14333. ;; postgresql is required to run `psql' but postgis is not required for
  14334. ;; proper operation.
  14335. (packages (cons* postgresql %base-packages))
  14336. (services
  14337. (cons*
  14338. (postgresql-service #:extension-packages (list postgis))
  14339. %base-services)))
  14340. @end lisp
  14341. Then the extension becomes visible and you can initialise an empty geographic
  14342. database in this way:
  14343. @example
  14344. psql -U postgres
  14345. > create database postgistest;
  14346. > \connect postgistest;
  14347. > create extension postgis;
  14348. > create extension postgis_topology;
  14349. @end example
  14350. There is no need to add this field for contrib extensions such as hstore or
  14351. dblink as they are already loadable by postgresql. This field is only
  14352. required to add extensions provided by other packages.
  14353. @end deffn
  14354. @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
  14355. Return a service that runs @command{mysqld}, the MySQL or MariaDB
  14356. database server.
  14357. The optional @var{config} argument specifies the configuration for
  14358. @command{mysqld}, which should be a @code{<mysql-configuration>} object.
  14359. @end deffn
  14360. @deftp {Data Type} mysql-configuration
  14361. Data type representing the configuration of @var{mysql-service}.
  14362. @table @asis
  14363. @item @code{mysql} (default: @var{mariadb})
  14364. Package object of the MySQL database server, can be either @var{mariadb}
  14365. or @var{mysql}.
  14366. For MySQL, a temporary root password will be displayed at activation time.
  14367. For MariaDB, the root password is empty.
  14368. @item @code{port} (default: @code{3306})
  14369. TCP port on which the database server listens for incoming connections.
  14370. @end table
  14371. @end deftp
  14372. @defvr {Scheme Variable} memcached-service-type
  14373. This is the service type for the @uref{https://memcached.org/,
  14374. Memcached} service, which provides a distributed in memory cache. The
  14375. value for the service type is a @code{memcached-configuration} object.
  14376. @end defvr
  14377. @lisp
  14378. (service memcached-service-type)
  14379. @end lisp
  14380. @deftp {Data Type} memcached-configuration
  14381. Data type representing the configuration of memcached.
  14382. @table @asis
  14383. @item @code{memcached} (default: @code{memcached})
  14384. The Memcached package to use.
  14385. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  14386. Network interfaces on which to listen.
  14387. @item @code{tcp-port} (default: @code{11211})
  14388. Port on which to accept connections on,
  14389. @item @code{udp-port} (default: @code{11211})
  14390. Port on which to accept UDP connections on, a value of 0 will disable
  14391. listening on a UDP socket.
  14392. @item @code{additional-options} (default: @code{'()})
  14393. Additional command line options to pass to @code{memcached}.
  14394. @end table
  14395. @end deftp
  14396. @defvr {Scheme Variable} mongodb-service-type
  14397. This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
  14398. The value for the service type is a @code{mongodb-configuration} object.
  14399. @end defvr
  14400. @lisp
  14401. (service mongodb-service-type)
  14402. @end lisp
  14403. @deftp {Data Type} mongodb-configuration
  14404. Data type representing the configuration of mongodb.
  14405. @table @asis
  14406. @item @code{mongodb} (default: @code{mongodb})
  14407. The MongoDB package to use.
  14408. @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
  14409. The configuration file for MongoDB.
  14410. @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
  14411. This value is used to create the directory, so that it exists and is
  14412. owned by the mongodb user. It should match the data-directory which
  14413. MongoDB is configured to use through the configuration file.
  14414. @end table
  14415. @end deftp
  14416. @defvr {Scheme Variable} redis-service-type
  14417. This is the service type for the @uref{https://redis.io/, Redis}
  14418. key/value store, whose value is a @code{redis-configuration} object.
  14419. @end defvr
  14420. @deftp {Data Type} redis-configuration
  14421. Data type representing the configuration of redis.
  14422. @table @asis
  14423. @item @code{redis} (default: @code{redis})
  14424. The Redis package to use.
  14425. @item @code{bind} (default: @code{"127.0.0.1"})
  14426. Network interface on which to listen.
  14427. @item @code{port} (default: @code{6379})
  14428. Port on which to accept connections on, a value of 0 will disable
  14429. listening on a TCP socket.
  14430. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  14431. Directory in which to store the database and related files.
  14432. @end table
  14433. @end deftp
  14434. @node Mail Services
  14435. @subsection Mail Services
  14436. @cindex mail
  14437. @cindex email
  14438. The @code{(gnu services mail)} module provides Guix service definitions
  14439. for email services: IMAP, POP3, and LMTP servers, as well as mail
  14440. transport agents (MTAs). Lots of acronyms! These services are detailed
  14441. in the subsections below.
  14442. @subsubheading Dovecot Service
  14443. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  14444. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  14445. @end deffn
  14446. By default, Dovecot does not need much configuration; the default
  14447. configuration object created by @code{(dovecot-configuration)} will
  14448. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  14449. certificate will be generated for TLS-protected connections, though
  14450. Dovecot will also listen on cleartext ports by default. There are a
  14451. number of options, though, which mail administrators might need to change,
  14452. and as is the case with other services, Guix allows the system
  14453. administrator to specify these parameters via a uniform Scheme interface.
  14454. For example, to specify that mail is located at @code{maildir~/.mail},
  14455. one would instantiate the Dovecot service like this:
  14456. @lisp
  14457. (dovecot-service #:config
  14458. (dovecot-configuration
  14459. (mail-location "maildir:~/.mail")))
  14460. @end lisp
  14461. The available configuration parameters follow. Each parameter
  14462. definition is preceded by its type; for example, @samp{string-list foo}
  14463. indicates that the @code{foo} parameter should be specified as a list of
  14464. strings. There is also a way to specify the configuration as a string,
  14465. if you have an old @code{dovecot.conf} file that you want to port over
  14466. from some other system; see the end for more details.
  14467. @c The following documentation was initially generated by
  14468. @c (generate-documentation) in (gnu services mail). Manually maintained
  14469. @c documentation is better, so we shouldn't hesitate to edit below as
  14470. @c needed. However if the change you want to make to this documentation
  14471. @c can be done in an automated way, it's probably easier to change
  14472. @c (generate-documentation) than to make it below and have to deal with
  14473. @c the churn as dovecot updates.
  14474. Available @code{dovecot-configuration} fields are:
  14475. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  14476. The dovecot package.
  14477. @end deftypevr
  14478. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  14479. A list of IPs or hosts where to listen for connections. @samp{*}
  14480. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  14481. interfaces. If you want to specify non-default ports or anything more
  14482. complex, customize the address and port fields of the
  14483. @samp{inet-listener} of the specific services you are interested in.
  14484. @end deftypevr
  14485. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  14486. List of protocols we want to serve. Available protocols include
  14487. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  14488. Available @code{protocol-configuration} fields are:
  14489. @deftypevr {@code{protocol-configuration} parameter} string name
  14490. The name of the protocol.
  14491. @end deftypevr
  14492. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  14493. UNIX socket path to the master authentication server to find users.
  14494. This is used by imap (for shared users) and lda.
  14495. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  14496. @end deftypevr
  14497. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  14498. Space separated list of plugins to load.
  14499. @end deftypevr
  14500. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  14501. Maximum number of IMAP connections allowed for a user from each IP
  14502. address. NOTE: The username is compared case-sensitively.
  14503. Defaults to @samp{10}.
  14504. @end deftypevr
  14505. @end deftypevr
  14506. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  14507. List of services to enable. Available services include @samp{imap},
  14508. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  14509. @samp{lmtp}.
  14510. Available @code{service-configuration} fields are:
  14511. @deftypevr {@code{service-configuration} parameter} string kind
  14512. The service kind. Valid values include @code{director},
  14513. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  14514. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  14515. @code{tcpwrap}, @code{quota-warning}, or anything else.
  14516. @end deftypevr
  14517. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  14518. Listeners for the service. A listener is either a
  14519. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  14520. an @code{inet-listener-configuration}.
  14521. Defaults to @samp{()}.
  14522. Available @code{unix-listener-configuration} fields are:
  14523. @deftypevr {@code{unix-listener-configuration} parameter} string path
  14524. Path to the file, relative to @code{base-dir} field. This is also used as
  14525. the section name.
  14526. @end deftypevr
  14527. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  14528. The access mode for the socket.
  14529. Defaults to @samp{"0600"}.
  14530. @end deftypevr
  14531. @deftypevr {@code{unix-listener-configuration} parameter} string user
  14532. The user to own the socket.
  14533. Defaults to @samp{""}.
  14534. @end deftypevr
  14535. @deftypevr {@code{unix-listener-configuration} parameter} string group
  14536. The group to own the socket.
  14537. Defaults to @samp{""}.
  14538. @end deftypevr
  14539. Available @code{fifo-listener-configuration} fields are:
  14540. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  14541. Path to the file, relative to @code{base-dir} field. This is also used as
  14542. the section name.
  14543. @end deftypevr
  14544. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  14545. The access mode for the socket.
  14546. Defaults to @samp{"0600"}.
  14547. @end deftypevr
  14548. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  14549. The user to own the socket.
  14550. Defaults to @samp{""}.
  14551. @end deftypevr
  14552. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  14553. The group to own the socket.
  14554. Defaults to @samp{""}.
  14555. @end deftypevr
  14556. Available @code{inet-listener-configuration} fields are:
  14557. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  14558. The protocol to listen for.
  14559. @end deftypevr
  14560. @deftypevr {@code{inet-listener-configuration} parameter} string address
  14561. The address on which to listen, or empty for all addresses.
  14562. Defaults to @samp{""}.
  14563. @end deftypevr
  14564. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  14565. The port on which to listen.
  14566. @end deftypevr
  14567. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  14568. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  14569. @samp{required}.
  14570. Defaults to @samp{#t}.
  14571. @end deftypevr
  14572. @end deftypevr
  14573. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  14574. Maximum number of simultaneous client connections per process. Once
  14575. this number of connections is received, the next incoming connection
  14576. will prompt Dovecot to spawn another process. If set to 0,
  14577. @code{default-client-limit} is used instead.
  14578. Defaults to @samp{0}.
  14579. @end deftypevr
  14580. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  14581. Number of connections to handle before starting a new process.
  14582. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  14583. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  14584. Defaults to @samp{1}.
  14585. @end deftypevr
  14586. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  14587. Maximum number of processes that can exist for this service. If set to
  14588. 0, @code{default-process-limit} is used instead.
  14589. Defaults to @samp{0}.
  14590. @end deftypevr
  14591. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  14592. Number of processes to always keep waiting for more connections.
  14593. Defaults to @samp{0}.
  14594. @end deftypevr
  14595. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  14596. If you set @samp{service-count 0}, you probably need to grow
  14597. this.
  14598. Defaults to @samp{256000000}.
  14599. @end deftypevr
  14600. @end deftypevr
  14601. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  14602. Dict configuration, as created by the @code{dict-configuration}
  14603. constructor.
  14604. Available @code{dict-configuration} fields are:
  14605. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  14606. A list of key-value pairs that this dict should hold.
  14607. Defaults to @samp{()}.
  14608. @end deftypevr
  14609. @end deftypevr
  14610. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  14611. A list of passdb configurations, each one created by the
  14612. @code{passdb-configuration} constructor.
  14613. Available @code{passdb-configuration} fields are:
  14614. @deftypevr {@code{passdb-configuration} parameter} string driver
  14615. The driver that the passdb should use. Valid values include
  14616. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  14617. @samp{static}.
  14618. Defaults to @samp{"pam"}.
  14619. @end deftypevr
  14620. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  14621. Space separated list of arguments to the passdb driver.
  14622. Defaults to @samp{""}.
  14623. @end deftypevr
  14624. @end deftypevr
  14625. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  14626. List of userdb configurations, each one created by the
  14627. @code{userdb-configuration} constructor.
  14628. Available @code{userdb-configuration} fields are:
  14629. @deftypevr {@code{userdb-configuration} parameter} string driver
  14630. The driver that the userdb should use. Valid values include
  14631. @samp{passwd} and @samp{static}.
  14632. Defaults to @samp{"passwd"}.
  14633. @end deftypevr
  14634. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  14635. Space separated list of arguments to the userdb driver.
  14636. Defaults to @samp{""}.
  14637. @end deftypevr
  14638. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  14639. Override fields from passwd.
  14640. Defaults to @samp{()}.
  14641. @end deftypevr
  14642. @end deftypevr
  14643. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  14644. Plug-in configuration, created by the @code{plugin-configuration}
  14645. constructor.
  14646. @end deftypevr
  14647. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  14648. List of namespaces. Each item in the list is created by the
  14649. @code{namespace-configuration} constructor.
  14650. Available @code{namespace-configuration} fields are:
  14651. @deftypevr {@code{namespace-configuration} parameter} string name
  14652. Name for this namespace.
  14653. @end deftypevr
  14654. @deftypevr {@code{namespace-configuration} parameter} string type
  14655. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  14656. Defaults to @samp{"private"}.
  14657. @end deftypevr
  14658. @deftypevr {@code{namespace-configuration} parameter} string separator
  14659. Hierarchy separator to use. You should use the same separator for
  14660. all namespaces or some clients get confused. @samp{/} is usually a good
  14661. one. The default however depends on the underlying mail storage
  14662. format.
  14663. Defaults to @samp{""}.
  14664. @end deftypevr
  14665. @deftypevr {@code{namespace-configuration} parameter} string prefix
  14666. Prefix required to access this namespace. This needs to be
  14667. different for all namespaces. For example @samp{Public/}.
  14668. Defaults to @samp{""}.
  14669. @end deftypevr
  14670. @deftypevr {@code{namespace-configuration} parameter} string location
  14671. Physical location of the mailbox. This is in the same format as
  14672. mail_location, which is also the default for it.
  14673. Defaults to @samp{""}.
  14674. @end deftypevr
  14675. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  14676. There can be only one INBOX, and this setting defines which
  14677. namespace has it.
  14678. Defaults to @samp{#f}.
  14679. @end deftypevr
  14680. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  14681. If namespace is hidden, it's not advertised to clients via NAMESPACE
  14682. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  14683. useful when converting from another server with different namespaces
  14684. which you want to deprecate but still keep working. For example you can
  14685. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  14686. and @samp{mail/}.
  14687. Defaults to @samp{#f}.
  14688. @end deftypevr
  14689. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  14690. Show the mailboxes under this namespace with the LIST command. This
  14691. makes the namespace visible for clients that do not support the NAMESPACE
  14692. extension. The special @code{children} value lists child mailboxes, but
  14693. hides the namespace prefix.
  14694. Defaults to @samp{#t}.
  14695. @end deftypevr
  14696. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  14697. Namespace handles its own subscriptions. If set to @code{#f}, the
  14698. parent namespace handles them. The empty prefix should always have this
  14699. as @code{#t}).
  14700. Defaults to @samp{#t}.
  14701. @end deftypevr
  14702. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  14703. List of predefined mailboxes in this namespace.
  14704. Defaults to @samp{()}.
  14705. Available @code{mailbox-configuration} fields are:
  14706. @deftypevr {@code{mailbox-configuration} parameter} string name
  14707. Name for this mailbox.
  14708. @end deftypevr
  14709. @deftypevr {@code{mailbox-configuration} parameter} string auto
  14710. @samp{create} will automatically create this mailbox.
  14711. @samp{subscribe} will both create and subscribe to the mailbox.
  14712. Defaults to @samp{"no"}.
  14713. @end deftypevr
  14714. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  14715. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  14716. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  14717. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  14718. Defaults to @samp{()}.
  14719. @end deftypevr
  14720. @end deftypevr
  14721. @end deftypevr
  14722. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  14723. Base directory where to store runtime data.
  14724. Defaults to @samp{"/var/run/dovecot/"}.
  14725. @end deftypevr
  14726. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  14727. Greeting message for clients.
  14728. Defaults to @samp{"Dovecot ready."}.
  14729. @end deftypevr
  14730. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  14731. List of trusted network ranges. Connections from these IPs are
  14732. allowed to override their IP addresses and ports (for logging and for
  14733. authentication checks). @samp{disable-plaintext-auth} is also ignored
  14734. for these networks. Typically you would specify your IMAP proxy servers
  14735. here.
  14736. Defaults to @samp{()}.
  14737. @end deftypevr
  14738. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  14739. List of login access check sockets (e.g.@: tcpwrap).
  14740. Defaults to @samp{()}.
  14741. @end deftypevr
  14742. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  14743. Show more verbose process titles (in ps). Currently shows user name
  14744. and IP address. Useful for seeing who is actually using the IMAP
  14745. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  14746. accounts).
  14747. Defaults to @samp{#f}.
  14748. @end deftypevr
  14749. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  14750. Should all processes be killed when Dovecot master process shuts down.
  14751. Setting this to @code{#f} means that Dovecot can be upgraded without
  14752. forcing existing client connections to close (although that could also
  14753. be a problem if the upgrade is e.g.@: due to a security fix).
  14754. Defaults to @samp{#t}.
  14755. @end deftypevr
  14756. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  14757. If non-zero, run mail commands via this many connections to doveadm
  14758. server, instead of running them directly in the same process.
  14759. Defaults to @samp{0}.
  14760. @end deftypevr
  14761. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  14762. UNIX socket or host:port used for connecting to doveadm server.
  14763. Defaults to @samp{"doveadm-server"}.
  14764. @end deftypevr
  14765. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  14766. List of environment variables that are preserved on Dovecot startup
  14767. and passed down to all of its child processes. You can also give
  14768. key=value pairs to always set specific settings.
  14769. @end deftypevr
  14770. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  14771. Disable LOGIN command and all other plaintext authentications unless
  14772. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  14773. matches the local IP (i.e.@: you're connecting from the same computer),
  14774. the connection is considered secure and plaintext authentication is
  14775. allowed. See also ssl=required setting.
  14776. Defaults to @samp{#t}.
  14777. @end deftypevr
  14778. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  14779. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  14780. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  14781. for caching to be used.
  14782. Defaults to @samp{0}.
  14783. @end deftypevr
  14784. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  14785. Time to live for cached data. After TTL expires the cached record
  14786. is no longer used, *except* if the main database lookup returns internal
  14787. failure. We also try to handle password changes automatically: If
  14788. user's previous authentication was successful, but this one wasn't, the
  14789. cache isn't used. For now this works only with plaintext
  14790. authentication.
  14791. Defaults to @samp{"1 hour"}.
  14792. @end deftypevr
  14793. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  14794. TTL for negative hits (user not found, password mismatch).
  14795. 0 disables caching them completely.
  14796. Defaults to @samp{"1 hour"}.
  14797. @end deftypevr
  14798. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  14799. List of realms for SASL authentication mechanisms that need them.
  14800. You can leave it empty if you don't want to support multiple realms.
  14801. Many clients simply use the first one listed here, so keep the default
  14802. realm first.
  14803. Defaults to @samp{()}.
  14804. @end deftypevr
  14805. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  14806. Default realm/domain to use if none was specified. This is used for
  14807. both SASL realms and appending @@domain to username in plaintext
  14808. logins.
  14809. Defaults to @samp{""}.
  14810. @end deftypevr
  14811. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  14812. List of allowed characters in username. If the user-given username
  14813. contains a character not listed in here, the login automatically fails.
  14814. This is just an extra check to make sure user can't exploit any
  14815. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  14816. you want to allow all characters, set this value to empty.
  14817. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  14818. @end deftypevr
  14819. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  14820. Username character translations before it's looked up from
  14821. databases. The value contains series of from -> to characters. For
  14822. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  14823. translated to @samp{@@}.
  14824. Defaults to @samp{""}.
  14825. @end deftypevr
  14826. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  14827. Username formatting before it's looked up from databases. You can
  14828. use the standard variables here, e.g.@: %Lu would lowercase the username,
  14829. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  14830. change the @samp{@@} into @samp{-AT-}. This translation is done after
  14831. @samp{auth-username-translation} changes.
  14832. Defaults to @samp{"%Lu"}.
  14833. @end deftypevr
  14834. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  14835. If you want to allow master users to log in by specifying the master
  14836. username within the normal username string (i.e.@: not using SASL
  14837. mechanism's support for it), you can specify the separator character
  14838. here. The format is then <username><separator><master username>.
  14839. UW-IMAP uses @samp{*} as the separator, so that could be a good
  14840. choice.
  14841. Defaults to @samp{""}.
  14842. @end deftypevr
  14843. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  14844. Username to use for users logging in with ANONYMOUS SASL
  14845. mechanism.
  14846. Defaults to @samp{"anonymous"}.
  14847. @end deftypevr
  14848. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  14849. Maximum number of dovecot-auth worker processes. They're used to
  14850. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  14851. They're automatically created and destroyed as needed.
  14852. Defaults to @samp{30}.
  14853. @end deftypevr
  14854. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  14855. Host name to use in GSSAPI principal names. The default is to use
  14856. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  14857. allow all keytab entries.
  14858. Defaults to @samp{""}.
  14859. @end deftypevr
  14860. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  14861. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  14862. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  14863. need to change the auth service to run as root to be able to read this
  14864. file.
  14865. Defaults to @samp{""}.
  14866. @end deftypevr
  14867. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  14868. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  14869. and @samp{ntlm-auth} helper.
  14870. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  14871. Defaults to @samp{#f}.
  14872. @end deftypevr
  14873. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  14874. Path for Samba's @samp{ntlm-auth} helper binary.
  14875. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  14876. @end deftypevr
  14877. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  14878. Time to delay before replying to failed authentications.
  14879. Defaults to @samp{"2 secs"}.
  14880. @end deftypevr
  14881. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  14882. Require a valid SSL client certificate or the authentication
  14883. fails.
  14884. Defaults to @samp{#f}.
  14885. @end deftypevr
  14886. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  14887. Take the username from client's SSL certificate, using
  14888. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  14889. CommonName.
  14890. Defaults to @samp{#f}.
  14891. @end deftypevr
  14892. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  14893. List of wanted authentication mechanisms. Supported mechanisms are:
  14894. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  14895. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  14896. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  14897. @samp{disable-plaintext-auth} setting.
  14898. @end deftypevr
  14899. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  14900. List of IPs or hostnames to all director servers, including ourself.
  14901. Ports can be specified as ip:port. The default port is the same as what
  14902. director service's @samp{inet-listener} is using.
  14903. Defaults to @samp{()}.
  14904. @end deftypevr
  14905. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  14906. List of IPs or hostnames to all backend mail servers. Ranges are
  14907. allowed too, like 10.0.0.10-10.0.0.30.
  14908. Defaults to @samp{()}.
  14909. @end deftypevr
  14910. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  14911. How long to redirect users to a specific server after it no longer
  14912. has any connections.
  14913. Defaults to @samp{"15 min"}.
  14914. @end deftypevr
  14915. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  14916. How the username is translated before being hashed. Useful values
  14917. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  14918. are shared within domain.
  14919. Defaults to @samp{"%Lu"}.
  14920. @end deftypevr
  14921. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  14922. Log file to use for error messages. @samp{syslog} logs to syslog,
  14923. @samp{/dev/stderr} logs to stderr.
  14924. Defaults to @samp{"syslog"}.
  14925. @end deftypevr
  14926. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  14927. Log file to use for informational messages. Defaults to
  14928. @samp{log-path}.
  14929. Defaults to @samp{""}.
  14930. @end deftypevr
  14931. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  14932. Log file to use for debug messages. Defaults to
  14933. @samp{info-log-path}.
  14934. Defaults to @samp{""}.
  14935. @end deftypevr
  14936. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  14937. Syslog facility to use if you're logging to syslog. Usually if you
  14938. don't want to use @samp{mail}, you'll use local0..local7. Also other
  14939. standard facilities are supported.
  14940. Defaults to @samp{"mail"}.
  14941. @end deftypevr
  14942. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  14943. Log unsuccessful authentication attempts and the reasons why they
  14944. failed.
  14945. Defaults to @samp{#f}.
  14946. @end deftypevr
  14947. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  14948. In case of password mismatches, log the attempted password. Valid
  14949. values are no, plain and sha1. sha1 can be useful for detecting brute
  14950. force password attempts vs. user simply trying the same password over
  14951. and over again. You can also truncate the value to n chars by appending
  14952. ":n" (e.g.@: sha1:6).
  14953. Defaults to @samp{"no"}.
  14954. @end deftypevr
  14955. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  14956. Even more verbose logging for debugging purposes. Shows for example
  14957. SQL queries.
  14958. Defaults to @samp{#f}.
  14959. @end deftypevr
  14960. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  14961. In case of password mismatches, log the passwords and used scheme so
  14962. the problem can be debugged. Enabling this also enables
  14963. @samp{auth-debug}.
  14964. Defaults to @samp{#f}.
  14965. @end deftypevr
  14966. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  14967. Enable mail process debugging. This can help you figure out why
  14968. Dovecot isn't finding your mails.
  14969. Defaults to @samp{#f}.
  14970. @end deftypevr
  14971. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  14972. Show protocol level SSL errors.
  14973. Defaults to @samp{#f}.
  14974. @end deftypevr
  14975. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  14976. Prefix for each line written to log file. % codes are in
  14977. strftime(3) format.
  14978. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  14979. @end deftypevr
  14980. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  14981. List of elements we want to log. The elements which have a
  14982. non-empty variable value are joined together to form a comma-separated
  14983. string.
  14984. @end deftypevr
  14985. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  14986. Login log format. %s contains @samp{login-log-format-elements}
  14987. string, %$ contains the data we want to log.
  14988. Defaults to @samp{"%$: %s"}.
  14989. @end deftypevr
  14990. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  14991. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  14992. of possible variables you can use.
  14993. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  14994. @end deftypevr
  14995. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  14996. Format to use for logging mail deliveries. You can use variables:
  14997. @table @code
  14998. @item %$
  14999. Delivery status message (e.g.@: @samp{saved to INBOX})
  15000. @item %m
  15001. Message-ID
  15002. @item %s
  15003. Subject
  15004. @item %f
  15005. From address
  15006. @item %p
  15007. Physical size
  15008. @item %w
  15009. Virtual size.
  15010. @end table
  15011. Defaults to @samp{"msgid=%m: %$"}.
  15012. @end deftypevr
  15013. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  15014. Location for users' mailboxes. The default is empty, which means
  15015. that Dovecot tries to find the mailboxes automatically. This won't work
  15016. if the user doesn't yet have any mail, so you should explicitly tell
  15017. Dovecot the full location.
  15018. If you're using mbox, giving a path to the INBOX
  15019. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  15020. where the other mailboxes are kept. This is called the @emph{root mail
  15021. directory}, and it must be the first path given in the
  15022. @samp{mail-location} setting.
  15023. There are a few special variables you can use, e.g.:
  15024. @table @samp
  15025. @item %u
  15026. username
  15027. @item %n
  15028. user part in user@@domain, same as %u if there's no domain
  15029. @item %d
  15030. domain part in user@@domain, empty if there's no domain
  15031. @item %h
  15032. home director
  15033. @end table
  15034. See doc/wiki/Variables.txt for full list. Some examples:
  15035. @table @samp
  15036. @item maildir:~/Maildir
  15037. @item mbox:~/mail:INBOX=/var/mail/%u
  15038. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  15039. @end table
  15040. Defaults to @samp{""}.
  15041. @end deftypevr
  15042. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  15043. System user and group used to access mails. If you use multiple,
  15044. userdb can override these by returning uid or gid fields. You can use
  15045. either numbers or names. <doc/wiki/UserIds.txt>.
  15046. Defaults to @samp{""}.
  15047. @end deftypevr
  15048. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  15049. Defaults to @samp{""}.
  15050. @end deftypevr
  15051. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  15052. Group to enable temporarily for privileged operations. Currently
  15053. this is used only with INBOX when either its initial creation or
  15054. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  15055. @file{/var/mail}.
  15056. Defaults to @samp{""}.
  15057. @end deftypevr
  15058. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  15059. Grant access to these supplementary groups for mail processes.
  15060. Typically these are used to set up access to shared mailboxes. Note
  15061. that it may be dangerous to set these if users can create symlinks
  15062. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  15063. could allow a user to delete others' mailboxes, or @code{ln -s
  15064. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  15065. @samp{""}.
  15066. @end deftypevr
  15067. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  15068. Allow full file system access to clients. There's no access checks
  15069. other than what the operating system does for the active UID/GID. It
  15070. works with both maildir and mboxes, allowing you to prefix mailboxes
  15071. names with e.g.@: @file{/path/} or @file{~user/}.
  15072. Defaults to @samp{#f}.
  15073. @end deftypevr
  15074. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  15075. Don't use @code{mmap()} at all. This is required if you store indexes to
  15076. shared file systems (NFS or clustered file system).
  15077. Defaults to @samp{#f}.
  15078. @end deftypevr
  15079. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  15080. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  15081. supports @samp{O_EXCL} since version 3, so this should be safe to use
  15082. nowadays by default.
  15083. Defaults to @samp{#t}.
  15084. @end deftypevr
  15085. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  15086. When to use fsync() or fdatasync() calls:
  15087. @table @code
  15088. @item optimized
  15089. Whenever necessary to avoid losing important data
  15090. @item always
  15091. Useful with e.g.@: NFS when @code{write()}s are delayed
  15092. @item never
  15093. Never use it (best performance, but crashes can lose data).
  15094. @end table
  15095. Defaults to @samp{"optimized"}.
  15096. @end deftypevr
  15097. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  15098. Mail storage exists in NFS. Set this to yes to make Dovecot flush
  15099. NFS caches whenever needed. If you're using only a single mail server
  15100. this isn't needed.
  15101. Defaults to @samp{#f}.
  15102. @end deftypevr
  15103. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  15104. Mail index files also exist in NFS. Setting this to yes requires
  15105. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  15106. Defaults to @samp{#f}.
  15107. @end deftypevr
  15108. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  15109. Locking method for index files. Alternatives are fcntl, flock and
  15110. dotlock. Dotlocking uses some tricks which may create more disk I/O
  15111. than other locking methods. NFS users: flock doesn't work, remember to
  15112. change @samp{mmap-disable}.
  15113. Defaults to @samp{"fcntl"}.
  15114. @end deftypevr
  15115. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  15116. Directory in which LDA/LMTP temporarily stores incoming mails >128
  15117. kB.
  15118. Defaults to @samp{"/tmp"}.
  15119. @end deftypevr
  15120. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  15121. Valid UID range for users. This is mostly to make sure that users can't
  15122. log in as daemons or other system users. Note that denying root logins is
  15123. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  15124. is set to 0.
  15125. Defaults to @samp{500}.
  15126. @end deftypevr
  15127. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  15128. Defaults to @samp{0}.
  15129. @end deftypevr
  15130. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  15131. Valid GID range for users. Users having non-valid GID as primary group ID
  15132. aren't allowed to log in. If user belongs to supplementary groups with
  15133. non-valid GIDs, those groups are not set.
  15134. Defaults to @samp{1}.
  15135. @end deftypevr
  15136. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  15137. Defaults to @samp{0}.
  15138. @end deftypevr
  15139. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  15140. Maximum allowed length for mail keyword name. It's only forced when
  15141. trying to create new keywords.
  15142. Defaults to @samp{50}.
  15143. @end deftypevr
  15144. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  15145. List of directories under which chrooting is allowed for mail
  15146. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  15147. too). This setting doesn't affect @samp{login-chroot}
  15148. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  15149. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  15150. which local users can modify, that may lead to root exploit. Usually
  15151. this should be done only if you don't allow shell access for users.
  15152. <doc/wiki/Chrooting.txt>.
  15153. Defaults to @samp{()}.
  15154. @end deftypevr
  15155. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  15156. Default chroot directory for mail processes. This can be overridden
  15157. for specific users in user database by giving @samp{/./} in user's home
  15158. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  15159. there is no real need to do chrooting, Dovecot doesn't allow users to
  15160. access files outside their mail directory anyway. If your home
  15161. directories are prefixed with the chroot directory, append @samp{/.} to
  15162. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  15163. Defaults to @samp{""}.
  15164. @end deftypevr
  15165. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  15166. UNIX socket path to master authentication server to find users.
  15167. This is used by imap (for shared users) and lda.
  15168. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  15169. @end deftypevr
  15170. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  15171. Directory where to look up mail plugins.
  15172. Defaults to @samp{"/usr/lib/dovecot"}.
  15173. @end deftypevr
  15174. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  15175. List of plugins to load for all services. Plugins specific to IMAP,
  15176. LDA, etc.@: are added to this list in their own .conf files.
  15177. Defaults to @samp{()}.
  15178. @end deftypevr
  15179. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  15180. The minimum number of mails in a mailbox before updates are done to
  15181. cache file. This allows optimizing Dovecot's behavior to do less disk
  15182. writes at the cost of more disk reads.
  15183. Defaults to @samp{0}.
  15184. @end deftypevr
  15185. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  15186. When IDLE command is running, mailbox is checked once in a while to
  15187. see if there are any new mails or other changes. This setting defines
  15188. the minimum time to wait between those checks. Dovecot can also use
  15189. dnotify, inotify and kqueue to find out immediately when changes
  15190. occur.
  15191. Defaults to @samp{"30 secs"}.
  15192. @end deftypevr
  15193. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  15194. Save mails with CR+LF instead of plain LF. This makes sending those
  15195. mails take less CPU, especially with sendfile() syscall with Linux and
  15196. FreeBSD. But it also creates a bit more disk I/O which may just make it
  15197. slower. Also note that if other software reads the mboxes/maildirs,
  15198. they may handle the extra CRs wrong and cause problems.
  15199. Defaults to @samp{#f}.
  15200. @end deftypevr
  15201. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  15202. By default LIST command returns all entries in maildir beginning
  15203. with a dot. Enabling this option makes Dovecot return only entries
  15204. which are directories. This is done by stat()ing each entry, so it
  15205. causes more disk I/O.
  15206. (For systems setting struct @samp{dirent->d_type} this check is free
  15207. and it's done always regardless of this setting).
  15208. Defaults to @samp{#f}.
  15209. @end deftypevr
  15210. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  15211. When copying a message, do it with hard links whenever possible.
  15212. This makes the performance much better, and it's unlikely to have any
  15213. side effects.
  15214. Defaults to @samp{#t}.
  15215. @end deftypevr
  15216. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  15217. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  15218. directory only when its mtime changes unexpectedly or when we can't find
  15219. the mail otherwise.
  15220. Defaults to @samp{#f}.
  15221. @end deftypevr
  15222. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  15223. Which locking methods to use for locking mbox. There are four
  15224. available:
  15225. @table @code
  15226. @item dotlock
  15227. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  15228. solution. If you want to use /var/mail/ like directory, the users will
  15229. need write access to that directory.
  15230. @item dotlock-try
  15231. Same as dotlock, but if it fails because of permissions or because there
  15232. isn't enough disk space, just skip it.
  15233. @item fcntl
  15234. Use this if possible. Works with NFS too if lockd is used.
  15235. @item flock
  15236. May not exist in all systems. Doesn't work with NFS.
  15237. @item lockf
  15238. May not exist in all systems. Doesn't work with NFS.
  15239. @end table
  15240. You can use multiple locking methods; if you do the order they're declared
  15241. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  15242. locking methods as well. Some operating systems don't allow using some of
  15243. them simultaneously.
  15244. @end deftypevr
  15245. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  15246. @end deftypevr
  15247. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  15248. Maximum time to wait for lock (all of them) before aborting.
  15249. Defaults to @samp{"5 mins"}.
  15250. @end deftypevr
  15251. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  15252. If dotlock exists but the mailbox isn't modified in any way,
  15253. override the lock file after this much time.
  15254. Defaults to @samp{"2 mins"}.
  15255. @end deftypevr
  15256. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  15257. When mbox changes unexpectedly we have to fully read it to find out
  15258. what changed. If the mbox is large this can take a long time. Since
  15259. the change is usually just a newly appended mail, it'd be faster to
  15260. simply read the new mails. If this setting is enabled, Dovecot does
  15261. this but still safely fallbacks to re-reading the whole mbox file
  15262. whenever something in mbox isn't how it's expected to be. The only real
  15263. downside to this setting is that if some other MUA changes message
  15264. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  15265. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  15266. Defaults to @samp{#t}.
  15267. @end deftypevr
  15268. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  15269. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  15270. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  15271. @samp{mbox-dirty-syncs} is ignored.
  15272. Defaults to @samp{#f}.
  15273. @end deftypevr
  15274. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  15275. Delay writing mbox headers until doing a full write sync (EXPUNGE
  15276. and CHECK commands and when closing the mailbox). This is especially
  15277. useful for POP3 where clients often delete all mails. The downside is
  15278. that our changes aren't immediately visible to other MUAs.
  15279. Defaults to @samp{#t}.
  15280. @end deftypevr
  15281. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  15282. If mbox size is smaller than this (e.g.@: 100k), don't write index
  15283. files. If an index file already exists it's still read, just not
  15284. updated.
  15285. Defaults to @samp{0}.
  15286. @end deftypevr
  15287. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  15288. Maximum dbox file size until it's rotated.
  15289. Defaults to @samp{10000000}.
  15290. @end deftypevr
  15291. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  15292. Maximum dbox file age until it's rotated. Typically in days. Day
  15293. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  15294. disabled.
  15295. Defaults to @samp{"1d"}.
  15296. @end deftypevr
  15297. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  15298. When creating new mdbox files, immediately preallocate their size to
  15299. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  15300. with some file systems (ext4, xfs).
  15301. Defaults to @samp{#f}.
  15302. @end deftypevr
  15303. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  15304. sdbox and mdbox support saving mail attachments to external files,
  15305. which also allows single instance storage for them. Other backends
  15306. don't support this for now.
  15307. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  15308. Directory root where to store mail attachments. Disabled, if empty.
  15309. Defaults to @samp{""}.
  15310. @end deftypevr
  15311. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  15312. Attachments smaller than this aren't saved externally. It's also
  15313. possible to write a plugin to disable saving specific attachments
  15314. externally.
  15315. Defaults to @samp{128000}.
  15316. @end deftypevr
  15317. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  15318. File system backend to use for saving attachments:
  15319. @table @code
  15320. @item posix
  15321. No SiS done by Dovecot (but this might help FS's own deduplication)
  15322. @item sis posix
  15323. SiS with immediate byte-by-byte comparison during saving
  15324. @item sis-queue posix
  15325. SiS with delayed comparison and deduplication.
  15326. @end table
  15327. Defaults to @samp{"sis posix"}.
  15328. @end deftypevr
  15329. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  15330. Hash format to use in attachment filenames. You can add any text and
  15331. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  15332. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  15333. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  15334. Defaults to @samp{"%@{sha1@}"}.
  15335. @end deftypevr
  15336. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  15337. Defaults to @samp{100}.
  15338. @end deftypevr
  15339. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  15340. Defaults to @samp{1000}.
  15341. @end deftypevr
  15342. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  15343. Default VSZ (virtual memory size) limit for service processes.
  15344. This is mainly intended to catch and kill processes that leak memory
  15345. before they eat up everything.
  15346. Defaults to @samp{256000000}.
  15347. @end deftypevr
  15348. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  15349. Login user is internally used by login processes. This is the most
  15350. untrusted user in Dovecot system. It shouldn't have access to anything
  15351. at all.
  15352. Defaults to @samp{"dovenull"}.
  15353. @end deftypevr
  15354. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  15355. Internal user is used by unprivileged processes. It should be
  15356. separate from login user, so that login processes can't disturb other
  15357. processes.
  15358. Defaults to @samp{"dovecot"}.
  15359. @end deftypevr
  15360. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  15361. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  15362. Defaults to @samp{"required"}.
  15363. @end deftypevr
  15364. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  15365. PEM encoded X.509 SSL/TLS certificate (public key).
  15366. Defaults to @samp{"</etc/dovecot/default.pem"}.
  15367. @end deftypevr
  15368. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  15369. PEM encoded SSL/TLS private key. The key is opened before
  15370. dropping root privileges, so keep the key file unreadable by anyone but
  15371. root.
  15372. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  15373. @end deftypevr
  15374. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  15375. If key file is password protected, give the password here.
  15376. Alternatively give it when starting dovecot with -p parameter. Since
  15377. this file is often world-readable, you may want to place this setting
  15378. instead to a different.
  15379. Defaults to @samp{""}.
  15380. @end deftypevr
  15381. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  15382. PEM encoded trusted certificate authority. Set this only if you
  15383. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  15384. contain the CA certificate(s) followed by the matching
  15385. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  15386. Defaults to @samp{""}.
  15387. @end deftypevr
  15388. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  15389. Require that CRL check succeeds for client certificates.
  15390. Defaults to @samp{#t}.
  15391. @end deftypevr
  15392. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  15393. Request client to send a certificate. If you also want to require
  15394. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  15395. Defaults to @samp{#f}.
  15396. @end deftypevr
  15397. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  15398. Which field from certificate to use for username. commonName and
  15399. x500UniqueIdentifier are the usual choices. You'll also need to set
  15400. @samp{auth-ssl-username-from-cert? #t}.
  15401. Defaults to @samp{"commonName"}.
  15402. @end deftypevr
  15403. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  15404. Minimum SSL protocol version to accept.
  15405. Defaults to @samp{"TLSv1"}.
  15406. @end deftypevr
  15407. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  15408. SSL ciphers to use.
  15409. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  15410. @end deftypevr
  15411. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  15412. SSL crypto device to use, for valid values run "openssl engine".
  15413. Defaults to @samp{""}.
  15414. @end deftypevr
  15415. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  15416. Address to use when sending rejection mails.
  15417. %d expands to recipient domain.
  15418. Defaults to @samp{"postmaster@@%d"}.
  15419. @end deftypevr
  15420. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  15421. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  15422. and in LMTP replies. Default is the system's real hostname@@domain.
  15423. Defaults to @samp{""}.
  15424. @end deftypevr
  15425. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  15426. If user is over quota, return with temporary failure instead of
  15427. bouncing the mail.
  15428. Defaults to @samp{#f}.
  15429. @end deftypevr
  15430. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  15431. Binary to use for sending mails.
  15432. Defaults to @samp{"/usr/sbin/sendmail"}.
  15433. @end deftypevr
  15434. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  15435. If non-empty, send mails via this SMTP host[:port] instead of
  15436. sendmail.
  15437. Defaults to @samp{""}.
  15438. @end deftypevr
  15439. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  15440. Subject: header to use for rejection mails. You can use the same
  15441. variables as for @samp{rejection-reason} below.
  15442. Defaults to @samp{"Rejected: %s"}.
  15443. @end deftypevr
  15444. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  15445. Human readable error message for rejection mails. You can use
  15446. variables:
  15447. @table @code
  15448. @item %n
  15449. CRLF
  15450. @item %r
  15451. reason
  15452. @item %s
  15453. original subject
  15454. @item %t
  15455. recipient
  15456. @end table
  15457. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  15458. @end deftypevr
  15459. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  15460. Delimiter character between local-part and detail in email
  15461. address.
  15462. Defaults to @samp{"+"}.
  15463. @end deftypevr
  15464. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  15465. Header where the original recipient address (SMTP's RCPT TO:
  15466. address) is taken from if not available elsewhere. With dovecot-lda -a
  15467. parameter overrides this. A commonly used header for this is
  15468. X-Original-To.
  15469. Defaults to @samp{""}.
  15470. @end deftypevr
  15471. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  15472. Should saving a mail to a nonexistent mailbox automatically create
  15473. it?.
  15474. Defaults to @samp{#f}.
  15475. @end deftypevr
  15476. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  15477. Should automatically created mailboxes be also automatically
  15478. subscribed?.
  15479. Defaults to @samp{#f}.
  15480. @end deftypevr
  15481. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  15482. Maximum IMAP command line length. Some clients generate very long
  15483. command lines with huge mailboxes, so you may need to raise this if you
  15484. get "Too long argument" or "IMAP command line too large" errors
  15485. often.
  15486. Defaults to @samp{64000}.
  15487. @end deftypevr
  15488. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  15489. IMAP logout format string:
  15490. @table @code
  15491. @item %i
  15492. total number of bytes read from client
  15493. @item %o
  15494. total number of bytes sent to client.
  15495. @end table
  15496. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  15497. 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@}"}.
  15498. @end deftypevr
  15499. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  15500. Override the IMAP CAPABILITY response. If the value begins with '+',
  15501. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  15502. Defaults to @samp{""}.
  15503. @end deftypevr
  15504. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  15505. How long to wait between "OK Still here" notifications when client
  15506. is IDLEing.
  15507. Defaults to @samp{"2 mins"}.
  15508. @end deftypevr
  15509. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  15510. ID field names and values to send to clients. Using * as the value
  15511. makes Dovecot use the default value. The following fields have default
  15512. values currently: name, version, os, os-version, support-url,
  15513. support-email.
  15514. Defaults to @samp{""}.
  15515. @end deftypevr
  15516. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  15517. ID fields sent by client to log. * means everything.
  15518. Defaults to @samp{""}.
  15519. @end deftypevr
  15520. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  15521. Workarounds for various client bugs:
  15522. @table @code
  15523. @item delay-newmail
  15524. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  15525. CHECK commands. Some clients ignore them otherwise, for example OSX
  15526. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  15527. may show user "Message no longer in server" errors. Note that OE6
  15528. still breaks even with this workaround if synchronization is set to
  15529. "Headers Only".
  15530. @item tb-extra-mailbox-sep
  15531. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  15532. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  15533. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  15534. @item tb-lsub-flags
  15535. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  15536. This makes Thunderbird realize they aren't selectable and show them
  15537. greyed out, instead of only later giving "not selectable" popup error.
  15538. @end table
  15539. Defaults to @samp{()}.
  15540. @end deftypevr
  15541. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  15542. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  15543. Defaults to @samp{""}.
  15544. @end deftypevr
  15545. Whew! Lots of configuration options. The nice thing about it though is
  15546. that Guix has a complete interface to Dovecot's configuration
  15547. language. This allows not only a nice way to declare configurations,
  15548. but also offers reflective capabilities as well: users can write code to
  15549. inspect and transform configurations from within Scheme.
  15550. However, it could be that you just want to get a @code{dovecot.conf} up
  15551. and running. In that case, you can pass an
  15552. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  15553. @code{dovecot-service}. As its name indicates, an opaque configuration
  15554. does not have easy reflective capabilities.
  15555. Available @code{opaque-dovecot-configuration} fields are:
  15556. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  15557. The dovecot package.
  15558. @end deftypevr
  15559. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  15560. The contents of the @code{dovecot.conf}, as a string.
  15561. @end deftypevr
  15562. For example, if your @code{dovecot.conf} is just the empty string, you
  15563. could instantiate a dovecot service like this:
  15564. @lisp
  15565. (dovecot-service #:config
  15566. (opaque-dovecot-configuration
  15567. (string "")))
  15568. @end lisp
  15569. @subsubheading OpenSMTPD Service
  15570. @deffn {Scheme Variable} opensmtpd-service-type
  15571. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  15572. service, whose value should be an @code{opensmtpd-configuration} object
  15573. as in this example:
  15574. @lisp
  15575. (service opensmtpd-service-type
  15576. (opensmtpd-configuration
  15577. (config-file (local-file "./my-smtpd.conf"))))
  15578. @end lisp
  15579. @end deffn
  15580. @deftp {Data Type} opensmtpd-configuration
  15581. Data type representing the configuration of opensmtpd.
  15582. @table @asis
  15583. @item @code{package} (default: @var{opensmtpd})
  15584. Package object of the OpenSMTPD SMTP server.
  15585. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  15586. File-like object of the OpenSMTPD configuration file to use. By default
  15587. it listens on the loopback network interface, and allows for mail from
  15588. users and daemons on the local machine, as well as permitting email to
  15589. remote servers. Run @command{man smtpd.conf} for more information.
  15590. @end table
  15591. @end deftp
  15592. @subsubheading Exim Service
  15593. @cindex mail transfer agent (MTA)
  15594. @cindex MTA (mail transfer agent)
  15595. @cindex SMTP
  15596. @deffn {Scheme Variable} exim-service-type
  15597. This is the type of the @uref{https://exim.org, Exim} mail transfer
  15598. agent (MTA), whose value should be an @code{exim-configuration} object
  15599. as in this example:
  15600. @lisp
  15601. (service exim-service-type
  15602. (exim-configuration
  15603. (config-file (local-file "./my-exim.conf"))))
  15604. @end lisp
  15605. @end deffn
  15606. In order to use an @code{exim-service-type} service you must also have a
  15607. @code{mail-aliases-service-type} service present in your
  15608. @code{operating-system} (even if it has no aliases).
  15609. @deftp {Data Type} exim-configuration
  15610. Data type representing the configuration of exim.
  15611. @table @asis
  15612. @item @code{package} (default: @var{exim})
  15613. Package object of the Exim server.
  15614. @item @code{config-file} (default: @code{#f})
  15615. File-like object of the Exim configuration file to use. If its value is
  15616. @code{#f} then use the default configuration file from the package
  15617. provided in @code{package}. The resulting configuration file is loaded
  15618. after setting the @code{exim_user} and @code{exim_group} configuration
  15619. variables.
  15620. @end table
  15621. @end deftp
  15622. @subsubheading Getmail service
  15623. @cindex IMAP
  15624. @cindex POP
  15625. @deffn {Scheme Variable} getmail-service-type
  15626. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  15627. mail retriever, whose value should be an @code{getmail-configuration}.
  15628. @end deffn
  15629. Available @code{getmail-configuration} fields are:
  15630. @deftypevr {@code{getmail-configuration} parameter} symbol name
  15631. A symbol to identify the getmail service.
  15632. Defaults to @samp{"unset"}.
  15633. @end deftypevr
  15634. @deftypevr {@code{getmail-configuration} parameter} package package
  15635. The getmail package to use.
  15636. @end deftypevr
  15637. @deftypevr {@code{getmail-configuration} parameter} string user
  15638. The user to run getmail as.
  15639. Defaults to @samp{"getmail"}.
  15640. @end deftypevr
  15641. @deftypevr {@code{getmail-configuration} parameter} string group
  15642. The group to run getmail as.
  15643. Defaults to @samp{"getmail"}.
  15644. @end deftypevr
  15645. @deftypevr {@code{getmail-configuration} parameter} string directory
  15646. The getmail directory to use.
  15647. Defaults to @samp{"/var/lib/getmail/default"}.
  15648. @end deftypevr
  15649. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  15650. The getmail configuration file to use.
  15651. Available @code{getmail-configuration-file} fields are:
  15652. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  15653. What mail account to retrieve mail from, and how to access that account.
  15654. Available @code{getmail-retriever-configuration} fields are:
  15655. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  15656. The type of mail retriever to use. Valid values include @samp{passwd}
  15657. and @samp{static}.
  15658. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  15659. @end deftypevr
  15660. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  15661. Username to login to the mail server with.
  15662. Defaults to @samp{unset}.
  15663. @end deftypevr
  15664. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  15665. Username to login to the mail server with.
  15666. Defaults to @samp{unset}.
  15667. @end deftypevr
  15668. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  15669. Port number to connect to.
  15670. Defaults to @samp{#f}.
  15671. @end deftypevr
  15672. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  15673. Override fields from passwd.
  15674. Defaults to @samp{""}.
  15675. @end deftypevr
  15676. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  15677. Override fields from passwd.
  15678. Defaults to @samp{()}.
  15679. @end deftypevr
  15680. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  15681. PEM-formatted key file to use for the TLS negotiation.
  15682. Defaults to @samp{""}.
  15683. @end deftypevr
  15684. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  15685. PEM-formatted certificate file to use for the TLS negotiation.
  15686. Defaults to @samp{""}.
  15687. @end deftypevr
  15688. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  15689. CA certificates to use.
  15690. Defaults to @samp{""}.
  15691. @end deftypevr
  15692. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  15693. Extra retriever parameters.
  15694. Defaults to @samp{()}.
  15695. @end deftypevr
  15696. @end deftypevr
  15697. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  15698. What to do with retrieved messages.
  15699. Available @code{getmail-destination-configuration} fields are:
  15700. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  15701. The type of mail destination. Valid values include @samp{Maildir},
  15702. @samp{Mboxrd} and @samp{MDA_external}.
  15703. Defaults to @samp{unset}.
  15704. @end deftypevr
  15705. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  15706. The path option for the mail destination. The behaviour depends on the
  15707. chosen type.
  15708. Defaults to @samp{""}.
  15709. @end deftypevr
  15710. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  15711. Extra destination parameters
  15712. Defaults to @samp{()}.
  15713. @end deftypevr
  15714. @end deftypevr
  15715. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  15716. Configure getmail.
  15717. Available @code{getmail-options-configuration} fields are:
  15718. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  15719. If set to @samp{0}, getmail will only print warnings and errors. A
  15720. value of @samp{1} means that messages will be printed about retrieving
  15721. and deleting messages. If set to @samp{2}, getmail will print messages
  15722. about each of it's actions.
  15723. Defaults to @samp{1}.
  15724. @end deftypevr
  15725. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  15726. If true, getmail will retrieve all available messages. Otherwise it
  15727. will only retrieve messages it hasn't seen previously.
  15728. Defaults to @samp{#t}.
  15729. @end deftypevr
  15730. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  15731. If set to true, messages will be deleted from the server after
  15732. retrieving and successfully delivering them. Otherwise, messages will
  15733. be left on the server.
  15734. Defaults to @samp{#f}.
  15735. @end deftypevr
  15736. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  15737. Getmail will delete messages this number of days after seeing them, if
  15738. they have been delivered. This means messages will be left on the
  15739. server this number of days after delivering them. A value of @samp{0}
  15740. disabled this feature.
  15741. Defaults to @samp{0}.
  15742. @end deftypevr
  15743. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  15744. Delete messages larger than this of bytes after retrieving them, even if
  15745. the delete and delete-after options are disabled. A value of @samp{0}
  15746. disables this feature.
  15747. Defaults to @samp{0}.
  15748. @end deftypevr
  15749. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  15750. Retrieve messages totalling up to this number of bytes before closing
  15751. the session with the server. A value of @samp{0} disables this feature.
  15752. Defaults to @samp{0}.
  15753. @end deftypevr
  15754. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  15755. Don't retrieve messages larger than this number of bytes. A value of
  15756. @samp{0} disables this feature.
  15757. Defaults to @samp{0}.
  15758. @end deftypevr
  15759. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  15760. If true, getmail will add a Delivered-To header to messages.
  15761. Defaults to @samp{#t}.
  15762. @end deftypevr
  15763. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  15764. If set, getmail adds a Received header to the messages.
  15765. Defaults to @samp{#t}.
  15766. @end deftypevr
  15767. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  15768. Getmail will record a log of its actions to the named file. A value of
  15769. @samp{""} disables this feature.
  15770. Defaults to @samp{""}.
  15771. @end deftypevr
  15772. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  15773. If true, getmail will record a log of its actions using the system
  15774. logger.
  15775. Defaults to @samp{#f}.
  15776. @end deftypevr
  15777. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  15778. If true, getmail will log information about messages not retrieved and
  15779. the reason for not retrieving them, as well as starting and ending
  15780. information lines.
  15781. Defaults to @samp{#f}.
  15782. @end deftypevr
  15783. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  15784. Extra options to include.
  15785. Defaults to @samp{()}.
  15786. @end deftypevr
  15787. @end deftypevr
  15788. @end deftypevr
  15789. @deftypevr {@code{getmail-configuration} parameter} list idle
  15790. A list of mailboxes that getmail should wait on the server for new mail
  15791. notifications. This depends on the server supporting the IDLE
  15792. extension.
  15793. Defaults to @samp{()}.
  15794. @end deftypevr
  15795. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  15796. Environment variables to set for getmail.
  15797. Defaults to @samp{()}.
  15798. @end deftypevr
  15799. @subsubheading Mail Aliases Service
  15800. @cindex email aliases
  15801. @cindex aliases, for email addresses
  15802. @deffn {Scheme Variable} mail-aliases-service-type
  15803. This is the type of the service which provides @code{/etc/aliases},
  15804. specifying how to deliver mail to users on this system.
  15805. @lisp
  15806. (service mail-aliases-service-type
  15807. '(("postmaster" "bob")
  15808. ("bob" "bob@@example.com" "bob@@example2.com")))
  15809. @end lisp
  15810. @end deffn
  15811. The configuration for a @code{mail-aliases-service-type} service is an
  15812. association list denoting how to deliver mail that comes to this
  15813. system. Each entry is of the form @code{(alias addresses ...)}, with
  15814. @code{alias} specifying the local alias and @code{addresses} specifying
  15815. where to deliver this user's mail.
  15816. The aliases aren't required to exist as users on the local system. In
  15817. the above example, there doesn't need to be a @code{postmaster} entry in
  15818. the @code{operating-system}'s @code{user-accounts} in order to deliver
  15819. the @code{postmaster} mail to @code{bob} (which subsequently would
  15820. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  15821. @subsubheading GNU Mailutils IMAP4 Daemon
  15822. @cindex GNU Mailutils IMAP4 Daemon
  15823. @deffn {Scheme Variable} imap4d-service-type
  15824. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  15825. mailutils, GNU Mailutils Manual}), whose value should be an
  15826. @code{imap4d-configuration} object as in this example:
  15827. @lisp
  15828. (service imap4d-service-type
  15829. (imap4d-configuration
  15830. (config-file (local-file "imap4d.conf"))))
  15831. @end lisp
  15832. @end deffn
  15833. @deftp {Data Type} imap4d-configuration
  15834. Data type representing the configuration of @command{imap4d}.
  15835. @table @asis
  15836. @item @code{package} (default: @code{mailutils})
  15837. The package that provides @command{imap4d}.
  15838. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  15839. File-like object of the configuration file to use, by default it will listen
  15840. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  15841. Mailutils Manual}, for details.
  15842. @end table
  15843. @end deftp
  15844. @node Messaging Services
  15845. @subsection Messaging Services
  15846. @cindex messaging
  15847. @cindex jabber
  15848. @cindex XMPP
  15849. The @code{(gnu services messaging)} module provides Guix service
  15850. definitions for messaging services. Currently it provides the following
  15851. services:
  15852. @subsubheading Prosody Service
  15853. @deffn {Scheme Variable} prosody-service-type
  15854. This is the type for the @uref{https://prosody.im, Prosody XMPP
  15855. communication server}. Its value must be a @code{prosody-configuration}
  15856. record as in this example:
  15857. @lisp
  15858. (service prosody-service-type
  15859. (prosody-configuration
  15860. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  15861. (int-components
  15862. (list
  15863. (int-component-configuration
  15864. (hostname "conference.example.net")
  15865. (plugin "muc")
  15866. (mod-muc (mod-muc-configuration)))))
  15867. (virtualhosts
  15868. (list
  15869. (virtualhost-configuration
  15870. (domain "example.net"))))))
  15871. @end lisp
  15872. See below for details about @code{prosody-configuration}.
  15873. @end deffn
  15874. By default, Prosody does not need much configuration. Only one
  15875. @code{virtualhosts} field is needed: it specifies the domain you wish
  15876. Prosody to serve.
  15877. You can perform various sanity checks on the generated configuration
  15878. with the @code{prosodyctl check} command.
  15879. Prosodyctl will also help you to import certificates from the
  15880. @code{letsencrypt} directory so that the @code{prosody} user can access
  15881. them. See @url{https://prosody.im/doc/letsencrypt}.
  15882. @example
  15883. prosodyctl --root cert import /etc/letsencrypt/live
  15884. @end example
  15885. The available configuration parameters follow. Each parameter
  15886. definition is preceded by its type; for example, @samp{string-list foo}
  15887. indicates that the @code{foo} parameter should be specified as a list of
  15888. strings. Types starting with @code{maybe-} denote parameters that won't
  15889. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  15890. There is also a way to specify the configuration as a string, if you
  15891. have an old @code{prosody.cfg.lua} file that you want to port over from
  15892. some other system; see the end for more details.
  15893. The @code{file-object} type designates either a file-like object
  15894. (@pxref{G-Expressions, file-like objects}) or a file name.
  15895. @c The following documentation was initially generated by
  15896. @c (generate-documentation) in (gnu services messaging). Manually maintained
  15897. @c documentation is better, so we shouldn't hesitate to edit below as
  15898. @c needed. However if the change you want to make to this documentation
  15899. @c can be done in an automated way, it's probably easier to change
  15900. @c (generate-documentation) than to make it below and have to deal with
  15901. @c the churn as Prosody updates.
  15902. Available @code{prosody-configuration} fields are:
  15903. @deftypevr {@code{prosody-configuration} parameter} package prosody
  15904. The Prosody package.
  15905. @end deftypevr
  15906. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  15907. Location of the Prosody data storage directory. See
  15908. @url{https://prosody.im/doc/configure}.
  15909. Defaults to @samp{"/var/lib/prosody"}.
  15910. @end deftypevr
  15911. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  15912. Additional plugin directories. They are searched in all the specified
  15913. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  15914. Defaults to @samp{()}.
  15915. @end deftypevr
  15916. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  15917. Every virtual host and component needs a certificate so that clients and
  15918. servers can securely verify its identity. Prosody will automatically load
  15919. certificates/keys from the directory specified here.
  15920. Defaults to @samp{"/etc/prosody/certs"}.
  15921. @end deftypevr
  15922. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  15923. This is a list of accounts that are admins for the server. Note that you
  15924. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  15925. @url{https://prosody.im/doc/creating_accounts}.
  15926. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  15927. Defaults to @samp{()}.
  15928. @end deftypevr
  15929. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  15930. Enable use of libevent for better performance under high load. See
  15931. @url{https://prosody.im/doc/libevent}.
  15932. Defaults to @samp{#f}.
  15933. @end deftypevr
  15934. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  15935. This is the list of modules Prosody will load on startup. It looks for
  15936. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  15937. Documentation on modules can be found at:
  15938. @url{https://prosody.im/doc/modules}.
  15939. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  15940. @end deftypevr
  15941. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  15942. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  15943. should you want to disable them then add them to this list.
  15944. Defaults to @samp{()}.
  15945. @end deftypevr
  15946. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  15947. Path to a text file where the shared groups are defined. If this path is
  15948. empty then @samp{mod_groups} does nothing. See
  15949. @url{https://prosody.im/doc/modules/mod_groups}.
  15950. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  15951. @end deftypevr
  15952. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  15953. Disable account creation by default, for security. See
  15954. @url{https://prosody.im/doc/creating_accounts}.
  15955. Defaults to @samp{#f}.
  15956. @end deftypevr
  15957. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  15958. These are the SSL/TLS-related settings. Most of them are disabled so to
  15959. use Prosody's defaults. If you do not completely understand these options, do
  15960. not add them to your config, it is easy to lower the security of your server
  15961. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  15962. Available @code{ssl-configuration} fields are:
  15963. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  15964. This determines what handshake to use.
  15965. @end deftypevr
  15966. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  15967. Path to your private key file.
  15968. @end deftypevr
  15969. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  15970. Path to your certificate file.
  15971. @end deftypevr
  15972. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  15973. Path to directory containing root certificates that you wish Prosody to
  15974. trust when verifying the certificates of remote servers.
  15975. Defaults to @samp{"/etc/ssl/certs"}.
  15976. @end deftypevr
  15977. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  15978. Path to a file containing root certificates that you wish Prosody to trust.
  15979. Similar to @code{capath} but with all certificates concatenated together.
  15980. @end deftypevr
  15981. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  15982. A list of verification options (these mostly map to OpenSSL's
  15983. @code{set_verify()} flags).
  15984. @end deftypevr
  15985. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  15986. A list of general options relating to SSL/TLS. These map to OpenSSL's
  15987. @code{set_options()}. For a full list of options available in LuaSec, see the
  15988. LuaSec source.
  15989. @end deftypevr
  15990. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  15991. How long a chain of certificate authorities to check when looking for a
  15992. trusted root certificate.
  15993. @end deftypevr
  15994. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  15995. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  15996. clients, and in what order.
  15997. @end deftypevr
  15998. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  15999. A path to a file containing parameters for Diffie-Hellman key exchange. You
  16000. can create such a file with:
  16001. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  16002. @end deftypevr
  16003. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  16004. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  16005. @samp{"secp384r1"}.
  16006. @end deftypevr
  16007. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  16008. A list of ``extra'' verification options.
  16009. @end deftypevr
  16010. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  16011. Password for encrypted private keys.
  16012. @end deftypevr
  16013. @end deftypevr
  16014. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  16015. Whether to force all client-to-server connections to be encrypted or not.
  16016. See @url{https://prosody.im/doc/modules/mod_tls}.
  16017. Defaults to @samp{#f}.
  16018. @end deftypevr
  16019. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  16020. Set of mechanisms that will never be offered. See
  16021. @url{https://prosody.im/doc/modules/mod_saslauth}.
  16022. Defaults to @samp{("DIGEST-MD5")}.
  16023. @end deftypevr
  16024. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  16025. Whether to force all server-to-server connections to be encrypted or not.
  16026. See @url{https://prosody.im/doc/modules/mod_tls}.
  16027. Defaults to @samp{#f}.
  16028. @end deftypevr
  16029. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  16030. Whether to require encryption and certificate authentication. This
  16031. provides ideal security, but requires servers you communicate with to support
  16032. encryption AND present valid, trusted certificates. See
  16033. @url{https://prosody.im/doc/s2s#security}.
  16034. Defaults to @samp{#f}.
  16035. @end deftypevr
  16036. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  16037. Many servers don't support encryption or have invalid or self-signed
  16038. certificates. You can list domains here that will not be required to
  16039. authenticate using certificates. They will be authenticated using DNS. See
  16040. @url{https://prosody.im/doc/s2s#security}.
  16041. Defaults to @samp{()}.
  16042. @end deftypevr
  16043. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  16044. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  16045. valid certificates for some domains by specifying a list here. See
  16046. @url{https://prosody.im/doc/s2s#security}.
  16047. Defaults to @samp{()}.
  16048. @end deftypevr
  16049. @deftypevr {@code{prosody-configuration} parameter} string authentication
  16050. Select the authentication backend to use. The default provider stores
  16051. passwords in plaintext and uses Prosody's configured data storage to store the
  16052. authentication data. If you do not trust your server please see
  16053. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  16054. about using the hashed backend. See also
  16055. @url{https://prosody.im/doc/authentication}
  16056. Defaults to @samp{"internal_plain"}.
  16057. @end deftypevr
  16058. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  16059. Set logging options. Advanced logging configuration is not yet supported
  16060. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  16061. Defaults to @samp{"*syslog"}.
  16062. @end deftypevr
  16063. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  16064. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  16065. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  16066. @end deftypevr
  16067. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  16068. Maximum allowed size of the HTTP body (in bytes).
  16069. @end deftypevr
  16070. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  16071. Some modules expose their own URL in various ways. This URL is built
  16072. from the protocol, host and port used. If Prosody sits behind a proxy, the
  16073. public URL will be @code{http-external-url} instead. See
  16074. @url{https://prosody.im/doc/http#external_url}.
  16075. @end deftypevr
  16076. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  16077. A host in Prosody is a domain on which user accounts can be created. For
  16078. example if you want your users to have addresses like
  16079. @samp{"john.smith@@example.com"} then you need to add a host
  16080. @samp{"example.com"}. All options in this list will apply only to this host.
  16081. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  16082. the actual physical host that Prosody is installed on. A single Prosody
  16083. instance can serve many domains, each one defined as a VirtualHost entry in
  16084. Prosody's configuration. Conversely a server that hosts a single domain would
  16085. have just one VirtualHost entry.
  16086. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  16087. Available @code{virtualhost-configuration} fields are:
  16088. 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:
  16089. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  16090. Domain you wish Prosody to serve.
  16091. @end deftypevr
  16092. @end deftypevr
  16093. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  16094. Components are extra services on a server which are available to clients,
  16095. usually on a subdomain of the main server (such as
  16096. @samp{"mycomponent.example.com"}). Example components might be chatroom
  16097. servers, user directories, or gateways to other protocols.
  16098. Internal components are implemented with Prosody-specific plugins. To add an
  16099. internal component, you simply fill the hostname field, and the plugin you wish
  16100. to use for the component.
  16101. See @url{https://prosody.im/doc/components}.
  16102. Defaults to @samp{()}.
  16103. Available @code{int-component-configuration} fields are:
  16104. 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:
  16105. @deftypevr {@code{int-component-configuration} parameter} string hostname
  16106. Hostname of the component.
  16107. @end deftypevr
  16108. @deftypevr {@code{int-component-configuration} parameter} string plugin
  16109. Plugin you wish to use for the component.
  16110. @end deftypevr
  16111. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  16112. Multi-user chat (MUC) is Prosody's module for allowing you to create
  16113. hosted chatrooms/conferences for XMPP users.
  16114. General information on setting up and using multi-user chatrooms can be found
  16115. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  16116. which you should read if you are new to XMPP chatrooms.
  16117. See also @url{https://prosody.im/doc/modules/mod_muc}.
  16118. Available @code{mod-muc-configuration} fields are:
  16119. @deftypevr {@code{mod-muc-configuration} parameter} string name
  16120. The name to return in service discovery responses.
  16121. Defaults to @samp{"Prosody Chatrooms"}.
  16122. @end deftypevr
  16123. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  16124. If @samp{#t}, this will only allow admins to create new chatrooms.
  16125. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  16126. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  16127. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  16128. restricts to service administrators only.
  16129. Defaults to @samp{#f}.
  16130. @end deftypevr
  16131. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  16132. Maximum number of history messages that will be sent to the member that has
  16133. just joined the room.
  16134. Defaults to @samp{20}.
  16135. @end deftypevr
  16136. @end deftypevr
  16137. @end deftypevr
  16138. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  16139. External components use XEP-0114, which most standalone components
  16140. support. To add an external component, you simply fill the hostname field. See
  16141. @url{https://prosody.im/doc/components}.
  16142. Defaults to @samp{()}.
  16143. Available @code{ext-component-configuration} fields are:
  16144. 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:
  16145. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  16146. Password which the component will use to log in.
  16147. @end deftypevr
  16148. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  16149. Hostname of the component.
  16150. @end deftypevr
  16151. @end deftypevr
  16152. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  16153. Port(s) Prosody listens on for component connections.
  16154. Defaults to @samp{(5347)}.
  16155. @end deftypevr
  16156. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  16157. Interface Prosody listens on for component connections.
  16158. Defaults to @samp{"127.0.0.1"}.
  16159. @end deftypevr
  16160. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  16161. Raw content that will be added to the configuration file.
  16162. @end deftypevr
  16163. It could be that you just want to get a @code{prosody.cfg.lua}
  16164. up and running. In that case, you can pass an
  16165. @code{opaque-prosody-configuration} record as the value of
  16166. @code{prosody-service-type}. As its name indicates, an opaque configuration
  16167. does not have easy reflective capabilities.
  16168. Available @code{opaque-prosody-configuration} fields are:
  16169. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  16170. The prosody package.
  16171. @end deftypevr
  16172. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  16173. The contents of the @code{prosody.cfg.lua} to use.
  16174. @end deftypevr
  16175. For example, if your @code{prosody.cfg.lua} is just the empty
  16176. string, you could instantiate a prosody service like this:
  16177. @lisp
  16178. (service prosody-service-type
  16179. (opaque-prosody-configuration
  16180. (prosody.cfg.lua "")))
  16181. @end lisp
  16182. @c end of Prosody auto-generated documentation
  16183. @subsubheading BitlBee Service
  16184. @cindex IRC (Internet Relay Chat)
  16185. @cindex IRC gateway
  16186. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  16187. interface to a variety of messaging protocols such as XMPP.
  16188. @defvr {Scheme Variable} bitlbee-service-type
  16189. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  16190. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  16191. below).
  16192. To have BitlBee listen on port 6667 on localhost, add this line to your
  16193. services:
  16194. @lisp
  16195. (service bitlbee-service-type)
  16196. @end lisp
  16197. @end defvr
  16198. @deftp {Data Type} bitlbee-configuration
  16199. This is the configuration for BitlBee, with the following fields:
  16200. @table @asis
  16201. @item @code{interface} (default: @code{"127.0.0.1"})
  16202. @itemx @code{port} (default: @code{6667})
  16203. Listen on the network interface corresponding to the IP address
  16204. specified in @var{interface}, on @var{port}.
  16205. When @var{interface} is @code{127.0.0.1}, only local clients can
  16206. connect; when it is @code{0.0.0.0}, connections can come from any
  16207. networking interface.
  16208. @item @code{bitlbee} (default: @code{bitlbee})
  16209. The BitlBee package to use.
  16210. @item @code{plugins} (default: @code{'()})
  16211. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  16212. @item @code{extra-settings} (default: @code{""})
  16213. Configuration snippet added as-is to the BitlBee configuration file.
  16214. @end table
  16215. @end deftp
  16216. @subsubheading Quassel Service
  16217. @cindex IRC (Internet Relay Chat)
  16218. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  16219. meaning that one or more clients can attach to and detach from the
  16220. central core.
  16221. @defvr {Scheme Variable} quassel-service-type
  16222. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  16223. IRC backend daemon. Its value is a @code{quassel-configuration}
  16224. (see below).
  16225. @end defvr
  16226. @deftp {Data Type} quassel-configuration
  16227. This is the configuration for Quassel, with the following fields:
  16228. @table @asis
  16229. @item @code{quassel} (default: @code{quassel})
  16230. The Quassel package to use.
  16231. @item @code{interface} (default: @code{"::,0.0.0.0"})
  16232. @item @code{port} (default: @code{4242})
  16233. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  16234. interfaces specified in the comma delimited @var{interface}, on
  16235. @var{port}.
  16236. @item @code{loglevel} (default: @code{"Info"})
  16237. The level of logging desired. Accepted values are Debug, Info, Warning
  16238. and Error.
  16239. @end table
  16240. @end deftp
  16241. @node Telephony Services
  16242. @subsection Telephony Services
  16243. @cindex Murmur (VoIP server)
  16244. @cindex VoIP server
  16245. This section describes how to set up and run a Murmur server. Murmur is
  16246. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  16247. (VoIP) suite.
  16248. @deftp {Data Type} murmur-configuration
  16249. The service type for the Murmur server. An example configuration can
  16250. look like this:
  16251. @lisp
  16252. (service murmur-service-type
  16253. (murmur-configuration
  16254. (welcome-text
  16255. "Welcome to this Mumble server running on Guix!")
  16256. (cert-required? #t) ;disallow text password logins
  16257. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  16258. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  16259. @end lisp
  16260. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  16261. password with the command that is printed during the activation phase.
  16262. It is recommended to register a normal Mumble user account
  16263. and grant it admin or moderator rights.
  16264. You can use the @code{mumble} client to
  16265. login as new normal user, register yourself, and log out.
  16266. For the next step login with the name @code{SuperUser} use
  16267. the @code{SuperUser} password that you set previously,
  16268. and grant your newly registered mumble user administrator or moderator
  16269. rights and create some channels.
  16270. Available @code{murmur-configuration} fields are:
  16271. @table @asis
  16272. @item @code{package} (default: @code{mumble})
  16273. Package that contains @code{bin/murmurd}.
  16274. @item @code{user} (default: @code{"murmur"})
  16275. User who will run the Murmur server.
  16276. @item @code{group} (default: @code{"murmur"})
  16277. Group of the user who will run the murmur server.
  16278. @item @code{port} (default: @code{64738})
  16279. Port on which the server will listen.
  16280. @item @code{welcome-text} (default: @code{""})
  16281. Welcome text sent to clients when they connect.
  16282. @item @code{server-password} (default: @code{""})
  16283. Password the clients have to enter in order to connect.
  16284. @item @code{max-users} (default: @code{100})
  16285. Maximum of users that can be connected to the server at once.
  16286. @item @code{max-user-bandwidth} (default: @code{#f})
  16287. Maximum voice traffic a user can send per second.
  16288. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  16289. File name of the sqlite database.
  16290. The service's user will become the owner of the directory.
  16291. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  16292. File name of the log file.
  16293. The service's user will become the owner of the directory.
  16294. @item @code{autoban-attempts} (default: @code{10})
  16295. Maximum number of logins a user can make in @code{autoban-timeframe}
  16296. without getting auto banned for @code{autoban-time}.
  16297. @item @code{autoban-timeframe} (default: @code{120})
  16298. Timeframe for autoban in seconds.
  16299. @item @code{autoban-time} (default: @code{300})
  16300. Amount of time in seconds for which a client gets banned
  16301. when violating the autoban limits.
  16302. @item @code{opus-threshold} (default: @code{100})
  16303. Percentage of clients that need to support opus
  16304. before switching over to opus audio codec.
  16305. @item @code{channel-nesting-limit} (default: @code{10})
  16306. How deep channels can be nested at maximum.
  16307. @item @code{channelname-regex} (default: @code{#f})
  16308. A string in form of a Qt regular expression that channel names must conform to.
  16309. @item @code{username-regex} (default: @code{#f})
  16310. A string in form of a Qt regular expression that user names must conform to.
  16311. @item @code{text-message-length} (default: @code{5000})
  16312. Maximum size in bytes that a user can send in one text chat message.
  16313. @item @code{image-message-length} (default: @code{(* 128 1024)})
  16314. Maximum size in bytes that a user can send in one image message.
  16315. @item @code{cert-required?} (default: @code{#f})
  16316. If it is set to @code{#t} clients that use weak password authentication
  16317. will not be accepted. Users must have completed the certificate wizard to join.
  16318. @item @code{remember-channel?} (default: @code{#f})
  16319. Should murmur remember the last channel each user was in when they disconnected
  16320. and put them into the remembered channel when they rejoin.
  16321. @item @code{allow-html?} (default: @code{#f})
  16322. Should html be allowed in text messages, user comments, and channel descriptions.
  16323. @item @code{allow-ping?} (default: @code{#f})
  16324. Setting to true exposes the current user count, the maximum user count, and
  16325. the server's maximum bandwidth per client to unauthenticated users. In the
  16326. Mumble client, this information is shown in the Connect dialog.
  16327. Disabling this setting will prevent public listing of the server.
  16328. @item @code{bonjour?} (default: @code{#f})
  16329. Should the server advertise itself in the local network through the bonjour protocol.
  16330. @item @code{send-version?} (default: @code{#f})
  16331. Should the murmur server version be exposed in ping requests.
  16332. @item @code{log-days} (default: @code{31})
  16333. Murmur also stores logs in the database, which are accessible via RPC.
  16334. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  16335. or -1 to disable logging to the database.
  16336. @item @code{obfuscate-ips?} (default: @code{#t})
  16337. Should logged ips be obfuscated to protect the privacy of users.
  16338. @item @code{ssl-cert} (default: @code{#f})
  16339. File name of the SSL/TLS certificate used for encrypted connections.
  16340. @lisp
  16341. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  16342. @end lisp
  16343. @item @code{ssl-key} (default: @code{#f})
  16344. Filepath to the ssl private key used for encrypted connections.
  16345. @lisp
  16346. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  16347. @end lisp
  16348. @item @code{ssl-dh-params} (default: @code{#f})
  16349. File name of a PEM-encoded file with Diffie-Hellman parameters
  16350. for the SSL/TLS encryption. Alternatively you set it to
  16351. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  16352. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  16353. @item @code{ssl-ciphers} (default: @code{#f})
  16354. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  16355. in SSL/TLS.
  16356. This option is specified using
  16357. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  16358. OpenSSL cipher list notation}.
  16359. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  16360. before setting it here, to get a feel for which cipher suites you will get.
  16361. After setting this option, it is recommend that you inspect your Murmur log
  16362. to ensure that Murmur is using the cipher suites that you expected it to.
  16363. Note: Changing this option may impact the backwards compatibility of your
  16364. Murmur server, and can remove the ability for older Mumble clients to be able
  16365. to connect to it.
  16366. @item @code{public-registration} (default: @code{#f})
  16367. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  16368. You can optionally register your server in the public server list that the
  16369. @code{mumble} client shows on startup.
  16370. You cannot register your server if you have set a @code{server-password},
  16371. or set @code{allow-ping} to @code{#f}.
  16372. It might take a few hours until it shows up in the public list.
  16373. @item @code{file} (default: @code{#f})
  16374. Optional alternative override for this configuration.
  16375. @end table
  16376. @end deftp
  16377. @deftp {Data Type} murmur-public-registration-configuration
  16378. Configuration for public registration of a murmur service.
  16379. @table @asis
  16380. @item @code{name}
  16381. This is a display name for your server. Not to be confused with the hostname.
  16382. @item @code{password}
  16383. A password to identify your registration.
  16384. Subsequent updates will need the same password. Don't lose your password.
  16385. @item @code{url}
  16386. This should be a @code{http://} or @code{https://} link to your web
  16387. site.
  16388. @item @code{hostname} (default: @code{#f})
  16389. By default your server will be listed by its IP address.
  16390. If it is set your server will be linked by this host name instead.
  16391. @end table
  16392. @end deftp
  16393. @node Monitoring Services
  16394. @subsection Monitoring Services
  16395. @subsubheading Tailon Service
  16396. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  16397. viewing and searching log files.
  16398. The following example will configure the service with default values.
  16399. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  16400. @lisp
  16401. (service tailon-service-type)
  16402. @end lisp
  16403. The following example customises more of the Tailon configuration,
  16404. adding @command{sed} to the list of allowed commands.
  16405. @lisp
  16406. (service tailon-service-type
  16407. (tailon-configuration
  16408. (config-file
  16409. (tailon-configuration-file
  16410. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  16411. @end lisp
  16412. @deftp {Data Type} tailon-configuration
  16413. Data type representing the configuration of Tailon.
  16414. This type has the following parameters:
  16415. @table @asis
  16416. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  16417. The configuration file to use for Tailon. This can be set to a
  16418. @dfn{tailon-configuration-file} record value, or any gexp
  16419. (@pxref{G-Expressions}).
  16420. For example, to instead use a local file, the @code{local-file} function
  16421. can be used:
  16422. @lisp
  16423. (service tailon-service-type
  16424. (tailon-configuration
  16425. (config-file (local-file "./my-tailon.conf"))))
  16426. @end lisp
  16427. @item @code{package} (default: @code{tailon})
  16428. The tailon package to use.
  16429. @end table
  16430. @end deftp
  16431. @deftp {Data Type} tailon-configuration-file
  16432. Data type representing the configuration options for Tailon.
  16433. This type has the following parameters:
  16434. @table @asis
  16435. @item @code{files} (default: @code{(list "/var/log")})
  16436. List of files to display. The list can include strings for a single file
  16437. or directory, or a list, where the first item is the name of a
  16438. subsection, and the remaining items are the files or directories in that
  16439. subsection.
  16440. @item @code{bind} (default: @code{"localhost:8080"})
  16441. Address and port to which Tailon should bind on.
  16442. @item @code{relative-root} (default: @code{#f})
  16443. URL path to use for Tailon, set to @code{#f} to not use a path.
  16444. @item @code{allow-transfers?} (default: @code{#t})
  16445. Allow downloading the log files in the web interface.
  16446. @item @code{follow-names?} (default: @code{#t})
  16447. Allow tailing of not-yet existent files.
  16448. @item @code{tail-lines} (default: @code{200})
  16449. Number of lines to read initially from each file.
  16450. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  16451. Commands to allow running. By default, @code{sed} is disabled.
  16452. @item @code{debug?} (default: @code{#f})
  16453. Set @code{debug?} to @code{#t} to show debug messages.
  16454. @item @code{wrap-lines} (default: @code{#t})
  16455. Initial line wrapping state in the web interface. Set to @code{#t} to
  16456. initially wrap lines (the default), or to @code{#f} to initially not
  16457. wrap lines.
  16458. @item @code{http-auth} (default: @code{#f})
  16459. HTTP authentication type to use. Set to @code{#f} to disable
  16460. authentication (the default). Supported values are @code{"digest"} or
  16461. @code{"basic"}.
  16462. @item @code{users} (default: @code{#f})
  16463. If HTTP authentication is enabled (see @code{http-auth}), access will be
  16464. restricted to the credentials provided here. To configure users, use a
  16465. list of pairs, where the first element of the pair is the username, and
  16466. the 2nd element of the pair is the password.
  16467. @lisp
  16468. (tailon-configuration-file
  16469. (http-auth "basic")
  16470. (users '(("user1" . "password1")
  16471. ("user2" . "password2"))))
  16472. @end lisp
  16473. @end table
  16474. @end deftp
  16475. @subsubheading Darkstat Service
  16476. @cindex darkstat
  16477. Darkstat is a packet sniffer that captures network traffic, calculates
  16478. statistics about usage, and serves reports over HTTP.
  16479. @defvar {Scheme Variable} darkstat-service-type
  16480. This is the service type for the
  16481. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  16482. service, its value must be a @code{darkstat-configuration} record as in
  16483. this example:
  16484. @lisp
  16485. (service darkstat-service-type
  16486. (darkstat-configuration
  16487. (interface "eno1")))
  16488. @end lisp
  16489. @end defvar
  16490. @deftp {Data Type} darkstat-configuration
  16491. Data type representing the configuration of @command{darkstat}.
  16492. @table @asis
  16493. @item @code{package} (default: @code{darkstat})
  16494. The darkstat package to use.
  16495. @item @code{interface}
  16496. Capture traffic on the specified network interface.
  16497. @item @code{port} (default: @code{"667"})
  16498. Bind the web interface to the specified port.
  16499. @item @code{bind-address} (default: @code{"127.0.0.1"})
  16500. Bind the web interface to the specified address.
  16501. @item @code{base} (default: @code{"/"})
  16502. Specify the path of the base URL. This can be useful if
  16503. @command{darkstat} is accessed via a reverse proxy.
  16504. @end table
  16505. @end deftp
  16506. @subsubheading Prometheus Node Exporter Service
  16507. @cindex prometheus-node-exporter
  16508. The Prometheus ``node exporter'' makes hardware and operating system statistics
  16509. provided by the Linux kernel available for the Prometheus monitoring system.
  16510. This service should be deployed on all physical nodes and virtual machines,
  16511. where monitoring these statistics is desirable.
  16512. @defvar {Scheme variable} prometheus-node-exporter-service-type
  16513. This is the service type for the
  16514. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  16515. service, its value must be a @code{prometheus-node-exporter-configuration}
  16516. record as in this example:
  16517. @lisp
  16518. (service prometheus-node-exporter-service-type
  16519. (prometheus-node-exporter-configuration
  16520. (web-listen-address ":9100")))
  16521. @end lisp
  16522. @end defvar
  16523. @deftp {Data Type} prometheus-node-exporter-configuration
  16524. Data type representing the configuration of @command{node_exporter}.
  16525. @table @asis
  16526. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  16527. The prometheus-node-exporter package to use.
  16528. @item @code{web-listen-address} (default: @code{":9100"})
  16529. Bind the web interface to the specified address.
  16530. @end table
  16531. @end deftp
  16532. @subsubheading Zabbix server
  16533. @cindex zabbix zabbix-server
  16534. Zabbix provides monitoring metrics, among others network utilization, CPU load
  16535. and disk space consumption:
  16536. @itemize
  16537. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  16538. @item Auto-discovery of servers and network devices and interfaces.
  16539. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  16540. @item Distributed monitoring with centralized web administration.
  16541. @item Native high performance agents.
  16542. @item SLA, and ITIL KPI metrics on reporting.
  16543. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  16544. @item Remote command execution through Zabbix proxies.
  16545. @end itemize
  16546. @c %start of fragment
  16547. Available @code{zabbix-server-configuration} fields are:
  16548. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  16549. The zabbix-server package.
  16550. @end deftypevr
  16551. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  16552. User who will run the Zabbix server.
  16553. Defaults to @samp{"zabbix"}.
  16554. @end deftypevr
  16555. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  16556. Group who will run the Zabbix server.
  16557. Defaults to @samp{"zabbix"}.
  16558. @end deftypevr
  16559. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  16560. Database host name.
  16561. Defaults to @samp{"127.0.0.1"}.
  16562. @end deftypevr
  16563. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  16564. Database name.
  16565. Defaults to @samp{"zabbix"}.
  16566. @end deftypevr
  16567. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  16568. Database user.
  16569. Defaults to @samp{"zabbix"}.
  16570. @end deftypevr
  16571. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  16572. Database password. Please, use @code{include-files} with
  16573. @code{DBPassword=SECRET} inside a specified file instead.
  16574. Defaults to @samp{""}.
  16575. @end deftypevr
  16576. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  16577. Database port.
  16578. Defaults to @samp{5432}.
  16579. @end deftypevr
  16580. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  16581. Specifies where log messages are written to:
  16582. @itemize @bullet
  16583. @item
  16584. @code{system} - syslog.
  16585. @item
  16586. @code{file} - file specified with @code{log-file} parameter.
  16587. @item
  16588. @code{console} - standard output.
  16589. @end itemize
  16590. Defaults to @samp{""}.
  16591. @end deftypevr
  16592. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  16593. Log file name for @code{log-type} @code{file} parameter.
  16594. Defaults to @samp{"/var/log/zabbix/server.log"}.
  16595. @end deftypevr
  16596. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  16597. Name of PID file.
  16598. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  16599. @end deftypevr
  16600. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  16601. The location of certificate authority (CA) files for SSL server
  16602. certificate verification.
  16603. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  16604. @end deftypevr
  16605. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  16606. Location of SSL client certificates.
  16607. Defaults to @samp{"/etc/ssl/certs"}.
  16608. @end deftypevr
  16609. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  16610. Extra options will be appended to Zabbix server configuration file.
  16611. Defaults to @samp{""}.
  16612. @end deftypevr
  16613. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  16614. You may include individual files or all files in a directory in the
  16615. configuration file.
  16616. Defaults to @samp{()}.
  16617. @end deftypevr
  16618. @c %end of fragment
  16619. @subsubheading Zabbix agent
  16620. @cindex zabbix zabbix-agent
  16621. Zabbix agent gathers information for Zabbix server.
  16622. @c %start of fragment
  16623. Available @code{zabbix-agent-configuration} fields are:
  16624. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  16625. The zabbix-agent package.
  16626. @end deftypevr
  16627. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  16628. User who will run the Zabbix agent.
  16629. Defaults to @samp{"zabbix"}.
  16630. @end deftypevr
  16631. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  16632. Group who will run the Zabbix agent.
  16633. Defaults to @samp{"zabbix"}.
  16634. @end deftypevr
  16635. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  16636. Unique, case sensitive hostname which is required for active checks and
  16637. must match hostname as configured on the server.
  16638. Defaults to @samp{"Zabbix server"}.
  16639. @end deftypevr
  16640. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  16641. Specifies where log messages are written to:
  16642. @itemize @bullet
  16643. @item
  16644. @code{system} - syslog.
  16645. @item
  16646. @code{file} - file specified with @code{log-file} parameter.
  16647. @item
  16648. @code{console} - standard output.
  16649. @end itemize
  16650. Defaults to @samp{""}.
  16651. @end deftypevr
  16652. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  16653. Log file name for @code{log-type} @code{file} parameter.
  16654. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  16655. @end deftypevr
  16656. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  16657. Name of PID file.
  16658. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  16659. @end deftypevr
  16660. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  16661. List of IP addresses, optionally in CIDR notation, or hostnames of
  16662. Zabbix servers and Zabbix proxies. Incoming connections will be
  16663. accepted only from the hosts listed here.
  16664. Defaults to @samp{("127.0.0.1")}.
  16665. @end deftypevr
  16666. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  16667. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  16668. proxies for active checks. If port is not specified, default port is
  16669. used. If this parameter is not specified, active checks are disabled.
  16670. Defaults to @samp{("127.0.0.1")}.
  16671. @end deftypevr
  16672. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  16673. Extra options will be appended to Zabbix server configuration file.
  16674. Defaults to @samp{""}.
  16675. @end deftypevr
  16676. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  16677. You may include individual files or all files in a directory in the
  16678. configuration file.
  16679. Defaults to @samp{()}.
  16680. @end deftypevr
  16681. @c %end of fragment
  16682. @subsubheading Zabbix front-end
  16683. @cindex zabbix zabbix-front-end
  16684. This service provides a WEB interface to Zabbix server.
  16685. @c %start of fragment
  16686. Available @code{zabbix-front-end-configuration} fields are:
  16687. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  16688. NGINX configuration.
  16689. @end deftypevr
  16690. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  16691. Database host name.
  16692. Defaults to @samp{"localhost"}.
  16693. @end deftypevr
  16694. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  16695. Database port.
  16696. Defaults to @samp{5432}.
  16697. @end deftypevr
  16698. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  16699. Database name.
  16700. Defaults to @samp{"zabbix"}.
  16701. @end deftypevr
  16702. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  16703. Database user.
  16704. Defaults to @samp{"zabbix"}.
  16705. @end deftypevr
  16706. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  16707. Database password. Please, use @code{db-secret-file} instead.
  16708. Defaults to @samp{""}.
  16709. @end deftypevr
  16710. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  16711. Secret file which will be appended to @file{zabbix.conf.php} file. This
  16712. file contains credentials for use by Zabbix front-end. You are expected
  16713. to create it manually.
  16714. Defaults to @samp{""}.
  16715. @end deftypevr
  16716. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  16717. Zabbix server hostname.
  16718. Defaults to @samp{"localhost"}.
  16719. @end deftypevr
  16720. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  16721. Zabbix server port.
  16722. Defaults to @samp{10051}.
  16723. @end deftypevr
  16724. @c %end of fragment
  16725. @node Kerberos Services
  16726. @subsection Kerberos Services
  16727. @cindex Kerberos
  16728. The @code{(gnu services kerberos)} module provides services relating to
  16729. the authentication protocol @dfn{Kerberos}.
  16730. @subsubheading Krb5 Service
  16731. Programs using a Kerberos client library normally
  16732. expect a configuration file in @file{/etc/krb5.conf}.
  16733. This service generates such a file from a definition provided in the
  16734. operating system declaration.
  16735. It does not cause any daemon to be started.
  16736. No ``keytab'' files are provided by this service---you must explicitly create them.
  16737. This service is known to work with the MIT client library, @code{mit-krb5}.
  16738. Other implementations have not been tested.
  16739. @defvr {Scheme Variable} krb5-service-type
  16740. A service type for Kerberos 5 clients.
  16741. @end defvr
  16742. @noindent
  16743. Here is an example of its use:
  16744. @lisp
  16745. (service krb5-service-type
  16746. (krb5-configuration
  16747. (default-realm "EXAMPLE.COM")
  16748. (allow-weak-crypto? #t)
  16749. (realms (list
  16750. (krb5-realm
  16751. (name "EXAMPLE.COM")
  16752. (admin-server "groucho.example.com")
  16753. (kdc "karl.example.com"))
  16754. (krb5-realm
  16755. (name "ARGRX.EDU")
  16756. (admin-server "kerb-admin.argrx.edu")
  16757. (kdc "keys.argrx.edu"))))))
  16758. @end lisp
  16759. @noindent
  16760. This example provides a Kerberos@tie{}5 client configuration which:
  16761. @itemize
  16762. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  16763. of which have distinct administration servers and key distribution centers;
  16764. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  16765. specified by clients;
  16766. @item Accepts services which only support encryption types known to be weak.
  16767. @end itemize
  16768. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  16769. Only the most commonly used ones are described here.
  16770. For a full list, and more detailed explanation of each, see the MIT
  16771. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  16772. documentation.
  16773. @deftp {Data Type} krb5-realm
  16774. @cindex realm, kerberos
  16775. @table @asis
  16776. @item @code{name}
  16777. This field is a string identifying the name of the realm.
  16778. A common convention is to use the fully qualified DNS name of your organization,
  16779. converted to upper case.
  16780. @item @code{admin-server}
  16781. This field is a string identifying the host where the administration server is
  16782. running.
  16783. @item @code{kdc}
  16784. This field is a string identifying the key distribution center
  16785. for the realm.
  16786. @end table
  16787. @end deftp
  16788. @deftp {Data Type} krb5-configuration
  16789. @table @asis
  16790. @item @code{allow-weak-crypto?} (default: @code{#f})
  16791. If this flag is @code{#t} then services which only offer encryption algorithms
  16792. known to be weak will be accepted.
  16793. @item @code{default-realm} (default: @code{#f})
  16794. This field should be a string identifying the default Kerberos
  16795. realm for the client.
  16796. You should set this field to the name of your Kerberos realm.
  16797. If this value is @code{#f}
  16798. then a realm must be specified with every Kerberos principal when invoking programs
  16799. such as @command{kinit}.
  16800. @item @code{realms}
  16801. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  16802. access.
  16803. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  16804. field.
  16805. @end table
  16806. @end deftp
  16807. @subsubheading PAM krb5 Service
  16808. @cindex pam-krb5
  16809. The @code{pam-krb5} service allows for login authentication and password
  16810. management via Kerberos.
  16811. You will need this service if you want PAM enabled applications to authenticate
  16812. users using Kerberos.
  16813. @defvr {Scheme Variable} pam-krb5-service-type
  16814. A service type for the Kerberos 5 PAM module.
  16815. @end defvr
  16816. @deftp {Data Type} pam-krb5-configuration
  16817. Data type representing the configuration of the Kerberos 5 PAM module.
  16818. This type has the following parameters:
  16819. @table @asis
  16820. @item @code{pam-krb5} (default: @code{pam-krb5})
  16821. The pam-krb5 package to use.
  16822. @item @code{minimum-uid} (default: @code{1000})
  16823. The smallest user ID for which Kerberos authentications should be attempted.
  16824. Local accounts with lower values will silently fail to authenticate.
  16825. @end table
  16826. @end deftp
  16827. @node LDAP Services
  16828. @subsection LDAP Services
  16829. @cindex LDAP
  16830. @cindex nslcd, LDAP service
  16831. The @code{(gnu services authentication)} module provides the
  16832. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  16833. server. In addition to configuring the service itself, you may want to add
  16834. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  16835. Switch} for detailed information.
  16836. Here is a simple operating system declaration with a default configuration of
  16837. the @code{nslcd-service-type} and a Name Service Switch configuration that
  16838. consults the @code{ldap} name service last:
  16839. @lisp
  16840. (use-service-modules authentication)
  16841. (use-modules (gnu system nss))
  16842. ...
  16843. (operating-system
  16844. ...
  16845. (services
  16846. (cons*
  16847. (service nslcd-service-type)
  16848. (service dhcp-client-service-type)
  16849. %base-services))
  16850. (name-service-switch
  16851. (let ((services (list (name-service (name "db"))
  16852. (name-service (name "files"))
  16853. (name-service (name "ldap")))))
  16854. (name-service-switch
  16855. (inherit %mdns-host-lookup-nss)
  16856. (password services)
  16857. (shadow services)
  16858. (group services)
  16859. (netgroup services)
  16860. (gshadow services)))))
  16861. @end lisp
  16862. @c %start of generated documentation for nslcd-configuration
  16863. Available @code{nslcd-configuration} fields are:
  16864. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  16865. The @code{nss-pam-ldapd} package to use.
  16866. @end deftypevr
  16867. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  16868. The number of threads to start that can handle requests and perform LDAP
  16869. queries. Each thread opens a separate connection to the LDAP server.
  16870. The default is to start 5 threads.
  16871. Defaults to @samp{disabled}.
  16872. @end deftypevr
  16873. @deftypevr {@code{nslcd-configuration} parameter} string uid
  16874. This specifies the user id with which the daemon should be run.
  16875. Defaults to @samp{"nslcd"}.
  16876. @end deftypevr
  16877. @deftypevr {@code{nslcd-configuration} parameter} string gid
  16878. This specifies the group id with which the daemon should be run.
  16879. Defaults to @samp{"nslcd"}.
  16880. @end deftypevr
  16881. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  16882. This option controls the way logging is done via a list containing
  16883. SCHEME and LEVEL. The SCHEME argument may either be the symbols
  16884. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  16885. argument is optional and specifies the log level. The log level may be
  16886. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  16887. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  16888. specified log level or higher are logged.
  16889. Defaults to @samp{("/var/log/nslcd" info)}.
  16890. @end deftypevr
  16891. @deftypevr {@code{nslcd-configuration} parameter} list uri
  16892. The list of LDAP server URIs. Normally, only the first server will be
  16893. used with the following servers as fall-back.
  16894. Defaults to @samp{("ldap://localhost:389/")}.
  16895. @end deftypevr
  16896. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  16897. The version of the LDAP protocol to use. The default is to use the
  16898. maximum version supported by the LDAP library.
  16899. Defaults to @samp{disabled}.
  16900. @end deftypevr
  16901. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  16902. Specifies the distinguished name with which to bind to the directory
  16903. server for lookups. The default is to bind anonymously.
  16904. Defaults to @samp{disabled}.
  16905. @end deftypevr
  16906. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  16907. Specifies the credentials with which to bind. This option is only
  16908. applicable when used with binddn.
  16909. Defaults to @samp{disabled}.
  16910. @end deftypevr
  16911. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  16912. Specifies the distinguished name to use when the root user tries to
  16913. modify a user's password using the PAM module.
  16914. Defaults to @samp{disabled}.
  16915. @end deftypevr
  16916. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  16917. Specifies the credentials with which to bind if the root user tries to
  16918. change a user's password. This option is only applicable when used with
  16919. rootpwmoddn
  16920. Defaults to @samp{disabled}.
  16921. @end deftypevr
  16922. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  16923. Specifies the SASL mechanism to be used when performing SASL
  16924. authentication.
  16925. Defaults to @samp{disabled}.
  16926. @end deftypevr
  16927. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  16928. Specifies the SASL realm to be used when performing SASL authentication.
  16929. Defaults to @samp{disabled}.
  16930. @end deftypevr
  16931. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  16932. Specifies the authentication identity to be used when performing SASL
  16933. authentication.
  16934. Defaults to @samp{disabled}.
  16935. @end deftypevr
  16936. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  16937. Specifies the authorization identity to be used when performing SASL
  16938. authentication.
  16939. Defaults to @samp{disabled}.
  16940. @end deftypevr
  16941. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  16942. Determines whether the LDAP server host name should be canonicalised. If
  16943. this is enabled the LDAP library will do a reverse host name lookup. By
  16944. default, it is left up to the LDAP library whether this check is
  16945. performed or not.
  16946. Defaults to @samp{disabled}.
  16947. @end deftypevr
  16948. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  16949. Set the name for the GSS-API Kerberos credentials cache.
  16950. Defaults to @samp{disabled}.
  16951. @end deftypevr
  16952. @deftypevr {@code{nslcd-configuration} parameter} string base
  16953. The directory search base.
  16954. Defaults to @samp{"dc=example,dc=com"}.
  16955. @end deftypevr
  16956. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  16957. Specifies the search scope (subtree, onelevel, base or children). The
  16958. default scope is subtree; base scope is almost never useful for name
  16959. service lookups; children scope is not supported on all servers.
  16960. Defaults to @samp{(subtree)}.
  16961. @end deftypevr
  16962. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  16963. Specifies the policy for dereferencing aliases. The default policy is
  16964. to never dereference aliases.
  16965. Defaults to @samp{disabled}.
  16966. @end deftypevr
  16967. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  16968. Specifies whether automatic referral chasing should be enabled. The
  16969. default behaviour is to chase referrals.
  16970. Defaults to @samp{disabled}.
  16971. @end deftypevr
  16972. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  16973. This option allows for custom attributes to be looked up instead of the
  16974. default RFC 2307 attributes. It is a list of maps, each consisting of
  16975. the name of a map, the RFC 2307 attribute to match and the query
  16976. expression for the attribute as it is available in the directory.
  16977. Defaults to @samp{()}.
  16978. @end deftypevr
  16979. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  16980. A list of filters consisting of the name of a map to which the filter
  16981. applies and an LDAP search filter expression.
  16982. Defaults to @samp{()}.
  16983. @end deftypevr
  16984. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  16985. Specifies the time limit in seconds to use when connecting to the
  16986. directory server. The default value is 10 seconds.
  16987. Defaults to @samp{disabled}.
  16988. @end deftypevr
  16989. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  16990. Specifies the time limit (in seconds) to wait for a response from the
  16991. LDAP server. A value of zero, which is the default, is to wait
  16992. indefinitely for searches to be completed.
  16993. Defaults to @samp{disabled}.
  16994. @end deftypevr
  16995. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  16996. Specifies the period if inactivity (in seconds) after which the con‐
  16997. nection to the LDAP server will be closed. The default is not to time
  16998. out connections.
  16999. Defaults to @samp{disabled}.
  17000. @end deftypevr
  17001. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  17002. Specifies the number of seconds to sleep when connecting to all LDAP
  17003. servers fails. By default one second is waited between the first
  17004. failure and the first retry.
  17005. Defaults to @samp{disabled}.
  17006. @end deftypevr
  17007. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  17008. Specifies the time after which the LDAP server is considered to be
  17009. permanently unavailable. Once this time is reached retries will be done
  17010. only once per this time period. The default value is 10 seconds.
  17011. Defaults to @samp{disabled}.
  17012. @end deftypevr
  17013. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  17014. Specifies whether to use SSL/TLS or not (the default is not to). If
  17015. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  17016. SSL.
  17017. Defaults to @samp{disabled}.
  17018. @end deftypevr
  17019. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  17020. Specifies what checks to perform on a server-supplied certificate. The
  17021. meaning of the values is described in the ldap.conf(5) manual page.
  17022. Defaults to @samp{disabled}.
  17023. @end deftypevr
  17024. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  17025. Specifies the directory containing X.509 certificates for peer authen‐
  17026. tication. This parameter is ignored when using GnuTLS.
  17027. Defaults to @samp{disabled}.
  17028. @end deftypevr
  17029. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  17030. Specifies the path to the X.509 certificate for peer authentication.
  17031. Defaults to @samp{disabled}.
  17032. @end deftypevr
  17033. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  17034. Specifies the path to an entropy source. This parameter is ignored when
  17035. using GnuTLS.
  17036. Defaults to @samp{disabled}.
  17037. @end deftypevr
  17038. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  17039. Specifies the ciphers to use for TLS as a string.
  17040. Defaults to @samp{disabled}.
  17041. @end deftypevr
  17042. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  17043. Specifies the path to the file containing the local certificate for
  17044. client TLS authentication.
  17045. Defaults to @samp{disabled}.
  17046. @end deftypevr
  17047. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  17048. Specifies the path to the file containing the private key for client TLS
  17049. authentication.
  17050. Defaults to @samp{disabled}.
  17051. @end deftypevr
  17052. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  17053. Set this to a number greater than 0 to request paged results from the
  17054. LDAP server in accordance with RFC2696. The default (0) is to not
  17055. request paged results.
  17056. Defaults to @samp{disabled}.
  17057. @end deftypevr
  17058. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  17059. This option prevents group membership lookups through LDAP for the
  17060. specified users. Alternatively, the value 'all-local may be used. With
  17061. that value nslcd builds a full list of non-LDAP users on startup.
  17062. Defaults to @samp{disabled}.
  17063. @end deftypevr
  17064. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  17065. This option ensures that LDAP users with a numeric user id lower than
  17066. the specified value are ignored.
  17067. Defaults to @samp{disabled}.
  17068. @end deftypevr
  17069. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  17070. This option specifies an offset that is added to all LDAP numeric user
  17071. ids. This can be used to avoid user id collisions with local users.
  17072. Defaults to @samp{disabled}.
  17073. @end deftypevr
  17074. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  17075. This option specifies an offset that is added to all LDAP numeric group
  17076. ids. This can be used to avoid user id collisions with local groups.
  17077. Defaults to @samp{disabled}.
  17078. @end deftypevr
  17079. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  17080. If this option is set, the member attribute of a group may point to
  17081. another group. Members of nested groups are also returned in the higher
  17082. level group and parent groups are returned when finding groups for a
  17083. specific user. The default is not to perform extra searches for nested
  17084. groups.
  17085. Defaults to @samp{disabled}.
  17086. @end deftypevr
  17087. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  17088. If this option is set, the group member list is not retrieved when
  17089. looking up groups. Lookups for finding which groups a user belongs to
  17090. will remain functional so the user will likely still get the correct
  17091. groups assigned on login.
  17092. Defaults to @samp{disabled}.
  17093. @end deftypevr
  17094. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  17095. If this option is set, functions which cause all user/group entries to
  17096. be loaded from the directory will not succeed in doing so. This can
  17097. dramatically reduce LDAP server load in situations where there are a
  17098. great number of users and/or groups. This option is not recommended for
  17099. most configurations.
  17100. Defaults to @samp{disabled}.
  17101. @end deftypevr
  17102. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  17103. This option can be used to specify how user and group names are verified
  17104. within the system. This pattern is used to check all user and group
  17105. names that are requested and returned from LDAP.
  17106. Defaults to @samp{disabled}.
  17107. @end deftypevr
  17108. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  17109. This specifies whether or not to perform searches using case-insensitive
  17110. matching. Enabling this could open up the system to authorization
  17111. bypass vulnerabilities and introduce nscd cache poisoning
  17112. vulnerabilities which allow denial of service.
  17113. Defaults to @samp{disabled}.
  17114. @end deftypevr
  17115. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  17116. This option specifies whether password policy controls are requested and
  17117. handled from the LDAP server when performing user authentication.
  17118. Defaults to @samp{disabled}.
  17119. @end deftypevr
  17120. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  17121. By default nslcd performs an LDAP search with the user's credentials
  17122. after BIND (authentication) to ensure that the BIND operation was
  17123. successful. The default search is a simple check to see if the user's
  17124. DN exists. A search filter can be specified that will be used instead.
  17125. It should return at least one entry.
  17126. Defaults to @samp{disabled}.
  17127. @end deftypevr
  17128. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  17129. This option allows flexible fine tuning of the authorisation check that
  17130. should be performed. The search filter specified is executed and if any
  17131. entries match, access is granted, otherwise access is denied.
  17132. Defaults to @samp{disabled}.
  17133. @end deftypevr
  17134. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  17135. If this option is set password modification using pam_ldap will be
  17136. denied and the specified message will be presented to the user instead.
  17137. The message can be used to direct the user to an alternative means of
  17138. changing their password.
  17139. Defaults to @samp{disabled}.
  17140. @end deftypevr
  17141. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  17142. List of pam service names for which LDAP authentication should suffice.
  17143. Defaults to @samp{()}.
  17144. @end deftypevr
  17145. @c %end of generated documentation for nslcd-configuration
  17146. @node Web Services
  17147. @subsection Web Services
  17148. @cindex web
  17149. @cindex www
  17150. @cindex HTTP
  17151. The @code{(gnu services web)} module provides the Apache HTTP Server,
  17152. the nginx web server, and also a fastcgi wrapper daemon.
  17153. @subsubheading Apache HTTP Server
  17154. @deffn {Scheme Variable} httpd-service-type
  17155. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  17156. (@dfn{httpd}). The value for this service type is a
  17157. @code{httpd-configuration} record.
  17158. A simple example configuration is given below.
  17159. @lisp
  17160. (service httpd-service-type
  17161. (httpd-configuration
  17162. (config
  17163. (httpd-config-file
  17164. (server-name "www.example.com")
  17165. (document-root "/srv/http/www.example.com")))))
  17166. @end lisp
  17167. Other services can also extend the @code{httpd-service-type} to add to
  17168. the configuration.
  17169. @lisp
  17170. (simple-service 'www.example.com-server httpd-service-type
  17171. (list
  17172. (httpd-virtualhost
  17173. "*:80"
  17174. (list (string-join '("ServerName www.example.com"
  17175. "DocumentRoot /srv/http/www.example.com")
  17176. "\n")))))
  17177. @end lisp
  17178. @end deffn
  17179. The details for the @code{httpd-configuration}, @code{httpd-module},
  17180. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  17181. given below.
  17182. @deffn {Data Type} httpd-configuration
  17183. This data type represents the configuration for the httpd service.
  17184. @table @asis
  17185. @item @code{package} (default: @code{httpd})
  17186. The httpd package to use.
  17187. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  17188. The pid file used by the shepherd-service.
  17189. @item @code{config} (default: @code{(httpd-config-file)})
  17190. The configuration file to use with the httpd service. The default value
  17191. is a @code{httpd-config-file} record, but this can also be a different
  17192. G-expression that generates a file, for example a @code{plain-file}. A
  17193. file outside of the store can also be specified through a string.
  17194. @end table
  17195. @end deffn
  17196. @deffn {Data Type} httpd-module
  17197. This data type represents a module for the httpd service.
  17198. @table @asis
  17199. @item @code{name}
  17200. The name of the module.
  17201. @item @code{file}
  17202. The file for the module. This can be relative to the httpd package being
  17203. used, the absolute location of a file, or a G-expression for a file
  17204. within the store, for example @code{(file-append mod-wsgi
  17205. "/modules/mod_wsgi.so")}.
  17206. @end table
  17207. @end deffn
  17208. @defvr {Scheme Variable} %default-httpd-modules
  17209. A default list of @code{httpd-module} objects.
  17210. @end defvr
  17211. @deffn {Data Type} httpd-config-file
  17212. This data type represents a configuration file for the httpd service.
  17213. @table @asis
  17214. @item @code{modules} (default: @code{%default-httpd-modules})
  17215. The modules to load. Additional modules can be added here, or loaded by
  17216. additional configuration.
  17217. For example, in order to handle requests for PHP files, you can use Apache’s
  17218. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  17219. @lisp
  17220. (service httpd-service-type
  17221. (httpd-configuration
  17222. (config
  17223. (httpd-config-file
  17224. (modules (cons*
  17225. (httpd-module
  17226. (name "proxy_module")
  17227. (file "modules/mod_proxy.so"))
  17228. (httpd-module
  17229. (name "proxy_fcgi_module")
  17230. (file "modules/mod_proxy_fcgi.so"))
  17231. %default-httpd-modules))
  17232. (extra-config (list "\
  17233. <FilesMatch \\.php$>
  17234. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  17235. </FilesMatch>"))))))
  17236. (service php-fpm-service-type
  17237. (php-fpm-configuration
  17238. (socket "/var/run/php-fpm.sock")
  17239. (socket-group "httpd")))
  17240. @end lisp
  17241. @item @code{server-root} (default: @code{httpd})
  17242. The @code{ServerRoot} in the configuration file, defaults to the httpd
  17243. package. Directives including @code{Include} and @code{LoadModule} are
  17244. taken as relative to the server root.
  17245. @item @code{server-name} (default: @code{#f})
  17246. The @code{ServerName} in the configuration file, used to specify the
  17247. request scheme, hostname and port that the server uses to identify
  17248. itself.
  17249. This doesn't need to be set in the server config, and can be specified
  17250. in virtual hosts. The default is @code{#f} to not specify a
  17251. @code{ServerName}.
  17252. @item @code{document-root} (default: @code{"/srv/http"})
  17253. The @code{DocumentRoot} from which files will be served.
  17254. @item @code{listen} (default: @code{'("80")})
  17255. The list of values for the @code{Listen} directives in the config
  17256. file. The value should be a list of strings, when each string can
  17257. specify the port number to listen on, and optionally the IP address and
  17258. protocol to use.
  17259. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  17260. The @code{PidFile} to use. This should match the @code{pid-file} set in
  17261. the @code{httpd-configuration} so that the Shepherd service is
  17262. configured correctly.
  17263. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  17264. The @code{ErrorLog} to which the server will log errors.
  17265. @item @code{user} (default: @code{"httpd"})
  17266. The @code{User} which the server will answer requests as.
  17267. @item @code{group} (default: @code{"httpd"})
  17268. The @code{Group} which the server will answer requests as.
  17269. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  17270. A flat list of strings and G-expressions which will be added to the end
  17271. of the configuration file.
  17272. Any values which the service is extended with will be appended to this
  17273. list.
  17274. @end table
  17275. @end deffn
  17276. @deffn {Data Type} httpd-virtualhost
  17277. This data type represents a virtualhost configuration block for the httpd service.
  17278. These should be added to the extra-config for the httpd-service.
  17279. @lisp
  17280. (simple-service 'www.example.com-server httpd-service-type
  17281. (list
  17282. (httpd-virtualhost
  17283. "*:80"
  17284. (list (string-join '("ServerName www.example.com"
  17285. "DocumentRoot /srv/http/www.example.com")
  17286. "\n")))))
  17287. @end lisp
  17288. @table @asis
  17289. @item @code{addresses-and-ports}
  17290. The addresses and ports for the @code{VirtualHost} directive.
  17291. @item @code{contents}
  17292. The contents of the @code{VirtualHost} directive, this should be a list
  17293. of strings and G-expressions.
  17294. @end table
  17295. @end deffn
  17296. @subsubheading NGINX
  17297. @deffn {Scheme Variable} nginx-service-type
  17298. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  17299. value for this service type is a @code{<nginx-configuration>} record.
  17300. A simple example configuration is given below.
  17301. @lisp
  17302. (service nginx-service-type
  17303. (nginx-configuration
  17304. (server-blocks
  17305. (list (nginx-server-configuration
  17306. (server-name '("www.example.com"))
  17307. (root "/srv/http/www.example.com"))))))
  17308. @end lisp
  17309. In addition to adding server blocks to the service configuration
  17310. directly, this service can be extended by other services to add server
  17311. blocks, as in this example:
  17312. @lisp
  17313. (simple-service 'my-extra-server nginx-service-type
  17314. (list (nginx-server-configuration
  17315. (root "/srv/http/extra-website")
  17316. (try-files (list "$uri" "$uri/index.html")))))
  17317. @end lisp
  17318. @end deffn
  17319. At startup, @command{nginx} has not yet read its configuration file, so
  17320. it uses a default file to log error messages. If it fails to load its
  17321. configuration file, that is where error messages are logged. After the
  17322. configuration file is loaded, the default error log file changes as per
  17323. configuration. In our case, startup error messages can be found in
  17324. @file{/var/run/nginx/logs/error.log}, and after configuration in
  17325. @file{/var/log/nginx/error.log}. The second location can be changed
  17326. with the @var{log-directory} configuration option.
  17327. @deffn {Data Type} nginx-configuration
  17328. This data type represents the configuration for NGinx. Some
  17329. configuration can be done through this and the other provided record
  17330. types, or alternatively, a config file can be provided.
  17331. @table @asis
  17332. @item @code{nginx} (default: @code{nginx})
  17333. The nginx package to use.
  17334. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  17335. The directory to which NGinx will write log files.
  17336. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  17337. The directory in which NGinx will create a pid file, and write temporary
  17338. files.
  17339. @item @code{server-blocks} (default: @code{'()})
  17340. A list of @dfn{server blocks} to create in the generated configuration
  17341. file, the elements should be of type
  17342. @code{<nginx-server-configuration>}.
  17343. The following example would setup NGinx to serve @code{www.example.com}
  17344. from the @code{/srv/http/www.example.com} directory, without using
  17345. HTTPS.
  17346. @lisp
  17347. (service nginx-service-type
  17348. (nginx-configuration
  17349. (server-blocks
  17350. (list (nginx-server-configuration
  17351. (server-name '("www.example.com"))
  17352. (root "/srv/http/www.example.com"))))))
  17353. @end lisp
  17354. @item @code{upstream-blocks} (default: @code{'()})
  17355. A list of @dfn{upstream blocks} to create in the generated configuration
  17356. file, the elements should be of type
  17357. @code{<nginx-upstream-configuration>}.
  17358. Configuring upstreams through the @code{upstream-blocks} can be useful
  17359. when combined with @code{locations} in the
  17360. @code{<nginx-server-configuration>} records. The following example
  17361. creates a server configuration with one location configuration, that
  17362. will proxy requests to a upstream configuration, which will handle
  17363. requests with two servers.
  17364. @lisp
  17365. (service
  17366. nginx-service-type
  17367. (nginx-configuration
  17368. (server-blocks
  17369. (list (nginx-server-configuration
  17370. (server-name '("www.example.com"))
  17371. (root "/srv/http/www.example.com")
  17372. (locations
  17373. (list
  17374. (nginx-location-configuration
  17375. (uri "/path1")
  17376. (body '("proxy_pass http://server-proxy;"))))))))
  17377. (upstream-blocks
  17378. (list (nginx-upstream-configuration
  17379. (name "server-proxy")
  17380. (servers (list "server1.example.com"
  17381. "server2.example.com")))))))
  17382. @end lisp
  17383. @item @code{file} (default: @code{#f})
  17384. If a configuration @var{file} is provided, this will be used, rather than
  17385. generating a configuration file from the provided @code{log-directory},
  17386. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  17387. proper operation, these arguments should match what is in @var{file} to ensure
  17388. that the directories are created when the service is activated.
  17389. This can be useful if you have an existing configuration file, or it's
  17390. not possible to do what is required through the other parts of the
  17391. nginx-configuration record.
  17392. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  17393. Bucket size for the server names hash tables, defaults to @code{#f} to
  17394. use the size of the processors cache line.
  17395. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  17396. Maximum bucket size for the server names hash tables.
  17397. @item @code{modules} (default: @code{'()})
  17398. List of nginx dynamic modules to load. This should be a list of file
  17399. names of loadable modules, as in this example:
  17400. @lisp
  17401. (modules
  17402. (list
  17403. (file-append nginx-accept-language-module "\
  17404. /etc/nginx/modules/ngx_http_accept_language_module.so")))
  17405. @end lisp
  17406. @item @code{global-directives} (default: @code{'((events . ()))})
  17407. Association list of global directives for the top level of the nginx
  17408. configuration. Values may themselves be association lists.
  17409. @lisp
  17410. (global-directives
  17411. `((worker_processes . 16)
  17412. (pcre_jit . on)
  17413. (events . ((worker_connections . 1024)))))
  17414. @end lisp
  17415. @item @code{extra-content} (default: @code{""})
  17416. Extra content for the @code{http} block. Should be string or a string
  17417. valued G-expression.
  17418. @end table
  17419. @end deffn
  17420. @deftp {Data Type} nginx-server-configuration
  17421. Data type representing the configuration of an nginx server block.
  17422. This type has the following parameters:
  17423. @table @asis
  17424. @item @code{listen} (default: @code{'("80" "443 ssl")})
  17425. Each @code{listen} directive sets the address and port for IP, or the
  17426. path for a UNIX-domain socket on which the server will accept requests.
  17427. Both address and port, or only address or only port can be specified.
  17428. An address may also be a hostname, for example:
  17429. @lisp
  17430. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  17431. @end lisp
  17432. @item @code{server-name} (default: @code{(list 'default)})
  17433. A list of server names this server represents. @code{'default} represents the
  17434. default server for connections matching no other server.
  17435. @item @code{root} (default: @code{"/srv/http"})
  17436. Root of the website nginx will serve.
  17437. @item @code{locations} (default: @code{'()})
  17438. A list of @dfn{nginx-location-configuration} or
  17439. @dfn{nginx-named-location-configuration} records to use within this
  17440. server block.
  17441. @item @code{index} (default: @code{(list "index.html")})
  17442. Index files to look for when clients ask for a directory. If it cannot be found,
  17443. Nginx will send the list of files in the directory.
  17444. @item @code{try-files} (default: @code{'()})
  17445. A list of files whose existence is checked in the specified order.
  17446. @code{nginx} will use the first file it finds to process the request.
  17447. @item @code{ssl-certificate} (default: @code{#f})
  17448. Where to find the certificate for secure connections. Set it to @code{#f} if
  17449. you don't have a certificate or you don't want to use HTTPS.
  17450. @item @code{ssl-certificate-key} (default: @code{#f})
  17451. Where to find the private key for secure connections. Set it to @code{#f} if
  17452. you don't have a key or you don't want to use HTTPS.
  17453. @item @code{server-tokens?} (default: @code{#f})
  17454. Whether the server should add its configuration to response.
  17455. @item @code{raw-content} (default: @code{'()})
  17456. A list of raw lines added to the server block.
  17457. @end table
  17458. @end deftp
  17459. @deftp {Data Type} nginx-upstream-configuration
  17460. Data type representing the configuration of an nginx @code{upstream}
  17461. block. This type has the following parameters:
  17462. @table @asis
  17463. @item @code{name}
  17464. Name for this group of servers.
  17465. @item @code{servers}
  17466. Specify the addresses of the servers in the group. The address can be
  17467. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  17468. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  17469. prefix @samp{unix:}. For addresses using an IP address or domain name,
  17470. the default port is 80, and a different port can be specified
  17471. explicitly.
  17472. @end table
  17473. @end deftp
  17474. @deftp {Data Type} nginx-location-configuration
  17475. Data type representing the configuration of an nginx @code{location}
  17476. block. This type has the following parameters:
  17477. @table @asis
  17478. @item @code{uri}
  17479. URI which this location block matches.
  17480. @anchor{nginx-location-configuration body}
  17481. @item @code{body}
  17482. Body of the location block, specified as a list of strings. This can contain
  17483. many
  17484. configuration directives. For example, to pass requests to a upstream
  17485. server group defined using an @code{nginx-upstream-configuration} block,
  17486. the following directive would be specified in the body @samp{(list "proxy_pass
  17487. http://upstream-name;")}.
  17488. @end table
  17489. @end deftp
  17490. @deftp {Data Type} nginx-named-location-configuration
  17491. Data type representing the configuration of an nginx named location
  17492. block. Named location blocks are used for request redirection, and not
  17493. used for regular request processing. This type has the following
  17494. parameters:
  17495. @table @asis
  17496. @item @code{name}
  17497. Name to identify this location block.
  17498. @item @code{body}
  17499. @xref{nginx-location-configuration body}, as the body for named location
  17500. blocks can be used in a similar way to the
  17501. @code{nginx-location-configuration body}. One restriction is that the
  17502. body of a named location block cannot contain location blocks.
  17503. @end table
  17504. @end deftp
  17505. @subsubheading Varnish Cache
  17506. @cindex Varnish
  17507. Varnish is a fast cache server that sits in between web applications
  17508. and end users. It proxies requests from clients and caches the
  17509. accessed URLs such that multiple requests for the same resource only
  17510. creates one request to the back-end.
  17511. @defvr {Scheme Variable} varnish-service-type
  17512. Service type for the Varnish daemon.
  17513. @end defvr
  17514. @deftp {Data Type} varnish-configuration
  17515. Data type representing the @code{varnish} service configuration.
  17516. This type has the following parameters:
  17517. @table @asis
  17518. @item @code{package} (default: @code{varnish})
  17519. The Varnish package to use.
  17520. @item @code{name} (default: @code{"default"})
  17521. A name for this Varnish instance. Varnish will create a directory in
  17522. @file{/var/varnish/} with this name and keep temporary files there. If
  17523. the name starts with a forward slash, it is interpreted as an absolute
  17524. directory name.
  17525. Pass the @code{-n} argument to other Varnish programs to connect to the
  17526. named instance, e.g.@: @command{varnishncsa -n default}.
  17527. @item @code{backend} (default: @code{"localhost:8080"})
  17528. The backend to use. This option has no effect if @code{vcl} is set.
  17529. @item @code{vcl} (default: #f)
  17530. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  17531. is @code{#f}, Varnish will proxy @code{backend} using the default
  17532. configuration. Otherwise this must be a file-like object with valid
  17533. VCL syntax.
  17534. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  17535. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  17536. can do something along these lines:
  17537. @lisp
  17538. (define %gnu-mirror
  17539. (plain-file "gnu.vcl"
  17540. "vcl 4.1;
  17541. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  17542. (operating-system
  17543. ;; @dots{}
  17544. (services (cons (service varnish-service-type
  17545. (varnish-configuration
  17546. (listen '(":80"))
  17547. (vcl %gnu-mirror)))
  17548. %base-services)))
  17549. @end lisp
  17550. The configuration of an already running Varnish instance can be inspected
  17551. and changed using the @command{varnishadm} program.
  17552. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  17553. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  17554. comprehensive documentation on Varnish and its configuration language.
  17555. @item @code{listen} (default: @code{'("localhost:80")})
  17556. List of addresses Varnish will listen on.
  17557. @item @code{storage} (default: @code{'("malloc,128m")})
  17558. List of storage backends that will be available in VCL.
  17559. @item @code{parameters} (default: @code{'()})
  17560. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  17561. @item @code{extra-options} (default: @code{'()})
  17562. Additional arguments to pass to the @command{varnishd} process.
  17563. @end table
  17564. @end deftp
  17565. @subsubheading Patchwork
  17566. @cindex Patchwork
  17567. Patchwork is a patch tracking system. It can collect patches sent to a
  17568. mailing list, and display them in a web interface.
  17569. @defvr {Scheme Variable} patchwork-service-type
  17570. Service type for Patchwork.
  17571. @end defvr
  17572. The following example is an example of a minimal service for Patchwork, for
  17573. the @code{patchwork.example.com} domain.
  17574. @lisp
  17575. (service patchwork-service-type
  17576. (patchwork-configuration
  17577. (domain "patchwork.example.com")
  17578. (settings-module
  17579. (patchwork-settings-module
  17580. (allowed-hosts (list domain))
  17581. (default-from-email "patchwork@@patchwork.example.com")))
  17582. (getmail-retriever-config
  17583. (getmail-retriever-configuration
  17584. (type "SimpleIMAPSSLRetriever")
  17585. (server "imap.example.com")
  17586. (port 993)
  17587. (username "patchwork")
  17588. (password-command
  17589. (list (file-append coreutils "/bin/cat")
  17590. "/etc/getmail-patchwork-imap-password"))
  17591. (extra-parameters
  17592. '((mailboxes . ("Patches"))))))))
  17593. @end lisp
  17594. There are three records for configuring the Patchwork service. The
  17595. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  17596. within the HTTPD service.
  17597. The @code{settings-module} field within the @code{<patchwork-configuration>}
  17598. record can be populated with the @code{<patchwork-settings-module>} record,
  17599. which describes a settings module that is generated within the Guix store.
  17600. For the @code{database-configuration} field within the
  17601. @code{<patchwork-settings-module>}, the
  17602. @code{<patchwork-database-configuration>} must be used.
  17603. @deftp {Data Type} patchwork-configuration
  17604. Data type representing the Patchwork service configuration. This type has the
  17605. following parameters:
  17606. @table @asis
  17607. @item @code{patchwork} (default: @code{patchwork})
  17608. The Patchwork package to use.
  17609. @item @code{domain}
  17610. The domain to use for Patchwork, this is used in the HTTPD service virtual
  17611. host.
  17612. @item @code{settings-module}
  17613. The settings module to use for Patchwork. As a Django application, Patchwork
  17614. is configured with a Python module containing the settings. This can either be
  17615. an instance of the @code{<patchwork-settings-module>} record, any other record
  17616. that represents the settings in the store, or a directory outside of the
  17617. store.
  17618. @item @code{static-path} (default: @code{"/static/"})
  17619. The path under which the HTTPD service should serve the static files.
  17620. @item @code{getmail-retriever-config}
  17621. The getmail-retriever-configuration record value to use with
  17622. Patchwork. Getmail will be configured with this value, the messages will be
  17623. delivered to Patchwork.
  17624. @end table
  17625. @end deftp
  17626. @deftp {Data Type} patchwork-settings-module
  17627. Data type representing a settings module for Patchwork. Some of these
  17628. settings relate directly to Patchwork, but others relate to Django, the web
  17629. framework used by Patchwork, or the Django Rest Framework library. This type
  17630. has the following parameters:
  17631. @table @asis
  17632. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  17633. The database connection settings used for Patchwork. See the
  17634. @code{<patchwork-database-configuration>} record type for more information.
  17635. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  17636. Patchwork, as a Django web application uses a secret key for cryptographically
  17637. signing values. This file should contain a unique unpredictable value.
  17638. If this file does not exist, it will be created and populated with a random
  17639. value by the patchwork-setup shepherd service.
  17640. This setting relates to Django.
  17641. @item @code{allowed-hosts}
  17642. A list of valid hosts for this Patchwork service. This should at least include
  17643. the domain specified in the @code{<patchwork-configuration>} record.
  17644. This is a Django setting.
  17645. @item @code{default-from-email}
  17646. The email address from which Patchwork should send email by default.
  17647. This is a Patchwork setting.
  17648. @item @code{static-url} (default: @code{#f})
  17649. The URL to use when serving static assets. It can be part of a URL, or a full
  17650. URL, but must end in a @code{/}.
  17651. If the default value is used, the @code{static-path} value from the
  17652. @code{<patchwork-configuration>} record will be used.
  17653. This is a Django setting.
  17654. @item @code{admins} (default: @code{'()})
  17655. Email addresses to send the details of errors that occur. Each value should
  17656. be a list containing two elements, the name and then the email address.
  17657. This is a Django setting.
  17658. @item @code{debug?} (default: @code{#f})
  17659. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  17660. messages will be shown.
  17661. This is a Django setting.
  17662. @item @code{enable-rest-api?} (default: @code{#t})
  17663. Whether to enable the Patchwork REST API.
  17664. This is a Patchwork setting.
  17665. @item @code{enable-xmlrpc?} (default: @code{#t})
  17666. Whether to enable the XML RPC API.
  17667. This is a Patchwork setting.
  17668. @item @code{force-https-links?} (default: @code{#t})
  17669. Whether to use HTTPS links on Patchwork pages.
  17670. This is a Patchwork setting.
  17671. @item @code{extra-settings} (default: @code{""})
  17672. Extra code to place at the end of the Patchwork settings module.
  17673. @end table
  17674. @end deftp
  17675. @deftp {Data Type} patchwork-database-configuration
  17676. Data type representing the database configuration for Patchwork.
  17677. @table @asis
  17678. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  17679. The database engine to use.
  17680. @item @code{name} (default: @code{"patchwork"})
  17681. The name of the database to use.
  17682. @item @code{user} (default: @code{"httpd"})
  17683. The user to connect to the database as.
  17684. @item @code{password} (default: @code{""})
  17685. The password to use when connecting to the database.
  17686. @item @code{host} (default: @code{""})
  17687. The host to make the database connection to.
  17688. @item @code{port} (default: @code{""})
  17689. The port on which to connect to the database.
  17690. @end table
  17691. @end deftp
  17692. @subsubheading Mumi
  17693. @cindex Mumi, Debbugs Web interface
  17694. @cindex Debbugs, Mumi Web interface
  17695. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  17696. Web interface to the Debbugs bug tracker, by default for
  17697. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  17698. but it also fetches and indexes mail retrieved from Debbugs.
  17699. @defvr {Scheme Variable} mumi-service-type
  17700. This is the service type for Mumi.
  17701. @end defvr
  17702. @deftp {Data Type} mumi-configuration
  17703. Data type representing the Mumi service configuration. This type has the
  17704. following fields:
  17705. @table @asis
  17706. @item @code{mumi} (default: @code{mumi})
  17707. The Mumi package to use.
  17708. @item @code{mailer?} (default: @code{#true})
  17709. Whether to enable or disable the mailer component.
  17710. @item @code{mumi-configuration-sender}
  17711. The email address used as the sender for comments.
  17712. @item @code{mumi-configuration-smtp}
  17713. A URI to configure the SMTP settings for Mailutils. This could be
  17714. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  17715. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  17716. mailutils, GNU@tie{}Mailutils}.
  17717. @end table
  17718. @end deftp
  17719. @subsubheading FastCGI
  17720. @cindex fastcgi
  17721. @cindex fcgiwrap
  17722. FastCGI is an interface between the front-end and the back-end of a web
  17723. service. It is a somewhat legacy facility; new web services should
  17724. generally just talk HTTP between the front-end and the back-end.
  17725. However there are a number of back-end services such as PHP or the
  17726. optimized HTTP Git repository access that use FastCGI, so we have
  17727. support for it in Guix.
  17728. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  17729. dispatch some subset of its requests to the fastcgi backend, which
  17730. listens on a local TCP or UNIX socket. There is an intermediary
  17731. @code{fcgiwrap} program that sits between the actual backend process and
  17732. the web server. The front-end indicates which backend program to run,
  17733. passing that information to the @code{fcgiwrap} process.
  17734. @defvr {Scheme Variable} fcgiwrap-service-type
  17735. A service type for the @code{fcgiwrap} FastCGI proxy.
  17736. @end defvr
  17737. @deftp {Data Type} fcgiwrap-configuration
  17738. Data type representing the configuration of the @code{fcgiwrap} service.
  17739. This type has the following parameters:
  17740. @table @asis
  17741. @item @code{package} (default: @code{fcgiwrap})
  17742. The fcgiwrap package to use.
  17743. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  17744. The socket on which the @code{fcgiwrap} process should listen, as a
  17745. string. Valid @var{socket} values include
  17746. @code{unix:@var{/path/to/unix/socket}},
  17747. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  17748. @code{tcp6:[@var{ipv6_addr}]:port}.
  17749. @item @code{user} (default: @code{fcgiwrap})
  17750. @itemx @code{group} (default: @code{fcgiwrap})
  17751. The user and group names, as strings, under which to run the
  17752. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  17753. the user asks for the specific user or group names @code{fcgiwrap} that
  17754. the corresponding user and/or group is present on the system.
  17755. It is possible to configure a FastCGI-backed web service to pass HTTP
  17756. authentication information from the front-end to the back-end, and to
  17757. allow @code{fcgiwrap} to run the back-end process as a corresponding
  17758. local user. To enable this capability on the back-end, run
  17759. @code{fcgiwrap} as the @code{root} user and group. Note that this
  17760. capability also has to be configured on the front-end as well.
  17761. @end table
  17762. @end deftp
  17763. @cindex php-fpm
  17764. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  17765. with some additional features useful for sites of any size.
  17766. These features include:
  17767. @itemize @bullet
  17768. @item Adaptive process spawning
  17769. @item Basic statistics (similar to Apache's mod_status)
  17770. @item Advanced process management with graceful stop/start
  17771. @item Ability to start workers with different uid/gid/chroot/environment
  17772. and different php.ini (replaces safe_mode)
  17773. @item Stdout & stderr logging
  17774. @item Emergency restart in case of accidental opcode cache destruction
  17775. @item Accelerated upload support
  17776. @item Support for a "slowlog"
  17777. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  17778. a special function to finish request & flush all data while continuing to do
  17779. something time-consuming (video converting, stats processing, etc.)
  17780. @end itemize
  17781. ...@: and much more.
  17782. @defvr {Scheme Variable} php-fpm-service-type
  17783. A Service type for @code{php-fpm}.
  17784. @end defvr
  17785. @deftp {Data Type} php-fpm-configuration
  17786. Data Type for php-fpm service configuration.
  17787. @table @asis
  17788. @item @code{php} (default: @code{php})
  17789. The php package to use.
  17790. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  17791. The address on which to accept FastCGI requests. Valid syntaxes are:
  17792. @table @asis
  17793. @item @code{"ip.add.re.ss:port"}
  17794. Listen on a TCP socket to a specific address on a specific port.
  17795. @item @code{"port"}
  17796. Listen on a TCP socket to all addresses on a specific port.
  17797. @item @code{"/path/to/unix/socket"}
  17798. Listen on a unix socket.
  17799. @end table
  17800. @item @code{user} (default: @code{php-fpm})
  17801. User who will own the php worker processes.
  17802. @item @code{group} (default: @code{php-fpm})
  17803. Group of the worker processes.
  17804. @item @code{socket-user} (default: @code{php-fpm})
  17805. User who can speak to the php-fpm socket.
  17806. @item @code{socket-group} (default: @code{nginx})
  17807. Group that can speak to the php-fpm socket.
  17808. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  17809. The process id of the php-fpm process is written to this file
  17810. once the service has started.
  17811. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  17812. Log for the php-fpm master process.
  17813. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  17814. Detailed settings for the php-fpm process manager.
  17815. Must be one of:
  17816. @table @asis
  17817. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  17818. @item @code{<php-fpm-static-process-manager-configuration>}
  17819. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  17820. @end table
  17821. @item @code{display-errors} (default @code{#f})
  17822. Determines whether php errors and warning should be sent to clients
  17823. and displayed in their browsers.
  17824. This is useful for local php development, but a security risk for public sites,
  17825. as error messages can reveal passwords and personal data.
  17826. @item @code{timezone} (default @code{#f})
  17827. Specifies @code{php_admin_value[date.timezone]} parameter.
  17828. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  17829. This file will log the @code{stderr} outputs of php worker processes.
  17830. Can be set to @code{#f} to disable logging.
  17831. @item @code{file} (default @code{#f})
  17832. An optional override of the whole configuration.
  17833. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  17834. @item @code{php-ini-file} (default @code{#f})
  17835. An optional override of the default php settings.
  17836. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  17837. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  17838. For local development it is useful to set a higher timeout and memory
  17839. limit for spawned php processes. This be accomplished with the
  17840. following operating system configuration snippet:
  17841. @lisp
  17842. (define %local-php-ini
  17843. (plain-file "php.ini"
  17844. "memory_limit = 2G
  17845. max_execution_time = 1800"))
  17846. (operating-system
  17847. ;; @dots{}
  17848. (services (cons (service php-fpm-service-type
  17849. (php-fpm-configuration
  17850. (php-ini-file %local-php-ini)))
  17851. %base-services)))
  17852. @end lisp
  17853. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  17854. directives} for comprehensive documentation on the acceptable
  17855. @file{php.ini} directives.
  17856. @end table
  17857. @end deftp
  17858. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  17859. Data Type for the @code{dynamic} php-fpm process manager. With the
  17860. @code{dynamic} process manager, spare worker processes are kept around
  17861. based on it's configured limits.
  17862. @table @asis
  17863. @item @code{max-children} (default: @code{5})
  17864. Maximum of worker processes.
  17865. @item @code{start-servers} (default: @code{2})
  17866. How many worker processes should be started on start-up.
  17867. @item @code{min-spare-servers} (default: @code{1})
  17868. How many spare worker processes should be kept around at minimum.
  17869. @item @code{max-spare-servers} (default: @code{3})
  17870. How many spare worker processes should be kept around at maximum.
  17871. @end table
  17872. @end deftp
  17873. @deftp {Data type} php-fpm-static-process-manager-configuration
  17874. Data Type for the @code{static} php-fpm process manager. With the
  17875. @code{static} process manager, an unchanging number of worker processes
  17876. are created.
  17877. @table @asis
  17878. @item @code{max-children} (default: @code{5})
  17879. Maximum of worker processes.
  17880. @end table
  17881. @end deftp
  17882. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  17883. Data Type for the @code{on-demand} php-fpm process manager. With the
  17884. @code{on-demand} process manager, worker processes are only created as
  17885. requests arrive.
  17886. @table @asis
  17887. @item @code{max-children} (default: @code{5})
  17888. Maximum of worker processes.
  17889. @item @code{process-idle-timeout} (default: @code{10})
  17890. The time in seconds after which a process with no requests is killed.
  17891. @end table
  17892. @end deftp
  17893. @deffn {Scheme Procedure} nginx-php-location @
  17894. [#:nginx-package nginx] @
  17895. [socket (string-append "/var/run/php" @
  17896. (version-major (package-version php)) @
  17897. "-fpm.sock")]
  17898. A helper function to quickly add php to an @code{nginx-server-configuration}.
  17899. @end deffn
  17900. A simple services setup for nginx with php can look like this:
  17901. @lisp
  17902. (services (cons* (service dhcp-client-service-type)
  17903. (service php-fpm-service-type)
  17904. (service nginx-service-type
  17905. (nginx-server-configuration
  17906. (server-name '("example.com"))
  17907. (root "/srv/http/")
  17908. (locations
  17909. (list (nginx-php-location)))
  17910. (listen '("80"))
  17911. (ssl-certificate #f)
  17912. (ssl-certificate-key #f)))
  17913. %base-services))
  17914. @end lisp
  17915. @cindex cat-avatar-generator
  17916. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  17917. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  17918. the hash of a user's email address.
  17919. @deffn {Scheme Procedure} cat-avatar-generator-service @
  17920. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  17921. [#:package cat-avatar-generator] @
  17922. [#:configuration (nginx-server-configuration)]
  17923. Returns an nginx-server-configuration that inherits @code{configuration}. It
  17924. extends the nginx configuration to add a server block that serves @code{package},
  17925. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  17926. be able to use @code{cache-dir} as its cache directory.
  17927. @end deffn
  17928. A simple setup for cat-avatar-generator can look like this:
  17929. @lisp
  17930. (services (cons* (cat-avatar-generator-service
  17931. #:configuration
  17932. (nginx-server-configuration
  17933. (server-name '("example.com"))))
  17934. ...
  17935. %base-services))
  17936. @end lisp
  17937. @subsubheading Hpcguix-web
  17938. @cindex hpcguix-web
  17939. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  17940. program is a customizable web interface to browse Guix packages,
  17941. initially designed for users of high-performance computing (HPC)
  17942. clusters.
  17943. @defvr {Scheme Variable} hpcguix-web-service-type
  17944. The service type for @code{hpcguix-web}.
  17945. @end defvr
  17946. @deftp {Data Type} hpcguix-web-configuration
  17947. Data type for the hpcguix-web service configuration.
  17948. @table @asis
  17949. @item @code{specs}
  17950. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  17951. configuration. The main items available in this spec are:
  17952. @table @asis
  17953. @item @code{title-prefix} (default: @code{"hpcguix | "})
  17954. The page title prefix.
  17955. @item @code{guix-command} (default: @code{"guix"})
  17956. The @command{guix} command.
  17957. @item @code{package-filter-proc} (default: @code{(const #t)})
  17958. A procedure specifying how to filter packages that are displayed.
  17959. @item @code{package-page-extension-proc} (default: @code{(const '())})
  17960. Extension package for @code{hpcguix-web}.
  17961. @item @code{menu} (default: @code{'()})
  17962. Additional entry in page @code{menu}.
  17963. @item @code{channels} (default: @code{%default-channels})
  17964. List of channels from which the package list is built (@pxref{Channels}).
  17965. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  17966. The expiration time, in seconds, after which the package list is rebuilt from
  17967. the latest instances of the given channels.
  17968. @end table
  17969. See the hpcguix-web repository for a
  17970. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  17971. complete example}.
  17972. @item @code{package} (default: @code{hpcguix-web})
  17973. The hpcguix-web package to use.
  17974. @end table
  17975. @end deftp
  17976. A typical hpcguix-web service declaration looks like this:
  17977. @lisp
  17978. (service hpcguix-web-service-type
  17979. (hpcguix-web-configuration
  17980. (specs
  17981. #~(define site-config
  17982. (hpcweb-configuration
  17983. (title-prefix "Guix-HPC - ")
  17984. (menu '(("/about" "ABOUT"))))))))
  17985. @end lisp
  17986. @quotation Note
  17987. The hpcguix-web service periodically updates the package list it publishes by
  17988. pulling channels from Git. To that end, it needs to access X.509 certificates
  17989. so that it can authenticate Git servers when communicating over HTTPS, and it
  17990. assumes that @file{/etc/ssl/certs} contains those certificates.
  17991. Thus, make sure to add @code{nss-certs} or another certificate package to the
  17992. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  17993. more information on X.509 certificates.
  17994. @end quotation
  17995. @node Certificate Services
  17996. @subsection Certificate Services
  17997. @cindex Web
  17998. @cindex HTTP, HTTPS
  17999. @cindex Let's Encrypt
  18000. @cindex TLS certificates
  18001. The @code{(gnu services certbot)} module provides a service to
  18002. automatically obtain a valid TLS certificate from the Let's Encrypt
  18003. certificate authority. These certificates can then be used to serve
  18004. content securely over HTTPS or other TLS-based protocols, with the
  18005. knowledge that the client will be able to verify the server's
  18006. authenticity.
  18007. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  18008. @code{certbot} tool to automate the certification process. This tool
  18009. first securely generates a key on the server. It then makes a request
  18010. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  18011. checks that the request originates from the host in question by using a
  18012. challenge-response protocol, requiring the server to provide its
  18013. response over HTTP. If that protocol completes successfully, the CA
  18014. signs the key, resulting in a certificate. That certificate is valid
  18015. for a limited period of time, and therefore to continue to provide TLS
  18016. services, the server needs to periodically ask the CA to renew its
  18017. signature.
  18018. The certbot service automates this process: the initial key
  18019. generation, the initial certification request to the Let's Encrypt
  18020. service, the web server challenge/response integration, writing the
  18021. certificate to disk, the automated periodic renewals, and the deployment
  18022. tasks associated with the renewal (e.g.@: reloading services, copying keys
  18023. with different permissions).
  18024. Certbot is run twice a day, at a random minute within the hour. It
  18025. won't do anything until your certificates are due for renewal or
  18026. revoked, but running it regularly would give your service a chance of
  18027. staying online in case a Let's Encrypt-initiated revocation happened for
  18028. some reason.
  18029. By using this service, you agree to the ACME Subscriber Agreement, which
  18030. can be found there:
  18031. @url{https://acme-v01.api.letsencrypt.org/directory}.
  18032. @defvr {Scheme Variable} certbot-service-type
  18033. A service type for the @code{certbot} Let's Encrypt client. Its value
  18034. must be a @code{certbot-configuration} record as in this example:
  18035. @lisp
  18036. (define %nginx-deploy-hook
  18037. (program-file
  18038. "nginx-deploy-hook"
  18039. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  18040. (kill pid SIGHUP))))
  18041. (service certbot-service-type
  18042. (certbot-configuration
  18043. (email "foo@@example.net")
  18044. (certificates
  18045. (list
  18046. (certificate-configuration
  18047. (domains '("example.net" "www.example.net"))
  18048. (deploy-hook %nginx-deploy-hook))
  18049. (certificate-configuration
  18050. (domains '("bar.example.net")))))))
  18051. @end lisp
  18052. See below for details about @code{certbot-configuration}.
  18053. @end defvr
  18054. @deftp {Data Type} certbot-configuration
  18055. Data type representing the configuration of the @code{certbot} service.
  18056. This type has the following parameters:
  18057. @table @asis
  18058. @item @code{package} (default: @code{certbot})
  18059. The certbot package to use.
  18060. @item @code{webroot} (default: @code{/var/www})
  18061. The directory from which to serve the Let's Encrypt challenge/response
  18062. files.
  18063. @item @code{certificates} (default: @code{()})
  18064. A list of @code{certificates-configuration}s for which to generate
  18065. certificates and request signatures. Each certificate has a @code{name}
  18066. and several @code{domains}.
  18067. @item @code{email} (default: @code{#f})
  18068. Optional email address used for registration and recovery contact.
  18069. Setting this is encouraged as it allows you to receive important
  18070. notifications about the account and issued certificates.
  18071. @item @code{server} (default: @code{#f})
  18072. Optional URL of ACME server. Setting this overrides certbot's default,
  18073. which is the Let's Encrypt server.
  18074. @item @code{rsa-key-size} (default: @code{2048})
  18075. Size of the RSA key.
  18076. @item @code{default-location} (default: @i{see below})
  18077. The default @code{nginx-location-configuration}. Because @code{certbot}
  18078. needs to be able to serve challenges and responses, it needs to be able
  18079. to run a web server. It does so by extending the @code{nginx} web
  18080. service with an @code{nginx-server-configuration} listening on the
  18081. @var{domains} on port 80, and which has a
  18082. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  18083. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  18084. these nginx configuration data types.
  18085. Requests to other URL paths will be matched by the
  18086. @code{default-location}, which if present is added to all
  18087. @code{nginx-server-configuration}s.
  18088. By default, the @code{default-location} will issue a redirect from
  18089. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  18090. you to define what to serve on your site via @code{https}.
  18091. Pass @code{#f} to not issue a default location.
  18092. @end table
  18093. @end deftp
  18094. @deftp {Data Type} certificate-configuration
  18095. Data type representing the configuration of a certificate.
  18096. This type has the following parameters:
  18097. @table @asis
  18098. @item @code{name} (default: @i{see below})
  18099. This name is used by Certbot for housekeeping and in file paths; it
  18100. doesn't affect the content of the certificate itself. To see
  18101. certificate names, run @code{certbot certificates}.
  18102. Its default is the first provided domain.
  18103. @item @code{domains} (default: @code{()})
  18104. The first domain provided will be the subject CN of the certificate, and
  18105. all domains will be Subject Alternative Names on the certificate.
  18106. @item @code{challenge} (default: @code{#f})
  18107. The challenge type that has to be run by certbot. If @code{#f} is specified,
  18108. default to the HTTP challenge. If a value is specified, defaults to the
  18109. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  18110. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  18111. and gives Let's Encrypt permission to log the public IP address of the
  18112. requesting machine.
  18113. @item @code{authentication-hook} (default: @code{#f})
  18114. Command to be run in a shell once for each certificate challenge to be
  18115. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  18116. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  18117. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  18118. file name of the resource requested when performing an HTTP-01 challenge.
  18119. @item @code{cleanup-hook} (default: @code{#f})
  18120. Command to be run in a shell once for each certificate challenge that
  18121. have been answered by the @code{auth-hook}. For this command, the shell
  18122. variables available in the @code{auth-hook} script are still available, and
  18123. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  18124. of the @code{auth-hook} script.
  18125. @item @code{deploy-hook} (default: @code{#f})
  18126. Command to be run in a shell once for each successfully issued
  18127. certificate. For this command, the shell variable
  18128. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  18129. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  18130. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  18131. contain a space-delimited list of renewed certificate domains (for
  18132. example, @samp{"example.com www.example.com"}.
  18133. @end table
  18134. @end deftp
  18135. For each @code{certificate-configuration}, the certificate is saved to
  18136. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  18137. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  18138. @node DNS Services
  18139. @subsection DNS Services
  18140. @cindex DNS (domain name system)
  18141. @cindex domain name system (DNS)
  18142. The @code{(gnu services dns)} module provides services related to the
  18143. @dfn{domain name system} (DNS). It provides a server service for hosting
  18144. an @emph{authoritative} DNS server for multiple zones, slave or master.
  18145. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  18146. caching and forwarding DNS server for the LAN, which uses
  18147. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  18148. @subsubheading Knot Service
  18149. An example configuration of an authoritative server for two zones, one master
  18150. and one slave, is:
  18151. @lisp
  18152. (define-zone-entries example.org.zone
  18153. ;; Name TTL Class Type Data
  18154. ("@@" "" "IN" "A" "127.0.0.1")
  18155. ("@@" "" "IN" "NS" "ns")
  18156. ("ns" "" "IN" "A" "127.0.0.1"))
  18157. (define master-zone
  18158. (knot-zone-configuration
  18159. (domain "example.org")
  18160. (zone (zone-file
  18161. (origin "example.org")
  18162. (entries example.org.zone)))))
  18163. (define slave-zone
  18164. (knot-zone-configuration
  18165. (domain "plop.org")
  18166. (dnssec-policy "default")
  18167. (master (list "plop-master"))))
  18168. (define plop-master
  18169. (knot-remote-configuration
  18170. (id "plop-master")
  18171. (address (list "208.76.58.171"))))
  18172. (operating-system
  18173. ;; ...
  18174. (services (cons* (service knot-service-type
  18175. (knot-configuration
  18176. (remotes (list plop-master))
  18177. (zones (list master-zone slave-zone))))
  18178. ;; ...
  18179. %base-services)))
  18180. @end lisp
  18181. @deffn {Scheme Variable} knot-service-type
  18182. This is the type for the Knot DNS server.
  18183. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  18184. zones, that is to say domain names you would buy from a registrar. This server
  18185. is not a resolver, meaning that it can only resolve names for which it is
  18186. authoritative. This server can be configured to serve zones as a master server
  18187. or a slave server as a per-zone basis. Slave zones will get their data from
  18188. masters, and will serve it as an authoritative server. From the point of view
  18189. of a resolver, there is no difference between master and slave.
  18190. The following data types are used to configure the Knot DNS server:
  18191. @end deffn
  18192. @deftp {Data Type} knot-key-configuration
  18193. Data type representing a key.
  18194. This type has the following parameters:
  18195. @table @asis
  18196. @item @code{id} (default: @code{""})
  18197. An identifier for other configuration fields to refer to this key. IDs must
  18198. be unique and must not be empty.
  18199. @item @code{algorithm} (default: @code{#f})
  18200. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  18201. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  18202. and @code{'hmac-sha512}.
  18203. @item @code{secret} (default: @code{""})
  18204. The secret key itself.
  18205. @end table
  18206. @end deftp
  18207. @deftp {Data Type} knot-acl-configuration
  18208. Data type representing an Access Control List (ACL) configuration.
  18209. This type has the following parameters:
  18210. @table @asis
  18211. @item @code{id} (default: @code{""})
  18212. An identifier for ether configuration fields to refer to this key. IDs must be
  18213. unique and must not be empty.
  18214. @item @code{address} (default: @code{'()})
  18215. An ordered list of IP addresses, network subnets, or network ranges represented
  18216. with strings. The query must match one of them. Empty value means that
  18217. address match is not required.
  18218. @item @code{key} (default: @code{'()})
  18219. An ordered list of references to keys represented with strings. The string
  18220. must match a key ID defined in a @code{knot-key-configuration}. No key means
  18221. that a key is not require to match that ACL.
  18222. @item @code{action} (default: @code{'()})
  18223. An ordered list of actions that are permitted or forbidden by this ACL. Possible
  18224. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  18225. and @code{'update}.
  18226. @item @code{deny?} (default: @code{#f})
  18227. When true, the ACL defines restrictions. Listed actions are forbidden. When
  18228. false, listed actions are allowed.
  18229. @end table
  18230. @end deftp
  18231. @deftp {Data Type} zone-entry
  18232. Data type representing a record entry in a zone file.
  18233. This type has the following parameters:
  18234. @table @asis
  18235. @item @code{name} (default: @code{"@@"})
  18236. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  18237. are relative to the origin of the zone. For example, in the @code{example.org}
  18238. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  18239. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  18240. refers to @code{ns.example.org}.
  18241. @item @code{ttl} (default: @code{""})
  18242. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  18243. @item @code{class} (default: @code{"IN"})
  18244. The class of the record. Knot currently supports only @code{"IN"} and
  18245. partially @code{"CH"}.
  18246. @item @code{type} (default: @code{"A"})
  18247. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  18248. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  18249. defined.
  18250. @item @code{data} (default: @code{""})
  18251. The data contained in the record. For instance an IP address associated with
  18252. an A record, or a domain name associated with an NS record. Remember that
  18253. domain names are relative to the origin unless they end with a dot.
  18254. @end table
  18255. @end deftp
  18256. @deftp {Data Type} zone-file
  18257. Data type representing the content of a zone file.
  18258. This type has the following parameters:
  18259. @table @asis
  18260. @item @code{entries} (default: @code{'()})
  18261. The list of entries. The SOA record is taken care of, so you don't need to
  18262. put it in the list of entries. This list should probably contain an entry
  18263. for your primary authoritative DNS server. Other than using a list of entries
  18264. directly, you can use @code{define-zone-entries} to define a object containing
  18265. the list of entries more easily, that you can later pass to the @code{entries}
  18266. field of the @code{zone-file}.
  18267. @item @code{origin} (default: @code{""})
  18268. The name of your zone. This parameter cannot be empty.
  18269. @item @code{ns} (default: @code{"ns"})
  18270. The domain of your primary authoritative DNS server. The name is relative to
  18271. the origin, unless it ends with a dot. It is mandatory that this primary
  18272. DNS server corresponds to an NS record in the zone and that it is associated
  18273. to an IP address in the list of entries.
  18274. @item @code{mail} (default: @code{"hostmaster"})
  18275. An email address people can contact you at, as the owner of the zone. This
  18276. is translated as @code{<mail>@@<origin>}.
  18277. @item @code{serial} (default: @code{1})
  18278. The serial number of the zone. As this is used to keep track of changes by
  18279. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  18280. Always increment it when you make a change in your zone.
  18281. @item @code{refresh} (default: @code{(* 2 24 3600)})
  18282. The frequency at which slaves will do a zone transfer. This value is a number
  18283. of seconds. It can be computed by multiplications or with
  18284. @code{(string->duration)}.
  18285. @item @code{retry} (default: @code{(* 15 60)})
  18286. The period after which a slave will retry to contact its master when it fails
  18287. to do so a first time.
  18288. @item @code{expiry} (default: @code{(* 14 24 3600)})
  18289. Default TTL of records. Existing records are considered correct for at most
  18290. this amount of time. After this period, resolvers will invalidate their cache
  18291. and check again that it still exists.
  18292. @item @code{nx} (default: @code{3600})
  18293. Default TTL of inexistant records. This delay is usually short because you want
  18294. your new domains to reach everyone quickly.
  18295. @end table
  18296. @end deftp
  18297. @deftp {Data Type} knot-remote-configuration
  18298. Data type representing a remote configuration.
  18299. This type has the following parameters:
  18300. @table @asis
  18301. @item @code{id} (default: @code{""})
  18302. An identifier for other configuration fields to refer to this remote. IDs must
  18303. be unique and must not be empty.
  18304. @item @code{address} (default: @code{'()})
  18305. An ordered list of destination IP addresses. Addresses are tried in sequence.
  18306. An optional port can be given with the @@ separator. For instance:
  18307. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  18308. @item @code{via} (default: @code{'()})
  18309. An ordered list of source IP addresses. An empty list will have Knot choose
  18310. an appropriate source IP. An optional port can be given with the @@ separator.
  18311. The default is to choose at random.
  18312. @item @code{key} (default: @code{#f})
  18313. A reference to a key, that is a string containing the identifier of a key
  18314. defined in a @code{knot-key-configuration} field.
  18315. @end table
  18316. @end deftp
  18317. @deftp {Data Type} knot-keystore-configuration
  18318. Data type representing a keystore to hold dnssec keys.
  18319. This type has the following parameters:
  18320. @table @asis
  18321. @item @code{id} (default: @code{""})
  18322. The id of the keystore. It must not be empty.
  18323. @item @code{backend} (default: @code{'pem})
  18324. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  18325. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  18326. The configuration string of the backend. An example for the PKCS#11 is:
  18327. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  18328. For the pem backend, the string represents a path in the file system.
  18329. @end table
  18330. @end deftp
  18331. @deftp {Data Type} knot-policy-configuration
  18332. Data type representing a dnssec policy. Knot DNS is able to automatically
  18333. sign your zones. It can either generate and manage your keys automatically or
  18334. use keys that you generate.
  18335. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  18336. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  18337. zone. In order to be trusted, the KSK needs to be present in the parent zone
  18338. (usually a top-level domain). If your registrar supports dnssec, you will
  18339. have to send them your KSK's hash so they can add a DS record in their zone.
  18340. This is not automated and need to be done each time you change your KSK.
  18341. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  18342. easily and use weaker cryptographic functions (they use lower parameters) in
  18343. order to sign records quickly, so they are changed often. The KSK however
  18344. requires manual interaction with the registrar, so they are changed less often
  18345. and use stronger parameters because they sign only one record.
  18346. This type has the following parameters:
  18347. @table @asis
  18348. @item @code{id} (default: @code{""})
  18349. The id of the policy. It must not be empty.
  18350. @item @code{keystore} (default: @code{"default"})
  18351. A reference to a keystore, that is a string containing the identifier of a
  18352. keystore defined in a @code{knot-keystore-configuration} field. The
  18353. @code{"default"} identifier means the default keystore (a kasp database that
  18354. was setup by this service).
  18355. @item @code{manual?} (default: @code{#f})
  18356. Whether the key management is manual or automatic.
  18357. @item @code{single-type-signing?} (default: @code{#f})
  18358. When @code{#t}, use the Single-Type Signing Scheme.
  18359. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  18360. An algorithm of signing keys and issued signatures.
  18361. @item @code{ksk-size} (default: @code{256})
  18362. The length of the KSK. Note that this value is correct for the default
  18363. algorithm, but would be unsecure for other algorithms.
  18364. @item @code{zsk-size} (default: @code{256})
  18365. The length of the ZSK. Note that this value is correct for the default
  18366. algorithm, but would be unsecure for other algorithms.
  18367. @item @code{dnskey-ttl} (default: @code{'default})
  18368. The TTL value for DNSKEY records added into zone apex. The special
  18369. @code{'default} value means same as the zone SOA TTL.
  18370. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  18371. The period between ZSK publication and the next rollover initiation.
  18372. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  18373. An extra delay added for each key rollover step. This value should be high
  18374. enough to cover propagation of data from the master server to all slaves.
  18375. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  18376. A validity period of newly issued signatures.
  18377. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  18378. A period how long before a signature expiration the signature will be refreshed.
  18379. @item @code{nsec3?} (default: @code{#f})
  18380. When @code{#t}, NSEC3 will be used instead of NSEC.
  18381. @item @code{nsec3-iterations} (default: @code{5})
  18382. The number of additional times the hashing is performed.
  18383. @item @code{nsec3-salt-length} (default: @code{8})
  18384. The length of a salt field in octets, which is appended to the original owner
  18385. name before hashing.
  18386. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  18387. The validity period of newly issued salt field.
  18388. @end table
  18389. @end deftp
  18390. @deftp {Data Type} knot-zone-configuration
  18391. Data type representing a zone served by Knot.
  18392. This type has the following parameters:
  18393. @table @asis
  18394. @item @code{domain} (default: @code{""})
  18395. The domain served by this configuration. It must not be empty.
  18396. @item @code{file} (default: @code{""})
  18397. The file where this zone is saved. This parameter is ignored by master zones.
  18398. Empty means default location that depends on the domain name.
  18399. @item @code{zone} (default: @code{(zone-file)})
  18400. The content of the zone file. This parameter is ignored by slave zones. It
  18401. must contain a zone-file record.
  18402. @item @code{master} (default: @code{'()})
  18403. A list of master remotes. When empty, this zone is a master. When set, this
  18404. zone is a slave. This is a list of remotes identifiers.
  18405. @item @code{ddns-master} (default: @code{#f})
  18406. The main master. When empty, it defaults to the first master in the list of
  18407. masters.
  18408. @item @code{notify} (default: @code{'()})
  18409. A list of slave remote identifiers.
  18410. @item @code{acl} (default: @code{'()})
  18411. A list of acl identifiers.
  18412. @item @code{semantic-checks?} (default: @code{#f})
  18413. When set, this adds more semantic checks to the zone.
  18414. @item @code{disable-any?} (default: @code{#f})
  18415. When set, this forbids queries of the ANY type.
  18416. @item @code{zonefile-sync} (default: @code{0})
  18417. The delay between a modification in memory and on disk. 0 means immediate
  18418. synchronization.
  18419. @item @code{zonefile-load} (default: @code{#f})
  18420. The way the zone file contents are applied during zone load. Possible values
  18421. are:
  18422. @itemize
  18423. @item @code{#f} for using the default value from Knot,
  18424. @item @code{'none} for not using the zone file at all,
  18425. @item @code{'difference} for computing the difference between already available
  18426. contents and zone contents and applying it to the current zone contents,
  18427. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  18428. ignoring the SOA serial in the zone file, while the server takes care of it
  18429. automatically.
  18430. @item @code{'whole} for loading zone contents from the zone file.
  18431. @end itemize
  18432. @item @code{journal-content} (default: @code{#f})
  18433. The way the journal is used to store zone and its changes. Possible values
  18434. are @code{'none} to not use it at all, @code{'changes} to store changes and
  18435. @code{'all} to store contents. @code{#f} does not set this option, so the
  18436. default value from Knot is used.
  18437. @item @code{max-journal-usage} (default: @code{#f})
  18438. The maximum size for the journal on disk. @code{#f} does not set this option,
  18439. so the default value from Knot is used.
  18440. @item @code{max-journal-depth} (default: @code{#f})
  18441. The maximum size of the history. @code{#f} does not set this option, so the
  18442. default value from Knot is used.
  18443. @item @code{max-zone-size} (default: @code{#f})
  18444. The maximum size of the zone file. This limit is enforced for incoming
  18445. transfer and updates. @code{#f} does not set this option, so the default
  18446. value from Knot is used.
  18447. @item @code{dnssec-policy} (default: @code{#f})
  18448. A reference to a @code{knot-policy-configuration} record, or the special
  18449. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  18450. on this zone.
  18451. @item @code{serial-policy} (default: @code{'increment})
  18452. A policy between @code{'increment} and @code{'unixtime}.
  18453. @end table
  18454. @end deftp
  18455. @deftp {Data Type} knot-configuration
  18456. Data type representing the Knot configuration.
  18457. This type has the following parameters:
  18458. @table @asis
  18459. @item @code{knot} (default: @code{knot})
  18460. The Knot package.
  18461. @item @code{run-directory} (default: @code{"/var/run/knot"})
  18462. The run directory. This directory will be used for pid file and sockets.
  18463. @item @code{includes} (default: @code{'()})
  18464. A list of strings or file-like objects denoting other files that must be
  18465. included at the top of the configuration file.
  18466. @cindex secrets, Knot service
  18467. This can be used to manage secrets out-of-band. For example, secret
  18468. keys may be stored in an out-of-band file not managed by Guix, and
  18469. thus not visible in @file{/gnu/store}---e.g., you could store secret
  18470. key configuration in @file{/etc/knot/secrets.conf} and add this file
  18471. to the @code{includes} list.
  18472. One can generate a secret tsig key (for nsupdate and zone transfers with the
  18473. keymgr command from the knot package. Note that the package is not automatically
  18474. installed by the service. The following example shows how to generate a new
  18475. tsig key:
  18476. @example
  18477. keymgr -t mysecret > /etc/knot/secrets.conf
  18478. chmod 600 /etc/knot/secrets.conf
  18479. @end example
  18480. Also note that the generated key will be named @var{mysecret}, so it is the
  18481. name that needs to be used in the @var{key} field of the
  18482. @code{knot-acl-configuration} record and in other places that need to refer
  18483. to that key.
  18484. It can also be used to add configuration not supported by this interface.
  18485. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  18486. An ip address on which to listen.
  18487. @item @code{listen-v6} (default: @code{"::"})
  18488. An ip address on which to listen.
  18489. @item @code{listen-port} (default: @code{53})
  18490. A port on which to listen.
  18491. @item @code{keys} (default: @code{'()})
  18492. The list of knot-key-configuration used by this configuration.
  18493. @item @code{acls} (default: @code{'()})
  18494. The list of knot-acl-configuration used by this configuration.
  18495. @item @code{remotes} (default: @code{'()})
  18496. The list of knot-remote-configuration used by this configuration.
  18497. @item @code{zones} (default: @code{'()})
  18498. The list of knot-zone-configuration used by this configuration.
  18499. @end table
  18500. @end deftp
  18501. @subsubheading Knot Resolver Service
  18502. @deffn {Scheme Variable} knot-resolver-service-type
  18503. This this the type of the knot resolver service, whose value should be
  18504. an @code{knot-resolver-configuration} object as in this example:
  18505. @lisp
  18506. (service knot-resolver-service-type
  18507. (knot-resolver-configuration
  18508. (kresd-config-file (plain-file "kresd.conf" "
  18509. net.listen('192.168.0.1', 5353)
  18510. user('knot-resolver', 'knot-resolver')
  18511. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  18512. cache.size = 100 * MB
  18513. "))))
  18514. @end lisp
  18515. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  18516. @end deffn
  18517. @deftp {Data Type} knot-resolver-configuration
  18518. Data type representing the configuration of knot-resolver.
  18519. @table @asis
  18520. @item @code{package} (default: @var{knot-resolver})
  18521. Package object of the knot DNS resolver.
  18522. @item @code{kresd-config-file} (default: %kresd.conf)
  18523. File-like object of the kresd configuration file to use, by default it
  18524. will listen on @code{127.0.0.1} and @code{::1}.
  18525. @item @code{garbage-collection-interval} (default: 1000)
  18526. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  18527. @end table
  18528. @end deftp
  18529. @subsubheading Dnsmasq Service
  18530. @deffn {Scheme Variable} dnsmasq-service-type
  18531. This is the type of the dnsmasq service, whose value should be an
  18532. @code{dnsmasq-configuration} object as in this example:
  18533. @lisp
  18534. (service dnsmasq-service-type
  18535. (dnsmasq-configuration
  18536. (no-resolv? #t)
  18537. (servers '("192.168.1.1"))))
  18538. @end lisp
  18539. @end deffn
  18540. @deftp {Data Type} dnsmasq-configuration
  18541. Data type representing the configuration of dnsmasq.
  18542. @table @asis
  18543. @item @code{package} (default: @var{dnsmasq})
  18544. Package object of the dnsmasq server.
  18545. @item @code{no-hosts?} (default: @code{#f})
  18546. When true, don't read the hostnames in /etc/hosts.
  18547. @item @code{port} (default: @code{53})
  18548. The port to listen on. Setting this to zero completely disables DNS
  18549. responses, leaving only DHCP and/or TFTP functions.
  18550. @item @code{local-service?} (default: @code{#t})
  18551. Accept DNS queries only from hosts whose address is on a local subnet,
  18552. ie a subnet for which an interface exists on the server.
  18553. @item @code{listen-addresses} (default: @code{'()})
  18554. Listen on the given IP addresses.
  18555. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  18556. The file to read the IP address of the upstream nameservers from.
  18557. @item @code{no-resolv?} (default: @code{#f})
  18558. When true, don't read @var{resolv-file}.
  18559. @item @code{servers} (default: @code{'()})
  18560. Specify IP address of upstream servers directly.
  18561. @item @code{addresses} (default: @code{'()})
  18562. For each entry, specify an IP address to return for any host in the
  18563. given domains. Queries in the domains are never forwarded and always
  18564. replied to with the specified IP address.
  18565. This is useful for redirecting hosts locally, for example:
  18566. @lisp
  18567. (service dnsmasq-service-type
  18568. (dnsmasq-configuration
  18569. (addresses
  18570. '(; Redirect to a local web-server.
  18571. "/example.org/127.0.0.1"
  18572. ; Redirect subdomain to a specific IP.
  18573. "/subdomain.example.org/192.168.1.42"))))
  18574. @end lisp
  18575. Note that rules in @file{/etc/hosts} take precedence over this.
  18576. @item @code{cache-size} (default: @code{150})
  18577. Set the size of dnsmasq's cache. Setting the cache size to zero
  18578. disables caching.
  18579. @item @code{negative-cache?} (default: @code{#t})
  18580. When false, disable negative caching.
  18581. @item @code{tftp-enable?} (default: @code{#f})
  18582. Whether to enable the built-in TFTP server.
  18583. @item @code{tftp-no-fail?} (default: @code{#f})
  18584. If true, does not fail dnsmasq if the TFTP server could not start up.
  18585. @item @code{tftp-single-port?} (default: @code{#f})
  18586. Whether to use only one single port for TFTP.
  18587. @item @code{tftp-secure?} (default: @code{#f})
  18588. If true, only files owned by the user running the dnsmasq process are accessible.
  18589. If dnsmasq is being run as root, different rules apply:
  18590. @code{tftp-secure?} has no effect, but only files which have the
  18591. world-readable bit set are accessible.
  18592. @item @code{tftp-max} (default: @code{#f})
  18593. If set, sets the maximal number of concurrent connections allowed.
  18594. @item @code{tftp-mtu} (default: @code{#f})
  18595. If set, sets the MTU for TFTP packets to that value.
  18596. @item @code{tftp-no-blocksize?} (default: @code{#f})
  18597. If true, stops the TFTP server from negotiating the blocksize with a client.
  18598. @item @code{tftp-lowercase?} (default: @code{#f})
  18599. Whether to convert all filenames in TFTP requests to lowercase.
  18600. @item @code{tftp-port-range} (default: @code{#f})
  18601. If set, fixes the dynamical ports (one per client) to the given range
  18602. (@code{"<start>,<end>"}).
  18603. @item @code{tftp-root} (default: @code{/var/empty,lo})
  18604. Look for files to transfer using TFTP relative to the given directory.
  18605. When this is set, TFTP paths which include ".." are rejected, to stop clients
  18606. getting outside the specified root. Absolute paths (starting with /) are
  18607. allowed, but they must be within the tftp-root. If the optional interface
  18608. argument is given, the directory is only used for TFTP requests via that
  18609. interface.
  18610. @item @code{tftp-unique-root} (default: @code{#f})
  18611. If set, add the IP or hardware address of the TFTP client as a path component
  18612. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  18613. directory exists. Defaults to adding IP address (in standard dotted-quad
  18614. format).
  18615. For instance, if --tftp-root is "/tftp" and client 1.2.3.4 requests file
  18616. "myfile" then the effective path will be "/tftp/1.2.3.4/myfile" if
  18617. /tftp/1.2.3.4 exists or /tftp/myfile otherwise. When "=mac" is specified
  18618. it will append the MAC address instead, using lowercase zero padded digits
  18619. separated by dashes, e.g.: 01-02-03-04-aa-bb Note that resolving MAC
  18620. addresses is only possible if the client is in the local network or obtained
  18621. a DHCP lease from dnsmasq.
  18622. @end table
  18623. @end deftp
  18624. @subsubheading ddclient Service
  18625. @cindex ddclient
  18626. The ddclient service described below runs the ddclient daemon, which takes
  18627. care of automatically updating DNS entries for service providers such as
  18628. @uref{https://dyn.com/dns/, Dyn}.
  18629. The following example show instantiates the service with its default
  18630. configuration:
  18631. @lisp
  18632. (service ddclient-service-type)
  18633. @end lisp
  18634. Note that ddclient needs to access credentials that are stored in a
  18635. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  18636. @code{secret-file} below). You are expected to create this file manually, in
  18637. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  18638. service configuration, for instance by using @code{plain-file}, but it will be
  18639. world-readable @i{via} @file{/gnu/store}). See the examples in the
  18640. @file{share/ddclient} directory of the @code{ddclient} package.
  18641. @c %start of fragment
  18642. Available @code{ddclient-configuration} fields are:
  18643. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  18644. The ddclient package.
  18645. @end deftypevr
  18646. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  18647. The period after which ddclient will retry to check IP and domain name.
  18648. Defaults to @samp{300}.
  18649. @end deftypevr
  18650. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  18651. Use syslog for the output.
  18652. Defaults to @samp{#t}.
  18653. @end deftypevr
  18654. @deftypevr {@code{ddclient-configuration} parameter} string mail
  18655. Mail to user.
  18656. Defaults to @samp{"root"}.
  18657. @end deftypevr
  18658. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  18659. Mail failed update to user.
  18660. Defaults to @samp{"root"}.
  18661. @end deftypevr
  18662. @deftypevr {@code{ddclient-configuration} parameter} string pid
  18663. The ddclient PID file.
  18664. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  18665. @end deftypevr
  18666. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  18667. Enable SSL support.
  18668. Defaults to @samp{#t}.
  18669. @end deftypevr
  18670. @deftypevr {@code{ddclient-configuration} parameter} string user
  18671. Specifies the user name or ID that is used when running ddclient
  18672. program.
  18673. Defaults to @samp{"ddclient"}.
  18674. @end deftypevr
  18675. @deftypevr {@code{ddclient-configuration} parameter} string group
  18676. Group of the user who will run the ddclient program.
  18677. Defaults to @samp{"ddclient"}.
  18678. @end deftypevr
  18679. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  18680. Secret file which will be appended to @file{ddclient.conf} file. This
  18681. file contains credentials for use by ddclient. You are expected to
  18682. create it manually.
  18683. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  18684. @end deftypevr
  18685. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  18686. Extra options will be appended to @file{ddclient.conf} file.
  18687. Defaults to @samp{()}.
  18688. @end deftypevr
  18689. @c %end of fragment
  18690. @node VPN Services
  18691. @subsection VPN Services
  18692. @cindex VPN (virtual private network)
  18693. @cindex virtual private network (VPN)
  18694. The @code{(gnu services vpn)} module provides services related to
  18695. @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
  18696. your machine to connect to a VPN, and a @emph{server} service for your machine
  18697. to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
  18698. @deffn {Scheme Procedure} openvpn-client-service @
  18699. [#:config (openvpn-client-configuration)]
  18700. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  18701. @end deffn
  18702. @deffn {Scheme Procedure} openvpn-server-service @
  18703. [#:config (openvpn-server-configuration)]
  18704. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  18705. Both can be run simultaneously.
  18706. @end deffn
  18707. @c %automatically generated documentation
  18708. Available @code{openvpn-client-configuration} fields are:
  18709. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  18710. The OpenVPN package.
  18711. @end deftypevr
  18712. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  18713. The OpenVPN pid file.
  18714. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  18715. @end deftypevr
  18716. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  18717. The protocol (UDP or TCP) used to open a channel between clients and
  18718. servers.
  18719. Defaults to @samp{udp}.
  18720. @end deftypevr
  18721. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  18722. The device type used to represent the VPN connection.
  18723. Defaults to @samp{tun}.
  18724. @end deftypevr
  18725. @deftypevr {@code{openvpn-client-configuration} parameter} string ca
  18726. The certificate authority to check connections against.
  18727. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  18728. @end deftypevr
  18729. @deftypevr {@code{openvpn-client-configuration} parameter} string cert
  18730. The certificate of the machine the daemon is running on. It should be
  18731. signed by the authority given in @code{ca}.
  18732. Defaults to @samp{"/etc/openvpn/client.crt"}.
  18733. @end deftypevr
  18734. @deftypevr {@code{openvpn-client-configuration} parameter} string key
  18735. The key of the machine the daemon is running on. It must be the key whose
  18736. certificate is @code{cert}.
  18737. Defaults to @samp{"/etc/openvpn/client.key"}.
  18738. @end deftypevr
  18739. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  18740. Whether to use the lzo compression algorithm.
  18741. Defaults to @samp{#t}.
  18742. @end deftypevr
  18743. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  18744. Don't re-read key files across SIGUSR1 or --ping-restart.
  18745. Defaults to @samp{#t}.
  18746. @end deftypevr
  18747. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  18748. Don't close and reopen TUN/TAP device or run up/down scripts across
  18749. SIGUSR1 or --ping-restart restarts.
  18750. Defaults to @samp{#t}.
  18751. @end deftypevr
  18752. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  18753. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  18754. poll/epoll/select prior to the write operation.
  18755. Defaults to @samp{#f}.
  18756. @end deftypevr
  18757. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  18758. Verbosity level.
  18759. Defaults to @samp{3}.
  18760. @end deftypevr
  18761. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  18762. Add an additional layer of HMAC authentication on top of the TLS control
  18763. channel to protect against DoS attacks.
  18764. Defaults to @samp{#f}.
  18765. @end deftypevr
  18766. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  18767. Authenticate with server using username/password. The option is a file
  18768. containing username/password on 2 lines. Do not use a file-like object as it
  18769. would be added to the store and readable by any user.
  18770. Defaults to @samp{'disabled}.
  18771. @end deftypevr
  18772. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  18773. Whether to check the server certificate has server usage extension.
  18774. Defaults to @samp{#t}.
  18775. @end deftypevr
  18776. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  18777. Bind to a specific local port number.
  18778. Defaults to @samp{#f}.
  18779. @end deftypevr
  18780. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  18781. Retry resolving server address.
  18782. Defaults to @samp{#t}.
  18783. @end deftypevr
  18784. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  18785. A list of remote servers to connect to.
  18786. Defaults to @samp{()}.
  18787. Available @code{openvpn-remote-configuration} fields are:
  18788. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  18789. Server name.
  18790. Defaults to @samp{"my-server"}.
  18791. @end deftypevr
  18792. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  18793. Port number the server listens to.
  18794. Defaults to @samp{1194}.
  18795. @end deftypevr
  18796. @end deftypevr
  18797. @c %end of automatic openvpn-client documentation
  18798. @c %automatically generated documentation
  18799. Available @code{openvpn-server-configuration} fields are:
  18800. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  18801. The OpenVPN package.
  18802. @end deftypevr
  18803. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  18804. The OpenVPN pid file.
  18805. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  18806. @end deftypevr
  18807. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  18808. The protocol (UDP or TCP) used to open a channel between clients and
  18809. servers.
  18810. Defaults to @samp{udp}.
  18811. @end deftypevr
  18812. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  18813. The device type used to represent the VPN connection.
  18814. Defaults to @samp{tun}.
  18815. @end deftypevr
  18816. @deftypevr {@code{openvpn-server-configuration} parameter} string ca
  18817. The certificate authority to check connections against.
  18818. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  18819. @end deftypevr
  18820. @deftypevr {@code{openvpn-server-configuration} parameter} string cert
  18821. The certificate of the machine the daemon is running on. It should be
  18822. signed by the authority given in @code{ca}.
  18823. Defaults to @samp{"/etc/openvpn/client.crt"}.
  18824. @end deftypevr
  18825. @deftypevr {@code{openvpn-server-configuration} parameter} string key
  18826. The key of the machine the daemon is running on. It must be the key whose
  18827. certificate is @code{cert}.
  18828. Defaults to @samp{"/etc/openvpn/client.key"}.
  18829. @end deftypevr
  18830. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  18831. Whether to use the lzo compression algorithm.
  18832. Defaults to @samp{#t}.
  18833. @end deftypevr
  18834. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  18835. Don't re-read key files across SIGUSR1 or --ping-restart.
  18836. Defaults to @samp{#t}.
  18837. @end deftypevr
  18838. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  18839. Don't close and reopen TUN/TAP device or run up/down scripts across
  18840. SIGUSR1 or --ping-restart restarts.
  18841. Defaults to @samp{#t}.
  18842. @end deftypevr
  18843. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  18844. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  18845. poll/epoll/select prior to the write operation.
  18846. Defaults to @samp{#f}.
  18847. @end deftypevr
  18848. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  18849. Verbosity level.
  18850. Defaults to @samp{3}.
  18851. @end deftypevr
  18852. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  18853. Add an additional layer of HMAC authentication on top of the TLS control
  18854. channel to protect against DoS attacks.
  18855. Defaults to @samp{#f}.
  18856. @end deftypevr
  18857. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  18858. Specifies the port number on which the server listens.
  18859. Defaults to @samp{1194}.
  18860. @end deftypevr
  18861. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  18862. An ip and mask specifying the subnet inside the virtual network.
  18863. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  18864. @end deftypevr
  18865. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  18866. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  18867. Defaults to @samp{#f}.
  18868. @end deftypevr
  18869. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  18870. The Diffie-Hellman parameters file.
  18871. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  18872. @end deftypevr
  18873. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  18874. The file that records client IPs.
  18875. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  18876. @end deftypevr
  18877. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  18878. When true, the server will act as a gateway for its clients.
  18879. Defaults to @samp{#f}.
  18880. @end deftypevr
  18881. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  18882. When true, clients are allowed to talk to each other inside the VPN.
  18883. Defaults to @samp{#f}.
  18884. @end deftypevr
  18885. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  18886. Causes ping-like messages to be sent back and forth over the link so
  18887. that each side knows when the other side has gone down. @code{keepalive}
  18888. requires a pair. The first element is the period of the ping sending,
  18889. and the second element is the timeout before considering the other side
  18890. down.
  18891. @end deftypevr
  18892. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  18893. The maximum number of clients.
  18894. Defaults to @samp{100}.
  18895. @end deftypevr
  18896. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  18897. The status file. This file shows a small report on current connection.
  18898. It is truncated and rewritten every minute.
  18899. Defaults to @samp{"/var/run/openvpn/status"}.
  18900. @end deftypevr
  18901. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  18902. The list of configuration for some clients.
  18903. Defaults to @samp{()}.
  18904. Available @code{openvpn-ccd-configuration} fields are:
  18905. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  18906. Client name.
  18907. Defaults to @samp{"client"}.
  18908. @end deftypevr
  18909. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  18910. Client own network
  18911. Defaults to @samp{#f}.
  18912. @end deftypevr
  18913. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  18914. Client VPN IP.
  18915. Defaults to @samp{#f}.
  18916. @end deftypevr
  18917. @end deftypevr
  18918. @c %end of automatic openvpn-server documentation
  18919. @node Network File System
  18920. @subsection Network File System
  18921. @cindex NFS
  18922. The @code{(gnu services nfs)} module provides the following services,
  18923. which are most commonly used in relation to mounting or exporting
  18924. directory trees as @dfn{network file systems} (NFS).
  18925. While it is possible to use the individual components that together make
  18926. up a Network File System service, we recommended to configure an NFS
  18927. server with the @code{nfs-service-type}.
  18928. @subsubheading NFS Service
  18929. @cindex NFS, server
  18930. The NFS service takes care of setting up all NFS component services,
  18931. kernel configuration file systems, and installs configuration files in
  18932. the locations that NFS expects.
  18933. @defvr {Scheme Variable} nfs-service-type
  18934. A service type for a complete NFS server.
  18935. @end defvr
  18936. @deftp {Data Type} nfs-configuration
  18937. This data type represents the configuration of the NFS service and all
  18938. of its subsystems.
  18939. It has the following parameters:
  18940. @table @asis
  18941. @item @code{nfs-utils} (default: @code{nfs-utils})
  18942. The nfs-utils package to use.
  18943. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  18944. If a list of string values is provided, the @command{rpc.nfsd} daemon
  18945. will be limited to supporting the given versions of the NFS protocol.
  18946. @item @code{exports} (default: @code{'()})
  18947. This is a list of directories the NFS server should export. Each entry
  18948. is a list consisting of two elements: a directory name and a string
  18949. containing all options. This is an example in which the directory
  18950. @file{/export} is served to all NFS clients as a read-only share:
  18951. @lisp
  18952. (nfs-configuration
  18953. (exports
  18954. '(("/export"
  18955. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  18956. @end lisp
  18957. @item @code{rpcmountd-port} (default: @code{#f})
  18958. The network port that the @command{rpc.mountd} daemon should use.
  18959. @item @code{rpcstatd-port} (default: @code{#f})
  18960. The network port that the @command{rpc.statd} daemon should use.
  18961. @item @code{rpcbind} (default: @code{rpcbind})
  18962. The rpcbind package to use.
  18963. @item @code{idmap-domain} (default: @code{"localdomain"})
  18964. The local NFSv4 domain name.
  18965. @item @code{nfsd-port} (default: @code{2049})
  18966. The network port that the @command{nfsd} daemon should use.
  18967. @item @code{nfsd-threads} (default: @code{8})
  18968. The number of threads used by the @command{nfsd} daemon.
  18969. @item @code{nfsd-tcp?} (default: @code{#t})
  18970. Whether the @command{nfsd} daemon should listen on a TCP socket.
  18971. @item @code{nfsd-udp?} (default: @code{#f})
  18972. Whether the @command{nfsd} daemon should listen on a UDP socket.
  18973. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  18974. The directory where the pipefs file system is mounted.
  18975. @item @code{debug} (default: @code{'()"})
  18976. A list of subsystems for which debugging output should be enabled. This
  18977. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  18978. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  18979. @end table
  18980. @end deftp
  18981. If you don't need a complete NFS service or prefer to build it yourself
  18982. you can use the individual component services that are documented below.
  18983. @subsubheading RPC Bind Service
  18984. @cindex rpcbind
  18985. The RPC Bind service provides a facility to map program numbers into
  18986. universal addresses.
  18987. Many NFS related services use this facility. Hence it is automatically
  18988. started when a dependent service starts.
  18989. @defvr {Scheme Variable} rpcbind-service-type
  18990. A service type for the RPC portmapper daemon.
  18991. @end defvr
  18992. @deftp {Data Type} rpcbind-configuration
  18993. Data type representing the configuration of the RPC Bind Service.
  18994. This type has the following parameters:
  18995. @table @asis
  18996. @item @code{rpcbind} (default: @code{rpcbind})
  18997. The rpcbind package to use.
  18998. @item @code{warm-start?} (default: @code{#t})
  18999. If this parameter is @code{#t}, then the daemon will read a
  19000. state file on startup thus reloading state information saved by a previous
  19001. instance.
  19002. @end table
  19003. @end deftp
  19004. @subsubheading Pipefs Pseudo File System
  19005. @cindex pipefs
  19006. @cindex rpc_pipefs
  19007. The pipefs file system is used to transfer NFS related data
  19008. between the kernel and user space programs.
  19009. @defvr {Scheme Variable} pipefs-service-type
  19010. A service type for the pipefs pseudo file system.
  19011. @end defvr
  19012. @deftp {Data Type} pipefs-configuration
  19013. Data type representing the configuration of the pipefs pseudo file system service.
  19014. This type has the following parameters:
  19015. @table @asis
  19016. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  19017. The directory to which the file system is to be attached.
  19018. @end table
  19019. @end deftp
  19020. @subsubheading GSS Daemon Service
  19021. @cindex GSSD
  19022. @cindex GSS
  19023. @cindex global security system
  19024. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  19025. based protocols.
  19026. Before exchanging RPC requests an RPC client must establish a security
  19027. context. Typically this is done using the Kerberos command @command{kinit}
  19028. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  19029. @defvr {Scheme Variable} gss-service-type
  19030. A service type for the Global Security System (GSS) daemon.
  19031. @end defvr
  19032. @deftp {Data Type} gss-configuration
  19033. Data type representing the configuration of the GSS daemon service.
  19034. This type has the following parameters:
  19035. @table @asis
  19036. @item @code{nfs-utils} (default: @code{nfs-utils})
  19037. The package in which the @command{rpc.gssd} command is to be found.
  19038. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  19039. The directory where the pipefs file system is mounted.
  19040. @end table
  19041. @end deftp
  19042. @subsubheading IDMAP Daemon Service
  19043. @cindex idmapd
  19044. @cindex name mapper
  19045. The idmap daemon service provides mapping between user IDs and user names.
  19046. Typically it is required in order to access file systems mounted via NFSv4.
  19047. @defvr {Scheme Variable} idmap-service-type
  19048. A service type for the Identity Mapper (IDMAP) daemon.
  19049. @end defvr
  19050. @deftp {Data Type} idmap-configuration
  19051. Data type representing the configuration of the IDMAP daemon service.
  19052. This type has the following parameters:
  19053. @table @asis
  19054. @item @code{nfs-utils} (default: @code{nfs-utils})
  19055. The package in which the @command{rpc.idmapd} command is to be found.
  19056. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  19057. The directory where the pipefs file system is mounted.
  19058. @item @code{domain} (default: @code{#f})
  19059. The local NFSv4 domain name.
  19060. This must be a string or @code{#f}.
  19061. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  19062. @item @code{verbosity} (default: @code{0})
  19063. The verbosity level of the daemon.
  19064. @end table
  19065. @end deftp
  19066. @node Continuous Integration
  19067. @subsection Continuous Integration
  19068. @cindex continuous integration
  19069. @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
  19070. continuous integration tool for Guix. It can be used both for development and
  19071. for providing substitutes to others (@pxref{Substitutes}).
  19072. The @code{(gnu services cuirass)} module provides the following service.
  19073. @defvr {Scheme Procedure} cuirass-service-type
  19074. The type of the Cuirass service. Its value must be a
  19075. @code{cuirass-configuration} object, as described below.
  19076. @end defvr
  19077. To add build jobs, you have to set the @code{specifications} field of the
  19078. configuration. Here is an example of a service that polls the Guix repository
  19079. and builds the packages from a manifest. Some of the packages are defined in
  19080. the @code{"custom-packages"} input, which is the equivalent of
  19081. @env{GUIX_PACKAGE_PATH}.
  19082. @lisp
  19083. (define %cuirass-specs
  19084. #~(list
  19085. '((#:name . "my-manifest")
  19086. (#:load-path-inputs . ("guix"))
  19087. (#:package-path-inputs . ("custom-packages"))
  19088. (#:proc-input . "guix")
  19089. (#:proc-file . "build-aux/cuirass/gnu-system.scm")
  19090. (#:proc . cuirass-jobs)
  19091. (#:proc-args . ((subset . "manifests")
  19092. (systems . ("x86_64-linux"))
  19093. (manifests . (("config" . "guix/manifest.scm")))))
  19094. (#:inputs . (((#:name . "guix")
  19095. (#:url . "git://git.savannah.gnu.org/guix.git")
  19096. (#:load-path . ".")
  19097. (#:branch . "master")
  19098. (#:no-compile? . #t))
  19099. ((#:name . "config")
  19100. (#:url . "https://git.example.org/config.git")
  19101. (#:load-path . ".")
  19102. (#:branch . "master")
  19103. (#:no-compile? . #t))
  19104. ((#:name . "custom-packages")
  19105. (#:url . "https://git.example.org/custom-packages.git")
  19106. (#:load-path . ".")
  19107. (#:branch . "master")
  19108. (#:no-compile? . #t)))))))
  19109. (service cuirass-service-type
  19110. (cuirass-configuration
  19111. (specifications %cuirass-specs)))
  19112. @end lisp
  19113. While information related to build jobs is located directly in the
  19114. specifications, global settings for the @command{cuirass} process are
  19115. accessible in other @code{cuirass-configuration} fields.
  19116. @deftp {Data Type} cuirass-configuration
  19117. Data type representing the configuration of Cuirass.
  19118. @table @asis
  19119. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  19120. Location of the log file.
  19121. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  19122. Location of the log file used by the web interface.
  19123. @item @code{queries-log-file} (default: @code{#f})
  19124. Location of the SQL queries log file. By default, SQL queries logging is
  19125. disabled.
  19126. @item @code{web-queries-log-file} (default: @code{#f})
  19127. Location of the web SQL queries log file. By default, web SQL queries
  19128. logging is disabled.
  19129. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  19130. Location of the repository cache.
  19131. @item @code{user} (default: @code{"cuirass"})
  19132. Owner of the @code{cuirass} process.
  19133. @item @code{group} (default: @code{"cuirass"})
  19134. Owner's group of the @code{cuirass} process.
  19135. @item @code{interval} (default: @code{60})
  19136. Number of seconds between the poll of the repositories followed by the
  19137. Cuirass jobs.
  19138. @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
  19139. Location of sqlite database which contains the build results and previously
  19140. added specifications.
  19141. @item @code{ttl} (default: @code{(* 30 24 3600)})
  19142. Specifies the time-to-live (TTL) in seconds of garbage collector roots that
  19143. are registered for build results. This means that build results are protected
  19144. from garbage collection for at least @var{ttl} seconds.
  19145. @item @code{port} (default: @code{8081})
  19146. Port number used by the HTTP server.
  19147. @item @code{host} (default: @code{"localhost"})
  19148. Listen on the network interface for @var{host}. The default is to
  19149. accept connections from localhost.
  19150. @item @code{specifications} (default: @code{#~'()})
  19151. A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
  19152. where a specification is an association list
  19153. (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
  19154. keys are keywords (@code{#:keyword-example}) as shown in the example
  19155. above.
  19156. @item @code{use-substitutes?} (default: @code{#f})
  19157. This allows using substitutes to avoid building every dependencies of a job
  19158. from source.
  19159. @item @code{one-shot?} (default: @code{#f})
  19160. Only evaluate specifications and build derivations once.
  19161. @item @code{fallback?} (default: @code{#f})
  19162. When substituting a pre-built binary fails, fall back to building
  19163. packages locally.
  19164. @item @code{extra-options} (default: @code{'()})
  19165. Extra options to pass when running the Cuirass processes.
  19166. @item @code{cuirass} (default: @code{cuirass})
  19167. The Cuirass package to use.
  19168. @end table
  19169. @end deftp
  19170. @node Power Management Services
  19171. @subsection Power Management Services
  19172. @cindex tlp
  19173. @cindex power management with TLP
  19174. @subsubheading TLP daemon
  19175. The @code{(gnu services pm)} module provides a Guix service definition
  19176. for the Linux power management tool TLP.
  19177. TLP enables various powersaving modes in userspace and kernel.
  19178. Contrary to @code{upower-service}, it is not a passive,
  19179. monitoring tool, as it will apply custom settings each time a new power
  19180. source is detected. More information can be found at
  19181. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  19182. @deffn {Scheme Variable} tlp-service-type
  19183. The service type for the TLP tool. The default settings are optimised
  19184. for battery life on most systems, but you can tweak them to your heart's
  19185. content by adding a valid @code{tlp-configuration}:
  19186. @lisp
  19187. (service tlp-service-type
  19188. (tlp-configuration
  19189. (cpu-scaling-governor-on-ac (list "performance"))
  19190. (sched-powersave-on-bat? #t)))
  19191. @end lisp
  19192. @end deffn
  19193. Each parameter definition is preceded by its type; for example,
  19194. @samp{boolean foo} indicates that the @code{foo} parameter
  19195. should be specified as a boolean. Types starting with
  19196. @code{maybe-} denote parameters that won't show up in TLP config file
  19197. when their value is @code{'disabled}.
  19198. @c The following documentation was initially generated by
  19199. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  19200. @c documentation is better, so we shouldn't hesitate to edit below as
  19201. @c needed. However if the change you want to make to this documentation
  19202. @c can be done in an automated way, it's probably easier to change
  19203. @c (generate-documentation) than to make it below and have to deal with
  19204. @c the churn as TLP updates.
  19205. Available @code{tlp-configuration} fields are:
  19206. @deftypevr {@code{tlp-configuration} parameter} package tlp
  19207. The TLP package.
  19208. @end deftypevr
  19209. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  19210. Set to true if you wish to enable TLP.
  19211. Defaults to @samp{#t}.
  19212. @end deftypevr
  19213. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  19214. Default mode when no power supply can be detected. Alternatives are AC
  19215. and BAT.
  19216. Defaults to @samp{"AC"}.
  19217. @end deftypevr
  19218. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  19219. Number of seconds Linux kernel has to wait after the disk goes idle,
  19220. before syncing on AC.
  19221. Defaults to @samp{0}.
  19222. @end deftypevr
  19223. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  19224. Same as @code{disk-idle-ac} but on BAT mode.
  19225. Defaults to @samp{2}.
  19226. @end deftypevr
  19227. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  19228. Dirty pages flushing periodicity, expressed in seconds.
  19229. Defaults to @samp{15}.
  19230. @end deftypevr
  19231. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  19232. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  19233. Defaults to @samp{60}.
  19234. @end deftypevr
  19235. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  19236. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  19237. alternatives are powersave and performance. With acpi-cpufreq driver,
  19238. alternatives are ondemand, powersave, performance and conservative.
  19239. Defaults to @samp{disabled}.
  19240. @end deftypevr
  19241. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  19242. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  19243. Defaults to @samp{disabled}.
  19244. @end deftypevr
  19245. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  19246. Set the min available frequency for the scaling governor on AC.
  19247. Defaults to @samp{disabled}.
  19248. @end deftypevr
  19249. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  19250. Set the max available frequency for the scaling governor on AC.
  19251. Defaults to @samp{disabled}.
  19252. @end deftypevr
  19253. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  19254. Set the min available frequency for the scaling governor on BAT.
  19255. Defaults to @samp{disabled}.
  19256. @end deftypevr
  19257. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  19258. Set the max available frequency for the scaling governor on BAT.
  19259. Defaults to @samp{disabled}.
  19260. @end deftypevr
  19261. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  19262. Limit the min P-state to control the power dissipation of the CPU, in AC
  19263. mode. Values are stated as a percentage of the available performance.
  19264. Defaults to @samp{disabled}.
  19265. @end deftypevr
  19266. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  19267. Limit the max P-state to control the power dissipation of the CPU, in AC
  19268. mode. Values are stated as a percentage of the available performance.
  19269. Defaults to @samp{disabled}.
  19270. @end deftypevr
  19271. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  19272. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  19273. Defaults to @samp{disabled}.
  19274. @end deftypevr
  19275. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  19276. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  19277. Defaults to @samp{disabled}.
  19278. @end deftypevr
  19279. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  19280. Enable CPU turbo boost feature on AC mode.
  19281. Defaults to @samp{disabled}.
  19282. @end deftypevr
  19283. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  19284. Same as @code{cpu-boost-on-ac?} on BAT mode.
  19285. Defaults to @samp{disabled}.
  19286. @end deftypevr
  19287. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  19288. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  19289. used under light load conditions.
  19290. Defaults to @samp{#f}.
  19291. @end deftypevr
  19292. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  19293. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  19294. Defaults to @samp{#t}.
  19295. @end deftypevr
  19296. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  19297. Enable Linux kernel NMI watchdog.
  19298. Defaults to @samp{#f}.
  19299. @end deftypevr
  19300. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  19301. For Linux kernels with PHC patch applied, change CPU voltages. An
  19302. example value would be @samp{"F:V F:V F:V F:V"}.
  19303. Defaults to @samp{disabled}.
  19304. @end deftypevr
  19305. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  19306. Set CPU performance versus energy saving policy on AC. Alternatives are
  19307. performance, normal, powersave.
  19308. Defaults to @samp{"performance"}.
  19309. @end deftypevr
  19310. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  19311. Same as @code{energy-perf-policy-ac} but on BAT mode.
  19312. Defaults to @samp{"powersave"}.
  19313. @end deftypevr
  19314. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  19315. Hard disk devices.
  19316. @end deftypevr
  19317. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  19318. Hard disk advanced power management level.
  19319. @end deftypevr
  19320. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  19321. Same as @code{disk-apm-bat} but on BAT mode.
  19322. @end deftypevr
  19323. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  19324. Hard disk spin down timeout. One value has to be specified for each
  19325. declared hard disk.
  19326. Defaults to @samp{disabled}.
  19327. @end deftypevr
  19328. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  19329. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  19330. Defaults to @samp{disabled}.
  19331. @end deftypevr
  19332. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  19333. Select IO scheduler for disk devices. One value has to be specified for
  19334. each declared hard disk. Example alternatives are cfq, deadline and
  19335. noop.
  19336. Defaults to @samp{disabled}.
  19337. @end deftypevr
  19338. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  19339. SATA aggressive link power management (ALPM) level. Alternatives are
  19340. min_power, medium_power, max_performance.
  19341. Defaults to @samp{"max_performance"}.
  19342. @end deftypevr
  19343. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  19344. Same as @code{sata-linkpwr-ac} but on BAT mode.
  19345. Defaults to @samp{"min_power"}.
  19346. @end deftypevr
  19347. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  19348. Exclude specified SATA host devices for link power management.
  19349. Defaults to @samp{disabled}.
  19350. @end deftypevr
  19351. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  19352. Enable Runtime Power Management for AHCI controller and disks on AC
  19353. mode.
  19354. Defaults to @samp{disabled}.
  19355. @end deftypevr
  19356. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  19357. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  19358. Defaults to @samp{disabled}.
  19359. @end deftypevr
  19360. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  19361. Seconds of inactivity before disk is suspended.
  19362. Defaults to @samp{15}.
  19363. @end deftypevr
  19364. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  19365. PCI Express Active State Power Management level. Alternatives are
  19366. default, performance, powersave.
  19367. Defaults to @samp{"performance"}.
  19368. @end deftypevr
  19369. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  19370. Same as @code{pcie-aspm-ac} but on BAT mode.
  19371. Defaults to @samp{"powersave"}.
  19372. @end deftypevr
  19373. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  19374. Radeon graphics clock speed level. Alternatives are low, mid, high,
  19375. auto, default.
  19376. Defaults to @samp{"high"}.
  19377. @end deftypevr
  19378. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  19379. Same as @code{radeon-power-ac} but on BAT mode.
  19380. Defaults to @samp{"low"}.
  19381. @end deftypevr
  19382. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  19383. Radeon dynamic power management method (DPM). Alternatives are battery,
  19384. performance.
  19385. Defaults to @samp{"performance"}.
  19386. @end deftypevr
  19387. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  19388. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  19389. Defaults to @samp{"battery"}.
  19390. @end deftypevr
  19391. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  19392. Radeon DPM performance level. Alternatives are auto, low, high.
  19393. Defaults to @samp{"auto"}.
  19394. @end deftypevr
  19395. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  19396. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  19397. Defaults to @samp{"auto"}.
  19398. @end deftypevr
  19399. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  19400. Wifi power saving mode.
  19401. Defaults to @samp{#f}.
  19402. @end deftypevr
  19403. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  19404. Same as @code{wifi-power-ac?} but on BAT mode.
  19405. Defaults to @samp{#t}.
  19406. @end deftypevr
  19407. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  19408. Disable wake on LAN.
  19409. Defaults to @samp{#t}.
  19410. @end deftypevr
  19411. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  19412. Timeout duration in seconds before activating audio power saving on
  19413. Intel HDA and AC97 devices. A value of 0 disables power saving.
  19414. Defaults to @samp{0}.
  19415. @end deftypevr
  19416. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  19417. Same as @code{sound-powersave-ac} but on BAT mode.
  19418. Defaults to @samp{1}.
  19419. @end deftypevr
  19420. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  19421. Disable controller in powersaving mode on Intel HDA devices.
  19422. Defaults to @samp{#t}.
  19423. @end deftypevr
  19424. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  19425. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  19426. powered on again by releasing (and reinserting) the eject lever or by
  19427. pressing the disc eject button on newer models.
  19428. Defaults to @samp{#f}.
  19429. @end deftypevr
  19430. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  19431. Name of the optical drive device to power off.
  19432. Defaults to @samp{"sr0"}.
  19433. @end deftypevr
  19434. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  19435. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  19436. and auto.
  19437. Defaults to @samp{"on"}.
  19438. @end deftypevr
  19439. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  19440. Same as @code{runtime-pm-ac} but on BAT mode.
  19441. Defaults to @samp{"auto"}.
  19442. @end deftypevr
  19443. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  19444. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  19445. ones.
  19446. Defaults to @samp{#t}.
  19447. @end deftypevr
  19448. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  19449. Exclude specified PCI(e) device addresses from Runtime Power Management.
  19450. Defaults to @samp{disabled}.
  19451. @end deftypevr
  19452. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  19453. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  19454. Power Management.
  19455. @end deftypevr
  19456. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  19457. Enable USB autosuspend feature.
  19458. Defaults to @samp{#t}.
  19459. @end deftypevr
  19460. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  19461. Exclude specified devices from USB autosuspend.
  19462. Defaults to @samp{disabled}.
  19463. @end deftypevr
  19464. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  19465. Exclude WWAN devices from USB autosuspend.
  19466. Defaults to @samp{#t}.
  19467. @end deftypevr
  19468. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  19469. Include specified devices into USB autosuspend, even if they are already
  19470. excluded by the driver or via @code{usb-blacklist-wwan?}.
  19471. Defaults to @samp{disabled}.
  19472. @end deftypevr
  19473. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  19474. Enable USB autosuspend before shutdown.
  19475. Defaults to @samp{disabled}.
  19476. @end deftypevr
  19477. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  19478. Restore radio device state (bluetooth, wifi, wwan) from previous
  19479. shutdown on system startup.
  19480. Defaults to @samp{#f}.
  19481. @end deftypevr
  19482. @cindex thermald
  19483. @cindex CPU frequency scaling with thermald
  19484. @subsubheading Thermald daemon
  19485. The @code{(gnu services pm)} module provides an interface to
  19486. thermald, a CPU frequency scaling service which helps prevent overheating.
  19487. @defvr {Scheme Variable} thermald-service-type
  19488. This is the service type for
  19489. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  19490. Thermal Daemon, which is responsible for controlling the thermal state
  19491. of processors and preventing overheating.
  19492. @end defvr
  19493. @deftp {Data Type} thermald-configuration
  19494. Data type representing the configuration of @code{thermald-service-type}.
  19495. @table @asis
  19496. @item @code{ignore-cpuid-check?} (default: @code{#f})
  19497. Ignore cpuid check for supported CPU models.
  19498. @item @code{thermald} (default: @var{thermald})
  19499. Package object of thermald.
  19500. @end table
  19501. @end deftp
  19502. @node Audio Services
  19503. @subsection Audio Services
  19504. The @code{(gnu services audio)} module provides a service to start MPD
  19505. (the Music Player Daemon).
  19506. @cindex mpd
  19507. @subsubheading Music Player Daemon
  19508. The Music Player Daemon (MPD) is a service that can play music while
  19509. being controlled from the local machine or over the network by a variety
  19510. of clients.
  19511. The following example shows how one might run @code{mpd} as user
  19512. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  19513. @lisp
  19514. (service mpd-service-type
  19515. (mpd-configuration
  19516. (user "bob")
  19517. (port "6666")))
  19518. @end lisp
  19519. @defvr {Scheme Variable} mpd-service-type
  19520. The service type for @command{mpd}
  19521. @end defvr
  19522. @deftp {Data Type} mpd-configuration
  19523. Data type representing the configuration of @command{mpd}.
  19524. @table @asis
  19525. @item @code{user} (default: @code{"mpd"})
  19526. The user to run mpd as.
  19527. @item @code{music-dir} (default: @code{"~/Music"})
  19528. The directory to scan for music files.
  19529. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  19530. The directory to store playlists.
  19531. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  19532. The location of the music database.
  19533. @item @code{state-file} (default: @code{"~/.mpd/state"})
  19534. The location of the file that stores current MPD's state.
  19535. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  19536. The location of the sticker database.
  19537. @item @code{port} (default: @code{"6600"})
  19538. The port to run mpd on.
  19539. @item @code{address} (default: @code{"any"})
  19540. The address that mpd will bind to. To use a Unix domain socket,
  19541. an absolute path can be specified here.
  19542. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  19543. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  19544. @end table
  19545. @end deftp
  19546. @deftp {Data Type} mpd-output
  19547. Data type representing an @command{mpd} audio output.
  19548. @table @asis
  19549. @item @code{name} (default: @code{"MPD"})
  19550. The name of the audio output.
  19551. @item @code{type} (default: @code{"pulse"})
  19552. The type of audio output.
  19553. @item @code{enabled?} (default: @code{#t})
  19554. Specifies whether this audio output is enabled when MPD is started. By
  19555. default, all audio outputs are enabled. This is just the default
  19556. setting when there is no state file; with a state file, the previous
  19557. state is restored.
  19558. @item @code{tags?} (default: @code{#t})
  19559. If set to @code{#f}, then MPD will not send tags to this output. This
  19560. is only useful for output plugins that can receive tags, for example the
  19561. @code{httpd} output plugin.
  19562. @item @code{always-on?} (default: @code{#f})
  19563. If set to @code{#t}, then MPD attempts to keep this audio output always
  19564. open. This may be useful for streaming servers, when you don’t want to
  19565. disconnect all listeners even when playback is accidentally stopped.
  19566. @item @code{mixer-type}
  19567. This field accepts a symbol that specifies which mixer should be used
  19568. for this audio output: the @code{hardware} mixer, the @code{software}
  19569. mixer, the @code{null} mixer (allows setting the volume, but with no
  19570. effect; this can be used as a trick to implement an external mixer
  19571. External Mixer) or no mixer (@code{none}).
  19572. @item @code{extra-options} (default: @code{'()"})
  19573. An association list of option symbols to string values to be appended to
  19574. the audio output configuration.
  19575. @end table
  19576. @end deftp
  19577. The following example shows a configuration of @code{mpd} that provides
  19578. an HTTP audio streaming output.
  19579. @lisp
  19580. (service mpd-service-type
  19581. (mpd-configuration
  19582. (outputs
  19583. (list (mpd-output
  19584. (name "streaming")
  19585. (type "httpd")
  19586. (mixer-type 'null)
  19587. (extra-options
  19588. `((encoder . "vorbis")
  19589. (port . "8080"))))))))
  19590. @end lisp
  19591. @node Virtualization Services
  19592. @subsection Virtualization services
  19593. The @code{(gnu services virtualization)} module provides services for
  19594. the libvirt and virtlog daemons, as well as other virtualization-related
  19595. services.
  19596. @subsubheading Libvirt daemon
  19597. @code{libvirtd} is the server side daemon component of the libvirt
  19598. virtualization management system. This daemon runs on host servers
  19599. and performs required management tasks for virtualized guests.
  19600. @deffn {Scheme Variable} libvirt-service-type
  19601. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  19602. Its value must be a @code{libvirt-configuration}.
  19603. @lisp
  19604. (service libvirt-service-type
  19605. (libvirt-configuration
  19606. (unix-sock-group "libvirt")
  19607. (tls-port "16555")))
  19608. @end lisp
  19609. @end deffn
  19610. @c Auto-generated with (generate-libvirt-documentation)
  19611. Available @code{libvirt-configuration} fields are:
  19612. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  19613. Libvirt package.
  19614. @end deftypevr
  19615. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  19616. Flag listening for secure TLS connections on the public TCP/IP port.
  19617. must set @code{listen} for this to have any effect.
  19618. It is necessary to setup a CA and issue server certificates before using
  19619. this capability.
  19620. Defaults to @samp{#t}.
  19621. @end deftypevr
  19622. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  19623. Listen for unencrypted TCP connections on the public TCP/IP port. must
  19624. set @code{listen} for this to have any effect.
  19625. Using the TCP socket requires SASL authentication by default. Only SASL
  19626. mechanisms which support data encryption are allowed. This is
  19627. DIGEST_MD5 and GSSAPI (Kerberos5)
  19628. Defaults to @samp{#f}.
  19629. @end deftypevr
  19630. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  19631. Port for accepting secure TLS connections This can be a port number, or
  19632. service name
  19633. Defaults to @samp{"16514"}.
  19634. @end deftypevr
  19635. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  19636. Port for accepting insecure TCP connections This can be a port number,
  19637. or service name
  19638. Defaults to @samp{"16509"}.
  19639. @end deftypevr
  19640. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  19641. IP address or hostname used for client connections.
  19642. Defaults to @samp{"0.0.0.0"}.
  19643. @end deftypevr
  19644. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  19645. Flag toggling mDNS advertisement of the libvirt service.
  19646. Alternatively can disable for all services on a host by stopping the
  19647. Avahi daemon.
  19648. Defaults to @samp{#f}.
  19649. @end deftypevr
  19650. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  19651. Default mDNS advertisement name. This must be unique on the immediate
  19652. broadcast network.
  19653. Defaults to @samp{"Virtualization Host <hostname>"}.
  19654. @end deftypevr
  19655. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  19656. UNIX domain socket group ownership. This can be used to allow a
  19657. 'trusted' set of users access to management capabilities without
  19658. becoming root.
  19659. Defaults to @samp{"root"}.
  19660. @end deftypevr
  19661. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  19662. UNIX socket permissions for the R/O socket. This is used for monitoring
  19663. VM status only.
  19664. Defaults to @samp{"0777"}.
  19665. @end deftypevr
  19666. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  19667. UNIX socket permissions for the R/W socket. Default allows only root.
  19668. If PolicyKit is enabled on the socket, the default will change to allow
  19669. everyone (eg, 0777)
  19670. Defaults to @samp{"0770"}.
  19671. @end deftypevr
  19672. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  19673. UNIX socket permissions for the admin socket. Default allows only owner
  19674. (root), do not change it unless you are sure to whom you are exposing
  19675. the access to.
  19676. Defaults to @samp{"0777"}.
  19677. @end deftypevr
  19678. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  19679. The directory in which sockets will be found/created.
  19680. Defaults to @samp{"/var/run/libvirt"}.
  19681. @end deftypevr
  19682. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  19683. Authentication scheme for UNIX read-only sockets. By default socket
  19684. permissions allow anyone to connect
  19685. Defaults to @samp{"polkit"}.
  19686. @end deftypevr
  19687. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  19688. Authentication scheme for UNIX read-write sockets. By default socket
  19689. permissions only allow root. If PolicyKit support was compiled into
  19690. libvirt, the default will be to use 'polkit' auth.
  19691. Defaults to @samp{"polkit"}.
  19692. @end deftypevr
  19693. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  19694. Authentication scheme for TCP sockets. If you don't enable SASL, then
  19695. all TCP traffic is cleartext. Don't do this outside of a dev/test
  19696. scenario.
  19697. Defaults to @samp{"sasl"}.
  19698. @end deftypevr
  19699. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  19700. Authentication scheme for TLS sockets. TLS sockets already have
  19701. encryption provided by the TLS layer, and limited authentication is done
  19702. by certificates.
  19703. It is possible to make use of any SASL authentication mechanism as well,
  19704. by using 'sasl' for this option
  19705. Defaults to @samp{"none"}.
  19706. @end deftypevr
  19707. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  19708. API access control scheme.
  19709. By default an authenticated user is allowed access to all APIs. Access
  19710. drivers can place restrictions on this.
  19711. Defaults to @samp{()}.
  19712. @end deftypevr
  19713. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  19714. Server key file path. If set to an empty string, then no private key is
  19715. loaded.
  19716. Defaults to @samp{""}.
  19717. @end deftypevr
  19718. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  19719. Server key file path. If set to an empty string, then no certificate is
  19720. loaded.
  19721. Defaults to @samp{""}.
  19722. @end deftypevr
  19723. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  19724. Server key file path. If set to an empty string, then no CA certificate
  19725. is loaded.
  19726. Defaults to @samp{""}.
  19727. @end deftypevr
  19728. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  19729. Certificate revocation list path. If set to an empty string, then no
  19730. CRL is loaded.
  19731. Defaults to @samp{""}.
  19732. @end deftypevr
  19733. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  19734. Disable verification of our own server certificates.
  19735. When libvirtd starts it performs some sanity checks against its own
  19736. certificates.
  19737. Defaults to @samp{#f}.
  19738. @end deftypevr
  19739. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  19740. Disable verification of client certificates.
  19741. Client certificate verification is the primary authentication mechanism.
  19742. Any client which does not present a certificate signed by the CA will be
  19743. rejected.
  19744. Defaults to @samp{#f}.
  19745. @end deftypevr
  19746. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  19747. Whitelist of allowed x509 Distinguished Name.
  19748. Defaults to @samp{()}.
  19749. @end deftypevr
  19750. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  19751. Whitelist of allowed SASL usernames. The format for username depends on
  19752. the SASL authentication mechanism.
  19753. Defaults to @samp{()}.
  19754. @end deftypevr
  19755. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  19756. Override the compile time default TLS priority string. The default is
  19757. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  19758. is desired for libvirt to deviate from the global default settings.
  19759. Defaults to @samp{"NORMAL"}.
  19760. @end deftypevr
  19761. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  19762. Maximum number of concurrent client connections to allow over all
  19763. sockets combined.
  19764. Defaults to @samp{5000}.
  19765. @end deftypevr
  19766. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  19767. Maximum length of queue of connections waiting to be accepted by the
  19768. daemon. Note, that some protocols supporting retransmission may obey
  19769. this so that a later reattempt at connection succeeds.
  19770. Defaults to @samp{1000}.
  19771. @end deftypevr
  19772. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  19773. Maximum length of queue of accepted but not yet authenticated clients.
  19774. Set this to zero to turn this feature off
  19775. Defaults to @samp{20}.
  19776. @end deftypevr
  19777. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  19778. Number of workers to start up initially.
  19779. Defaults to @samp{5}.
  19780. @end deftypevr
  19781. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  19782. Maximum number of worker threads.
  19783. If the number of active clients exceeds @code{min-workers}, then more
  19784. threads are spawned, up to max_workers limit. Typically you'd want
  19785. max_workers to equal maximum number of clients allowed.
  19786. Defaults to @samp{20}.
  19787. @end deftypevr
  19788. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  19789. Number of priority workers. If all workers from above pool are stuck,
  19790. some calls marked as high priority (notably domainDestroy) can be
  19791. executed in this pool.
  19792. Defaults to @samp{5}.
  19793. @end deftypevr
  19794. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  19795. Total global limit on concurrent RPC calls.
  19796. Defaults to @samp{20}.
  19797. @end deftypevr
  19798. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  19799. Limit on concurrent requests from a single client connection. To avoid
  19800. one client monopolizing the server this should be a small fraction of
  19801. the global max_requests and max_workers parameter.
  19802. Defaults to @samp{5}.
  19803. @end deftypevr
  19804. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  19805. Same as @code{min-workers} but for the admin interface.
  19806. Defaults to @samp{1}.
  19807. @end deftypevr
  19808. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  19809. Same as @code{max-workers} but for the admin interface.
  19810. Defaults to @samp{5}.
  19811. @end deftypevr
  19812. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  19813. Same as @code{max-clients} but for the admin interface.
  19814. Defaults to @samp{5}.
  19815. @end deftypevr
  19816. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  19817. Same as @code{max-queued-clients} but for the admin interface.
  19818. Defaults to @samp{5}.
  19819. @end deftypevr
  19820. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  19821. Same as @code{max-client-requests} but for the admin interface.
  19822. Defaults to @samp{5}.
  19823. @end deftypevr
  19824. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  19825. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  19826. Defaults to @samp{3}.
  19827. @end deftypevr
  19828. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  19829. Logging filters.
  19830. A filter allows to select a different logging level for a given category
  19831. of logs The format for a filter is one of:
  19832. @itemize @bullet
  19833. @item
  19834. x:name
  19835. @item
  19836. x:+name
  19837. @end itemize
  19838. where @code{name} is a string which is matched against the category
  19839. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  19840. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  19841. name in the filter can be a substring of the full category name, in
  19842. order to match multiple similar categories), the optional @samp{"+"}
  19843. prefix tells libvirt to log stack trace for each message matching name,
  19844. and @code{x} is the minimal level where matching messages should be
  19845. logged:
  19846. @itemize @bullet
  19847. @item
  19848. 1: DEBUG
  19849. @item
  19850. 2: INFO
  19851. @item
  19852. 3: WARNING
  19853. @item
  19854. 4: ERROR
  19855. @end itemize
  19856. Multiple filters can be defined in a single filters statement, they just
  19857. need to be separated by spaces.
  19858. Defaults to @samp{"3:remote 4:event"}.
  19859. @end deftypevr
  19860. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  19861. Logging outputs.
  19862. An output is one of the places to save logging information. The format
  19863. for an output can be:
  19864. @table @code
  19865. @item x:stderr
  19866. output goes to stderr
  19867. @item x:syslog:name
  19868. use syslog for the output and use the given name as the ident
  19869. @item x:file:file_path
  19870. output to a file, with the given filepath
  19871. @item x:journald
  19872. output to journald logging system
  19873. @end table
  19874. In all case the x prefix is the minimal level, acting as a filter
  19875. @itemize @bullet
  19876. @item
  19877. 1: DEBUG
  19878. @item
  19879. 2: INFO
  19880. @item
  19881. 3: WARNING
  19882. @item
  19883. 4: ERROR
  19884. @end itemize
  19885. Multiple outputs can be defined, they just need to be separated by
  19886. spaces.
  19887. Defaults to @samp{"3:stderr"}.
  19888. @end deftypevr
  19889. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  19890. Allows usage of the auditing subsystem to be altered
  19891. @itemize @bullet
  19892. @item
  19893. 0: disable all auditing
  19894. @item
  19895. 1: enable auditing, only if enabled on host
  19896. @item
  19897. 2: enable auditing, and exit if disabled on host.
  19898. @end itemize
  19899. Defaults to @samp{1}.
  19900. @end deftypevr
  19901. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  19902. Send audit messages via libvirt logging infrastructure.
  19903. Defaults to @samp{#f}.
  19904. @end deftypevr
  19905. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  19906. Host UUID. UUID must not have all digits be the same.
  19907. Defaults to @samp{""}.
  19908. @end deftypevr
  19909. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  19910. Source to read host UUID.
  19911. @itemize @bullet
  19912. @item
  19913. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  19914. @item
  19915. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  19916. @end itemize
  19917. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  19918. be generated.
  19919. Defaults to @samp{"smbios"}.
  19920. @end deftypevr
  19921. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  19922. A keepalive message is sent to a client after @code{keepalive_interval}
  19923. seconds of inactivity to check if the client is still responding. If
  19924. set to -1, libvirtd will never send keepalive requests; however clients
  19925. can still send them and the daemon will send responses.
  19926. Defaults to @samp{5}.
  19927. @end deftypevr
  19928. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  19929. Maximum number of keepalive messages that are allowed to be sent to the
  19930. client without getting any response before the connection is considered
  19931. broken.
  19932. In other words, the connection is automatically closed approximately
  19933. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  19934. the last message received from the client. When @code{keepalive-count}
  19935. is set to 0, connections will be automatically closed after
  19936. @code{keepalive-interval} seconds of inactivity without sending any
  19937. keepalive messages.
  19938. Defaults to @samp{5}.
  19939. @end deftypevr
  19940. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  19941. Same as above but for admin interface.
  19942. Defaults to @samp{5}.
  19943. @end deftypevr
  19944. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  19945. Same as above but for admin interface.
  19946. Defaults to @samp{5}.
  19947. @end deftypevr
  19948. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  19949. Timeout for Open vSwitch calls.
  19950. The @code{ovs-vsctl} utility is used for the configuration and its
  19951. timeout option is set by default to 5 seconds to avoid potential
  19952. infinite waits blocking libvirt.
  19953. Defaults to @samp{5}.
  19954. @end deftypevr
  19955. @c %end of autogenerated docs
  19956. @subsubheading Virtlog daemon
  19957. The virtlogd service is a server side daemon component of libvirt that is
  19958. used to manage logs from virtual machine consoles.
  19959. This daemon is not used directly by libvirt client applications, rather it
  19960. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  19961. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  19962. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  19963. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  19964. @deffn {Scheme Variable} virtlog-service-type
  19965. This is the type of the virtlog daemon.
  19966. Its value must be a @code{virtlog-configuration}.
  19967. @lisp
  19968. (service virtlog-service-type
  19969. (virtlog-configuration
  19970. (max-clients 1000)))
  19971. @end lisp
  19972. @end deffn
  19973. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  19974. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  19975. Defaults to @samp{3}.
  19976. @end deftypevr
  19977. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  19978. Logging filters.
  19979. A filter allows to select a different logging level for a given category
  19980. of logs The format for a filter is one of:
  19981. @itemize @bullet
  19982. @item
  19983. x:name
  19984. @item
  19985. x:+name
  19986. @end itemize
  19987. where @code{name} is a string which is matched against the category
  19988. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  19989. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  19990. be a substring of the full category name, in order to match multiple
  19991. similar categories), the optional "+" prefix tells libvirt to log stack
  19992. trace for each message matching name, and @code{x} is the minimal level
  19993. where matching messages should be logged:
  19994. @itemize @bullet
  19995. @item
  19996. 1: DEBUG
  19997. @item
  19998. 2: INFO
  19999. @item
  20000. 3: WARNING
  20001. @item
  20002. 4: ERROR
  20003. @end itemize
  20004. Multiple filters can be defined in a single filters statement, they just
  20005. need to be separated by spaces.
  20006. Defaults to @samp{"3:remote 4:event"}.
  20007. @end deftypevr
  20008. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  20009. Logging outputs.
  20010. An output is one of the places to save logging information The format
  20011. for an output can be:
  20012. @table @code
  20013. @item x:stderr
  20014. output goes to stderr
  20015. @item x:syslog:name
  20016. use syslog for the output and use the given name as the ident
  20017. @item x:file:file_path
  20018. output to a file, with the given filepath
  20019. @item x:journald
  20020. output to journald logging system
  20021. @end table
  20022. In all case the x prefix is the minimal level, acting as a filter
  20023. @itemize @bullet
  20024. @item
  20025. 1: DEBUG
  20026. @item
  20027. 2: INFO
  20028. @item
  20029. 3: WARNING
  20030. @item
  20031. 4: ERROR
  20032. @end itemize
  20033. Multiple outputs can be defined, they just need to be separated by
  20034. spaces.
  20035. Defaults to @samp{"3:stderr"}.
  20036. @end deftypevr
  20037. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  20038. Maximum number of concurrent client connections to allow over all
  20039. sockets combined.
  20040. Defaults to @samp{1024}.
  20041. @end deftypevr
  20042. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  20043. Maximum file size before rolling over.
  20044. Defaults to @samp{2MB}
  20045. @end deftypevr
  20046. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  20047. Maximum number of backup files to keep.
  20048. Defaults to @samp{3}
  20049. @end deftypevr
  20050. @node Transparent Emulation with QEMU
  20051. @subsubheading Transparent Emulation with QEMU
  20052. @cindex emulation
  20053. @cindex @code{binfmt_misc}
  20054. @code{qemu-binfmt-service-type} provides support for transparent
  20055. emulation of program binaries built for different architectures---e.g.,
  20056. it allows you to transparently execute an ARMv7 program on an x86_64
  20057. machine. It achieves this by combining the @uref{https://www.qemu.org,
  20058. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  20059. This feature only allows you to emulate GNU/Linux on a different
  20060. architecture, but see below for GNU/Hurd support.
  20061. @defvr {Scheme Variable} qemu-binfmt-service-type
  20062. This is the type of the QEMU/binfmt service for transparent emulation.
  20063. Its value must be a @code{qemu-binfmt-configuration} object, which
  20064. specifies the QEMU package to use as well as the architecture we want to
  20065. emulated:
  20066. @lisp
  20067. (service qemu-binfmt-service-type
  20068. (qemu-binfmt-configuration
  20069. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  20070. @end lisp
  20071. In this example, we enable transparent emulation for the ARM and aarch64
  20072. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  20073. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  20074. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  20075. @end defvr
  20076. @deftp {Data Type} qemu-binfmt-configuration
  20077. This is the configuration for the @code{qemu-binfmt} service.
  20078. @table @asis
  20079. @item @code{platforms} (default: @code{'()})
  20080. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  20081. object} as returned by @code{lookup-qemu-platforms} (see below).
  20082. @item @code{guix-support?} (default: @code{#f})
  20083. When it is true, QEMU and all its dependencies are added to the build
  20084. environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
  20085. @option{--chroot-directory} option}). This allows the @code{binfmt_misc}
  20086. handlers to be used within the build environment, which in turn means
  20087. that you can transparently build programs for another architecture.
  20088. For example, let's suppose you're on an x86_64 machine and you have this
  20089. service:
  20090. @lisp
  20091. (service qemu-binfmt-service-type
  20092. (qemu-binfmt-configuration
  20093. (platforms (lookup-qemu-platforms "arm"))
  20094. (guix-support? #t)))
  20095. @end lisp
  20096. You can run:
  20097. @example
  20098. guix build -s armhf-linux inkscape
  20099. @end example
  20100. @noindent
  20101. and it will build Inkscape for ARMv7 @emph{as if it were a native
  20102. build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
  20103. if you'd like to test a package build for an architecture you don't have
  20104. access to!
  20105. @item @code{qemu} (default: @code{qemu})
  20106. The QEMU package to use.
  20107. @end table
  20108. @end deftp
  20109. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  20110. Return the list of QEMU platform objects corresponding to
  20111. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  20112. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  20113. @code{"mips64el"}, and so on.
  20114. @end deffn
  20115. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  20116. Return true if @var{obj} is a platform object.
  20117. @end deffn
  20118. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  20119. Return the name of @var{platform}---a string such as @code{"arm"}.
  20120. @end deffn
  20121. @subsubheading The Hurd in a Virtual Machine
  20122. @cindex @code{hurd}
  20123. @cindex the Hurd
  20124. @cindex childhurd
  20125. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  20126. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  20127. to be used on GNU/Linux and the given GNU/Hurd operating system
  20128. configuration is cross-compiled. The virtual machine is a Shepherd
  20129. service that can be referred to by the names @code{hurd-vm} and
  20130. @code{childhurd} and be controlled with commands such as:
  20131. @example
  20132. herd start hurd-vm
  20133. herd stop childhurd
  20134. @end example
  20135. When the service is running, you can view its console by connecting to
  20136. it with a VNC client, for example with:
  20137. @example
  20138. guix environment --ad-hoc tigervnc-client -- \
  20139. vncviewer localhost:5900
  20140. @end example
  20141. The default configuration (see @code{hurd-vm-configuration} below)
  20142. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  20143. (the virtual machine emulator) redirects to port 10222 on the host.
  20144. Thus, you can connect over SSH to the childhurd with:
  20145. @example
  20146. ssh root@@localhost -p 10022
  20147. @end example
  20148. The childhurd is volatile and stateless: it starts with a fresh root
  20149. file system every time you restart it. By default though, all the files
  20150. under @file{/etc/childhurd} on the host are copied as is to the root
  20151. file system of the childhurd when it boots. This allows you to
  20152. initialize ``secrets'' inside the VM: SSH host keys, authorized
  20153. substitute keys, and so on---see the explanation of @code{secret-root}
  20154. below.
  20155. @defvr {Scheme Variable} hurd-vm-service-type
  20156. This is the type of the Hurd in a Virtual Machine service. Its value
  20157. must be a @code{hurd-vm-configuration} object, which specifies the
  20158. operating system (@pxref{operating-system Reference}) and the disk size
  20159. for the Hurd Virtual Machine, the QEMU package to use as well as the
  20160. options for running it.
  20161. For example:
  20162. @lisp
  20163. (service hurd-vm-service-type
  20164. (hurd-vm-configuration
  20165. (disk-size (* 5000 (expt 2 20))) ;5G
  20166. (memory-size 1024))) ;1024MiB
  20167. @end lisp
  20168. would create a disk image big enough to build GNU@tie{}Hello, with some
  20169. extra memory.
  20170. @end defvr
  20171. @deftp {Data Type} hurd-vm-configuration
  20172. The data type representing the configuration for
  20173. @code{hurd-vm-service-type}.
  20174. @table @asis
  20175. @item @code{os} (default: @var{%hurd-vm-operating-system})
  20176. The operating system to instantiate. This default is bare-bones with a
  20177. permissive OpenSSH secure shell daemon listening on port 2222
  20178. (@pxref{Networking Services, @code{openssh-service-type}}).
  20179. @item @code{qemu} (default: @code{qemu-minimal})
  20180. The QEMU package to use.
  20181. @item @code{image} (default: @var{hurd-vm-disk-image})
  20182. The procedure used to build the disk-image built from this
  20183. configuration.
  20184. @item @code{disk-size} (default: @code{'guess})
  20185. The size of the disk image.
  20186. @item @code{memory-size} (default: @code{512})
  20187. The memory size of the Virtual Machine in mebibytes.
  20188. @item @code{options} (default: @code{'("--snapshot")})
  20189. The extra options for running QEMU.
  20190. @item @code{id} (default: @code{#f})
  20191. If set, a non-zero positive integer used to parameterize Childhurd
  20192. instances. It is appended to the service's name,
  20193. e.g. @code{childhurd1}.
  20194. @item @code{net-options} (default: @var{hurd-vm-net-options})
  20195. The procedure used to produce the list of QEMU networking options.
  20196. By default, it produces
  20197. @lisp
  20198. '("--device" "rtl8139,netdev=net0"
  20199. "--netdev" "user,id=net0\
  20200. ,hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004\
  20201. ,hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222\
  20202. ,hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900")
  20203. @end lisp
  20204. with forwarded ports:
  20205. @example
  20206. @var{ssh-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  20207. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  20208. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  20209. @end example
  20210. @item @code{secret-root} (default: @file{/etc/childhurd})
  20211. The root directory with out-of-band secrets to be installed into the
  20212. childhurd once it runs. Childhurds are volatile which means that on
  20213. every startup, secrets such as the SSH host keys and Guix signing key
  20214. are recreated.
  20215. If the @file{/etc/childhurd} directory does not exist, the
  20216. @code{secret-service} running in the Childhurd will be sent an empty
  20217. list of secrets.
  20218. By default, the service automatically populates @file{/etc/childhurd}
  20219. with the following non-volatile secrets, unless they already exist:
  20220. @example
  20221. /etc/childhurd/etc/guix/acl
  20222. /etc/childhurd/etc/guix/signing-key.pub
  20223. /etc/childhurd/etc/guix/signing-key.sec
  20224. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  20225. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  20226. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  20227. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  20228. @end example
  20229. These files are automatically sent to the guest Hurd VM when it boots,
  20230. including permissions.
  20231. @cindex childhurd, offloading
  20232. @cindex Hurd, offloading
  20233. Having these files in place means that only a couple of things are
  20234. missing to allow the host to offload @code{i586-gnu} builds to the
  20235. childhurd:
  20236. @enumerate
  20237. @item
  20238. Authorizing the childhurd's key on the host so that the host accepts
  20239. build results coming from the childhurd, which can be done like so:
  20240. @example
  20241. guix archive --authorize < \
  20242. /etc/childhurd/etc/guix/signing-key.pub
  20243. @end example
  20244. @item
  20245. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  20246. Offload Setup}).
  20247. @end enumerate
  20248. We're working towards making that happen automatically---get in touch
  20249. with us at @email{guix-devel@@gnu.org} to discuss it!
  20250. @end table
  20251. @end deftp
  20252. Note that by default the VM image is volatile, i.e., once stopped the
  20253. contents are lost. If you want a stateful image instead, override the
  20254. configuration's @code{image} and @code{options} without
  20255. the @code{--snapshot} flag using something along these lines:
  20256. @lisp
  20257. (service hurd-vm-service-type
  20258. (hurd-vm-configuration
  20259. (image (const "/out/of/store/writable/hurd.img"))
  20260. (options '())))
  20261. @end lisp
  20262. @subsubheading Ganeti
  20263. @cindex ganeti
  20264. @quotation Note
  20265. This service is considered experimental. Configuration options may be changed
  20266. in a backwards-incompatible manner, and not all features have been thorougly
  20267. tested. Users of this service are encouraged to share their experience at
  20268. @email{guix-devel@@gnu.org}.
  20269. @end quotation
  20270. Ganeti is a virtual machine management system. It is designed to keep virtual
  20271. machines running on a cluster of servers even in the event of hardware failures,
  20272. and to make maintenance and recovery tasks easy. It consists of multiple
  20273. services which are described later in this section. In addition to the Ganeti
  20274. service, you will need the OpenSSH service (@pxref{Networking Services,
  20275. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  20276. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  20277. and address (or use a DNS server).
  20278. All nodes participating in a Ganeti cluster should have the same Ganeti and
  20279. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  20280. cluster node that supports multiple storage backends, and installs the
  20281. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  20282. @lisp
  20283. (use-package-modules virtualization)
  20284. (use-service-modules base ganeti networking ssh)
  20285. (operating-system
  20286. ;; @dots{}
  20287. (host-name "node1")
  20288. (hosts-file (plain-file "hosts" (format #f "
  20289. 127.0.0.1 localhost
  20290. ::1 localhost
  20291. 192.168.1.200 ganeti.example.com
  20292. 192.168.1.201 node1.example.com node1
  20293. 192.168.1.202 node2.example.com node2
  20294. ")))
  20295. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  20296. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  20297. (packages (append (map specification->package
  20298. '("qemu" "lvm2" "drbd-utils" "ceph"
  20299. ;; Add the debootstrap and guix OS providers.
  20300. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  20301. %base-packages))
  20302. (services
  20303. (append (list (static-networking-service "eth0" "192.168.1.201"
  20304. #:netmask "255.255.255.0"
  20305. #:gateway "192.168.1.254"
  20306. #:name-servers '("192.168.1.252"
  20307. "192.168.1.253"))
  20308. ;; Ganeti uses SSH to communicate between nodes.
  20309. (service openssh-service-type
  20310. (openssh-configuration
  20311. (permit-root-login 'without-password)))
  20312. (service ganeti-service-type
  20313. (ganeti-configuration
  20314. ;; This list specifies allowed file system paths
  20315. ;; for storing virtual machine images.
  20316. (file-storage-paths '("/srv/ganeti/file-storage"))
  20317. ;; This variable configures a single "variant" for
  20318. ;; both Debootstrap and Guix that works with KVM.
  20319. (os %default-ganeti-os))))
  20320. %base-services)))
  20321. @end lisp
  20322. Users are advised to read the
  20323. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  20324. administrators guide} to learn about the various cluster options and
  20325. day-to-day operations. There is also a
  20326. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  20327. describing how to configure and initialize a small cluster.
  20328. @defvr {Scheme Variable} ganeti-service-type
  20329. This is a service type that includes all the various services that Ganeti
  20330. nodes should run.
  20331. Its value is a @code{ganeti-configuration} object that defines the package
  20332. to use for CLI operations, as well as configuration for the various daemons.
  20333. Allowed file storage paths and available guest operating systems are also
  20334. configured through this data type.
  20335. @end defvr
  20336. @deftp {Data Type} ganeti-configuration
  20337. The @code{ganeti} service takes the following configuration options:
  20338. @table @asis
  20339. @item @code{ganeti} (default: @code{ganeti})
  20340. The @code{ganeti} package to use. It will be installed to the system profile
  20341. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  20342. that the value specified here does not affect the other services as each refer
  20343. to a specific @code{ganeti} package (see below).
  20344. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  20345. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  20346. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  20347. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  20348. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  20349. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  20350. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  20351. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  20352. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  20353. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  20354. These options control the various daemons and cron jobs that are distributed
  20355. with Ganeti. The possible values for these are described in detail below.
  20356. To override a setting, you must use the configuration type for that service:
  20357. @lisp
  20358. (service ganeti-service-type
  20359. (ganeti-configuration
  20360. (rapi-configuration
  20361. (ganeti-rapi-configuration
  20362. (interface "eth1"))))
  20363. (watcher-configuration
  20364. (ganeti-watcher-configuration
  20365. (rapi-ip "10.0.0.1"))))
  20366. @end lisp
  20367. @item @code{file-storage-paths} (default: @code{'()})
  20368. List of allowed directories for file storage backend.
  20369. @item @code{os} (default: @code{%default-ganeti-os})
  20370. List of @code{<ganeti-os>} records.
  20371. @end table
  20372. In essence @code{ganeti-service-type} is shorthand for declaring each service
  20373. individually:
  20374. @lisp
  20375. (service ganeti-noded-service-type)
  20376. (service ganeti-confd-service-type)
  20377. (service ganeti-wconfd-service-type)
  20378. (service ganeti-luxid-service-type)
  20379. (service ganeti-kvmd-service-type)
  20380. (service ganeti-mond-service-type)
  20381. (service ganeti-metad-service-type)
  20382. (service ganeti-watcher-service-type)
  20383. (service ganeti-cleaner-service-type)
  20384. @end lisp
  20385. Plus a service extension for @code{etc-service-type} that configures the file
  20386. storage backend and OS variants.
  20387. @end deftp
  20388. @deftp {Data Type} ganeti-os
  20389. This data type is suitable for passing to the @code{os} parameter of
  20390. @code{ganeti-configuration}. It takes the following parameters:
  20391. @table @asis
  20392. @item @code{name}
  20393. The name for this OS provider. It is only used to specify where the
  20394. configuration ends up. Setting it to ``debootstrap'' will create
  20395. @file{/etc/ganeti/instance-debootstrap}.
  20396. @item @code{extension}
  20397. The file extension for variants of this OS type. For example
  20398. @file{.conf} or @file{.scm}.
  20399. @item @code{variants} (default: @code{'()})
  20400. List of @code{ganeti-os-variant} objects for this OS.
  20401. @end table
  20402. @end deftp
  20403. @deftp {Data Type} ganeti-os-variant
  20404. This is the data type for a Ganeti OS variant. It takes the following
  20405. parameters:
  20406. @table @asis
  20407. @item @code{name}
  20408. The name of this variant.
  20409. @item @code{configuration}
  20410. A configuration file for this variant.
  20411. @end table
  20412. @end deftp
  20413. @defvr {Scheme Variable} %default-debootstrap-hooks
  20414. This variable contains hooks to configure networking and the GRUB bootloader.
  20415. @end defvr
  20416. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  20417. This variable contains a list of packages suitable for a fully-virtualized guest.
  20418. @end defvr
  20419. @deftp {Data Type} debootstrap-configuration
  20420. This data type creates configuration files suitable for the debootstrap OS provider.
  20421. @table @asis
  20422. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  20423. When not @code{#f}, this must be a G-expression that specifies a directory with
  20424. scripts that will run when the OS is installed. It can also be a list of
  20425. @code{(name . file-like)} pairs. For example:
  20426. @lisp
  20427. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  20428. @end lisp
  20429. That will create a directory with one executable named @code{99-hello-world}
  20430. and run it every time this variant is installed. If set to @code{#f}, hooks
  20431. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  20432. @item @code{proxy} (default: @code{#f})
  20433. Optional HTTP proxy to use.
  20434. @item @code{mirror} (default: @code{#f})
  20435. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  20436. The default varies depending on the distribution.
  20437. @item @code{arch} (default: @code{#f})
  20438. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  20439. on an AArch64 host. Default is to use the current system architecture.
  20440. @item @code{suite} (default: @code{"stable"})
  20441. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  20442. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  20443. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  20444. List of extra packages that will get installed by dpkg in addition
  20445. to the minimal system.
  20446. @item @code{components} (default: @code{#f})
  20447. When set, must be a list of Debian repository ``components''. For example
  20448. @code{'("main" "contrib")}.
  20449. @item @code{generate-cache?} (default: @code{#t})
  20450. Whether to automatically cache the generated debootstrap archive.
  20451. @item @code{clean-cache} (default: @code{14})
  20452. Discard the cache after this amount of days. Use @code{#f} to never
  20453. clear the cache.
  20454. @item @code{partition-style} (default: @code{'msdos})
  20455. The type of partition to create. When set, it must be one of
  20456. @code{'msdos}, @code{'none} or a string.
  20457. @item @code{partition-alignment} (default: @code{2048})
  20458. Alignment of the partition in sectors.
  20459. @end table
  20460. @end deftp
  20461. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  20462. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  20463. takes two parameters: a name and a @code{debootstrap-configuration} object.
  20464. @end deffn
  20465. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  20466. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  20467. a list of variants created with @code{debootstrap-variant}.
  20468. @end deffn
  20469. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  20470. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  20471. use with the Guix OS provider. It takes a name and a G-expression that returns
  20472. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  20473. Guix System configuration.
  20474. @end deffn
  20475. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  20476. This is a helper procedure that creates a @code{ganeti-os} record. It
  20477. takes a list of variants produced by @code{guix-variant}.
  20478. @end deffn
  20479. @defvr {Scheme Variable} %default-debootstrap-variants
  20480. This is a convenience variable to make the debootstrap provider work
  20481. ``out of the box'' without users having to declare variants manually. It
  20482. contains a single debootstrap variant with the default configuration:
  20483. @lisp
  20484. (list (debootstrap-variant
  20485. "default"
  20486. (debootstrap-configuration)))
  20487. @end lisp
  20488. @end defvr
  20489. @defvr {Scheme Variable} %default-guix-variants
  20490. This is a convenience variable to make the Guix OS provider work without
  20491. additional configuration. It creates a virtual machine that has an SSH
  20492. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  20493. @lisp
  20494. (list (guix-variant
  20495. "default"
  20496. (file-append ganeti-instance-guix
  20497. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  20498. @end lisp
  20499. @end defvr
  20500. Users can implement support for OS providers unbeknownst to Guix by extending
  20501. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  20502. For example:
  20503. @lisp
  20504. (ganeti-os
  20505. (name "custom")
  20506. (extension ".conf")
  20507. (variants
  20508. (list (ganeti-os-variant
  20509. (name "foo")
  20510. (configuration (plain-file "bar" "this is fine"))))))
  20511. @end lisp
  20512. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  20513. to a file in the store with contents @code{this is fine}. It also creates
  20514. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  20515. Obviously this may not work for all OS providers out there. If you find the
  20516. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  20517. The rest of this section documents the various services that are included by
  20518. @code{ganeti-service-type}.
  20519. @defvr {Scheme Variable} ganeti-noded-service-type
  20520. @command{ganeti-noded} is the daemon responsible for node-specific functions
  20521. within the Ganeti system. The value of this service must be a
  20522. @code{ganeti-noded-configuration} object.
  20523. @end defvr
  20524. @deftp {Data Type} ganeti-noded-configuration
  20525. This is the configuration for the @code{ganeti-noded} service.
  20526. @table @asis
  20527. @item @code{ganeti} (default: @code{ganeti})
  20528. The @code{ganeti} package to use for this service.
  20529. @item @code{port} (default: @code{1811})
  20530. The TCP port on which the node daemon listens for network requests.
  20531. @item @code{address} (default: @code{"0.0.0.0"})
  20532. The network address that the daemon will bind to. The default address means
  20533. bind to all available addresses.
  20534. @item @code{interface} (default: @code{#f})
  20535. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  20536. that the daemon will bind to.
  20537. @item @code{max-clients} (default: @code{20})
  20538. This sets a limit on the maximum number of simultaneous client connections
  20539. that the daemon will handle. Connections above this count are accepted, but
  20540. no responses will be sent until enough connections have closed.
  20541. @item @code{ssl?} (default: @code{#t})
  20542. Whether to use SSL/TLS to encrypt network communications. The certificate
  20543. is automatically provisioned by the cluster and can be rotated with
  20544. @command{gnt-cluster renew-crypto}.
  20545. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  20546. This can be used to provide a specific encryption key for TLS communications.
  20547. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  20548. This can be used to provide a specific certificate for TLS communications.
  20549. @item @code{debug?} (default: @code{#f})
  20550. When true, the daemon performs additional logging for debugging purposes.
  20551. Note that this will leak encryption details to the log files, use with caution.
  20552. @end table
  20553. @end deftp
  20554. @defvr {Scheme Variable} ganeti-confd-service-type
  20555. @command{ganeti-confd} answers queries related to the configuration of a
  20556. Ganeti cluster. The purpose of this daemon is to have a highly available
  20557. and fast way to query cluster configuration values. It is automatically
  20558. active on all @dfn{master candidates}. The value of this service must be a
  20559. @code{ganeti-confd-configuration} object.
  20560. @end defvr
  20561. @deftp {Data Type} ganeti-confd-configuration
  20562. This is the configuration for the @code{ganeti-confd} service.
  20563. @table @asis
  20564. @item @code{ganeti} (default: @code{ganeti})
  20565. The @code{ganeti} package to use for this service.
  20566. @item @code{port} (default: @code{1814})
  20567. The UDP port on which to listen for network requests.
  20568. @item @code{address} (default: @code{"0.0.0.0"})
  20569. Network address that the daemon will bind to.
  20570. @item @code{debug?} (default: @code{#f})
  20571. When true, the daemon performs additional logging for debugging purposes.
  20572. @end table
  20573. @end deftp
  20574. @defvr {Scheme Variable} ganeti-wconfd-service-type
  20575. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  20576. about the cluster configuration and is the only entity that can accept
  20577. changes to it. All jobs that need to modify the configuration will do so
  20578. by sending appropriate requests to this daemon. It only runs on the
  20579. @dfn{master node} and will automatically disable itself on other nodes.
  20580. The value of this service must be a
  20581. @code{ganeti-wconfd-configuration} object.
  20582. @end defvr
  20583. @deftp {Data Type} ganeti-wconfd-configuration
  20584. This is the configuration for the @code{ganeti-wconfd} service.
  20585. @table @asis
  20586. @item @code{ganeti} (default: @code{ganeti})
  20587. The @code{ganeti} package to use for this service.
  20588. @item @code{no-voting?} (default: @code{#f})
  20589. The daemon will refuse to start if the majority of cluster nodes does not
  20590. agree that it is running on the master node. Set to @code{#t} to start
  20591. even if a quorum can not be reached (dangerous, use with caution).
  20592. @item @code{debug?} (default: @code{#f})
  20593. When true, the daemon performs additional logging for debugging purposes.
  20594. @end table
  20595. @end deftp
  20596. @defvr {Scheme Variable} ganeti-luxid-service-type
  20597. @command{ganeti-luxid} is a daemon used to answer queries related to the
  20598. configuration and the current live state of a Ganeti cluster. Additionally,
  20599. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  20600. submitted via this daemon and it schedules and starts them.
  20601. It takes a @code{ganeti-luxid-configuration} object.
  20602. @end defvr
  20603. @deftp {Data Type} ganeti-luxid-configuration
  20604. This is the configuration for the @code{ganeti-wconfd} service.
  20605. @table @asis
  20606. @item @code{ganeti} (default: @code{ganeti})
  20607. The @code{ganeti} package to use for this service.
  20608. @item @code{no-voting?} (default: @code{#f})
  20609. The daemon will refuse to start if it cannot verify that the majority of
  20610. cluster nodes believes that it is running on the master node. Set to
  20611. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  20612. @item @code{debug?} (default: @code{#f})
  20613. When true, the daemon performs additional logging for debugging purposes.
  20614. @end table
  20615. @end deftp
  20616. @defvr {Scheme Variable} ganeti-rapi-service-type
  20617. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  20618. the master node and can be used to perform cluster actions programmatically
  20619. via a JSON-based RPC protocol.
  20620. Most query operations are allowed without authentication (unless
  20621. @var{require-authentication?} is set), whereas write operations require
  20622. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  20623. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  20624. API documentation} for more information.
  20625. The value of this service must be a @code{ganeti-rapi-configuration} object.
  20626. @end defvr
  20627. @deftp {Data Type} ganeti-rapi-configuration
  20628. This is the configuration for the @code{ganeti-rapi} service.
  20629. @table @asis
  20630. @item @code{ganeti} (default: @code{ganeti})
  20631. The @code{ganeti} package to use for this service.
  20632. @item @code{require-authentication?} (default: @code{#f})
  20633. Whether to require authentication even for read-only operations.
  20634. @item @code{port} (default: @code{5080})
  20635. The TCP port on which to listen to API requests.
  20636. @item @code{address} (default: @code{"0.0.0.0"})
  20637. The network address that the service will bind to. By default it listens
  20638. on all configured addresses.
  20639. @item @code{interface} (default: @code{#f})
  20640. When set, it must specify a specific network interface such as @code{eth0}
  20641. that the daemon will bind to.
  20642. @item @code{max-clients} (default: @code{20})
  20643. The maximum number of simultaneous client requests to handle. Further
  20644. connections are allowed, but no responses are sent until enough connections
  20645. have closed.
  20646. @item @code{ssl?} (default: @code{#t})
  20647. Whether to use SSL/TLS encryption on the RAPI port.
  20648. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  20649. This can be used to provide a specific encryption key for TLS communications.
  20650. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  20651. This can be used to provide a specific certificate for TLS communications.
  20652. @item @code{debug?} (default: @code{#f})
  20653. When true, the daemon performs additional logging for debugging purposes.
  20654. Note that this will leak encryption details to the log files, use with caution.
  20655. @end table
  20656. @end deftp
  20657. @defvr {Scheme Variable} ganeti-kvmd-service-type
  20658. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  20659. instance was shut down by an administrator or a user. Normally Ganeti will
  20660. restart an instance that was not stopped through Ganeti itself. If the
  20661. cluster option @code{user_shutdown} is true, this daemon monitors the
  20662. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  20663. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  20664. it shuts down gracefully by itself.
  20665. It takes a @code{ganeti-kvmd-configuration} object.
  20666. @end defvr
  20667. @deftp {Data Type} ganeti-kvmd-configuration
  20668. @table @asis
  20669. @item @code{ganeti} (default: @code{ganeti})
  20670. The @code{ganeti} package to use for this service.
  20671. @item @code{debug?} (default: @code{#f})
  20672. When true, the daemon performs additional logging for debugging purposes.
  20673. @end table
  20674. @end deftp
  20675. @defvr {Scheme Variable} ganeti-mond-service-type
  20676. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  20677. functionality. It is responsible for running data collectors and publish the
  20678. collected information through a HTTP interface.
  20679. It takes a @code{ganeti-mond-configuration} object.
  20680. @end defvr
  20681. @deftp {Data Type} ganeti-mond-configuration
  20682. @table @asis
  20683. @item @code{ganeti} (default: @code{ganeti})
  20684. The @code{ganeti} package to use for this service.
  20685. @item @code{port} (default: @code{1815})
  20686. The port on which the daemon will listen.
  20687. @item @code{address} (default: @code{"0.0.0.0"})
  20688. The network address that the daemon will bind to. By default it binds to all
  20689. available interfaces.
  20690. @item @code{debug?} (default: @code{#f})
  20691. When true, the daemon performs additional logging for debugging purposes.
  20692. @end table
  20693. @end deftp
  20694. @defvr {Scheme Variable} ganeti-metad-service-type
  20695. @command{ganeti-metad} is an optional daemon that can be used to provide
  20696. information about the cluster to instances or OS install scripts.
  20697. It takes a @code{ganeti-metad-configuration} object.
  20698. @end defvr
  20699. @deftp {Data Type} ganeti-metad-configuration
  20700. @table @asis
  20701. @item @code{ganeti} (default: @code{ganeti})
  20702. The @code{ganeti} package to use for this service.
  20703. @item @code{port} (default: @code{80})
  20704. The port on which the daemon will listen.
  20705. @item @code{address} (default: @code{#f})
  20706. If set, the daemon will bind to this address only. If left unset, the behavior
  20707. depends on the cluster configuration.
  20708. @item @code{debug?} (default: @code{#f})
  20709. When true, the daemon performs additional logging for debugging purposes.
  20710. @end table
  20711. @end deftp
  20712. @defvr {Scheme Variable} ganeti-watcher-service-type
  20713. @command{ganeti-watcher} is a script designed to run periodically and ensure
  20714. the health of a cluster. It will automatically restart instances that have
  20715. stopped without Ganetis consent, and repairs DRBD links in case a node has
  20716. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  20717. that are not running. If the cluster parameter @code{ensure_node_health}
  20718. is set, the watcher will also shutdown instances and DRBD devices if the
  20719. node it is running on is declared offline by known master candidates.
  20720. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  20721. The service takes a @code{ganeti-watcher-configuration} object.
  20722. @end defvr
  20723. @deftp {Data Type} ganeti-watcher-configuration
  20724. @table @asis
  20725. @item @code{ganeti} (default: @code{ganeti})
  20726. The @code{ganeti} package to use for this service.
  20727. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  20728. How often to run the script. The default is every five minutes.
  20729. @item @code{rapi-ip} (default: @code{#f})
  20730. This option needs to be specified only if the RAPI daemon is configured to use
  20731. a particular interface or address. By default the cluster address is used.
  20732. @item @code{job-age} (default: @code{(* 6 3600)})
  20733. Archive cluster jobs older than this age, specified in seconds. The default
  20734. is 6 hours. This keeps @command{gnt-job list} manageable.
  20735. @item @code{verify-disks?} (default: @code{#t})
  20736. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  20737. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  20738. manually instead.
  20739. @item @code{debug?} (default: @code{#f})
  20740. When @code{#t}, the script performs additional logging for debugging purposes.
  20741. @end table
  20742. @end deftp
  20743. @defvr {Scheme Variable} ganeti-cleaner-service-type
  20744. @command{ganeti-cleaner} is a script designed to run periodically and remove
  20745. old files from the cluster. This service type controls two @dfn{cron jobs}:
  20746. one intended for the master node that permanently purges old cluster jobs,
  20747. and one intended for every node that removes expired X509 certificates, keys,
  20748. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  20749. it is safe to include even on non-master nodes as it will disable itself as
  20750. necessary.
  20751. It takes a @code{ganeti-cleaner-configuration} object.
  20752. @end defvr
  20753. @deftp {Data Type} ganeti-cleaner-configuration
  20754. @table @asis
  20755. @item @code{ganeti} (default: @code{ganeti})
  20756. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  20757. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  20758. How often to run the master cleaning job. The default is once per day, at
  20759. 01:45:00.
  20760. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  20761. How often to run the node cleaning job. The default is once per day, at
  20762. 02:45:00.
  20763. @end table
  20764. @end deftp
  20765. @node Version Control Services
  20766. @subsection Version Control Services
  20767. The @code{(gnu services version-control)} module provides a service to
  20768. allow remote access to local Git repositories. There are three options:
  20769. the @code{git-daemon-service}, which provides access to repositories via
  20770. the @code{git://} unsecured TCP-based protocol, extending the
  20771. @code{nginx} web server to proxy some requests to
  20772. @code{git-http-backend}, or providing a web interface with
  20773. @code{cgit-service-type}.
  20774. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  20775. Return a service that runs @command{git daemon}, a simple TCP server to
  20776. expose repositories over the Git protocol for anonymous access.
  20777. The optional @var{config} argument should be a
  20778. @code{<git-daemon-configuration>} object, by default it allows read-only
  20779. access to exported@footnote{By creating the magic file
  20780. @file{git-daemon-export-ok} in the repository directory.} repositories under
  20781. @file{/srv/git}.
  20782. @end deffn
  20783. @deftp {Data Type} git-daemon-configuration
  20784. Data type representing the configuration for @code{git-daemon-service}.
  20785. @table @asis
  20786. @item @code{package} (default: @code{git})
  20787. Package object of the Git distributed version control system.
  20788. @item @code{export-all?} (default: @code{#f})
  20789. Whether to allow access for all Git repositories, even if they do not
  20790. have the @file{git-daemon-export-ok} file.
  20791. @item @code{base-path} (default: @file{/srv/git})
  20792. Whether to remap all the path requests as relative to the given path.
  20793. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  20794. @samp{example.com}, then if you later try to pull
  20795. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  20796. path as @file{/srv/git/hello.git}.
  20797. @item @code{user-path} (default: @code{#f})
  20798. Whether to allow @code{~user} notation to be used in requests. When
  20799. specified with empty string, requests to
  20800. @indicateurl{git://host/~alice/foo} is taken as a request to access
  20801. @code{foo} repository in the home directory of user @code{alice}. If
  20802. @code{(user-path "@var{path}")} is specified, the same request is taken
  20803. as a request to access @file{@var{path}/foo} repository in the home
  20804. directory of user @code{alice}.
  20805. @item @code{listen} (default: @code{'()})
  20806. Whether to listen on specific IP addresses or hostnames, defaults to
  20807. all.
  20808. @item @code{port} (default: @code{#f})
  20809. Whether to listen on an alternative port, which defaults to 9418.
  20810. @item @code{whitelist} (default: @code{'()})
  20811. If not empty, only allow access to this list of directories.
  20812. @item @code{extra-options} (default: @code{'()})
  20813. Extra options will be passed to @command{git daemon}, please run
  20814. @command{man git-daemon} for more information.
  20815. @end table
  20816. @end deftp
  20817. The @code{git://} protocol lacks authentication. When you pull from a
  20818. repository fetched via @code{git://}, you don't know whether the data you
  20819. receive was modified or is even coming from the specified host, and your
  20820. connection is subject to eavesdropping. It's better to use an authenticated
  20821. and encrypted transport, such as @code{https}. Although Git allows you
  20822. to serve repositories using unsophisticated file-based web servers,
  20823. there is a faster protocol implemented by the @code{git-http-backend}
  20824. program. This program is the back-end of a proper Git web service. It
  20825. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  20826. on running the necessary @code{fcgiwrap} daemon.
  20827. Guix has a separate configuration data type for serving Git repositories
  20828. over HTTP.
  20829. @deftp {Data Type} git-http-configuration
  20830. Data type representing the configuration for a future
  20831. @code{git-http-service-type}; can currently be used to configure Nginx
  20832. trough @code{git-http-nginx-location-configuration}.
  20833. @table @asis
  20834. @item @code{package} (default: @var{git})
  20835. Package object of the Git distributed version control system.
  20836. @item @code{git-root} (default: @file{/srv/git})
  20837. Directory containing the Git repositories to expose to the world.
  20838. @item @code{export-all?} (default: @code{#f})
  20839. Whether to expose access for all Git repositories in @var{git-root},
  20840. even if they do not have the @file{git-daemon-export-ok} file.
  20841. @item @code{uri-path} (default: @samp{/git/})
  20842. Path prefix for Git access. With the default @samp{/git/} prefix, this
  20843. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  20844. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  20845. with this prefix are not passed on to this Git instance.
  20846. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  20847. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  20848. Services}.
  20849. @end table
  20850. @end deftp
  20851. There is no @code{git-http-service-type}, currently; instead you can
  20852. create an @code{nginx-location-configuration} from a
  20853. @code{git-http-configuration} and then add that location to a web
  20854. server.
  20855. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  20856. [config=(git-http-configuration)]
  20857. Compute an @code{nginx-location-configuration} that corresponds to the
  20858. given Git http configuration. An example nginx service definition to
  20859. serve the default @file{/srv/git} over HTTPS might be:
  20860. @lisp
  20861. (service nginx-service-type
  20862. (nginx-configuration
  20863. (server-blocks
  20864. (list
  20865. (nginx-server-configuration
  20866. (listen '("443 ssl"))
  20867. (server-name "git.my-host.org")
  20868. (ssl-certificate
  20869. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  20870. (ssl-certificate-key
  20871. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  20872. (locations
  20873. (list
  20874. (git-http-nginx-location-configuration
  20875. (git-http-configuration (uri-path "/"))))))))))
  20876. @end lisp
  20877. This example assumes that you are using Let's Encrypt to get your TLS
  20878. certificate. @xref{Certificate Services}. The default @code{certbot}
  20879. service will redirect all HTTP traffic on @code{git.my-host.org} to
  20880. HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
  20881. system services. @xref{Web Services}.
  20882. @end deffn
  20883. @subsubheading Cgit Service
  20884. @cindex Cgit service
  20885. @cindex Git, web interface
  20886. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  20887. repositories written in C.
  20888. The following example will configure the service with default values.
  20889. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  20890. @lisp
  20891. (service cgit-service-type)
  20892. @end lisp
  20893. The @code{file-object} type designates either a file-like object
  20894. (@pxref{G-Expressions, file-like objects}) or a string.
  20895. @c %start of fragment
  20896. Available @code{cgit-configuration} fields are:
  20897. @deftypevr {@code{cgit-configuration} parameter} package package
  20898. The CGIT package.
  20899. @end deftypevr
  20900. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  20901. NGINX configuration.
  20902. @end deftypevr
  20903. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  20904. Specifies a command which will be invoked to format the content of about
  20905. pages (both top-level and for each repository).
  20906. Defaults to @samp{""}.
  20907. @end deftypevr
  20908. @deftypevr {@code{cgit-configuration} parameter} string agefile
  20909. Specifies a path, relative to each repository path, which can be used to
  20910. specify the date and time of the youngest commit in the repository.
  20911. Defaults to @samp{""}.
  20912. @end deftypevr
  20913. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  20914. Specifies a command that will be invoked for authenticating repository
  20915. access.
  20916. Defaults to @samp{""}.
  20917. @end deftypevr
  20918. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  20919. Flag which, when set to @samp{age}, enables date ordering in the branch
  20920. ref list, and when set @samp{name} enables ordering by branch name.
  20921. Defaults to @samp{"name"}.
  20922. @end deftypevr
  20923. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  20924. Path used to store the cgit cache entries.
  20925. Defaults to @samp{"/var/cache/cgit"}.
  20926. @end deftypevr
  20927. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  20928. Number which specifies the time-to-live, in minutes, for the cached
  20929. version of repository pages accessed with a fixed SHA1.
  20930. Defaults to @samp{-1}.
  20931. @end deftypevr
  20932. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  20933. Number which specifies the time-to-live, in minutes, for the cached
  20934. version of repository pages accessed without a fixed SHA1.
  20935. Defaults to @samp{5}.
  20936. @end deftypevr
  20937. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  20938. Number which specifies the time-to-live, in minutes, for the cached
  20939. version of the repository summary page.
  20940. Defaults to @samp{5}.
  20941. @end deftypevr
  20942. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  20943. Number which specifies the time-to-live, in minutes, for the cached
  20944. version of the repository index page.
  20945. Defaults to @samp{5}.
  20946. @end deftypevr
  20947. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  20948. Number which specifies the time-to-live, in minutes, for the result of
  20949. scanning a path for Git repositories.
  20950. Defaults to @samp{15}.
  20951. @end deftypevr
  20952. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  20953. Number which specifies the time-to-live, in minutes, for the cached
  20954. version of the repository about page.
  20955. Defaults to @samp{15}.
  20956. @end deftypevr
  20957. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  20958. Number which specifies the time-to-live, in minutes, for the cached
  20959. version of snapshots.
  20960. Defaults to @samp{5}.
  20961. @end deftypevr
  20962. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  20963. The maximum number of entries in the cgit cache. When set to @samp{0},
  20964. caching is disabled.
  20965. Defaults to @samp{0}.
  20966. @end deftypevr
  20967. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  20968. Sort items in the repo list case sensitively.
  20969. Defaults to @samp{#t}.
  20970. @end deftypevr
  20971. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  20972. List of common prefixes which, when combined with a repository URL,
  20973. generates valid clone URLs for the repository.
  20974. Defaults to @samp{()}.
  20975. @end deftypevr
  20976. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  20977. List of @code{clone-url} templates.
  20978. Defaults to @samp{()}.
  20979. @end deftypevr
  20980. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  20981. Command which will be invoked to format commit messages.
  20982. Defaults to @samp{""}.
  20983. @end deftypevr
  20984. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  20985. Flag which, when set to @samp{date}, enables strict date ordering in the
  20986. commit log, and when set to @samp{topo} enables strict topological
  20987. ordering.
  20988. Defaults to @samp{"git log"}.
  20989. @end deftypevr
  20990. @deftypevr {@code{cgit-configuration} parameter} file-object css
  20991. URL which specifies the css document to include in all cgit pages.
  20992. Defaults to @samp{"/share/cgit/cgit.css"}.
  20993. @end deftypevr
  20994. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  20995. Specifies a command which will be invoked to format names and email
  20996. address of committers, authors, and taggers, as represented in various
  20997. places throughout the cgit interface.
  20998. Defaults to @samp{""}.
  20999. @end deftypevr
  21000. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  21001. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  21002. fragment suitable for embedding in other HTML pages.
  21003. Defaults to @samp{#f}.
  21004. @end deftypevr
  21005. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  21006. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  21007. commit history graph to the left of the commit messages in the
  21008. repository log page.
  21009. Defaults to @samp{#f}.
  21010. @end deftypevr
  21011. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  21012. Flag which, when set to @samp{#t}, allows all filter settings to be
  21013. overridden in repository-specific cgitrc files.
  21014. Defaults to @samp{#f}.
  21015. @end deftypevr
  21016. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  21017. Flag which, when set to @samp{#t}, allows users to follow a file in the
  21018. log view.
  21019. Defaults to @samp{#f}.
  21020. @end deftypevr
  21021. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  21022. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  21023. clones.
  21024. Defaults to @samp{#t}.
  21025. @end deftypevr
  21026. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  21027. Flag which, when set to @samp{#t}, will make cgit generate extra links
  21028. "summary", "commit", "tree" for each repo in the repository index.
  21029. Defaults to @samp{#f}.
  21030. @end deftypevr
  21031. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  21032. Flag which, when set to @samp{#t}, will make cgit display the owner of
  21033. each repo in the repository index.
  21034. Defaults to @samp{#t}.
  21035. @end deftypevr
  21036. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  21037. Flag which, when set to @samp{#t}, will make cgit print the number of
  21038. modified files for each commit on the repository log page.
  21039. Defaults to @samp{#f}.
  21040. @end deftypevr
  21041. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  21042. Flag which, when set to @samp{#t}, will make cgit print the number of
  21043. added and removed lines for each commit on the repository log page.
  21044. Defaults to @samp{#f}.
  21045. @end deftypevr
  21046. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  21047. Flag which, when set to @code{#t}, will make cgit display remote
  21048. branches in the summary and refs views.
  21049. Defaults to @samp{#f}.
  21050. @end deftypevr
  21051. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  21052. Flag which, when set to @code{1}, will make cgit use the subject of the
  21053. parent commit as link text when generating links to parent commits in
  21054. commit view.
  21055. Defaults to @samp{#f}.
  21056. @end deftypevr
  21057. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  21058. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  21059. parent commit as link text when generating links to parent commits in
  21060. commit view.
  21061. Defaults to @samp{#f}.
  21062. @end deftypevr
  21063. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  21064. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  21065. links for plaintext blobs printed in the tree view.
  21066. Defaults to @samp{#t}.
  21067. @end deftypevr
  21068. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  21069. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  21070. set any repo specific settings.
  21071. Defaults to @samp{#f}.
  21072. @end deftypevr
  21073. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  21074. URL used as link to a shortcut icon for cgit.
  21075. Defaults to @samp{"/favicon.ico"}.
  21076. @end deftypevr
  21077. @deftypevr {@code{cgit-configuration} parameter} string footer
  21078. The content of the file specified with this option will be included
  21079. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  21080. "generated by..."@: message).
  21081. Defaults to @samp{""}.
  21082. @end deftypevr
  21083. @deftypevr {@code{cgit-configuration} parameter} string head-include
  21084. The content of the file specified with this option will be included
  21085. verbatim in the HTML HEAD section on all pages.
  21086. Defaults to @samp{""}.
  21087. @end deftypevr
  21088. @deftypevr {@code{cgit-configuration} parameter} string header
  21089. The content of the file specified with this option will be included
  21090. verbatim at the top of all pages.
  21091. Defaults to @samp{""}.
  21092. @end deftypevr
  21093. @deftypevr {@code{cgit-configuration} parameter} file-object include
  21094. Name of a configfile to include before the rest of the current config-
  21095. file is parsed.
  21096. Defaults to @samp{""}.
  21097. @end deftypevr
  21098. @deftypevr {@code{cgit-configuration} parameter} string index-header
  21099. The content of the file specified with this option will be included
  21100. verbatim above the repository index.
  21101. Defaults to @samp{""}.
  21102. @end deftypevr
  21103. @deftypevr {@code{cgit-configuration} parameter} string index-info
  21104. The content of the file specified with this option will be included
  21105. verbatim below the heading on the repository index page.
  21106. Defaults to @samp{""}.
  21107. @end deftypevr
  21108. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  21109. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  21110. in the servers timezone.
  21111. Defaults to @samp{#f}.
  21112. @end deftypevr
  21113. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  21114. URL which specifies the source of an image which will be used as a logo
  21115. on all cgit pages.
  21116. Defaults to @samp{"/share/cgit/cgit.png"}.
  21117. @end deftypevr
  21118. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  21119. URL loaded when clicking on the cgit logo image.
  21120. Defaults to @samp{""}.
  21121. @end deftypevr
  21122. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  21123. Command which will be invoked to format the Owner column of the main
  21124. page.
  21125. Defaults to @samp{""}.
  21126. @end deftypevr
  21127. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  21128. Number of items to display in atom feeds view.
  21129. Defaults to @samp{10}.
  21130. @end deftypevr
  21131. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  21132. Number of entries to list per page in "log" view.
  21133. Defaults to @samp{50}.
  21134. @end deftypevr
  21135. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  21136. Number of commit message characters to display in "log" view.
  21137. Defaults to @samp{80}.
  21138. @end deftypevr
  21139. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  21140. Specifies the number of entries to list per page on the repository index
  21141. page.
  21142. Defaults to @samp{50}.
  21143. @end deftypevr
  21144. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  21145. Specifies the maximum number of repo description characters to display
  21146. on the repository index page.
  21147. Defaults to @samp{80}.
  21148. @end deftypevr
  21149. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  21150. Specifies the maximum size of a blob to display HTML for in KBytes.
  21151. Defaults to @samp{0}.
  21152. @end deftypevr
  21153. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  21154. Maximum statistics period. Valid values are @samp{week},@samp{month},
  21155. @samp{quarter} and @samp{year}.
  21156. Defaults to @samp{""}.
  21157. @end deftypevr
  21158. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  21159. Mimetype for the specified filename extension.
  21160. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  21161. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  21162. "image/png") (svg "image/svg+xml"))}.
  21163. @end deftypevr
  21164. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  21165. Specifies the file to use for automatic mimetype lookup.
  21166. Defaults to @samp{""}.
  21167. @end deftypevr
  21168. @deftypevr {@code{cgit-configuration} parameter} string module-link
  21169. Text which will be used as the formatstring for a hyperlink when a
  21170. submodule is printed in a directory listing.
  21171. Defaults to @samp{""}.
  21172. @end deftypevr
  21173. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  21174. If set to the value @samp{#t} caching will be disabled.
  21175. Defaults to @samp{#f}.
  21176. @end deftypevr
  21177. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  21178. If set to @samp{#t} showing full author email addresses will be
  21179. disabled.
  21180. Defaults to @samp{#f}.
  21181. @end deftypevr
  21182. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  21183. Flag which, when set to @samp{#t}, will make cgit omit the standard
  21184. header on all pages.
  21185. Defaults to @samp{#f}.
  21186. @end deftypevr
  21187. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  21188. A list of subdirectories inside of @code{repository-directory}, relative
  21189. to it, that should loaded as Git repositories. An empty list means that
  21190. all subdirectories will be loaded.
  21191. Defaults to @samp{()}.
  21192. @end deftypevr
  21193. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  21194. Text which will be used as default value for @code{cgit-repo-readme}.
  21195. Defaults to @samp{""}.
  21196. @end deftypevr
  21197. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  21198. If set to @code{#t} and @code{repository-directory} is enabled, if any
  21199. repositories are found with a suffix of @code{.git}, this suffix will be
  21200. removed for the URL and name.
  21201. Defaults to @samp{#f}.
  21202. @end deftypevr
  21203. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  21204. Maximum number of files to consider when detecting renames.
  21205. Defaults to @samp{-1}.
  21206. @end deftypevr
  21207. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  21208. The way in which repositories in each section are sorted.
  21209. Defaults to @samp{""}.
  21210. @end deftypevr
  21211. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  21212. Text used as content for the @code{robots} meta-tag.
  21213. Defaults to @samp{("noindex" "nofollow")}.
  21214. @end deftypevr
  21215. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  21216. Text printed below the heading on the repository index page.
  21217. Defaults to @samp{"a fast webinterface for the git dscm"}.
  21218. @end deftypevr
  21219. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  21220. The content of the file specified with this option will be included
  21221. verbatim below the ``about'' link on the repository index page.
  21222. Defaults to @samp{""}.
  21223. @end deftypevr
  21224. @deftypevr {@code{cgit-configuration} parameter} string root-title
  21225. Text printed as heading on the repository index page.
  21226. Defaults to @samp{""}.
  21227. @end deftypevr
  21228. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  21229. If set to @samp{#t} and repository-directory is enabled,
  21230. repository-directory will recurse into directories whose name starts
  21231. with a period. Otherwise, repository-directory will stay away from such
  21232. directories, considered as ``hidden''. Note that this does not apply to
  21233. the @file{.git} directory in non-bare repos.
  21234. Defaults to @samp{#f}.
  21235. @end deftypevr
  21236. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  21237. Text which specifies the default set of snapshot formats that cgit
  21238. generates links for.
  21239. Defaults to @samp{()}.
  21240. @end deftypevr
  21241. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  21242. Name of the directory to scan for repositories (represents
  21243. @code{scan-path}).
  21244. Defaults to @samp{"/srv/git"}.
  21245. @end deftypevr
  21246. @deftypevr {@code{cgit-configuration} parameter} string section
  21247. The name of the current repository section - all repositories defined
  21248. after this option will inherit the current section name.
  21249. Defaults to @samp{""}.
  21250. @end deftypevr
  21251. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  21252. Flag which, when set to @samp{1}, will sort the sections on the
  21253. repository listing by name.
  21254. Defaults to @samp{""}.
  21255. @end deftypevr
  21256. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  21257. A number which, if defined prior to repository-directory, specifies how
  21258. many path elements from each repo path to use as a default section name.
  21259. Defaults to @samp{0}.
  21260. @end deftypevr
  21261. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  21262. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  21263. default.
  21264. Defaults to @samp{#f}.
  21265. @end deftypevr
  21266. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  21267. Specifies a command which will be invoked to format plaintext blobs in
  21268. the tree view.
  21269. Defaults to @samp{""}.
  21270. @end deftypevr
  21271. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  21272. Specifies the number of branches to display in the repository ``summary''
  21273. view.
  21274. Defaults to @samp{10}.
  21275. @end deftypevr
  21276. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  21277. Specifies the number of log entries to display in the repository
  21278. ``summary'' view.
  21279. Defaults to @samp{10}.
  21280. @end deftypevr
  21281. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  21282. Specifies the number of tags to display in the repository ``summary''
  21283. view.
  21284. Defaults to @samp{10}.
  21285. @end deftypevr
  21286. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  21287. Filename which, if specified, needs to be present within the repository
  21288. for cgit to allow access to that repository.
  21289. Defaults to @samp{""}.
  21290. @end deftypevr
  21291. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  21292. URL which, if specified, will be used as root for all cgit links.
  21293. Defaults to @samp{"/"}.
  21294. @end deftypevr
  21295. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  21296. A list of @dfn{cgit-repo} records to use with config.
  21297. Defaults to @samp{()}.
  21298. Available @code{repository-cgit-configuration} fields are:
  21299. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  21300. A mask of snapshot formats for this repo that cgit generates links for,
  21301. restricted by the global @code{snapshots} setting.
  21302. Defaults to @samp{()}.
  21303. @end deftypevr
  21304. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  21305. Override the default @code{source-filter}.
  21306. Defaults to @samp{""}.
  21307. @end deftypevr
  21308. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  21309. The relative URL used to access the repository.
  21310. Defaults to @samp{""}.
  21311. @end deftypevr
  21312. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  21313. Override the default @code{about-filter}.
  21314. Defaults to @samp{""}.
  21315. @end deftypevr
  21316. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  21317. Flag which, when set to @samp{age}, enables date ordering in the branch
  21318. ref list, and when set to @samp{name} enables ordering by branch name.
  21319. Defaults to @samp{""}.
  21320. @end deftypevr
  21321. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  21322. A list of URLs which can be used to clone repo.
  21323. Defaults to @samp{()}.
  21324. @end deftypevr
  21325. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  21326. Override the default @code{commit-filter}.
  21327. Defaults to @samp{""}.
  21328. @end deftypevr
  21329. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  21330. Flag which, when set to @samp{date}, enables strict date ordering in the
  21331. commit log, and when set to @samp{topo} enables strict topological
  21332. ordering.
  21333. Defaults to @samp{""}.
  21334. @end deftypevr
  21335. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  21336. The name of the default branch for this repository. If no such branch
  21337. exists in the repository, the first branch name (when sorted) is used as
  21338. default instead. By default branch pointed to by HEAD, or ``master'' if
  21339. there is no suitable HEAD.
  21340. Defaults to @samp{""}.
  21341. @end deftypevr
  21342. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  21343. The value to show as repository description.
  21344. Defaults to @samp{""}.
  21345. @end deftypevr
  21346. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  21347. The value to show as repository homepage.
  21348. Defaults to @samp{""}.
  21349. @end deftypevr
  21350. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  21351. Override the default @code{email-filter}.
  21352. Defaults to @samp{""}.
  21353. @end deftypevr
  21354. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  21355. A flag which can be used to disable the global setting
  21356. @code{enable-commit-graph?}.
  21357. Defaults to @samp{disabled}.
  21358. @end deftypevr
  21359. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  21360. A flag which can be used to disable the global setting
  21361. @code{enable-log-filecount?}.
  21362. Defaults to @samp{disabled}.
  21363. @end deftypevr
  21364. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  21365. A flag which can be used to disable the global setting
  21366. @code{enable-log-linecount?}.
  21367. Defaults to @samp{disabled}.
  21368. @end deftypevr
  21369. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  21370. Flag which, when set to @code{#t}, will make cgit display remote
  21371. branches in the summary and refs views.
  21372. Defaults to @samp{disabled}.
  21373. @end deftypevr
  21374. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  21375. A flag which can be used to override the global setting
  21376. @code{enable-subject-links?}.
  21377. Defaults to @samp{disabled}.
  21378. @end deftypevr
  21379. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  21380. A flag which can be used to override the global setting
  21381. @code{enable-html-serving?}.
  21382. Defaults to @samp{disabled}.
  21383. @end deftypevr
  21384. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  21385. Flag which, when set to @code{#t}, hides the repository from the
  21386. repository index.
  21387. Defaults to @samp{#f}.
  21388. @end deftypevr
  21389. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  21390. Flag which, when set to @samp{#t}, ignores the repository.
  21391. Defaults to @samp{#f}.
  21392. @end deftypevr
  21393. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  21394. URL which specifies the source of an image which will be used as a logo
  21395. on this repo’s pages.
  21396. Defaults to @samp{""}.
  21397. @end deftypevr
  21398. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  21399. URL loaded when clicking on the cgit logo image.
  21400. Defaults to @samp{""}.
  21401. @end deftypevr
  21402. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  21403. Override the default @code{owner-filter}.
  21404. Defaults to @samp{""}.
  21405. @end deftypevr
  21406. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  21407. Text which will be used as the formatstring for a hyperlink when a
  21408. submodule is printed in a directory listing. The arguments for the
  21409. formatstring are the path and SHA1 of the submodule commit.
  21410. Defaults to @samp{""}.
  21411. @end deftypevr
  21412. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  21413. Text which will be used as the formatstring for a hyperlink when a
  21414. submodule with the specified subdirectory path is printed in a directory
  21415. listing.
  21416. Defaults to @samp{()}.
  21417. @end deftypevr
  21418. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  21419. Override the default maximum statistics period.
  21420. Defaults to @samp{""}.
  21421. @end deftypevr
  21422. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  21423. The value to show as repository name.
  21424. Defaults to @samp{""}.
  21425. @end deftypevr
  21426. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  21427. A value used to identify the owner of the repository.
  21428. Defaults to @samp{""}.
  21429. @end deftypevr
  21430. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  21431. An absolute path to the repository directory.
  21432. Defaults to @samp{""}.
  21433. @end deftypevr
  21434. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  21435. A path (relative to repo) which specifies a file to include verbatim as
  21436. the ``About'' page for this repo.
  21437. Defaults to @samp{""}.
  21438. @end deftypevr
  21439. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  21440. The name of the current repository section - all repositories defined
  21441. after this option will inherit the current section name.
  21442. Defaults to @samp{""}.
  21443. @end deftypevr
  21444. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  21445. Extra options will be appended to cgitrc file.
  21446. Defaults to @samp{()}.
  21447. @end deftypevr
  21448. @end deftypevr
  21449. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  21450. Extra options will be appended to cgitrc file.
  21451. Defaults to @samp{()}.
  21452. @end deftypevr
  21453. @c %end of fragment
  21454. However, it could be that you just want to get a @code{cgitrc} up and
  21455. running. In that case, you can pass an @code{opaque-cgit-configuration}
  21456. as a record to @code{cgit-service-type}. As its name indicates, an
  21457. opaque configuration does not have easy reflective capabilities.
  21458. Available @code{opaque-cgit-configuration} fields are:
  21459. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  21460. The cgit package.
  21461. @end deftypevr
  21462. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  21463. The contents of the @code{cgitrc}, as a string.
  21464. @end deftypevr
  21465. For example, if your @code{cgitrc} is just the empty string, you
  21466. could instantiate a cgit service like this:
  21467. @lisp
  21468. (service cgit-service-type
  21469. (opaque-cgit-configuration
  21470. (cgitrc "")))
  21471. @end lisp
  21472. @subsubheading Gitolite Service
  21473. @cindex Gitolite service
  21474. @cindex Git, hosting
  21475. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  21476. repositories on a central server.
  21477. Gitolite can handle multiple repositories and users, and supports flexible
  21478. configuration of the permissions for the users on the repositories.
  21479. The following example will configure Gitolite using the default @code{git}
  21480. user, and the provided SSH public key.
  21481. @lisp
  21482. (service gitolite-service-type
  21483. (gitolite-configuration
  21484. (admin-pubkey (plain-file
  21485. "yourname.pub"
  21486. "ssh-rsa AAAA... guix@@example.com"))))
  21487. @end lisp
  21488. Gitolite is configured through a special admin repository which you can clone,
  21489. for example, if you setup Gitolite on @code{example.com}, you would run the
  21490. following command to clone the admin repository.
  21491. @example
  21492. git clone git@@example.com:gitolite-admin
  21493. @end example
  21494. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  21495. be inserted in to the @file{keydir} directory in the gitolite-admin
  21496. repository. If this results in a change in the repository, it will be
  21497. committed using the message ``gitolite setup by GNU Guix''.
  21498. @deftp {Data Type} gitolite-configuration
  21499. Data type representing the configuration for @code{gitolite-service-type}.
  21500. @table @asis
  21501. @item @code{package} (default: @var{gitolite})
  21502. Gitolite package to use.
  21503. @item @code{user} (default: @var{git})
  21504. User to use for Gitolite. This will be user that you use when accessing
  21505. Gitolite over SSH.
  21506. @item @code{group} (default: @var{git})
  21507. Group to use for Gitolite.
  21508. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  21509. Directory in which to store the Gitolite configuration and repositories.
  21510. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  21511. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  21512. representing the configuration for Gitolite.
  21513. @item @code{admin-pubkey} (default: @var{#f})
  21514. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  21515. setup Gitolite. This will be inserted in to the @file{keydir} directory
  21516. within the gitolite-admin repository.
  21517. To specify the SSH key as a string, use the @code{plain-file} function.
  21518. @lisp
  21519. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  21520. @end lisp
  21521. @end table
  21522. @end deftp
  21523. @deftp {Data Type} gitolite-rc-file
  21524. Data type representing the Gitolite RC file.
  21525. @table @asis
  21526. @item @code{umask} (default: @code{#o0077})
  21527. This controls the permissions Gitolite sets on the repositories and their
  21528. contents.
  21529. A value like @code{#o0027} will give read access to the group used by Gitolite
  21530. (by default: @code{git}). This is necessary when using Gitolite with software
  21531. like cgit or gitweb.
  21532. @item @code{git-config-keys} (default: @code{""})
  21533. Gitolite allows you to set git config values using the @samp{config} keyword. This
  21534. setting allows control over the config keys to accept.
  21535. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  21536. Set the role names allowed to be used by users running the perms command.
  21537. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  21538. This setting controls the commands and features to enable within Gitolite.
  21539. @end table
  21540. @end deftp
  21541. @node Game Services
  21542. @subsection Game Services
  21543. @subsubheading The Battle for Wesnoth Service
  21544. @cindex wesnothd
  21545. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  21546. based tactical strategy game, with several single player campaigns, and
  21547. multiplayer games (both networked and local).
  21548. @defvar {Scheme Variable} wesnothd-service-type
  21549. Service type for the wesnothd service. Its value must be a
  21550. @code{wesnothd-configuration} object. To run wesnothd in the default
  21551. configuration, instantiate it as:
  21552. @lisp
  21553. (service wesnothd-service-type)
  21554. @end lisp
  21555. @end defvar
  21556. @deftp {Data Type} wesnothd-configuration
  21557. Data type representing the configuration of @command{wesnothd}.
  21558. @table @asis
  21559. @item @code{package} (default: @code{wesnoth-server})
  21560. The wesnoth server package to use.
  21561. @item @code{port} (default: @code{15000})
  21562. The port to bind the server to.
  21563. @end table
  21564. @end deftp
  21565. @node PAM Mount Service
  21566. @subsection PAM Mount Service
  21567. @cindex pam-mount
  21568. The @code{(gnu services pam-mount)} module provides a service allowing
  21569. users to mount volumes when they log in. It should be able to mount any
  21570. volume format supported by the system.
  21571. @defvar {Scheme Variable} pam-mount-service-type
  21572. Service type for PAM Mount support.
  21573. @end defvar
  21574. @deftp {Data Type} pam-mount-configuration
  21575. Data type representing the configuration of PAM Mount.
  21576. It takes the following parameters:
  21577. @table @asis
  21578. @item @code{rules}
  21579. The configuration rules that will be used to generate
  21580. @file{/etc/security/pam_mount.conf.xml}.
  21581. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  21582. Guile Reference Manual}), and the the default ones don't mount anything
  21583. for anyone at login:
  21584. @lisp
  21585. `((debug (@@ (enable "0")))
  21586. (mntoptions (@@ (allow ,(string-join
  21587. '("nosuid" "nodev" "loop"
  21588. "encryption" "fsck" "nonempty"
  21589. "allow_root" "allow_other")
  21590. ","))))
  21591. (mntoptions (@@ (require "nosuid,nodev")))
  21592. (logout (@@ (wait "0")
  21593. (hup "0")
  21594. (term "no")
  21595. (kill "no")))
  21596. (mkmountpoint (@@ (enable "1")
  21597. (remove "true"))))
  21598. @end lisp
  21599. Some @code{volume} elements must be added to automatically mount volumes
  21600. at login. Here's an example allowing the user @code{alice} to mount her
  21601. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  21602. the partition where he stores his data:
  21603. @lisp
  21604. (define pam-mount-rules
  21605. `((debug (@@ (enable "0")))
  21606. (volume (@@ (user "alice")
  21607. (fstype "crypt")
  21608. (path "/dev/sda2")
  21609. (mountpoint "/home/alice")))
  21610. (volume (@@ (user "bob")
  21611. (fstype "auto")
  21612. (path "/dev/sdb3")
  21613. (mountpoint "/home/bob/data")
  21614. (options "defaults,autodefrag,compress")))
  21615. (mntoptions (@@ (allow ,(string-join
  21616. '("nosuid" "nodev" "loop"
  21617. "encryption" "fsck" "nonempty"
  21618. "allow_root" "allow_other")
  21619. ","))))
  21620. (mntoptions (@@ (require "nosuid,nodev")))
  21621. (logout (@@ (wait "0")
  21622. (hup "0")
  21623. (term "no")
  21624. (kill "no")))
  21625. (mkmountpoint (@@ (enable "1")
  21626. (remove "true")))))
  21627. (service pam-mount-service-type
  21628. (pam-mount-configuration
  21629. (rules pam-mount-rules)))
  21630. @end lisp
  21631. The complete list of possible options can be found in the man page for
  21632. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  21633. @end table
  21634. @end deftp
  21635. @node Guix Services
  21636. @subsection Guix Services
  21637. @subsubheading Guix Build Coordinator
  21638. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  21639. Coordinator} aids in distributing derivation builds among machines
  21640. running an @dfn{agent}. The build daemon is still used to build the
  21641. derivations, but the Guix Build Coordinator manages allocating builds
  21642. and working with the results.
  21643. @quotation Note
  21644. This service is considered experimental. Configuration options may be
  21645. changed in a backwards-incompatible manner, and not all features have
  21646. been thorougly tested.
  21647. @end quotation
  21648. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  21649. more connected @dfn{agent} processes. The coordinator process handles
  21650. clients submitting builds, and allocating builds to agents. The agent
  21651. processes talk to a build daemon to actually perform the builds, then
  21652. send the results back to the coordinator.
  21653. There is a script to run the coordinator component of the Guix Build
  21654. Coordinator, but the Guix service uses a custom Guile script instead, to
  21655. provide better integration with G-expressions used in the configuration.
  21656. @defvar {Scheme Variable} guix-build-coordinator-service-type
  21657. Service type for the Guix Build Coordinator. Its value must be a
  21658. @code{guix-build-coordinator-configuration} object.
  21659. @end defvar
  21660. @deftp {Data Type} guix-build-coordinator-configuration
  21661. Data type representing the configuration of the Guix Build Coordinator.
  21662. @table @asis
  21663. @item @code{package} (default: @code{guix-build-coordinator})
  21664. The Guix Build Coordinator package to use.
  21665. @item @code{user} (default: @code{"guix-build-coordinator"})
  21666. The system user to run the service as.
  21667. @item @code{group} (default: @code{"guix-build-coordinator"})
  21668. The system group to run the service as.
  21669. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  21670. The URI to use for the database.
  21671. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  21672. The URI describing how to listen to requests from agent processes.
  21673. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  21674. The URI describing how to listen to requests from clients. The client
  21675. API allows submitting builds and currently isn't authenticated, so take
  21676. care when configuring this value.
  21677. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  21678. A G-expression for the allocation strategy to be used. This is a
  21679. procedure that takes the datastore as an argument and populates the
  21680. allocation plan in the database.
  21681. @item @code{hooks} (default: @var{'()})
  21682. An association list of hooks. These provide a way to execute arbitrary
  21683. code upon certian events, like a build result being processed.
  21684. @item @code{guile} (default: @code{guile-3.0-latest})
  21685. The Guile package with which to run the Guix Build Coordinator.
  21686. @end table
  21687. @end deftp
  21688. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  21689. Service type for a Guix Build Coordinator agent. Its value must be a
  21690. @code{guix-build-coordinator-agent-configuration} object.
  21691. @end defvar
  21692. @deftp {Data Type} guix-build-coordinator-agent-configuration
  21693. Data type representing the configuration a Guix Build Coordinator agent.
  21694. @table @asis
  21695. @item @code{package} (default: @code{guix-build-coordinator})
  21696. The Guix Build Coordinator package to use.
  21697. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  21698. The system user to run the service as.
  21699. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  21700. The URI to use when connecting to the coordinator.
  21701. @item @code{uuid}
  21702. The UUID of the agent. This should be generated by the coordinator
  21703. process, stored in the coordinator database, and used by the intended
  21704. agent.
  21705. @item @code{password} (default: @code{#f})
  21706. The password to use when connecting to the coordinator. A file to read
  21707. the password from can also be specified, and this is more secure.
  21708. @item @code{password-file} (default: @code{#f})
  21709. A file containing the password to use when connecting to the
  21710. coordinator.
  21711. @item @code{systems} (default: @var{#f})
  21712. The systems for which this agent should fetch builds. The agent process
  21713. will use the current system it's running on as the default.
  21714. @item @code{max-parallel-builds} (default: @code{1})
  21715. The number of builds to perform in parallel.
  21716. @item @code{derivation-substitute-urls} (default: @code{1})
  21717. URLs from which to attempt to fetch substitutes for derivations, if the
  21718. derivations aren't already available.
  21719. @item @code{non-derivation-substitute-urls} (default: @code{1})
  21720. URLs from which to attempt to fetch substitutes for build inputs, if the
  21721. input store items aren't already available.
  21722. @end table
  21723. @end deftp
  21724. The Guix Build Coordinator package contains a script to query an
  21725. instance of the Guix Data Service for derivations to build, and then
  21726. submit builds for those derivations to the coordinator. The service
  21727. type below assists in running this script. This is an additional tool
  21728. that may be useful when building derivations contained within an
  21729. instance of the Guix Data Service.
  21730. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  21731. Service type for the
  21732. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  21733. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  21734. object.
  21735. @end defvar
  21736. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  21737. Data type representing the options to the queue builds from guix data
  21738. service script.
  21739. @table @asis
  21740. @item @code{package} (default: @code{guix-build-coordinator})
  21741. The Guix Build Coordinator package to use.
  21742. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  21743. The system user to run the service as.
  21744. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  21745. The URI to use when connecting to the coordinator.
  21746. @item @code{systems} (default: @code{#f})
  21747. The systems for which to fetch derivations to build.
  21748. @item @code{systems-and-targets} (default: @code{#f})
  21749. An association list of system and target pairs for which to fetch
  21750. derivations to build.
  21751. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  21752. The Guix Data Service instance from which to query to find out about
  21753. derivations to build.
  21754. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  21755. A file to record which commits have been processed, to avoid needlessly
  21756. processing them again if the service is restarted.
  21757. @end table
  21758. @end deftp
  21759. @subsubheading Guix Data Service
  21760. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  21761. and provides data about GNU Guix. This includes information about
  21762. packages, derivations and lint warnings.
  21763. The data is stored in a PostgreSQL database, and available through a web
  21764. interface.
  21765. @defvar {Scheme Variable} guix-data-service-type
  21766. Service type for the Guix Data Service. Its value must be a
  21767. @code{guix-data-service-configuration} object. The service optionally
  21768. extends the getmail service, as the guix-commits mailing list is used to
  21769. find out about changes in the Guix git repository.
  21770. @end defvar
  21771. @deftp {Data Type} guix-data-service-configuration
  21772. Data type representing the configuration of the Guix Data Service.
  21773. @table @asis
  21774. @item @code{package} (default: @code{guix-data-service})
  21775. The Guix Data Service package to use.
  21776. @item @code{user} (default: @code{"guix-data-service"})
  21777. The system user to run the service as.
  21778. @item @code{group} (default: @code{"guix-data-service"})
  21779. The system group to run the service as.
  21780. @item @code{port} (default: @code{8765})
  21781. The port to bind the web service to.
  21782. @item @code{host} (default: @code{"127.0.0.1"})
  21783. The host to bind the web service to.
  21784. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  21785. If set, this is the list of mailboxes that the getmail service will be
  21786. configured to listen to.
  21787. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  21788. If set, this is the @code{getmail-retriever-configuration} object with
  21789. which to configure getmail to fetch mail from the guix-commits mailing
  21790. list.
  21791. @item @code{extra-options} (default: @var{'()})
  21792. Extra command line options for @code{guix-data-service}.
  21793. @item @code{extra-process-jobs-options} (default: @var{'()})
  21794. Extra command line options for @code{guix-data-service-process-jobs}.
  21795. @end table
  21796. @end deftp
  21797. @node Linux Services
  21798. @subsection Linux Services
  21799. @cindex oom
  21800. @cindex out of memory killer
  21801. @cindex earlyoom
  21802. @cindex early out of memory daemon
  21803. @subsubheading Early OOM Service
  21804. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  21805. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  21806. space and provides a more responsive and configurable alternative to the
  21807. in-kernel OOM killer. It is useful to prevent the system from becoming
  21808. unresponsive when it runs out of memory.
  21809. @deffn {Scheme Variable} earlyoom-service-type
  21810. The service type for running @command{earlyoom}, the Early OOM daemon.
  21811. Its value must be a @code{earlyoom-configuration} object, described
  21812. below. The service can be instantiated in its default configuration
  21813. with:
  21814. @lisp
  21815. (service earlyoom-service-type)
  21816. @end lisp
  21817. @end deffn
  21818. @deftp {Data Type} earlyoom-configuration
  21819. This is the configuration record for the @code{earlyoom-service-type}.
  21820. @table @asis
  21821. @item @code{earlyoom} (default: @var{earlyoom})
  21822. The Earlyoom package to use.
  21823. @item @code{minimum-available-memory} (default: @code{10})
  21824. The threshold for the minimum @emph{available} memory, in percentages.
  21825. @item @code{minimum-free-swap} (default: @code{10})
  21826. The threshold for the minimum free swap memory, in percentages.
  21827. @item @code{prefer-regexp} (default: @code{#f})
  21828. A regular expression (as a string) to match the names of the processes
  21829. that should be preferably killed.
  21830. @item @code{avoid-regexp} (default: @code{#f})
  21831. A regular expression (as a string) to match the names of the processes
  21832. that should @emph{not} be killed.
  21833. @item @code{memory-report-interval} (default: @code{0})
  21834. The interval in seconds at which a memory report is printed. It is
  21835. disabled by default.
  21836. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  21837. A boolean indicating whether the positive adjustments set in
  21838. @file{/proc/*/oom_score_adj}.
  21839. @item @code{show-debug-messages?} (default: @code{#f})
  21840. A boolean indicating whether debug messages should be printed. The logs
  21841. are saved at @file{/var/log/earlyoom.log}.
  21842. @item @code{send-notification-command} (default: @code{#f})
  21843. This can be used to provide a custom command used for sending
  21844. notifications.
  21845. @end table
  21846. @end deftp
  21847. @cindex modprobe
  21848. @cindex kernel module loader
  21849. @subsubheading Kernel Module Loader Service
  21850. The kernel module loader service allows one to load loadable kernel
  21851. modules at boot. This is especially useful for modules that don't
  21852. autoload and need to be manually loaded, as it's the case with
  21853. @code{ddcci}.
  21854. @deffn {Scheme Variable} kernel-module-loader-service-type
  21855. The service type for loading loadable kernel modules at boot with
  21856. @command{modprobe}. Its value must be a list of strings representing
  21857. module names. For example loading the drivers provided by
  21858. @code{ddcci-driver-linux}, in debugging mode by passing some module
  21859. parameters, can be done as follow:
  21860. @lisp
  21861. (use-modules (gnu) (gnu services))
  21862. (use-package-modules linux)
  21863. (use-service-modules linux)
  21864. (define ddcci-config
  21865. (plain-file "ddcci.conf"
  21866. "options ddcci dyndbg delay=120"))
  21867. (operating-system
  21868. ...
  21869. (services (cons* (service kernel-module-loader-service-type
  21870. '("ddcci" "ddcci_backlight"))
  21871. (simple-service 'ddcci-config etc-service-type
  21872. (list `("modprobe.d/ddcci.conf"
  21873. ,ddcci-config)))
  21874. %base-services))
  21875. (kernel-loadable-modules (list ddcci-driver-linux)))
  21876. @end lisp
  21877. @end deffn
  21878. @cindex zram
  21879. @cindex compressed swap
  21880. @cindex Compressed RAM-based block devices
  21881. @subsubheading Zram Device Service
  21882. The Zram device service provides a compressed swap device in system
  21883. memory. The Linux Kernel documentation has more information about
  21884. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  21885. devices.
  21886. @deffn {Scheme Variable} zram-device-service-type
  21887. This service creates the zram block device, formats it as swap and
  21888. enables it as a swap device. The service's value is a
  21889. @code{zram-device-configuration} record.
  21890. @deftp {Data Type} zram-device-configuration
  21891. This is the data type representing the configuration for the zram-device
  21892. service.
  21893. @table @asis
  21894. @item @code{size} (default @var{"1G"})
  21895. This is the amount of space you wish to provide for the zram device. It
  21896. accepts a string and can be a number of bytes or use a suffix, eg.:
  21897. @var{"512M"} or @var{1024000}.
  21898. @item @code{compression-algorithm} (default @var{'lzo})
  21899. This is the compression algorithm you wish to use. It is difficult to
  21900. list all the possible compression options, but common ones supported by
  21901. Guix's Linux Libre Kernel include @var{'lzo}, @var{'lz4} and @var{'zstd}.
  21902. @item @code{memory-limit} (default @var{0})
  21903. This is the maximum amount of memory which the zram device can use.
  21904. Setting it to '0' disables the limit. While it is generally expected
  21905. that compression will be 2:1, it is possible that uncompressable data
  21906. can be written to swap and this is a method to limit how much memory can
  21907. be used. It accepts a string and can be a number of bytes or use a
  21908. suffix, eg.: @var{"2G"}.
  21909. @item @code{priority} (default @var{-1})
  21910. This is the priority of the swap device created from the zram device.
  21911. @code{swapon} accepts values between -1 and 32767, with higher values
  21912. indicating higher priority. Higher priority swap will generally be used
  21913. first.
  21914. @end table
  21915. @end deftp
  21916. @end deffn
  21917. @node Hurd Services
  21918. @subsection Hurd Services
  21919. @defvr {Scheme Variable} hurd-console-service-type
  21920. This service starts the fancy @code{VGA} console client on the Hurd.
  21921. The service's value is a @code{hurd-console-configuration} record.
  21922. @end defvr
  21923. @deftp {Data Type} hurd-console-configuration
  21924. This is the data type representing the configuration for the
  21925. hurd-console-service.
  21926. @table @asis
  21927. @item @code{hurd} (default: @var{hurd})
  21928. The Hurd package to use.
  21929. @end table
  21930. @end deftp
  21931. @defvr {Scheme Variable} hurd-getty-service-type
  21932. This service starts a tty using the Hurd @code{getty} program.
  21933. The service's value is a @code{hurd-getty-configuration} record.
  21934. @end defvr
  21935. @deftp {Data Type} hurd-getty-configuration
  21936. This is the data type representing the configuration for the
  21937. hurd-getty-service.
  21938. @table @asis
  21939. @item @code{hurd} (default: @var{hurd})
  21940. The Hurd package to use.
  21941. @item @code{tty}
  21942. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  21943. @item @code{baud-rate} (default: @code{38400})
  21944. An integer specifying the baud rate of the tty.
  21945. @end table
  21946. @end deftp
  21947. @node Miscellaneous Services
  21948. @subsection Miscellaneous Services
  21949. @cindex fingerprint
  21950. @subsubheading Fingerprint Service
  21951. The @code{(gnu services authentication)} module provides a DBus service to
  21952. read and identify fingerprints via a fingerprint sensor.
  21953. @defvr {Scheme Variable} fprintd-service-type
  21954. The service type for @command{fprintd}, which provides the fingerprint
  21955. reading capability.
  21956. @lisp
  21957. (service fprintd-service-type)
  21958. @end lisp
  21959. @end defvr
  21960. @cindex sysctl
  21961. @subsubheading System Control Service
  21962. The @code{(gnu services sysctl)} provides a service to configure kernel
  21963. parameters at boot.
  21964. @defvr {Scheme Variable} sysctl-service-type
  21965. The service type for @command{sysctl}, which modifies kernel parameters
  21966. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  21967. instantiated as:
  21968. @lisp
  21969. (service sysctl-service-type
  21970. (sysctl-configuration
  21971. (settings '(("net.ipv4.ip_forward" . "1")))))
  21972. @end lisp
  21973. @end defvr
  21974. @deftp {Data Type} sysctl-configuration
  21975. The data type representing the configuration of @command{sysctl}.
  21976. @table @asis
  21977. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  21978. The @command{sysctl} executable to use.
  21979. @item @code{settings} (default: @code{'()})
  21980. An association list specifies kernel parameters and their values.
  21981. @end table
  21982. @end deftp
  21983. @cindex pcscd
  21984. @subsubheading PC/SC Smart Card Daemon Service
  21985. The @code{(gnu services security-token)} module provides the following service
  21986. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  21987. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  21988. manager that coordinates communications with smart card readers, smart cards
  21989. and cryptographic tokens that are connected to the system.
  21990. @defvr {Scheme Variable} pcscd-service-type
  21991. Service type for the @command{pcscd} service. Its value must be a
  21992. @code{pcscd-configuration} object. To run pcscd in the default
  21993. configuration, instantiate it as:
  21994. @lisp
  21995. (service pcscd-service-type)
  21996. @end lisp
  21997. @end defvr
  21998. @deftp {Data Type} pcscd-configuration
  21999. The data type representing the configuration of @command{pcscd}.
  22000. @table @asis
  22001. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  22002. The pcsc-lite package that provides pcscd.
  22003. @item @code{usb-drivers} (default: @code{(list ccid)})
  22004. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  22005. under @file{pcsc/drivers} in the store directory of the package.
  22006. @end table
  22007. @end deftp
  22008. @cindex lirc
  22009. @subsubheading Lirc Service
  22010. The @code{(gnu services lirc)} module provides the following service.
  22011. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  22012. [#:device #f] [#:driver #f] [#:config-file #f] @
  22013. [#:extra-options '()]
  22014. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  22015. decodes infrared signals from remote controls.
  22016. Optionally, @var{device}, @var{driver} and @var{config-file}
  22017. (configuration file name) may be specified. See @command{lircd} manual
  22018. for details.
  22019. Finally, @var{extra-options} is a list of additional command-line options
  22020. passed to @command{lircd}.
  22021. @end deffn
  22022. @cindex spice
  22023. @subsubheading Spice Service
  22024. The @code{(gnu services spice)} module provides the following service.
  22025. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  22026. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  22027. that enables sharing the clipboard with a vm and setting the guest display
  22028. resolution when the graphical console window resizes.
  22029. @end deffn
  22030. @cindex inputattach
  22031. @subsubheading inputattach Service
  22032. @cindex tablet input, for Xorg
  22033. @cindex touchscreen input, for Xorg
  22034. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  22035. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  22036. Xorg display server.
  22037. @deffn {Scheme Variable} inputattach-service-type
  22038. Type of a service that runs @command{inputattach} on a device and
  22039. dispatches events from it.
  22040. @end deffn
  22041. @deftp {Data Type} inputattach-configuration
  22042. @table @asis
  22043. @item @code{device-type} (default: @code{"wacom"})
  22044. The type of device to connect to. Run @command{inputattach --help}, from the
  22045. @code{inputattach} package, to see the list of supported device types.
  22046. @item @code{device} (default: @code{"/dev/ttyS0"})
  22047. The device file to connect to the device.
  22048. @item @code{baud-rate} (default: @code{#f})
  22049. Baud rate to use for the serial connection.
  22050. Should be a number or @code{#f}.
  22051. @item @code{log-file} (default: @code{#f})
  22052. If true, this must be the name of a file to log messages to.
  22053. @end table
  22054. @end deftp
  22055. @subsubheading Dictionary Service
  22056. @cindex dictionary
  22057. The @code{(gnu services dict)} module provides the following service:
  22058. @defvr {Scheme Variable} dicod-service-type
  22059. This is the type of the service that runs the @command{dicod} daemon, an
  22060. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  22061. @end defvr
  22062. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  22063. Return a service that runs the @command{dicod} daemon, an implementation
  22064. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  22065. The optional @var{config} argument specifies the configuration for
  22066. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  22067. default it serves the GNU Collaborative International Dictionary of English.
  22068. You can add @command{open localhost} to your @file{~/.dico} file to make
  22069. @code{localhost} the default server for @command{dico} client
  22070. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  22071. @end deffn
  22072. @deftp {Data Type} dicod-configuration
  22073. Data type representing the configuration of dicod.
  22074. @table @asis
  22075. @item @code{dico} (default: @var{dico})
  22076. Package object of the GNU Dico dictionary server.
  22077. @item @code{interfaces} (default: @var{'("localhost")})
  22078. This is the list of IP addresses and ports and possibly socket file
  22079. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  22080. dico, GNU Dico Manual}).
  22081. @item @code{handlers} (default: @var{'()})
  22082. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  22083. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  22084. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  22085. @end table
  22086. @end deftp
  22087. @deftp {Data Type} dicod-handler
  22088. Data type representing a dictionary handler (module instance).
  22089. @table @asis
  22090. @item @code{name}
  22091. Name of the handler (module instance).
  22092. @item @code{module} (default: @var{#f})
  22093. Name of the dicod module of the handler (instance). If it is @code{#f},
  22094. the module has the same name as the handler.
  22095. (@pxref{Modules,,, dico, GNU Dico Manual}).
  22096. @item @code{options}
  22097. List of strings or gexps representing the arguments for the module handler
  22098. @end table
  22099. @end deftp
  22100. @deftp {Data Type} dicod-database
  22101. Data type representing a dictionary database.
  22102. @table @asis
  22103. @item @code{name}
  22104. Name of the database, will be used in DICT commands.
  22105. @item @code{handler}
  22106. Name of the dicod handler (module instance) used by this database
  22107. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  22108. @item @code{complex?} (default: @var{#f})
  22109. Whether the database configuration complex. The complex configuration
  22110. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  22111. @item @code{options}
  22112. List of strings or gexps representing the arguments for the database
  22113. (@pxref{Databases,,, dico, GNU Dico Manual}).
  22114. @end table
  22115. @end deftp
  22116. @defvr {Scheme Variable} %dicod-database:gcide
  22117. A @code{<dicod-database>} object serving the GNU Collaborative International
  22118. Dictionary of English using the @code{gcide} package.
  22119. @end defvr
  22120. The following is an example @code{dicod-service} configuration.
  22121. @lisp
  22122. (dicod-service #:config
  22123. (dicod-configuration
  22124. (handlers (list (dicod-handler
  22125. (name "wordnet")
  22126. (module "dictorg")
  22127. (options
  22128. (list #~(string-append "dbdir=" #$wordnet))))))
  22129. (databases (list (dicod-database
  22130. (name "wordnet")
  22131. (complex? #t)
  22132. (handler "wordnet")
  22133. (options '("database=wn")))
  22134. %dicod-database:gcide))))
  22135. @end lisp
  22136. @cindex Docker
  22137. @subsubheading Docker Service
  22138. The @code{(gnu services docker)} module provides the following services.
  22139. @defvr {Scheme Variable} docker-service-type
  22140. This is the type of the service that runs @url{https://www.docker.com,Docker},
  22141. a daemon that can execute application bundles (sometimes referred to as
  22142. ``containers'') in isolated environments.
  22143. @end defvr
  22144. @deftp {Data Type} docker-configuration
  22145. This is the data type representing the configuration of Docker and Containerd.
  22146. @table @asis
  22147. @item @code{package} (default: @code{docker})
  22148. The Docker daemon package to use.
  22149. @item @code{package} (default: @code{docker-cli})
  22150. The Docker client package to use.
  22151. @item @code{containerd} (default: @var{containerd})
  22152. The Containerd package to use.
  22153. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  22154. The Docker user-land networking proxy package to use.
  22155. @item @code{enable-proxy?} (default @code{#t})
  22156. Enable or disable the use of the Docker user-land networking proxy.
  22157. @item @code{debug?} (default @code{#f})
  22158. Enable or disable debug output.
  22159. @item @code{enable-iptables?} (default @code{#t})
  22160. Enable or disable the addition of iptables rules.
  22161. @end table
  22162. @end deftp
  22163. @cindex Audit
  22164. @subsubheading Auditd Service
  22165. The @code{(gnu services auditd)} module provides the following service.
  22166. @defvr {Scheme Variable} auditd-service-type
  22167. This is the type of the service that runs
  22168. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  22169. a daemon that tracks security-relevant information on your system.
  22170. Examples of things that can be tracked:
  22171. @enumerate
  22172. @item
  22173. File accesses
  22174. @item
  22175. System calls
  22176. @item
  22177. Invoked commands
  22178. @item
  22179. Failed login attempts
  22180. @item
  22181. Firewall filtering
  22182. @item
  22183. Network access
  22184. @end enumerate
  22185. @command{auditctl} from the @code{audit} package can be used in order
  22186. to add or remove events to be tracked (until the next reboot).
  22187. In order to permanently track events, put the command line arguments
  22188. of auditctl into a file called @code{audit.rules} in the configuration
  22189. directory (see below).
  22190. @command{aureport} from the @code{audit} package can be used in order
  22191. to view a report of all recorded events.
  22192. The audit daemon by default logs into the file
  22193. @file{/var/log/audit.log}.
  22194. @end defvr
  22195. @deftp {Data Type} auditd-configuration
  22196. This is the data type representing the configuration of auditd.
  22197. @table @asis
  22198. @item @code{audit} (default: @code{audit})
  22199. The audit package to use.
  22200. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  22201. The directory containing the configuration file for the audit package, which
  22202. must be named @code{auditd.conf}, and optionally some audit rules to
  22203. instantiate on startup.
  22204. @end table
  22205. @end deftp
  22206. @defvr {Scheme Variable} singularity-service-type
  22207. This is the type of the service that allows you to run
  22208. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  22209. create and run application bundles (aka. ``containers''). The value for this
  22210. service is the Singularity package to use.
  22211. The service does not install a daemon; instead, it installs helper programs as
  22212. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  22213. @command{singularity run} and similar commands.
  22214. @end defvr
  22215. @cindex rshiny
  22216. @subsubheading R-Shiny service
  22217. The @code{(gnu services science)} module provides the following service.
  22218. @defvr {Scheme Variable} rshiny-service-type
  22219. This is a type of service which is used to run a webapp created with
  22220. @code{r-shiny}. This service sets the @code{R_LIBS_USER} environment
  22221. variable and runs the provided script to call @code{runApp}.
  22222. @deftp {Data Type} rshiny-configuration
  22223. This is the data type representing the configuration of rshiny.
  22224. @table @asis
  22225. @item @code{package} (default: @code{r-shiny})
  22226. The package to use.
  22227. @item @code{binary} (defaunlt @code{"rshiny"})
  22228. The name of the binary or shell script located at @code{package/bin/} to
  22229. run when the service is run.
  22230. The common way to create this file is as follows:
  22231. @lisp
  22232. @dots{}
  22233. (let* ((out (assoc-ref %outputs "out"))
  22234. (targetdir (string-append out "/share/" ,name))
  22235. (app (string-append out "/bin/" ,name))
  22236. (Rbin (string-append (assoc-ref %build-inputs "r-min")
  22237. "/bin/Rscript")))
  22238. ;; @dots{}
  22239. (mkdir-p (string-append out "/bin"))
  22240. (call-with-output-file app
  22241. (lambda (port)
  22242. (format port
  22243. "#!~a
  22244. library(shiny)
  22245. setwd(\"~a\")
  22246. runApp(launch.browser=0, port=4202)~%\n"
  22247. Rbin targetdir))))
  22248. @end lisp
  22249. @end table
  22250. @end deftp
  22251. @end defvr
  22252. @cindex Nix
  22253. @subsubheading Nix service
  22254. The @code{(gnu services nix)} module provides the following service.
  22255. @defvr {Scheme Variable} nix-service-type
  22256. This is the type of the service that runs build daemon of the
  22257. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  22258. how to use it:
  22259. @lisp
  22260. (use-modules (gnu))
  22261. (use-service-modules nix)
  22262. (use-package-modules package-management)
  22263. (operating-system
  22264. ;; @dots{}
  22265. (packages (append (list nix)
  22266. %base-packages))
  22267. (services (append (list (service nix-service-type))
  22268. %base-services)))
  22269. @end lisp
  22270. After @command{guix system reconfigure} configure Nix for your user:
  22271. @itemize
  22272. @item Add a Nix channel and update it. See
  22273. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  22274. @item Create a symlink to your profile and activate Nix profile:
  22275. @end itemize
  22276. @example
  22277. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  22278. $ source /run/current-system/profile/etc/profile.d/nix.sh
  22279. @end example
  22280. @end defvr
  22281. @deftp {Data Type} nix-configuration
  22282. This data type represents the configuration of the Nix daemon.
  22283. @table @asis
  22284. @item @code{nix} (default: @code{nix})
  22285. The Nix package to use.
  22286. @item @code{sandbox} (default: @code{#t})
  22287. Specifies whether builds are sandboxed by default.
  22288. @item @code{build-sandbox-items} (default: @code{'()})
  22289. This is a list of strings or objects appended to the
  22290. @code{build-sandbox-items} field of the configuration file.
  22291. @item @code{extra-config} (default: @code{'()})
  22292. This is a list of strings or objects appended to the configuration file.
  22293. It is used to pass extra text to be added verbatim to the configuration
  22294. file.
  22295. @item @code{extra-options} (default: @code{'()})
  22296. Extra command line options for @code{nix-service-type}.
  22297. @end table
  22298. @end deftp
  22299. @node Setuid Programs
  22300. @section Setuid Programs
  22301. @cindex setuid programs
  22302. Some programs need to run with ``root'' privileges, even when they are
  22303. launched by unprivileged users. A notorious example is the
  22304. @command{passwd} program, which users can run to change their
  22305. password, and which needs to access the @file{/etc/passwd} and
  22306. @file{/etc/shadow} files---something normally restricted to root, for
  22307. obvious security reasons. To address that, these executables are
  22308. @dfn{setuid-root}, meaning that they always run with root privileges
  22309. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  22310. for more info about the setuid mechanism).
  22311. The store itself @emph{cannot} contain setuid programs: that would be a
  22312. security issue since any user on the system can write derivations that
  22313. populate the store (@pxref{The Store}). Thus, a different mechanism is
  22314. used: instead of changing the setuid bit directly on files that are in
  22315. the store, we let the system administrator @emph{declare} which programs
  22316. should be setuid root.
  22317. The @code{setuid-programs} field of an @code{operating-system}
  22318. declaration contains a list of G-expressions denoting the names of
  22319. programs to be setuid-root (@pxref{Using the Configuration System}).
  22320. For instance, the @command{passwd} program, which is part of the Shadow
  22321. package, can be designated by this G-expression (@pxref{G-Expressions}):
  22322. @example
  22323. #~(string-append #$shadow "/bin/passwd")
  22324. @end example
  22325. A default set of setuid programs is defined by the
  22326. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  22327. @defvr {Scheme Variable} %setuid-programs
  22328. A list of G-expressions denoting common programs that are setuid-root.
  22329. The list includes commands such as @command{passwd}, @command{ping},
  22330. @command{su}, and @command{sudo}.
  22331. @end defvr
  22332. Under the hood, the actual setuid programs are created in the
  22333. @file{/run/setuid-programs} directory at system activation time. The
  22334. files in this directory refer to the ``real'' binaries, which are in the
  22335. store.
  22336. @node X.509 Certificates
  22337. @section X.509 Certificates
  22338. @cindex HTTPS, certificates
  22339. @cindex X.509 certificates
  22340. @cindex TLS
  22341. Web servers available over HTTPS (that is, HTTP over the transport-layer
  22342. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  22343. that the client can then use to @emph{authenticate} the server. To do
  22344. that, clients verify that the server's certificate is signed by a
  22345. so-called @dfn{certificate authority} (CA). But to verify the CA's
  22346. signature, clients must have first acquired the CA's certificate.
  22347. Web browsers such as GNU@tie{}IceCat include their own set of CA
  22348. certificates, such that they are able to verify CA signatures
  22349. out-of-the-box.
  22350. However, most other programs that can talk HTTPS---@command{wget},
  22351. @command{git}, @command{w3m}, etc.---need to be told where CA
  22352. certificates can be found.
  22353. @cindex @code{nss-certs}
  22354. In Guix, this is done by adding a package that provides certificates
  22355. to the @code{packages} field of the @code{operating-system} declaration
  22356. (@pxref{operating-system Reference}). Guix includes one such package,
  22357. @code{nss-certs}, which is a set of CA certificates provided as part of
  22358. Mozilla's Network Security Services.
  22359. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  22360. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  22361. most applications and libraries look for certificates by default, points
  22362. to the certificates installed globally.
  22363. Unprivileged users, including users of Guix on a foreign distro,
  22364. can also install their own certificate package in
  22365. their profile. A number of environment variables need to be defined so
  22366. that applications and libraries know where to find them. Namely, the
  22367. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  22368. variables. Some applications add their own environment variables; for
  22369. instance, the Git version control system honors the certificate bundle
  22370. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  22371. would typically run something like:
  22372. @example
  22373. guix install nss-certs
  22374. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  22375. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  22376. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  22377. @end example
  22378. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  22379. variable to point to a certificate bundle, so you would have to run
  22380. something like this:
  22381. @example
  22382. guix install nss-certs
  22383. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  22384. @end example
  22385. For other applications you may want to look up the required environment
  22386. variable in the relevant documentation.
  22387. @node Name Service Switch
  22388. @section Name Service Switch
  22389. @cindex name service switch
  22390. @cindex NSS
  22391. The @code{(gnu system nss)} module provides bindings to the
  22392. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  22393. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  22394. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  22395. extended with new ``name'' lookup methods for system databases, which
  22396. includes host names, service names, user accounts, and more (@pxref{Name
  22397. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  22398. C Library Reference Manual}).
  22399. The NSS configuration specifies, for each system database, which lookup
  22400. method is to be used, and how the various methods are chained
  22401. together---for instance, under which circumstances NSS should try the
  22402. next method in the list. The NSS configuration is given in the
  22403. @code{name-service-switch} field of @code{operating-system} declarations
  22404. (@pxref{operating-system Reference, @code{name-service-switch}}).
  22405. @cindex nss-mdns
  22406. @cindex .local, host name lookup
  22407. As an example, the declaration below configures the NSS to use the
  22408. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  22409. back-end}, which supports host name lookups over multicast DNS (mDNS)
  22410. for host names ending in @code{.local}:
  22411. @lisp
  22412. (name-service-switch
  22413. (hosts (list %files ;first, check /etc/hosts
  22414. ;; If the above did not succeed, try
  22415. ;; with 'mdns_minimal'.
  22416. (name-service
  22417. (name "mdns_minimal")
  22418. ;; 'mdns_minimal' is authoritative for
  22419. ;; '.local'. When it returns "not found",
  22420. ;; no need to try the next methods.
  22421. (reaction (lookup-specification
  22422. (not-found => return))))
  22423. ;; Then fall back to DNS.
  22424. (name-service
  22425. (name "dns"))
  22426. ;; Finally, try with the "full" 'mdns'.
  22427. (name-service
  22428. (name "mdns")))))
  22429. @end lisp
  22430. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  22431. contains this configuration, so you will not have to type it if all you
  22432. want is to have @code{.local} host lookup working.
  22433. Note that, in this case, in addition to setting the
  22434. @code{name-service-switch} of the @code{operating-system} declaration,
  22435. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  22436. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  22437. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  22438. to the name service cache daemon (@pxref{Base Services,
  22439. @code{nscd-service}}).
  22440. For convenience, the following variables provide typical NSS
  22441. configurations.
  22442. @defvr {Scheme Variable} %default-nss
  22443. This is the default name service switch configuration, a
  22444. @code{name-service-switch} object.
  22445. @end defvr
  22446. @defvr {Scheme Variable} %mdns-host-lookup-nss
  22447. This is the name service switch configuration with support for host name
  22448. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  22449. @end defvr
  22450. The reference for name service switch configuration is given below. It
  22451. is a direct mapping of the configuration file format of the C library , so
  22452. please refer to the C library manual for more information (@pxref{NSS
  22453. Configuration File,,, libc, The GNU C Library Reference Manual}).
  22454. Compared to the configuration file format of libc NSS, it has the advantage
  22455. not only of adding this warm parenthetic feel that we like, but also
  22456. static checks: you will know about syntax errors and typos as soon as you
  22457. run @command{guix system}.
  22458. @deftp {Data Type} name-service-switch
  22459. This is the data type representation the configuration of libc's name
  22460. service switch (NSS). Each field below represents one of the supported
  22461. system databases.
  22462. @table @code
  22463. @item aliases
  22464. @itemx ethers
  22465. @itemx group
  22466. @itemx gshadow
  22467. @itemx hosts
  22468. @itemx initgroups
  22469. @itemx netgroup
  22470. @itemx networks
  22471. @itemx password
  22472. @itemx public-key
  22473. @itemx rpc
  22474. @itemx services
  22475. @itemx shadow
  22476. The system databases handled by the NSS. Each of these fields must be a
  22477. list of @code{<name-service>} objects (see below).
  22478. @end table
  22479. @end deftp
  22480. @deftp {Data Type} name-service
  22481. This is the data type representing an actual name service and the
  22482. associated lookup action.
  22483. @table @code
  22484. @item name
  22485. A string denoting the name service (@pxref{Services in the NSS
  22486. configuration,,, libc, The GNU C Library Reference Manual}).
  22487. Note that name services listed here must be visible to nscd. This is
  22488. achieved by passing the @code{#:name-services} argument to
  22489. @code{nscd-service} the list of packages providing the needed name
  22490. services (@pxref{Base Services, @code{nscd-service}}).
  22491. @item reaction
  22492. An action specified using the @code{lookup-specification} macro
  22493. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  22494. Reference Manual}). For example:
  22495. @lisp
  22496. (lookup-specification (unavailable => continue)
  22497. (success => return))
  22498. @end lisp
  22499. @end table
  22500. @end deftp
  22501. @node Initial RAM Disk
  22502. @section Initial RAM Disk
  22503. @cindex initrd
  22504. @cindex initial RAM disk
  22505. For bootstrapping purposes, the Linux-Libre kernel is passed an
  22506. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  22507. root file system as well as an initialization script. The latter is
  22508. responsible for mounting the real root file system, and for loading any
  22509. kernel modules that may be needed to achieve that.
  22510. The @code{initrd-modules} field of an @code{operating-system}
  22511. declaration allows you to specify Linux-libre kernel modules that must
  22512. be available in the initrd. In particular, this is where you would list
  22513. modules needed to actually drive the hard disk where your root partition
  22514. is---although the default value of @code{initrd-modules} should cover
  22515. most use cases. For example, assuming you need the @code{megaraid_sas}
  22516. module in addition to the default modules to be able to access your root
  22517. file system, you would write:
  22518. @lisp
  22519. (operating-system
  22520. ;; @dots{}
  22521. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  22522. @end lisp
  22523. @defvr {Scheme Variable} %base-initrd-modules
  22524. This is the list of kernel modules included in the initrd by default.
  22525. @end defvr
  22526. Furthermore, if you need lower-level customization, the @code{initrd}
  22527. field of an @code{operating-system} declaration allows
  22528. you to specify which initrd you would like to use. The @code{(gnu
  22529. system linux-initrd)} module provides three ways to build an initrd: the
  22530. high-level @code{base-initrd} procedure and the low-level
  22531. @code{raw-initrd} and @code{expression->initrd} procedures.
  22532. The @code{base-initrd} procedure is intended to cover most common uses.
  22533. For example, if you want to add a bunch of kernel modules to be loaded
  22534. at boot time, you can define the @code{initrd} field of the operating
  22535. system declaration like this:
  22536. @lisp
  22537. (initrd (lambda (file-systems . rest)
  22538. ;; Create a standard initrd but set up networking
  22539. ;; with the parameters QEMU expects by default.
  22540. (apply base-initrd file-systems
  22541. #:qemu-networking? #t
  22542. rest)))
  22543. @end lisp
  22544. The @code{base-initrd} procedure also handles common use cases that
  22545. involves using the system as a QEMU guest, or as a ``live'' system with
  22546. volatile root file system.
  22547. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  22548. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  22549. such as trying to guess which kernel modules and packages should be included
  22550. to the initrd. An example use of @code{raw-initrd} is when a user has
  22551. a custom Linux kernel configuration and default kernel modules included by
  22552. @code{base-initrd} are not available.
  22553. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  22554. honors several options passed on the Linux kernel command line
  22555. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  22556. @code{-append} option of QEMU), notably:
  22557. @table @code
  22558. @item --load=@var{boot}
  22559. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  22560. program, once it has mounted the root file system.
  22561. Guix uses this option to yield control to a boot program that runs the
  22562. service activation programs and then spawns the GNU@tie{}Shepherd, the
  22563. initialization system.
  22564. @item --root=@var{root}
  22565. Mount @var{root} as the root file system. @var{root} can be a device
  22566. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  22567. When unspecified, the device name from the root file system of the
  22568. operating system declaration is used.
  22569. @item --system=@var{system}
  22570. Have @file{/run/booted-system} and @file{/run/current-system} point to
  22571. @var{system}.
  22572. @item modprobe.blacklist=@var{modules}@dots{}
  22573. @cindex module, black-listing
  22574. @cindex black list, of kernel modules
  22575. Instruct the initial RAM disk as well as the @command{modprobe} command
  22576. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  22577. must be a comma-separated list of module names---e.g.,
  22578. @code{usbkbd,9pnet}.
  22579. @item --repl
  22580. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  22581. tries to load kernel modules and to mount the root file system. Our
  22582. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  22583. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  22584. Manual}, for more information on Guile's REPL.
  22585. @end table
  22586. Now that you know all the features that initial RAM disks produced by
  22587. @code{base-initrd} and @code{raw-initrd} provide,
  22588. here is how to use it and customize it further.
  22589. @cindex initrd
  22590. @cindex initial RAM disk
  22591. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  22592. [#:linux-modules '()] [#:mapped-devices '()] @
  22593. [#:keyboard-layout #f] @
  22594. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  22595. Return a derivation that builds a raw initrd. @var{file-systems} is
  22596. a list of file systems to be mounted by the initrd, possibly in addition to
  22597. the root file system specified on the kernel command line via @option{--root}.
  22598. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  22599. @var{mapped-devices} is a list of device mappings to realize before
  22600. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  22601. @var{helper-packages} is a list of packages to be copied in the initrd. It may
  22602. include @code{e2fsck/static} or other packages needed by the initrd to check
  22603. the root file system.
  22604. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  22605. the desired console keyboard layout. This is done before @var{mapped-devices}
  22606. are set up and before @var{file-systems} are mounted such that, should the
  22607. user need to enter a passphrase or use the REPL, this happens using the
  22608. intended keyboard layout.
  22609. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  22610. parameters. When @var{virtio?} is true, load additional modules so that the
  22611. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  22612. When @var{volatile-root?} is true, the root file system is writable but any changes
  22613. to it are lost.
  22614. @end deffn
  22615. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  22616. [#:mapped-devices '()] [#:keyboard-layout #f] @
  22617. [#:qemu-networking? #f] [#:volatile-root? #f] @
  22618. [#:linux-modules '()]
  22619. Return as a file-like object a generic initrd, with kernel
  22620. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  22621. mounted by the initrd, possibly in addition to the root file system specified
  22622. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  22623. mappings to realize before @var{file-systems} are mounted.
  22624. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  22625. the desired console keyboard layout. This is done before @var{mapped-devices}
  22626. are set up and before @var{file-systems} are mounted such that, should the
  22627. user need to enter a passphrase or use the REPL, this happens using the
  22628. intended keyboard layout.
  22629. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  22630. The initrd is automatically populated with all the kernel modules necessary
  22631. for @var{file-systems} and for the given options. Additional kernel
  22632. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  22633. loaded at boot time in the order in which they appear.
  22634. @end deffn
  22635. Needless to say, the initrds we produce and use embed a
  22636. statically-linked Guile, and the initialization program is a Guile
  22637. program. That gives a lot of flexibility. The
  22638. @code{expression->initrd} procedure builds such an initrd, given the
  22639. program to run in that initrd.
  22640. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  22641. [#:guile %guile-3.0-static-stripped] [#:name "guile-initrd"]
  22642. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  22643. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  22644. upon booting. All the derivations referenced by @var{exp} are
  22645. automatically copied to the initrd.
  22646. @end deffn
  22647. @node Bootloader Configuration
  22648. @section Bootloader Configuration
  22649. @cindex bootloader
  22650. @cindex boot loader
  22651. The operating system supports multiple bootloaders. The bootloader is
  22652. configured using @code{bootloader-configuration} declaration. All the
  22653. fields of this structure are bootloader agnostic except for one field,
  22654. @code{bootloader} that indicates the bootloader to be configured and
  22655. installed.
  22656. Some of the bootloaders do not honor every field of
  22657. @code{bootloader-configuration}. For instance, the extlinux
  22658. bootloader does not support themes and thus ignores the @code{theme}
  22659. field.
  22660. @deftp {Data Type} bootloader-configuration
  22661. The type of a bootloader configuration declaration.
  22662. @table @asis
  22663. @item @code{bootloader}
  22664. @cindex EFI, bootloader
  22665. @cindex UEFI, bootloader
  22666. @cindex BIOS, bootloader
  22667. The bootloader to use, as a @code{bootloader} object. For now
  22668. @code{grub-bootloader}, @code{grub-efi-bootloader},
  22669. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  22670. @code{u-boot-bootloader} are supported.
  22671. @cindex ARM, bootloaders
  22672. @cindex AArch64, bootloaders
  22673. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  22674. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  22675. of bootloaders for a wide range of ARM and AArch64 systems, using the
  22676. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  22677. @vindex grub-efi-bootloader
  22678. @code{grub-efi-bootloader} allows to boot on modern systems using the
  22679. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  22680. use if the installation image contains a @file{/sys/firmware/efi} directory
  22681. when you boot it on your system.
  22682. @vindex grub-bootloader
  22683. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  22684. in ``legacy'' BIOS mode.
  22685. @vindex grub-efi-netboot-bootloader
  22686. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  22687. through TFTP. In combination with an NFS root file system this allows you to
  22688. build a diskless Guix system.
  22689. The installation of the @code{grub-efi-netboot-bootloader} generates the content
  22690. of the TFTP root directory at @code{target}
  22691. (@pxref{Bootloader Configuration, @code{target}}), to be served by a TFTP server.
  22692. You may want to mount your TFTP server directory onto @code{target} to move the
  22693. required files to the TFTP server automatically.
  22694. If you plan to use an NFS root file system as well (actually if you mount the
  22695. store from an NFS share), then the TFTP server needs to serve the file
  22696. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  22697. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  22698. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  22699. files from the store will be accessed by GRUB through TFTP with their normal
  22700. store path, for example as
  22701. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  22702. Two symlinks are created to make this possible. The first symlink is
  22703. @code{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  22704. @file{../../../boot/grub/grub.cfg},
  22705. where @code{target} may be @file{/boot}. In this case the link is not leaving
  22706. the served TFTP root directory, but otherwise it does. The second link is
  22707. @code{target}@file{/gnu/store} and points to @file{../gnu/store}. This link
  22708. is leaving the served TFTP root directory.
  22709. The assumption behind all this is that you have an NFS server exporting the root
  22710. file system for your Guix system, and additionally a TFTP server exporting your
  22711. @code{target} directory—usually @file{/boot}—from that same root file system for
  22712. your Guix system. In this constellation the symlinks will work.
  22713. For other constellations you will have to program your own bootloader installer,
  22714. which then takes care to make necessary files from the store accessible through
  22715. TFTP, for example by copying them into the TFTP root directory at @code{target}.
  22716. It is important to note that symlinks pointing outside the TFTP root directory
  22717. may need to be allowed in the configuration of your TFTP server. Further the
  22718. store link exposes the whole store through TFTP. Both points need to be
  22719. considered carefully for security aspects.
  22720. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  22721. NFS servers, you also need a properly configured DHCP server to make the booting
  22722. over netboot possible. For all this we can currently only recommend you to look
  22723. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  22724. @item @code{target}
  22725. This is a string denoting the target onto which to install the
  22726. bootloader.
  22727. The interpretation depends on the bootloader in question. For
  22728. @code{grub-bootloader}, for example, it should be a device name understood by
  22729. the bootloader @command{installer} command, such as @code{/dev/sda} or
  22730. @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
  22731. @code{grub-efi-bootloader}, it should be the mount point of the EFI file
  22732. system, usually @file{/boot/efi}. For @code{grub-efi-netboot-bootloader},
  22733. @code{target} should be the mount point corresponding to the TFTP root
  22734. directory of your TFTP server.
  22735. @item @code{menu-entries} (default: @code{()})
  22736. A possibly empty list of @code{menu-entry} objects (see below), denoting
  22737. entries to appear in the bootloader menu, in addition to the current
  22738. system entry and the entry pointing to previous system generations.
  22739. @item @code{default-entry} (default: @code{0})
  22740. The index of the default boot menu entry. Index 0 is for the entry of the
  22741. current system.
  22742. @item @code{timeout} (default: @code{5})
  22743. The number of seconds to wait for keyboard input before booting. Set to
  22744. 0 to boot immediately, and to -1 to wait indefinitely.
  22745. @cindex keyboard layout, for the bootloader
  22746. @item @code{keyboard-layout} (default: @code{#f})
  22747. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  22748. layout, usually US@tie{}English (``qwerty'').
  22749. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  22750. Layout}).
  22751. @quotation Note
  22752. This option is currently ignored by bootloaders other than @code{grub} and
  22753. @code{grub-efi}.
  22754. @end quotation
  22755. @item @code{theme} (default: @var{#f})
  22756. The bootloader theme object describing the theme to use. If no theme
  22757. is provided, some bootloaders might use a default theme, that's true
  22758. for GRUB.
  22759. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  22760. The output terminals used for the bootloader boot menu, as a list of
  22761. symbols. GRUB accepts the values: @code{console}, @code{serial},
  22762. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  22763. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  22764. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  22765. configuration,,, grub,GNU GRUB manual}).
  22766. @item @code{terminal-inputs} (default: @code{'()})
  22767. The input terminals used for the bootloader boot menu, as a list of
  22768. symbols. For GRUB, the default is the native platform terminal as
  22769. determined at run-time. GRUB accepts the values: @code{console},
  22770. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  22771. @code{usb_keyboard}. This field corresponds to the GRUB variable
  22772. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  22773. manual}).
  22774. @item @code{serial-unit} (default: @code{#f})
  22775. The serial unit used by the bootloader, as an integer from 0 to 3.
  22776. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  22777. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  22778. @item @code{serial-speed} (default: @code{#f})
  22779. The speed of the serial interface, as an integer. For GRUB, the
  22780. default value is chosen at run-time; currently GRUB chooses
  22781. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  22782. @end table
  22783. @end deftp
  22784. @cindex dual boot
  22785. @cindex boot menu
  22786. Should you want to list additional boot menu entries @i{via} the
  22787. @code{menu-entries} field above, you will need to create them with the
  22788. @code{menu-entry} form. For example, imagine you want to be able to
  22789. boot another distro (hard to imagine!), you can define a menu entry
  22790. along these lines:
  22791. @lisp
  22792. (menu-entry
  22793. (label "The Other Distro")
  22794. (linux "/boot/old/vmlinux-2.6.32")
  22795. (linux-arguments '("root=/dev/sda2"))
  22796. (initrd "/boot/old/initrd"))
  22797. @end lisp
  22798. Details below.
  22799. @deftp {Data Type} menu-entry
  22800. The type of an entry in the bootloader menu.
  22801. @table @asis
  22802. @item @code{label}
  22803. The label to show in the menu---e.g., @code{"GNU"}.
  22804. @item @code{linux} (default: @code{#f})
  22805. The Linux kernel image to boot, for example:
  22806. @lisp
  22807. (file-append linux-libre "/bzImage")
  22808. @end lisp
  22809. For GRUB, it is also possible to specify a device explicitly in the
  22810. file path using GRUB's device naming convention (@pxref{Naming
  22811. convention,,, grub, GNU GRUB manual}), for example:
  22812. @example
  22813. "(hd0,msdos1)/boot/vmlinuz"
  22814. @end example
  22815. If the device is specified explicitly as above, then the @code{device}
  22816. field is ignored entirely.
  22817. @item @code{linux-arguments} (default: @code{()})
  22818. The list of extra Linux kernel command-line arguments---e.g.,
  22819. @code{("console=ttyS0")}.
  22820. @item @code{initrd} (default: @code{#f})
  22821. A G-Expression or string denoting the file name of the initial RAM disk
  22822. to use (@pxref{G-Expressions}).
  22823. @item @code{device} (default: @code{#f})
  22824. The device where the kernel and initrd are to be found---i.e., for GRUB,
  22825. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  22826. This may be a file system label (a string), a file system UUID (a
  22827. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  22828. the bootloader will search the device containing the file specified by
  22829. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  22830. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  22831. @item @code{multiboot-kernel} (default: @code{#f})
  22832. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  22833. manual}). When this field is set, a Multiboot menu-entry is generated.
  22834. For example:
  22835. @lisp
  22836. (file-append mach "/boot/gnumach")
  22837. @end lisp
  22838. @item @code{multiboot-arguments} (default: @code{()})
  22839. The list of extra command-line arguments for the multiboot-kernel.
  22840. @item @code{multiboot-modules} (default: @code{()})
  22841. The list of commands for loading Multiboot modules. For example:
  22842. @lisp
  22843. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  22844. @dots{})
  22845. (list (file-append libc "/lib/ld.so.1") "exec"
  22846. @dots{}))
  22847. @end lisp
  22848. @end table
  22849. @end deftp
  22850. @cindex HDPI
  22851. @cindex HiDPI
  22852. @cindex resolution
  22853. @c FIXME: Write documentation once it's stable.
  22854. For now only GRUB has theme support. GRUB themes are created using
  22855. the @code{grub-theme} form, which is not fully documented yet.
  22856. @deftp {Data Type} grub-theme
  22857. Data type representing the configuration of the GRUB theme.
  22858. @table @asis
  22859. @item @code{gfxmode} (default: @code{'("auto")})
  22860. The GRUB @code{gfxmode} to set (a list of screen resolution strings, see
  22861. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  22862. @end table
  22863. @end deftp
  22864. @deffn {Scheme Procedure} grub-theme
  22865. Return the default GRUB theme used by the operating system if no
  22866. @code{theme} field is specified in @code{bootloader-configuration}
  22867. record.
  22868. It comes with a fancy background image displaying the GNU and Guix
  22869. logos.
  22870. @end deffn
  22871. For example, to override the default resolution, you may use something
  22872. like
  22873. @lisp
  22874. (bootloader
  22875. (bootloader-configuration
  22876. ;; @dots{}
  22877. (theme (grub-theme
  22878. (inherit (grub-theme))
  22879. (gfxmode '("1024x786x32" "auto"))))))
  22880. @end lisp
  22881. @node Invoking guix system
  22882. @section Invoking @code{guix system}
  22883. Once you have written an operating system declaration as seen in the
  22884. previous section, it can be @dfn{instantiated} using the @command{guix
  22885. system} command. The synopsis is:
  22886. @example
  22887. guix system @var{options}@dots{} @var{action} @var{file}
  22888. @end example
  22889. @var{file} must be the name of a file containing an
  22890. @code{operating-system} declaration. @var{action} specifies how the
  22891. operating system is instantiated. Currently the following values are
  22892. supported:
  22893. @table @code
  22894. @item search
  22895. Display available service type definitions that match the given regular
  22896. expressions, sorted by relevance:
  22897. @cindex HDPI
  22898. @cindex HiDPI
  22899. @cindex resolution
  22900. @example
  22901. $ guix system search console
  22902. name: console-fonts
  22903. location: gnu/services/base.scm:806:2
  22904. extends: shepherd-root
  22905. description: Install the given fonts on the specified ttys (fonts are per
  22906. + virtual console on GNU/Linux). The value of this service is a list of
  22907. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  22908. + package or any valid argument to `setfont', as in this example:
  22909. +
  22910. + '(("tty1" . "LatGrkCyr-8x16")
  22911. + ("tty2" . (file-append
  22912. + font-tamzen
  22913. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  22914. + ("tty3" . (file-append
  22915. + font-terminus
  22916. + "/share/consolefonts/ter-132n"))) ; for HDPI
  22917. relevance: 9
  22918. name: mingetty
  22919. location: gnu/services/base.scm:1190:2
  22920. extends: shepherd-root
  22921. description: Provide console login using the `mingetty' program.
  22922. relevance: 2
  22923. name: login
  22924. location: gnu/services/base.scm:860:2
  22925. extends: pam
  22926. description: Provide a console log-in service as specified by its
  22927. + configuration value, a `login-configuration' object.
  22928. relevance: 2
  22929. @dots{}
  22930. @end example
  22931. As for @command{guix package --search}, the result is written in
  22932. @code{recutils} format, which makes it easy to filter the output
  22933. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  22934. @item reconfigure
  22935. Build the operating system described in @var{file}, activate it, and
  22936. switch to it@footnote{This action (and the related actions
  22937. @code{switch-generation} and @code{roll-back}) are usable only on
  22938. systems already running Guix System.}.
  22939. @quotation Note
  22940. @c The paragraph below refers to the problem discussed at
  22941. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  22942. It is highly recommended to run @command{guix pull} once before you run
  22943. @command{guix system reconfigure} for the first time (@pxref{Invoking
  22944. guix pull}). Failing to do that you would see an older version of Guix
  22945. once @command{reconfigure} has completed.
  22946. @end quotation
  22947. This effects all the configuration specified in @var{file}: user
  22948. accounts, system services, global package list, setuid programs, etc.
  22949. The command starts system services specified in @var{file} that are not
  22950. currently running; if a service is currently running this command will
  22951. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  22952. @code{herd stop X} or @code{herd restart X}).
  22953. This command creates a new generation whose number is one greater than
  22954. the current generation (as reported by @command{guix system
  22955. list-generations}). If that generation already exists, it will be
  22956. overwritten. This behavior mirrors that of @command{guix package}
  22957. (@pxref{Invoking guix package}).
  22958. It also adds a bootloader menu entry for the new OS configuration,
  22959. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  22960. entries for older configurations to a submenu, allowing you to choose
  22961. an older system generation at boot time should you need it.
  22962. @cindex provenance tracking, of the operating system
  22963. Upon completion, the new system is deployed under
  22964. @file{/run/current-system}. This directory contains @dfn{provenance
  22965. meta-data}: the list of channels in use (@pxref{Channels}) and
  22966. @var{file} itself, when available. You can view it by running:
  22967. @example
  22968. guix system describe
  22969. @end example
  22970. This information is useful should you later want to inspect how this
  22971. particular generation was built. In fact, assuming @var{file} is
  22972. self-contained, you can later rebuild generation @var{n} of your
  22973. operating system with:
  22974. @example
  22975. guix time-machine \
  22976. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  22977. system reconfigure \
  22978. /var/guix/profiles/system-@var{n}-link/configuration.scm
  22979. @end example
  22980. You can think of it as some sort of built-in version control! Your
  22981. system is not just a binary artifact: @emph{it carries its own source}.
  22982. @xref{Service Reference, @code{provenance-service-type}}, for more
  22983. information on provenance tracking.
  22984. By default, @command{reconfigure} @emph{prevents you from downgrading
  22985. your system}, which could (re)introduce security vulnerabilities and
  22986. also cause problems with ``stateful'' services such as database
  22987. management systems. You can override that behavior by passing
  22988. @option{--allow-downgrades}.
  22989. @item switch-generation
  22990. @cindex generations
  22991. Switch to an existing system generation. This action atomically
  22992. switches the system profile to the specified system generation. It
  22993. also rearranges the system's existing bootloader menu entries. It
  22994. makes the menu entry for the specified system generation the default,
  22995. and it moves the entries for the other generations to a submenu, if
  22996. supported by the bootloader being used. The next time the system
  22997. boots, it will use the specified system generation.
  22998. The bootloader itself is not being reinstalled when using this
  22999. command. Thus, the installed bootloader is used with an updated
  23000. configuration file.
  23001. The target generation can be specified explicitly by its generation
  23002. number. For example, the following invocation would switch to system
  23003. generation 7:
  23004. @example
  23005. guix system switch-generation 7
  23006. @end example
  23007. The target generation can also be specified relative to the current
  23008. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  23009. ``3 generations ahead of the current generation,'' and @code{-1} means
  23010. ``1 generation prior to the current generation.'' When specifying a
  23011. negative value such as @code{-1}, you must precede it with @code{--} to
  23012. prevent it from being parsed as an option. For example:
  23013. @example
  23014. guix system switch-generation -- -1
  23015. @end example
  23016. Currently, the effect of invoking this action is @emph{only} to switch
  23017. the system profile to an existing generation and rearrange the
  23018. bootloader menu entries. To actually start using the target system
  23019. generation, you must reboot after running this action. In the future,
  23020. it will be updated to do the same things as @command{reconfigure},
  23021. like activating and deactivating services.
  23022. This action will fail if the specified generation does not exist.
  23023. @item roll-back
  23024. @cindex rolling back
  23025. Switch to the preceding system generation. The next time the system
  23026. boots, it will use the preceding system generation. This is the inverse
  23027. of @command{reconfigure}, and it is exactly the same as invoking
  23028. @command{switch-generation} with an argument of @code{-1}.
  23029. Currently, as with @command{switch-generation}, you must reboot after
  23030. running this action to actually start using the preceding system
  23031. generation.
  23032. @item delete-generations
  23033. @cindex deleting system generations
  23034. @cindex saving space
  23035. Delete system generations, making them candidates for garbage collection
  23036. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  23037. collector'').
  23038. This works in the same way as @samp{guix package --delete-generations}
  23039. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  23040. arguments, all system generations but the current one are deleted:
  23041. @example
  23042. guix system delete-generations
  23043. @end example
  23044. You can also select the generations you want to delete. The example below
  23045. deletes all the system generations that are more than two month old:
  23046. @example
  23047. guix system delete-generations 2m
  23048. @end example
  23049. Running this command automatically reinstalls the bootloader with an updated
  23050. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  23051. longer lists the generations that have been deleted.
  23052. @item build
  23053. Build the derivation of the operating system, which includes all the
  23054. configuration files and programs needed to boot and run the system.
  23055. This action does not actually install anything.
  23056. @item init
  23057. Populate the given directory with all the files necessary to run the
  23058. operating system specified in @var{file}. This is useful for first-time
  23059. installations of Guix System. For instance:
  23060. @example
  23061. guix system init my-os-config.scm /mnt
  23062. @end example
  23063. copies to @file{/mnt} all the store items required by the configuration
  23064. specified in @file{my-os-config.scm}. This includes configuration
  23065. files, packages, and so on. It also creates other essential files
  23066. needed for the system to operate correctly---e.g., the @file{/etc},
  23067. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  23068. This command also installs bootloader on the target specified in
  23069. @file{my-os-config}, unless the @option{--no-bootloader} option was
  23070. passed.
  23071. @item vm
  23072. @cindex virtual machine
  23073. @cindex VM
  23074. @anchor{guix system vm}
  23075. Build a virtual machine that contains the operating system declared in
  23076. @var{file}, and return a script to run that virtual machine (VM).
  23077. @quotation Note
  23078. The @code{vm} action and others below
  23079. can use KVM support in the Linux-libre kernel. Specifically, if the
  23080. machine has hardware virtualization support, the corresponding
  23081. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  23082. must exist and be readable and writable by the user and by the
  23083. build users of the daemon (@pxref{Build Environment Setup}).
  23084. @end quotation
  23085. Arguments given to the script are passed to QEMU as in the example
  23086. below, which enables networking and requests 1@tie{}GiB of RAM for the
  23087. emulated machine:
  23088. @example
  23089. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -net user,model=virtio-net-pci
  23090. @end example
  23091. The VM shares its store with the host system.
  23092. Additional file systems can be shared between the host and the VM using
  23093. the @option{--share} and @option{--expose} command-line options: the former
  23094. specifies a directory to be shared with write access, while the latter
  23095. provides read-only access to the shared directory.
  23096. The example below creates a VM in which the user's home directory is
  23097. accessible read-only, and where the @file{/exchange} directory is a
  23098. read-write mapping of @file{$HOME/tmp} on the host:
  23099. @example
  23100. guix system vm my-config.scm \
  23101. --expose=$HOME --share=$HOME/tmp=/exchange
  23102. @end example
  23103. On GNU/Linux, the default is to boot directly to the kernel; this has
  23104. the advantage of requiring only a very tiny root disk image since the
  23105. store of the host can then be mounted.
  23106. The @option{--full-boot} option forces a complete boot sequence, starting
  23107. with the bootloader. This requires more disk space since a root image
  23108. containing at least the kernel, initrd, and bootloader data files must
  23109. be created. The @option{--image-size} option can be used to specify the
  23110. size of the image.
  23111. @cindex System images, creation in various formats
  23112. @cindex Creating system images in various formats
  23113. @item vm-image
  23114. @itemx disk-image
  23115. @itemx docker-image
  23116. Return a virtual machine, disk image, or Docker image of the operating
  23117. system declared in @var{file} that stands alone. By default,
  23118. @command{guix system} estimates the size of the image needed to store
  23119. the system, but you can use the @option{--image-size} option to specify
  23120. a value. Docker images are built to contain exactly what they need, so
  23121. the @option{--image-size} option is ignored in the case of
  23122. @code{docker-image}.
  23123. The @code{disk-image} command can produce various image types. The
  23124. image type can be selected using the @command{--image-type} option. It
  23125. defaults to @code{raw}. When its value is @code{iso9660}, the
  23126. @option{--label} option can be used to specify a volume ID with
  23127. @code{disk-image}.
  23128. When using the @code{raw} image type, a raw disk image is produced; it
  23129. can be copied as is to a USB stick, for instance. Assuming
  23130. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  23131. the image to it using the following command:
  23132. @example
  23133. # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc status=progress
  23134. @end example
  23135. The @code{--list-image-types} command lists all the available image
  23136. types.
  23137. When using @code{vm-image}, the returned image is in qcow2 format, which
  23138. the QEMU emulator can efficiently use. @xref{Running Guix in a VM},
  23139. for more information on how to run the image in a virtual machine.
  23140. When using @code{docker-image}, a Docker image is produced. Guix builds
  23141. the image from scratch, not from a pre-existing Docker base image. As a
  23142. result, it contains @emph{exactly} what you define in the operating
  23143. system configuration file. You can then load the image and launch a
  23144. Docker container using commands like the following:
  23145. @example
  23146. image_id="`docker load < guix-system-docker-image.tar.gz`"
  23147. container_id="`docker create $image_id`"
  23148. docker start $container_id
  23149. @end example
  23150. This command starts a new Docker container from the specified image. It
  23151. will boot the Guix system in the usual manner, which means it will
  23152. start any services you have defined in the operating system
  23153. configuration. You can get an interactive shell running in the container
  23154. using @command{docker exec}:
  23155. @example
  23156. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  23157. @end example
  23158. Depending on what you run in the Docker container, it
  23159. may be necessary to give the container additional permissions. For
  23160. example, if you intend to build software using Guix inside of the Docker
  23161. container, you may need to pass the @option{--privileged} option to
  23162. @code{docker create}.
  23163. Last, the @option{--network} option applies to @command{guix system
  23164. docker-image}: it produces an image where network is supposedly shared
  23165. with the host, and thus without services like nscd or NetworkManager.
  23166. @item container
  23167. Return a script to run the operating system declared in @var{file}
  23168. within a container. Containers are a set of lightweight isolation
  23169. mechanisms provided by the kernel Linux-libre. Containers are
  23170. substantially less resource-demanding than full virtual machines since
  23171. the kernel, shared objects, and other resources can be shared with the
  23172. host system; this also means they provide thinner isolation.
  23173. Currently, the script must be run as root in order to support more than
  23174. a single user and group. The container shares its store with the host
  23175. system.
  23176. As with the @code{vm} action (@pxref{guix system vm}), additional file
  23177. systems to be shared between the host and container can be specified
  23178. using the @option{--share} and @option{--expose} options:
  23179. @example
  23180. guix system container my-config.scm \
  23181. --expose=$HOME --share=$HOME/tmp=/exchange
  23182. @end example
  23183. @quotation Note
  23184. This option requires Linux-libre 3.19 or newer.
  23185. @end quotation
  23186. @end table
  23187. @var{options} can contain any of the common build options (@pxref{Common
  23188. Build Options}). In addition, @var{options} can contain one of the
  23189. following:
  23190. @table @option
  23191. @item --expression=@var{expr}
  23192. @itemx -e @var{expr}
  23193. Consider the operating-system @var{expr} evaluates to.
  23194. This is an alternative to specifying a file which evaluates to an
  23195. operating system.
  23196. This is used to generate the Guix system installer @pxref{Building the
  23197. Installation Image}).
  23198. @item --system=@var{system}
  23199. @itemx -s @var{system}
  23200. Attempt to build for @var{system} instead of the host system type.
  23201. This works as per @command{guix build} (@pxref{Invoking guix build}).
  23202. @item --derivation
  23203. @itemx -d
  23204. Return the derivation file name of the given operating system without
  23205. building anything.
  23206. @cindex provenance tracking, of the operating system
  23207. @item --save-provenance
  23208. As discussed above, @command{guix system init} and @command{guix system
  23209. reconfigure} always save provenance information @i{via} a dedicated
  23210. service (@pxref{Service Reference, @code{provenance-service-type}}).
  23211. However, other commands don't do that by default. If you wish to, say,
  23212. create a virtual machine image that contains provenance information, you
  23213. can run:
  23214. @example
  23215. guix system vm-image --save-provenance config.scm
  23216. @end example
  23217. That way, the resulting image will effectively ``embed its own source''
  23218. in the form of meta-data in @file{/run/current-system}. With that
  23219. information, one can rebuild the image to make sure it really contains
  23220. what it pretends to contain; or they could use that to derive a variant
  23221. of the image.
  23222. @item --image-type=@var{type}
  23223. @itemx -t @var{type}
  23224. For the @code{disk-image} action, create an image with given @var{type}.
  23225. When this option is omitted, @command{guix system} uses the @code{raw}
  23226. image type.
  23227. @cindex ISO-9660 format
  23228. @cindex CD image format
  23229. @cindex DVD image format
  23230. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  23231. for burning on CDs and DVDs.
  23232. @item --image-size=@var{size}
  23233. For the @code{vm-image} and @code{disk-image} actions, create an image
  23234. of the given @var{size}. @var{size} may be a number of bytes, or it may
  23235. include a unit as a suffix (@pxref{Block size, size specifications,,
  23236. coreutils, GNU Coreutils}).
  23237. When this option is omitted, @command{guix system} computes an estimate
  23238. of the image size as a function of the size of the system declared in
  23239. @var{file}.
  23240. @item --network
  23241. @itemx -N
  23242. For the @code{container} action, allow containers to access the host network,
  23243. that is, do not create a network namespace.
  23244. @item --root=@var{file}
  23245. @itemx -r @var{file}
  23246. Make @var{file} a symlink to the result, and register it as a garbage
  23247. collector root.
  23248. @item --skip-checks
  23249. Skip pre-installation safety checks.
  23250. By default, @command{guix system init} and @command{guix system
  23251. reconfigure} perform safety checks: they make sure the file systems that
  23252. appear in the @code{operating-system} declaration actually exist
  23253. (@pxref{File Systems}), and that any Linux kernel modules that may be
  23254. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  23255. RAM Disk}). Passing this option skips these tests altogether.
  23256. @item --allow-downgrades
  23257. Instruct @command{guix system reconfigure} to allow system downgrades.
  23258. By default, @command{reconfigure} prevents you from downgrading your
  23259. system. It achieves that by comparing the provenance info of your
  23260. system (shown by @command{guix system describe}) with that of your
  23261. @command{guix} command (shown by @command{guix describe}). If the
  23262. commits for @command{guix} are not descendants of those used for your
  23263. system, @command{guix system reconfigure} errors out. Passing
  23264. @option{--allow-downgrades} allows you to bypass these checks.
  23265. @quotation Note
  23266. Make sure you understand its security implications before using
  23267. @option{--allow-downgrades}.
  23268. @end quotation
  23269. @cindex on-error
  23270. @cindex on-error strategy
  23271. @cindex error strategy
  23272. @item --on-error=@var{strategy}
  23273. Apply @var{strategy} when an error occurs when reading @var{file}.
  23274. @var{strategy} may be one of the following:
  23275. @table @code
  23276. @item nothing-special
  23277. Report the error concisely and exit. This is the default strategy.
  23278. @item backtrace
  23279. Likewise, but also display a backtrace.
  23280. @item debug
  23281. Report the error and enter Guile's debugger. From there, you can run
  23282. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  23283. display local variable values, and more generally inspect the state of the
  23284. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  23285. a list of available debugging commands.
  23286. @end table
  23287. @end table
  23288. Once you have built, configured, re-configured, and re-re-configured
  23289. your Guix installation, you may find it useful to list the operating
  23290. system generations available on disk---and that you can choose from the
  23291. bootloader boot menu:
  23292. @table @code
  23293. @item describe
  23294. Describe the current system generation: its file name, the kernel and
  23295. bootloader used, etc., as well as provenance information when available.
  23296. @item list-generations
  23297. List a summary of each generation of the operating system available on
  23298. disk, in a human-readable way. This is similar to the
  23299. @option{--list-generations} option of @command{guix package}
  23300. (@pxref{Invoking guix package}).
  23301. Optionally, one can specify a pattern, with the same syntax that is used
  23302. in @command{guix package --list-generations}, to restrict the list of
  23303. generations displayed. For instance, the following command displays
  23304. generations that are up to 10 days old:
  23305. @example
  23306. $ guix system list-generations 10d
  23307. @end example
  23308. @end table
  23309. The @command{guix system} command has even more to offer! The following
  23310. sub-commands allow you to visualize how your system services relate to
  23311. each other:
  23312. @anchor{system-extension-graph}
  23313. @table @code
  23314. @item extension-graph
  23315. Emit in Dot/Graphviz format to standard output the @dfn{service
  23316. extension graph} of the operating system defined in @var{file}
  23317. (@pxref{Service Composition}, for more information on service
  23318. extensions).
  23319. The command:
  23320. @example
  23321. $ guix system extension-graph @var{file} | xdot -
  23322. @end example
  23323. shows the extension relations among services.
  23324. @anchor{system-shepherd-graph}
  23325. @item shepherd-graph
  23326. Emit in Dot/Graphviz format to standard output the @dfn{dependency
  23327. graph} of shepherd services of the operating system defined in
  23328. @var{file}. @xref{Shepherd Services}, for more information and for an
  23329. example graph.
  23330. @end table
  23331. @node Invoking guix deploy
  23332. @section Invoking @code{guix deploy}
  23333. We've already seen @code{operating-system} declarations used to manage a
  23334. machine's configuration locally. Suppose you need to configure multiple
  23335. machines, though---perhaps you're managing a service on the web that's
  23336. comprised of several servers. @command{guix deploy} enables you to use those
  23337. same @code{operating-system} declarations to manage multiple remote hosts at
  23338. once as a logical ``deployment''.
  23339. @quotation Note
  23340. The functionality described in this section is still under development
  23341. and is subject to change. Get in touch with us on
  23342. @email{guix-devel@@gnu.org}!
  23343. @end quotation
  23344. @example
  23345. guix deploy @var{file}
  23346. @end example
  23347. Such an invocation will deploy the machines that the code within @var{file}
  23348. evaluates to. As an example, @var{file} might contain a definition like this:
  23349. @lisp
  23350. ;; This is a Guix deployment of a "bare bones" setup, with
  23351. ;; no X11 display server, to a machine with an SSH daemon
  23352. ;; listening on localhost:2222. A configuration such as this
  23353. ;; may be appropriate for virtual machine with ports
  23354. ;; forwarded to the host's loopback interface.
  23355. (use-service-modules networking ssh)
  23356. (use-package-modules bootloaders)
  23357. (define %system
  23358. (operating-system
  23359. (host-name "gnu-deployed")
  23360. (timezone "Etc/UTC")
  23361. (bootloader (bootloader-configuration
  23362. (bootloader grub-bootloader)
  23363. (target "/dev/vda")
  23364. (terminal-outputs '(console))))
  23365. (file-systems (cons (file-system
  23366. (mount-point "/")
  23367. (device "/dev/vda1")
  23368. (type "ext4"))
  23369. %base-file-systems))
  23370. (services
  23371. (append (list (service dhcp-client-service-type)
  23372. (service openssh-service-type
  23373. (openssh-configuration
  23374. (permit-root-login #t)
  23375. (allow-empty-passwords? #t))))
  23376. %base-services))))
  23377. (list (machine
  23378. (operating-system %system)
  23379. (environment managed-host-environment-type)
  23380. (configuration (machine-ssh-configuration
  23381. (host-name "localhost")
  23382. (system "x86_64-linux")
  23383. (user "alice")
  23384. (identity "./id_rsa")
  23385. (port 2222)))))
  23386. @end lisp
  23387. The file should evaluate to a list of @var{machine} objects. This example,
  23388. upon being deployed, will create a new generation on the remote system
  23389. realizing the @code{operating-system} declaration @code{%system}.
  23390. @code{environment} and @code{configuration} specify how the machine should be
  23391. provisioned---that is, how the computing resources should be created and
  23392. managed. The above example does not create any resources, as a
  23393. @code{'managed-host} is a machine that is already running the Guix system and
  23394. available over the network. This is a particularly simple case; a more
  23395. complex deployment may involve, for example, starting virtual machines through
  23396. a Virtual Private Server (VPS) provider. In such a case, a different
  23397. @var{environment} type would be used.
  23398. Do note that you first need to generate a key pair on the coordinator machine
  23399. to allow the daemon to export signed archives of files from the store
  23400. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  23401. System:
  23402. @example
  23403. # guix archive --generate-key
  23404. @end example
  23405. @noindent
  23406. Each target machine must authorize the key of the master machine so that it
  23407. accepts store items it receives from the coordinator:
  23408. @example
  23409. # guix archive --authorize < coordinator-public-key.txt
  23410. @end example
  23411. @code{user}, in this example, specifies the name of the user account to log in
  23412. as to perform the deployment. Its default value is @code{root}, but root
  23413. login over SSH may be forbidden in some cases. To work around this,
  23414. @command{guix deploy} can log in as an unprivileged user and employ
  23415. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  23416. currently installed on the remote and can be invoked non-interactively as
  23417. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  23418. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  23419. be accomplished with the following operating system configuration snippet:
  23420. @lisp
  23421. (use-modules ...
  23422. (gnu system)) ;for %sudoers-specification
  23423. (define %user "username")
  23424. (operating-system
  23425. ...
  23426. (sudoers-file
  23427. (plain-file "sudoers"
  23428. (string-append (plain-file-content %sudoers-specification)
  23429. (format #f "~a ALL = NOPASSWD: ALL~%"
  23430. %user)))))
  23431. @end lisp
  23432. For more information regarding the format of the @file{sudoers} file,
  23433. consult @command{man sudoers}.
  23434. @deftp {Data Type} machine
  23435. This is the data type representing a single machine in a heterogeneous Guix
  23436. deployment.
  23437. @table @asis
  23438. @item @code{operating-system}
  23439. The object of the operating system configuration to deploy.
  23440. @item @code{environment}
  23441. An @code{environment-type} describing how the machine should be provisioned.
  23442. @item @code{configuration} (default: @code{#f})
  23443. An object describing the configuration for the machine's @code{environment}.
  23444. If the @code{environment} has a default configuration, @code{#f} may be used.
  23445. If @code{#f} is used for an environment with no default configuration,
  23446. however, an error will be thrown.
  23447. @end table
  23448. @end deftp
  23449. @deftp {Data Type} machine-ssh-configuration
  23450. This is the data type representing the SSH client parameters for a machine
  23451. with an @code{environment} of @code{managed-host-environment-type}.
  23452. @table @asis
  23453. @item @code{host-name}
  23454. @item @code{build-locally?} (default: @code{#t})
  23455. If false, system derivations will be built on the machine being deployed to.
  23456. @item @code{system}
  23457. The system type describing the architecture of the machine being deployed
  23458. to---e.g., @code{"x86_64-linux"}.
  23459. @item @code{authorize?} (default: @code{#t})
  23460. If true, the coordinator's signing key will be added to the remote's ACL
  23461. keyring.
  23462. @item @code{port} (default: @code{22})
  23463. @item @code{user} (default: @code{"root"})
  23464. @item @code{identity} (default: @code{#f})
  23465. If specified, the path to the SSH private key to use to authenticate with the
  23466. remote host.
  23467. @item @code{host-key} (default: @code{#f})
  23468. This should be the SSH host key of the machine, which looks like this:
  23469. @example
  23470. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  23471. @end example
  23472. When @code{host-key} is @code{#f}, the server is authenticated against
  23473. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  23474. client does.
  23475. @item @code{allow-downgrades?} (default: @code{#f})
  23476. Whether to allow potential downgrades.
  23477. Like @command{guix system reconfigure}, @command{guix deploy} compares
  23478. the channel commits currently deployed on the remote host (as returned
  23479. by @command{guix system describe}) to those currently in use (as
  23480. returned by @command{guix describe}) to determine whether commits
  23481. currently in use are descendants of those deployed. When this is not
  23482. the case and @code{allow-downgrades?} is false, it raises an error.
  23483. This ensures you do not accidentally downgrade remote machines.
  23484. @end table
  23485. @end deftp
  23486. @deftp {Data Type} digital-ocean-configuration
  23487. This is the data type describing the Droplet that should be created for a
  23488. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  23489. @table @asis
  23490. @item @code{ssh-key}
  23491. The path to the SSH private key to use to authenticate with the remote
  23492. host. In the future, this field may not exist.
  23493. @item @code{tags}
  23494. A list of string ``tags'' that uniquely identify the machine. Must be given
  23495. such that no two machines in the deployment have the same set of tags.
  23496. @item @code{region}
  23497. A Digital Ocean region slug, such as @code{"nyc3"}.
  23498. @item @code{size}
  23499. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  23500. @item @code{enable-ipv6?}
  23501. Whether or not the droplet should be created with IPv6 networking.
  23502. @end table
  23503. @end deftp
  23504. @node Running Guix in a VM
  23505. @section Running Guix in a Virtual Machine
  23506. @cindex virtual machine
  23507. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
  23508. distributed at
  23509. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.xz}.
  23510. This image is a compressed image in QCOW format. You will first need to
  23511. decompress with @command{xz -d}, and then you can pass it to an emulator such
  23512. as QEMU (see below for details).
  23513. This image boots the Xfce graphical environment and it contains some
  23514. commonly-used tools. You can install more software in the image by running
  23515. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  23516. also reconfigure the system based on its initial configuration file available
  23517. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  23518. Configuration System}).
  23519. Instead of using this pre-built image, one can also build their own virtual
  23520. machine image using @command{guix system vm-image} (@pxref{Invoking guix
  23521. system}). The returned image is in qcow2 format, which the
  23522. @uref{https://qemu.org/, QEMU emulator} can efficiently use.
  23523. @cindex QEMU
  23524. If you built your own image, you must copy it out of the store
  23525. (@pxref{The Store}) and give yourself permission to write to the copy
  23526. before you can use it. When invoking QEMU, you must choose a system
  23527. emulator that is suitable for your hardware platform. Here is a minimal
  23528. QEMU invocation that will boot the result of @command{guix system
  23529. vm-image} on x86_64 hardware:
  23530. @example
  23531. $ qemu-system-x86_64 \
  23532. -nic user,model=virtio-net-pci \
  23533. -enable-kvm -m 1024 \
  23534. -device virtio-blk,drive=myhd \
  23535. -drive if=none,file=/tmp/qemu-image,id=myhd
  23536. @end example
  23537. Here is what each of these options means:
  23538. @table @code
  23539. @item qemu-system-x86_64
  23540. This specifies the hardware platform to emulate. This should match the
  23541. host.
  23542. @item -nic user,model=virtio-net-pci
  23543. Enable the unprivileged user-mode network stack. The guest OS can
  23544. access the host but not vice versa. This is the simplest way to get the
  23545. guest OS online. @code{model} specifies which network device to emulate:
  23546. @code{virtio-net-pci} is a special device made for virtualized operating
  23547. systems and recommended for most uses. Assuming your hardware platform is
  23548. x86_64, you can get a list of available NIC models by running
  23549. @command{qemu-system-x86_64 -nic model=help}.
  23550. @item -enable-kvm
  23551. If your system has hardware virtualization extensions, enabling the
  23552. virtual machine support (KVM) of the Linux kernel will make things run
  23553. faster.
  23554. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  23555. @item -m 1024
  23556. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  23557. which may be insufficient for some operations.
  23558. @item -device virtio-blk,drive=myhd
  23559. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  23560. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  23561. better performance than if it were emulating a complete disk drive. See the
  23562. QEMU and KVM documentation for more info.
  23563. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  23564. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing store the
  23565. the ``myhd'' drive.
  23566. @end table
  23567. The default @command{run-vm.sh} script that is returned by an invocation of
  23568. @command{guix system vm} does not add a @command{-nic user} flag by default.
  23569. To get network access from within the vm add the @code{(dhcp-client-service)}
  23570. to your system definition and start the VM using
  23571. @command{`guix system vm config.scm` -nic user}. An important caveat of using
  23572. @command{-nic user} for networking is that @command{ping} will not work, because
  23573. it uses the ICMP protocol. You'll have to use a different command to check for
  23574. network connectivity, for example @command{guix download}.
  23575. @subsection Connecting Through SSH
  23576. @cindex SSH
  23577. @cindex SSH server
  23578. To enable SSH inside a VM you need to add an SSH server like
  23579. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  23580. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  23581. 22 by default, to the host. You can do this with
  23582. @example
  23583. `guix system vm config.scm` -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  23584. @end example
  23585. To connect to the VM you can run
  23586. @example
  23587. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  23588. @end example
  23589. The @command{-p} tells @command{ssh} the port you want to connect to.
  23590. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  23591. every time you modify your @command{config.scm} file and the
  23592. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  23593. connection to an unknown host every time you connect.
  23594. @subsection Using @command{virt-viewer} with Spice
  23595. As an alternative to the default @command{qemu} graphical client you can
  23596. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  23597. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  23598. @command{qemu}. See previous section for further information on how to do this.
  23599. Spice also allows you to do some nice stuff like share your clipboard with your
  23600. VM. To enable that you'll also have to pass the following flags to @command{qemu}:
  23601. @example
  23602. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  23603. -chardev spicevmc,name=vdagent,id=vdagent
  23604. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  23605. name=com.redhat.spice.0
  23606. @end example
  23607. You'll also need to add the @code{(spice-vdagent-service)} to your
  23608. system definition (@pxref{Miscellaneous Services, Spice service}).
  23609. @node Defining Services
  23610. @section Defining Services
  23611. The previous sections show the available services and how one can combine
  23612. them in an @code{operating-system} declaration. But how do we define
  23613. them in the first place? And what is a service anyway?
  23614. @menu
  23615. * Service Composition:: The model for composing services.
  23616. * Service Types and Services:: Types and services.
  23617. * Service Reference:: API reference.
  23618. * Shepherd Services:: A particular type of service.
  23619. @end menu
  23620. @node Service Composition
  23621. @subsection Service Composition
  23622. @cindex services
  23623. @cindex daemons
  23624. Here we define a @dfn{service} as, broadly, something that extends the
  23625. functionality of the operating system. Often a service is a process---a
  23626. @dfn{daemon}---started when the system boots: a secure shell server, a
  23627. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  23628. whose execution can be triggered by another daemon---e.g., an FTP server
  23629. started by @command{inetd} or a D-Bus service activated by
  23630. @command{dbus-daemon}. Occasionally, a service does not map to a
  23631. daemon. For instance, the ``account'' service collects user accounts
  23632. and makes sure they exist when the system runs; the ``udev'' service
  23633. collects device management rules and makes them available to the eudev
  23634. daemon; the @file{/etc} service populates the @file{/etc} directory
  23635. of the system.
  23636. @cindex service extensions
  23637. Guix system services are connected by @dfn{extensions}. For instance, the
  23638. secure shell service @emph{extends} the Shepherd---the
  23639. initialization system, running as PID@tie{}1---by giving it the command
  23640. lines to start and stop the secure shell daemon (@pxref{Networking
  23641. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  23642. service by passing it its @file{.service} specification, and extends the
  23643. udev service by passing it device management rules (@pxref{Desktop
  23644. Services, @code{upower-service}}); the Guix daemon service extends the
  23645. Shepherd by passing it the command lines to start and stop the daemon,
  23646. and extends the account service by passing it a list of required build
  23647. user accounts (@pxref{Base Services}).
  23648. All in all, services and their ``extends'' relations form a directed
  23649. acyclic graph (DAG). If we represent services as boxes and extensions
  23650. as arrows, a typical system might provide something like this:
  23651. @image{images/service-graph,,5in,Typical service extension graph.}
  23652. @cindex system service
  23653. At the bottom, we see the @dfn{system service}, which produces the
  23654. directory containing everything to run and boot the system, as returned
  23655. by the @command{guix system build} command. @xref{Service Reference},
  23656. to learn about the other service types shown here.
  23657. @xref{system-extension-graph, the @command{guix system extension-graph}
  23658. command}, for information on how to generate this representation for a
  23659. particular operating system definition.
  23660. @cindex service types
  23661. Technically, developers can define @dfn{service types} to express these
  23662. relations. There can be any number of services of a given type on the
  23663. system---for instance, a system running two instances of the GNU secure
  23664. shell server (lsh) has two instances of @code{lsh-service-type}, with
  23665. different parameters.
  23666. The following section describes the programming interface for service
  23667. types and services.
  23668. @node Service Types and Services
  23669. @subsection Service Types and Services
  23670. A @dfn{service type} is a node in the DAG described above. Let us start
  23671. with a simple example, the service type for the Guix build daemon
  23672. (@pxref{Invoking guix-daemon}):
  23673. @lisp
  23674. (define guix-service-type
  23675. (service-type
  23676. (name 'guix)
  23677. (extensions
  23678. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  23679. (service-extension account-service-type guix-accounts)
  23680. (service-extension activation-service-type guix-activation)))
  23681. (default-value (guix-configuration))))
  23682. @end lisp
  23683. @noindent
  23684. It defines three things:
  23685. @enumerate
  23686. @item
  23687. A name, whose sole purpose is to make inspection and debugging easier.
  23688. @item
  23689. A list of @dfn{service extensions}, where each extension designates the
  23690. target service type and a procedure that, given the parameters of the
  23691. service, returns a list of objects to extend the service of that type.
  23692. Every service type has at least one service extension. The only
  23693. exception is the @dfn{boot service type}, which is the ultimate service.
  23694. @item
  23695. Optionally, a default value for instances of this type.
  23696. @end enumerate
  23697. In this example, @code{guix-service-type} extends three services:
  23698. @table @code
  23699. @item shepherd-root-service-type
  23700. The @code{guix-shepherd-service} procedure defines how the Shepherd
  23701. service is extended. Namely, it returns a @code{<shepherd-service>}
  23702. object that defines how @command{guix-daemon} is started and stopped
  23703. (@pxref{Shepherd Services}).
  23704. @item account-service-type
  23705. This extension for this service is computed by @code{guix-accounts},
  23706. which returns a list of @code{user-group} and @code{user-account}
  23707. objects representing the build user accounts (@pxref{Invoking
  23708. guix-daemon}).
  23709. @item activation-service-type
  23710. Here @code{guix-activation} is a procedure that returns a gexp, which is
  23711. a code snippet to run at ``activation time''---e.g., when the service is
  23712. booted.
  23713. @end table
  23714. A service of this type is instantiated like this:
  23715. @lisp
  23716. (service guix-service-type
  23717. (guix-configuration
  23718. (build-accounts 5)
  23719. (extra-options '("--gc-keep-derivations"))))
  23720. @end lisp
  23721. The second argument to the @code{service} form is a value representing
  23722. the parameters of this specific service instance.
  23723. @xref{guix-configuration-type, @code{guix-configuration}}, for
  23724. information about the @code{guix-configuration} data type. When the
  23725. value is omitted, the default value specified by
  23726. @code{guix-service-type} is used:
  23727. @lisp
  23728. (service guix-service-type)
  23729. @end lisp
  23730. @code{guix-service-type} is quite simple because it extends other
  23731. services but is not extensible itself.
  23732. @c @subsubsubsection Extensible Service Types
  23733. The service type for an @emph{extensible} service looks like this:
  23734. @lisp
  23735. (define udev-service-type
  23736. (service-type (name 'udev)
  23737. (extensions
  23738. (list (service-extension shepherd-root-service-type
  23739. udev-shepherd-service)))
  23740. (compose concatenate) ;concatenate the list of rules
  23741. (extend (lambda (config rules)
  23742. (match config
  23743. (($ <udev-configuration> udev initial-rules)
  23744. (udev-configuration
  23745. (udev udev) ;the udev package to use
  23746. (rules (append initial-rules rules)))))))))
  23747. @end lisp
  23748. This is the service type for the
  23749. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  23750. management daemon}. Compared to the previous example, in addition to an
  23751. extension of @code{shepherd-root-service-type}, we see two new fields:
  23752. @table @code
  23753. @item compose
  23754. This is the procedure to @dfn{compose} the list of extensions to
  23755. services of this type.
  23756. Services can extend the udev service by passing it lists of rules; we
  23757. compose those extensions simply by concatenating them.
  23758. @item extend
  23759. This procedure defines how the value of the service is @dfn{extended} with
  23760. the composition of the extensions.
  23761. Udev extensions are composed into a list of rules, but the udev service
  23762. value is itself a @code{<udev-configuration>} record. So here, we
  23763. extend that record by appending the list of rules it contains to the
  23764. list of contributed rules.
  23765. @item description
  23766. This is a string giving an overview of the service type. The string can
  23767. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  23768. @command{guix system search} command searches these strings and displays
  23769. them (@pxref{Invoking guix system}).
  23770. @end table
  23771. There can be only one instance of an extensible service type such as
  23772. @code{udev-service-type}. If there were more, the
  23773. @code{service-extension} specifications would be ambiguous.
  23774. Still here? The next section provides a reference of the programming
  23775. interface for services.
  23776. @node Service Reference
  23777. @subsection Service Reference
  23778. We have seen an overview of service types (@pxref{Service Types and
  23779. Services}). This section provides a reference on how to manipulate
  23780. services and service types. This interface is provided by the
  23781. @code{(gnu services)} module.
  23782. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  23783. Return a new service of @var{type}, a @code{<service-type>} object (see
  23784. below). @var{value} can be any object; it represents the parameters of
  23785. this particular service instance.
  23786. When @var{value} is omitted, the default value specified by @var{type}
  23787. is used; if @var{type} does not specify a default value, an error is
  23788. raised.
  23789. For instance, this:
  23790. @lisp
  23791. (service openssh-service-type)
  23792. @end lisp
  23793. @noindent
  23794. is equivalent to this:
  23795. @lisp
  23796. (service openssh-service-type
  23797. (openssh-configuration))
  23798. @end lisp
  23799. In both cases the result is an instance of @code{openssh-service-type}
  23800. with the default configuration.
  23801. @end deffn
  23802. @deffn {Scheme Procedure} service? @var{obj}
  23803. Return true if @var{obj} is a service.
  23804. @end deffn
  23805. @deffn {Scheme Procedure} service-kind @var{service}
  23806. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  23807. @end deffn
  23808. @deffn {Scheme Procedure} service-value @var{service}
  23809. Return the value associated with @var{service}. It represents its
  23810. parameters.
  23811. @end deffn
  23812. Here is an example of how a service is created and manipulated:
  23813. @lisp
  23814. (define s
  23815. (service nginx-service-type
  23816. (nginx-configuration
  23817. (nginx nginx)
  23818. (log-directory log-directory)
  23819. (run-directory run-directory)
  23820. (file config-file))))
  23821. (service? s)
  23822. @result{} #t
  23823. (eq? (service-kind s) nginx-service-type)
  23824. @result{} #t
  23825. @end lisp
  23826. The @code{modify-services} form provides a handy way to change the
  23827. parameters of some of the services of a list such as
  23828. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  23829. evaluates to a list of services. Of course, you could always use
  23830. standard list combinators such as @code{map} and @code{fold} to do that
  23831. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  23832. @code{modify-services} simply provides a more concise form for this
  23833. common pattern.
  23834. @deffn {Scheme Syntax} modify-services @var{services} @
  23835. (@var{type} @var{variable} => @var{body}) @dots{}
  23836. Modify the services listed in @var{services} according to the given
  23837. clauses. Each clause has the form:
  23838. @example
  23839. (@var{type} @var{variable} => @var{body})
  23840. @end example
  23841. where @var{type} is a service type---e.g.,
  23842. @code{guix-service-type}---and @var{variable} is an identifier that is
  23843. bound within the @var{body} to the service parameters---e.g., a
  23844. @code{guix-configuration} instance---of the original service of that
  23845. @var{type}.
  23846. The @var{body} should evaluate to the new service parameters, which will
  23847. be used to configure the new service. This new service will replace the
  23848. original in the resulting list. Because a service's service parameters
  23849. are created using @code{define-record-type*}, you can write a succinct
  23850. @var{body} that evaluates to the new service parameters by using the
  23851. @code{inherit} feature that @code{define-record-type*} provides.
  23852. @xref{Using the Configuration System}, for example usage.
  23853. @end deffn
  23854. Next comes the programming interface for service types. This is
  23855. something you want to know when writing new service definitions, but not
  23856. necessarily when simply looking for ways to customize your
  23857. @code{operating-system} declaration.
  23858. @deftp {Data Type} service-type
  23859. @cindex service type
  23860. This is the representation of a @dfn{service type} (@pxref{Service Types
  23861. and Services}).
  23862. @table @asis
  23863. @item @code{name}
  23864. This is a symbol, used only to simplify inspection and debugging.
  23865. @item @code{extensions}
  23866. A non-empty list of @code{<service-extension>} objects (see below).
  23867. @item @code{compose} (default: @code{#f})
  23868. If this is @code{#f}, then the service type denotes services that cannot
  23869. be extended---i.e., services that do not receive ``values'' from other
  23870. services.
  23871. Otherwise, it must be a one-argument procedure. The procedure is called
  23872. by @code{fold-services} and is passed a list of values collected from
  23873. extensions. It may return any single value.
  23874. @item @code{extend} (default: @code{#f})
  23875. If this is @code{#f}, services of this type cannot be extended.
  23876. Otherwise, it must be a two-argument procedure: @code{fold-services}
  23877. calls it, passing it the initial value of the service as the first
  23878. argument and the result of applying @code{compose} to the extension
  23879. values as the second argument. It must return a value that is a valid
  23880. parameter value for the service instance.
  23881. @item @code{description}
  23882. This is a string, possibly using Texinfo markup, describing in a couple
  23883. of sentences what the service is about. This string allows users to
  23884. find about the service through @command{guix system search}
  23885. (@pxref{Invoking guix system}).
  23886. @item @code{default-value} (default: @code{&no-default-value})
  23887. The default value associated for instances of this service type. This
  23888. allows users to use the @code{service} form without its second argument:
  23889. @lisp
  23890. (service @var{type})
  23891. @end lisp
  23892. The returned service in this case has the default value specified by
  23893. @var{type}.
  23894. @end table
  23895. @xref{Service Types and Services}, for examples.
  23896. @end deftp
  23897. @deffn {Scheme Procedure} service-extension @var{target-type} @
  23898. @var{compute}
  23899. Return a new extension for services of type @var{target-type}.
  23900. @var{compute} must be a one-argument procedure: @code{fold-services}
  23901. calls it, passing it the value associated with the service that provides
  23902. the extension; it must return a valid value for the target service.
  23903. @end deffn
  23904. @deffn {Scheme Procedure} service-extension? @var{obj}
  23905. Return true if @var{obj} is a service extension.
  23906. @end deffn
  23907. Occasionally, you might want to simply extend an existing service. This
  23908. involves creating a new service type and specifying the extension of
  23909. interest, which can be verbose; the @code{simple-service} procedure
  23910. provides a shorthand for this.
  23911. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  23912. Return a service that extends @var{target} with @var{value}. This works
  23913. by creating a singleton service type @var{name}, of which the returned
  23914. service is an instance.
  23915. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  23916. an additional job:
  23917. @lisp
  23918. (simple-service 'my-mcron-job mcron-service-type
  23919. #~(job '(next-hour (3)) "guix gc -F 2G"))
  23920. @end lisp
  23921. @end deffn
  23922. At the core of the service abstraction lies the @code{fold-services}
  23923. procedure, which is responsible for ``compiling'' a list of services
  23924. down to a single directory that contains everything needed to boot and
  23925. run the system---the directory shown by the @command{guix system build}
  23926. command (@pxref{Invoking guix system}). In essence, it propagates
  23927. service extensions down the service graph, updating each node parameters
  23928. on the way, until it reaches the root node.
  23929. @deffn {Scheme Procedure} fold-services @var{services} @
  23930. [#:target-type @var{system-service-type}]
  23931. Fold @var{services} by propagating their extensions down to the root of
  23932. type @var{target-type}; return the root service adjusted accordingly.
  23933. @end deffn
  23934. Lastly, the @code{(gnu services)} module also defines several essential
  23935. service types, some of which are listed below.
  23936. @defvr {Scheme Variable} system-service-type
  23937. This is the root of the service graph. It produces the system directory
  23938. as returned by the @command{guix system build} command.
  23939. @end defvr
  23940. @defvr {Scheme Variable} boot-service-type
  23941. The type of the ``boot service'', which produces the @dfn{boot script}.
  23942. The boot script is what the initial RAM disk runs when booting.
  23943. @end defvr
  23944. @defvr {Scheme Variable} etc-service-type
  23945. The type of the @file{/etc} service. This service is used to create
  23946. files under @file{/etc} and can be extended by
  23947. passing it name/file tuples such as:
  23948. @lisp
  23949. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  23950. @end lisp
  23951. In this example, the effect would be to add an @file{/etc/issue} file
  23952. pointing to the given file.
  23953. @end defvr
  23954. @defvr {Scheme Variable} setuid-program-service-type
  23955. Type for the ``setuid-program service''. This service collects lists of
  23956. executable file names, passed as gexps, and adds them to the set of
  23957. setuid-root programs on the system (@pxref{Setuid Programs}).
  23958. @end defvr
  23959. @defvr {Scheme Variable} profile-service-type
  23960. Type of the service that populates the @dfn{system profile}---i.e., the
  23961. programs under @file{/run/current-system/profile}. Other services can
  23962. extend it by passing it lists of packages to add to the system profile.
  23963. @end defvr
  23964. @cindex provenance tracking, of the operating system
  23965. @anchor{provenance-service-type}
  23966. @defvr {Scheme Variable} provenance-service-type
  23967. This is the type of the service that records @dfn{provenance meta-data}
  23968. in the system itself. It creates several files under
  23969. @file{/run/current-system}:
  23970. @table @file
  23971. @item channels.scm
  23972. This is a ``channel file'' that can be passed to @command{guix pull -C}
  23973. or @command{guix time-machine -C}, and which describes the channels used
  23974. to build the system, if that information was available
  23975. (@pxref{Channels}).
  23976. @item configuration.scm
  23977. This is the file that was passed as the value for this
  23978. @code{provenance-service-type} service. By default, @command{guix
  23979. system reconfigure} automatically passes the OS configuration file it
  23980. received on the command line.
  23981. @item provenance
  23982. This contains the same information as the two other files but in a
  23983. format that is more readily processable.
  23984. @end table
  23985. In general, these two pieces of information (channels and configuration
  23986. file) are enough to reproduce the operating system ``from source''.
  23987. @quotation Caveats
  23988. This information is necessary to rebuild your operating system, but it
  23989. is not always sufficient. In particular, @file{configuration.scm}
  23990. itself is insufficient if it is not self-contained---if it refers to
  23991. external Guile modules or to extra files. If you want
  23992. @file{configuration.scm} to be self-contained, we recommend that modules
  23993. or files it refers to be part of a channel.
  23994. Besides, provenance meta-data is ``silent'' in the sense that it does
  23995. not change the bits contained in your system, @emph{except for the
  23996. meta-data bits themselves}. Two different OS configurations or sets of
  23997. channels can lead to the same system, bit-for-bit; when
  23998. @code{provenance-service-type} is used, these two systems will have
  23999. different meta-data and thus different store file names, which makes
  24000. comparison less trivial.
  24001. @end quotation
  24002. This service is automatically added to your operating system
  24003. configuration when you use @command{guix system reconfigure},
  24004. @command{guix system init}, or @command{guix deploy}.
  24005. @end defvr
  24006. @node Shepherd Services
  24007. @subsection Shepherd Services
  24008. @cindex shepherd services
  24009. @cindex PID 1
  24010. @cindex init system
  24011. The @code{(gnu services shepherd)} module provides a way to define
  24012. services managed by the GNU@tie{}Shepherd, which is the
  24013. initialization system---the first process that is started when the
  24014. system boots, also known as PID@tie{}1
  24015. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  24016. Services in the Shepherd can depend on each other. For instance, the
  24017. SSH daemon may need to be started after the syslog daemon has been
  24018. started, which in turn can only happen once all the file systems have
  24019. been mounted. The simple operating system defined earlier (@pxref{Using
  24020. the Configuration System}) results in a service graph like this:
  24021. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  24022. You can actually generate such a graph for any operating system
  24023. definition using the @command{guix system shepherd-graph} command
  24024. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  24025. The @code{%shepherd-root-service} is a service object representing
  24026. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  24027. by passing it lists of @code{<shepherd-service>} objects.
  24028. @deftp {Data Type} shepherd-service
  24029. The data type representing a service managed by the Shepherd.
  24030. @table @asis
  24031. @item @code{provision}
  24032. This is a list of symbols denoting what the service provides.
  24033. These are the names that may be passed to @command{herd start},
  24034. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  24035. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  24036. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  24037. @item @code{requirement} (default: @code{'()})
  24038. List of symbols denoting the Shepherd services this one depends on.
  24039. @cindex one-shot services, for the Shepherd
  24040. @item @code{one-shot?} (default: @code{#f})
  24041. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  24042. after their @code{start} action has completed. @xref{Slots of services,,,
  24043. shepherd, The GNU Shepherd Manual}, for more info.
  24044. @item @code{respawn?} (default: @code{#t})
  24045. Whether to restart the service when it stops, for instance when the
  24046. underlying process dies.
  24047. @item @code{start}
  24048. @itemx @code{stop} (default: @code{#~(const #f)})
  24049. The @code{start} and @code{stop} fields refer to the Shepherd's
  24050. facilities to start and stop processes (@pxref{Service De- and
  24051. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  24052. G-expressions that get expanded in the Shepherd configuration file
  24053. (@pxref{G-Expressions}).
  24054. @item @code{actions} (default: @code{'()})
  24055. @cindex actions, of Shepherd services
  24056. This is a list of @code{shepherd-action} objects (see below) defining
  24057. @dfn{actions} supported by the service, in addition to the standard
  24058. @code{start} and @code{stop} actions. Actions listed here become available as
  24059. @command{herd} sub-commands:
  24060. @example
  24061. herd @var{action} @var{service} [@var{arguments}@dots{}]
  24062. @end example
  24063. @item @code{auto-start?} (default: @code{#t})
  24064. Whether this service should be started automatically by the Shepherd. If it
  24065. is @code{#f} the service has to be started manually with @code{herd start}.
  24066. @item @code{documentation}
  24067. A documentation string, as shown when running:
  24068. @example
  24069. herd doc @var{service-name}
  24070. @end example
  24071. where @var{service-name} is one of the symbols in @code{provision}
  24072. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  24073. @item @code{modules} (default: @code{%default-modules})
  24074. This is the list of modules that must be in scope when @code{start} and
  24075. @code{stop} are evaluated.
  24076. @end table
  24077. @end deftp
  24078. @deftp {Data Type} shepherd-action
  24079. This is the data type that defines additional actions implemented by a
  24080. Shepherd service (see above).
  24081. @table @code
  24082. @item name
  24083. Symbol naming the action.
  24084. @item documentation
  24085. This is a documentation string for the action. It can be viewed by running:
  24086. @example
  24087. herd doc @var{service} action @var{action}
  24088. @end example
  24089. @item procedure
  24090. This should be a gexp that evaluates to a procedure of at least one argument,
  24091. which is the ``running value'' of the service (@pxref{Slots of services,,,
  24092. shepherd, The GNU Shepherd Manual}).
  24093. @end table
  24094. The following example defines an action called @code{say-hello} that kindly
  24095. greets the user:
  24096. @lisp
  24097. (shepherd-action
  24098. (name 'say-hello)
  24099. (documentation "Say hi!")
  24100. (procedure #~(lambda (running . args)
  24101. (format #t "Hello, friend! arguments: ~s\n"
  24102. args)
  24103. #t)))
  24104. @end lisp
  24105. Assuming this action is added to the @code{example} service, then you can do:
  24106. @example
  24107. # herd say-hello example
  24108. Hello, friend! arguments: ()
  24109. # herd say-hello example a b c
  24110. Hello, friend! arguments: ("a" "b" "c")
  24111. @end example
  24112. This, as you can see, is a fairly sophisticated way to say hello.
  24113. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  24114. info on actions.
  24115. @end deftp
  24116. @defvr {Scheme Variable} shepherd-root-service-type
  24117. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  24118. This is the service type that extensions target when they want to create
  24119. shepherd services (@pxref{Service Types and Services}, for an example).
  24120. Each extension must pass a list of @code{<shepherd-service>}.
  24121. @end defvr
  24122. @defvr {Scheme Variable} %shepherd-root-service
  24123. This service represents PID@tie{}1.
  24124. @end defvr
  24125. @node Documentation
  24126. @chapter Documentation
  24127. @cindex documentation, searching for
  24128. @cindex searching for documentation
  24129. @cindex Info, documentation format
  24130. @cindex man pages
  24131. @cindex manual pages
  24132. In most cases packages installed with Guix come with documentation.
  24133. There are two main documentation formats: ``Info'', a browseable
  24134. hypertext format used for GNU software, and ``manual pages'' (or ``man
  24135. pages''), the linear documentation format traditionally found on Unix.
  24136. Info manuals are accessed with the @command{info} command or with Emacs,
  24137. and man pages are accessed using @command{man}.
  24138. You can look for documentation of software installed on your system by
  24139. keyword. For example, the following command searches for information
  24140. about ``TLS'' in Info manuals:
  24141. @example
  24142. $ info -k TLS
  24143. "(emacs)Network Security" -- STARTTLS
  24144. "(emacs)Network Security" -- TLS
  24145. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  24146. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  24147. @dots{}
  24148. @end example
  24149. @noindent
  24150. The command below searches for the same keyword in man pages:
  24151. @example
  24152. $ man -k TLS
  24153. SSL (7) - OpenSSL SSL/TLS library
  24154. certtool (1) - GnuTLS certificate tool
  24155. @dots {}
  24156. @end example
  24157. These searches are purely local to your computer so you have the
  24158. guarantee that documentation you find corresponds to what you have
  24159. actually installed, you can access it off-line, and your privacy is
  24160. respected.
  24161. Once you have these results, you can view the relevant documentation by
  24162. running, say:
  24163. @example
  24164. $ info "(gnutls)Core TLS API"
  24165. @end example
  24166. @noindent
  24167. or:
  24168. @example
  24169. $ man certtool
  24170. @end example
  24171. Info manuals contain sections and indices as well as hyperlinks like
  24172. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  24173. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  24174. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  24175. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  24176. Introduction}, for an introduction to Info navigation.
  24177. @node Installing Debugging Files
  24178. @chapter Installing Debugging Files
  24179. @cindex debugging files
  24180. Program binaries, as produced by the GCC compilers for instance, are
  24181. typically written in the ELF format, with a section containing
  24182. @dfn{debugging information}. Debugging information is what allows the
  24183. debugger, GDB, to map binary code to source code; it is required to
  24184. debug a compiled program in good conditions.
  24185. The problem with debugging information is that is takes up a fair amount
  24186. of disk space. For example, debugging information for the GNU C Library
  24187. weighs in at more than 60 MiB. Thus, as a user, keeping all the
  24188. debugging info of all the installed programs is usually not an option.
  24189. Yet, space savings should not come at the cost of an impediment to
  24190. debugging---especially in the GNU system, which should make it easier
  24191. for users to exert their computing freedom (@pxref{GNU Distribution}).
  24192. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  24193. mechanism that allows users to get the best of both worlds: debugging
  24194. information can be stripped from the binaries and stored in separate
  24195. files. GDB is then able to load debugging information from those files,
  24196. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  24197. with GDB}).
  24198. The GNU distribution takes advantage of this by storing debugging
  24199. information in the @code{lib/debug} sub-directory of a separate package
  24200. output unimaginatively called @code{debug} (@pxref{Packages with
  24201. Multiple Outputs}). Users can choose to install the @code{debug} output
  24202. of a package when they need it. For instance, the following command
  24203. installs the debugging information for the GNU C Library and for GNU
  24204. Guile:
  24205. @example
  24206. guix install glibc:debug guile:debug
  24207. @end example
  24208. GDB must then be told to look for debug files in the user's profile, by
  24209. setting the @code{debug-file-directory} variable (consider setting it
  24210. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  24211. GDB}):
  24212. @example
  24213. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  24214. @end example
  24215. From there on, GDB will pick up debugging information from the
  24216. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  24217. In addition, you will most likely want GDB to be able to show the source
  24218. code being debugged. To do that, you will have to unpack the source
  24219. code of the package of interest (obtained with @code{guix build
  24220. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  24221. directory using the @code{directory} command (@pxref{Source Path,
  24222. @code{directory},, gdb, Debugging with GDB}).
  24223. @c XXX: keep me up-to-date
  24224. The @code{debug} output mechanism in Guix is implemented by the
  24225. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  24226. opt-in---debugging information is available only for the packages
  24227. with definitions explicitly declaring a @code{debug} output. This may be
  24228. changed to opt-out in the future if our build farm servers can handle
  24229. the load. To check whether a package has a @code{debug} output, use
  24230. @command{guix package --list-available} (@pxref{Invoking guix package}).
  24231. @node Security Updates
  24232. @chapter Security Updates
  24233. @cindex security updates
  24234. @cindex security vulnerabilities
  24235. Occasionally, important security vulnerabilities are discovered in software
  24236. packages and must be patched. Guix developers try hard to keep track of
  24237. known vulnerabilities and to apply fixes as soon as possible in the
  24238. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  24239. containing only security updates). The @command{guix lint} tool helps
  24240. developers find out about vulnerable versions of software packages in the
  24241. distribution:
  24242. @smallexample
  24243. $ guix lint -c cve
  24244. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  24245. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  24246. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  24247. @dots{}
  24248. @end smallexample
  24249. @xref{Invoking guix lint}, for more information.
  24250. Guix follows a functional
  24251. package management discipline (@pxref{Introduction}), which implies
  24252. that, when a package is changed, @emph{every package that depends on it}
  24253. must be rebuilt. This can significantly slow down the deployment of
  24254. fixes in core packages such as libc or Bash, since basically the whole
  24255. distribution would need to be rebuilt. Using pre-built binaries helps
  24256. (@pxref{Substitutes}), but deployment may still take more time than
  24257. desired.
  24258. @cindex grafts
  24259. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  24260. for fast deployment of critical updates without the costs associated
  24261. with a whole-distribution rebuild. The idea is to rebuild only the
  24262. package that needs to be patched, and then to ``graft'' it onto packages
  24263. explicitly installed by the user and that were previously referring to
  24264. the original package. The cost of grafting is typically very low, and
  24265. order of magnitudes lower than a full rebuild of the dependency chain.
  24266. @cindex replacements of packages, for grafts
  24267. For instance, suppose a security update needs to be applied to Bash.
  24268. Guix developers will provide a package definition for the ``fixed''
  24269. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  24270. Packages}). Then, the original package definition is augmented with a
  24271. @code{replacement} field pointing to the package containing the bug fix:
  24272. @lisp
  24273. (define bash
  24274. (package
  24275. (name "bash")
  24276. ;; @dots{}
  24277. (replacement bash-fixed)))
  24278. @end lisp
  24279. From there on, any package depending directly or indirectly on Bash---as
  24280. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  24281. gc})---that is installed is automatically ``rewritten'' to refer to
  24282. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  24283. time proportional to the size of the package, usually less than a
  24284. minute for an ``average'' package on a recent machine. Grafting is
  24285. recursive: when an indirect dependency requires grafting, then grafting
  24286. ``propagates'' up to the package that the user is installing.
  24287. Currently, the length of the name and version of the graft and that of
  24288. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  24289. above) must be equal. This restriction mostly comes from the fact that
  24290. grafting works by patching files, including binary files, directly.
  24291. Other restrictions may apply: for instance, when adding a graft to a
  24292. package providing a shared library, the original shared library and its
  24293. replacement must have the same @code{SONAME} and be binary-compatible.
  24294. The @option{--no-grafts} command-line option allows you to forcefully
  24295. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  24296. Thus, the command:
  24297. @example
  24298. guix build bash --no-grafts
  24299. @end example
  24300. @noindent
  24301. returns the store file name of the original Bash, whereas:
  24302. @example
  24303. guix build bash
  24304. @end example
  24305. @noindent
  24306. returns the store file name of the ``fixed'', replacement Bash. This
  24307. allows you to distinguish between the two variants of Bash.
  24308. To verify which Bash your whole profile refers to, you can run
  24309. (@pxref{Invoking guix gc}):
  24310. @example
  24311. guix gc -R `readlink -f ~/.guix-profile` | grep bash
  24312. @end example
  24313. @noindent
  24314. @dots{} and compare the store file names that you get with those above.
  24315. Likewise for a complete Guix system generation:
  24316. @example
  24317. guix gc -R `guix system build my-config.scm` | grep bash
  24318. @end example
  24319. Lastly, to check which Bash running processes are using, you can use the
  24320. @command{lsof} command:
  24321. @example
  24322. lsof | grep /gnu/store/.*bash
  24323. @end example
  24324. @node Bootstrapping
  24325. @chapter Bootstrapping
  24326. @c Adapted from the ELS 2013 paper.
  24327. @cindex bootstrapping
  24328. Bootstrapping in our context refers to how the distribution gets built
  24329. ``from nothing''. Remember that the build environment of a derivation
  24330. contains nothing but its declared inputs (@pxref{Introduction}). So
  24331. there's an obvious chicken-and-egg problem: how does the first package
  24332. get built? How does the first compiler get compiled? Note that this is
  24333. a question of interest only to the curious hacker, not to the regular
  24334. user, so you can shamelessly skip this section if you consider yourself
  24335. a ``regular user''.
  24336. @cindex bootstrap binaries
  24337. The GNU system is primarily made of C code, with libc at its core. The
  24338. GNU build system itself assumes the availability of a Bourne shell and
  24339. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  24340. `grep'. Furthermore, build programs---programs that run
  24341. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  24342. (@pxref{Derivations}). Consequently, to be able to build anything at
  24343. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  24344. Binutils, libc, and the other packages mentioned above---the
  24345. @dfn{bootstrap binaries}.
  24346. These bootstrap binaries are ``taken for granted'', though we can also
  24347. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  24348. Binaries}).
  24349. @menu
  24350. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  24351. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  24352. @end menu
  24353. @node Reduced Binary Seed Bootstrap
  24354. @section The Reduced Binary Seed Bootstrap
  24355. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  24356. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  24357. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  24358. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  24359. ``taken for granted.''
  24360. Taking the bootstrap binaries for granted means that we consider them to
  24361. be a correct and trustworthy ``seed'' for building the complete system.
  24362. Therein lies a problem: the combined size of these bootstrap binaries is
  24363. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  24364. or even inspecting these is next to impossible.
  24365. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  24366. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  24367. Source Bootstrap'' and while we are working towards that goal it would
  24368. be hyperbole to use that term for what we do now.}.
  24369. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  24370. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  24371. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  24372. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  24373. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  24374. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  24375. C Library are built from source. From here on the more traditional
  24376. bootstrap process resumes. This approach has reduced the bootstrap
  24377. binaries in size to about 145MB in Guix v1.1.
  24378. The next step that Guix has taken is to replace the shell and all its
  24379. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  24380. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  24381. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  24382. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  24383. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  24384. removed are now built from source.
  24385. Building the GNU System from source is currently only possibly by adding
  24386. some historical GNU packages as intermediate steps@footnote{Packages
  24387. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  24388. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  24389. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  24390. and GNU packages become more bootstrappable again (e.g., new releases of
  24391. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  24392. hard to bootstrap @code{xz}-compression), this set of added packages can
  24393. hopefully be reduced again.
  24394. The graph below shows the resulting dependency graph for
  24395. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  24396. traditional bootstrap of the rest of the Guix System.
  24397. @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
  24398. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  24399. The only significant binary bootstrap seeds that remain@footnote{
  24400. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  24401. together with @code{mes}.} are a Scheme intepreter and a Scheme
  24402. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  24403. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  24404. to get Guile running.}.
  24405. This further reduction has brought down the size of the binary seed to
  24406. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  24407. Work is ongoing to remove all binary blobs from our free software
  24408. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  24409. is work to bring these bootstraps to the @code{arm-linux} and
  24410. @code{aarch64-linux} architectures and to the Hurd.
  24411. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  24412. IRC network or discuss on @email{bug-mes@@gnu.org} or
  24413. @email{gash-devel@@nongnu.org}.
  24414. @node Preparing to Use the Bootstrap Binaries
  24415. @section Preparing to Use the Bootstrap Binaries
  24416. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  24417. @c large image, it's hard to scroll. Oh well.
  24418. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  24419. The figure above shows the very beginning of the dependency graph of the
  24420. distribution, corresponding to the package definitions of the @code{(gnu
  24421. packages bootstrap)} module. A similar figure can be generated with
  24422. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  24423. @example
  24424. guix graph -t derivation \
  24425. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  24426. | dot -Tps > gcc.ps
  24427. @end example
  24428. or, for the further Reduced Binary Seed bootstrap
  24429. @example
  24430. guix graph -t derivation \
  24431. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  24432. | dot -Tps > mes.ps
  24433. @end example
  24434. At this level of detail, things are
  24435. slightly complex. First, Guile itself consists of an ELF executable,
  24436. along with many source and compiled Scheme files that are dynamically
  24437. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  24438. tarball shown in this graph. This tarball is part of Guix's ``source''
  24439. distribution, and gets inserted into the store with @code{add-to-store}
  24440. (@pxref{The Store}).
  24441. But how do we write a derivation that unpacks this tarball and adds it
  24442. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  24443. derivation---the first one that gets built---uses @code{bash} as its
  24444. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  24445. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  24446. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  24447. the Guix source distribution, whose sole purpose is to allow the Guile
  24448. tarball to be unpacked.
  24449. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  24450. Guile that can be used to run subsequent build programs. Its first task
  24451. is to download tarballs containing the other pre-built binaries---this
  24452. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  24453. @code{ftp-client.scm} are used for this purpose. The
  24454. @code{module-import.drv} derivations import those modules in a directory
  24455. in the store, using the original layout. The
  24456. @code{module-import-compiled.drv} derivations compile those modules, and
  24457. write them in an output directory with the right layout. This
  24458. corresponds to the @code{#:modules} argument of
  24459. @code{build-expression->derivation} (@pxref{Derivations}).
  24460. Finally, the various tarballs are unpacked by the derivations
  24461. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  24462. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  24463. point we have a working C tool chain.
  24464. @unnumberedsec Building the Build Tools
  24465. Bootstrapping is complete when we have a full tool chain that does not
  24466. depend on the pre-built bootstrap tools discussed above. This
  24467. no-dependency requirement is verified by checking whether the files of
  24468. the final tool chain contain references to the @file{/gnu/store}
  24469. directories of the bootstrap inputs. The process that leads to this
  24470. ``final'' tool chain is described by the package definitions found in
  24471. the @code{(gnu packages commencement)} module.
  24472. The @command{guix graph} command allows us to ``zoom out'' compared to
  24473. the graph above, by looking at the level of package objects instead of
  24474. individual derivations---remember that a package may translate to
  24475. several derivations, typically one derivation to download its source,
  24476. one to build the Guile modules it needs, and one to actually build the
  24477. package from source. The command:
  24478. @example
  24479. guix graph -t bag \
  24480. -e '(@@@@ (gnu packages commencement)
  24481. glibc-final-with-bootstrap-bash)' | xdot -
  24482. @end example
  24483. @noindent
  24484. displays the dependency graph leading to the ``final'' C
  24485. library@footnote{You may notice the @code{glibc-intermediate} label,
  24486. suggesting that it is not @emph{quite} final, but as a good
  24487. approximation, we will consider it final.}, depicted below.
  24488. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  24489. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  24490. The first tool that gets built with the bootstrap binaries is
  24491. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  24492. for all the following packages. From there Findutils and Diffutils get
  24493. built.
  24494. Then come the first-stage Binutils and GCC, built as pseudo cross
  24495. tools---i.e., with @option{--target} equal to @option{--host}. They are
  24496. used to build libc. Thanks to this cross-build trick, this libc is
  24497. guaranteed not to hold any reference to the initial tool chain.
  24498. From there the final Binutils and GCC (not shown above) are built. GCC
  24499. uses @command{ld} from the final Binutils, and links programs against
  24500. the just-built libc. This tool chain is used to build the other
  24501. packages used by Guix and by the GNU Build System: Guile, Bash,
  24502. Coreutils, etc.
  24503. And voilà! At this point we have the complete set of build tools that
  24504. the GNU Build System expects. These are in the @code{%final-inputs}
  24505. variable of the @code{(gnu packages commencement)} module, and are
  24506. implicitly used by any package that uses @code{gnu-build-system}
  24507. (@pxref{Build Systems, @code{gnu-build-system}}).
  24508. @unnumberedsec Building the Bootstrap Binaries
  24509. @cindex bootstrap binaries
  24510. Because the final tool chain does not depend on the bootstrap binaries,
  24511. those rarely need to be updated. Nevertheless, it is useful to have an
  24512. automated way to produce them, should an update occur, and this is what
  24513. the @code{(gnu packages make-bootstrap)} module provides.
  24514. The following command builds the tarballs containing the bootstrap binaries
  24515. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  24516. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  24517. and Guile, and a tarball containing a mixture of Coreutils and other basic
  24518. command-line tools):
  24519. @example
  24520. guix build bootstrap-tarballs
  24521. @end example
  24522. The generated tarballs are those that should be referred to in the
  24523. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  24524. this section.
  24525. Still here? Then perhaps by now you've started to wonder: when do we
  24526. reach a fixed point? That is an interesting question! The answer is
  24527. unknown, but if you would like to investigate further (and have
  24528. significant computational and storage resources to do so), then let us
  24529. know.
  24530. @unnumberedsec Reducing the Set of Bootstrap Binaries
  24531. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  24532. binary code! Why is that a problem? It's a problem because these big chunks
  24533. of binary code are practically non-auditable, which makes it hard to establish
  24534. what source code produced them. Every unauditable binary also leaves us
  24535. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  24536. paper @emph{Reflections on Trusting Trust}.
  24537. This is mitigated by the fact that our bootstrap binaries were generated
  24538. from an earlier Guix revision. Nevertheless it lacks the level of
  24539. transparency that we get in the rest of the package dependency graph,
  24540. where Guix always gives us a source-to-binary mapping. Thus, our goal
  24541. is to reduce the set of bootstrap binaries to the bare minimum.
  24542. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  24543. on-going projects to do that. One of these is about replacing the
  24544. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  24545. of increasing complexity, which could be built from source starting from
  24546. a simple and auditable assembler.
  24547. Our first major achievement is the replacement of of GCC, the GNU C Library
  24548. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  24549. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  24550. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  24551. bootstrapped yet and thus we inject them as binary seeds. We call this the
  24552. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  24553. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  24554. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  24555. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  24556. also looking at any other bootstrap binaries. Your help is welcome!
  24557. @node Porting
  24558. @chapter Porting to a New Platform
  24559. As discussed above, the GNU distribution is self-contained, and
  24560. self-containment is achieved by relying on pre-built ``bootstrap
  24561. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  24562. operating system kernel, CPU architecture, and application binary
  24563. interface (ABI). Thus, to port the distribution to a platform that is
  24564. not yet supported, one must build those bootstrap binaries, and update
  24565. the @code{(gnu packages bootstrap)} module to use them on that platform.
  24566. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  24567. When everything goes well, and assuming the GNU tool chain supports the
  24568. target platform, this can be as simple as running a command like this
  24569. one:
  24570. @example
  24571. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  24572. @end example
  24573. For this to work, the @code{glibc-dynamic-linker} procedure in
  24574. @code{(gnu packages bootstrap)} must be augmented to return the right
  24575. file name for libc's dynamic linker on that platform; likewise,
  24576. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  24577. taught about the new platform.
  24578. Once these are built, the @code{(gnu packages bootstrap)} module needs
  24579. to be updated to refer to these binaries on the target platform. That
  24580. is, the hashes and URLs of the bootstrap tarballs for the new platform
  24581. must be added alongside those of the currently supported platforms. The
  24582. bootstrap Guile tarball is treated specially: it is expected to be
  24583. available locally, and @file{gnu/local.mk} has rules to download it for
  24584. the supported architectures; a rule for the new platform must be added
  24585. as well.
  24586. In practice, there may be some complications. First, it may be that the
  24587. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  24588. above) is not recognized by all the GNU tools. Typically, glibc
  24589. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  24590. configure flag (see @code{gcc.scm} for examples of how to handle this).
  24591. Second, some of the required packages could fail to build for that
  24592. platform. Lastly, the generated binaries could be broken for some
  24593. reason.
  24594. @c *********************************************************************
  24595. @include contributing.texi
  24596. @c *********************************************************************
  24597. @node Acknowledgments
  24598. @chapter Acknowledgments
  24599. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  24600. which was designed and
  24601. implemented by Eelco Dolstra, with contributions from other people (see
  24602. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  24603. management, and promoted unprecedented features, such as transactional
  24604. package upgrades and rollbacks, per-user profiles, and referentially
  24605. transparent build processes. Without this work, Guix would not exist.
  24606. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  24607. an inspiration for Guix.
  24608. GNU@tie{}Guix itself is a collective work with contributions from a
  24609. number of people. See the @file{AUTHORS} file in Guix for more
  24610. information on these fine people. The @file{THANKS} file lists people
  24611. who have helped by reporting bugs, taking care of the infrastructure,
  24612. providing artwork and themes, making suggestions, and more---thank you!
  24613. @c *********************************************************************
  24614. @node GNU Free Documentation License
  24615. @appendix GNU Free Documentation License
  24616. @cindex license, GNU Free Documentation License
  24617. @include fdl-1.3.texi
  24618. @c *********************************************************************
  24619. @node Concept Index
  24620. @unnumbered Concept Index
  24621. @printindex cp
  24622. @node Programming Index
  24623. @unnumbered Programming Index
  24624. @syncodeindex tp fn
  24625. @syncodeindex vr fn
  24626. @printindex fn
  24627. @bye
  24628. @c Local Variables:
  24629. @c ispell-local-dictionary: "american";
  24630. @c End: