guix.texi 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=15145
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER ci.guix.gnu.org
  16. @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER}
  17. @copying
  18. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
  19. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  20. Copyright @copyright{} 2013 Nikita Karetnikov@*
  21. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  22. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  23. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  24. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  25. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 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, 2021 Chris Marusich@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 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, 2020, 2021 Christopher Baines@*
  36. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  37. Copyright @copyright{} 2017, 2018, 2020, 2021 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, 2021 Christopher Lemmer Webber@*
  43. Copyright @copyright{} 2017, 2018, 2019, 2020 Marius Bakke@*
  44. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  45. Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
  46. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Tobias Geerinckx-Rice@*
  47. Copyright @copyright{} 2017 George Clemmer@*
  48. Copyright @copyright{} 2017 Andy Wingo@*
  49. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  50. Copyright @copyright{} 2017 nee@*
  51. Copyright @copyright{} 2018 Rutger Helling@*
  52. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  53. Copyright @copyright{} 2018 Mike Gerwitz@*
  54. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  55. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  56. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  57. Copyright @copyright{} 2018 Laura Lazzati@*
  58. Copyright @copyright{} 2018 Alex Vong@*
  59. Copyright @copyright{} 2019 Josh Holland@*
  60. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  61. Copyright @copyright{} 2019 Ivan Petkov@*
  62. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  63. Copyright @copyright{} 2019 Kyle Andrews@*
  64. Copyright @copyright{} 2019 Alex Griffin@*
  65. Copyright @copyright{} 2019, 2020 Guillaume Le Vaillant@*
  66. Copyright @copyright{} 2020 Leo Prikler@*
  67. Copyright @copyright{} 2019, 2020 Simon Tournier@*
  68. Copyright @copyright{} 2020 Wiktor Żelazny@*
  69. Copyright @copyright{} 2020 Damien Cassou@*
  70. Copyright @copyright{} 2020 Jakub Kądziołka@*
  71. Copyright @copyright{} 2020 Jack Hill@*
  72. Copyright @copyright{} 2020 Naga Malleswari@*
  73. Copyright @copyright{} 2020 Brice Waegeneire@*
  74. Copyright @copyright{} 2020 R Veera Kumar@*
  75. Copyright @copyright{} 2020 Pierre Langlois@*
  76. Copyright @copyright{} 2020 pinoaffe@*
  77. Copyright @copyright{} 2020 André Batista@*
  78. Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
  79. Copyright @copyright{} 2020 raingloom@*
  80. Copyright @copyright{} 2020 Daniel Brooks@*
  81. Copyright @copyright{} 2020 John Soo@*
  82. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  83. Copyright @copyright{} 2020 Edgar Vincent@*
  84. Copyright @copyright{} 2021 Maxime Devos@*
  85. Permission is granted to copy, distribute and/or modify this document
  86. under the terms of the GNU Free Documentation License, Version 1.3 or
  87. any later version published by the Free Software Foundation; with no
  88. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  89. copy of the license is included in the section entitled ``GNU Free
  90. Documentation License''.
  91. @end copying
  92. @dircategory System administration
  93. @direntry
  94. * Guix: (guix). Manage installed software and system configuration.
  95. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  96. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  97. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  98. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  99. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  100. @end direntry
  101. @dircategory Software development
  102. @direntry
  103. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  104. * guix build: (guix)Invoking guix build. Building packages.
  105. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  106. @end direntry
  107. @titlepage
  108. @title GNU Guix Reference Manual
  109. @subtitle Using the GNU Guix Functional Package Manager
  110. @author The GNU Guix Developers
  111. @page
  112. @vskip 0pt plus 1filll
  113. Edition @value{EDITION} @*
  114. @value{UPDATED} @*
  115. @insertcopying
  116. @end titlepage
  117. @contents
  118. @c *********************************************************************
  119. @node Top
  120. @top GNU Guix
  121. This document describes GNU Guix version @value{VERSION}, a functional
  122. package management tool written for the GNU system.
  123. @c TRANSLATORS: You can replace the following paragraph with information on
  124. @c how to join your own translation team and how to report issues with the
  125. @c translation.
  126. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  127. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  128. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  129. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  130. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  131. would like to translate it in your native language, consider joining
  132. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  133. Weblate}.
  134. @menu
  135. * Introduction:: What is Guix about?
  136. * Installation:: Installing Guix.
  137. * System Installation:: Installing the whole operating system.
  138. * Getting Started:: Your first steps.
  139. * Package Management:: Package installation, upgrade, etc.
  140. * Channels:: Customizing the package collection.
  141. * Development:: Guix-aided software development.
  142. * Programming Interface:: Using Guix in Scheme.
  143. * Utilities:: Package management commands.
  144. * System Configuration:: Configuring the operating system.
  145. * Documentation:: Browsing software user manuals.
  146. * Installing Debugging Files:: Feeding the debugger.
  147. * Security Updates:: Deploying security fixes quickly.
  148. * Bootstrapping:: GNU/Linux built from scratch.
  149. * Porting:: Targeting another platform or kernel.
  150. * Contributing:: Your help needed!
  151. * Acknowledgments:: Thanks!
  152. * GNU Free Documentation License:: The license of this manual.
  153. * Concept Index:: Concepts.
  154. * Programming Index:: Data types, functions, and variables.
  155. @detailmenu
  156. --- The Detailed Node Listing ---
  157. Introduction
  158. * Managing Software the Guix Way:: What's special.
  159. * GNU Distribution:: The packages and tools.
  160. Installation
  161. * Binary Installation:: Getting Guix running in no time!
  162. * Requirements:: Software needed to build and run Guix.
  163. * Running the Test Suite:: Testing Guix.
  164. * Setting Up the Daemon:: Preparing the build daemon's environment.
  165. * Invoking guix-daemon:: Running the build daemon.
  166. * Application Setup:: Application-specific setup.
  167. * Upgrading Guix:: Upgrading Guix and its build daemon.
  168. Setting Up the Daemon
  169. * Build Environment Setup:: Preparing the isolated build environment.
  170. * Daemon Offload Setup:: Offloading builds to remote machines.
  171. * SELinux Support:: Using an SELinux policy for the daemon.
  172. System Installation
  173. * Limitations:: What you can expect.
  174. * Hardware Considerations:: Supported hardware.
  175. * USB Stick and DVD Installation:: Preparing the installation medium.
  176. * Preparing for Installation:: Networking, partitioning, etc.
  177. * Guided Graphical Installation:: Easy graphical installation.
  178. * Manual Installation:: Manual installation for wizards.
  179. * After System Installation:: When installation succeeded.
  180. * Installing Guix in a VM:: Guix System playground.
  181. * Building the Installation Image:: How this comes to be.
  182. Manual Installation
  183. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  184. * Proceeding with the Installation:: Installing.
  185. Package Management
  186. * Features:: How Guix will make your life brighter.
  187. * Invoking guix package:: Package installation, removal, etc.
  188. * Substitutes:: Downloading pre-built binaries.
  189. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  190. * Invoking guix gc:: Running the garbage collector.
  191. * Invoking guix pull:: Fetching the latest Guix and distribution.
  192. * Invoking guix time-machine:: Running an older revision of Guix.
  193. * Inferiors:: Interacting with another revision of Guix.
  194. * Invoking guix describe:: Display information about your Guix revision.
  195. * Invoking guix archive:: Exporting and importing store files.
  196. Substitutes
  197. * Official Substitute Server:: One particular source of substitutes.
  198. * Substitute Server Authorization:: How to enable or disable substitutes.
  199. * Getting Substitutes from Other Servers:: Substitute diversity.
  200. * Substitute Authentication:: How Guix verifies substitutes.
  201. * Proxy Settings:: How to get substitutes via proxy.
  202. * Substitution Failure:: What happens when substitution fails.
  203. * On Trusting Binaries:: How can you trust that binary blob?
  204. Channels
  205. * Specifying Additional Channels:: Extending the package collection.
  206. * Using a Custom Guix Channel:: Using a customized Guix.
  207. * Replicating Guix:: Running the @emph{exact same} Guix.
  208. * Channel Authentication:: How Guix verifies what it fetches.
  209. * Channels with Substitutes:: Using channels with available substitutes.
  210. * Creating a Channel:: How to write your custom channel.
  211. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  212. * Declaring Channel Dependencies:: How to depend on other channels.
  213. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  214. * Primary URL:: Distinguishing mirror to original.
  215. * Writing Channel News:: Communicating information to channel's users.
  216. Development
  217. * Invoking guix environment:: Setting up development environments.
  218. * Invoking guix pack:: Creating software bundles.
  219. * The GCC toolchain:: Working with languages supported by GCC.
  220. * Invoking guix git authenticate:: Authenticating Git repositories.
  221. Programming Interface
  222. * Package Modules:: Packages from the programmer's viewpoint.
  223. * Defining Packages:: Defining new packages.
  224. * Defining Package Variants:: Customizing packages.
  225. * Build Systems:: Specifying how packages are built.
  226. * Build Phases:: Phases of the build process of a package.
  227. * Build Utilities:: Helpers for your package definitions and more.
  228. * The Store:: Manipulating the package store.
  229. * Derivations:: Low-level interface to package derivations.
  230. * The Store Monad:: Purely functional interface to the store.
  231. * G-Expressions:: Manipulating build expressions.
  232. * Invoking guix repl:: Programming Guix in Guile.
  233. Defining Packages
  234. * package Reference:: The package data type.
  235. * origin Reference:: The origin data type.
  236. Utilities
  237. * Invoking guix build:: Building packages from the command line.
  238. * Invoking guix edit:: Editing package definitions.
  239. * Invoking guix download:: Downloading a file and printing its hash.
  240. * Invoking guix hash:: Computing the cryptographic hash of a file.
  241. * Invoking guix import:: Importing package definitions.
  242. * Invoking guix refresh:: Updating package definitions.
  243. * Invoking guix lint:: Finding errors in package definitions.
  244. * Invoking guix size:: Profiling disk usage.
  245. * Invoking guix graph:: Visualizing the graph of packages.
  246. * Invoking guix publish:: Sharing substitutes.
  247. * Invoking guix challenge:: Challenging substitute servers.
  248. * Invoking guix copy:: Copying to and from a remote store.
  249. * Invoking guix container:: Process isolation.
  250. * Invoking guix weather:: Assessing substitute availability.
  251. * Invoking guix processes:: Listing client processes.
  252. Invoking @command{guix build}
  253. * Common Build Options:: Build options for most commands.
  254. * Package Transformation Options:: Creating variants of packages.
  255. * Additional Build Options:: Options specific to 'guix build'.
  256. * Debugging Build Failures:: Real life packaging experience.
  257. System Configuration
  258. * Using the Configuration System:: Customizing your GNU system.
  259. * operating-system Reference:: Detail of operating-system declarations.
  260. * File Systems:: Configuring file system mounts.
  261. * Mapped Devices:: Block device extra processing.
  262. * User Accounts:: Specifying user accounts.
  263. * Keyboard Layout:: How the system interprets key strokes.
  264. * Locales:: Language and cultural convention settings.
  265. * Services:: Specifying system services.
  266. * Setuid Programs:: Programs running with root privileges.
  267. * X.509 Certificates:: Authenticating HTTPS servers.
  268. * Name Service Switch:: Configuring libc's name service switch.
  269. * Initial RAM Disk:: Linux-Libre bootstrapping.
  270. * Bootloader Configuration:: Configuring the boot loader.
  271. * Invoking guix system:: Instantiating a system configuration.
  272. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  273. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  274. * Defining Services:: Adding new service definitions.
  275. Services
  276. * Base Services:: Essential system services.
  277. * Scheduled Job Execution:: The mcron service.
  278. * Log Rotation:: The rottlog service.
  279. * Networking Services:: Network setup, SSH daemon, etc.
  280. * Unattended Upgrades:: Automated system upgrades.
  281. * X Window:: Graphical display.
  282. * Printing Services:: Local and remote printer support.
  283. * Desktop Services:: D-Bus and desktop services.
  284. * Sound Services:: ALSA and Pulseaudio services.
  285. * Database Services:: SQL databases, key-value stores, etc.
  286. * Mail Services:: IMAP, POP3, SMTP, and all that.
  287. * Messaging Services:: Messaging services.
  288. * Telephony Services:: Telephony services.
  289. * Monitoring Services:: Monitoring services.
  290. * Kerberos Services:: Kerberos services.
  291. * LDAP Services:: LDAP services.
  292. * Web Services:: Web servers.
  293. * Certificate Services:: TLS certificates via Let's Encrypt.
  294. * DNS Services:: DNS daemons.
  295. * VPN Services:: VPN daemons.
  296. * Network File System:: NFS related services.
  297. * Continuous Integration:: Cuirass and Laminar services.
  298. * Power Management Services:: Extending battery life.
  299. * Audio Services:: The MPD.
  300. * Virtualization Services:: Virtualization services.
  301. * Version Control Services:: Providing remote access to Git repositories.
  302. * Game Services:: Game servers.
  303. * PAM Mount Service:: Service to mount volumes when logging in.
  304. * Guix Services:: Services relating specifically to Guix.
  305. * Linux Services:: Services tied to the Linux kernel.
  306. * Hurd Services:: Services specific for a Hurd System.
  307. * Miscellaneous Services:: Other services.
  308. Defining Services
  309. * Service Composition:: The model for composing services.
  310. * Service Types and Services:: Types and services.
  311. * Service Reference:: API reference.
  312. * Shepherd Services:: A particular type of service.
  313. Installing Debugging Files
  314. * Separate Debug Info:: Installing 'debug' outputs.
  315. * Rebuilding Debug Info:: Building missing debug info.
  316. Bootstrapping
  317. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  318. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  319. @end detailmenu
  320. @end menu
  321. @c *********************************************************************
  322. @node Introduction
  323. @chapter Introduction
  324. @cindex purpose
  325. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  326. using the international phonetic alphabet (IPA).} is a package
  327. management tool for and distribution of the GNU system.
  328. Guix makes it easy for unprivileged
  329. users to install, upgrade, or remove software packages, to roll back to a
  330. previous package set, to build packages from source, and generally
  331. assists with the creation and maintenance of software environments.
  332. @cindex Guix System
  333. @cindex GuixSD, now Guix System
  334. @cindex Guix System Distribution, now Guix System
  335. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  336. complements the available tools without interference (@pxref{Installation}),
  337. or you can use it as a standalone operating system distribution,
  338. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  339. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  340. group everything under the ``Guix'' banner since, after all, Guix System is
  341. readily available through the @command{guix system} command, even if you're
  342. using a different distro underneath!}. @xref{GNU Distribution}.
  343. @menu
  344. * Managing Software the Guix Way:: What's special.
  345. * GNU Distribution:: The packages and tools.
  346. @end menu
  347. @node Managing Software the Guix Way
  348. @section Managing Software the Guix Way
  349. @cindex user interfaces
  350. Guix provides a command-line package management interface
  351. (@pxref{Package Management}), tools to help with software development
  352. (@pxref{Development}), command-line utilities for more advanced usage
  353. (@pxref{Utilities}), as well as Scheme programming interfaces
  354. (@pxref{Programming Interface}).
  355. @cindex build daemon
  356. Its @dfn{build daemon} is responsible for building packages on behalf of
  357. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  358. binaries from authorized sources (@pxref{Substitutes}).
  359. @cindex extensibility of the distribution
  360. @cindex customization, of packages
  361. Guix includes package definitions for many GNU and non-GNU packages, all
  362. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  363. user's computing freedom}. It is @emph{extensible}: users can write
  364. their own package definitions (@pxref{Defining Packages}) and make them
  365. available as independent package modules (@pxref{Package Modules}). It
  366. is also @emph{customizable}: users can @emph{derive} specialized package
  367. definitions from existing ones, including from the command line
  368. (@pxref{Package Transformation Options}).
  369. @cindex functional package management
  370. @cindex isolation
  371. Under the hood, Guix implements the @dfn{functional package management}
  372. discipline pioneered by Nix (@pxref{Acknowledgments}).
  373. In Guix, the package build and installation process is seen
  374. as a @emph{function}, in the mathematical sense. That function takes inputs,
  375. such as build scripts, a compiler, and libraries, and
  376. returns an installed package. As a pure function, its result depends
  377. solely on its inputs---for instance, it cannot refer to software or
  378. scripts that were not explicitly passed as inputs. A build function
  379. always produces the same result when passed a given set of inputs. It
  380. cannot alter the environment of the running system in
  381. any way; for instance, it cannot create, modify, or delete files outside
  382. of its build and installation directories. This is achieved by running
  383. build processes in isolated environments (or @dfn{containers}), where only their
  384. explicit inputs are visible.
  385. @cindex store
  386. The result of package build functions is @dfn{cached} in the file
  387. system, in a special directory called @dfn{the store} (@pxref{The
  388. Store}). Each package is installed in a directory of its own in the
  389. store---by default under @file{/gnu/store}. The directory name contains
  390. a hash of all the inputs used to build that package; thus, changing an
  391. input yields a different directory name.
  392. This approach is the foundation for the salient features of Guix: support
  393. for transactional package upgrade and rollback, per-user installation, and
  394. garbage collection of packages (@pxref{Features}).
  395. @node GNU Distribution
  396. @section GNU Distribution
  397. @cindex Guix System
  398. Guix comes with a distribution of the GNU system consisting entirely of
  399. free software@footnote{The term ``free'' here refers to the
  400. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  401. users of that software}.}. The
  402. distribution can be installed on its own (@pxref{System Installation}),
  403. but it is also possible to install Guix as a package manager on top of
  404. an installed GNU/Linux system (@pxref{Installation}). When we need to
  405. distinguish between the two, we refer to the standalone distribution as
  406. Guix@tie{}System.
  407. The distribution provides core GNU packages such as GNU libc, GCC, and
  408. Binutils, as well as many GNU and non-GNU applications. The complete
  409. list of available packages can be browsed
  410. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  411. running @command{guix package} (@pxref{Invoking guix package}):
  412. @example
  413. guix package --list-available
  414. @end example
  415. Our goal is to provide a practical 100% free software distribution of
  416. Linux-based and other variants of GNU, with a focus on the promotion and
  417. tight integration of GNU components, and an emphasis on programs and
  418. tools that help users exert that freedom.
  419. Packages are currently available on the following platforms:
  420. @table @code
  421. @item x86_64-linux
  422. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  423. @item i686-linux
  424. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  425. @item armhf-linux
  426. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  427. using the EABI hard-float application binary interface (ABI),
  428. and Linux-Libre kernel.
  429. @item aarch64-linux
  430. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  431. @item i586-gnu
  432. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  433. (IA32).
  434. This configuration is experimental and under development. The easiest
  435. way for you to give it a try is by setting up an instance of
  436. @code{hurd-vm-service-type} on your GNU/Linux machine
  437. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  438. @xref{Contributing}, on how to help!
  439. @item mips64el-linux (deprecated)
  440. little-endian 64-bit MIPS processors, specifically the Loongson series,
  441. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  442. supported; in particular, there is no ongoing work to ensure that this
  443. architecture still works. Should someone decide they wish to revive this
  444. architecture then the code is still available.
  445. @item powerpc64le-linux
  446. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  447. includes POWER9 systems such as the
  448. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  449. RYF Talos II mainboard}. This platform is available as a "technology
  450. preview": although it is supported, substitutes are not yet available
  451. from the build farm (@pxref{Substitutes}), and some packages may fail to
  452. build (@pxref{Tracking Bugs and Patches}). That said, the Guix
  453. community is actively working on improving this support, and now is a
  454. great time to try it and get involved!
  455. @end table
  456. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  457. configuration and Guix takes care of instantiating the configuration in a
  458. transactional, reproducible, and stateless fashion (@pxref{System
  459. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  460. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  461. Manual}), the well-known GNU utilities and tool chain, as well as the
  462. graphical environment or system services of your choice.
  463. Guix System is available on all the above platforms except
  464. @code{mips64el-linux} and @code{powerpc64le-linux}.
  465. @noindent
  466. For information on porting to other architectures or kernels,
  467. @pxref{Porting}.
  468. Building this distribution is a cooperative effort, and you are invited
  469. to join! @xref{Contributing}, for information about how you can help.
  470. @c *********************************************************************
  471. @node Installation
  472. @chapter Installation
  473. @cindex installing Guix
  474. @quotation Note
  475. We recommend the use of this
  476. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  477. shell installer script} to install Guix on top of a running GNU/Linux system,
  478. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  479. with the installation of the package manager, which can be done on top of a
  480. running GNU/Linux system. If, instead, you want to install the complete GNU
  481. operating system, @pxref{System Installation}.} The script automates the
  482. download, installation, and initial configuration of Guix. It should be run
  483. as the root user.
  484. @end quotation
  485. @cindex foreign distro
  486. @cindex directories related to foreign distro
  487. When installed on a foreign distro, GNU@tie{}Guix complements the available
  488. tools without interference. Its data lives exclusively in two directories,
  489. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  490. such as @file{/etc}, are left untouched.
  491. Once installed, Guix can be updated by running @command{guix pull}
  492. (@pxref{Invoking guix pull}).
  493. If you prefer to perform the installation steps manually or want to tweak
  494. them, you may find the following subsections useful. They describe the
  495. software requirements of Guix, as well as how to install it manually and get
  496. ready to use it.
  497. @menu
  498. * Binary Installation:: Getting Guix running in no time!
  499. * Requirements:: Software needed to build and run Guix.
  500. * Running the Test Suite:: Testing Guix.
  501. * Setting Up the Daemon:: Preparing the build daemon's environment.
  502. * Invoking guix-daemon:: Running the build daemon.
  503. * Application Setup:: Application-specific setup.
  504. * Upgrading Guix:: Upgrading Guix and its build daemon.
  505. @end menu
  506. @node Binary Installation
  507. @section Binary Installation
  508. @cindex installing Guix from binaries
  509. @cindex installer script
  510. This section describes how to install Guix on an arbitrary system from a
  511. self-contained tarball providing binaries for Guix and for all its
  512. dependencies. This is often quicker than installing from source, which
  513. is described in the next sections. The only requirement is to have
  514. GNU@tie{}tar and Xz.
  515. @c Note duplicated from the ``Installation'' node.
  516. @quotation Note
  517. We recommend the use of this
  518. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  519. shell installer script}. The script automates the download, installation, and
  520. initial configuration steps described below. It should be run as the root
  521. user. As root, you can thus run this:
  522. @example
  523. cd /tmp
  524. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  525. chmod +x guix-install.sh
  526. ./guix-install.sh
  527. @end example
  528. When you're done, @pxref{Application Setup} for extra configuration you
  529. might need, and @ref{Getting Started} for your first steps!
  530. @end quotation
  531. Installing goes along these lines:
  532. @enumerate
  533. @item
  534. @cindex downloading Guix binary
  535. Download the binary tarball from
  536. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  537. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  538. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  539. (@pxref{GNU Distribution}).
  540. @c The following is somewhat duplicated in ``System Installation''.
  541. Make sure to download the associated @file{.sig} file and to verify the
  542. authenticity of the tarball against it, along these lines:
  543. @example
  544. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  545. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  546. @end example
  547. If that command fails because you do not have the required public key,
  548. then run this command to import it:
  549. @example
  550. $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
  551. -qO - | gpg --import -
  552. @end example
  553. @noindent
  554. and rerun the @code{gpg --verify} command.
  555. Take note that a warning like ``This key is not certified with a trusted
  556. signature!'' is normal.
  557. @c end authentication part
  558. @item
  559. Now, you need to become the @code{root} user. Depending on your distribution,
  560. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  561. @example
  562. # cd /tmp
  563. # tar --warning=no-timestamp -xf \
  564. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  565. # mv var/guix /var/ && mv gnu /
  566. @end example
  567. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  568. The latter contains a ready-to-use profile for @code{root} (see next
  569. step).
  570. Do @emph{not} unpack the tarball on a working Guix system since that
  571. would overwrite its own essential files.
  572. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  573. not emit warnings about ``implausibly old time stamps'' (such
  574. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  575. versions are fine).
  576. They stem from the fact that all the
  577. files in the archive have their modification time set to 1 (which
  578. means January 1st, 1970). This is done on purpose to make sure the
  579. archive content is independent of its creation time, thus making it
  580. reproducible.
  581. @item
  582. Make the profile available under @file{~root/.config/guix/current}, which is
  583. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  584. @example
  585. # mkdir -p ~root/.config/guix
  586. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  587. ~root/.config/guix/current
  588. @end example
  589. Source @file{etc/profile} to augment @env{PATH} and other relevant
  590. environment variables:
  591. @example
  592. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  593. source $GUIX_PROFILE/etc/profile
  594. @end example
  595. @item
  596. Create the group and user accounts for build users as explained below
  597. (@pxref{Build Environment Setup}).
  598. @item
  599. Run the daemon, and set it to automatically start on boot.
  600. If your host distro uses the systemd init system, this can be achieved
  601. with these commands:
  602. @c Versions of systemd that supported symlinked service files are not
  603. @c yet widely deployed, so we should suggest that users copy the service
  604. @c files into place.
  605. @c
  606. @c See this thread for more information:
  607. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  608. @example
  609. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  610. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  611. /etc/systemd/system/
  612. # systemctl enable --now gnu-store.mount guix-daemon
  613. @end example
  614. If your host distro uses the Upstart init system:
  615. @example
  616. # initctl reload-configuration
  617. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  618. /etc/init/
  619. # start guix-daemon
  620. @end example
  621. Otherwise, you can still start the daemon manually with:
  622. @example
  623. # ~root/.config/guix/current/bin/guix-daemon \
  624. --build-users-group=guixbuild
  625. @end example
  626. @item
  627. Make the @command{guix} command available to other users on the machine,
  628. for instance with:
  629. @example
  630. # mkdir -p /usr/local/bin
  631. # cd /usr/local/bin
  632. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  633. @end example
  634. It is also a good idea to make the Info version of this manual available
  635. there:
  636. @example
  637. # mkdir -p /usr/local/share/info
  638. # cd /usr/local/share/info
  639. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  640. do ln -s $i ; done
  641. @end example
  642. That way, assuming @file{/usr/local/share/info} is in the search path,
  643. running @command{info guix} will open this manual (@pxref{Other Info
  644. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  645. Info search path).
  646. @item
  647. @cindex substitutes, authorization thereof
  648. To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
  649. (@pxref{Substitutes}), authorize them:
  650. @example
  651. # guix archive --authorize < \
  652. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
  653. @end example
  654. @item
  655. Each user may need to perform a few additional steps to make their Guix
  656. environment ready for use, @pxref{Application Setup}.
  657. @end enumerate
  658. Voilà, the installation is complete!
  659. You can confirm that Guix is working by installing a sample package into
  660. the root profile:
  661. @example
  662. # guix install hello
  663. @end example
  664. The binary installation tarball can be (re)produced and verified simply
  665. by running the following command in the Guix source tree:
  666. @example
  667. make guix-binary.@var{system}.tar.xz
  668. @end example
  669. @noindent
  670. ...@: which, in turn, runs:
  671. @example
  672. guix pack -s @var{system} --localstatedir \
  673. --profile-name=current-guix guix
  674. @end example
  675. @xref{Invoking guix pack}, for more info on this handy tool.
  676. @node Requirements
  677. @section Requirements
  678. This section lists requirements when building Guix from source. The
  679. build procedure for Guix is the same as for other GNU software, and is
  680. not covered here. Please see the files @file{README} and @file{INSTALL}
  681. in the Guix source tree for additional details.
  682. @cindex official website
  683. GNU Guix is available for download from its website at
  684. @url{https://www.gnu.org/software/guix/}.
  685. GNU Guix depends on the following packages:
  686. @itemize
  687. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x or
  688. 2.2.x;
  689. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  690. 0.1.0 or later;
  691. @item
  692. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  693. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  694. Guile,, gnutls-guile, GnuTLS-Guile});
  695. @item
  696. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  697. or later;
  698. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  699. version 0.1.0 or later;
  700. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  701. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  702. @item
  703. @c FIXME: We need the #:fetch-options parameter of 'submodule-update',
  704. @c which appeared in 0.5.0. Change below after string freeze.
  705. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.3.0
  706. or later;
  707. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  708. 4.3.0 or later;
  709. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  710. @end itemize
  711. The following dependencies are optional:
  712. @itemize
  713. @item
  714. @c Note: We need at least 0.13.0 for #:nodelay.
  715. Support for build offloading (@pxref{Daemon Offload Setup}) and
  716. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  717. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  718. version 0.13.0 or later.
  719. @item
  720. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  721. compression and decompression in @command{guix publish} and for
  722. substitutes (@pxref{Invoking guix publish}).
  723. @item
  724. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  725. the @code{crate} importer (@pxref{Invoking guix import}).
  726. @item
  727. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  728. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  729. the ``updaters'' (@pxref{Invoking guix refresh}).
  730. @item
  731. When @url{http://www.bzip.org, libbz2} is available,
  732. @command{guix-daemon} can use it to compress build logs.
  733. @end itemize
  734. Unless @option{--disable-daemon} was passed to @command{configure}, the
  735. following packages are also needed:
  736. @itemize
  737. @item @url{https://gnupg.org/, GNU libgcrypt};
  738. @item @url{https://sqlite.org, SQLite 3};
  739. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  740. C++11 standard.
  741. @end itemize
  742. @cindex state directory
  743. When configuring Guix on a system that already has a Guix installation,
  744. be sure to specify the same state directory as the existing installation
  745. using the @option{--localstatedir} option of the @command{configure}
  746. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  747. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  748. set to the value @file{/var}. The @command{configure} script protects
  749. against unintended misconfiguration of @var{localstatedir} so you do not
  750. inadvertently corrupt your store (@pxref{The Store}).
  751. @node Running the Test Suite
  752. @section Running the Test Suite
  753. @cindex test suite
  754. After a successful @command{configure} and @code{make} run, it is a good
  755. idea to run the test suite. It can help catch issues with the setup or
  756. environment, or bugs in Guix itself---and really, reporting test
  757. failures is a good way to help improve the software. To run the test
  758. suite, type:
  759. @example
  760. make check
  761. @end example
  762. Test cases can run in parallel: you can use the @code{-j} option of
  763. GNU@tie{}make to speed things up. The first run may take a few minutes
  764. on a recent machine; subsequent runs will be faster because the store
  765. that is created for test purposes will already have various things in
  766. cache.
  767. It is also possible to run a subset of the tests by defining the
  768. @code{TESTS} makefile variable as in this example:
  769. @example
  770. make check TESTS="tests/store.scm tests/cpio.scm"
  771. @end example
  772. By default, tests results are displayed at a file level. In order to
  773. see the details of every individual test cases, it is possible to define
  774. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  775. @example
  776. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  777. @end example
  778. The underlying SRFI 64 custom Automake test driver used for the 'check'
  779. test suite (located at @file{build-aux/test-driver.scm}) also allows
  780. selecting which test cases to run at a finer level, via its
  781. @option{--select} and @option{--exclude} options. Here's an example, to
  782. run all the test cases from the @file{tests/packages.scm} test file
  783. whose names start with ``transaction-upgrade-entry'':
  784. @example
  785. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  786. make check TESTS="tests/packages.scm"
  787. @end example
  788. Those wishing to inspect the results of failed tests directly from the
  789. command line can add the @option{--errors-only=yes} option to the
  790. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  791. Automake makefile variable, as in:
  792. @example
  793. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  794. @end example
  795. The @option{--show-duration=yes} option can be used to print the
  796. duration of the individual test cases, when used in combination with
  797. @option{--brief=no}:
  798. @example
  799. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  800. @end example
  801. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  802. information about the Automake Parallel Test Harness.
  803. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  804. @file{test-suite.log} file. Please specify the Guix version being used
  805. as well as version numbers of the dependencies (@pxref{Requirements}) in
  806. your message.
  807. Guix also comes with a whole-system test suite that tests complete
  808. Guix System instances. It can only run on systems where
  809. Guix is already installed, using:
  810. @example
  811. make check-system
  812. @end example
  813. @noindent
  814. or, again, by defining @code{TESTS} to select a subset of tests to run:
  815. @example
  816. make check-system TESTS="basic mcron"
  817. @end example
  818. These system tests are defined in the @code{(gnu tests @dots{})}
  819. modules. They work by running the operating systems under test with
  820. lightweight instrumentation in a virtual machine (VM). They can be
  821. computationally intensive or rather cheap, depending on whether
  822. substitutes are available for their dependencies (@pxref{Substitutes}).
  823. Some of them require a lot of storage space to hold VM images.
  824. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  825. all the details.
  826. @node Setting Up the Daemon
  827. @section Setting Up the Daemon
  828. @cindex daemon
  829. Operations such as building a package or running the garbage collector
  830. are all performed by a specialized process, the @dfn{build daemon}, on
  831. behalf of clients. Only the daemon may access the store and its
  832. associated database. Thus, any operation that manipulates the store
  833. goes through the daemon. For instance, command-line tools such as
  834. @command{guix package} and @command{guix build} communicate with the
  835. daemon (@i{via} remote procedure calls) to instruct it what to do.
  836. The following sections explain how to prepare the build daemon's
  837. environment. See also @ref{Substitutes}, for information on how to allow
  838. the daemon to download pre-built binaries.
  839. @menu
  840. * Build Environment Setup:: Preparing the isolated build environment.
  841. * Daemon Offload Setup:: Offloading builds to remote machines.
  842. * SELinux Support:: Using an SELinux policy for the daemon.
  843. @end menu
  844. @node Build Environment Setup
  845. @subsection Build Environment Setup
  846. @cindex build environment
  847. In a standard multi-user setup, Guix and its daemon---the
  848. @command{guix-daemon} program---are installed by the system
  849. administrator; @file{/gnu/store} is owned by @code{root} and
  850. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  851. Guix tools to build packages or otherwise access the store, and the
  852. daemon will do it on their behalf, ensuring that the store is kept in a
  853. consistent state, and allowing built packages to be shared among users.
  854. @cindex build users
  855. When @command{guix-daemon} runs as @code{root}, you may not want package
  856. build processes themselves to run as @code{root} too, for obvious
  857. security reasons. To avoid that, a special pool of @dfn{build users}
  858. should be created for use by build processes started by the daemon.
  859. These build users need not have a shell and a home directory: they will
  860. just be used when the daemon drops @code{root} privileges in build
  861. processes. Having several such users allows the daemon to launch
  862. distinct build processes under separate UIDs, which guarantees that they
  863. do not interfere with each other---an essential feature since builds are
  864. regarded as pure functions (@pxref{Introduction}).
  865. On a GNU/Linux system, a build user pool may be created like this (using
  866. Bash syntax and the @code{shadow} commands):
  867. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  868. @c for why `-G' is needed.
  869. @example
  870. # groupadd --system guixbuild
  871. # for i in $(seq -w 1 10);
  872. do
  873. useradd -g guixbuild -G guixbuild \
  874. -d /var/empty -s $(which nologin) \
  875. -c "Guix build user $i" --system \
  876. guixbuilder$i;
  877. done
  878. @end example
  879. @noindent
  880. The number of build users determines how many build jobs may run in
  881. parallel, as specified by the @option{--max-jobs} option
  882. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  883. @command{guix system vm} and related commands, you may need to add the
  884. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  885. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  886. (@pxref{Invoking guix system}).
  887. The @code{guix-daemon} program may then be run as @code{root} with the
  888. following command@footnote{If your machine uses the systemd init system,
  889. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  890. file in @file{/etc/systemd/system} will ensure that
  891. @command{guix-daemon} is automatically started. Similarly, if your
  892. machine uses the Upstart init system, drop the
  893. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  894. file in @file{/etc/init}.}:
  895. @example
  896. # guix-daemon --build-users-group=guixbuild
  897. @end example
  898. @cindex chroot
  899. @noindent
  900. This way, the daemon starts build processes in a chroot, under one of
  901. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  902. environment contains nothing but:
  903. @c Keep this list in sync with libstore/build.cc! -----------------------
  904. @itemize
  905. @item
  906. a minimal @code{/dev} directory, created mostly independently from the
  907. host @code{/dev}@footnote{``Mostly'', because while the set of files
  908. that appear in the chroot's @code{/dev} is fixed, most of these files
  909. can only be created if the host has them.};
  910. @item
  911. the @code{/proc} directory; it only shows the processes of the container
  912. since a separate PID name space is used;
  913. @item
  914. @file{/etc/passwd} with an entry for the current user and an entry for
  915. user @file{nobody};
  916. @item
  917. @file{/etc/group} with an entry for the user's group;
  918. @item
  919. @file{/etc/hosts} with an entry that maps @code{localhost} to
  920. @code{127.0.0.1};
  921. @item
  922. a writable @file{/tmp} directory.
  923. @end itemize
  924. You can influence the directory where the daemon stores build trees
  925. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  926. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  927. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  928. This way, the value of @env{TMPDIR} does not leak inside build
  929. environments, which avoids discrepancies in cases where build processes
  930. capture the name of their build tree.
  931. @vindex http_proxy
  932. @vindex https_proxy
  933. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  934. environment variables for HTTP and HTTPS downloads it performs, be it
  935. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  936. (@pxref{Substitutes}).
  937. If you are installing Guix as an unprivileged user, it is still possible
  938. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  939. However, build processes will not be isolated from one another, and not
  940. from the rest of the system. Thus, build processes may interfere with
  941. each other, and may access programs, libraries, and other files
  942. available on the system---making it much harder to view them as
  943. @emph{pure} functions.
  944. @node Daemon Offload Setup
  945. @subsection Using the Offload Facility
  946. @cindex offloading
  947. @cindex build hook
  948. When desired, the build daemon can @dfn{offload} derivation builds to
  949. other machines running Guix, using the @code{offload} @dfn{build
  950. hook}@footnote{This feature is available only when
  951. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  952. present.}. When that feature is enabled, a list of user-specified build
  953. machines is read from @file{/etc/guix/machines.scm}; every time a build
  954. is requested, for instance via @code{guix build}, the daemon attempts to
  955. offload it to one of the machines that satisfy the constraints of the
  956. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  957. A single machine can have multiple system types, either because its
  958. architecture natively supports it, via emulation
  959. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  960. or both. Missing prerequisites for the build are
  961. copied over SSH to the target machine, which then proceeds with the
  962. build; upon success the output(s) of the build are copied back to the
  963. initial machine. The offload facility comes with a basic scheduler that
  964. attempts to select the best machine. The best machine is chosen among
  965. the available machines based on criteria such as:
  966. @enumerate
  967. @item
  968. The availability of a build slot. A build machine can have as many
  969. build slots (connections) as the value of the @code{parallel-builds}
  970. field of its @code{build-machine} object.
  971. @item
  972. Its relative speed, as defined via the @code{speed} field of its
  973. @code{build-machine} object.
  974. @item
  975. Its load. The normalized machine load must be lower than a threshold
  976. value, configurable via the @code{overload-threshold} field of its
  977. @code{build-machine} object.
  978. @item
  979. Disk space availability. More than a 100 MiB must be available.
  980. @end enumerate
  981. The @file{/etc/guix/machines.scm} file typically looks like this:
  982. @lisp
  983. (list (build-machine
  984. (name "eightysix.example.org")
  985. (systems (list "x86_64-linux" "i686-linux"))
  986. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  987. (user "bob")
  988. (speed 2.)) ;incredibly fast!
  989. (build-machine
  990. (name "armeight.example.org")
  991. (systems (list "aarch64-linux"))
  992. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  993. (user "alice")
  994. (private-key
  995. (string-append (getenv "HOME")
  996. "/.ssh/identity-for-guix"))))
  997. @end lisp
  998. @noindent
  999. In the example above we specify a list of two build machines, one for
  1000. the @code{x86_64} and @code{i686} architectures and one for the
  1001. @code{aarch64} architecture.
  1002. In fact, this file is---not surprisingly!---a Scheme file that is
  1003. evaluated when the @code{offload} hook is started. Its return value
  1004. must be a list of @code{build-machine} objects. While this example
  1005. shows a fixed list of build machines, one could imagine, say, using
  1006. DNS-SD to return a list of potential build machines discovered in the
  1007. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1008. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1009. detailed below.
  1010. @deftp {Data Type} build-machine
  1011. This data type represents build machines to which the daemon may offload
  1012. builds. The important fields are:
  1013. @table @code
  1014. @item name
  1015. The host name of the remote machine.
  1016. @item systems
  1017. The system types the remote machine supports---e.g., @code{(list
  1018. "x86_64-linux" "i686-linux")}.
  1019. @item user
  1020. The user account to use when connecting to the remote machine over SSH.
  1021. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1022. allow non-interactive logins.
  1023. @item host-key
  1024. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1025. This is used to authenticate the machine when we connect to it. It is a
  1026. long string that looks like this:
  1027. @example
  1028. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1029. @end example
  1030. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1031. key can be found in a file such as
  1032. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1033. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1034. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1035. similar file. It can be converted to the OpenSSH format using
  1036. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1037. @example
  1038. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1039. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1040. @end example
  1041. @end table
  1042. A number of optional fields may be specified:
  1043. @table @asis
  1044. @item @code{port} (default: @code{22})
  1045. Port number of SSH server on the machine.
  1046. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1047. The SSH private key file to use when connecting to the machine, in
  1048. OpenSSH format. This key must not be protected with a passphrase.
  1049. Note that the default value is the private key @emph{of the root
  1050. account}. Make sure it exists if you use the default.
  1051. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1052. @itemx @code{compression-level} (default: @code{3})
  1053. The SSH-level compression methods and compression level requested.
  1054. Note that offloading relies on SSH compression to reduce bandwidth usage
  1055. when transferring files to and from build machines.
  1056. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1057. File name of the Unix-domain socket @command{guix-daemon} is listening
  1058. to on that machine.
  1059. @item @code{overload-threshold} (default: @code{0.6})
  1060. The load threshold above which a potential offload machine is
  1061. disregarded by the offload scheduler. The value roughly translates to
  1062. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1063. 1.0 (100%). It can also be disabled by setting
  1064. @code{overload-threshold} to @code{#f}.
  1065. @item @code{parallel-builds} (default: @code{1})
  1066. The number of builds that may run in parallel on the machine.
  1067. @item @code{speed} (default: @code{1.0})
  1068. A ``relative speed factor''. The offload scheduler will tend to prefer
  1069. machines with a higher speed factor.
  1070. @item @code{features} (default: @code{'()})
  1071. A list of strings denoting specific features supported by the machine.
  1072. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1073. and corresponding hardware support. Derivations can request features by
  1074. name, and they will be scheduled on matching build machines.
  1075. @end table
  1076. @end deftp
  1077. The @command{guix} command must be in the search path on the build
  1078. machines. You can check whether this is the case by running:
  1079. @example
  1080. ssh build-machine guix repl --version
  1081. @end example
  1082. There is one last thing to do once @file{machines.scm} is in place. As
  1083. explained above, when offloading, files are transferred back and forth
  1084. between the machine stores. For this to work, you first need to
  1085. generate a key pair on each machine to allow the daemon to export signed
  1086. archives of files from the store (@pxref{Invoking guix archive}):
  1087. @example
  1088. # guix archive --generate-key
  1089. @end example
  1090. @noindent
  1091. Each build machine must authorize the key of the master machine so that
  1092. it accepts store items it receives from the master:
  1093. @example
  1094. # guix archive --authorize < master-public-key.txt
  1095. @end example
  1096. @noindent
  1097. Likewise, the master machine must authorize the key of each build machine.
  1098. All the fuss with keys is here to express pairwise mutual trust
  1099. relations between the master and the build machines. Concretely, when
  1100. the master receives files from a build machine (and @i{vice versa}), its
  1101. build daemon can make sure they are genuine, have not been tampered
  1102. with, and that they are signed by an authorized key.
  1103. @cindex offload test
  1104. To test whether your setup is operational, run this command on the
  1105. master node:
  1106. @example
  1107. # guix offload test
  1108. @end example
  1109. This will attempt to connect to each of the build machines specified in
  1110. @file{/etc/guix/machines.scm}, make sure Guix is
  1111. available on each machine, attempt to export to the machine and import
  1112. from it, and report any error in the process.
  1113. If you want to test a different machine file, just specify it on the
  1114. command line:
  1115. @example
  1116. # guix offload test machines-qualif.scm
  1117. @end example
  1118. Last, you can test the subset of the machines whose name matches a
  1119. regular expression like this:
  1120. @example
  1121. # guix offload test machines.scm '\.gnu\.org$'
  1122. @end example
  1123. @cindex offload status
  1124. To display the current load of all build hosts, run this command on the
  1125. main node:
  1126. @example
  1127. # guix offload status
  1128. @end example
  1129. @node SELinux Support
  1130. @subsection SELinux Support
  1131. @cindex SELinux, daemon policy
  1132. @cindex mandatory access control, SELinux
  1133. @cindex security, guix-daemon
  1134. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1135. can be installed on a system where SELinux is enabled, in order to label
  1136. Guix files and to specify the expected behavior of the daemon. Since
  1137. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1138. be used on Guix System.
  1139. @subsubsection Installing the SELinux policy
  1140. @cindex SELinux, policy installation
  1141. To install the policy run this command as root:
  1142. @example
  1143. semodule -i etc/guix-daemon.cil
  1144. @end example
  1145. Then relabel the file system with @code{restorecon} or by a different
  1146. mechanism provided by your system.
  1147. Once the policy is installed, the file system has been relabeled, and
  1148. the daemon has been restarted, it should be running in the
  1149. @code{guix_daemon_t} context. You can confirm this with the following
  1150. command:
  1151. @example
  1152. ps -Zax | grep guix-daemon
  1153. @end example
  1154. Monitor the SELinux log files as you run a command like @code{guix build
  1155. hello} to convince yourself that SELinux permits all necessary
  1156. operations.
  1157. @subsubsection Limitations
  1158. @cindex SELinux, limitations
  1159. This policy is not perfect. Here is a list of limitations or quirks
  1160. that should be considered when deploying the provided SELinux policy for
  1161. the Guix daemon.
  1162. @enumerate
  1163. @item
  1164. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1165. operations involve contexts that have anything to do with
  1166. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1167. but it would be preferable to define socket rules for only this label.
  1168. @item
  1169. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1170. the file label of the destination of a symlink is independent of the
  1171. file label of the link itself. Although all profiles under
  1172. $localstatedir are labelled, the links to these profiles inherit the
  1173. label of the directory they are in. For links in the user’s home
  1174. directory this will be @code{user_home_t}. But for links from the root
  1175. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1176. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1177. reading and following these links.
  1178. @item
  1179. The daemon’s feature to listen for TCP connections might no longer work.
  1180. This might require extra rules, because SELinux treats network sockets
  1181. differently from files.
  1182. @item
  1183. Currently all files with a name matching the regular expression
  1184. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1185. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1186. that name in any profile would be permitted to run in the
  1187. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1188. build a package that provides this executable and convince a user to
  1189. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1190. At that point SELinux could not prevent it from accessing files that are
  1191. allowed for processes in that domain.
  1192. You will need to relabel the store directory after all upgrades to
  1193. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1194. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1195. or by other means provided by your operating system.
  1196. We could generate a much more restrictive policy at installation time,
  1197. so that only the @emph{exact} file name of the currently installed
  1198. @code{guix-daemon} executable would be labelled with
  1199. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1200. The downside is that root would have to install or upgrade the policy at
  1201. installation time whenever the Guix package that provides the
  1202. effectively running @code{guix-daemon} executable is upgraded.
  1203. @end enumerate
  1204. @node Invoking guix-daemon
  1205. @section Invoking @command{guix-daemon}
  1206. The @command{guix-daemon} program implements all the functionality to
  1207. access the store. This includes launching build processes, running the
  1208. garbage collector, querying the availability of a build result, etc. It
  1209. is normally run as @code{root} like this:
  1210. @example
  1211. # guix-daemon --build-users-group=guixbuild
  1212. @end example
  1213. @noindent
  1214. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1215. @cindex chroot
  1216. @cindex container, build environment
  1217. @cindex build environment
  1218. @cindex reproducible builds
  1219. By default, @command{guix-daemon} launches build processes under
  1220. different UIDs, taken from the build group specified with
  1221. @option{--build-users-group}. In addition, each build process is run in a
  1222. chroot environment that only contains the subset of the store that the
  1223. build process depends on, as specified by its derivation
  1224. (@pxref{Programming Interface, derivation}), plus a set of specific
  1225. system directories. By default, the latter contains @file{/dev} and
  1226. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1227. @dfn{container}: in addition to having its own file system tree, it has
  1228. a separate mount name space, its own PID name space, network name space,
  1229. etc. This helps achieve reproducible builds (@pxref{Features}).
  1230. When the daemon performs a build on behalf of the user, it creates a
  1231. build directory under @file{/tmp} or under the directory specified by
  1232. its @env{TMPDIR} environment variable. This directory is shared with
  1233. the container for the duration of the build, though within the container,
  1234. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1235. The build directory is automatically deleted upon completion, unless the
  1236. build failed and the client specified @option{--keep-failed}
  1237. (@pxref{Common Build Options, @option{--keep-failed}}).
  1238. The daemon listens for connections and spawns one sub-process for each session
  1239. started by a client (one of the @command{guix} sub-commands). The
  1240. @command{guix processes} command allows you to get an overview of the activity
  1241. on your system by viewing each of the active sessions and clients.
  1242. @xref{Invoking guix processes}, for more information.
  1243. The following command-line options are supported:
  1244. @table @code
  1245. @item --build-users-group=@var{group}
  1246. Take users from @var{group} to run build processes (@pxref{Setting Up
  1247. the Daemon, build users}).
  1248. @item --no-substitutes
  1249. @cindex substitutes
  1250. Do not use substitutes for build products. That is, always build things
  1251. locally instead of allowing downloads of pre-built binaries
  1252. (@pxref{Substitutes}).
  1253. When the daemon runs with @option{--no-substitutes}, clients can still
  1254. explicitly enable substitution @i{via} the @code{set-build-options}
  1255. remote procedure call (@pxref{The Store}).
  1256. @anchor{daemon-substitute-urls}
  1257. @item --substitute-urls=@var{urls}
  1258. Consider @var{urls} the default whitespace-separated list of substitute
  1259. source URLs. When this option is omitted,
  1260. @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
  1261. This means that substitutes may be downloaded from @var{urls}, as long
  1262. as they are signed by a trusted signature (@pxref{Substitutes}).
  1263. @xref{Getting Substitutes from Other Servers}, for more information on
  1264. how to configure the daemon to get substitutes from other servers.
  1265. @cindex offloading
  1266. @item --no-offload
  1267. Do not use offload builds to other machines (@pxref{Daemon Offload
  1268. Setup}). That is, always build things locally instead of offloading
  1269. builds to remote machines.
  1270. @item --cache-failures
  1271. Cache build failures. By default, only successful builds are cached.
  1272. When this option is used, @command{guix gc --list-failures} can be used
  1273. to query the set of store items marked as failed; @command{guix gc
  1274. --clear-failures} removes store items from the set of cached failures.
  1275. @xref{Invoking guix gc}.
  1276. @item --cores=@var{n}
  1277. @itemx -c @var{n}
  1278. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1279. as available.
  1280. The default value is @code{0}, but it may be overridden by clients, such
  1281. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1282. guix build}).
  1283. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1284. in the build process, which can then use it to exploit internal
  1285. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1286. @item --max-jobs=@var{n}
  1287. @itemx -M @var{n}
  1288. Allow at most @var{n} build jobs in parallel. The default value is
  1289. @code{1}. Setting it to @code{0} means that no builds will be performed
  1290. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1291. Setup}), or simply fail.
  1292. @item --max-silent-time=@var{seconds}
  1293. When the build or substitution process remains silent for more than
  1294. @var{seconds}, terminate it and report a build failure.
  1295. The default value is @code{0}, which disables the timeout.
  1296. The value specified here can be overridden by clients (@pxref{Common
  1297. Build Options, @option{--max-silent-time}}).
  1298. @item --timeout=@var{seconds}
  1299. Likewise, when the build or substitution process lasts for more than
  1300. @var{seconds}, terminate it and report a build failure.
  1301. The default value is @code{0}, which disables the timeout.
  1302. The value specified here can be overridden by clients (@pxref{Common
  1303. Build Options, @option{--timeout}}).
  1304. @item --rounds=@var{N}
  1305. Build each derivation @var{n} times in a row, and raise an error if
  1306. consecutive build results are not bit-for-bit identical. Note that this
  1307. setting can be overridden by clients such as @command{guix build}
  1308. (@pxref{Invoking guix build}).
  1309. When used in conjunction with @option{--keep-failed}, the differing
  1310. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1311. This makes it easy to look for differences between the two results.
  1312. @item --debug
  1313. Produce debugging output.
  1314. This is useful to debug daemon start-up issues, but then it may be
  1315. overridden by clients, for example the @option{--verbosity} option of
  1316. @command{guix build} (@pxref{Invoking guix build}).
  1317. @item --chroot-directory=@var{dir}
  1318. Add @var{dir} to the build chroot.
  1319. Doing this may change the result of build processes---for instance if
  1320. they use optional dependencies found in @var{dir} when it is available,
  1321. and not otherwise. For that reason, it is not recommended to do so.
  1322. Instead, make sure that each derivation declares all the inputs that it
  1323. needs.
  1324. @item --disable-chroot
  1325. Disable chroot builds.
  1326. Using this option is not recommended since, again, it would allow build
  1327. processes to gain access to undeclared dependencies. It is necessary,
  1328. though, when @command{guix-daemon} is running under an unprivileged user
  1329. account.
  1330. @item --log-compression=@var{type}
  1331. Compress build logs according to @var{type}, one of @code{gzip},
  1332. @code{bzip2}, or @code{none}.
  1333. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1334. @var{localstatedir}. To save space, the daemon automatically compresses
  1335. them with Bzip2 by default.
  1336. @item --discover[=yes|no]
  1337. Whether to discover substitute servers on the local network using mDNS
  1338. and DNS-SD.
  1339. This feature is still experimental. However, here are a few
  1340. considerations.
  1341. @enumerate
  1342. @item
  1343. It might be faster/less expensive than fetching from remote servers;
  1344. @item
  1345. There are no security risks, only genuine substitutes will be used
  1346. (@pxref{Substitute Authentication});
  1347. @item
  1348. An attacker advertising @command{guix publish} on your LAN cannot serve
  1349. you malicious binaries, but they can learn what software you’re
  1350. installing;
  1351. @item
  1352. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1353. LAN can see what software you’re installing.
  1354. @end enumerate
  1355. It is also possible to enable or disable substitute server discovery at
  1356. run-time by running:
  1357. @example
  1358. herd discover guix-daemon on
  1359. herd discover guix-daemon off
  1360. @end example
  1361. @item --disable-deduplication
  1362. @cindex deduplication
  1363. Disable automatic file ``deduplication'' in the store.
  1364. By default, files added to the store are automatically ``deduplicated'':
  1365. if a newly added file is identical to another one found in the store,
  1366. the daemon makes the new file a hard link to the other file. This can
  1367. noticeably reduce disk usage, at the expense of slightly increased
  1368. input/output load at the end of a build process. This option disables
  1369. this optimization.
  1370. @item --gc-keep-outputs[=yes|no]
  1371. Tell whether the garbage collector (GC) must keep outputs of live
  1372. derivations.
  1373. @cindex GC roots
  1374. @cindex garbage collector roots
  1375. When set to @code{yes}, the GC will keep the outputs of any live
  1376. derivation available in the store---the @file{.drv} files. The default
  1377. is @code{no}, meaning that derivation outputs are kept only if they are
  1378. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1379. roots.
  1380. @item --gc-keep-derivations[=yes|no]
  1381. Tell whether the garbage collector (GC) must keep derivations
  1382. corresponding to live outputs.
  1383. When set to @code{yes}, as is the case by default, the GC keeps
  1384. derivations---i.e., @file{.drv} files---as long as at least one of their
  1385. outputs is live. This allows users to keep track of the origins of
  1386. items in their store. Setting it to @code{no} saves a bit of disk
  1387. space.
  1388. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1389. liveness to flow from outputs to derivations, and setting
  1390. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1391. derivations to outputs. When both are set to @code{yes}, the effect is
  1392. to keep all the build prerequisites (the sources, compiler, libraries,
  1393. and other build-time tools) of live objects in the store, regardless of
  1394. whether these prerequisites are reachable from a GC root. This is
  1395. convenient for developers since it saves rebuilds or downloads.
  1396. @item --impersonate-linux-2.6
  1397. On Linux-based systems, impersonate Linux 2.6. This means that the
  1398. kernel's @command{uname} system call will report 2.6 as the release number.
  1399. This might be helpful to build programs that (usually wrongfully) depend
  1400. on the kernel version number.
  1401. @item --lose-logs
  1402. Do not keep build logs. By default they are kept under
  1403. @file{@var{localstatedir}/guix/log}.
  1404. @item --system=@var{system}
  1405. Assume @var{system} as the current system type. By default it is the
  1406. architecture/kernel pair found at configure time, such as
  1407. @code{x86_64-linux}.
  1408. @item --listen=@var{endpoint}
  1409. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1410. as the file name of a Unix-domain socket if it starts with
  1411. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1412. host name or host name and port to listen to. Here are a few examples:
  1413. @table @code
  1414. @item --listen=/gnu/var/daemon
  1415. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1416. creating it if needed.
  1417. @item --listen=localhost
  1418. @cindex daemon, remote access
  1419. @cindex remote access to the daemon
  1420. @cindex daemon, cluster setup
  1421. @cindex clusters, daemon setup
  1422. Listen for TCP connections on the network interface corresponding to
  1423. @code{localhost}, on port 44146.
  1424. @item --listen=128.0.0.42:1234
  1425. Listen for TCP connections on the network interface corresponding to
  1426. @code{128.0.0.42}, on port 1234.
  1427. @end table
  1428. This option can be repeated multiple times, in which case
  1429. @command{guix-daemon} accepts connections on all the specified
  1430. endpoints. Users can tell client commands what endpoint to connect to
  1431. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1432. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1433. @quotation Note
  1434. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1435. @option{--listen=@var{host}} is suitable on local networks, such as
  1436. clusters, where only trusted nodes may connect to the build daemon. In
  1437. other cases where remote access to the daemon is needed, we recommend
  1438. using Unix-domain sockets along with SSH.
  1439. @end quotation
  1440. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1441. connections on the Unix-domain socket located at
  1442. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1443. @end table
  1444. @node Application Setup
  1445. @section Application Setup
  1446. @cindex foreign distro
  1447. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1448. so-called @dfn{foreign distro}---a few additional steps are needed to
  1449. get everything in place. Here are some of them.
  1450. @subsection Locales
  1451. @anchor{locales-and-locpath}
  1452. @cindex locales, when not on Guix System
  1453. @vindex LOCPATH
  1454. @vindex GUIX_LOCPATH
  1455. Packages installed @i{via} Guix will not use the locale data of the
  1456. host system. Instead, you must first install one of the locale packages
  1457. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1458. variable:
  1459. @example
  1460. $ guix install glibc-locales
  1461. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1462. @end example
  1463. Note that the @code{glibc-locales} package contains data for all the
  1464. locales supported by the GNU@tie{}libc and weighs in at around
  1465. 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1466. limited to a few UTF-8 locales.
  1467. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1468. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1469. Manual}). There are two important differences though:
  1470. @enumerate
  1471. @item
  1472. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1473. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1474. to make sure the programs of the foreign distro will not end up loading
  1475. incompatible locale data.
  1476. @item
  1477. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1478. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1479. should your Guix profile contain a mixture of programs linked against
  1480. different libc version, each libc version will only try to load locale
  1481. data in the right format.
  1482. @end enumerate
  1483. This is important because the locale data format used by different libc
  1484. versions may be incompatible.
  1485. @subsection Name Service Switch
  1486. @cindex name service switch, glibc
  1487. @cindex NSS (name service switch), glibc
  1488. @cindex nscd (name service caching daemon)
  1489. @cindex name service caching daemon (nscd)
  1490. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1491. the system run the GNU C library's @dfn{name service cache daemon},
  1492. @command{nscd}, which should be listening on the
  1493. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1494. installed with Guix may fail to look up host names or user accounts, or
  1495. may even crash. The next paragraphs explain why.
  1496. @cindex @file{nsswitch.conf}
  1497. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1498. an extensible mechanism for ``name lookups'' in general: host name
  1499. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1500. The GNU C Library Reference Manual}).
  1501. @cindex Network information service (NIS)
  1502. @cindex NIS (Network information service)
  1503. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1504. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1505. resolution of @code{.local} host names, the @code{nis} plugin allows
  1506. user account lookup using the Network information service (NIS), and so
  1507. on. These extra ``lookup services'' are configured system-wide in
  1508. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1509. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1510. Reference Manual}).
  1511. When they perform a name lookup---for instance by calling the
  1512. @code{getaddrinfo} function in C---applications first try to connect to
  1513. the nscd; on success, nscd performs name lookups on their behalf. If
  1514. the nscd is not running, then they perform the name lookup by
  1515. themselves, by loading the name lookup services into their own address
  1516. space and running it. These name lookup services---the
  1517. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1518. the host system's C library, rather than from the C library the
  1519. application is linked against (the C library coming from Guix).
  1520. And this is where the problem is: if your application is linked against
  1521. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1522. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1523. likely crash or have its name lookups fail unexpectedly.
  1524. Running @command{nscd} on the system, among other advantages, eliminates
  1525. this binary incompatibility problem because those @code{libnss_*.so}
  1526. files are loaded in the @command{nscd} process, not in applications
  1527. themselves.
  1528. @subsection X11 Fonts
  1529. @cindex fonts
  1530. The majority of graphical applications use Fontconfig to locate and
  1531. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1532. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1533. by default. Thus, to allow graphical applications installed with Guix
  1534. to display fonts, you have to install fonts with Guix as well.
  1535. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1536. @code{font-gnu-freefont}.
  1537. @cindex @code{fc-cache}
  1538. @cindex font cache
  1539. Once you have installed or removed fonts, or when you notice an
  1540. application that does not find fonts, you may need to install Fontconfig
  1541. and to force an update of its font cache by running:
  1542. @example
  1543. guix install fontconfig
  1544. fc-cache -rv
  1545. @end example
  1546. To display text written in Chinese languages, Japanese, or Korean in
  1547. graphical applications, consider installing
  1548. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1549. has multiple outputs, one per language family (@pxref{Packages with
  1550. Multiple Outputs}). For instance, the following command installs fonts
  1551. for Chinese languages:
  1552. @example
  1553. guix install font-adobe-source-han-sans:cn
  1554. @end example
  1555. @cindex @code{xterm}
  1556. Older programs such as @command{xterm} do not use Fontconfig and instead
  1557. rely on server-side font rendering. Such programs require to specify a
  1558. full name of a font using XLFD (X Logical Font Description), like this:
  1559. @example
  1560. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1561. @end example
  1562. To be able to use such full names for the TrueType fonts installed in
  1563. your Guix profile, you need to extend the font path of the X server:
  1564. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1565. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1566. @example
  1567. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1568. @end example
  1569. @cindex @code{xlsfonts}
  1570. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1571. to make sure your TrueType fonts are listed there.
  1572. @subsection X.509 Certificates
  1573. @cindex @code{nss-certs}
  1574. The @code{nss-certs} package provides X.509 certificates, which allow
  1575. programs to authenticate Web servers accessed over HTTPS.
  1576. When using Guix on a foreign distro, you can install this package and
  1577. define the relevant environment variables so that packages know where to
  1578. look for certificates. @xref{X.509 Certificates}, for detailed
  1579. information.
  1580. @subsection Emacs Packages
  1581. @cindex @code{emacs}
  1582. When you install Emacs packages with Guix, the Elisp files are placed
  1583. under the @file{share/emacs/site-lisp/} directory of the profile in
  1584. which they are installed. The Elisp libraries are made available to
  1585. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1586. set when installing Emacs itself.
  1587. Additionally, autoload definitions are automatically evaluated at the
  1588. initialization of Emacs, by the Guix-specific
  1589. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1590. want to avoid auto-loading the Emacs packages installed with Guix, you
  1591. can do so by running Emacs with the @option{--no-site-file} option
  1592. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1593. @node Upgrading Guix
  1594. @section Upgrading Guix
  1595. @cindex Upgrading Guix, on a foreign distro
  1596. To upgrade Guix, run:
  1597. @example
  1598. guix pull
  1599. @end example
  1600. @xref{Invoking guix pull}, for more information.
  1601. @cindex upgrading Guix for the root user, on a foreign distro
  1602. @cindex upgrading the Guix daemon, on a foreign distro
  1603. @cindex @command{guix pull} for the root user, on a foreign distro
  1604. On a foreign distro, you can upgrade the build daemon by running:
  1605. @example
  1606. sudo -i guix pull
  1607. @end example
  1608. @noindent
  1609. followed by (assuming your distro uses the systemd service management
  1610. tool):
  1611. @example
  1612. systemctl restart guix-daemon.service
  1613. @end example
  1614. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1615. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1616. @c TODO What else?
  1617. @c *********************************************************************
  1618. @node System Installation
  1619. @chapter System Installation
  1620. @cindex installing Guix System
  1621. @cindex Guix System, installation
  1622. This section explains how to install Guix System
  1623. on a machine. Guix, as a package manager, can
  1624. also be installed on top of a running GNU/Linux system,
  1625. @pxref{Installation}.
  1626. @ifinfo
  1627. @quotation Note
  1628. @c This paragraph is for people reading this from tty2 of the
  1629. @c installation image.
  1630. You are reading this documentation with an Info reader. For details on
  1631. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1632. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1633. Info}. Hit @kbd{l} afterwards to come back here.
  1634. Alternatively, run @command{info info} in another tty to keep the manual
  1635. available.
  1636. @end quotation
  1637. @end ifinfo
  1638. @menu
  1639. * Limitations:: What you can expect.
  1640. * Hardware Considerations:: Supported hardware.
  1641. * USB Stick and DVD Installation:: Preparing the installation medium.
  1642. * Preparing for Installation:: Networking, partitioning, etc.
  1643. * Guided Graphical Installation:: Easy graphical installation.
  1644. * Manual Installation:: Manual installation for wizards.
  1645. * After System Installation:: When installation succeeded.
  1646. * Installing Guix in a VM:: Guix System playground.
  1647. * Building the Installation Image:: How this comes to be.
  1648. @end menu
  1649. @node Limitations
  1650. @section Limitations
  1651. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1652. use cases. The reliability guarantees it provides---transactional upgrades
  1653. and rollbacks, reproducibility---make it a solid foundation.
  1654. Nevertheless, before you proceed with the installation, be aware of the
  1655. following noteworthy limitations applicable to version @value{VERSION}:
  1656. @itemize
  1657. @item
  1658. More and more system services are provided (@pxref{Services}), but some
  1659. may be missing.
  1660. @item
  1661. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1662. as well as a number of X11 window managers. However, KDE is currently
  1663. missing.
  1664. @end itemize
  1665. More than a disclaimer, this is an invitation to report issues (and success
  1666. stories!), and to join us in improving it. @xref{Contributing}, for more
  1667. info.
  1668. @node Hardware Considerations
  1669. @section Hardware Considerations
  1670. @cindex hardware support on Guix System
  1671. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1672. builds around the kernel Linux-libre, which means that only hardware for
  1673. which free software drivers and firmware exist is supported. Nowadays,
  1674. a wide range of off-the-shelf hardware is supported on
  1675. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1676. Ethernet controllers. Unfortunately, there are still areas where
  1677. hardware vendors deny users control over their own computing, and such
  1678. hardware is not supported on Guix System.
  1679. @cindex WiFi, hardware support
  1680. One of the main areas where free drivers or firmware are lacking is WiFi
  1681. devices. WiFi devices known to work include those using Atheros chips
  1682. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1683. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1684. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1685. Linux-libre driver. Free firmware exists for both and is available
  1686. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1687. (@pxref{operating-system Reference, @code{firmware}}).
  1688. @cindex RYF, Respects Your Freedom
  1689. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1690. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1691. certification program for hardware products that respect your freedom
  1692. and your privacy and ensure that you have control over your device. We
  1693. encourage you to check the list of RYF-certified devices.
  1694. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1695. web site. It contains a catalog of hardware devices with information
  1696. about their support in GNU/Linux.
  1697. @node USB Stick and DVD Installation
  1698. @section USB Stick and DVD Installation
  1699. An ISO-9660 installation image that can be written to a USB stick or
  1700. burnt to a DVD can be downloaded from
  1701. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz},
  1702. where you can replace @code{x86_64-linux} with one of:
  1703. @table @code
  1704. @item x86_64-linux
  1705. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1706. @item i686-linux
  1707. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1708. @end table
  1709. @c start duplication of authentication part from ``Binary Installation''
  1710. Make sure to download the associated @file{.sig} file and to verify the
  1711. authenticity of the image against it, along these lines:
  1712. @example
  1713. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1714. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1715. @end example
  1716. If that command fails because you do not have the required public key,
  1717. then run this command to import it:
  1718. @example
  1719. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1720. -qO - | gpg --import -
  1721. @end example
  1722. @noindent
  1723. and rerun the @code{gpg --verify} command.
  1724. Take note that a warning like ``This key is not certified with a trusted
  1725. signature!'' is normal.
  1726. @c end duplication
  1727. This image contains the tools necessary for an installation.
  1728. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1729. @unnumberedsubsec Copying to a USB Stick
  1730. To copy the image to a USB stick, follow these steps:
  1731. @enumerate
  1732. @item
  1733. Decompress the image using the @command{xz} command:
  1734. @example
  1735. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1736. @end example
  1737. @item
  1738. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1739. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1740. copy the image with:
  1741. @example
  1742. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1743. sync
  1744. @end example
  1745. Access to @file{/dev/sdX} usually requires root privileges.
  1746. @end enumerate
  1747. @unnumberedsubsec Burning on a DVD
  1748. To copy the image to a DVD, follow these steps:
  1749. @enumerate
  1750. @item
  1751. Decompress the image using the @command{xz} command:
  1752. @example
  1753. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1754. @end example
  1755. @item
  1756. Insert a blank DVD into your machine, and determine
  1757. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1758. copy the image with:
  1759. @example
  1760. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1761. @end example
  1762. Access to @file{/dev/srX} usually requires root privileges.
  1763. @end enumerate
  1764. @unnumberedsubsec Booting
  1765. Once this is done, you should be able to reboot the system and boot from
  1766. the USB stick or DVD@. The latter usually requires you to get in the
  1767. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1768. In order to boot from Libreboot, switch to the command mode by pressing
  1769. the @kbd{c} key and type @command{search_grub usb}.
  1770. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1771. Guix System in a virtual machine (VM).
  1772. @node Preparing for Installation
  1773. @section Preparing for Installation
  1774. Once you have booted, you can use the guided graphical installer, which makes
  1775. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1776. if you are already familiar with GNU/Linux and if you want more control than
  1777. what the graphical installer provides, you can choose the ``manual''
  1778. installation process (@pxref{Manual Installation}).
  1779. The graphical installer is available on TTY1. You can obtain root shells on
  1780. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1781. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1782. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1783. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1784. which allows you to select text with the left mouse button and to paste it
  1785. with the middle button.
  1786. @quotation Note
  1787. Installation requires access to the Internet so that any missing
  1788. dependencies of your system configuration can be downloaded. See the
  1789. ``Networking'' section below.
  1790. @end quotation
  1791. @node Guided Graphical Installation
  1792. @section Guided Graphical Installation
  1793. The graphical installer is a text-based user interface. It will guide you,
  1794. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1795. The first dialog boxes allow you to set up the system as you use it during the
  1796. installation: you can choose the language, keyboard layout, and set up
  1797. networking, which will be used during the installation. The image below shows
  1798. the networking dialog.
  1799. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1800. Later steps allow you to partition your hard disk, as shown in the image
  1801. below, to choose whether or not to use encrypted file systems, to enter the
  1802. host name and root password, and to create an additional account, among other
  1803. things.
  1804. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1805. Note that, at any time, the installer allows you to exit the current
  1806. installation step and resume at a previous step, as show in the image below.
  1807. @image{images/installer-resume,5in,, resuming the installation process}
  1808. Once you're done, the installer produces an operating system configuration and
  1809. displays it (@pxref{Using the Configuration System}). At that point you can
  1810. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1811. new system and enjoy. @xref{After System Installation}, for what's next!
  1812. @node Manual Installation
  1813. @section Manual Installation
  1814. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1815. on your machine. This option requires familiarity with GNU/Linux, with the
  1816. shell, and with common administration tools. If you think this is not for
  1817. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1818. Installation}).
  1819. The installation system provides root shells on TTYs 3 to 6; press
  1820. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1821. many common tools needed to install the system. But it is also a full-blown
  1822. Guix System, which means that you can install additional packages, should you
  1823. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1824. @menu
  1825. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1826. * Proceeding with the Installation:: Installing.
  1827. @end menu
  1828. @node Keyboard Layout and Networking and Partitioning
  1829. @subsection Keyboard Layout, Networking, and Partitioning
  1830. Before you can install the system, you may want to adjust the keyboard layout,
  1831. set up networking, and partition your target hard disk. This section will
  1832. guide you through this.
  1833. @subsubsection Keyboard Layout
  1834. @cindex keyboard layout
  1835. The installation image uses the US qwerty keyboard layout. If you want
  1836. to change it, you can use the @command{loadkeys} command. For example,
  1837. the following command selects the Dvorak keyboard layout:
  1838. @example
  1839. loadkeys dvorak
  1840. @end example
  1841. See the files under @file{/run/current-system/profile/share/keymaps} for
  1842. a list of available keyboard layouts. Run @command{man loadkeys} for
  1843. more information.
  1844. @subsubsection Networking
  1845. Run the following command to see what your network interfaces are called:
  1846. @example
  1847. ifconfig -a
  1848. @end example
  1849. @noindent
  1850. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1851. @example
  1852. ip address
  1853. @end example
  1854. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1855. Wired interfaces have a name starting with @samp{e}; for example, the
  1856. interface corresponding to the first on-board Ethernet controller is
  1857. called @samp{eno1}. Wireless interfaces have a name starting with
  1858. @samp{w}, like @samp{w1p2s0}.
  1859. @table @asis
  1860. @item Wired connection
  1861. To configure a wired network run the following command, substituting
  1862. @var{interface} with the name of the wired interface you want to use.
  1863. @example
  1864. ifconfig @var{interface} up
  1865. @end example
  1866. @noindent
  1867. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1868. @example
  1869. ip link set @var{interface} up
  1870. @end example
  1871. @item Wireless connection
  1872. @cindex wireless
  1873. @cindex WiFi
  1874. To configure wireless networking, you can create a configuration file
  1875. for the @command{wpa_supplicant} configuration tool (its location is not
  1876. important) using one of the available text editors such as
  1877. @command{nano}:
  1878. @example
  1879. nano wpa_supplicant.conf
  1880. @end example
  1881. As an example, the following stanza can go to this file and will work
  1882. for many wireless networks, provided you give the actual SSID and
  1883. passphrase for the network you are connecting to:
  1884. @example
  1885. network=@{
  1886. ssid="@var{my-ssid}"
  1887. key_mgmt=WPA-PSK
  1888. psk="the network's secret passphrase"
  1889. @}
  1890. @end example
  1891. Start the wireless service and run it in the background with the
  1892. following command (substitute @var{interface} with the name of the
  1893. network interface you want to use):
  1894. @example
  1895. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1896. @end example
  1897. Run @command{man wpa_supplicant} for more information.
  1898. @end table
  1899. @cindex DHCP
  1900. At this point, you need to acquire an IP address. On a network where IP
  1901. addresses are automatically assigned @i{via} DHCP, you can run:
  1902. @example
  1903. dhclient -v @var{interface}
  1904. @end example
  1905. Try to ping a server to see if networking is up and running:
  1906. @example
  1907. ping -c 3 gnu.org
  1908. @end example
  1909. Setting up network access is almost always a requirement because the
  1910. image does not contain all the software and tools that may be needed.
  1911. @cindex proxy, during system installation
  1912. If you need HTTP and HTTPS access to go through a proxy, run the
  1913. following command:
  1914. @example
  1915. herd set-http-proxy guix-daemon @var{URL}
  1916. @end example
  1917. @noindent
  1918. where @var{URL} is the proxy URL, for example
  1919. @code{http://example.org:8118}.
  1920. @cindex installing over SSH
  1921. If you want to, you can continue the installation remotely by starting
  1922. an SSH server:
  1923. @example
  1924. herd start ssh-daemon
  1925. @end example
  1926. Make sure to either set a password with @command{passwd}, or configure
  1927. OpenSSH public key authentication before logging in.
  1928. @subsubsection Disk Partitioning
  1929. Unless this has already been done, the next step is to partition, and
  1930. then format the target partition(s).
  1931. The installation image includes several partitioning tools, including
  1932. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1933. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1934. the partition layout you want:
  1935. @example
  1936. cfdisk
  1937. @end example
  1938. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1939. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1940. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1941. manual}).
  1942. @cindex EFI, installation
  1943. @cindex UEFI, installation
  1944. @cindex ESP, EFI system partition
  1945. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1946. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1947. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  1948. @example
  1949. parted /dev/sda set 1 esp on
  1950. @end example
  1951. @quotation Note
  1952. @vindex grub-bootloader
  1953. @vindex grub-efi-bootloader
  1954. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  1955. @file{/sys/firmware/efi} exists in the installation image, then you should
  1956. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  1957. Otherwise you should use the BIOS-based GRUB, known as
  1958. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  1959. bootloaders.
  1960. @end quotation
  1961. Once you are done partitioning the target hard disk drive, you have to
  1962. create a file system on the relevant partition(s)@footnote{Currently
  1963. Guix System only supports ext4, btrfs, JFS, and F2FS file systems. In
  1964. particular, code that reads file system UUIDs and labels only works for these
  1965. file system types.}. For the ESP, if you have one and assuming it is
  1966. @file{/dev/sda1}, run:
  1967. @example
  1968. mkfs.fat -F32 /dev/sda1
  1969. @end example
  1970. For the root file system, ext4 is the most widely used format. Other
  1971. file systems, such as Btrfs, support compression, which is reported to
  1972. nicely complement file deduplication that the daemon performs
  1973. independently of the file system (@pxref{Invoking guix-daemon,
  1974. deduplication}).
  1975. Preferably, assign file systems a label so that you can easily and
  1976. reliably refer to them in @code{file-system} declarations (@pxref{File
  1977. Systems}). This is typically done using the @code{-L} option of
  1978. @command{mkfs.ext4} and related commands. So, assuming the target root
  1979. partition lives at @file{/dev/sda2}, a file system with the label
  1980. @code{my-root} can be created with:
  1981. @example
  1982. mkfs.ext4 -L my-root /dev/sda2
  1983. @end example
  1984. @cindex encrypted disk
  1985. If you are instead planning to encrypt the root partition, you can use
  1986. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  1987. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  1988. @code{man cryptsetup}} for more information). Assuming you want to
  1989. store the root partition on @file{/dev/sda2}, the command sequence would
  1990. be along these lines:
  1991. @example
  1992. cryptsetup luksFormat /dev/sda2
  1993. cryptsetup open --type luks /dev/sda2 my-partition
  1994. mkfs.ext4 -L my-root /dev/mapper/my-partition
  1995. @end example
  1996. Once that is done, mount the target file system under @file{/mnt}
  1997. with a command like (again, assuming @code{my-root} is the label of the
  1998. root file system):
  1999. @example
  2000. mount LABEL=my-root /mnt
  2001. @end example
  2002. Also mount any other file systems you would like to use on the target
  2003. system relative to this path. If you have opted for @file{/boot/efi} as an
  2004. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  2005. found by @code{guix system init} afterwards.
  2006. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  2007. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  2008. sure to initialize them with @command{mkswap}. Assuming you have one
  2009. swap partition on @file{/dev/sda3}, you would run:
  2010. @example
  2011. mkswap /dev/sda3
  2012. swapon /dev/sda3
  2013. @end example
  2014. Alternatively, you may use a swap file. For example, assuming that in
  2015. the new system you want to use the file @file{/swapfile} as a swap file,
  2016. you would run@footnote{This example will work for many types of file
  2017. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  2018. btrfs), the required steps may be different. For details, see the
  2019. manual pages for @command{mkswap} and @command{swapon}.}:
  2020. @example
  2021. # This is 10 GiB of swap space. Adjust "count" to change the size.
  2022. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  2023. # For security, make the file readable and writable only by root.
  2024. chmod 600 /mnt/swapfile
  2025. mkswap /mnt/swapfile
  2026. swapon /mnt/swapfile
  2027. @end example
  2028. Note that if you have encrypted the root partition and created a swap
  2029. file in its file system as described above, then the encryption also
  2030. protects the swap file, just like any other file in that file system.
  2031. @node Proceeding with the Installation
  2032. @subsection Proceeding with the Installation
  2033. With the target partitions ready and the target root mounted on
  2034. @file{/mnt}, we're ready to go. First, run:
  2035. @example
  2036. herd start cow-store /mnt
  2037. @end example
  2038. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  2039. during the installation phase are written to the target disk on @file{/mnt}
  2040. rather than kept in memory. This is necessary because the first phase of
  2041. the @command{guix system init} command (see below) entails downloads or
  2042. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  2043. Next, you have to edit a file and
  2044. provide the declaration of the operating system to be installed. To
  2045. that end, the installation system comes with three text editors. We
  2046. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2047. supports syntax highlighting and parentheses matching; other editors
  2048. include GNU Zile (an Emacs clone), and
  2049. nvi (a clone of the original BSD @command{vi} editor).
  2050. We strongly recommend storing that file on the target root file system, say,
  2051. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2052. configuration file once you have rebooted into the newly-installed system.
  2053. @xref{Using the Configuration System}, for an overview of the
  2054. configuration file. The example configurations discussed in that
  2055. section are available under @file{/etc/configuration} in the
  2056. installation image. Thus, to get started with a system configuration
  2057. providing a graphical display server (a ``desktop'' system), you can run
  2058. something along these lines:
  2059. @example
  2060. # mkdir /mnt/etc
  2061. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2062. # nano /mnt/etc/config.scm
  2063. @end example
  2064. You should pay attention to what your configuration file contains, and
  2065. in particular:
  2066. @itemize
  2067. @item
  2068. Make sure the @code{bootloader-configuration} form refers to the target
  2069. you want to install GRUB on. It should mention @code{grub-bootloader} if
  2070. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  2071. for newer UEFI systems. For legacy systems, the @code{target} field
  2072. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  2073. to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
  2074. currently mounted and a @code{file-system} entry is specified in your
  2075. configuration.
  2076. @item
  2077. Be sure that your file system labels match the value of their respective
  2078. @code{device} fields in your @code{file-system} configuration, assuming
  2079. your @code{file-system} configuration uses the @code{file-system-label}
  2080. procedure in its @code{device} field.
  2081. @item
  2082. If there are encrypted or RAID partitions, make sure to add a
  2083. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2084. @end itemize
  2085. Once you are done preparing the configuration file, the new system must
  2086. be initialized (remember that the target root file system is mounted
  2087. under @file{/mnt}):
  2088. @example
  2089. guix system init /mnt/etc/config.scm /mnt
  2090. @end example
  2091. @noindent
  2092. This copies all the necessary files and installs GRUB on
  2093. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2094. more information, @pxref{Invoking guix system}. This command may trigger
  2095. downloads or builds of missing packages, which can take some time.
  2096. Once that command has completed---and hopefully succeeded!---you can run
  2097. @command{reboot} and boot into the new system. The @code{root} password
  2098. in the new system is initially empty; other users' passwords need to be
  2099. initialized by running the @command{passwd} command as @code{root},
  2100. unless your configuration specifies otherwise
  2101. (@pxref{user-account-password, user account passwords}).
  2102. @xref{After System Installation}, for what's next!
  2103. @node After System Installation
  2104. @section After System Installation
  2105. Success, you've now booted into Guix System! From then on, you can update the
  2106. system whenever you want by running, say:
  2107. @example
  2108. guix pull
  2109. sudo guix system reconfigure /etc/config.scm
  2110. @end example
  2111. @noindent
  2112. This builds a new system generation with the latest packages and services
  2113. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2114. your system includes the latest security updates (@pxref{Security Updates}).
  2115. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2116. @quotation Note
  2117. @cindex sudo vs. @command{guix pull}
  2118. Note that @command{sudo guix} runs your user's @command{guix} command and
  2119. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2120. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2121. The difference matters here, because @command{guix pull} updates
  2122. the @command{guix} command and package definitions only for the user it is run
  2123. as. This means that if you choose to use @command{guix system reconfigure} in
  2124. root's login shell, you'll need to @command{guix pull} separately.
  2125. @end quotation
  2126. Now, @pxref{Getting Started}, and
  2127. join us on @code{#guix} on the Freenode IRC network or on
  2128. @email{guix-devel@@gnu.org} to share your experience!
  2129. @node Installing Guix in a VM
  2130. @section Installing Guix in a Virtual Machine
  2131. @cindex virtual machine, Guix System installation
  2132. @cindex virtual private server (VPS)
  2133. @cindex VPS (virtual private server)
  2134. If you'd like to install Guix System in a virtual machine (VM) or on a
  2135. virtual private server (VPS) rather than on your beloved machine, this
  2136. section is for you.
  2137. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2138. disk image, follow these steps:
  2139. @enumerate
  2140. @item
  2141. First, retrieve and decompress the Guix system installation image as
  2142. described previously (@pxref{USB Stick and DVD Installation}).
  2143. @item
  2144. Create a disk image that will hold the installed system. To make a
  2145. qcow2-formatted disk image, use the @command{qemu-img} command:
  2146. @example
  2147. qemu-img create -f qcow2 guix-system.img 50G
  2148. @end example
  2149. The resulting file will be much smaller than 50 GB (typically less than
  2150. 1 MB), but it will grow as the virtualized storage device is filled up.
  2151. @item
  2152. Boot the USB installation image in an VM:
  2153. @example
  2154. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2155. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2156. -drive file=guix-system.img \
  2157. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2158. @end example
  2159. @code{-enable-kvm} is optional, but significantly improves performance,
  2160. @pxref{Running Guix in a VM}.
  2161. @item
  2162. You're now root in the VM, proceed with the installation process.
  2163. @xref{Preparing for Installation}, and follow the instructions.
  2164. @end enumerate
  2165. Once installation is complete, you can boot the system that's on your
  2166. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2167. that.
  2168. @node Building the Installation Image
  2169. @section Building the Installation Image
  2170. @cindex installation image
  2171. The installation image described above was built using the @command{guix
  2172. system} command, specifically:
  2173. @example
  2174. guix system image -t iso9660 gnu/system/install.scm
  2175. @end example
  2176. Have a look at @file{gnu/system/install.scm} in the source tree,
  2177. and see also @ref{Invoking guix system} for more information
  2178. about the installation image.
  2179. @section Building the Installation Image for ARM Boards
  2180. Many ARM boards require a specific variant of the
  2181. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2182. If you build a disk image and the bootloader is not available otherwise
  2183. (on another boot drive etc), it's advisable to build an image that
  2184. includes the bootloader, specifically:
  2185. @example
  2186. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2187. @end example
  2188. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2189. board, a list of possible boards will be printed.
  2190. @c *********************************************************************
  2191. @node Getting Started
  2192. @chapter Getting Started
  2193. Presumably, you've reached this section because either you have
  2194. installed Guix on top of another distribution (@pxref{Installation}), or
  2195. you've installed the standalone Guix System (@pxref{System
  2196. Installation}). It's time for you to get started using Guix and this
  2197. section aims to help you do that and give you a feel of what it's like.
  2198. Guix is about installing software, so probably the first thing you'll
  2199. want to do is to actually look for software. Let's say you're looking
  2200. for a text editor, you can run:
  2201. @example
  2202. guix search text editor
  2203. @end example
  2204. This command shows you a number of matching @dfn{packages}, each time
  2205. showing the package's name, version, a description, and additional info.
  2206. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2207. you can go ahead and install it (run this command as a regular user,
  2208. @emph{no need for root privileges}!):
  2209. @example
  2210. guix install emacs
  2211. @end example
  2212. @cindex profile
  2213. You've installed your first package, congrats! The package is now
  2214. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2215. profile is a directory containing installed packages.
  2216. In the process, you've
  2217. probably noticed that Guix downloaded pre-built binaries; or, if you
  2218. explicitly chose to @emph{not} use pre-built binaries, then probably
  2219. Guix is still building software (@pxref{Substitutes}, for more info).
  2220. Unless you're using Guix System, the @command{guix install} command must
  2221. have printed this hint:
  2222. @example
  2223. hint: Consider setting the necessary environment variables by running:
  2224. GUIX_PROFILE="$HOME/.guix-profile"
  2225. . "$GUIX_PROFILE/etc/profile"
  2226. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2227. @end example
  2228. Indeed, you must now tell your shell where @command{emacs} and other
  2229. programs installed with Guix are to be found. Pasting the two lines
  2230. above will do just that: it will add
  2231. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2232. is---to the @code{PATH} environment variable. You can paste these two
  2233. lines in your shell so they take effect right away, but more importantly
  2234. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2235. do not use Bash) so that environment variables are set next time you
  2236. spawn a shell. You only need to do this once and other search paths
  2237. environment variables will be taken care of similarly---e.g., if you
  2238. eventually install @code{python} and Python libraries,
  2239. @env{GUIX_PYTHONPATH} will be defined.
  2240. You can go on installing packages at your will. To list installed
  2241. packages, run:
  2242. @example
  2243. guix package --list-installed
  2244. @end example
  2245. To remove a package, you would unsurprisingly run @command{guix remove}.
  2246. A distinguishing feature is the ability to @dfn{roll back} any operation
  2247. you made---installation, removal, upgrade---by simply typing:
  2248. @example
  2249. guix package --roll-back
  2250. @end example
  2251. This is because each operation is in fact a @dfn{transaction} that
  2252. creates a new @dfn{generation}. These generations and the difference
  2253. between them can be displayed by running:
  2254. @example
  2255. guix package --list-generations
  2256. @end example
  2257. Now you know the basics of package management!
  2258. @quotation Going further
  2259. @xref{Package Management}, for more about package management. You may
  2260. like @dfn{declarative} package management with @command{guix package
  2261. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2262. deleting old generations, collecting garbage, and other nifty features
  2263. that will come in handy as you become more familiar with Guix. If you
  2264. are a developer, @pxref{Development} for additional tools. And if
  2265. you're curious, @pxref{Features}, to peek under the hood.
  2266. @end quotation
  2267. Once you've installed a set of packages, you will want to periodically
  2268. @emph{upgrade} them to the latest and greatest version. To do that, you
  2269. will first pull the latest revision of Guix and its package collection:
  2270. @example
  2271. guix pull
  2272. @end example
  2273. The end result is a new @command{guix} command, under
  2274. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2275. first time you run @command{guix pull}, be sure to follow the hint that
  2276. the command prints and, similar to what we saw above, paste these two
  2277. lines in your terminal and @file{.bash_profile}:
  2278. @example
  2279. GUIX_PROFILE="$HOME/.config/guix/current"
  2280. . "$GUIX_PROFILE/etc/profile"
  2281. @end example
  2282. @noindent
  2283. You must also instruct your shell to point to this new @command{guix}:
  2284. @example
  2285. hash guix
  2286. @end example
  2287. At this point, you're running a brand new Guix. You can thus go ahead
  2288. and actually upgrade all the packages you previously installed:
  2289. @example
  2290. guix upgrade
  2291. @end example
  2292. As you run this command, you will see that binaries are downloaded (or
  2293. perhaps some packages are built), and eventually you end up with the
  2294. upgraded packages. Should one of these upgraded packages not be to your
  2295. liking, remember you can always roll back!
  2296. You can display the exact revision of Guix you're currently using by
  2297. running:
  2298. @example
  2299. guix describe
  2300. @end example
  2301. The information it displays is @emph{all it takes to reproduce the exact
  2302. same Guix}, be it at a different point in time or on a different
  2303. machine.
  2304. @quotation Going further
  2305. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2306. how to specify additional @dfn{channels} to pull packages from, how to
  2307. replicate Guix, and more. You may also find @command{time-machine}
  2308. handy (@pxref{Invoking guix time-machine}).
  2309. @end quotation
  2310. If you installed Guix System, one of the first things you'll want to do
  2311. is to upgrade your system. Once you've run @command{guix pull} to get
  2312. the latest Guix, you can upgrade the system like this:
  2313. @example
  2314. sudo guix system reconfigure /etc/config.scm
  2315. @end example
  2316. Upon completion, the system runs the latest versions of its software
  2317. packages. When you eventually reboot, you'll notice a sub-menu in the
  2318. bootloader that reads ``Old system generations'': it's what allows you
  2319. to boot @emph{an older generation of your system}, should the latest
  2320. generation be ``broken'' or otherwise unsatisfying. Just like for
  2321. packages, you can always @emph{roll back} to a previous generation
  2322. @emph{of the whole system}:
  2323. @example
  2324. sudo guix system roll-back
  2325. @end example
  2326. There are many things you'll probably want to tweak on your system:
  2327. adding new user accounts, adding new system services, fiddling with the
  2328. configuration of those services, etc. The system configuration is
  2329. @emph{entirely} described in the @file{/etc/config.scm} file.
  2330. @xref{Using the Configuration System}, to learn how to change it.
  2331. Now you know enough to get started!
  2332. @quotation Resources
  2333. The rest of this manual provides a reference for all things Guix. Here
  2334. are some additional resources you may find useful:
  2335. @itemize
  2336. @item
  2337. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2338. ``how-to'' style of recipes for a variety of applications.
  2339. @item
  2340. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2341. Card} lists in two pages most of the commands and options you'll ever
  2342. need.
  2343. @item
  2344. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2345. instructional videos} covering topics such as everyday use of Guix, how
  2346. to get help, and how to become a contributor.
  2347. @item
  2348. @xref{Documentation}, to learn how to access documentation on your
  2349. computer.
  2350. @end itemize
  2351. We hope you will enjoy Guix as much as the community enjoys building it!
  2352. @end quotation
  2353. @c *********************************************************************
  2354. @node Package Management
  2355. @chapter Package Management
  2356. @cindex packages
  2357. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2358. remove software packages, without having to know about their build
  2359. procedures or dependencies. Guix also goes beyond this obvious set of
  2360. features.
  2361. This chapter describes the main features of Guix, as well as the
  2362. package management tools it provides. Along with the command-line
  2363. interface described below (@pxref{Invoking guix package, @code{guix
  2364. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2365. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2366. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2367. with it):
  2368. @example
  2369. guix install emacs-guix
  2370. @end example
  2371. @menu
  2372. * Features:: How Guix will make your life brighter.
  2373. * Invoking guix package:: Package installation, removal, etc.
  2374. * Substitutes:: Downloading pre-built binaries.
  2375. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2376. * Invoking guix gc:: Running the garbage collector.
  2377. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2378. * Invoking guix time-machine:: Running an older revision of Guix.
  2379. * Inferiors:: Interacting with another revision of Guix.
  2380. * Invoking guix describe:: Display information about your Guix revision.
  2381. * Invoking guix archive:: Exporting and importing store files.
  2382. @end menu
  2383. @node Features
  2384. @section Features
  2385. Here we assume you've already made your first steps with Guix
  2386. (@pxref{Getting Started}) and would like to get an overview about what's
  2387. going on under the hood.
  2388. When using Guix, each package ends up in the @dfn{package store}, in its
  2389. own directory---something that resembles
  2390. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2391. Instead of referring to these directories, users have their own
  2392. @dfn{profile}, which points to the packages that they actually want to
  2393. use. These profiles are stored within each user's home directory, at
  2394. @code{$HOME/.guix-profile}.
  2395. For example, @code{alice} installs GCC 4.7.2. As a result,
  2396. @file{/home/alice/.guix-profile/bin/gcc} points to
  2397. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2398. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2399. simply continues to point to
  2400. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2401. coexist on the same system without any interference.
  2402. The @command{guix package} command is the central tool to manage
  2403. packages (@pxref{Invoking guix package}). It operates on the per-user
  2404. profiles, and can be used @emph{with normal user privileges}.
  2405. @cindex transactions
  2406. The command provides the obvious install, remove, and upgrade
  2407. operations. Each invocation is actually a @emph{transaction}: either
  2408. the specified operation succeeds, or nothing happens. Thus, if the
  2409. @command{guix package} process is terminated during the transaction,
  2410. or if a power outage occurs during the transaction, then the user's
  2411. profile remains in its previous state, and remains usable.
  2412. In addition, any package transaction may be @emph{rolled back}. So, if,
  2413. for example, an upgrade installs a new version of a package that turns
  2414. out to have a serious bug, users may roll back to the previous instance
  2415. of their profile, which was known to work well. Similarly, the global
  2416. system configuration on Guix is subject to
  2417. transactional upgrades and roll-back
  2418. (@pxref{Using the Configuration System}).
  2419. All packages in the package store may be @emph{garbage-collected}.
  2420. Guix can determine which packages are still referenced by user
  2421. profiles, and remove those that are provably no longer referenced
  2422. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2423. generations of their profile so that the packages they refer to can be
  2424. collected.
  2425. @cindex reproducibility
  2426. @cindex reproducible builds
  2427. Guix takes a @dfn{purely functional} approach to package
  2428. management, as described in the introduction (@pxref{Introduction}).
  2429. Each @file{/gnu/store} package directory name contains a hash of all the
  2430. inputs that were used to build that package---compiler, libraries, build
  2431. scripts, etc. This direct correspondence allows users to make sure a
  2432. given package installation matches the current state of their
  2433. distribution. It also helps maximize @dfn{build reproducibility}:
  2434. thanks to the isolated build environments that are used, a given build
  2435. is likely to yield bit-identical files when performed on different
  2436. machines (@pxref{Invoking guix-daemon, container}).
  2437. @cindex substitutes
  2438. This foundation allows Guix to support @dfn{transparent binary/source
  2439. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2440. available from an external source---a @dfn{substitute}, Guix just
  2441. downloads it and unpacks it;
  2442. otherwise, it builds the package from source, locally
  2443. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2444. reproducible, users do not have to trust servers that provide
  2445. substitutes: they can force a local build and @emph{challenge} providers
  2446. (@pxref{Invoking guix challenge}).
  2447. Control over the build environment is a feature that is also useful for
  2448. developers. The @command{guix environment} command allows developers of
  2449. a package to quickly set up the right development environment for their
  2450. package, without having to manually install the dependencies of the
  2451. package into their profile (@pxref{Invoking guix environment}).
  2452. @cindex replication, of software environments
  2453. @cindex provenance tracking, of software artifacts
  2454. All of Guix and its package definitions is version-controlled, and
  2455. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2456. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2457. Guix instance on a different machine or at a later point in time, which in
  2458. turn allows you to @emph{replicate complete software environments}, while
  2459. retaining precise @dfn{provenance tracking} of the software.
  2460. @node Invoking guix package
  2461. @section Invoking @command{guix package}
  2462. @cindex installing packages
  2463. @cindex removing packages
  2464. @cindex package installation
  2465. @cindex package removal
  2466. @cindex profile
  2467. The @command{guix package} command is the tool that allows users to
  2468. install, upgrade, and remove packages, as well as rolling back to
  2469. previous configurations. These operations work on a user
  2470. @dfn{profile}---a directory of installed packages. Each user has a
  2471. default profile in @file{$HOME/.guix-profile}.
  2472. The command operates only on the user's own profile,
  2473. and works with normal user privileges (@pxref{Features}). Its syntax
  2474. is:
  2475. @example
  2476. guix package @var{options}
  2477. @end example
  2478. @cindex transactions
  2479. Primarily, @var{options} specifies the operations to be performed during
  2480. the transaction. Upon completion, a new profile is created, but
  2481. previous @dfn{generations} of the profile remain available, should the user
  2482. want to roll back.
  2483. For example, to remove @code{lua} and install @code{guile} and
  2484. @code{guile-cairo} in a single transaction:
  2485. @example
  2486. guix package -r lua -i guile guile-cairo
  2487. @end example
  2488. @cindex aliases, for @command{guix package}
  2489. For your convenience, we also provide the following aliases:
  2490. @itemize
  2491. @item
  2492. @command{guix search} is an alias for @command{guix package -s},
  2493. @item
  2494. @command{guix install} is an alias for @command{guix package -i},
  2495. @item
  2496. @command{guix remove} is an alias for @command{guix package -r},
  2497. @item
  2498. @command{guix upgrade} is an alias for @command{guix package -u},
  2499. @item
  2500. and @command{guix show} is an alias for @command{guix package --show=}.
  2501. @end itemize
  2502. These aliases are less expressive than @command{guix package} and provide
  2503. fewer options, so in some cases you'll probably want to use @command{guix
  2504. package} directly.
  2505. @command{guix package} also supports a @dfn{declarative approach}
  2506. whereby the user specifies the exact set of packages to be available and
  2507. passes it @i{via} the @option{--manifest} option
  2508. (@pxref{profile-manifest, @option{--manifest}}).
  2509. @cindex profile
  2510. For each user, a symlink to the user's default profile is automatically
  2511. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2512. current generation of the user's default profile. Thus, users can add
  2513. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2514. variable, and so on.
  2515. @cindex search paths
  2516. If you are not using Guix System, consider adding the
  2517. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2518. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2519. shells get all the right environment variable definitions:
  2520. @example
  2521. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2522. source "$GUIX_PROFILE/etc/profile"
  2523. @end example
  2524. In a multi-user setup, user profiles are stored in a place registered as
  2525. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2526. to (@pxref{Invoking guix gc}). That directory is normally
  2527. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2528. @var{localstatedir} is the value passed to @code{configure} as
  2529. @option{--localstatedir}, and @var{user} is the user name. The
  2530. @file{per-user} directory is created when @command{guix-daemon} is
  2531. started, and the @var{user} sub-directory is created by @command{guix
  2532. package}.
  2533. The @var{options} can be among the following:
  2534. @table @code
  2535. @item --install=@var{package} @dots{}
  2536. @itemx -i @var{package} @dots{}
  2537. Install the specified @var{package}s.
  2538. Each @var{package} may specify either a simple package name, such as
  2539. @code{guile}, or a package name followed by an at-sign and version number,
  2540. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2541. case, the newest version prefixed by @code{1.8} is selected).
  2542. If no version number is specified, the
  2543. newest available version will be selected. In addition, @var{package}
  2544. may contain a colon, followed by the name of one of the outputs of the
  2545. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2546. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2547. name (and optionally version) are searched for among the GNU
  2548. distribution modules (@pxref{Package Modules}).
  2549. @cindex propagated inputs
  2550. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2551. that automatically get installed along with the required package
  2552. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2553. @code{package} objects}, for information about propagated inputs in
  2554. package definitions).
  2555. @anchor{package-cmd-propagated-inputs}
  2556. An example is the GNU MPC library: its C header files refer to those of
  2557. the GNU MPFR library, which in turn refer to those of the GMP library.
  2558. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2559. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2560. also been explicitly installed by the user.
  2561. Besides, packages sometimes rely on the definition of environment
  2562. variables for their search paths (see explanation of
  2563. @option{--search-paths} below). Any missing or possibly incorrect
  2564. environment variable definitions are reported here.
  2565. @item --install-from-expression=@var{exp}
  2566. @itemx -e @var{exp}
  2567. Install the package @var{exp} evaluates to.
  2568. @var{exp} must be a Scheme expression that evaluates to a
  2569. @code{<package>} object. This option is notably useful to disambiguate
  2570. between same-named variants of a package, with expressions such as
  2571. @code{(@@ (gnu packages base) guile-final)}.
  2572. Note that this option installs the first output of the specified
  2573. package, which may be insufficient when needing a specific output of a
  2574. multiple-output package.
  2575. @item --install-from-file=@var{file}
  2576. @itemx -f @var{file}
  2577. Install the package that the code within @var{file} evaluates to.
  2578. As an example, @var{file} might contain a definition like this
  2579. (@pxref{Defining Packages}):
  2580. @lisp
  2581. @include package-hello.scm
  2582. @end lisp
  2583. Developers may find it useful to include such a @file{guix.scm} file
  2584. in the root of their project source tree that can be used to test
  2585. development snapshots and create reproducible development environments
  2586. (@pxref{Invoking guix environment}).
  2587. The @var{file} may also contain a JSON representation of one or more
  2588. package definitions. Running @code{guix package -f} on
  2589. @file{hello.json} with the following contents would result in installing
  2590. the package @code{greeter} after building @code{myhello}:
  2591. @example
  2592. @verbatiminclude package-hello.json
  2593. @end example
  2594. @item --remove=@var{package} @dots{}
  2595. @itemx -r @var{package} @dots{}
  2596. Remove the specified @var{package}s.
  2597. As for @option{--install}, each @var{package} may specify a version number
  2598. and/or output name in addition to the package name. For instance,
  2599. @samp{-r glibc:debug} would remove the @code{debug} output of
  2600. @code{glibc}.
  2601. @item --upgrade[=@var{regexp} @dots{}]
  2602. @itemx -u [@var{regexp} @dots{}]
  2603. @cindex upgrading packages
  2604. Upgrade all the installed packages. If one or more @var{regexp}s are
  2605. specified, upgrade only installed packages whose name matches a
  2606. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2607. Note that this upgrades package to the latest version of packages found
  2608. in the distribution currently installed. To update your distribution,
  2609. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2610. pull}).
  2611. @cindex package transformations, upgrades
  2612. When upgrading, package transformations that were originally applied
  2613. when creating the profile are automatically re-applied (@pxref{Package
  2614. Transformation Options}). For example, assume you first installed Emacs
  2615. from the tip of its development branch with:
  2616. @example
  2617. guix install emacs-next --with-branch=emacs-next=master
  2618. @end example
  2619. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2620. of the Emacs development branch and build @code{emacs-next} from that
  2621. checkout.
  2622. Note that transformation options such as @option{--with-branch} and
  2623. @option{--with-source} depend on external state; it is up to you to
  2624. ensure that they work as expected. You can also discard a
  2625. transformations that apply to a package by running:
  2626. @example
  2627. guix install @var{package}
  2628. @end example
  2629. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2630. When used together with the @option{--upgrade} option, do @emph{not}
  2631. upgrade any packages whose name matches a @var{regexp}. For example, to
  2632. upgrade all packages in the current profile except those containing the
  2633. substring ``emacs'':
  2634. @example
  2635. $ guix package --upgrade . --do-not-upgrade emacs
  2636. @end example
  2637. @item @anchor{profile-manifest}--manifest=@var{file}
  2638. @itemx -m @var{file}
  2639. @cindex profile declaration
  2640. @cindex profile manifest
  2641. Create a new generation of the profile from the manifest object
  2642. returned by the Scheme code in @var{file}. This option can be repeated
  2643. several times, in which case the manifests are concatenated.
  2644. This allows you to @emph{declare} the profile's contents rather than
  2645. constructing it through a sequence of @option{--install} and similar
  2646. commands. The advantage is that @var{file} can be put under version
  2647. control, copied to different machines to reproduce the same profile, and
  2648. so on.
  2649. @c FIXME: Add reference to (guix profile) documentation when available.
  2650. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2651. of packages:
  2652. @findex packages->manifest
  2653. @lisp
  2654. (use-package-modules guile emacs)
  2655. (packages->manifest
  2656. (list emacs
  2657. guile-2.0
  2658. ;; Use a specific package output.
  2659. (list guile-2.0 "debug")))
  2660. @end lisp
  2661. @findex specifications->manifest
  2662. In this example we have to know which modules define the @code{emacs}
  2663. and @code{guile-2.0} variables to provide the right
  2664. @code{use-package-modules} line, which can be cumbersome. We can
  2665. instead provide regular package specifications and let
  2666. @code{specifications->manifest} look up the corresponding package
  2667. objects, like this:
  2668. @lisp
  2669. (specifications->manifest
  2670. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2671. @end lisp
  2672. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2673. obtain a manifest file from an existing profile.
  2674. @item --roll-back
  2675. @cindex rolling back
  2676. @cindex undoing transactions
  2677. @cindex transactions, undoing
  2678. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2679. the last transaction.
  2680. When combined with options such as @option{--install}, roll back occurs
  2681. before any other actions.
  2682. When rolling back from the first generation that actually contains
  2683. installed packages, the profile is made to point to the @dfn{zeroth
  2684. generation}, which contains no files apart from its own metadata.
  2685. After having rolled back, installing, removing, or upgrading packages
  2686. overwrites previous future generations. Thus, the history of the
  2687. generations in a profile is always linear.
  2688. @item --switch-generation=@var{pattern}
  2689. @itemx -S @var{pattern}
  2690. @cindex generations
  2691. Switch to a particular generation defined by @var{pattern}.
  2692. @var{pattern} may be either a generation number or a number prefixed
  2693. with ``+'' or ``-''. The latter means: move forward/backward by a
  2694. specified number of generations. For example, if you want to return to
  2695. the latest generation after @option{--roll-back}, use
  2696. @option{--switch-generation=+1}.
  2697. The difference between @option{--roll-back} and
  2698. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2699. not make a zeroth generation, so if a specified generation does not
  2700. exist, the current generation will not be changed.
  2701. @item --search-paths[=@var{kind}]
  2702. @cindex search paths
  2703. Report environment variable definitions, in Bash syntax, that may be
  2704. needed in order to use the set of installed packages. These environment
  2705. variables are used to specify @dfn{search paths} for files used by some
  2706. of the installed packages.
  2707. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2708. environment variables to be defined so it can look for headers and
  2709. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2710. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2711. library are installed in the profile, then @option{--search-paths} will
  2712. suggest setting these variables to @file{@var{profile}/include} and
  2713. @file{@var{profile}/lib}, respectively.
  2714. The typical use case is to define these environment variables in the
  2715. shell:
  2716. @example
  2717. $ eval `guix package --search-paths`
  2718. @end example
  2719. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2720. meaning that the returned environment variable definitions will either
  2721. be exact settings, or prefixes or suffixes of the current value of these
  2722. variables. When omitted, @var{kind} defaults to @code{exact}.
  2723. This option can also be used to compute the @emph{combined} search paths
  2724. of several profiles. Consider this example:
  2725. @example
  2726. $ guix package -p foo -i guile
  2727. $ guix package -p bar -i guile-json
  2728. $ guix package -p foo -p bar --search-paths
  2729. @end example
  2730. The last command above reports about the @env{GUILE_LOAD_PATH}
  2731. variable, even though, taken individually, neither @file{foo} nor
  2732. @file{bar} would lead to that recommendation.
  2733. @cindex profile, choosing
  2734. @item --profile=@var{profile}
  2735. @itemx -p @var{profile}
  2736. Use @var{profile} instead of the user's default profile.
  2737. @var{profile} must be the name of a file that will be created upon
  2738. completion. Concretely, @var{profile} will be a mere symbolic link
  2739. (``symlink'') pointing to the actual profile where packages are
  2740. installed:
  2741. @example
  2742. $ guix install hello -p ~/code/my-profile
  2743. @dots{}
  2744. $ ~/code/my-profile/bin/hello
  2745. Hello, world!
  2746. @end example
  2747. All it takes to get rid of the profile is to remove this symlink and its
  2748. siblings that point to specific generations:
  2749. @example
  2750. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2751. @end example
  2752. @item --list-profiles
  2753. List all the user's profiles:
  2754. @example
  2755. $ guix package --list-profiles
  2756. /home/charlie/.guix-profile
  2757. /home/charlie/code/my-profile
  2758. /home/charlie/code/devel-profile
  2759. /home/charlie/tmp/test
  2760. @end example
  2761. When running as root, list all the profiles of all the users.
  2762. @cindex collisions, in a profile
  2763. @cindex colliding packages in profiles
  2764. @cindex profile collisions
  2765. @item --allow-collisions
  2766. Allow colliding packages in the new profile. Use at your own risk!
  2767. By default, @command{guix package} reports as an error @dfn{collisions}
  2768. in the profile. Collisions happen when two or more different versions
  2769. or variants of a given package end up in the profile.
  2770. @item --bootstrap
  2771. Use the bootstrap Guile to build the profile. This option is only
  2772. useful to distribution developers.
  2773. @end table
  2774. In addition to these actions, @command{guix package} supports the
  2775. following options to query the current state of a profile, or the
  2776. availability of packages:
  2777. @table @option
  2778. @item --search=@var{regexp}
  2779. @itemx -s @var{regexp}
  2780. @anchor{guix-search}
  2781. @cindex searching for packages
  2782. List the available packages whose name, synopsis, or description matches
  2783. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2784. Print all the metadata of matching packages in
  2785. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2786. GNU recutils manual}).
  2787. This allows specific fields to be extracted using the @command{recsel}
  2788. command, for instance:
  2789. @example
  2790. $ guix package -s malloc | recsel -p name,version,relevance
  2791. name: jemalloc
  2792. version: 4.5.0
  2793. relevance: 6
  2794. name: glibc
  2795. version: 2.25
  2796. relevance: 1
  2797. name: libgc
  2798. version: 7.6.0
  2799. relevance: 1
  2800. @end example
  2801. Similarly, to show the name of all the packages available under the
  2802. terms of the GNU@tie{}LGPL version 3:
  2803. @example
  2804. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2805. name: elfutils
  2806. name: gmp
  2807. @dots{}
  2808. @end example
  2809. It is also possible to refine search results using several @code{-s} flags to
  2810. @command{guix package}, or several arguments to @command{guix search}. For
  2811. example, the following command returns a list of board games (this time using
  2812. the @command{guix search} alias):
  2813. @example
  2814. $ guix search '\<board\>' game | recsel -p name
  2815. name: gnubg
  2816. @dots{}
  2817. @end example
  2818. If we were to omit @code{-s game}, we would also get software packages
  2819. that deal with printed circuit boards; removing the angle brackets
  2820. around @code{board} would further add packages that have to do with
  2821. keyboards.
  2822. And now for a more elaborate example. The following command searches
  2823. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2824. libraries, and prints the name and synopsis of the matching packages:
  2825. @example
  2826. $ guix search crypto library | \
  2827. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2828. @end example
  2829. @noindent
  2830. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2831. information on @dfn{selection expressions} for @code{recsel -e}.
  2832. @item --show=@var{package}
  2833. Show details about @var{package}, taken from the list of available packages, in
  2834. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2835. recutils manual}).
  2836. @example
  2837. $ guix package --show=guile | recsel -p name,version
  2838. name: guile
  2839. version: 3.0.5
  2840. name: guile
  2841. version: 3.0.2
  2842. name: guile
  2843. version: 2.2.7
  2844. @dots{}
  2845. @end example
  2846. You may also specify the full name of a package to only get details about a
  2847. specific version of it (this time using the @command{guix show} alias):
  2848. @example
  2849. $ guix show guile@@3.0.5 | recsel -p name,version
  2850. name: guile
  2851. version: 3.0.5
  2852. @end example
  2853. @item --list-installed[=@var{regexp}]
  2854. @itemx -I [@var{regexp}]
  2855. List the currently installed packages in the specified profile, with the
  2856. most recently installed packages shown last. When @var{regexp} is
  2857. specified, list only installed packages whose name matches @var{regexp}.
  2858. For each installed package, print the following items, separated by
  2859. tabs: the package name, its version string, the part of the package that
  2860. is installed (for instance, @code{out} for the default output,
  2861. @code{include} for its headers, etc.), and the path of this package in
  2862. the store.
  2863. @item --list-available[=@var{regexp}]
  2864. @itemx -A [@var{regexp}]
  2865. List packages currently available in the distribution for this system
  2866. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2867. available packages whose name matches @var{regexp}.
  2868. For each package, print the following items separated by tabs: its name,
  2869. its version string, the parts of the package (@pxref{Packages with
  2870. Multiple Outputs}), and the source location of its definition.
  2871. @item --list-generations[=@var{pattern}]
  2872. @itemx -l [@var{pattern}]
  2873. @cindex generations
  2874. Return a list of generations along with their creation dates; for each
  2875. generation, show the installed packages, with the most recently
  2876. installed packages shown last. Note that the zeroth generation is never
  2877. shown.
  2878. For each installed package, print the following items, separated by
  2879. tabs: the name of a package, its version string, the part of the package
  2880. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2881. location of this package in the store.
  2882. When @var{pattern} is used, the command returns only matching
  2883. generations. Valid patterns include:
  2884. @itemize
  2885. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2886. generation numbers. For instance, @option{--list-generations=1} returns
  2887. the first one.
  2888. And @option{--list-generations=1,8,2} outputs three generations in the
  2889. specified order. Neither spaces nor trailing commas are allowed.
  2890. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2891. specified generations and everything in between. Note that the start of
  2892. a range must be smaller than its end.
  2893. It is also possible to omit the endpoint. For example,
  2894. @option{--list-generations=2..}, returns all generations starting from the
  2895. second one.
  2896. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2897. or months by passing an integer along with the first letter of the
  2898. duration. For example, @option{--list-generations=20d} lists generations
  2899. that are up to 20 days old.
  2900. @end itemize
  2901. @item --delete-generations[=@var{pattern}]
  2902. @itemx -d [@var{pattern}]
  2903. When @var{pattern} is omitted, delete all generations except the current
  2904. one.
  2905. This command accepts the same patterns as @option{--list-generations}.
  2906. When @var{pattern} is specified, delete the matching generations. When
  2907. @var{pattern} specifies a duration, generations @emph{older} than the
  2908. specified duration match. For instance, @option{--delete-generations=1m}
  2909. deletes generations that are more than one month old.
  2910. If the current generation matches, it is @emph{not} deleted. Also, the
  2911. zeroth generation is never deleted.
  2912. Note that deleting generations prevents rolling back to them.
  2913. Consequently, this command must be used with care.
  2914. @cindex manifest, exporting
  2915. @anchor{export-manifest}
  2916. @item --export-manifest
  2917. Write to standard output a manifest suitable for @option{--manifest}
  2918. corresponding to the chosen profile(s).
  2919. This option is meant to help you migrate from the ``imperative''
  2920. operating mode---running @command{guix install}, @command{guix upgrade},
  2921. etc.---to the declarative mode that @option{--manifest} offers.
  2922. Be aware that the resulting manifest @emph{approximates} what your
  2923. profile actually contains; for instance, depending on how your profile
  2924. was created, it can refer to packages or package versions that are not
  2925. exactly what you specified.
  2926. Keep in mind that a manifest is purely symbolic: it only contains
  2927. package names and possibly versions, and their meaning varies over time.
  2928. If you wish to ``pin'' channels to the revisions that were used to build
  2929. the profile(s), see @option{--export-channels} below.
  2930. @cindex pinning, channel revisions of a profile
  2931. @item --export-channels
  2932. Write to standard output the list of channels used by the chosen
  2933. profile(s), in a format suitable for @command{guix pull --channels} or
  2934. @command{guix time-machine --channels} (@pxref{Channels}).
  2935. Together with @option{--export-manifest}, this option provides
  2936. information allowing you to replicate the current profile
  2937. (@pxref{Replicating Guix}).
  2938. However, note that the output of this command @emph{approximates} what
  2939. was actually used to build this profile. In particular, a single
  2940. profile might have been built from several different revisions of the
  2941. same channel. In that case, @option{--export-manifest} chooses the last
  2942. one and writes the list of other revisions in a comment. If you really
  2943. need to pick packages from different channel revisions, you can use
  2944. inferiors in your manifest to do so (@pxref{Inferiors}).
  2945. Together with @option{--export-manifest}, this is a good starting point
  2946. if you are willing to migrate from the ``imperative'' model to the fully
  2947. declarative model consisting of a manifest file along with a channels
  2948. file pinning the exact channel revision(s) you want.
  2949. @end table
  2950. Finally, since @command{guix package} may actually start build
  2951. processes, it supports all the common build options (@pxref{Common Build
  2952. Options}). It also supports package transformation options, such as
  2953. @option{--with-source}, and preserves them across upgrades
  2954. (@pxref{Package Transformation Options}).
  2955. @node Substitutes
  2956. @section Substitutes
  2957. @cindex substitutes
  2958. @cindex pre-built binaries
  2959. Guix supports transparent source/binary deployment, which means that it
  2960. can either build things locally, or download pre-built items from a
  2961. server, or both. We call these pre-built items @dfn{substitutes}---they
  2962. are substitutes for local build results. In many cases, downloading a
  2963. substitute is much faster than building things locally.
  2964. Substitutes can be anything resulting from a derivation build
  2965. (@pxref{Derivations}). Of course, in the common case, they are
  2966. pre-built package binaries, but source tarballs, for instance, which
  2967. also result from derivation builds, can be available as substitutes.
  2968. @menu
  2969. * Official Substitute Server:: One particular source of substitutes.
  2970. * Substitute Server Authorization:: How to enable or disable substitutes.
  2971. * Getting Substitutes from Other Servers:: Substitute diversity.
  2972. * Substitute Authentication:: How Guix verifies substitutes.
  2973. * Proxy Settings:: How to get substitutes via proxy.
  2974. * Substitution Failure:: What happens when substitution fails.
  2975. * On Trusting Binaries:: How can you trust that binary blob?
  2976. @end menu
  2977. @node Official Substitute Server
  2978. @subsection Official Substitute Server
  2979. @cindex build farm
  2980. The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
  2981. that builds packages from Guix continuously for some
  2982. architectures, and makes them available as substitutes. This is the
  2983. default source of substitutes; it can be overridden by passing the
  2984. @option{--substitute-urls} option either to @command{guix-daemon}
  2985. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  2986. or to client tools such as @command{guix package}
  2987. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  2988. option}).
  2989. Substitute URLs can be either HTTP or HTTPS.
  2990. HTTPS is recommended because communications are encrypted; conversely,
  2991. using HTTP makes all communications visible to an eavesdropper, who
  2992. could use the information gathered to determine, for instance, whether
  2993. your system has unpatched security vulnerabilities.
  2994. Substitutes from the official build farm are enabled by default when
  2995. using Guix System (@pxref{GNU Distribution}). However,
  2996. they are disabled by default when using Guix on a foreign distribution,
  2997. unless you have explicitly enabled them via one of the recommended
  2998. installation steps (@pxref{Installation}). The following paragraphs
  2999. describe how to enable or disable substitutes for the official build
  3000. farm; the same procedure can also be used to enable substitutes for any
  3001. other substitute server.
  3002. @node Substitute Server Authorization
  3003. @subsection Substitute Server Authorization
  3004. @cindex security
  3005. @cindex substitutes, authorization thereof
  3006. @cindex access control list (ACL), for substitutes
  3007. @cindex ACL (access control list), for substitutes
  3008. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
  3009. mirror thereof, you
  3010. must add its public key to the access control list (ACL) of archive
  3011. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3012. archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
  3013. be compromised and to serve genuine substitutes.
  3014. @quotation Note
  3015. If you are using Guix System, you can skip this section: Guix System
  3016. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER}} by default.
  3017. @end quotation
  3018. The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
  3019. @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
  3020. the installation prefix of Guix. If you installed Guix from source,
  3021. make sure you checked the GPG signature of
  3022. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3023. Then, you can run something like this:
  3024. @example
  3025. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
  3026. @end example
  3027. Once this is in place, the output of a command like @code{guix build}
  3028. should change from something like:
  3029. @example
  3030. $ guix build emacs --dry-run
  3031. The following derivations would be built:
  3032. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3033. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3034. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3035. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3036. @dots{}
  3037. @end example
  3038. @noindent
  3039. to something like:
  3040. @example
  3041. $ guix build emacs --dry-run
  3042. 112.3 MB would be downloaded:
  3043. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3044. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3045. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3046. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3047. @dots{}
  3048. @end example
  3049. @noindent
  3050. The text changed from ``The following derivations would be built'' to
  3051. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3052. @code{@value{SUBSTITUTE-SERVER}} are usable and will be downloaded, when
  3053. possible, for future builds.
  3054. @cindex substitutes, how to disable
  3055. The substitute mechanism can be disabled globally by running
  3056. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3057. guix-daemon}). It can also be disabled temporarily by passing the
  3058. @option{--no-substitutes} option to @command{guix package},
  3059. @command{guix build}, and other command-line tools.
  3060. @node Getting Substitutes from Other Servers
  3061. @subsection Getting Substitutes from Other Servers
  3062. @cindex substitute servers, adding more
  3063. Guix can look up and fetch substitutes from several servers. This is
  3064. useful when you are using packages from additional channels for which
  3065. the official server does not have substitutes but another server
  3066. provides them. Another situation where this is useful is when you would
  3067. prefer to download from your organization's substitute server, resorting
  3068. to the official server only as a fallback or dismissing it altogether.
  3069. You can give Guix a list of substitute server URLs and it will check
  3070. them in the specified order. You also need to explicitly authorize the
  3071. public keys of substitute servers to instruct Guix to accept the
  3072. substitutes they sign.
  3073. On Guix System, this is achieved by modifying the configuration of the
  3074. @code{guix} service. Since the @code{guix} service is part of the
  3075. default lists of services, @code{%base-services} and
  3076. @code{%desktop-services}, you can use @code{modify-services} to change
  3077. its configuration and add the URLs and substitute keys that you want
  3078. (@pxref{Service Reference, @code{modify-services}}).
  3079. As an example, suppose you want to fetch substitutes from
  3080. @code{guix.example.org} and to authorize the signing key of that server,
  3081. in addition to the default @code{@value{SUBSTITUTE-SERVER}}. The
  3082. resulting operating system configuration will look something like:
  3083. @lisp
  3084. (operating-system
  3085. ;; @dots{}
  3086. (services
  3087. ;; Assume we're starting from '%desktop-services'. Replace it
  3088. ;; with the list of services you're actually using.
  3089. (modify-services %desktop-services
  3090. (guix-service-type config =>
  3091. (guix-configuration
  3092. (inherit config)
  3093. (substitute-urls
  3094. (append (list "https://guix.example.org")
  3095. %default-substitute-urls))
  3096. (authorized-keys
  3097. (append (list (local-file "./key.pub"))
  3098. %default-authorized-guix-keys)))))))
  3099. @end lisp
  3100. This assumes that the file @file{key.pub} contains the signing key of
  3101. @code{guix.example.org}. With this change in place in your operating
  3102. system configuration file (say @file{/etc/config.scm}), you can
  3103. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3104. changes take effect:
  3105. @example
  3106. $ sudo guix system reconfigure /etc/config.scm
  3107. $ sudo herd restart guix-daemon
  3108. @end example
  3109. If you're running Guix on a ``foreign distro'', you would instead take
  3110. the following steps to get substitutes from additional servers:
  3111. @enumerate
  3112. @item
  3113. Edit the service configuration file for @code{guix-daemon}; when using
  3114. systemd, this is normally
  3115. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3116. @option{--substitute-urls} option on the @command{guix-daemon} command
  3117. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3118. @code{guix-daemon --substitute-urls}}):
  3119. @example
  3120. @dots{} --substitute-urls='https://guix.example.org https://@value{SUBSTITUTE-SERVER}'
  3121. @end example
  3122. @item
  3123. Restart the daemon. For systemd, it goes like this:
  3124. @example
  3125. systemctl daemon-reload
  3126. systemctl restart guix-daemon.service
  3127. @end example
  3128. @item
  3129. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3130. @example
  3131. guix archive --authorize < key.pub
  3132. @end example
  3133. Again this assumes @file{key.pub} contains the public key that
  3134. @code{guix.example.org} uses to sign substitutes.
  3135. @end enumerate
  3136. Now you're all set! Substitutes will be preferably taken from
  3137. @code{https://guix.example.org}, using @code{@value{SUBSTITUTE-SERVER}}
  3138. as a fallback. Of course you can list as many substitute servers as you
  3139. like, with the caveat that substitute lookup can be slowed down if too
  3140. many servers need to be contacted.
  3141. Note that there are also situations where one may want to add the URL of
  3142. a substitute server @emph{without} authorizing its key.
  3143. @xref{Substitute Authentication}, to understand this fine point.
  3144. @node Substitute Authentication
  3145. @subsection Substitute Authentication
  3146. @cindex digital signatures
  3147. Guix detects and raises an error when attempting to use a substitute
  3148. that has been tampered with. Likewise, it ignores substitutes that are
  3149. not signed, or that are not signed by one of the keys listed in the ACL.
  3150. There is one exception though: if an unauthorized server provides
  3151. substitutes that are @emph{bit-for-bit identical} to those provided by
  3152. an authorized server, then the unauthorized server becomes eligible for
  3153. downloads. For example, assume we have chosen two substitute servers
  3154. with this option:
  3155. @example
  3156. --substitute-urls="https://a.example.org https://b.example.org"
  3157. @end example
  3158. @noindent
  3159. @cindex reproducible builds
  3160. If the ACL contains only the key for @samp{b.example.org}, and if
  3161. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3162. then Guix will download substitutes from @samp{a.example.org} because it
  3163. comes first in the list and can be considered a mirror of
  3164. @samp{b.example.org}. In practice, independent build machines usually
  3165. produce the same binaries, thanks to bit-reproducible builds (see
  3166. below).
  3167. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3168. (in other words, the server is not authenticated), contrary to what
  3169. HTTPS clients such as Web browsers usually do. This is because Guix
  3170. authenticates substitute information itself, as explained above, which
  3171. is what we care about (whereas X.509 certificates are about
  3172. authenticating bindings between domain names and public keys).
  3173. @node Proxy Settings
  3174. @subsection Proxy Settings
  3175. @vindex http_proxy
  3176. @vindex https_proxy
  3177. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3178. @env{https_proxy} environment variables can be set in the environment of
  3179. @command{guix-daemon} and are honored for downloads of substitutes.
  3180. Note that the value of those environment variables in the environment
  3181. where @command{guix build}, @command{guix package}, and other client
  3182. commands are run has @emph{absolutely no effect}.
  3183. @node Substitution Failure
  3184. @subsection Substitution Failure
  3185. Even when a substitute for a derivation is available, sometimes the
  3186. substitution attempt will fail. This can happen for a variety of
  3187. reasons: the substitute server might be offline, the substitute may
  3188. recently have been deleted, the connection might have been interrupted,
  3189. etc.
  3190. When substitutes are enabled and a substitute for a derivation is
  3191. available, but the substitution attempt fails, Guix will attempt to
  3192. build the derivation locally depending on whether or not
  3193. @option{--fallback} was given (@pxref{fallback-option,, common build
  3194. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3195. omitted, then no local build will be performed, and the derivation is
  3196. considered to have failed. However, if @option{--fallback} was given,
  3197. then Guix will attempt to build the derivation locally, and the success
  3198. or failure of the derivation depends on the success or failure of the
  3199. local build. Note that when substitutes are disabled or no substitute
  3200. is available for the derivation in question, a local build will
  3201. @emph{always} be performed, regardless of whether or not
  3202. @option{--fallback} was given.
  3203. To get an idea of how many substitutes are available right now, you can
  3204. try running the @command{guix weather} command (@pxref{Invoking guix
  3205. weather}). This command provides statistics on the substitutes provided
  3206. by a server.
  3207. @node On Trusting Binaries
  3208. @subsection On Trusting Binaries
  3209. @cindex trust, of pre-built binaries
  3210. Today, each individual's control over their own computing is at the
  3211. mercy of institutions, corporations, and groups with enough power and
  3212. determination to subvert the computing infrastructure and exploit its
  3213. weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
  3214. convenient, we encourage users to also build on their own, or even run
  3215. their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
  3216. interesting target. One way to help is by publishing the software you
  3217. build using @command{guix publish} so that others have one more choice
  3218. of server to download substitutes from (@pxref{Invoking guix publish}).
  3219. Guix has the foundations to maximize build reproducibility
  3220. (@pxref{Features}). In most cases, independent builds of a given
  3221. package or derivation should yield bit-identical results. Thus, through
  3222. a diverse set of independent package builds, we can strengthen the
  3223. integrity of our systems. The @command{guix challenge} command aims to
  3224. help users assess substitute servers, and to assist developers in
  3225. finding out about non-deterministic package builds (@pxref{Invoking guix
  3226. challenge}). Similarly, the @option{--check} option of @command{guix
  3227. build} allows users to check whether previously-installed substitutes
  3228. are genuine by rebuilding them locally (@pxref{build-check,
  3229. @command{guix build --check}}).
  3230. In the future, we want Guix to have support to publish and retrieve
  3231. binaries to/from other users, in a peer-to-peer fashion. If you would
  3232. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3233. @node Packages with Multiple Outputs
  3234. @section Packages with Multiple Outputs
  3235. @cindex multiple-output packages
  3236. @cindex package outputs
  3237. @cindex outputs
  3238. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3239. source package leads to exactly one directory in the store. When running
  3240. @command{guix install glibc}, one installs the default output of the
  3241. GNU libc package; the default output is called @code{out}, but its name
  3242. can be omitted as shown in this command. In this particular case, the
  3243. default output of @code{glibc} contains all the C header files, shared
  3244. libraries, static libraries, Info documentation, and other supporting
  3245. files.
  3246. Sometimes it is more appropriate to separate the various types of files
  3247. produced from a single source package into separate outputs. For
  3248. instance, the GLib C library (used by GTK+ and related packages)
  3249. installs more than 20 MiB of reference documentation as HTML pages.
  3250. To save space for users who do not need it, the documentation goes to a
  3251. separate output, called @code{doc}. To install the main GLib output,
  3252. which contains everything but the documentation, one would run:
  3253. @example
  3254. guix install glib
  3255. @end example
  3256. @cindex documentation
  3257. The command to install its documentation is:
  3258. @example
  3259. guix install glib:doc
  3260. @end example
  3261. Some packages install programs with different ``dependency footprints''.
  3262. For instance, the WordNet package installs both command-line tools and
  3263. graphical user interfaces (GUIs). The former depend solely on the C
  3264. library, whereas the latter depend on Tcl/Tk and the underlying X
  3265. libraries. In this case, we leave the command-line tools in the default
  3266. output, whereas the GUIs are in a separate output. This allows users
  3267. who do not need the GUIs to save space. The @command{guix size} command
  3268. can help find out about such situations (@pxref{Invoking guix size}).
  3269. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3270. There are several such multiple-output packages in the GNU distribution.
  3271. Other conventional output names include @code{lib} for libraries and
  3272. possibly header files, @code{bin} for stand-alone programs, and
  3273. @code{debug} for debugging information (@pxref{Installing Debugging
  3274. Files}). The outputs of a packages are listed in the third column of
  3275. the output of @command{guix package --list-available} (@pxref{Invoking
  3276. guix package}).
  3277. @node Invoking guix gc
  3278. @section Invoking @command{guix gc}
  3279. @cindex garbage collector
  3280. @cindex disk space
  3281. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3282. The @command{guix gc} command allows users to explicitly run the garbage
  3283. collector to reclaim space from the @file{/gnu/store} directory. It is
  3284. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3285. files or directories manually may break it beyond repair!
  3286. @cindex GC roots
  3287. @cindex garbage collector roots
  3288. The garbage collector has a set of known @dfn{roots}: any file under
  3289. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3290. cannot be deleted; any other file is considered @dfn{dead} and may be
  3291. deleted. The set of garbage collector roots (``GC roots'' for short)
  3292. includes default user profiles; by default, the symlinks under
  3293. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3294. added with @command{guix build --root}, for example (@pxref{Invoking
  3295. guix build}). The @command{guix gc --list-roots} command lists them.
  3296. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3297. often useful to remove old generations from user profiles; that way, old
  3298. package builds referenced by those generations can be reclaimed. This
  3299. is achieved by running @code{guix package --delete-generations}
  3300. (@pxref{Invoking guix package}).
  3301. Our recommendation is to run a garbage collection periodically, or when
  3302. you are short on disk space. For instance, to guarantee that at least
  3303. 5@tie{}GB are available on your disk, simply run:
  3304. @example
  3305. guix gc -F 5G
  3306. @end example
  3307. It is perfectly safe to run as a non-interactive periodic job
  3308. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3309. Running @command{guix gc} with no arguments will collect as
  3310. much garbage as it can, but that is often inconvenient: you may find
  3311. yourself having to rebuild or re-download software that is ``dead'' from
  3312. the GC viewpoint but that is necessary to build other pieces of
  3313. software---e.g., the compiler tool chain.
  3314. The @command{guix gc} command has three modes of operation: it can be
  3315. used to garbage-collect any dead files (the default), to delete specific
  3316. files (the @option{--delete} option), to print garbage-collector
  3317. information, or for more advanced queries. The garbage collection
  3318. options are as follows:
  3319. @table @code
  3320. @item --collect-garbage[=@var{min}]
  3321. @itemx -C [@var{min}]
  3322. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3323. sub-directories. This is the default operation when no option is
  3324. specified.
  3325. When @var{min} is given, stop once @var{min} bytes have been collected.
  3326. @var{min} may be a number of bytes, or it may include a unit as a
  3327. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3328. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3329. When @var{min} is omitted, collect all the garbage.
  3330. @item --free-space=@var{free}
  3331. @itemx -F @var{free}
  3332. Collect garbage until @var{free} space is available under
  3333. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3334. as @code{500MiB}, as described above.
  3335. When @var{free} or more is already available in @file{/gnu/store}, do
  3336. nothing and exit immediately.
  3337. @item --delete-generations[=@var{duration}]
  3338. @itemx -d [@var{duration}]
  3339. Before starting the garbage collection process, delete all the generations
  3340. older than @var{duration}, for all the user profiles; when run as root, this
  3341. applies to all the profiles @emph{of all the users}.
  3342. For example, this command deletes all the generations of all your profiles
  3343. that are older than 2 months (except generations that are current), and then
  3344. proceeds to free space until at least 10 GiB are available:
  3345. @example
  3346. guix gc -d 2m -F 10G
  3347. @end example
  3348. @item --delete
  3349. @itemx -D
  3350. Attempt to delete all the store files and directories specified as
  3351. arguments. This fails if some of the files are not in the store, or if
  3352. they are still live.
  3353. @item --list-failures
  3354. List store items corresponding to cached build failures.
  3355. This prints nothing unless the daemon was started with
  3356. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3357. @option{--cache-failures}}).
  3358. @item --list-roots
  3359. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3360. roots.
  3361. @item --list-busy
  3362. List store items in use by currently running processes. These store
  3363. items are effectively considered GC roots: they cannot be deleted.
  3364. @item --clear-failures
  3365. Remove the specified store items from the failed-build cache.
  3366. Again, this option only makes sense when the daemon is started with
  3367. @option{--cache-failures}. Otherwise, it does nothing.
  3368. @item --list-dead
  3369. Show the list of dead files and directories still present in the
  3370. store---i.e., files and directories no longer reachable from any root.
  3371. @item --list-live
  3372. Show the list of live store files and directories.
  3373. @end table
  3374. In addition, the references among existing store files can be queried:
  3375. @table @code
  3376. @item --references
  3377. @itemx --referrers
  3378. @cindex package dependencies
  3379. List the references (respectively, the referrers) of store files given
  3380. as arguments.
  3381. @item --requisites
  3382. @itemx -R
  3383. @cindex closure
  3384. List the requisites of the store files passed as arguments. Requisites
  3385. include the store files themselves, their references, and the references
  3386. of these, recursively. In other words, the returned list is the
  3387. @dfn{transitive closure} of the store files.
  3388. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3389. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3390. the graph of references.
  3391. @item --derivers
  3392. @cindex derivation
  3393. Return the derivation(s) leading to the given store items
  3394. (@pxref{Derivations}).
  3395. For example, this command:
  3396. @example
  3397. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3398. @end example
  3399. @noindent
  3400. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3401. installed in your profile.
  3402. Note that there may be zero matching @file{.drv} files, for instance
  3403. because these files have been garbage-collected. There can also be more
  3404. than one matching @file{.drv} due to fixed-output derivations.
  3405. @end table
  3406. Lastly, the following options allow you to check the integrity of the
  3407. store and to control disk usage.
  3408. @table @option
  3409. @item --verify[=@var{options}]
  3410. @cindex integrity, of the store
  3411. @cindex integrity checking
  3412. Verify the integrity of the store.
  3413. By default, make sure that all the store items marked as valid in the
  3414. database of the daemon actually exist in @file{/gnu/store}.
  3415. When provided, @var{options} must be a comma-separated list containing one
  3416. or more of @code{contents} and @code{repair}.
  3417. When passing @option{--verify=contents}, the daemon computes the
  3418. content hash of each store item and compares it against its hash in the
  3419. database. Hash mismatches are reported as data corruptions. Because it
  3420. traverses @emph{all the files in the store}, this command can take a
  3421. long time, especially on systems with a slow disk drive.
  3422. @cindex repairing the store
  3423. @cindex corruption, recovering from
  3424. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3425. causes the daemon to try to repair corrupt store items by fetching
  3426. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3427. atomic, and thus potentially dangerous, it is available only to the
  3428. system administrator. A lightweight alternative, when you know exactly
  3429. which items in the store are corrupt, is @command{guix build --repair}
  3430. (@pxref{Invoking guix build}).
  3431. @item --optimize
  3432. @cindex deduplication
  3433. Optimize the store by hard-linking identical files---this is
  3434. @dfn{deduplication}.
  3435. The daemon performs deduplication after each successful build or archive
  3436. import, unless it was started with @option{--disable-deduplication}
  3437. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3438. this option is primarily useful when the daemon was running with
  3439. @option{--disable-deduplication}.
  3440. @end table
  3441. @node Invoking guix pull
  3442. @section Invoking @command{guix pull}
  3443. @cindex upgrading Guix
  3444. @cindex updating Guix
  3445. @cindex @command{guix pull}
  3446. @cindex pull
  3447. @cindex security, @command{guix pull}
  3448. @cindex authenticity, of code obtained with @command{guix pull}
  3449. Packages are installed or upgraded to the latest version available in
  3450. the distribution currently available on your local machine. To update
  3451. that distribution, along with the Guix tools, you must run @command{guix
  3452. pull}: the command downloads the latest Guix source code and package
  3453. descriptions, and deploys it. Source code is downloaded from a
  3454. @uref{https://git-scm.com, Git} repository, by default the official
  3455. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3456. pull} ensures that the code it downloads is @emph{authentic} by
  3457. verifying that commits are signed by Guix developers.
  3458. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3459. (@pxref{Channels}) specified by one of the followings, in this order:
  3460. @enumerate
  3461. @item
  3462. the @option{--channels} option;
  3463. @item
  3464. the user's @file{~/.config/guix/channels.scm} file;
  3465. @item
  3466. the system-wide @file{/etc/guix/channels.scm} file;
  3467. @item
  3468. the built-in default channels specified in the @code{%default-channels}
  3469. variable.
  3470. @end enumerate
  3471. On completion, @command{guix package} will use packages and package
  3472. versions from this just-retrieved copy of Guix. Not only that, but all
  3473. the Guix commands and Scheme modules will also be taken from that latest
  3474. version. New @command{guix} sub-commands added by the update also
  3475. become available.
  3476. Any user can update their Guix copy using @command{guix pull}, and the
  3477. effect is limited to the user who ran @command{guix pull}. For
  3478. instance, when user @code{root} runs @command{guix pull}, this has no
  3479. effect on the version of Guix that user @code{alice} sees, and vice
  3480. versa.
  3481. The result of running @command{guix pull} is a @dfn{profile} available
  3482. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3483. make sure to add it to the beginning of your search path so that you use
  3484. the latest version, and similarly for the Info manual
  3485. (@pxref{Documentation}):
  3486. @example
  3487. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3488. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3489. @end example
  3490. The @option{--list-generations} or @option{-l} option lists past generations
  3491. produced by @command{guix pull}, along with details about their provenance:
  3492. @example
  3493. $ guix pull -l
  3494. Generation 1 Jun 10 2018 00:18:18
  3495. guix 65956ad
  3496. repository URL: https://git.savannah.gnu.org/git/guix.git
  3497. branch: origin/master
  3498. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3499. Generation 2 Jun 11 2018 11:02:49
  3500. guix e0cc7f6
  3501. repository URL: https://git.savannah.gnu.org/git/guix.git
  3502. branch: origin/master
  3503. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3504. 2 new packages: keepalived, libnfnetlink
  3505. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3506. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3507. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3508. Generation 3 Jun 13 2018 23:31:07 (current)
  3509. guix 844cc1c
  3510. repository URL: https://git.savannah.gnu.org/git/guix.git
  3511. branch: origin/master
  3512. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3513. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3514. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3515. @end example
  3516. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3517. describe the current status of Guix.
  3518. This @code{~/.config/guix/current} profile works exactly like the profiles
  3519. created by @command{guix package} (@pxref{Invoking guix package}). That
  3520. is, you can list generations, roll back to the previous
  3521. generation---i.e., the previous Guix---and so on:
  3522. @example
  3523. $ guix pull --roll-back
  3524. switched from generation 3 to 2
  3525. $ guix pull --delete-generations=1
  3526. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3527. @end example
  3528. You can also use @command{guix package} (@pxref{Invoking guix package})
  3529. to manage the profile by naming it explicitly:
  3530. @example
  3531. $ guix package -p ~/.config/guix/current --roll-back
  3532. switched from generation 3 to 2
  3533. $ guix package -p ~/.config/guix/current --delete-generations=1
  3534. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3535. @end example
  3536. The @command{guix pull} command is usually invoked with no arguments,
  3537. but it supports the following options:
  3538. @table @code
  3539. @item --url=@var{url}
  3540. @itemx --commit=@var{commit}
  3541. @itemx --branch=@var{branch}
  3542. Download code for the @code{guix} channel from the specified @var{url}, at the
  3543. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3544. string), or @var{branch}.
  3545. @cindex @file{channels.scm}, configuration file
  3546. @cindex configuration file for channels
  3547. These options are provided for convenience, but you can also specify your
  3548. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3549. @option{--channels} option (see below).
  3550. @item --channels=@var{file}
  3551. @itemx -C @var{file}
  3552. Read the list of channels from @var{file} instead of
  3553. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3554. @var{file} must contain Scheme code that
  3555. evaluates to a list of channel objects. @xref{Channels}, for more
  3556. information.
  3557. @cindex channel news
  3558. @item --news
  3559. @itemx -N
  3560. Display the list of packages added or upgraded since the previous
  3561. generation, as well as, occasionally, news written by channel authors
  3562. for their users (@pxref{Channels, Writing Channel News}).
  3563. The package information is the same as displayed upon @command{guix
  3564. pull} completion, but without ellipses; it is also similar to the output
  3565. of @command{guix pull -l} for the last generation (see below).
  3566. @item --list-generations[=@var{pattern}]
  3567. @itemx -l [@var{pattern}]
  3568. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3569. is provided, the subset of generations that match @var{pattern}.
  3570. The syntax of @var{pattern} is the same as with @code{guix package
  3571. --list-generations} (@pxref{Invoking guix package}).
  3572. @item --roll-back
  3573. @cindex rolling back
  3574. @cindex undoing transactions
  3575. @cindex transactions, undoing
  3576. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3577. undo the last transaction.
  3578. @item --switch-generation=@var{pattern}
  3579. @itemx -S @var{pattern}
  3580. @cindex generations
  3581. Switch to a particular generation defined by @var{pattern}.
  3582. @var{pattern} may be either a generation number or a number prefixed
  3583. with ``+'' or ``-''. The latter means: move forward/backward by a
  3584. specified number of generations. For example, if you want to return to
  3585. the latest generation after @option{--roll-back}, use
  3586. @option{--switch-generation=+1}.
  3587. @item --delete-generations[=@var{pattern}]
  3588. @itemx -d [@var{pattern}]
  3589. When @var{pattern} is omitted, delete all generations except the current
  3590. one.
  3591. This command accepts the same patterns as @option{--list-generations}.
  3592. When @var{pattern} is specified, delete the matching generations. When
  3593. @var{pattern} specifies a duration, generations @emph{older} than the
  3594. specified duration match. For instance, @option{--delete-generations=1m}
  3595. deletes generations that are more than one month old.
  3596. If the current generation matches, it is @emph{not} deleted.
  3597. Note that deleting generations prevents rolling back to them.
  3598. Consequently, this command must be used with care.
  3599. @xref{Invoking guix describe}, for a way to display information about the
  3600. current generation only.
  3601. @item --profile=@var{profile}
  3602. @itemx -p @var{profile}
  3603. Use @var{profile} instead of @file{~/.config/guix/current}.
  3604. @item --dry-run
  3605. @itemx -n
  3606. Show which channel commit(s) would be used and what would be built or
  3607. substituted but do not actually do it.
  3608. @item --allow-downgrades
  3609. Allow pulling older or unrelated revisions of channels than those
  3610. currently in use.
  3611. @cindex downgrade attacks, protection against
  3612. By default, @command{guix pull} protects against so-called ``downgrade
  3613. attacks'' whereby the Git repository of a channel would be reset to an
  3614. earlier or unrelated revision of itself, potentially leading you to
  3615. install older, known-vulnerable versions of software packages.
  3616. @quotation Note
  3617. Make sure you understand its security implications before using
  3618. @option{--allow-downgrades}.
  3619. @end quotation
  3620. @item --disable-authentication
  3621. Allow pulling channel code without authenticating it.
  3622. @cindex authentication, of channel code
  3623. By default, @command{guix pull} authenticates code downloaded from
  3624. channels by verifying that its commits are signed by authorized
  3625. developers, and raises an error if this is not the case. This option
  3626. instructs it to not perform any such verification.
  3627. @quotation Note
  3628. Make sure you understand its security implications before using
  3629. @option{--disable-authentication}.
  3630. @end quotation
  3631. @item --system=@var{system}
  3632. @itemx -s @var{system}
  3633. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3634. the system type of the build host.
  3635. @item --bootstrap
  3636. Use the bootstrap Guile to build the latest Guix. This option is only
  3637. useful to Guix developers.
  3638. @end table
  3639. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3640. repository and branch to pull from, as well as @emph{additional} repositories
  3641. containing package modules that should be deployed. @xref{Channels}, for more
  3642. information.
  3643. In addition, @command{guix pull} supports all the common build options
  3644. (@pxref{Common Build Options}).
  3645. @node Invoking guix time-machine
  3646. @section Invoking @command{guix time-machine}
  3647. @cindex @command{guix time-machine}
  3648. @cindex pinning, channels
  3649. @cindex replicating Guix
  3650. @cindex reproducibility, of Guix
  3651. The @command{guix time-machine} command provides access to other
  3652. revisions of Guix, for example to install older versions of packages,
  3653. or to reproduce a computation in an identical environment. The revision
  3654. of Guix to be used is defined by a commit or by a channel
  3655. description file created by @command{guix describe}
  3656. (@pxref{Invoking guix describe}).
  3657. The general syntax is:
  3658. @example
  3659. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3660. @end example
  3661. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3662. @command{guix} command of the specified revision. The @var{options} that define
  3663. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3664. @table @code
  3665. @item --url=@var{url}
  3666. @itemx --commit=@var{commit}
  3667. @itemx --branch=@var{branch}
  3668. Use the @code{guix} channel from the specified @var{url}, at the
  3669. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3670. string), or @var{branch}.
  3671. @item --channels=@var{file}
  3672. @itemx -C @var{file}
  3673. Read the list of channels from @var{file}. @var{file} must contain
  3674. Scheme code that evaluates to a list of channel objects.
  3675. @xref{Channels} for more information.
  3676. @end table
  3677. As for @command{guix pull}, the absence of any options means that the
  3678. latest commit on the master branch will be used. The command
  3679. @example
  3680. guix time-machine -- build hello
  3681. @end example
  3682. will thus build the package @code{hello} as defined in the master branch,
  3683. which is in general a newer revision of Guix than you have installed.
  3684. Time travel works in both directions!
  3685. Note that @command{guix time-machine} can trigger builds of channels and
  3686. their dependencies, and these are controlled by the standard build
  3687. options (@pxref{Common Build Options}).
  3688. @node Inferiors
  3689. @section Inferiors
  3690. @c TODO: Remove this once we're more confident about API stability.
  3691. @quotation Note
  3692. The functionality described here is a ``technology preview'' as of version
  3693. @value{VERSION}. As such, the interface is subject to change.
  3694. @end quotation
  3695. @cindex inferiors
  3696. @cindex composition of Guix revisions
  3697. Sometimes you might need to mix packages from the revision of Guix you're
  3698. currently running with packages available in a different revision of Guix.
  3699. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3700. revisions in arbitrary ways.
  3701. @cindex inferior packages
  3702. Technically, an ``inferior'' is essentially a separate Guix process connected
  3703. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3704. @code{(guix inferior)} module allows you to create inferiors and to
  3705. communicate with them. It also provides a high-level interface to browse and
  3706. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3707. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3708. to interact with a separate revision of Guix. For example, let's assume you
  3709. want to install in your profile the current @code{guile} package, along with
  3710. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3711. because the newer @code{guile-json} has an incompatible API and you want to
  3712. run your code against the old API@. To do that, you could write a manifest for
  3713. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3714. manifest, you would create an inferior for that old Guix revision you care
  3715. about, and you would look up the @code{guile-json} package in the inferior:
  3716. @lisp
  3717. (use-modules (guix inferior) (guix channels)
  3718. (srfi srfi-1)) ;for 'first'
  3719. (define channels
  3720. ;; This is the old revision from which we want to
  3721. ;; extract guile-json.
  3722. (list (channel
  3723. (name 'guix)
  3724. (url "https://git.savannah.gnu.org/git/guix.git")
  3725. (commit
  3726. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3727. (define inferior
  3728. ;; An inferior representing the above revision.
  3729. (inferior-for-channels channels))
  3730. ;; Now create a manifest with the current "guile" package
  3731. ;; and the old "guile-json" package.
  3732. (packages->manifest
  3733. (list (first (lookup-inferior-packages inferior "guile-json"))
  3734. (specification->package "guile")))
  3735. @end lisp
  3736. On its first run, @command{guix package --manifest} might have to build the
  3737. channel you specified before it can create the inferior; subsequent runs will
  3738. be much faster because the Guix revision will be cached.
  3739. The @code{(guix inferior)} module provides the following procedures to open an
  3740. inferior:
  3741. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3742. [#:cache-directory] [#:ttl]
  3743. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3744. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3745. This procedure opens a new connection to the build daemon.
  3746. As a side effect, this procedure may build or substitute binaries for
  3747. @var{channels}, which can take time.
  3748. @end deffn
  3749. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3750. [#:command "bin/guix"]
  3751. Open the inferior Guix in @var{directory}, running
  3752. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3753. the inferior could not be launched.
  3754. @end deffn
  3755. @cindex inferior packages
  3756. The procedures listed below allow you to obtain and manipulate inferior
  3757. packages.
  3758. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3759. Return the list of packages known to @var{inferior}.
  3760. @end deffn
  3761. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3762. [@var{version}]
  3763. Return the sorted list of inferior packages matching @var{name} in
  3764. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3765. return only packages with a version number prefixed by @var{version}.
  3766. @end deffn
  3767. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3768. Return true if @var{obj} is an inferior package.
  3769. @end deffn
  3770. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3771. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3772. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3773. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3774. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3775. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3776. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3777. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3778. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3779. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3780. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3781. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3782. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3783. These procedures are the counterpart of package record accessors
  3784. (@pxref{package Reference}). Most of them work by querying the inferior
  3785. @var{package} comes from, so the inferior must still be live when you call
  3786. these procedures.
  3787. @end deffn
  3788. Inferior packages can be used transparently like any other package or
  3789. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3790. transparently handled by the @code{packages->manifest} procedure, which is
  3791. commonly used in manifests (@pxref{Invoking guix package, the
  3792. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3793. an inferior package pretty much anywhere you would insert a regular package:
  3794. in manifests, in the @code{packages} field of your @code{operating-system}
  3795. declaration, and so on.
  3796. @node Invoking guix describe
  3797. @section Invoking @command{guix describe}
  3798. @cindex reproducibility
  3799. @cindex replicating Guix
  3800. Often you may want to answer questions like: ``Which revision of Guix am I
  3801. using?'' or ``Which channels am I using?'' This is useful information in many
  3802. situations: if you want to @emph{replicate} an environment on a different
  3803. machine or user account, if you want to report a bug or to determine what
  3804. change in the channels you are using caused it, or if you want to record your
  3805. system state for reproducibility purposes. The @command{guix describe}
  3806. command answers these questions.
  3807. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3808. displays the channel(s) that it was built from, including their repository URL
  3809. and commit IDs (@pxref{Channels}):
  3810. @example
  3811. $ guix describe
  3812. Generation 10 Sep 03 2018 17:32:44 (current)
  3813. guix e0fa68c
  3814. repository URL: https://git.savannah.gnu.org/git/guix.git
  3815. branch: master
  3816. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3817. @end example
  3818. If you're familiar with the Git version control system, this is similar in
  3819. spirit to @command{git describe}; the output is also similar to that of
  3820. @command{guix pull --list-generations}, but limited to the current generation
  3821. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3822. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3823. information is all it takes to describe the revision of Guix you're using, and
  3824. also to replicate it.
  3825. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3826. to return a list of channels instead of the human-readable description above:
  3827. @example
  3828. $ guix describe -f channels
  3829. (list (channel
  3830. (name 'guix)
  3831. (url "https://git.savannah.gnu.org/git/guix.git")
  3832. (commit
  3833. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3834. (introduction
  3835. (make-channel-introduction
  3836. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3837. (openpgp-fingerprint
  3838. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3839. @end example
  3840. @noindent
  3841. You can save this to a file and feed it to @command{guix pull -C} on some
  3842. other machine or at a later point in time, which will instantiate @emph{this
  3843. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3844. From there on, since you're able to deploy the same revision of Guix, you can
  3845. just as well @emph{replicate a complete software environment}. We humbly
  3846. think that this is @emph{awesome}, and we hope you'll like it too!
  3847. The details of the options supported by @command{guix describe} are as
  3848. follows:
  3849. @table @code
  3850. @item --format=@var{format}
  3851. @itemx -f @var{format}
  3852. Produce output in the specified @var{format}, one of:
  3853. @table @code
  3854. @item human
  3855. produce human-readable output;
  3856. @item channels
  3857. produce a list of channel specifications that can be passed to @command{guix
  3858. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3859. guix pull});
  3860. @item channels-sans-intro
  3861. like @code{channels}, but omit the @code{introduction} field; use it to
  3862. produce a channel specification suitable for Guix version 1.1.0 or
  3863. earlier---the @code{introduction} field has to do with channel
  3864. authentication (@pxref{Channels, Channel Authentication}) and is not
  3865. supported by these older versions;
  3866. @item json
  3867. @cindex JSON
  3868. produce a list of channel specifications in JSON format;
  3869. @item recutils
  3870. produce a list of channel specifications in Recutils format.
  3871. @end table
  3872. @item --list-formats
  3873. Display available formats for @option{--format} option.
  3874. @item --profile=@var{profile}
  3875. @itemx -p @var{profile}
  3876. Display information about @var{profile}.
  3877. @end table
  3878. @node Invoking guix archive
  3879. @section Invoking @command{guix archive}
  3880. @cindex @command{guix archive}
  3881. @cindex archive
  3882. The @command{guix archive} command allows users to @dfn{export} files
  3883. from the store into a single archive, and to later @dfn{import} them on
  3884. a machine that runs Guix.
  3885. In particular, it allows store files to be transferred from one machine
  3886. to the store on another machine.
  3887. @quotation Note
  3888. If you're looking for a way to produce archives in a format suitable for
  3889. tools other than Guix, @pxref{Invoking guix pack}.
  3890. @end quotation
  3891. @cindex exporting store items
  3892. To export store files as an archive to standard output, run:
  3893. @example
  3894. guix archive --export @var{options} @var{specifications}...
  3895. @end example
  3896. @var{specifications} may be either store file names or package
  3897. specifications, as for @command{guix package} (@pxref{Invoking guix
  3898. package}). For instance, the following command creates an archive
  3899. containing the @code{gui} output of the @code{git} package and the main
  3900. output of @code{emacs}:
  3901. @example
  3902. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3903. @end example
  3904. If the specified packages are not built yet, @command{guix archive}
  3905. automatically builds them. The build process may be controlled with the
  3906. common build options (@pxref{Common Build Options}).
  3907. To transfer the @code{emacs} package to a machine connected over SSH,
  3908. one would run:
  3909. @example
  3910. guix archive --export -r emacs | ssh the-machine guix archive --import
  3911. @end example
  3912. @noindent
  3913. Similarly, a complete user profile may be transferred from one machine
  3914. to another like this:
  3915. @example
  3916. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3917. ssh the-machine guix archive --import
  3918. @end example
  3919. @noindent
  3920. However, note that, in both examples, all of @code{emacs} and the
  3921. profile as well as all of their dependencies are transferred (due to
  3922. @option{-r}), regardless of what is already available in the store on
  3923. the target machine. The @option{--missing} option can help figure out
  3924. which items are missing from the target store. The @command{guix copy}
  3925. command simplifies and optimizes this whole process, so this is probably
  3926. what you should use in this case (@pxref{Invoking guix copy}).
  3927. @cindex nar, archive format
  3928. @cindex normalized archive (nar)
  3929. @cindex nar bundle, archive format
  3930. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3931. format (described below), and the output of @command{guix archive
  3932. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3933. bundle}.
  3934. The nar format is
  3935. comparable in spirit to `tar', but with differences
  3936. that make it more appropriate for our purposes. First, rather than
  3937. recording all Unix metadata for each file, the nar format only mentions
  3938. the file type (regular, directory, or symbolic link); Unix permissions
  3939. and owner/group are dismissed. Second, the order in which directory
  3940. entries are stored always follows the order of file names according to
  3941. the C locale collation order. This makes archive production fully
  3942. deterministic.
  3943. That nar bundle format is essentially the concatenation of zero or more
  3944. nars along with metadata for each store item it contains: its file name,
  3945. references, corresponding derivation, and a digital signature.
  3946. When exporting, the daemon digitally signs the contents of the archive,
  3947. and that digital signature is appended. When importing, the daemon
  3948. verifies the signature and rejects the import in case of an invalid
  3949. signature or if the signing key is not authorized.
  3950. @c FIXME: Add xref to daemon doc about signatures.
  3951. The main options are:
  3952. @table @code
  3953. @item --export
  3954. Export the specified store files or packages (see below). Write the
  3955. resulting archive to the standard output.
  3956. Dependencies are @emph{not} included in the output, unless
  3957. @option{--recursive} is passed.
  3958. @item -r
  3959. @itemx --recursive
  3960. When combined with @option{--export}, this instructs @command{guix archive}
  3961. to include dependencies of the given items in the archive. Thus, the
  3962. resulting archive is self-contained: it contains the closure of the
  3963. exported store items.
  3964. @item --import
  3965. Read an archive from the standard input, and import the files listed
  3966. therein into the store. Abort if the archive has an invalid digital
  3967. signature, or if it is signed by a public key not among the authorized
  3968. keys (see @option{--authorize} below).
  3969. @item --missing
  3970. Read a list of store file names from the standard input, one per line,
  3971. and write on the standard output the subset of these files missing from
  3972. the store.
  3973. @item --generate-key[=@var{parameters}]
  3974. @cindex signing, archives
  3975. Generate a new key pair for the daemon. This is a prerequisite before
  3976. archives can be exported with @option{--export}. This
  3977. operation is usually instantaneous but it can take time if the system's
  3978. entropy pool needs to be refilled. On Guix System,
  3979. @code{guix-service-type} takes care of generating this key pair the
  3980. first boot.
  3981. The generated key pair is typically stored under @file{/etc/guix}, in
  3982. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  3983. key, which must be kept secret). When @var{parameters} is omitted,
  3984. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  3985. versions before 1.6.0, it is a 4096-bit RSA key.
  3986. Alternatively, @var{parameters} can specify
  3987. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  3988. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  3989. Libgcrypt Reference Manual}).
  3990. @item --authorize
  3991. @cindex authorizing, archives
  3992. Authorize imports signed by the public key passed on standard input.
  3993. The public key must be in ``s-expression advanced format''---i.e., the
  3994. same format as the @file{signing-key.pub} file.
  3995. The list of authorized keys is kept in the human-editable file
  3996. @file{/etc/guix/acl}. The file contains
  3997. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  3998. s-expressions''} and is structured as an access-control list in the
  3999. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  4000. (SPKI)}.
  4001. @item --extract=@var{directory}
  4002. @itemx -x @var{directory}
  4003. Read a single-item archive as served by substitute servers
  4004. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4005. low-level operation needed in only very narrow use cases; see below.
  4006. For example, the following command extracts the substitute for Emacs
  4007. served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
  4008. @example
  4009. $ wget -O - \
  4010. https://@value{SUBSTITUTE-SERVER}/nar/gzip/@dots{}-emacs-24.5 \
  4011. | gunzip | guix archive -x /tmp/emacs
  4012. @end example
  4013. Single-item archives are different from multiple-item archives produced
  4014. by @command{guix archive --export}; they contain a single store item,
  4015. and they do @emph{not} embed a signature. Thus this operation does
  4016. @emph{no} signature verification and its output should be considered
  4017. unsafe.
  4018. The primary purpose of this operation is to facilitate inspection of
  4019. archive contents coming from possibly untrusted substitute servers
  4020. (@pxref{Invoking guix challenge}).
  4021. @item --list
  4022. @itemx -t
  4023. Read a single-item archive as served by substitute servers
  4024. (@pxref{Substitutes}) and print the list of files it contains, as in
  4025. this example:
  4026. @example
  4027. $ wget -O - \
  4028. https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-emacs-26.3 \
  4029. | lzip -d | guix archive -t
  4030. @end example
  4031. @end table
  4032. @c *********************************************************************
  4033. @node Channels
  4034. @chapter Channels
  4035. @cindex channels
  4036. @cindex @file{channels.scm}, configuration file
  4037. @cindex configuration file for channels
  4038. @cindex @command{guix pull}, configuration file
  4039. @cindex configuration of @command{guix pull}
  4040. Guix and its package collection are updated by running @command{guix pull}
  4041. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4042. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4043. customized by defining @dfn{channels} in the
  4044. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4045. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4046. to pull from one or more channels. In other words, channels can be used
  4047. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4048. Guix is able to take into account security concerns and deal with authenticated
  4049. updates.
  4050. @menu
  4051. * Specifying Additional Channels:: Extending the package collection.
  4052. * Using a Custom Guix Channel:: Using a customized Guix.
  4053. * Replicating Guix:: Running the @emph{exact same} Guix.
  4054. * Channel Authentication:: How Guix verifies what it fetches.
  4055. * Channels with Substitutes:: Using channels with available substitutes.
  4056. * Creating a Channel:: How to write your custom channel.
  4057. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4058. * Declaring Channel Dependencies:: How to depend on other channels.
  4059. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4060. * Primary URL:: Distinguishing mirror to original.
  4061. * Writing Channel News:: Communicating information to channel's users.
  4062. @end menu
  4063. @node Specifying Additional Channels
  4064. @section Specifying Additional Channels
  4065. @cindex extending the package collection (channels)
  4066. @cindex variant packages (channels)
  4067. You can specify @emph{additional channels} to pull from. To use a channel, write
  4068. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4069. @emph{in addition} to the default Guix channel(s):
  4070. @vindex %default-channels
  4071. @lisp
  4072. ;; Add variant packages to those Guix provides.
  4073. (cons (channel
  4074. (name 'variant-packages)
  4075. (url "https://example.org/variant-packages.git"))
  4076. %default-channels)
  4077. @end lisp
  4078. @noindent
  4079. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4080. add a channel the list of channels that the variable @code{%default-channels}
  4081. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4082. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4083. but also the package modules from your own repository. The result in
  4084. @file{~/.config/guix/current} is the union of Guix with your own package
  4085. modules:
  4086. @example
  4087. $ guix pull --list-generations
  4088. @dots{}
  4089. Generation 19 Aug 27 2018 16:20:48
  4090. guix d894ab8
  4091. repository URL: https://git.savannah.gnu.org/git/guix.git
  4092. branch: master
  4093. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4094. variant-packages dd3df5e
  4095. repository URL: https://example.org/variant-packages.git
  4096. branch: master
  4097. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4098. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4099. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4100. @end example
  4101. @noindent
  4102. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4103. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4104. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4105. @code{variant-emacs-with-cool-features} might come from
  4106. @code{variant-packages}, while others come from the Guix default channel.
  4107. @node Using a Custom Guix Channel
  4108. @section Using a Custom Guix Channel
  4109. The channel called @code{guix} specifies where Guix itself---its command-line
  4110. tools as well as its package collection---should be downloaded. For instance,
  4111. suppose you want to update from another copy of the Guix repository at
  4112. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4113. write in @code{~/.config/guix/channels.scm} this specification:
  4114. @lisp
  4115. ;; Tell 'guix pull' to use another repo.
  4116. (list (channel
  4117. (name 'guix)
  4118. (url "https://example.org/another-guix.git")
  4119. (branch "super-hacks")))
  4120. @end lisp
  4121. @noindent
  4122. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4123. branch of the repository at @code{example.org}. The authentication concern is
  4124. addressed below ((@pxref{Channel Authentication}).
  4125. @node Replicating Guix
  4126. @section Replicating Guix
  4127. @cindex pinning, channels
  4128. @cindex replicating Guix
  4129. @cindex reproducibility, of Guix
  4130. The @command{guix pull --list-generations} output above shows precisely which
  4131. commits were used to build this instance of Guix. We can thus replicate it,
  4132. say, on another machine, by providing a channel specification in
  4133. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4134. @lisp
  4135. ;; Deploy specific commits of my channels of interest.
  4136. (list (channel
  4137. (name 'guix)
  4138. (url "https://git.savannah.gnu.org/git/guix.git")
  4139. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4140. (channel
  4141. (name 'variant-packages)
  4142. (url "https://example.org/variant-packages.git")
  4143. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4144. @end lisp
  4145. The @command{guix describe --format=channels} command can even generate this
  4146. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4147. file can be used with the -C options of @command{guix pull}
  4148. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4149. (@pxref{Invoking guix time-machine}).
  4150. At this point the two machines run the @emph{exact same Guix}, with access to
  4151. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4152. one machine will be exactly the same, bit for bit, as the output of the same
  4153. command on the other machine. It also means both machines have access to all
  4154. the source code of Guix and, transitively, to all the source code of every
  4155. package it defines.
  4156. This gives you super powers, allowing you to track the provenance of binary
  4157. artifacts with very fine grain, and to reproduce software environments at
  4158. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4159. @xref{Inferiors}, for another way to take advantage of these super powers.
  4160. @node Channel Authentication
  4161. @section Channel Authentication
  4162. @anchor{channel-authentication}
  4163. @cindex authentication, of channel code
  4164. The @command{guix pull} and @command{guix time-machine} commands
  4165. @dfn{authenticate} the code retrieved from channels: they make sure each
  4166. commit that is fetched is signed by an authorized developer. The goal
  4167. is to protect from unauthorized modifications to the channel that would
  4168. lead users to run malicious code.
  4169. As a user, you must provide a @dfn{channel introduction} in your
  4170. channels file so that Guix knows how to authenticate its first commit.
  4171. A channel specification, including its introduction, looks something
  4172. along these lines:
  4173. @lisp
  4174. (channel
  4175. (name 'some-channel)
  4176. (url "https://example.org/some-channel.git")
  4177. (introduction
  4178. (make-channel-introduction
  4179. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4180. (openpgp-fingerprint
  4181. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4182. @end lisp
  4183. The specification above shows the name and URL of the channel. The call
  4184. to @code{make-channel-introduction} above specifies that authentication
  4185. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4186. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4187. For the main channel, called @code{guix}, you automatically get that
  4188. information from your Guix installation. For other channels, include
  4189. the channel introduction provided by the channel authors in your
  4190. @file{channels.scm} file. Make sure you retrieve the channel
  4191. introduction from a trusted source since that is the root of your trust.
  4192. If you're curious about the authentication mechanics, read on!
  4193. @node Channels with Substitutes
  4194. @section Channels with Substitutes
  4195. When running @command{guix pull}, Guix will first compile the
  4196. definitions of every available package. This is an expensive operation
  4197. for which substitutes (@pxref{Substitutes}) may be available. The
  4198. following snippet in @file{channels.scm} will ensure that @command{guix
  4199. pull} uses the latest commit with available substitutes for the package
  4200. definitions: this is done by querying the continuous integration
  4201. server at @url{https://ci.guix.gnu.org}.
  4202. @lisp
  4203. (use-modules (guix ci))
  4204. (list (channel-with-substitutes-available
  4205. %default-guix-channel
  4206. "https://ci.guix.gnu.org"))
  4207. @end lisp
  4208. Note that this does not mean that all the packages that you will
  4209. install after running @command{guix pull} will have available
  4210. substitutes. It only ensures that @command{guix pull} will not try to
  4211. compile package definitions. This is particularly useful when using
  4212. machines with limited resources.
  4213. @node Creating a Channel
  4214. @section Creating a Channel
  4215. @cindex personal packages (channels)
  4216. @cindex channels, for personal packages
  4217. Let's say you have a bunch of custom package variants or personal packages
  4218. that you think would make little sense to contribute to the Guix project, but
  4219. would like to have these packages transparently available to you at the
  4220. command line. You would first write modules containing those package
  4221. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4222. then you and anyone else can use it as an additional channel to get packages
  4223. from. Neat, no?
  4224. @c What follows stems from discussions at
  4225. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4226. @c earlier discussions on guix-devel@gnu.org.
  4227. @quotation Warning
  4228. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4229. publish your personal channel to the world, we would like to share a few words
  4230. of caution:
  4231. @itemize
  4232. @item
  4233. Before publishing a channel, please consider contributing your package
  4234. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4235. to free software of all sorts, and packages in Guix proper are readily
  4236. available to all Guix users and benefit from the project's quality assurance
  4237. process.
  4238. @item
  4239. When you maintain package definitions outside Guix, we, Guix developers,
  4240. consider that @emph{the compatibility burden is on you}. Remember that
  4241. package modules and package definitions are just Scheme code that uses various
  4242. programming interfaces (APIs). We want to remain free to change these APIs to
  4243. keep improving Guix, possibly in ways that break your channel. We never
  4244. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4245. either.
  4246. @item
  4247. Corollary: if you're using an external channel and that channel breaks, please
  4248. @emph{report the issue to the channel authors}, not to the Guix project.
  4249. @end itemize
  4250. You've been warned! Having said this, we believe external channels are a
  4251. practical way to exert your freedom to augment Guix' package collection and to
  4252. share your improvements, which are basic tenets of
  4253. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4254. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4255. @end quotation
  4256. To create a channel, create a Git repository containing your own package
  4257. modules and make it available. The repository can contain anything, but a
  4258. useful channel will contain Guile modules that export packages. Once you
  4259. start using a channel, Guix will behave as if the root directory of that
  4260. channel's Git repository has been added to the Guile load path (@pxref{Load
  4261. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4262. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4263. module, then the module will be available under the name @code{(my-packages
  4264. my-tools)}, and you will be able to use it like any other module
  4265. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4266. As a channel author, consider bundling authentication material with your
  4267. channel so that users can authenticate it. @xref{Channel
  4268. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4269. on how to do it.
  4270. @node Package Modules in a Sub-directory
  4271. @section Package Modules in a Sub-directory
  4272. @cindex subdirectory, channels
  4273. As a channel author, you may want to keep your channel modules in a
  4274. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4275. add a meta-data file @file{.guix-channel} that contains:
  4276. @lisp
  4277. (channel
  4278. (version 0)
  4279. (directory "guix"))
  4280. @end lisp
  4281. @node Declaring Channel Dependencies
  4282. @section Declaring Channel Dependencies
  4283. @cindex dependencies, channels
  4284. @cindex meta-data, channels
  4285. Channel authors may decide to augment a package collection provided by other
  4286. channels. They can declare their channel to be dependent on other channels in
  4287. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4288. the channel repository.
  4289. The meta-data file should contain a simple S-expression like this:
  4290. @lisp
  4291. (channel
  4292. (version 0)
  4293. (dependencies
  4294. (channel
  4295. (name some-collection)
  4296. (url "https://example.org/first-collection.git")
  4297. ;; The 'introduction' bit below is optional: you would
  4298. ;; provide it for dependencies that can be authenticated.
  4299. (introduction
  4300. (channel-introduction
  4301. (version 0)
  4302. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4303. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4304. (channel
  4305. (name some-other-collection)
  4306. (url "https://example.org/second-collection.git")
  4307. (branch "testing"))))
  4308. @end lisp
  4309. In the above example this channel is declared to depend on two other channels,
  4310. which will both be fetched automatically. The modules provided by the channel
  4311. will be compiled in an environment where the modules of all these declared
  4312. channels are available.
  4313. For the sake of reliability and maintainability, you should avoid dependencies
  4314. on channels that you don't control, and you should aim to keep the number of
  4315. dependencies to a minimum.
  4316. @node Specifying Channel Authorizations
  4317. @section Specifying Channel Authorizations
  4318. @cindex channel authorizations
  4319. @anchor{channel-authorizations}
  4320. As we saw above, Guix ensures the source code it pulls from channels
  4321. comes from authorized developers. As a channel author, you need to
  4322. specify the list of authorized developers in the
  4323. @file{.guix-authorizations} file in the channel's Git repository. The
  4324. authentication rule is simple: each commit must be signed by a key
  4325. listed in the @file{.guix-authorizations} file of its parent
  4326. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4327. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4328. have one parent and merge commits have two parent commits. Read
  4329. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4330. for Computer Scientists}} for a great overview.} The
  4331. @file{.guix-authorizations} file looks like this:
  4332. @lisp
  4333. ;; Example '.guix-authorizations' file.
  4334. (authorizations
  4335. (version 0) ;current file format version
  4336. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4337. (name "alice"))
  4338. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4339. (name "bob"))
  4340. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4341. (name "charlie"))))
  4342. @end lisp
  4343. Each fingerprint is followed by optional key/value pairs, as in the
  4344. example above. Currently these key/value pairs are ignored.
  4345. This authentication rule creates a chicken-and-egg issue: how do we
  4346. authenticate the first commit? Related to that: how do we deal with
  4347. channels whose repository history contains unsigned commits and lack
  4348. @file{.guix-authorizations}? And how do we fork existing channels?
  4349. @cindex channel introduction
  4350. Channel introductions answer these questions by describing the first
  4351. commit of a channel that should be authenticated. The first time a
  4352. channel is fetched with @command{guix pull} or @command{guix
  4353. time-machine}, the command looks up the introductory commit and verifies
  4354. that it is signed by the specified OpenPGP key. From then on, it
  4355. authenticates commits according to the rule above.
  4356. Additionally, your channel must provide all the OpenPGP keys that were
  4357. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4358. files, which can be either binary or ``ASCII-armored''. By default,
  4359. those @file{.key} files are searched for in the branch named
  4360. @code{keyring} but you can specify a different branch name in
  4361. @code{.guix-channel} like so:
  4362. @lisp
  4363. (channel
  4364. (version 0)
  4365. (keyring-reference "my-keyring-branch"))
  4366. @end lisp
  4367. To summarize, as the author of a channel, there are three things you have
  4368. to do to allow users to authenticate your code:
  4369. @enumerate
  4370. @item
  4371. Export the OpenPGP keys of past and present committers with @command{gpg
  4372. --export} and store them in @file{.key} files, by default in a branch
  4373. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4374. @item
  4375. Introduce an initial @file{.guix-authorizations} in the channel's
  4376. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4377. information on how to sign Git commits.)
  4378. @item
  4379. Advertise the channel introduction, for instance on your channel's web
  4380. page. The channel introduction, as we saw above, is the commit/key
  4381. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4382. the fingerprint of the OpenPGP used to sign it.
  4383. @end enumerate
  4384. Before pushing to your public Git repository, you can run @command{guix
  4385. git-authenticate} to verify that you did sign all the commits you are
  4386. about to push with an authorized key:
  4387. @example
  4388. guix git authenticate @var{commit} @var{signer}
  4389. @end example
  4390. @noindent
  4391. where @var{commit} and @var{signer} are your channel introduction.
  4392. @xref{Invoking guix git authenticate}, for details.
  4393. Publishing a signed channel requires discipline: any mistake, such as an
  4394. unsigned commit or a commit signed by an unauthorized key, will prevent
  4395. users from pulling from your channel---well, that's the whole point of
  4396. authentication! Pay attention to merges in particular: merge commits
  4397. are considered authentic if and only if they are signed by a key present
  4398. in the @file{.guix-authorizations} file of @emph{both} branches.
  4399. @node Primary URL
  4400. @section Primary URL
  4401. @cindex primary URL, channels
  4402. Channel authors can indicate the primary URL of their channel's Git
  4403. repository in the @file{.guix-channel} file, like so:
  4404. @lisp
  4405. (channel
  4406. (version 0)
  4407. (url "https://example.org/guix.git"))
  4408. @end lisp
  4409. This allows @command{guix pull} to determine whether it is pulling code
  4410. from a mirror of the channel; when that is the case, it warns the user
  4411. that the mirror might be stale and displays the primary URL@. That way,
  4412. users cannot be tricked into fetching code from a stale mirror that does
  4413. not receive security updates.
  4414. This feature only makes sense for authenticated repositories, such as
  4415. the official @code{guix} channel, for which @command{guix pull} ensures
  4416. the code it fetches is authentic.
  4417. @node Writing Channel News
  4418. @section Writing Channel News
  4419. @cindex news, for channels
  4420. Channel authors may occasionally want to communicate to their users
  4421. information about important changes in the channel. You'd send them all
  4422. an email, but that's not convenient.
  4423. Instead, channels can provide a @dfn{news file}; when the channel users
  4424. run @command{guix pull}, that news file is automatically read and
  4425. @command{guix pull --news} can display the announcements that correspond
  4426. to the new commits that have been pulled, if any.
  4427. To do that, channel authors must first declare the name of the news file
  4428. in their @file{.guix-channel} file:
  4429. @lisp
  4430. (channel
  4431. (version 0)
  4432. (news-file "etc/news.txt"))
  4433. @end lisp
  4434. The news file itself, @file{etc/news.txt} in this example, must look
  4435. something like this:
  4436. @lisp
  4437. (channel-news
  4438. (version 0)
  4439. (entry (tag "the-bug-fix")
  4440. (title (en "Fixed terrible bug")
  4441. (fr "Oh la la"))
  4442. (body (en "@@emph@{Good news@}! It's fixed!")
  4443. (eo "Certe ĝi pli bone funkcias nun!")))
  4444. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4445. (title (en "Added a great package")
  4446. (ca "Què vol dir guix?"))
  4447. (body (en "Don't miss the @@code@{hello@} package!"))))
  4448. @end lisp
  4449. While the news file is using the Scheme syntax, avoid naming it with a
  4450. @file{.scm} extension or else it will get picked up when building the
  4451. channel and yield an error since it is not a valid module.
  4452. Alternatively, you can move the channel module to a subdirectory and
  4453. store the news file in another directory.
  4454. The file consists of a list of @dfn{news entries}. Each entry is
  4455. associated with a commit or tag: it describes changes made in this
  4456. commit, possibly in preceding commits as well. Users see entries only
  4457. the first time they obtain the commit the entry refers to.
  4458. The @code{title} field should be a one-line summary while @code{body}
  4459. can be arbitrarily long, and both can contain Texinfo markup
  4460. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4461. a list of language tag/message tuples, which allows @command{guix pull}
  4462. to display news in the language that corresponds to the user's locale.
  4463. If you want to translate news using a gettext-based workflow, you can
  4464. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4465. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4466. you write news entries in English first, the command below creates a PO
  4467. file containing the strings to translate:
  4468. @example
  4469. xgettext -o news.po -l scheme -ken etc/news.txt
  4470. @end example
  4471. To sum up, yes, you could use your channel as a blog. But beware, this
  4472. is @emph{not quite} what your users might expect.
  4473. @c *********************************************************************
  4474. @node Development
  4475. @chapter Development
  4476. @cindex software development
  4477. If you are a software developer, Guix provides tools that you should find
  4478. helpful---independently of the language you're developing in. This is what
  4479. this chapter is about.
  4480. The @command{guix environment} command provides a convenient way to set up
  4481. @dfn{development environments} containing all the dependencies and tools
  4482. necessary to work on the software package of your choice. The @command{guix
  4483. pack} command allows you to create @dfn{application bundles} that can be
  4484. easily distributed to users who do not run Guix.
  4485. @menu
  4486. * Invoking guix environment:: Setting up development environments.
  4487. * Invoking guix pack:: Creating software bundles.
  4488. * The GCC toolchain:: Working with languages supported by GCC.
  4489. * Invoking guix git authenticate:: Authenticating Git repositories.
  4490. @end menu
  4491. @node Invoking guix environment
  4492. @section Invoking @command{guix environment}
  4493. @cindex reproducible build environments
  4494. @cindex development environments
  4495. @cindex @command{guix environment}
  4496. @cindex environment, package build environment
  4497. The purpose of @command{guix environment} is to assist hackers in
  4498. creating reproducible development environments without polluting their
  4499. package profile. The @command{guix environment} tool takes one or more
  4500. packages, builds all of their inputs, and creates a shell
  4501. environment to use them.
  4502. The general syntax is:
  4503. @example
  4504. guix environment @var{options} @var{package}@dots{}
  4505. @end example
  4506. The following example spawns a new shell set up for the development of
  4507. GNU@tie{}Guile:
  4508. @example
  4509. guix environment guile
  4510. @end example
  4511. If the needed dependencies are not built yet, @command{guix environment}
  4512. automatically builds them. The environment of the new shell is an
  4513. augmented version of the environment that @command{guix environment} was
  4514. run in. It contains the necessary search paths for building the given
  4515. package added to the existing environment variables. To create
  4516. a ``pure'' environment, in which the original environment variables have
  4517. been unset, use the @option{--pure} option@footnote{Users sometimes
  4518. wrongfully augment environment variables such as @env{PATH} in their
  4519. @file{~/.bashrc} file. As a consequence, when @command{guix
  4520. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4521. introducing ``impurities'' in these environment variables. It is an
  4522. error to define such environment variables in @file{.bashrc}; instead,
  4523. they should be defined in @file{.bash_profile}, which is sourced only by
  4524. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4525. Manual}, for details on Bash start-up files.}.
  4526. Exiting from a Guix environment is the same as exiting from the shell,
  4527. and will place the user back in the old environment before @command{guix
  4528. environment} was invoked. The next garbage collection (@pxref{Invoking
  4529. guix gc}) will clean up packages that were installed from within the
  4530. environment and are no longer used outside of it.
  4531. @vindex GUIX_ENVIRONMENT
  4532. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4533. variable in the shell it spawns; its value is the file name of the
  4534. profile of this environment. This allows users to, say, define a
  4535. specific prompt for development environments in their @file{.bashrc}
  4536. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4537. @example
  4538. if [ -n "$GUIX_ENVIRONMENT" ]
  4539. then
  4540. export PS1="\u@@\h \w [dev]\$ "
  4541. fi
  4542. @end example
  4543. @noindent
  4544. ...@: or to browse the profile:
  4545. @example
  4546. $ ls "$GUIX_ENVIRONMENT/bin"
  4547. @end example
  4548. Additionally, more than one package may be specified, in which case the
  4549. union of the inputs for the given packages are used. For example, the
  4550. command below spawns a shell where all of the dependencies of both Guile
  4551. and Emacs are available:
  4552. @example
  4553. guix environment guile emacs
  4554. @end example
  4555. Sometimes an interactive shell session is not desired. An arbitrary
  4556. command may be invoked by placing the @code{--} token to separate the
  4557. command from the rest of the arguments:
  4558. @example
  4559. guix environment guile -- make -j4
  4560. @end example
  4561. In other situations, it is more convenient to specify the list of
  4562. packages needed in the environment. For example, the following command
  4563. runs @command{python} from an environment containing Python@tie{}3 and
  4564. NumPy:
  4565. @example
  4566. guix environment --ad-hoc python-numpy python -- python3
  4567. @end example
  4568. Furthermore, one might want the dependencies of a package and also some
  4569. additional packages that are not build-time or runtime dependencies, but
  4570. are useful when developing nonetheless. Because of this, the
  4571. @option{--ad-hoc} flag is positional. Packages appearing before
  4572. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4573. added to the environment. Packages appearing after are interpreted as
  4574. packages that will be added to the environment directly. For example,
  4575. the following command creates a Guix development environment that
  4576. additionally includes Git and strace:
  4577. @example
  4578. guix environment --pure guix --ad-hoc git strace
  4579. @end example
  4580. @cindex container
  4581. Sometimes it is desirable to isolate the environment as much as
  4582. possible, for maximal purity and reproducibility. In particular, when
  4583. using Guix on a host distro that is not Guix System, it is desirable to
  4584. prevent access to @file{/usr/bin} and other system-wide resources from
  4585. the development environment. For example, the following command spawns
  4586. a Guile REPL in a ``container'' where only the store and the current
  4587. working directory are mounted:
  4588. @example
  4589. guix environment --ad-hoc --container guile -- guile
  4590. @end example
  4591. @quotation Note
  4592. The @option{--container} option requires Linux-libre 3.19 or newer.
  4593. @end quotation
  4594. @cindex certificates
  4595. Another typical use case for containers is to run security-sensitive
  4596. applications such as a web browser. To run Eolie, we must expose and
  4597. share some files and directories; we include @code{nss-certs} and expose
  4598. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4599. @env{DISPLAY} environment variable since containerized graphical
  4600. applications won't display without it.
  4601. @example
  4602. guix environment --preserve='^DISPLAY$' --container --network \
  4603. --expose=/etc/machine-id \
  4604. --expose=/etc/ssl/certs/ \
  4605. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4606. --ad-hoc eolie nss-certs dbus -- eolie
  4607. @end example
  4608. The available options are summarized below.
  4609. @table @code
  4610. @item --root=@var{file}
  4611. @itemx -r @var{file}
  4612. @cindex persistent environment
  4613. @cindex garbage collector root, for environments
  4614. Make @var{file} a symlink to the profile for this environment, and
  4615. register it as a garbage collector root.
  4616. This is useful if you want to protect your environment from garbage
  4617. collection, to make it ``persistent''.
  4618. When this option is omitted, the environment is protected from garbage
  4619. collection only for the duration of the @command{guix environment}
  4620. session. This means that next time you recreate the same environment,
  4621. you could have to rebuild or re-download packages. @xref{Invoking guix
  4622. gc}, for more on GC roots.
  4623. @item --expression=@var{expr}
  4624. @itemx -e @var{expr}
  4625. Create an environment for the package or list of packages that
  4626. @var{expr} evaluates to.
  4627. For example, running:
  4628. @example
  4629. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4630. @end example
  4631. starts a shell with the environment for this specific variant of the
  4632. PETSc package.
  4633. Running:
  4634. @example
  4635. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4636. @end example
  4637. starts a shell with all the base system packages available.
  4638. The above commands only use the default output of the given packages.
  4639. To select other outputs, two element tuples can be specified:
  4640. @example
  4641. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4642. @end example
  4643. @item --load=@var{file}
  4644. @itemx -l @var{file}
  4645. Create an environment for the package or list of packages that the code
  4646. within @var{file} evaluates to.
  4647. As an example, @var{file} might contain a definition like this
  4648. (@pxref{Defining Packages}):
  4649. @lisp
  4650. @verbatiminclude environment-gdb.scm
  4651. @end lisp
  4652. @item --manifest=@var{file}
  4653. @itemx -m @var{file}
  4654. Create an environment for the packages contained in the manifest object
  4655. returned by the Scheme code in @var{file}. This option can be repeated
  4656. several times, in which case the manifests are concatenated.
  4657. This is similar to the same-named option in @command{guix package}
  4658. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4659. manifest files.
  4660. @item --ad-hoc
  4661. Include all specified packages in the resulting environment, as if an
  4662. @i{ad hoc} package were defined with them as inputs. This option is
  4663. useful for quickly creating an environment without having to write a
  4664. package expression to contain the desired inputs.
  4665. For instance, the command:
  4666. @example
  4667. guix environment --ad-hoc guile guile-sdl -- guile
  4668. @end example
  4669. runs @command{guile} in an environment where Guile and Guile-SDL are
  4670. available.
  4671. Note that this example implicitly asks for the default output of
  4672. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  4673. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  4674. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  4675. This option may be composed with the default behavior of @command{guix
  4676. environment}. Packages appearing before @option{--ad-hoc} are
  4677. interpreted as packages whose dependencies will be added to the
  4678. environment, the default behavior. Packages appearing after are
  4679. interpreted as packages that will be added to the environment directly.
  4680. @item --pure
  4681. Unset existing environment variables when building the new environment, except
  4682. those specified with @option{--preserve} (see below). This has the effect of
  4683. creating an environment in which search paths only contain package inputs.
  4684. @item --preserve=@var{regexp}
  4685. @itemx -E @var{regexp}
  4686. When used alongside @option{--pure}, preserve the environment variables
  4687. matching @var{regexp}---in other words, put them on a ``white list'' of
  4688. environment variables that must be preserved. This option can be repeated
  4689. several times.
  4690. @example
  4691. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  4692. -- mpirun @dots{}
  4693. @end example
  4694. This example runs @command{mpirun} in a context where the only environment
  4695. variables defined are @env{PATH}, environment variables whose name starts
  4696. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4697. @env{USER}, etc.).
  4698. @item --search-paths
  4699. Display the environment variable definitions that make up the
  4700. environment.
  4701. @item --system=@var{system}
  4702. @itemx -s @var{system}
  4703. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4704. @item --container
  4705. @itemx -C
  4706. @cindex container
  4707. Run @var{command} within an isolated container. The current working
  4708. directory outside the container is mapped inside the container.
  4709. Additionally, unless overridden with @option{--user}, a dummy home
  4710. directory is created that matches the current user's home directory, and
  4711. @file{/etc/passwd} is configured accordingly.
  4712. The spawned process runs as the current user outside the container. Inside
  4713. the container, it has the same UID and GID as the current user, unless
  4714. @option{--user} is passed (see below).
  4715. @item --network
  4716. @itemx -N
  4717. For containers, share the network namespace with the host system.
  4718. Containers created without this flag only have access to the loopback
  4719. device.
  4720. @item --link-profile
  4721. @itemx -P
  4722. For containers, link the environment profile to @file{~/.guix-profile}
  4723. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4724. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4725. actual profile within the container.
  4726. Linking will fail and abort the environment if the directory already
  4727. exists, which will certainly be the case if @command{guix environment}
  4728. was invoked in the user's home directory.
  4729. Certain packages are configured to look in @file{~/.guix-profile} for
  4730. configuration files and data;@footnote{For example, the
  4731. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4732. for additional fonts.} @option{--link-profile} allows these programs to
  4733. behave as expected within the environment.
  4734. @item --user=@var{user}
  4735. @itemx -u @var{user}
  4736. For containers, use the username @var{user} in place of the current
  4737. user. The generated @file{/etc/passwd} entry within the container will
  4738. contain the name @var{user}, the home directory will be
  4739. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4740. the UID and GID inside the container are 1000. @var{user}
  4741. need not exist on the system.
  4742. Additionally, any shared or exposed path (see @option{--share} and
  4743. @option{--expose} respectively) whose target is within the current user's
  4744. home directory will be remapped relative to @file{/home/USER}; this
  4745. includes the automatic mapping of the current working directory.
  4746. @example
  4747. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4748. cd $HOME/wd
  4749. guix environment --container --user=foo \
  4750. --expose=$HOME/test \
  4751. --expose=/tmp/target=$HOME/target
  4752. @end example
  4753. While this will limit the leaking of user identity through home paths
  4754. and each of the user fields, this is only one useful component of a
  4755. broader privacy/anonymity solution---not one in and of itself.
  4756. @item --no-cwd
  4757. For containers, the default behavior is to share the current working
  4758. directory with the isolated container and immediately change to that
  4759. directory within the container. If this is undesirable,
  4760. @option{--no-cwd} will cause the current working directory to @emph{not}
  4761. be automatically shared and will change to the user's home directory
  4762. within the container instead. See also @option{--user}.
  4763. @item --expose=@var{source}[=@var{target}]
  4764. @itemx --share=@var{source}[=@var{target}]
  4765. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4766. file system @var{source} from the host system as the read-only
  4767. (resp. writable) file system @var{target} within the container. If
  4768. @var{target} is not specified, @var{source} is used as the target mount
  4769. point in the container.
  4770. The example below spawns a Guile REPL in a container in which the user's
  4771. home directory is accessible read-only via the @file{/exchange}
  4772. directory:
  4773. @example
  4774. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  4775. @end example
  4776. @end table
  4777. @command{guix environment}
  4778. also supports all of the common build options that @command{guix
  4779. build} supports (@pxref{Common Build Options}) as well as package
  4780. transformation options (@pxref{Package Transformation Options}).
  4781. @node Invoking guix pack
  4782. @section Invoking @command{guix pack}
  4783. Occasionally you want to pass software to people who are not (yet!)
  4784. lucky enough to be using Guix. You'd tell them to run @command{guix
  4785. package -i @var{something}}, but that's not possible in this case. This
  4786. is where @command{guix pack} comes in.
  4787. @quotation Note
  4788. If you are looking for ways to exchange binaries among machines that
  4789. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  4790. publish}, and @ref{Invoking guix archive}.
  4791. @end quotation
  4792. @cindex pack
  4793. @cindex bundle
  4794. @cindex application bundle
  4795. @cindex software bundle
  4796. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  4797. @dfn{software bundle}: it creates a tarball or some other archive
  4798. containing the binaries of the software you're interested in, and all
  4799. its dependencies. The resulting archive can be used on any machine that
  4800. does not have Guix, and people can run the exact same binaries as those
  4801. you have with Guix. The pack itself is created in a bit-reproducible
  4802. fashion, so anyone can verify that it really contains the build results
  4803. that you pretend to be shipping.
  4804. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  4805. their dependencies, you can run:
  4806. @example
  4807. $ guix pack guile emacs geiser
  4808. @dots{}
  4809. /gnu/store/@dots{}-pack.tar.gz
  4810. @end example
  4811. The result here is a tarball containing a @file{/gnu/store} directory
  4812. with all the relevant packages. The resulting tarball contains a
  4813. @dfn{profile} with the three packages of interest; the profile is the
  4814. same as would be created by @command{guix package -i}. It is this
  4815. mechanism that is used to create Guix's own standalone binary tarball
  4816. (@pxref{Binary Installation}).
  4817. Users of this pack would have to run
  4818. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  4819. find inconvenient. To work around it, you can create, say, a
  4820. @file{/opt/gnu/bin} symlink to the profile:
  4821. @example
  4822. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  4823. @end example
  4824. @noindent
  4825. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  4826. @cindex relocatable binaries, with @command{guix pack}
  4827. What if the recipient of your pack does not have root privileges on
  4828. their machine, and thus cannot unpack it in the root file system? In
  4829. that case, you will want to use the @option{--relocatable} option (see
  4830. below). This option produces @dfn{relocatable binaries}, meaning they
  4831. they can be placed anywhere in the file system hierarchy: in the example
  4832. above, users can unpack your tarball in their home directory and
  4833. directly run @file{./opt/gnu/bin/guile}.
  4834. @cindex Docker, build an image with guix pack
  4835. Alternatively, you can produce a pack in the Docker image format using
  4836. the following command:
  4837. @example
  4838. guix pack -f docker -S /bin=bin guile guile-readline
  4839. @end example
  4840. @noindent
  4841. The result is a tarball that can be passed to the @command{docker load}
  4842. command, followed by @code{docker run}:
  4843. @example
  4844. docker load < @var{file}
  4845. docker run -ti guile-guile-readline /bin/guile
  4846. @end example
  4847. @noindent
  4848. where @var{file} is the image returned by @var{guix pack}, and
  4849. @code{guile-guile-readline} is its ``image tag''. See the
  4850. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  4851. documentation} for more information.
  4852. @cindex Singularity, build an image with guix pack
  4853. @cindex SquashFS, build an image with guix pack
  4854. Yet another option is to produce a SquashFS image with the following
  4855. command:
  4856. @example
  4857. guix pack -f squashfs bash guile emacs geiser
  4858. @end example
  4859. @noindent
  4860. The result is a SquashFS file system image that can either be mounted or
  4861. directly be used as a file system container image with the
  4862. @uref{https://www.sylabs.io/docs/, Singularity container execution
  4863. environment}, using commands like @command{singularity shell} or
  4864. @command{singularity exec}.
  4865. Several command-line options allow you to customize your pack:
  4866. @table @code
  4867. @item --format=@var{format}
  4868. @itemx -f @var{format}
  4869. Produce a pack in the given @var{format}.
  4870. The available formats are:
  4871. @table @code
  4872. @item tarball
  4873. This is the default format. It produces a tarball containing all the
  4874. specified binaries and symlinks.
  4875. @item docker
  4876. This produces a tarball that follows the
  4877. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  4878. Docker Image Specification}. The ``repository name'' as it appears in
  4879. the output of the @command{docker images} command is computed from
  4880. package names passed on the command line or in the manifest file.
  4881. @item squashfs
  4882. This produces a SquashFS image containing all the specified binaries and
  4883. symlinks, as well as empty mount points for virtual file systems like
  4884. procfs.
  4885. @quotation Note
  4886. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  4887. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  4888. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  4889. with something like:
  4890. @example
  4891. guix pack -f squashfs bash @dots{}
  4892. @end example
  4893. If you forget the @code{bash} (or similar) package, @command{singularity
  4894. run} and @command{singularity exec} will fail with an unhelpful ``no
  4895. such file or directory'' message.
  4896. @end quotation
  4897. @end table
  4898. @cindex relocatable binaries
  4899. @item --relocatable
  4900. @itemx -R
  4901. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  4902. anywhere in the file system hierarchy and run from there.
  4903. When this option is passed once, the resulting binaries require support for
  4904. @dfn{user namespaces} in the kernel Linux; when passed
  4905. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  4906. PRoot support, can be thought of as the abbreviation of ``Really
  4907. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  4908. other techniques if user namespaces are unavailable, and essentially
  4909. work anywhere---see below for the implications.
  4910. For example, if you create a pack containing Bash with:
  4911. @example
  4912. guix pack -RR -S /mybin=bin bash
  4913. @end example
  4914. @noindent
  4915. ...@: you can copy that pack to a machine that lacks Guix, and from your
  4916. home directory as a normal user, run:
  4917. @example
  4918. tar xf pack.tar.gz
  4919. ./mybin/sh
  4920. @end example
  4921. @noindent
  4922. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  4923. @file{/gnu/store} shows up and contains all the dependencies of
  4924. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  4925. altogether! That is probably the simplest way to deploy Guix-built
  4926. software on a non-Guix machine.
  4927. @quotation Note
  4928. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  4929. the kernel Linux, which allows unprivileged users to mount or change root.
  4930. Old versions of Linux did not support it, and some GNU/Linux distributions
  4931. turn it off.
  4932. To produce relocatable binaries that work even in the absence of user
  4933. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  4934. case, binaries will try user namespace support and fall back to another
  4935. @dfn{execution engine} if user namespaces are not supported. The
  4936. following execution engines are supported:
  4937. @table @code
  4938. @item default
  4939. Try user namespaces and fall back to PRoot if user namespaces are not
  4940. supported (see below).
  4941. @item performance
  4942. Try user namespaces and fall back to Fakechroot if user namespaces are
  4943. not supported (see below).
  4944. @item userns
  4945. Run the program through user namespaces and abort if they are not
  4946. supported.
  4947. @item proot
  4948. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  4949. provides the necessary
  4950. support for file system virtualization. It achieves that by using the
  4951. @code{ptrace} system call on the running program. This approach has the
  4952. advantage to work without requiring special kernel support, but it incurs
  4953. run-time overhead every time a system call is made.
  4954. @item fakechroot
  4955. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  4956. Fakechroot} virtualizes file system accesses by intercepting calls to C
  4957. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  4958. on. Unlike PRoot, it incurs very little overhead. However, it does not
  4959. always work: for example, some file system accesses made from within the
  4960. C library are not intercepted, and file system accesses made @i{via}
  4961. direct syscalls are not intercepted either, leading to erratic behavior.
  4962. @end table
  4963. @vindex GUIX_EXECUTION_ENGINE
  4964. When running a wrapped program, you can explicitly request one of the
  4965. execution engines listed above by setting the
  4966. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  4967. @end quotation
  4968. @cindex entry point, for Docker images
  4969. @item --entry-point=@var{command}
  4970. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  4971. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  4972. support it. @var{command} must be relative to the profile contained in the
  4973. pack.
  4974. The entry point specifies the command that tools like @code{docker run} or
  4975. @code{singularity run} automatically start by default. For example, you can
  4976. do:
  4977. @example
  4978. guix pack -f docker --entry-point=bin/guile guile
  4979. @end example
  4980. The resulting pack can easily be loaded and @code{docker run} with no extra
  4981. arguments will spawn @code{bin/guile}:
  4982. @example
  4983. docker load -i pack.tar.gz
  4984. docker run @var{image-id}
  4985. @end example
  4986. @item --expression=@var{expr}
  4987. @itemx -e @var{expr}
  4988. Consider the package @var{expr} evaluates to.
  4989. This has the same purpose as the same-named option in @command{guix
  4990. build} (@pxref{Additional Build Options, @option{--expression} in
  4991. @command{guix build}}).
  4992. @item --manifest=@var{file}
  4993. @itemx -m @var{file}
  4994. Use the packages contained in the manifest object returned by the Scheme
  4995. code in @var{file}. This option can be repeated several times, in which
  4996. case the manifests are concatenated.
  4997. This has a similar purpose as the same-named option in @command{guix
  4998. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  4999. same manifest files. It allows you to define a collection of packages
  5000. once and use it both for creating profiles and for creating archives
  5001. for use on machines that do not have Guix installed. Note that you can
  5002. specify @emph{either} a manifest file @emph{or} a list of packages,
  5003. but not both.
  5004. @item --system=@var{system}
  5005. @itemx -s @var{system}
  5006. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5007. the system type of the build host.
  5008. @item --target=@var{triplet}
  5009. @cindex cross-compilation
  5010. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5011. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5012. configuration triplets,, autoconf, Autoconf}).
  5013. @item --compression=@var{tool}
  5014. @itemx -C @var{tool}
  5015. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  5016. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  5017. compression.
  5018. @item --symlink=@var{spec}
  5019. @itemx -S @var{spec}
  5020. Add the symlinks specified by @var{spec} to the pack. This option can
  5021. appear several times.
  5022. @var{spec} has the form @code{@var{source}=@var{target}}, where
  5023. @var{source} is the symlink that will be created and @var{target} is the
  5024. symlink target.
  5025. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  5026. symlink pointing to the @file{bin} sub-directory of the profile.
  5027. @item --save-provenance
  5028. Save provenance information for the packages passed on the command line.
  5029. Provenance information includes the URL and commit of the channels in use
  5030. (@pxref{Channels}).
  5031. Provenance information is saved in the
  5032. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  5033. usual package metadata---the name and version of each package, their
  5034. propagated inputs, and so on. It is useful information to the recipient of
  5035. the pack, who then knows how the pack was (supposedly) obtained.
  5036. This option is not enabled by default because, like timestamps, provenance
  5037. information contributes nothing to the build process. In other words, there
  5038. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  5039. Recording such ``silent'' metadata in the output thus potentially breaks the
  5040. source-to-binary bitwise reproducibility property.
  5041. @item --root=@var{file}
  5042. @itemx -r @var{file}
  5043. @cindex garbage collector root, for packs
  5044. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  5045. collector root.
  5046. @item --localstatedir
  5047. @itemx --profile-name=@var{name}
  5048. Include the ``local state directory'', @file{/var/guix}, in the resulting
  5049. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  5050. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  5051. @file{~root/.guix-profile}.
  5052. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  5053. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  5054. the pack means that the store is ``complete'' and manageable by Guix;
  5055. not providing it pack means that the store is ``dead'': items cannot be
  5056. added to it or removed from it after extraction of the pack.
  5057. One use case for this is the Guix self-contained binary tarball
  5058. (@pxref{Binary Installation}).
  5059. @item --derivation
  5060. @itemx -d
  5061. Print the name of the derivation that builds the pack.
  5062. @item --bootstrap
  5063. Use the bootstrap binaries to build the pack. This option is only
  5064. useful to Guix developers.
  5065. @end table
  5066. In addition, @command{guix pack} supports all the common build options
  5067. (@pxref{Common Build Options}) and all the package transformation
  5068. options (@pxref{Package Transformation Options}).
  5069. @node The GCC toolchain
  5070. @section The GCC toolchain
  5071. @cindex GCC
  5072. @cindex ld-wrapper
  5073. @cindex linker wrapper
  5074. @cindex toolchain, for C development
  5075. @cindex toolchain, for Fortran development
  5076. If you need a complete toolchain for compiling and linking C or C++
  5077. source code, use the @code{gcc-toolchain} package. This package
  5078. provides a complete GCC toolchain for C/C++ development, including GCC
  5079. itself, the GNU C Library (headers and binaries, plus debugging symbols
  5080. in the @code{debug} output), Binutils, and a linker wrapper.
  5081. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  5082. passed to the linker, add corresponding @code{-rpath} arguments, and
  5083. invoke the actual linker with this new set of arguments. You can instruct the
  5084. wrapper to refuse to link against libraries not in the store by setting the
  5085. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  5086. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  5087. for Fortran development. For other languages, please use
  5088. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  5089. @node Invoking guix git authenticate
  5090. @section Invoking @command{guix git authenticate}
  5091. The @command{guix git authenticate} command authenticates a Git checkout
  5092. following the same rule as for channels (@pxref{channel-authentication,
  5093. channel authentication}). That is, starting from a given commit, it
  5094. ensures that all subsequent commits are signed by an OpenPGP key whose
  5095. fingerprint appears in the @file{.guix-authorizations} file of its
  5096. parent commit(s).
  5097. You will find this command useful if you maintain a channel. But in
  5098. fact, this authentication mechanism is useful in a broader context, so
  5099. you might want to use it for Git repositories that have nothing to do
  5100. with Guix.
  5101. The general syntax is:
  5102. @example
  5103. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  5104. @end example
  5105. By default, this command authenticates the Git checkout in the current
  5106. directory; it outputs nothing and exits with exit code zero on success
  5107. and non-zero on failure. @var{commit} above denotes the first commit
  5108. where authentication takes place, and @var{signer} is the OpenPGP
  5109. fingerprint of public key used to sign @var{commit}. Together, they
  5110. form a ``channel introduction'' (@pxref{channel-authentication, channel
  5111. introduction}). The options below allow you to fine-tune the process.
  5112. @table @code
  5113. @item --repository=@var{directory}
  5114. @itemx -r @var{directory}
  5115. Open the Git repository in @var{directory} instead of the current
  5116. directory.
  5117. @item --keyring=@var{reference}
  5118. @itemx -k @var{reference}
  5119. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5120. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5121. contain OpenPGP public keys in @file{.key} files, either in binary form
  5122. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5123. named @code{keyring}.
  5124. @item --stats
  5125. Display commit signing statistics upon completion.
  5126. @item --cache-key=@var{key}
  5127. Previously-authenticated commits are cached in a file under
  5128. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5129. stored in file @var{key} in that directory.
  5130. @item --historical-authorizations=@var{file}
  5131. By default, any commit whose parent commit(s) lack the
  5132. @file{.guix-authorizations} file is considered inauthentic. In
  5133. contrast, this option considers the authorizations in @var{file} for any
  5134. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5135. is the same as that of @file{.guix-authorizations}
  5136. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5137. @end table
  5138. @c *********************************************************************
  5139. @node Programming Interface
  5140. @chapter Programming Interface
  5141. GNU Guix provides several Scheme programming interfaces (APIs) to
  5142. define, build, and query packages. The first interface allows users to
  5143. write high-level package definitions. These definitions refer to
  5144. familiar packaging concepts, such as the name and version of a package,
  5145. its build system, and its dependencies. These definitions can then be
  5146. turned into concrete build actions.
  5147. Build actions are performed by the Guix daemon, on behalf of users. In a
  5148. standard setup, the daemon has write access to the store---the
  5149. @file{/gnu/store} directory---whereas users do not. The recommended
  5150. setup also has the daemon perform builds in chroots, under specific
  5151. build users, to minimize interference with the rest of the system.
  5152. @cindex derivation
  5153. Lower-level APIs are available to interact with the daemon and the
  5154. store. To instruct the daemon to perform a build action, users actually
  5155. provide it with a @dfn{derivation}. A derivation is a low-level
  5156. representation of the build actions to be taken, and the environment in
  5157. which they should occur---derivations are to package definitions what
  5158. assembly is to C programs. The term ``derivation'' comes from the fact
  5159. that build results @emph{derive} from them.
  5160. This chapter describes all these APIs in turn, starting from high-level
  5161. package definitions.
  5162. @menu
  5163. * Package Modules:: Packages from the programmer's viewpoint.
  5164. * Defining Packages:: Defining new packages.
  5165. * Defining Package Variants:: Customizing packages.
  5166. * Build Systems:: Specifying how packages are built.
  5167. * Build Phases:: Phases of the build process of a package.
  5168. * Build Utilities:: Helpers for your package definitions and more.
  5169. * The Store:: Manipulating the package store.
  5170. * Derivations:: Low-level interface to package derivations.
  5171. * The Store Monad:: Purely functional interface to the store.
  5172. * G-Expressions:: Manipulating build expressions.
  5173. * Invoking guix repl:: Programming Guix in Guile
  5174. @end menu
  5175. @node Package Modules
  5176. @section Package Modules
  5177. From a programming viewpoint, the package definitions of the
  5178. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5179. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5180. packages @dots{})} module name space are not necessarily ``GNU
  5181. packages''. This module naming scheme follows the usual Guile module
  5182. naming convention: @code{gnu} means that these modules are distributed
  5183. as part of the GNU system, and @code{packages} identifies modules that
  5184. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5185. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5186. module exports a variable named @code{emacs}, which is bound to a
  5187. @code{<package>} object (@pxref{Defining Packages}).
  5188. The @code{(gnu packages @dots{})} module name space is
  5189. automatically scanned for packages by the command-line tools. For
  5190. instance, when running @code{guix install emacs}, all the @code{(gnu
  5191. packages @dots{})} modules are scanned until one that exports a package
  5192. object whose name is @code{emacs} is found. This package search
  5193. facility is implemented in the @code{(gnu packages)} module.
  5194. @cindex customization, of packages
  5195. @cindex package module search path
  5196. Users can store package definitions in modules with different
  5197. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5198. name and module name must match. For instance, the @code{(my-packages
  5199. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5200. relative to the load path specified with @option{--load-path} or
  5201. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5202. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5203. these package definitions visible to the user interfaces:
  5204. @enumerate
  5205. @item
  5206. By adding the directory containing your package modules to the search path
  5207. with the @code{-L} flag of @command{guix package} and other commands
  5208. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5209. environment variable described below.
  5210. @item
  5211. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5212. pulls from it. A channel is essentially a Git repository containing package
  5213. modules. @xref{Channels}, for more information on how to define and use
  5214. channels.
  5215. @end enumerate
  5216. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5217. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5218. This is a colon-separated list of directories to search for additional
  5219. package modules. Directories listed in this variable take precedence
  5220. over the own modules of the distribution.
  5221. @end defvr
  5222. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5223. each package is built based solely on other packages in the
  5224. distribution. The root of this dependency graph is a small set of
  5225. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5226. bootstrap)} module. For more information on bootstrapping,
  5227. @pxref{Bootstrapping}.
  5228. @node Defining Packages
  5229. @section Defining Packages
  5230. The high-level interface to package definitions is implemented in the
  5231. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5232. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5233. package looks like this:
  5234. @lisp
  5235. (define-module (gnu packages hello)
  5236. #:use-module (guix packages)
  5237. #:use-module (guix download)
  5238. #:use-module (guix build-system gnu)
  5239. #:use-module (guix licenses)
  5240. #:use-module (gnu packages gawk))
  5241. (define-public hello
  5242. (package
  5243. (name "hello")
  5244. (version "2.10")
  5245. (source (origin
  5246. (method url-fetch)
  5247. (uri (string-append "mirror://gnu/hello/hello-" version
  5248. ".tar.gz"))
  5249. (sha256
  5250. (base32
  5251. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5252. (build-system gnu-build-system)
  5253. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5254. (inputs `(("gawk" ,gawk)))
  5255. (synopsis "Hello, GNU world: An example GNU package")
  5256. (description "Guess what GNU Hello prints!")
  5257. (home-page "https://www.gnu.org/software/hello/")
  5258. (license gpl3+)))
  5259. @end lisp
  5260. @noindent
  5261. Without being a Scheme expert, the reader may have guessed the meaning
  5262. of the various fields here. This expression binds the variable
  5263. @code{hello} to a @code{<package>} object, which is essentially a record
  5264. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5265. This package object can be inspected using procedures found in the
  5266. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5267. returns---surprise!---@code{"hello"}.
  5268. With luck, you may be able to import part or all of the definition of
  5269. the package you are interested in from another repository, using the
  5270. @code{guix import} command (@pxref{Invoking guix import}).
  5271. In the example above, @code{hello} is defined in a module of its own,
  5272. @code{(gnu packages hello)}. Technically, this is not strictly
  5273. necessary, but it is convenient to do so: all the packages defined in
  5274. modules under @code{(gnu packages @dots{})} are automatically known to
  5275. the command-line tools (@pxref{Package Modules}).
  5276. There are a few points worth noting in the above package definition:
  5277. @itemize
  5278. @item
  5279. The @code{source} field of the package is an @code{<origin>} object
  5280. (@pxref{origin Reference}, for the complete reference).
  5281. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5282. meaning that the source is a file to be downloaded over FTP or HTTP.
  5283. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5284. the GNU mirrors defined in @code{(guix download)}.
  5285. The @code{sha256} field specifies the expected SHA256 hash of the file
  5286. being downloaded. It is mandatory, and allows Guix to check the
  5287. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5288. base32 representation of the hash. You can obtain this information with
  5289. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5290. hash} (@pxref{Invoking guix hash}).
  5291. @cindex patches
  5292. When needed, the @code{origin} form can also have a @code{patches} field
  5293. listing patches to be applied, and a @code{snippet} field giving a
  5294. Scheme expression to modify the source code.
  5295. @item
  5296. @cindex GNU Build System
  5297. The @code{build-system} field specifies the procedure to build the
  5298. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5299. represents the familiar GNU Build System, where packages may be
  5300. configured, built, and installed with the usual @code{./configure &&
  5301. make && make check && make install} command sequence.
  5302. When you start packaging non-trivial software, you may need tools to
  5303. manipulate those build phases, manipulate files, and so on. @xref{Build
  5304. Utilities}, for more on this.
  5305. @item
  5306. The @code{arguments} field specifies options for the build system
  5307. (@pxref{Build Systems}). Here it is interpreted by
  5308. @code{gnu-build-system} as a request run @file{configure} with the
  5309. @option{--enable-silent-rules} flag.
  5310. @cindex quote
  5311. @cindex quoting
  5312. @findex '
  5313. @findex quote
  5314. What about these quote (@code{'}) characters? They are Scheme syntax to
  5315. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5316. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5317. for details. Here the value of the @code{arguments} field is a list of
  5318. arguments passed to the build system down the road, as with @code{apply}
  5319. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5320. Manual}).
  5321. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5322. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5323. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5324. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5325. Reference Manual}).
  5326. @item
  5327. The @code{inputs} field specifies inputs to the build process---i.e.,
  5328. build-time or run-time dependencies of the package. Here, we define an
  5329. input called @code{"gawk"} whose value is that of the @code{gawk}
  5330. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5331. @cindex backquote (quasiquote)
  5332. @findex `
  5333. @findex quasiquote
  5334. @cindex comma (unquote)
  5335. @findex ,
  5336. @findex unquote
  5337. @findex ,@@
  5338. @findex unquote-splicing
  5339. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  5340. us to introduce a literal list in the @code{inputs} field, while
  5341. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  5342. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  5343. Reference Manual}).
  5344. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5345. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5346. of ensuring that they are present (@pxref{Build Systems}).
  5347. However, any other dependencies need to be specified in the
  5348. @code{inputs} field. Any dependency not specified here will simply be
  5349. unavailable to the build process, possibly leading to a build failure.
  5350. @end itemize
  5351. @xref{package Reference}, for a full description of possible fields.
  5352. Once a package definition is in place, the
  5353. package may actually be built using the @code{guix build} command-line
  5354. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5355. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5356. package definition using the @command{guix edit} command
  5357. (@pxref{Invoking guix edit}).
  5358. @xref{Packaging Guidelines}, for
  5359. more information on how to test package definitions, and
  5360. @ref{Invoking guix lint}, for information on how to check a definition
  5361. for style conformance.
  5362. @vindex GUIX_PACKAGE_PATH
  5363. Lastly, @pxref{Channels}, for information
  5364. on how to extend the distribution by adding your own package definitions
  5365. in a ``channel''.
  5366. Finally, updating the package definition to a new upstream version
  5367. can be partly automated by the @command{guix refresh} command
  5368. (@pxref{Invoking guix refresh}).
  5369. Behind the scenes, a derivation corresponding to the @code{<package>}
  5370. object is first computed by the @code{package-derivation} procedure.
  5371. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5372. The build actions it prescribes may then be realized by using the
  5373. @code{build-derivations} procedure (@pxref{The Store}).
  5374. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5375. Return the @code{<derivation>} object of @var{package} for @var{system}
  5376. (@pxref{Derivations}).
  5377. @var{package} must be a valid @code{<package>} object, and @var{system}
  5378. must be a string denoting the target system type---e.g.,
  5379. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5380. must be a connection to the daemon, which operates on the store
  5381. (@pxref{The Store}).
  5382. @end deffn
  5383. @noindent
  5384. @cindex cross-compilation
  5385. Similarly, it is possible to compute a derivation that cross-builds a
  5386. package for some other system:
  5387. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5388. @var{package} @var{target} [@var{system}]
  5389. Return the @code{<derivation>} object of @var{package} cross-built from
  5390. @var{system} to @var{target}.
  5391. @var{target} must be a valid GNU triplet denoting the target hardware
  5392. and operating system, such as @code{"aarch64-linux-gnu"}
  5393. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5394. @end deffn
  5395. Once you have package definitions, you can easily define @emph{variants}
  5396. of those packages. @xref{Defining Package Variants}, for more on that.
  5397. @menu
  5398. * package Reference:: The package data type.
  5399. * origin Reference:: The origin data type.
  5400. @end menu
  5401. @node package Reference
  5402. @subsection @code{package} Reference
  5403. This section summarizes all the options available in @code{package}
  5404. declarations (@pxref{Defining Packages}).
  5405. @deftp {Data Type} package
  5406. This is the data type representing a package recipe.
  5407. @table @asis
  5408. @item @code{name}
  5409. The name of the package, as a string.
  5410. @item @code{version}
  5411. The version of the package, as a string.
  5412. @item @code{source}
  5413. An object telling how the source code for the package should be
  5414. acquired. Most of the time, this is an @code{origin} object, which
  5415. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5416. can also be any other ``file-like'' object such as a @code{local-file},
  5417. which denotes a file from the local file system (@pxref{G-Expressions,
  5418. @code{local-file}}).
  5419. @item @code{build-system}
  5420. The build system that should be used to build the package (@pxref{Build
  5421. Systems}).
  5422. @item @code{arguments} (default: @code{'()})
  5423. The arguments that should be passed to the build system. This is a
  5424. list, typically containing sequential keyword-value pairs.
  5425. @item @code{inputs} (default: @code{'()})
  5426. @itemx @code{native-inputs} (default: @code{'()})
  5427. @itemx @code{propagated-inputs} (default: @code{'()})
  5428. @cindex inputs, of packages
  5429. These fields list dependencies of the package. Each one is a list of
  5430. tuples, where each tuple has a label for the input (a string) as its
  5431. first element, a package, origin, or derivation as its second element,
  5432. and optionally the name of the output thereof that should be used, which
  5433. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  5434. more on package outputs). For example, the list below specifies three
  5435. inputs:
  5436. @lisp
  5437. `(("libffi" ,libffi)
  5438. ("libunistring" ,libunistring)
  5439. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  5440. @end lisp
  5441. @cindex cross compilation, package dependencies
  5442. The distinction between @code{native-inputs} and @code{inputs} is
  5443. necessary when considering cross-compilation. When cross-compiling,
  5444. dependencies listed in @code{inputs} are built for the @emph{target}
  5445. architecture; conversely, dependencies listed in @code{native-inputs}
  5446. are built for the architecture of the @emph{build} machine.
  5447. @code{native-inputs} is typically used to list tools needed at
  5448. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5449. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5450. this area (@pxref{Invoking guix lint}).
  5451. @anchor{package-propagated-inputs}
  5452. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5453. specified packages will be automatically installed to profiles
  5454. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5455. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5456. package}}, for information on how @command{guix package} deals with
  5457. propagated inputs).
  5458. For example this is necessary when packaging a C/C++ library that needs
  5459. headers of another library to compile, or when a pkg-config file refers
  5460. to another one @i{via} its @code{Requires} field.
  5461. Another example where @code{propagated-inputs} is useful is for languages
  5462. that lack a facility to record the run-time search path akin to the
  5463. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5464. more. When packaging libraries written in those languages, ensure they
  5465. can find library code they depend on at run time by listing run-time
  5466. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5467. @item @code{outputs} (default: @code{'("out")})
  5468. The list of output names of the package. @xref{Packages with Multiple
  5469. Outputs}, for typical uses of additional outputs.
  5470. @item @code{native-search-paths} (default: @code{'()})
  5471. @itemx @code{search-paths} (default: @code{'()})
  5472. A list of @code{search-path-specification} objects describing
  5473. search-path environment variables honored by the package.
  5474. @item @code{replacement} (default: @code{#f})
  5475. This must be either @code{#f} or a package object that will be used as a
  5476. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5477. for details.
  5478. @item @code{synopsis}
  5479. A one-line description of the package.
  5480. @item @code{description}
  5481. A more elaborate description of the package.
  5482. @item @code{license}
  5483. @cindex license, of packages
  5484. The license of the package; a value from @code{(guix licenses)},
  5485. or a list of such values.
  5486. @item @code{home-page}
  5487. The URL to the home-page of the package, as a string.
  5488. @item @code{supported-systems} (default: @code{%supported-systems})
  5489. The list of systems supported by the package, as strings of the form
  5490. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5491. @item @code{location} (default: source location of the @code{package} form)
  5492. The source location of the package. It is useful to override this when
  5493. inheriting from another package, in which case this field is not
  5494. automatically corrected.
  5495. @end table
  5496. @end deftp
  5497. @deffn {Scheme Syntax} this-package
  5498. When used in the @emph{lexical scope} of a package field definition, this
  5499. identifier resolves to the package being defined.
  5500. The example below shows how to add a package as a native input of itself when
  5501. cross-compiling:
  5502. @lisp
  5503. (package
  5504. (name "guile")
  5505. ;; ...
  5506. ;; When cross-compiled, Guile, for example, depends on
  5507. ;; a native version of itself. Add it here.
  5508. (native-inputs (if (%current-target-system)
  5509. `(("self" ,this-package))
  5510. '())))
  5511. @end lisp
  5512. It is an error to refer to @code{this-package} outside a package definition.
  5513. @end deffn
  5514. Because packages are regular Scheme objects that capture a complete
  5515. dependency graph and associated build procedures, it is often useful to
  5516. write procedures that take a package and return a modified version
  5517. thereof according to some parameters. Below are a few examples.
  5518. @cindex tool chain, choosing a package's tool chain
  5519. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  5520. Return a variant of @var{package} that uses @var{toolchain} instead of
  5521. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  5522. inputs (label/package tuples) providing equivalent functionality, such
  5523. as the @code{gcc-toolchain} package.
  5524. The example below returns a variant of the @code{hello} package built
  5525. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  5526. GNU C Library) instead of the default tool chain:
  5527. @lisp
  5528. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  5529. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  5530. @end lisp
  5531. The build tool chain is part of the @dfn{implicit inputs} of
  5532. packages---it's usually not listed as part of the various ``inputs''
  5533. fields and is instead pulled in by the build system. Consequently, this
  5534. procedure works by changing the build system of @var{package} so that it
  5535. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  5536. for more on build systems.
  5537. @end deffn
  5538. @node origin Reference
  5539. @subsection @code{origin} Reference
  5540. This section documents @dfn{origins}. An @code{origin} declaration
  5541. specifies data that must be ``produced''---downloaded, usually---and
  5542. whose content hash is known in advance. Origins are primarily used to
  5543. represent the source code of packages (@pxref{Defining Packages}). For
  5544. that reason, the @code{origin} form allows you to declare patches to
  5545. apply to the original source code as well as code snippets to modify it.
  5546. @deftp {Data Type} origin
  5547. This is the data type representing a source code origin.
  5548. @table @asis
  5549. @item @code{uri}
  5550. An object containing the URI of the source. The object type depends on
  5551. the @code{method} (see below). For example, when using the
  5552. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5553. values are: a URL represented as a string, or a list thereof.
  5554. @cindex fixed-output derivations, for download
  5555. @item @code{method}
  5556. A monadic procedure that handles the given URI@. The procedure must
  5557. accept at least three arguments: the value of the @code{uri} field and
  5558. the hash algorithm and hash value specified by the @code{hash} field.
  5559. It must return a store item or a derivation in the store monad
  5560. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  5561. (@pxref{Derivations}).
  5562. Commonly used methods include @code{url-fetch}, which fetches data from
  5563. a URL, and @code{git-fetch}, which fetches data from a Git repository
  5564. (see below).
  5565. @item @code{sha256}
  5566. A bytevector containing the SHA-256 hash of the source. This is
  5567. equivalent to providing a @code{content-hash} SHA256 object in the
  5568. @code{hash} field described below.
  5569. @item @code{hash}
  5570. The @code{content-hash} object of the source---see below for how to use
  5571. @code{content-hash}.
  5572. You can obtain this information using @code{guix download}
  5573. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5574. guix hash}).
  5575. @item @code{file-name} (default: @code{#f})
  5576. The file name under which the source code should be saved. When this is
  5577. @code{#f}, a sensible default value will be used in most cases. In case
  5578. the source is fetched from a URL, the file name from the URL will be
  5579. used. For version control checkouts, it is recommended to provide the
  5580. file name explicitly because the default is not very descriptive.
  5581. @item @code{patches} (default: @code{'()})
  5582. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  5583. file-like objects}) pointing to patches to be applied to the source.
  5584. This list of patches must be unconditional. In particular, it cannot
  5585. depend on the value of @code{%current-system} or
  5586. @code{%current-target-system}.
  5587. @item @code{snippet} (default: @code{#f})
  5588. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  5589. in the source directory. This is a convenient way to modify the source,
  5590. sometimes more convenient than a patch.
  5591. @item @code{patch-flags} (default: @code{'("-p1")})
  5592. A list of command-line flags that should be passed to the @code{patch}
  5593. command.
  5594. @item @code{patch-inputs} (default: @code{#f})
  5595. Input packages or derivations to the patching process. When this is
  5596. @code{#f}, the usual set of inputs necessary for patching are provided,
  5597. such as GNU@tie{}Patch.
  5598. @item @code{modules} (default: @code{'()})
  5599. A list of Guile modules that should be loaded during the patching
  5600. process and while running the code in the @code{snippet} field.
  5601. @item @code{patch-guile} (default: @code{#f})
  5602. The Guile package that should be used in the patching process. When
  5603. this is @code{#f}, a sensible default is used.
  5604. @end table
  5605. @end deftp
  5606. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  5607. Construct a content hash object for the given @var{algorithm}, and with
  5608. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  5609. it is @code{sha256}.
  5610. @var{value} can be a literal string, in which case it is base32-decoded,
  5611. or it can be a bytevector.
  5612. The following forms are all equivalent:
  5613. @lisp
  5614. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  5615. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  5616. sha256)
  5617. (content-hash (base32
  5618. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  5619. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  5620. sha256)
  5621. @end lisp
  5622. Technically, @code{content-hash} is currently implemented as a macro.
  5623. It performs sanity checks at macro-expansion time, when possible, such
  5624. as ensuring that @var{value} has the right size for @var{algorithm}.
  5625. @end deftp
  5626. As we have seen above, how exactly the data an origin refers to is
  5627. retrieved is determined by its @code{method} field. The @code{(guix
  5628. download)} module provides the most common method, @code{url-fetch},
  5629. described below.
  5630. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  5631. [name] [#:executable? #f]
  5632. Return a fixed-output derivation that fetches data from @var{url} (a
  5633. string, or a list of strings denoting alternate URLs), which is expected
  5634. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  5635. the file name is the base name of URL; optionally, @var{name} can
  5636. specify a different file name. When @var{executable?} is true, make the
  5637. downloaded file executable.
  5638. When one of the URL starts with @code{mirror://}, then its host part is
  5639. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  5640. Alternatively, when URL starts with @code{file://}, return the
  5641. corresponding file name in the store.
  5642. @end deffn
  5643. Likewise, the @code{(guix git-download)} module defines the
  5644. @code{git-fetch} origin method, which fetches data from a Git version
  5645. control repository, and the @code{git-reference} data type to describe
  5646. the repository and revision to fetch.
  5647. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  5648. Return a fixed-output derivation that fetches @var{ref}, a
  5649. @code{<git-reference>} object. The output is expected to have recursive
  5650. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5651. the file name, or a generic name if @code{#f}.
  5652. @end deffn
  5653. @deftp {Data Type} git-reference
  5654. This data type represents a Git reference for @code{git-fetch} to
  5655. retrieve.
  5656. @table @asis
  5657. @item @code{url}
  5658. The URL of the Git repository to clone.
  5659. @item @code{commit}
  5660. This string denotes either the commit to fetch (a hexadecimal string,
  5661. either the full SHA1 commit or a ``short'' commit string; the latter is
  5662. not recommended) or the tag to fetch.
  5663. @item @code{recursive?} (default: @code{#f})
  5664. This Boolean indicates whether to recursively fetch Git sub-modules.
  5665. @end table
  5666. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  5667. repository:
  5668. @lisp
  5669. (git-reference
  5670. (url "https://git.savannah.gnu.org/git/hello.git")
  5671. (commit "v2.10"))
  5672. @end lisp
  5673. This is equivalent to the reference below, which explicitly names the
  5674. commit:
  5675. @lisp
  5676. (git-reference
  5677. (url "https://git.savannah.gnu.org/git/hello.git")
  5678. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  5679. @end lisp
  5680. @end deftp
  5681. For Mercurial repositories, the module @code{(guix hg-download)} defines
  5682. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  5683. support of the Mercurial version control system.
  5684. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  5685. [name]
  5686. Return a fixed-output derivation that fetches @var{ref}, a
  5687. @code{<hg-reference>} object. The output is expected to have recursive
  5688. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5689. the file name, or a generic name if @code{#false}.
  5690. @end deffn
  5691. @node Defining Package Variants
  5692. @section Defining Package Variants
  5693. @cindex customizing packages
  5694. @cindex variants, of packages
  5695. One of the nice things with Guix is that, given a package definition,
  5696. you can easily @emph{derive} variants of that package---for a different
  5697. upstream version, with different dependencies, different compilation
  5698. options, and so on. Some of these custom packages can be defined
  5699. straight from the command line (@pxref{Package Transformation Options}).
  5700. This section describes how to define package variants in code. This can
  5701. be useful in ``manifests'' (@pxref{profile-manifest,
  5702. @option{--manifest}}) and in your own package collection
  5703. (@pxref{Creating a Channel}), among others!
  5704. @cindex inherit, for package definitions
  5705. As discussed earlier, packages are first-class objects in the Scheme
  5706. language. The @code{(guix packages)} module provides the @code{package}
  5707. construct to define new package objects (@pxref{package Reference}).
  5708. The easiest way to define a package variant is using the @code{inherit}
  5709. keyword together with @code{package}. This allows you to inherit from a
  5710. package definition while overriding the fields you want.
  5711. For example, given the @code{hello} variable, which contains a
  5712. definition for the current version of GNU@tie{}Hello, here's how you
  5713. would define a variant for version 2.2 (released in 2006, it's
  5714. vintage!):
  5715. @lisp
  5716. (use-modules (gnu packages base)) ;for 'hello'
  5717. (define hello-2.2
  5718. (package
  5719. (inherit hello)
  5720. (version "2.2")
  5721. (source (origin
  5722. (method url-fetch)
  5723. (uri (string-append "mirror://gnu/hello/hello-" version
  5724. ".tar.gz"))
  5725. (sha256
  5726. (base32
  5727. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  5728. @end lisp
  5729. The example above corresponds to what the @option{--with-source} package
  5730. transformation option does. Essentially @code{hello-2.2} preserves all
  5731. the fields of @code{hello}, except @code{version} and @code{source},
  5732. which it overrides. Note that the original @code{hello} variable is
  5733. still there, in the @code{(gnu packages base)} module, unchanged. When
  5734. you define a custom package like this, you are really @emph{adding} a
  5735. new package definition; the original one remains available.
  5736. You can just as well define variants with a different set of
  5737. dependencies than the original package. For example, the default
  5738. @code{gdb} package depends on @code{guile}, but since that is an
  5739. optional dependency, you can define a variant that removes that
  5740. dependency like so:
  5741. @lisp
  5742. (use-modules (gnu packages gdb) ;for 'gdb'
  5743. (srfi srfi-1)) ;for 'alist-delete'
  5744. (define gdb-sans-guile
  5745. (package
  5746. (inherit gdb)
  5747. (inputs (alist-delete "guile"
  5748. (package-inputs gdb)))))
  5749. @end lisp
  5750. The @code{alist-delete} call above removes the tuple from the
  5751. @code{inputs} field that has @code{"guile"} as its first element
  5752. (@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference
  5753. Manual}).
  5754. In some cases, you may find it useful to write functions
  5755. (``procedures'', in Scheme parlance) that return a package based on some
  5756. parameters. For example, consider the @code{luasocket} library for the
  5757. Lua programming language. We want to create @code{luasocket} packages
  5758. for major versions of Lua. One way to do that is to define a procedure
  5759. that takes a Lua package and returns a @code{luasocket} package that
  5760. depends on it:
  5761. @lisp
  5762. (define (make-lua-socket name lua)
  5763. ;; Return a luasocket package built with LUA.
  5764. (package
  5765. (name name)
  5766. (version "3.0")
  5767. ;; several fields omitted
  5768. (inputs
  5769. `(("lua" ,lua)))
  5770. (synopsis "Socket library for Lua")))
  5771. (define-public lua5.1-socket
  5772. (make-lua-socket "lua5.1-socket" lua-5.1))
  5773. (define-public lua5.2-socket
  5774. (make-lua-socket "lua5.2-socket" lua-5.2))
  5775. @end lisp
  5776. Here we have defined packages @code{lua5.1-socket} and
  5777. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  5778. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  5779. more info on procedures. Having top-level public definitions for these
  5780. two packages means that they can be referred to from the command line
  5781. (@pxref{Package Modules}).
  5782. @cindex package transformations
  5783. These are pretty simple package variants. As a convenience, the
  5784. @code{(guix transformations)} module provides a high-level interface
  5785. that directly maps to the more sophisticated package transformation
  5786. options (@pxref{Package Transformation Options}):
  5787. @deffn {Scheme Procedure} options->transformation @var{opts}
  5788. Return a procedure that, when passed an object to build (package,
  5789. derivation, etc.), applies the transformations specified by @var{opts} and returns
  5790. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  5791. @lisp
  5792. ((with-branch . "guile-gcrypt=master")
  5793. (without-tests . "libgcrypt"))
  5794. @end lisp
  5795. Each symbol names a transformation and the corresponding string is an argument
  5796. to that transformation.
  5797. @end deffn
  5798. For instance, a manifest equivalent to this command:
  5799. @example
  5800. guix build guix \
  5801. --with-branch=guile-gcrypt=master \
  5802. --with-debug-info=zlib
  5803. @end example
  5804. @noindent
  5805. ... would look like this:
  5806. @lisp
  5807. (use-modules (guix transformations))
  5808. (define transform
  5809. ;; The package transformation procedure.
  5810. (options->transformation
  5811. '((with-branch . "guile-gcrypt=master")
  5812. (with-debug-info . "zlib"))))
  5813. (packages->manifest
  5814. (list (transform (specification->package "guix"))))
  5815. @end lisp
  5816. @cindex input rewriting
  5817. @cindex dependency graph rewriting
  5818. The @code{options->transformation} procedure is convenient, but it's
  5819. perhaps also not as flexible as you may like. How is it implemented?
  5820. The astute reader probably noticed that most package transformation
  5821. options go beyond the superficial changes shown in the first examples of
  5822. this section: they involve @dfn{input rewriting}, whereby the dependency
  5823. graph of a package is rewritten by replacing specific inputs by others.
  5824. Dependency graph rewriting, for the purposes of swapping packages in the
  5825. graph, is what the @code{package-input-rewriting} procedure in
  5826. @code{(guix packages)} implements.
  5827. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  5828. [@var{rewrite-name}] [#:deep? #t]
  5829. Return a procedure that, when passed a package, replaces its direct and
  5830. indirect dependencies, including implicit inputs when @var{deep?} is
  5831. true, according to @var{replacements}. @var{replacements} is a list of
  5832. package pairs; the first element of each pair is the package to replace,
  5833. and the second one is the replacement.
  5834. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  5835. the name of a package and returns its new name after rewrite.
  5836. @end deffn
  5837. @noindent
  5838. Consider this example:
  5839. @lisp
  5840. (define libressl-instead-of-openssl
  5841. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  5842. ;; recursively.
  5843. (package-input-rewriting `((,openssl . ,libressl))))
  5844. (define git-with-libressl
  5845. (libressl-instead-of-openssl git))
  5846. @end lisp
  5847. @noindent
  5848. Here we first define a rewriting procedure that replaces @var{openssl}
  5849. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  5850. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  5851. This is exactly what the @option{--with-input} command-line option does
  5852. (@pxref{Package Transformation Options, @option{--with-input}}).
  5853. The following variant of @code{package-input-rewriting} can match packages to
  5854. be replaced by name rather than by identity.
  5855. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  5856. Return a procedure that, given a package, applies the given
  5857. @var{replacements} to all the package graph, including implicit inputs
  5858. unless @var{deep?} is false. @var{replacements} is a list of
  5859. spec/procedures pair; each spec is a package specification such as
  5860. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  5861. package and returns a replacement for that package.
  5862. @end deffn
  5863. The example above could be rewritten this way:
  5864. @lisp
  5865. (define libressl-instead-of-openssl
  5866. ;; Replace all the packages called "openssl" with LibreSSL.
  5867. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  5868. @end lisp
  5869. The key difference here is that, this time, packages are matched by spec and
  5870. not by identity. In other words, any package in the graph that is called
  5871. @code{openssl} will be replaced.
  5872. A more generic procedure to rewrite a package dependency graph is
  5873. @code{package-mapping}: it supports arbitrary changes to nodes in the
  5874. graph.
  5875. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  5876. Return a procedure that, given a package, applies @var{proc} to all the packages
  5877. depended on and returns the resulting package. The procedure stops recursion
  5878. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  5879. applied to implicit inputs as well.
  5880. @end deffn
  5881. @node Build Systems
  5882. @section Build Systems
  5883. @cindex build system
  5884. Each package definition specifies a @dfn{build system} and arguments for
  5885. that build system (@pxref{Defining Packages}). This @code{build-system}
  5886. field represents the build procedure of the package, as well as implicit
  5887. dependencies of that build procedure.
  5888. Build systems are @code{<build-system>} objects. The interface to
  5889. create and manipulate them is provided by the @code{(guix build-system)}
  5890. module, and actual build systems are exported by specific modules.
  5891. @cindex bag (low-level package representation)
  5892. Under the hood, build systems first compile package objects to
  5893. @dfn{bags}. A @dfn{bag} is like a package, but with less
  5894. ornamentation---in other words, a bag is a lower-level representation of
  5895. a package, which includes all the inputs of that package, including some
  5896. that were implicitly added by the build system. This intermediate
  5897. representation is then compiled to a derivation (@pxref{Derivations}).
  5898. The @code{package-with-c-toolchain} is an example of a way to change the
  5899. implicit inputs that a package's build system pulls in (@pxref{package
  5900. Reference, @code{package-with-c-toolchain}}).
  5901. Build systems accept an optional list of @dfn{arguments}. In package
  5902. definitions, these are passed @i{via} the @code{arguments} field
  5903. (@pxref{Defining Packages}). They are typically keyword arguments
  5904. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  5905. Guile Reference Manual}). The value of these arguments is usually
  5906. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  5907. by the daemon (@pxref{Derivations}).
  5908. The main build system is @code{gnu-build-system}, which implements the
  5909. standard build procedure for GNU and many other packages. It
  5910. is provided by the @code{(guix build-system gnu)} module.
  5911. @defvr {Scheme Variable} gnu-build-system
  5912. @code{gnu-build-system} represents the GNU Build System, and variants
  5913. thereof (@pxref{Configuration, configuration and makefile conventions,,
  5914. standards, GNU Coding Standards}).
  5915. @cindex build phases
  5916. In a nutshell, packages using it are configured, built, and installed with
  5917. the usual @code{./configure && make && make check && make install}
  5918. command sequence. In practice, a few additional steps are often needed.
  5919. All these steps are split up in separate @dfn{phases}.
  5920. @xref{Build Phases}, for more info on build phases and ways to customize
  5921. them.
  5922. In addition, this build system ensures that the ``standard'' environment
  5923. for GNU packages is available. This includes tools such as GCC, libc,
  5924. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  5925. build-system gnu)} module for a complete list). We call these the
  5926. @dfn{implicit inputs} of a package, because package definitions do not
  5927. have to mention them.
  5928. This build system supports a number of keyword arguments, which can be
  5929. passed @i{via} the @code{arguments} field of a package. Here are some
  5930. of the main parameters:
  5931. @table @code
  5932. @item #:phases
  5933. This argument specifies build-side code that evaluates to an alist of
  5934. build phases. @xref{Build Phases}, for more information.
  5935. @item #:configure-flags
  5936. This is a list of flags (strings) passed to the @command{configure}
  5937. script. @xref{Defining Packages}, for an example.
  5938. @item #:make-flags
  5939. This list of strings contains flags passed as arguments to
  5940. @command{make} invocations in the @code{build}, @code{check}, and
  5941. @code{install} phases.
  5942. @item #:out-of-source?
  5943. This Boolean, @code{#f} by default, indicates whether to run builds in a
  5944. build directory separate from the source tree.
  5945. When it is true, the @code{configure} phase creates a separate build
  5946. directory, changes to that directory, and runs the @code{configure}
  5947. script from there. This is useful for packages that require it, such as
  5948. @code{glibc}.
  5949. @item #:tests?
  5950. This Boolean, @code{#t} by default, indicates whether the @code{check}
  5951. phase should run the package's test suite.
  5952. @item #:test-target
  5953. This string, @code{"check"} by default, gives the name of the makefile
  5954. target used by the @code{check} phase.
  5955. @item #:parallel-build?
  5956. @itemx #:parallel-tests?
  5957. These Boolean values specify whether to build, respectively run the test
  5958. suite, in parallel, with the @code{-j} flag of @command{make}. When
  5959. they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
  5960. the number specified as the @option{--cores} option of
  5961. @command{guix-daemon} or that of the @command{guix} client command
  5962. (@pxref{Common Build Options, @option{--cores}}).
  5963. @cindex RUNPATH, validation
  5964. @item #:validate-runpath?
  5965. This Boolean, @code{#t} by default, determines whether to ``validate''
  5966. the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
  5967. as executables) previously installed by the @code{install} phase.
  5968. This validation step consists in making sure that all the shared
  5969. libraries needed by an ELF binaries, which are listed as
  5970. @code{DT_NEEDED} entries in its @code{PT_DYNAMIC} segment, appear in the
  5971. @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
  5972. running or using those binaries will not result in a ``file not found''
  5973. error at run time. @xref{Options, @option{-rpath},, ld, The GNU
  5974. Linker}, for more information on @code{RUNPATH}.
  5975. @item #:substitutable?
  5976. This Boolean, @code{#t} by default, tells whether the package outputs
  5977. should be substitutable---i.e., whether users should be able to obtain
  5978. substitutes for them instead of building locally (@pxref{Substitutes}).
  5979. @item #:allowed-references
  5980. @itemx #:disallowed-references
  5981. When true, these arguments must be a list of dependencies that must not
  5982. appear among the references of the build results. If, upon build
  5983. completion, some of these references are retained, the build process
  5984. fails.
  5985. This is useful to ensure that a package does not erroneously keep a
  5986. reference to some of it build-time inputs, in cases where doing so
  5987. would, for example, unnecessarily increase its size (@pxref{Invoking
  5988. guix size}).
  5989. @end table
  5990. Most other build systems support these keyword arguments.
  5991. @end defvr
  5992. Other @code{<build-system>} objects are defined to support other
  5993. conventions and tools used by free software packages. They inherit most
  5994. of @code{gnu-build-system}, and differ mainly in the set of inputs
  5995. implicitly added to the build process, and in the list of phases
  5996. executed. Some of these build systems are listed below.
  5997. @defvr {Scheme Variable} ant-build-system
  5998. This variable is exported by @code{(guix build-system ant)}. It
  5999. implements the build procedure for Java packages that can be built with
  6000. @url{https://ant.apache.org/, Ant build tool}.
  6001. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  6002. provided by the @code{icedtea} package to the set of inputs. Different
  6003. packages can be specified with the @code{#:ant} and @code{#:jdk}
  6004. parameters, respectively.
  6005. When the original package does not provide a suitable Ant build file,
  6006. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  6007. build file @file{build.xml} with tasks to build the specified jar
  6008. archive. In this case the parameter @code{#:source-dir} can be used to
  6009. specify the source sub-directory, defaulting to ``src''.
  6010. The @code{#:main-class} parameter can be used with the minimal ant
  6011. buildfile to specify the main class of the resulting jar. This makes the
  6012. jar file executable. The @code{#:test-include} parameter can be used to
  6013. specify the list of junit tests to run. It defaults to
  6014. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  6015. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  6016. because abstract classes cannot be run as tests.
  6017. The parameter @code{#:build-target} can be used to specify the Ant task
  6018. that should be run during the @code{build} phase. By default the
  6019. ``jar'' task will be run.
  6020. @end defvr
  6021. @defvr {Scheme Variable} android-ndk-build-system
  6022. @cindex Android distribution
  6023. @cindex Android NDK build system
  6024. This variable is exported by @code{(guix build-system android-ndk)}. It
  6025. implements a build procedure for Android NDK (native development kit)
  6026. packages using a Guix-specific build process.
  6027. The build system assumes that packages install their public interface
  6028. (header) files to the subdirectory @file{include} of the @code{out} output and
  6029. their libraries to the subdirectory @file{lib} the @code{out} output.
  6030. It's also assumed that the union of all the dependencies of a package
  6031. has no conflicting files.
  6032. For the time being, cross-compilation is not supported - so right now
  6033. the libraries and header files are assumed to be host tools.
  6034. @end defvr
  6035. @defvr {Scheme Variable} asdf-build-system/source
  6036. @defvrx {Scheme Variable} asdf-build-system/sbcl
  6037. @defvrx {Scheme Variable} asdf-build-system/ecl
  6038. These variables, exported by @code{(guix build-system asdf)}, implement
  6039. build procedures for Common Lisp packages using
  6040. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  6041. definition facility for Common Lisp programs and libraries.
  6042. The @code{asdf-build-system/source} system installs the packages in
  6043. source form, and can be loaded using any common lisp implementation, via
  6044. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  6045. systems in the format which a particular implementation understands.
  6046. These build systems can also be used to produce executable programs, or
  6047. lisp images which contain a set of packages pre-loaded.
  6048. The build system uses naming conventions. For binary packages, the
  6049. package name should be prefixed with the lisp implementation, such as
  6050. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  6051. Additionally, the corresponding source package should be labeled using
  6052. the same convention as python packages (see @ref{Python Modules}), using
  6053. the @code{cl-} prefix.
  6054. In order to create executable programs and images, the build-side
  6055. procedures @code{build-program} and @code{build-image} can be used.
  6056. They should be called in a build phase after the
  6057. @code{create-asdf-configuration} phase, so that the system which was
  6058. just built can be used within the resulting image. @code{build-program}
  6059. requires a list of Common Lisp expressions to be passed as the
  6060. @code{#:entry-program} argument.
  6061. By default, all the @file{.asd} files present in the sources are read to
  6062. find system definitions. The @code{#:asd-files} parameter can be used
  6063. to specify the list of @file{.asd} files to read. Furthermore, if the
  6064. package defines a system for its tests in a separate file, it will be
  6065. loaded before the tests are run if it is specified by the
  6066. @code{#:test-asd-file} parameter. If it is not set, the files
  6067. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  6068. and @code{test.asd} will be tried if they exist.
  6069. If for some reason the package must be named in a different way than the
  6070. naming conventions suggest, or if several systems must be compiled, the
  6071. @code{#:asd-systems} parameter can be used to specify the list of system
  6072. names.
  6073. @end defvr
  6074. @defvr {Scheme Variable} cargo-build-system
  6075. @cindex Rust programming language
  6076. @cindex Cargo (Rust build system)
  6077. This variable is exported by @code{(guix build-system cargo)}. It
  6078. supports builds of packages using Cargo, the build tool of the
  6079. @uref{https://www.rust-lang.org, Rust programming language}.
  6080. It adds @code{rustc} and @code{cargo} to the set of inputs.
  6081. A different Rust package can be specified with the @code{#:rust} parameter.
  6082. Regular cargo dependencies should be added to the package definition similarly
  6083. to other packages; those needed only at build time to native-inputs, others to
  6084. inputs. If you need to add source-only crates then you should add them to via
  6085. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  6086. spec can be a package or a source definition. Note that the spec must
  6087. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  6088. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  6089. should be added to the package definition via the
  6090. @code{#:cargo-development-inputs} parameter.
  6091. In its @code{configure} phase, this build system will make any source inputs
  6092. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  6093. parameters available to cargo. It will also remove an included
  6094. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  6095. @code{build} phase. The @code{package} phase will run @code{cargo package}
  6096. to create a source crate for future use. The @code{install} phase installs
  6097. the binaries defined by the crate. Unless @code{install-source? #f} is
  6098. defined it will also install a source crate repository of itself and unpacked
  6099. sources, to ease in future hacking on rust packages.
  6100. @end defvr
  6101. @defvr {Scheme Variable} chicken-build-system
  6102. This variable is exported by @code{(guix build-system chicken)}. It
  6103. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  6104. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  6105. gets compiled by a C compiler, in this case GCC.
  6106. This build system adds @code{chicken} to the package inputs, as well as
  6107. the packages of @code{gnu-build-system}.
  6108. The build system can't (yet) deduce the egg's name automatically, so just like
  6109. with @code{go-build-system} and its @code{#:import-path}, you should define
  6110. @code{#:egg-name} in the package's @code{arguments} field.
  6111. For example, if you are packaging the @code{srfi-1} egg:
  6112. @lisp
  6113. (arguments '(#:egg-name "srfi-1"))
  6114. @end lisp
  6115. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  6116. because CHICKEN doesn't embed absolute references in compiled eggs.
  6117. Test dependencies should go to @code{native-inputs}, as usual.
  6118. @end defvr
  6119. @defvr {Scheme Variable} copy-build-system
  6120. This variable is exported by @code{(guix build-system copy)}. It
  6121. supports builds of simple packages that don't require much compiling,
  6122. mostly just moving files around.
  6123. It adds much of the @code{gnu-build-system} packages to the set of
  6124. inputs. Because of this, the @code{copy-build-system} does not require
  6125. all the boilerplate code often needed for the
  6126. @code{trivial-build-system}.
  6127. To further simplify the file installation process, an
  6128. @code{#:install-plan} argument is exposed to let the packager specify
  6129. which files go where. The install plan is a list of @code{(@var{source}
  6130. @var{target} [@var{filters}])}. @var{filters} are optional.
  6131. @itemize
  6132. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  6133. @itemize
  6134. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  6135. @item Otherwise install @var{source} as @var{target}.
  6136. @end itemize
  6137. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  6138. the trailing slash of @var{target} is implied with the same meaning
  6139. as above.
  6140. @itemize
  6141. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  6142. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  6143. @code{#:exclude-regexp}, only select files are installed depending on
  6144. the filters. Each filters is specified by a list of strings.
  6145. @itemize
  6146. @item With @code{#:include}, install all the files which the path suffix matches
  6147. at least one of the elements in the given list.
  6148. @item With @code{#:include-regexp}, install all the files which the
  6149. subpaths match at least one of the regular expressions in the given
  6150. list.
  6151. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6152. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6153. install all files but those matching the exclusion filters.
  6154. If both inclusions and exclusions are specified, the exclusions are done
  6155. on top of the inclusions.
  6156. @end itemize
  6157. @end itemize
  6158. In all cases, the paths relative to @var{source} are preserved within
  6159. @var{target}.
  6160. @end itemize
  6161. Examples:
  6162. @itemize
  6163. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6164. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6165. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6166. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6167. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6168. @file{share/my-app/sub/file}.
  6169. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6170. @file{share/my-app/file}.
  6171. @end itemize
  6172. @end defvr
  6173. @cindex Clojure (programming language)
  6174. @cindex simple Clojure build system
  6175. @defvr {Scheme Variable} clojure-build-system
  6176. This variable is exported by @code{(guix build-system clojure)}. It implements
  6177. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6178. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6179. yet.
  6180. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6181. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6182. @code{#:zip} parameters, respectively.
  6183. A list of source directories, test directories and jar names can be specified
  6184. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6185. parameters, respectively. Compile directory and main class can be specified
  6186. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6187. Other parameters are documented below.
  6188. This build system is an extension of @code{ant-build-system}, but with the
  6189. following phases changed:
  6190. @table @code
  6191. @item build
  6192. This phase calls @code{compile} in Clojure to compile source files and runs
  6193. @command{jar} to create jars from both source files and compiled files
  6194. according to the include list and exclude list specified in
  6195. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6196. has priority over the include list. These lists consist of symbols
  6197. representing Clojure libraries or the special keyword @code{#:all} representing
  6198. all Clojure libraries found under the source directories. The parameter
  6199. @code{#:omit-source?} decides if source should be included into the jars.
  6200. @item check
  6201. This phase runs tests according to the include list and exclude list specified
  6202. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6203. meanings are analogous to that of @code{#:aot-include} and
  6204. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6205. stands for all Clojure libraries found under the test directories. The
  6206. parameter @code{#:tests?} decides if tests should be run.
  6207. @item install
  6208. This phase installs all jars built previously.
  6209. @end table
  6210. Apart from the above, this build system also contains an additional phase:
  6211. @table @code
  6212. @item install-doc
  6213. This phase installs all top-level files with base name matching
  6214. @code{%doc-regex}. A different regex can be specified with the
  6215. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6216. directories specified in @code{#:doc-dirs} are installed as well.
  6217. @end table
  6218. @end defvr
  6219. @defvr {Scheme Variable} cmake-build-system
  6220. This variable is exported by @code{(guix build-system cmake)}. It
  6221. implements the build procedure for packages using the
  6222. @url{https://www.cmake.org, CMake build tool}.
  6223. It automatically adds the @code{cmake} package to the set of inputs.
  6224. Which package is used can be specified with the @code{#:cmake}
  6225. parameter.
  6226. The @code{#:configure-flags} parameter is taken as a list of flags
  6227. passed to the @command{cmake} command. The @code{#:build-type}
  6228. parameter specifies in abstract terms the flags passed to the compiler;
  6229. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6230. debugging information''), which roughly means that code is compiled with
  6231. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6232. @end defvr
  6233. @defvr {Scheme Variable} dune-build-system
  6234. This variable is exported by @code{(guix build-system dune)}. It
  6235. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6236. tool for the OCaml programming language. It is implemented as an extension
  6237. of the @code{ocaml-build-system} which is described below. As such, the
  6238. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6239. system.
  6240. It automatically adds the @code{dune} package to the set of inputs.
  6241. Which package is used can be specified with the @code{#:dune}
  6242. parameter.
  6243. There is no @code{configure} phase because dune packages typically don't
  6244. need to be configured. The @code{#:build-flags} parameter is taken as a
  6245. list of flags passed to the @code{dune} command during the build.
  6246. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6247. command instead of the more recent @code{dune} command while building
  6248. a package. Its default value is @code{#f}.
  6249. The @code{#:package} parameter can be passed to specify a package name, which
  6250. is useful when a package contains multiple packages and you want to build
  6251. only one of them. This is equivalent to passing the @code{-p} argument to
  6252. @code{dune}.
  6253. @end defvr
  6254. @defvr {Scheme Variable} go-build-system
  6255. This variable is exported by @code{(guix build-system go)}. It
  6256. implements a build procedure for Go packages using the standard
  6257. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6258. Go build mechanisms}.
  6259. The user is expected to provide a value for the key @code{#:import-path}
  6260. and, in some cases, @code{#:unpack-path}. The
  6261. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6262. corresponds to the file system path expected by the package's build
  6263. scripts and any referring packages, and provides a unique way to
  6264. refer to a Go package. It is typically based on a combination of the
  6265. package source code's remote URI and file system hierarchy structure. In
  6266. some cases, you will need to unpack the package's source code to a
  6267. different directory structure than the one indicated by the import path,
  6268. and @code{#:unpack-path} should be used in such cases.
  6269. Packages that provide Go libraries should install their source code into
  6270. the built output. The key @code{#:install-source?}, which defaults to
  6271. @code{#t}, controls whether or not the source code is installed. It can
  6272. be set to @code{#f} for packages that only provide executable files.
  6273. @end defvr
  6274. @defvr {Scheme Variable} glib-or-gtk-build-system
  6275. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6276. is intended for use with packages making use of GLib or GTK+.
  6277. This build system adds the following two phases to the ones defined by
  6278. @code{gnu-build-system}:
  6279. @table @code
  6280. @item glib-or-gtk-wrap
  6281. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6282. @file{bin/} are able to find GLib ``schemas'' and
  6283. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6284. modules}. This is achieved by wrapping the programs in launch scripts
  6285. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6286. environment variables.
  6287. It is possible to exclude specific package outputs from that wrapping
  6288. process by listing their names in the
  6289. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6290. when an output is known not to contain any GLib or GTK+ binaries, and
  6291. where wrapping would gratuitously add a dependency of that output on
  6292. GLib and GTK+.
  6293. @item glib-or-gtk-compile-schemas
  6294. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6295. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6296. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6297. @command{glib-compile-schemas} program. It is provided by the package
  6298. @code{glib:bin} which is automatically imported by the build system.
  6299. The @code{glib} package providing @command{glib-compile-schemas} can be
  6300. specified with the @code{#:glib} parameter.
  6301. @end table
  6302. Both phases are executed after the @code{install} phase.
  6303. @end defvr
  6304. @defvr {Scheme Variable} guile-build-system
  6305. This build system is for Guile packages that consist exclusively of Scheme
  6306. code and that are so lean that they don't even have a makefile, let alone a
  6307. @file{configure} script. It compiles Scheme code using @command{guild
  6308. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6309. installs the @file{.scm} and @file{.go} files in the right place. It also
  6310. installs documentation.
  6311. This build system supports cross-compilation by using the
  6312. @option{--target} option of @samp{guild compile}.
  6313. Packages built with @code{guile-build-system} must provide a Guile package in
  6314. their @code{native-inputs} field.
  6315. @end defvr
  6316. @defvr {Scheme Variable} julia-build-system
  6317. This variable is exported by @code{(guix build-system julia)}. It
  6318. implements the build procedure used by @uref{https://julialang.org/,
  6319. julia} packages, which essentially is similar to running @samp{julia -e
  6320. 'using Pkg; Pkg.add(package)'} in an environment where
  6321. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6322. Tests are run by calling @code{/test/runtests.jl}.
  6323. The Julia package name is read from the file @file{Project.toml}. This
  6324. value can be overridden by passing the argument @code{#:julia-package-name}
  6325. (which must be correctly capitalized).
  6326. Julia packages usually manage their binary dependencies via
  6327. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  6328. after the wrapped library followed by @code{_jll.jl}.
  6329. To add the binary path @code{_jll.jl} packages, you need to patch the
  6330. files under @file{src/wrappers/}, replacing the call to the macro
  6331. @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
  6332. argument containing the store path the binary.
  6333. As an example, in the MbedTLS Julia package, we add a build phase
  6334. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  6335. MbedTLS package:
  6336. @lisp
  6337. (add-after 'unpack 'override-binary-path
  6338. (lambda* (#:key inputs #:allow-other-keys)
  6339. (for-each (lambda (wrapper)
  6340. (substitute* wrapper
  6341. (("generate_wrapper_header.*")
  6342. (string-append
  6343. "generate_wrapper_header(\"MbedTLS\", \""
  6344. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  6345. ;; There's a Julia file for each platform, override them all.
  6346. (find-files "src/wrappers/" "\\.jl$"))))
  6347. @end lisp
  6348. Some older packages that aren't using @file{Package.toml} yet, will require
  6349. this file to be created, too. The function @code{julia-create-package-toml}
  6350. helps creating the file. You need to pass the outputs and the source of the
  6351. package, it's name (the same as the @code{file-name} parameter), the package
  6352. uuid, the package version, and a list of dependencies specified by their name
  6353. and their uuid.
  6354. @end defvr
  6355. @defvr {Scheme Variable} maven-build-system
  6356. This variable is exported by @code{(guix build-system maven)}. It implements
  6357. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6358. is a dependency and lifecycle management tool for Java. A user of Maven
  6359. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6360. When Maven does not have one of the dependencies or plugins in its repository,
  6361. it will download them and use them to build the package.
  6362. The maven build system ensures that maven will not try to download any
  6363. dependency by running in offline mode. Maven will fail if a dependency is
  6364. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6365. modified to specify the version of dependencies and plugins that match the
  6366. versions available in the guix build environment. Dependencies and plugins
  6367. must be installed in the fake maven repository at @file{lib/m2}, and are
  6368. symlinked into a proper repository before maven is run. Maven is instructed
  6369. to use that repository for the build and installs built artifacts there.
  6370. Changed files are copied to the @file{lib/m2} directory of the package output.
  6371. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6372. or let the build system use the default @file{pom.xml} file in the sources.
  6373. In case you need to specify a dependency's version manually, you can use the
  6374. @code{#:local-packages} argument. It takes an association list where the key
  6375. is the groupId of the package and its value is an association list where the
  6376. key is the artifactId of the package and its value is the version you want to
  6377. override in the @file{pom.xml}.
  6378. Some packages use dependencies or plugins that are not useful at runtime nor
  6379. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6380. using the @code{#:exclude} argument. Its value is an association list where
  6381. the key is the groupId of the plugin or dependency you want to remove, and
  6382. the value is a list of artifactId you want to remove.
  6383. You can override the default @code{jdk} and @code{maven} packages with the
  6384. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6385. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6386. the build, with the same format as the @code{inputs} fields of the package
  6387. declaration. Its default value is @code{(default-maven-plugins)} which is
  6388. also exported.
  6389. @end defvr
  6390. @defvr {Scheme Variable} minify-build-system
  6391. This variable is exported by @code{(guix build-system minify)}. It
  6392. implements a minification procedure for simple JavaScript packages.
  6393. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6394. all JavaScript files in the @file{src} directory. A different minifier
  6395. package can be specified with the @code{#:uglify-js} parameter, but it
  6396. is expected that the package writes the minified code to the standard
  6397. output.
  6398. When the input JavaScript files are not all located in the @file{src}
  6399. directory, the parameter @code{#:javascript-files} can be used to
  6400. specify a list of file names to feed to the minifier.
  6401. @end defvr
  6402. @defvr {Scheme Variable} ocaml-build-system
  6403. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6404. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6405. of choosing the correct set of commands to run for each package. OCaml
  6406. packages can expect many different commands to be run. This build system will
  6407. try some of them.
  6408. When the package has a @file{setup.ml} file present at the top-level, it will
  6409. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6410. @code{ocaml setup.ml -install}. The build system will assume that this file
  6411. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6412. care of setting the prefix and enabling tests if they are not disabled. You
  6413. can pass configure and build flags with the @code{#:configure-flags} and
  6414. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6415. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6416. bypass this system in the build and install phases.
  6417. When the package has a @file{configure} file, it is assumed that it is a
  6418. hand-made configure script that requires a different argument format than
  6419. in the @code{gnu-build-system}. You can add more flags with the
  6420. @code{#:configure-flags} key.
  6421. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6422. @code{#t}), it will be used and more flags can be passed to the build and
  6423. install phases with the @code{#:make-flags} key.
  6424. Finally, some packages do not have these files and use a somewhat standard
  6425. location for its build system. In that case, the build system will run
  6426. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6427. providing the path to the required findlib module. Additional flags can
  6428. be passed via the @code{#:build-flags} key. Install is taken care of by
  6429. @command{opam-installer}. In this case, the @code{opam} package must
  6430. be added to the @code{native-inputs} field of the package definition.
  6431. Note that most OCaml packages assume they will be installed in the same
  6432. directory as OCaml, which is not what we want in guix. In particular, they
  6433. will install @file{.so} files in their module's directory, which is usually
  6434. fine because it is in the OCaml compiler directory. In guix though, these
  6435. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6436. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6437. @file{.so} libraries should be installed.
  6438. @end defvr
  6439. @defvr {Scheme Variable} python-build-system
  6440. This variable is exported by @code{(guix build-system python)}. It
  6441. implements the more or less standard build procedure used by Python
  6442. packages, which consists in running @code{python setup.py build} and
  6443. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6444. For packages that install stand-alone Python programs under @code{bin/},
  6445. it takes care of wrapping these programs so that their
  6446. @env{GUIX_PYTHONPATH} environment variable points to all the Python
  6447. libraries they depend on.
  6448. Which Python package is used to perform the build can be specified with
  6449. the @code{#:python} parameter. This is a useful way to force a package
  6450. to be built for a specific version of the Python interpreter, which
  6451. might be necessary if the package is only compatible with a single
  6452. interpreter version.
  6453. By default guix calls @code{setup.py} under control of
  6454. @code{setuptools}, much like @command{pip} does. Some packages are not
  6455. compatible with setuptools (and pip), thus you can disable this by
  6456. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6457. If a @code{"python"} output is available, the package is installed into it
  6458. instead of the default @code{"out"} output. This is useful for packages that
  6459. include a Python package as only a part of the software, and thus want to
  6460. combine the phases of @code{python-build-system} with another build system.
  6461. Python bindings are a common usecase.
  6462. @end defvr
  6463. @defvr {Scheme Variable} perl-build-system
  6464. This variable is exported by @code{(guix build-system perl)}. It
  6465. implements the standard build procedure for Perl packages, which either
  6466. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6467. followed by @code{Build} and @code{Build install}; or in running
  6468. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  6469. @code{make} and @code{make install}, depending on which of
  6470. @code{Build.PL} or @code{Makefile.PL} is present in the package
  6471. distribution. Preference is given to the former if both @code{Build.PL}
  6472. and @code{Makefile.PL} exist in the package distribution. This
  6473. preference can be reversed by specifying @code{#t} for the
  6474. @code{#:make-maker?} parameter.
  6475. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  6476. passes flags specified by the @code{#:make-maker-flags} or
  6477. @code{#:module-build-flags} parameter, respectively.
  6478. Which Perl package is used can be specified with @code{#:perl}.
  6479. @end defvr
  6480. @defvr {Scheme Variable} renpy-build-system
  6481. This variable is exported by @code{(guix build-system renpy)}. It implements
  6482. the more or less standard build procedure used by Ren'py games, which consists
  6483. of loading @code{#:game} once, thereby creating bytecode for it.
  6484. It further creates a wrapper script in @code{bin/} and a desktop entry in
  6485. @code{share/applications}, both of which can be used to launch the game.
  6486. Which Ren'py package is used can be specified with @code{#:renpy}.
  6487. Games can also be installed in outputs other than ``out'' by using
  6488. @code{#:output}.
  6489. @end defvr
  6490. @defvr {Scheme Variable} qt-build-system
  6491. This variable is exported by @code{(guix build-system qt)}. It
  6492. is intended for use with applications using Qt or KDE.
  6493. This build system adds the following two phases to the ones defined by
  6494. @code{cmake-build-system}:
  6495. @table @code
  6496. @item check-setup
  6497. The phase @code{check-setup} prepares the environment for running
  6498. the checks as commonly used by Qt test programs.
  6499. For now this only sets some environment variables:
  6500. @code{QT_QPA_PLATFORM=offscreen},
  6501. @code{DBUS_FATAL_WARNINGS=0} and
  6502. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  6503. This phase is added before the @code{check} phase.
  6504. It's a separate phase to ease adjusting if necessary.
  6505. @item qt-wrap
  6506. The phase @code{qt-wrap}
  6507. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  6508. and output. In case some path is found, all programs in the output's
  6509. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  6510. are wrapped in scripts defining the necessary environment variables.
  6511. It is possible to exclude specific package outputs from that wrapping process
  6512. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  6513. This is useful when an output is known not to contain any Qt binaries, and
  6514. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  6515. or such.
  6516. This phase is added after the @code{install} phase.
  6517. @end table
  6518. @end defvr
  6519. @defvr {Scheme Variable} r-build-system
  6520. This variable is exported by @code{(guix build-system r)}. It
  6521. implements the build procedure used by @uref{https://r-project.org, R}
  6522. packages, which essentially is little more than running @samp{R CMD
  6523. INSTALL --library=/gnu/store/@dots{}} in an environment where
  6524. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  6525. run after installation using the R function
  6526. @code{tools::testInstalledPackage}.
  6527. @end defvr
  6528. @defvr {Scheme Variable} rakudo-build-system
  6529. This variable is exported by @code{(guix build-system rakudo)}. It
  6530. implements the build procedure used by @uref{https://rakudo.org/,
  6531. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  6532. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  6533. installs the binaries, library files and the resources, as well as wrap
  6534. the files under the @code{bin/} directory. Tests can be skipped by
  6535. passing @code{#f} to the @code{tests?} parameter.
  6536. Which rakudo package is used can be specified with @code{rakudo}.
  6537. Which perl6-tap-harness package used for the tests can be specified with
  6538. @code{#:prove6} or removed by passing @code{#f} to the
  6539. @code{with-prove6?} parameter.
  6540. Which perl6-zef package used for tests and installing can be specified
  6541. with @code{#:zef} or removed by passing @code{#f} to the
  6542. @code{with-zef?} parameter.
  6543. @end defvr
  6544. @defvr {Scheme Variable} texlive-build-system
  6545. This variable is exported by @code{(guix build-system texlive)}. It is
  6546. used to build TeX packages in batch mode with a specified engine. The
  6547. build system sets the @env{TEXINPUTS} variable to find all TeX source
  6548. files in the inputs.
  6549. By default it runs @code{luatex} on all files ending on @code{ins}. A
  6550. different engine and format can be specified with the
  6551. @code{#:tex-format} argument. Different build targets can be specified
  6552. with the @code{#:build-targets} argument, which expects a list of file
  6553. names. The build system adds only @code{texlive-bin} and
  6554. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  6555. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  6556. and @code{#:texlive-latex-base}, respectively.
  6557. The @code{#:tex-directory} parameter tells the build system where to
  6558. install the built files under the texmf tree.
  6559. @end defvr
  6560. @defvr {Scheme Variable} ruby-build-system
  6561. This variable is exported by @code{(guix build-system ruby)}. It
  6562. implements the RubyGems build procedure used by Ruby packages, which
  6563. involves running @code{gem build} followed by @code{gem install}.
  6564. The @code{source} field of a package that uses this build system
  6565. typically references a gem archive, since this is the format that Ruby
  6566. developers use when releasing their software. The build system unpacks
  6567. the gem archive, potentially patches the source, runs the test suite,
  6568. repackages the gem, and installs it. Additionally, directories and
  6569. tarballs may be referenced to allow building unreleased gems from Git or
  6570. a traditional source release tarball.
  6571. Which Ruby package is used can be specified with the @code{#:ruby}
  6572. parameter. A list of additional flags to be passed to the @command{gem}
  6573. command can be specified with the @code{#:gem-flags} parameter.
  6574. @end defvr
  6575. @defvr {Scheme Variable} waf-build-system
  6576. This variable is exported by @code{(guix build-system waf)}. It
  6577. implements a build procedure around the @code{waf} script. The common
  6578. phases---@code{configure}, @code{build}, and @code{install}---are
  6579. implemented by passing their names as arguments to the @code{waf}
  6580. script.
  6581. The @code{waf} script is executed by the Python interpreter. Which
  6582. Python package is used to run the script can be specified with the
  6583. @code{#:python} parameter.
  6584. @end defvr
  6585. @defvr {Scheme Variable} scons-build-system
  6586. This variable is exported by @code{(guix build-system scons)}. It
  6587. implements the build procedure used by the SCons software construction
  6588. tool. This build system runs @code{scons} to build the package,
  6589. @code{scons test} to run tests, and then @code{scons install} to install
  6590. the package.
  6591. Additional flags to be passed to @code{scons} can be specified with the
  6592. @code{#:scons-flags} parameter. The default build and install targets
  6593. can be overridden with @code{#:build-targets} and
  6594. @code{#:install-targets} respectively. The version of Python used to
  6595. run SCons can be specified by selecting the appropriate SCons package
  6596. with the @code{#:scons} parameter.
  6597. @end defvr
  6598. @defvr {Scheme Variable} haskell-build-system
  6599. This variable is exported by @code{(guix build-system haskell)}. It
  6600. implements the Cabal build procedure used by Haskell packages, which
  6601. involves running @code{runhaskell Setup.hs configure
  6602. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  6603. Instead of installing the package by running @code{runhaskell Setup.hs
  6604. install}, to avoid trying to register libraries in the read-only
  6605. compiler store directory, the build system uses @code{runhaskell
  6606. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  6607. addition, the build system generates the package documentation by
  6608. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  6609. is passed. Optional Haddock parameters can be passed with the help of
  6610. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  6611. not found, the build system looks for @code{Setup.lhs} instead.
  6612. Which Haskell compiler is used can be specified with the @code{#:haskell}
  6613. parameter which defaults to @code{ghc}.
  6614. @end defvr
  6615. @defvr {Scheme Variable} dub-build-system
  6616. This variable is exported by @code{(guix build-system dub)}. It
  6617. implements the Dub build procedure used by D packages, which
  6618. involves running @code{dub build} and @code{dub run}.
  6619. Installation is done by copying the files manually.
  6620. Which D compiler is used can be specified with the @code{#:ldc}
  6621. parameter which defaults to @code{ldc}.
  6622. @end defvr
  6623. @anchor{emacs-build-system}
  6624. @defvr {Scheme Variable} emacs-build-system
  6625. This variable is exported by @code{(guix build-system emacs)}. It
  6626. implements an installation procedure similar to the packaging system
  6627. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  6628. It first creates the @code{@code{package}-autoloads.el} file, then it
  6629. byte compiles all Emacs Lisp files. Differently from the Emacs
  6630. packaging system, the Info documentation files are moved to the standard
  6631. documentation directory and the @file{dir} file is deleted. The Elisp
  6632. package files are installed directly under @file{share/emacs/site-lisp}.
  6633. @end defvr
  6634. @defvr {Scheme Variable} font-build-system
  6635. This variable is exported by @code{(guix build-system font)}. It
  6636. implements an installation procedure for font packages where upstream
  6637. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  6638. need to be copied into place. It copies font files to standard
  6639. locations in the output directory.
  6640. @end defvr
  6641. @defvr {Scheme Variable} meson-build-system
  6642. This variable is exported by @code{(guix build-system meson)}. It
  6643. implements the build procedure for packages that use
  6644. @url{https://mesonbuild.com, Meson} as their build system.
  6645. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  6646. of inputs, and they can be changed with the parameters @code{#:meson}
  6647. and @code{#:ninja} if needed.
  6648. This build system is an extension of @code{gnu-build-system}, but with the
  6649. following phases changed to some specific for Meson:
  6650. @table @code
  6651. @item configure
  6652. The phase runs @code{meson} with the flags specified in
  6653. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  6654. @code{debugoptimized} unless something else is specified in
  6655. @code{#:build-type}.
  6656. @item build
  6657. The phase runs @code{ninja} to build the package in parallel by default, but
  6658. this can be changed with @code{#:parallel-build?}.
  6659. @item check
  6660. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  6661. which is @code{"test"} by default.
  6662. @item install
  6663. The phase runs @code{ninja install} and can not be changed.
  6664. @end table
  6665. Apart from that, the build system also adds the following phases:
  6666. @table @code
  6667. @item fix-runpath
  6668. This phase ensures that all binaries can find the libraries they need.
  6669. It searches for required libraries in subdirectories of the package
  6670. being built, and adds those to @code{RUNPATH} where needed. It also
  6671. removes references to libraries left over from the build phase by
  6672. @code{meson}, such as test dependencies, that aren't actually required
  6673. for the program to run.
  6674. @item glib-or-gtk-wrap
  6675. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6676. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6677. @item glib-or-gtk-compile-schemas
  6678. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6679. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6680. @end table
  6681. @end defvr
  6682. @defvr {Scheme Variable} linux-module-build-system
  6683. @code{linux-module-build-system} allows building Linux kernel modules.
  6684. @cindex build phases
  6685. This build system is an extension of @code{gnu-build-system}, but with the
  6686. following phases changed:
  6687. @table @code
  6688. @item configure
  6689. This phase configures the environment so that the Linux kernel's Makefile
  6690. can be used to build the external kernel module.
  6691. @item build
  6692. This phase uses the Linux kernel's Makefile in order to build the external
  6693. kernel module.
  6694. @item install
  6695. This phase uses the Linux kernel's Makefile in order to install the external
  6696. kernel module.
  6697. @end table
  6698. It is possible and useful to specify the Linux kernel to use for building
  6699. the module (in the @code{arguments} form of a package using the
  6700. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  6701. @end defvr
  6702. @defvr {Scheme Variable} node-build-system
  6703. This variable is exported by @code{(guix build-system node)}. It
  6704. implements the build procedure used by @uref{https://nodejs.org,
  6705. Node.js}, which implements an approximation of the @code{npm install}
  6706. command, followed by an @code{npm test} command.
  6707. Which Node.js package is used to interpret the @code{npm} commands can
  6708. be specified with the @code{#:node} parameter which defaults to
  6709. @code{node}.
  6710. @end defvr
  6711. Lastly, for packages that do not need anything as sophisticated, a
  6712. ``trivial'' build system is provided. It is trivial in the sense that
  6713. it provides basically no support: it does not pull any implicit inputs,
  6714. and does not have a notion of build phases.
  6715. @defvr {Scheme Variable} trivial-build-system
  6716. This variable is exported by @code{(guix build-system trivial)}.
  6717. This build system requires a @code{#:builder} argument. This argument
  6718. must be a Scheme expression that builds the package output(s)---as
  6719. with @code{build-expression->derivation} (@pxref{Derivations,
  6720. @code{build-expression->derivation}}).
  6721. @end defvr
  6722. @node Build Phases
  6723. @section Build Phases
  6724. @cindex build phases, for packages
  6725. Almost all package build systems implement a notion @dfn{build phases}:
  6726. a sequence of actions that the build system executes, when you build the
  6727. package, leading to the installed byproducts in the store. A notable
  6728. exception is the ``bare-bones'' @code{trivial-build-system}
  6729. (@pxref{Build Systems}).
  6730. As discussed in the previous section, those build systems provide a
  6731. standard list of phases. For @code{gnu-build-system}, the main build
  6732. phases are the following:
  6733. @table @code
  6734. @item unpack
  6735. Unpack the source tarball, and change the current directory to the
  6736. extracted source tree. If the source is actually a directory, copy it
  6737. to the build tree, and enter that directory.
  6738. @item patch-source-shebangs
  6739. Patch shebangs encountered in source files so they refer to the right
  6740. store file names. For instance, this changes @code{#!/bin/sh} to
  6741. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  6742. @item configure
  6743. Run the @file{configure} script with a number of default options, such
  6744. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  6745. by the @code{#:configure-flags} argument.
  6746. @item build
  6747. Run @code{make} with the list of flags specified with
  6748. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  6749. (the default), build with @code{make -j}.
  6750. @item check
  6751. Run @code{make check}, or some other target specified with
  6752. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  6753. @code{#:parallel-tests?} argument is true (the default), run @code{make
  6754. check -j}.
  6755. @item install
  6756. Run @code{make install} with the flags listed in @code{#:make-flags}.
  6757. @item patch-shebangs
  6758. Patch shebangs on the installed executable files.
  6759. @item strip
  6760. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  6761. is false), copying them to the @code{debug} output when available
  6762. (@pxref{Installing Debugging Files}).
  6763. @end table
  6764. Other build systems have similar phases, with some variations. For
  6765. example, @code{cmake-build-system} has same-named phases but its
  6766. @code{configure} phases runs @code{cmake} instead of @code{./configure}.
  6767. Others, such as @code{python-build-system}, have a wholly different list
  6768. of standard phases. All this code runs on the @dfn{build side}: it is
  6769. evaluated when you actually build the package, in a dedicated build
  6770. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  6771. Build phases are represented as association lists or ``alists''
  6772. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  6773. each key is a symbol for the name of the phase and the associated value
  6774. is a procedure that accepts an arbitrary number of arguments. By
  6775. convention, those procedures receive information about the build in the
  6776. form of @dfn{keyword parameters}, which they can use or ignore.
  6777. @vindex %standard-phases
  6778. For example, here is how @code{(guix build gnu-build-system)} defines
  6779. @code{%standard-phases}, the variable holding its alist of build
  6780. phases@footnote{We present a simplified view of those build phases, but
  6781. do take a look at @code{(guix build gnu-build-system)} to see all the
  6782. details!}:
  6783. @lisp
  6784. ;; The build phases of 'gnu-build-system'.
  6785. (define* (unpack #:key source #:allow-other-keys)
  6786. ;; Extract the source tarball.
  6787. (invoke "tar" "xvf" source))
  6788. (define* (configure #:key outputs #:allow-other-keys)
  6789. ;; Run the 'configure' script. Install to output "out".
  6790. (let ((out (assoc-ref outputs "out")))
  6791. (invoke "./configure"
  6792. (string-append "--prefix=" out))))
  6793. (define* (build #:allow-other-keys)
  6794. ;; Compile.
  6795. (invoke "make"))
  6796. (define* (check #:key (test-target "check") (tests? #true)
  6797. #:allow-other-keys)
  6798. ;; Run the test suite.
  6799. (if tests?
  6800. (invoke "make" test-target)
  6801. (display "test suite not run\n")))
  6802. (define* (install #:allow-other-keys)
  6803. ;; Install files to the prefix 'configure' specified.
  6804. (invoke "make" "install"))
  6805. (define %standard-phases
  6806. ;; The list of standard phases (quite a few are omitted
  6807. ;; for brevity). Each element is a symbol/procedure pair.
  6808. (list (cons 'unpack unpack)
  6809. (cons 'configure configure)
  6810. (cons 'build build)
  6811. (cons 'check check)
  6812. (cons 'install install)))
  6813. @end lisp
  6814. This shows how @code{%standard-phases} is defined as a list of
  6815. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  6816. Manual}). The first pair associates the @code{unpack} procedure with
  6817. the @code{unpack} symbol---a name; the second pair defines the
  6818. @code{configure} phase similarly, and so on. When building a package
  6819. that uses @code{gnu-build-system} with its default list of phases, those
  6820. phases are executed sequentially. You can see the name of each phase
  6821. started and completed in the build log of packages that you build.
  6822. Let's now look at the procedures themselves. Each one is defined with
  6823. @code{define*}: @code{#:key} lists keyword parameters the procedure
  6824. accepts, possibly with a default value, and @code{#:allow-other-keys}
  6825. specifies that other keyword parameters are ignored (@pxref{Optional
  6826. Arguments,,, guile, GNU Guile Reference Manual}).
  6827. The @code{unpack} procedure honors the @code{source} parameter, which
  6828. the build system uses to pass the file name of the source tarball (or
  6829. version control checkout), and it ignores other parameters. The
  6830. @code{configure} phase only cares about the @code{outputs} parameter, an
  6831. alist mapping package output names to their store file name
  6832. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  6833. for @code{out}, the default output, and passes it to
  6834. @command{./configure} as the installation prefix, meaning that
  6835. @command{make install} will eventually copy all the files in that
  6836. directory (@pxref{Configuration, configuration and makefile
  6837. conventions,, standards, GNU Coding Standards}). @code{build} and
  6838. @code{install} ignore all their arguments. @code{check} honors the
  6839. @code{test-target} argument, which specifies the name of the Makefile
  6840. target to run tests; it prints a message and skips tests when
  6841. @code{tests?} is false.
  6842. @cindex build phases, customizing
  6843. The list of phases used for a particular package can be changed with the
  6844. @code{#:phases} parameter of the build system. Changing the set of
  6845. build phases boils down to building a new alist of phases based on the
  6846. @code{%standard-phases} alist described above. This can be done with
  6847. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  6848. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  6849. more convenient to do so with @code{modify-phases} (@pxref{Build
  6850. Utilities, @code{modify-phases}}).
  6851. Here is an example of a package definition that removes the
  6852. @code{configure} phase of @code{%standard-phases} and inserts a new
  6853. phase before the @code{build} phase, called
  6854. @code{set-prefix-in-makefile}:
  6855. @lisp
  6856. (define-public example
  6857. (package
  6858. (name "example")
  6859. ;; other fields omitted
  6860. (build-system gnu-build-system)
  6861. (arguments
  6862. '(#:phases (modify-phases %standard-phases
  6863. (delete 'configure)
  6864. (add-before 'build 'set-prefix-in-makefile
  6865. (lambda* (#:key outputs #:allow-other-keys)
  6866. ;; Modify the makefile so that its
  6867. ;; 'PREFIX' variable points to "out".
  6868. (let ((out (assoc-ref outputs "out")))
  6869. (substitute* "Makefile"
  6870. (("PREFIX =.*")
  6871. (string-append "PREFIX = "
  6872. out "\n")))
  6873. #true))))))))
  6874. @end lisp
  6875. The new phase that is inserted is written as an anonymous procedure,
  6876. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  6877. we have seen before. @xref{Build Utilities}, for more about the helpers
  6878. used by this phase, and for more examples of @code{modify-phases}.
  6879. @cindex code staging
  6880. @cindex staging, of code
  6881. Keep in mind that build phases are code evaluated at the time the
  6882. package is actually built. This explains why the whole
  6883. @code{modify-phases} expression above is quoted (it comes after the
  6884. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  6885. @xref{G-Expressions}, for an explanation of code staging and the
  6886. @dfn{code strata} involved.
  6887. @node Build Utilities
  6888. @section Build Utilities
  6889. As soon as you start writing non-trivial package definitions
  6890. (@pxref{Defining Packages}) or other build actions
  6891. (@pxref{G-Expressions}), you will likely start looking for helpers for
  6892. ``shell-like'' actions---creating directories, copying and deleting
  6893. files recursively, manipulating build phases, and so on. The
  6894. @code{(guix build utils)} module provides such utility procedures.
  6895. Most build systems load @code{(guix build utils)} (@pxref{Build
  6896. Systems}). Thus, when writing custom build phases for your package
  6897. definitions, you can usually assume those procedures are in scope.
  6898. When writing G-expressions, you can import @code{(guix build utils)} on
  6899. the ``build side'' using @code{with-imported-modules} and then put it in
  6900. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  6901. guile, GNU Guile Reference Manual}):
  6902. @lisp
  6903. (with-imported-modules '((guix build utils)) ;import it
  6904. (computed-file "empty-tree"
  6905. #~(begin
  6906. ;; Put it in scope.
  6907. (use-modules (guix build utils))
  6908. ;; Happily use its 'mkdir-p' procedure.
  6909. (mkdir-p (string-append #$output "/a/b/c")))))
  6910. @end lisp
  6911. The remainder of this section is the reference for most of the utility
  6912. procedures provided by @code{(guix build utils)}.
  6913. @c TODO Document what's missing.
  6914. @subsection Dealing with Store File Names
  6915. This section documents procedures that deal with store file names.
  6916. @deffn {Scheme Procedure} %store-directory
  6917. Return the directory name of the store.
  6918. @end deffn
  6919. @deffn {Scheme Procedure} store-file-name? @var{file}
  6920. Return true if @var{file} is in the store.
  6921. @end deffn
  6922. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  6923. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  6924. The result is typically a @code{"@var{package}-@var{version}"} string.
  6925. @end deffn
  6926. @deffn {Scheme Procedure} package-name->name+version @var{name}
  6927. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  6928. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  6929. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  6930. followed by a digit is considered to introduce the version part.
  6931. @end deffn
  6932. @subsection File Types
  6933. The procedures below deal with files and file types.
  6934. @deffn {Scheme Procedure} directory-exists? @var{dir}
  6935. Return @code{#t} if @var{dir} exists and is a directory.
  6936. @end deffn
  6937. @deffn {Scheme Procedure} executable-file? @var{file}
  6938. Return @code{#t} if @var{file} exists and is executable.
  6939. @end deffn
  6940. @deffn {Scheme Procedure} symbolic-link? @var{file}
  6941. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  6942. @end deffn
  6943. @deffn {Scheme Procedure} elf-file? @var{file}
  6944. @deffnx {Scheme Procedure} ar-file? @var{file}
  6945. @deffnx {Scheme Procedure} gzip-file? @var{file}
  6946. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  6947. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  6948. @end deffn
  6949. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  6950. If @var{file} is a gzip file, reset its embedded timestamp (as with
  6951. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  6952. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  6953. @end deffn
  6954. @subsection File Manipulation
  6955. The following procedures and macros help create, modify, and delete
  6956. files. They provide functionality comparable to common shell utilities
  6957. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  6958. @command{sed}. They complement Guile's extensive, but low-level, file
  6959. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  6960. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  6961. Run @var{body} with @var{directory} as the process's current directory.
  6962. Essentially, this macro changes the current directory to @var{directory}
  6963. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  6964. guile, GNU Guile Reference Manual}). It changes back to the initial
  6965. directory when the dynamic extent of @var{body} is left, be it @i{via}
  6966. normal procedure return or @i{via} a non-local exit such as an
  6967. exception.
  6968. @end deffn
  6969. @deffn {Scheme Procedure} mkdir-p @var{dir}
  6970. Create directory @var{dir} and all its ancestors.
  6971. @end deffn
  6972. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  6973. Create @var{directory} if it does not exist and copy @var{file} in there
  6974. under the same name.
  6975. @end deffn
  6976. @deffn {Scheme Procedure} make-file-writable @var{file}
  6977. Make @var{file} writable for its owner.
  6978. @end deffn
  6979. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  6980. [#:log (current-output-port)] [#:follow-symlinks? #f] @
  6981. [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
  6982. Copy @var{source} directory to @var{destination}. Follow symlinks if
  6983. @var{follow-symlinks?} is true; otherwise, just preserve them. Call
  6984. @var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
  6985. keep the modification time of the files in @var{source} on those of
  6986. @var{destination}. When @var{keep-permissions?} is true, preserve file
  6987. permissions. Write verbose output to the @var{log} port.
  6988. @end deffn
  6989. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  6990. [#:follow-mounts? #f]
  6991. Delete @var{dir} recursively, like @command{rm -rf}, without following
  6992. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  6993. is true. Report but ignore errors.
  6994. @end deffn
  6995. @deffn {Scheme Syntax} substitute* @var{file} @
  6996. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  6997. Substitute @var{regexp} in @var{file} by the string returned by
  6998. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  6999. the corresponding positional regexp sub-expression. For example:
  7000. @lisp
  7001. (substitute* file
  7002. (("hello")
  7003. "good morning\n")
  7004. (("foo([a-z]+)bar(.*)$" all letters end)
  7005. (string-append "baz" letter end)))
  7006. @end lisp
  7007. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  7008. by @code{good morning}. Anytime a line of @var{file} matches the second
  7009. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  7010. to the first sub-expression, and @code{end} is bound to the last one.
  7011. When one of the @var{match-var} is @code{_}, no variable is bound to the
  7012. corresponding match substring.
  7013. Alternatively, @var{file} may be a list of file names, in which case
  7014. they are all subject to the substitutions.
  7015. Be careful about using @code{$} to match the end of a line; by itself it
  7016. won't match the terminating newline of a line.
  7017. @end deffn
  7018. @subsection File Search
  7019. @cindex file, searching
  7020. This section documents procedures to search and filter files.
  7021. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  7022. Return a predicate that returns true when passed a file name whose base
  7023. name matches @var{regexp}.
  7024. @end deffn
  7025. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  7026. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  7027. Return the lexicographically sorted list of files under @var{dir} for
  7028. which @var{pred} returns true. @var{pred} is passed two arguments: the
  7029. absolute file name, and its stat buffer; the default predicate always
  7030. returns true. @var{pred} can also be a regular expression, in which
  7031. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  7032. @var{stat} is used to obtain file information; using @code{lstat} means
  7033. that symlinks are not followed. If @var{directories?} is true, then
  7034. directories will also be included. If @var{fail-on-error?} is true,
  7035. raise an exception upon error.
  7036. @end deffn
  7037. Here are a few examples where we assume that the current directory is
  7038. the root of the Guix source tree:
  7039. @lisp
  7040. ;; List all the regular files in the current directory.
  7041. (find-files ".")
  7042. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  7043. ;; List all the .scm files under gnu/services.
  7044. (find-files "gnu/services" "\\.scm$")
  7045. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  7046. ;; List ar files in the current directory.
  7047. (find-files "." (lambda (file stat) (ar-file? file)))
  7048. @result{} ("./libformat.a" "./libstore.a" @dots{})
  7049. @end lisp
  7050. @deffn {Scheme Procedure} which @var{program} [@var{inputs}=#false]
  7051. Return the complete file name for @var{program} as found in
  7052. @code{$PATH}, or @code{#false} if @var{program} could not be found.
  7053. If @var{INPUTS} is not @code{#false}, instead look in the
  7054. @file{/bin} and @file{/sbin} subdirectories of @var{INPUTS}.
  7055. @var{inputs} is an alist; its keys are ignored.
  7056. @end deffn
  7057. Here is an example using the @code{which} procedure in a build phase:
  7058. @lisp
  7059. (lambda* (#:key outputs inputs #:allow-other-keys)
  7060. (let ((growpart (string-append (assoc-ref outputs "out")
  7061. "/bin/growpart")))
  7062. (wrap-program growpart
  7063. `("PATH" ":" prefix (,(dirname (which "sfdisk" inputs))
  7064. ,(dirname (which "readlink" inputs)))))))
  7065. @end lisp
  7066. @subsection Wrapping Code
  7067. This section documents procedures that create ‘wrappers’ around existing
  7068. binaries, that e.g. set environment variables required during execution.
  7069. @deffn {Scheme Procedure} wrap-program @var{prog} @var{inputs} @var{vars}
  7070. Make a wrapper for @var{prog}. @var{vars} should look like this:
  7071. @lisp
  7072. '(VARIABLE DELIMITER POSITION LIST-OF-DIRECTORIES)
  7073. @end lisp
  7074. where @var{delimiter} is optional. @samp{:} will be used if @var{delimiter}
  7075. is not given.
  7076. For example, this command:
  7077. @lisp
  7078. (wrap-program "foo"
  7079. '("PATH" ":" = ("/gnu/.../bar/bin"))
  7080. '("CERT_PATH" suffix ("/gnu/.../baz/certs"
  7081. "/qux/certs")))
  7082. @end lisp
  7083. will copy @file{foo} to @file{.foo-real} and create the file @file{foo} with
  7084. the following contents:
  7085. @example
  7086. #!location/of/bin/bash
  7087. export PATH="/gnu/.../bar/bin"
  7088. export CERT_PATH="$CERT_PATH$@{CERT_PATH:+:@}/gnu/.../baz/certs:/qux/certs"
  7089. exec -a $0 location/of/.foo-real "$@@"
  7090. @end example
  7091. This is useful for scripts that expect particular programs to be in @env{PATH},
  7092. for programs that expect particular shared libraries to be in
  7093. @env{LD_LIBRARY_PATH}, or modules in @env{GUILE_LOAD_PATH}, etc.
  7094. If @var{prog} has previously been wrapped by @code{wrap-program} the wrapper is
  7095. extended with definitions for @var{vars}.
  7096. @end deffn
  7097. @deffn {Scheme Procedure} wrap-script @var{prog} @var{inputs} @var{vars}
  7098. Wrap the script @var{prog} such that @var{vars} are set first. The format
  7099. of @var{vars} is the same as in the @code{wrap-program} procedure. This
  7100. procedure differs from @code{wrap-program} in that it does not create a
  7101. separate shell script. Instead, @var{prog} is modified directly by prepending
  7102. a Guile script, which is interpreted as a comment in the script's language.
  7103. Special encoding comments as supported by Python are recreated on the second
  7104. line.
  7105. Note that this procedure can only be used once per file as Guile scripts are
  7106. not supported.
  7107. @end deffn
  7108. @subsection Build Phases
  7109. @cindex build phases
  7110. The @code{(guix build utils)} also contains tools to manipulate build
  7111. phases as used by build systems (@pxref{Build Systems}). Build phases
  7112. are represented as association lists or ``alists'' (@pxref{Association
  7113. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  7114. naming the phase and the associated value is a procedure (@pxref{Build
  7115. Phases}).
  7116. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  7117. manipulate alists. The @code{(guix build utils)} module complements
  7118. those with tools written with build phases in mind.
  7119. @cindex build phases, modifying
  7120. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  7121. Modify @var{phases} sequentially as per each @var{clause}, which may
  7122. have one of the following forms:
  7123. @lisp
  7124. (delete @var{old-phase-name})
  7125. (replace @var{old-phase-name} @var{new-phase})
  7126. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7127. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7128. @end lisp
  7129. Where every @var{phase-name} above is an expression evaluating to a
  7130. symbol, and @var{new-phase} an expression evaluating to a procedure.
  7131. @end deffn
  7132. The example below is taken from the definition of the @code{grep}
  7133. package. It adds a phase to run after the @code{install} phase, called
  7134. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  7135. is for anonymous procedures) that takes a @code{#:outputs} keyword
  7136. argument and ignores extra keyword arguments (@pxref{Optional
  7137. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  7138. @code{lambda*} and optional and keyword arguments.) The phase uses
  7139. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  7140. scripts so that they refer to @code{grep} by its absolute file name:
  7141. @lisp
  7142. (modify-phases %standard-phases
  7143. (add-after 'install 'fix-egrep-and-fgrep
  7144. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  7145. ;; absolute file name instead of searching for it in $PATH.
  7146. (lambda* (#:key outputs #:allow-other-keys)
  7147. (let* ((out (assoc-ref outputs "out"))
  7148. (bin (string-append out "/bin")))
  7149. (substitute* (list (string-append bin "/egrep")
  7150. (string-append bin "/fgrep"))
  7151. (("^exec grep")
  7152. (string-append "exec " bin "/grep")))
  7153. #t))))
  7154. @end lisp
  7155. In the example below, phases are modified in two ways: the standard
  7156. @code{configure} phase is deleted, presumably because the package does
  7157. not have a @file{configure} script or anything similar, and the default
  7158. @code{install} phase is replaced by one that manually copies the
  7159. executable files to be installed:
  7160. @lisp
  7161. (modify-phases %standard-phases
  7162. (delete 'configure) ;no 'configure' script
  7163. (replace 'install
  7164. (lambda* (#:key outputs #:allow-other-keys)
  7165. ;; The package's Makefile doesn't provide an "install"
  7166. ;; rule so do it by ourselves.
  7167. (let ((bin (string-append (assoc-ref outputs "out")
  7168. "/bin")))
  7169. (install-file "footswitch" bin)
  7170. (install-file "scythe" bin)
  7171. #t))))
  7172. @end lisp
  7173. @c TODO: Add more examples.
  7174. @node The Store
  7175. @section The Store
  7176. @cindex store
  7177. @cindex store items
  7178. @cindex store paths
  7179. Conceptually, the @dfn{store} is the place where derivations that have
  7180. been built successfully are stored---by default, @file{/gnu/store}.
  7181. Sub-directories in the store are referred to as @dfn{store items} or
  7182. sometimes @dfn{store paths}. The store has an associated database that
  7183. contains information such as the store paths referred to by each store
  7184. path, and the list of @emph{valid} store items---results of successful
  7185. builds. This database resides in @file{@var{localstatedir}/guix/db},
  7186. where @var{localstatedir} is the state directory specified @i{via}
  7187. @option{--localstatedir} at configure time, usually @file{/var}.
  7188. The store is @emph{always} accessed by the daemon on behalf of its clients
  7189. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  7190. connect to the daemon over a Unix-domain socket, send requests to it,
  7191. and read the result---these are remote procedure calls, or RPCs.
  7192. @quotation Note
  7193. Users must @emph{never} modify files under @file{/gnu/store} directly.
  7194. This would lead to inconsistencies and break the immutability
  7195. assumptions of Guix's functional model (@pxref{Introduction}).
  7196. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  7197. how to check the integrity of the store and attempt recovery from
  7198. accidental modifications.
  7199. @end quotation
  7200. The @code{(guix store)} module provides procedures to connect to the
  7201. daemon, and to perform RPCs. These are described below. By default,
  7202. @code{open-connection}, and thus all the @command{guix} commands,
  7203. connect to the local daemon or to the URI specified by the
  7204. @env{GUIX_DAEMON_SOCKET} environment variable.
  7205. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  7206. When set, the value of this variable should be a file name or a URI
  7207. designating the daemon endpoint. When it is a file name, it denotes a
  7208. Unix-domain socket to connect to. In addition to file names, the
  7209. supported URI schemes are:
  7210. @table @code
  7211. @item file
  7212. @itemx unix
  7213. These are for Unix-domain sockets.
  7214. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  7215. @file{/var/guix/daemon-socket/socket}.
  7216. @item guix
  7217. @cindex daemon, remote access
  7218. @cindex remote access to the daemon
  7219. @cindex daemon, cluster setup
  7220. @cindex clusters, daemon setup
  7221. These URIs denote connections over TCP/IP, without encryption nor
  7222. authentication of the remote host. The URI must specify the host name
  7223. and optionally a port number (by default port 44146 is used):
  7224. @example
  7225. guix://master.guix.example.org:1234
  7226. @end example
  7227. This setup is suitable on local networks, such as clusters, where only
  7228. trusted nodes may connect to the build daemon at
  7229. @code{master.guix.example.org}.
  7230. The @option{--listen} option of @command{guix-daemon} can be used to
  7231. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  7232. @option{--listen}}).
  7233. @item ssh
  7234. @cindex SSH access to build daemons
  7235. These URIs allow you to connect to a remote daemon over SSH@. This
  7236. feature requires Guile-SSH (@pxref{Requirements}) and a working
  7237. @command{guile} binary in @env{PATH} on the destination machine. It
  7238. supports public key and GSSAPI authentication. A typical URL might look
  7239. like this:
  7240. @example
  7241. ssh://charlie@@guix.example.org:22
  7242. @end example
  7243. As for @command{guix copy}, the usual OpenSSH client configuration files
  7244. are honored (@pxref{Invoking guix copy}).
  7245. @end table
  7246. Additional URI schemes may be supported in the future.
  7247. @c XXX: Remove this note when the protocol incurs fewer round trips
  7248. @c and when (guix derivations) no longer relies on file system access.
  7249. @quotation Note
  7250. The ability to connect to remote build daemons is considered
  7251. experimental as of @value{VERSION}. Please get in touch with us to
  7252. share any problems or suggestions you may have (@pxref{Contributing}).
  7253. @end quotation
  7254. @end defvr
  7255. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  7256. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  7257. @var{reserve-space?} is true, instruct it to reserve a little bit of
  7258. extra space on the file system so that the garbage collector can still
  7259. operate should the disk become full. Return a server object.
  7260. @var{file} defaults to @code{%default-socket-path}, which is the normal
  7261. location given the options that were passed to @command{configure}.
  7262. @end deffn
  7263. @deffn {Scheme Procedure} close-connection @var{server}
  7264. Close the connection to @var{server}.
  7265. @end deffn
  7266. @defvr {Scheme Variable} current-build-output-port
  7267. This variable is bound to a SRFI-39 parameter, which refers to the port
  7268. where build and error logs sent by the daemon should be written.
  7269. @end defvr
  7270. Procedures that make RPCs all take a server object as their first
  7271. argument.
  7272. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  7273. @cindex invalid store items
  7274. Return @code{#t} when @var{path} designates a valid store item and
  7275. @code{#f} otherwise (an invalid item may exist on disk but still be
  7276. invalid, for instance because it is the result of an aborted or failed
  7277. build).
  7278. A @code{&store-protocol-error} condition is raised if @var{path} is not
  7279. prefixed by the store directory (@file{/gnu/store}).
  7280. @end deffn
  7281. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  7282. Add @var{text} under file @var{name} in the store, and return its store
  7283. path. @var{references} is the list of store paths referred to by the
  7284. resulting store path.
  7285. @end deffn
  7286. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  7287. [@var{mode}]
  7288. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  7289. file names, or derivation/output pairs, using the specified
  7290. @var{mode}---@code{(build-mode normal)} by default.
  7291. @end deffn
  7292. Note that the @code{(guix monads)} module provides a monad as well as
  7293. monadic versions of the above procedures, with the goal of making it
  7294. more convenient to work with code that accesses the store (@pxref{The
  7295. Store Monad}).
  7296. @c FIXME
  7297. @i{This section is currently incomplete.}
  7298. @node Derivations
  7299. @section Derivations
  7300. @cindex derivations
  7301. Low-level build actions and the environment in which they are performed
  7302. are represented by @dfn{derivations}. A derivation contains the
  7303. following pieces of information:
  7304. @itemize
  7305. @item
  7306. The outputs of the derivation---derivations produce at least one file or
  7307. directory in the store, but may produce more.
  7308. @item
  7309. @cindex build-time dependencies
  7310. @cindex dependencies, build-time
  7311. The inputs of the derivations---i.e., its build-time dependencies---which may
  7312. be other derivations or plain files in the store (patches, build scripts,
  7313. etc.).
  7314. @item
  7315. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  7316. @item
  7317. The file name of a build script in the store, along with the arguments
  7318. to be passed.
  7319. @item
  7320. A list of environment variables to be defined.
  7321. @end itemize
  7322. @cindex derivation path
  7323. Derivations allow clients of the daemon to communicate build actions to
  7324. the store. They exist in two forms: as an in-memory representation,
  7325. both on the client- and daemon-side, and as files in the store whose
  7326. name end in @file{.drv}---these files are referred to as @dfn{derivation
  7327. paths}. Derivations paths can be passed to the @code{build-derivations}
  7328. procedure to perform the build actions they prescribe (@pxref{The
  7329. Store}).
  7330. @cindex fixed-output derivations
  7331. Operations such as file downloads and version-control checkouts for
  7332. which the expected content hash is known in advance are modeled as
  7333. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  7334. of a fixed-output derivation are independent of its inputs---e.g., a
  7335. source code download produces the same result regardless of the download
  7336. method and tools being used.
  7337. @cindex references
  7338. @cindex run-time dependencies
  7339. @cindex dependencies, run-time
  7340. The outputs of derivations---i.e., the build results---have a set of
  7341. @dfn{references}, as reported by the @code{references} RPC or the
  7342. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  7343. are the set of run-time dependencies of the build results. References are a
  7344. subset of the inputs of the derivation; this subset is automatically computed
  7345. by the build daemon by scanning all the files in the outputs.
  7346. The @code{(guix derivations)} module provides a representation of
  7347. derivations as Scheme objects, along with procedures to create and
  7348. otherwise manipulate derivations. The lowest-level primitive to create
  7349. a derivation is the @code{derivation} procedure:
  7350. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  7351. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7352. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  7353. [#:system (%current-system)] [#:references-graphs #f] @
  7354. [#:allowed-references #f] [#:disallowed-references #f] @
  7355. [#:leaked-env-vars #f] [#:local-build? #f] @
  7356. [#:substitutable? #t] [#:properties '()]
  7357. Build a derivation with the given arguments, and return the resulting
  7358. @code{<derivation>} object.
  7359. When @var{hash} and @var{hash-algo} are given, a
  7360. @dfn{fixed-output derivation} is created---i.e., one whose result is
  7361. known in advance, such as a file download. If, in addition,
  7362. @var{recursive?} is true, then that fixed output may be an executable
  7363. file or a directory and @var{hash} must be the hash of an archive
  7364. containing this output.
  7365. When @var{references-graphs} is true, it must be a list of file
  7366. name/store path pairs. In that case, the reference graph of each store
  7367. path is exported in the build environment in the corresponding file, in
  7368. a simple text format.
  7369. When @var{allowed-references} is true, it must be a list of store items
  7370. or outputs that the derivation's output may refer to. Likewise,
  7371. @var{disallowed-references}, if true, must be a list of things the
  7372. outputs may @emph{not} refer to.
  7373. When @var{leaked-env-vars} is true, it must be a list of strings
  7374. denoting environment variables that are allowed to ``leak'' from the
  7375. daemon's environment to the build environment. This is only applicable
  7376. to fixed-output derivations---i.e., when @var{hash} is true. The main
  7377. use is to allow variables such as @code{http_proxy} to be passed to
  7378. derivations that download files.
  7379. When @var{local-build?} is true, declare that the derivation is not a
  7380. good candidate for offloading and should rather be built locally
  7381. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  7382. where the costs of data transfers would outweigh the benefits.
  7383. When @var{substitutable?} is false, declare that substitutes of the
  7384. derivation's output should not be used (@pxref{Substitutes}). This is
  7385. useful, for instance, when building packages that capture details of the
  7386. host CPU instruction set.
  7387. @var{properties} must be an association list describing ``properties'' of the
  7388. derivation. It is kept as-is, uninterpreted, in the derivation.
  7389. @end deffn
  7390. @noindent
  7391. Here's an example with a shell script as its builder, assuming
  7392. @var{store} is an open connection to the daemon, and @var{bash} points
  7393. to a Bash executable in the store:
  7394. @lisp
  7395. (use-modules (guix utils)
  7396. (guix store)
  7397. (guix derivations))
  7398. (let ((builder ; add the Bash script to the store
  7399. (add-text-to-store store "my-builder.sh"
  7400. "echo hello world > $out\n" '())))
  7401. (derivation store "foo"
  7402. bash `("-e" ,builder)
  7403. #:inputs `((,bash) (,builder))
  7404. #:env-vars '(("HOME" . "/homeless"))))
  7405. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  7406. @end lisp
  7407. As can be guessed, this primitive is cumbersome to use directly. A
  7408. better approach is to write build scripts in Scheme, of course! The
  7409. best course of action for that is to write the build code as a
  7410. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  7411. information, @pxref{G-Expressions}.
  7412. Once upon a time, @code{gexp->derivation} did not exist and constructing
  7413. derivations with build code written in Scheme was achieved with
  7414. @code{build-expression->derivation}, documented below. This procedure
  7415. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  7416. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  7417. @var{name} @var{exp} @
  7418. [#:system (%current-system)] [#:inputs '()] @
  7419. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7420. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7421. [#:references-graphs #f] [#:allowed-references #f] @
  7422. [#:disallowed-references #f] @
  7423. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  7424. Return a derivation that executes Scheme expression @var{exp} as a
  7425. builder for derivation @var{name}. @var{inputs} must be a list of
  7426. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  7427. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  7428. modules from the current search path to be copied in the store,
  7429. compiled, and made available in the load path during the execution of
  7430. @var{exp}---e.g., @code{((guix build utils) (guix build
  7431. gnu-build-system))}.
  7432. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  7433. to a list of output/path pairs, and where @code{%build-inputs} is bound
  7434. to a list of string/output-path pairs made from @var{inputs}.
  7435. Optionally, @var{env-vars} is a list of string pairs specifying the name
  7436. and value of environment variables visible to the builder. The builder
  7437. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  7438. @var{exp} returns @code{#f}, the build is considered to have failed.
  7439. @var{exp} is built using @var{guile-for-build} (a derivation). When
  7440. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  7441. @code{%guile-for-build} fluid is used instead.
  7442. See the @code{derivation} procedure for the meaning of
  7443. @var{references-graphs}, @var{allowed-references},
  7444. @var{disallowed-references}, @var{local-build?}, and
  7445. @var{substitutable?}.
  7446. @end deffn
  7447. @noindent
  7448. Here's an example of a single-output derivation that creates a directory
  7449. containing one file:
  7450. @lisp
  7451. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  7452. (mkdir out) ; create /gnu/store/@dots{}-goo
  7453. (call-with-output-file (string-append out "/test")
  7454. (lambda (p)
  7455. (display '(hello guix) p))))))
  7456. (build-expression->derivation store "goo" builder))
  7457. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  7458. @end lisp
  7459. @node The Store Monad
  7460. @section The Store Monad
  7461. @cindex monad
  7462. The procedures that operate on the store described in the previous
  7463. sections all take an open connection to the build daemon as their first
  7464. argument. Although the underlying model is functional, they either have
  7465. side effects or depend on the current state of the store.
  7466. The former is inconvenient: the connection to the build daemon has to be
  7467. carried around in all those functions, making it impossible to compose
  7468. functions that do not take that parameter with functions that do. The
  7469. latter can be problematic: since store operations have side effects
  7470. and/or depend on external state, they have to be properly sequenced.
  7471. @cindex monadic values
  7472. @cindex monadic functions
  7473. This is where the @code{(guix monads)} module comes in. This module
  7474. provides a framework for working with @dfn{monads}, and a particularly
  7475. useful monad for our uses, the @dfn{store monad}. Monads are a
  7476. construct that allows two things: associating ``context'' with values
  7477. (in our case, the context is the store), and building sequences of
  7478. computations (here computations include accesses to the store). Values
  7479. in a monad---values that carry this additional context---are called
  7480. @dfn{monadic values}; procedures that return such values are called
  7481. @dfn{monadic procedures}.
  7482. Consider this ``normal'' procedure:
  7483. @lisp
  7484. (define (sh-symlink store)
  7485. ;; Return a derivation that symlinks the 'bash' executable.
  7486. (let* ((drv (package-derivation store bash))
  7487. (out (derivation->output-path drv))
  7488. (sh (string-append out "/bin/bash")))
  7489. (build-expression->derivation store "sh"
  7490. `(symlink ,sh %output))))
  7491. @end lisp
  7492. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  7493. as a monadic function:
  7494. @lisp
  7495. (define (sh-symlink)
  7496. ;; Same, but return a monadic value.
  7497. (mlet %store-monad ((drv (package->derivation bash)))
  7498. (gexp->derivation "sh"
  7499. #~(symlink (string-append #$drv "/bin/bash")
  7500. #$output))))
  7501. @end lisp
  7502. There are several things to note in the second version: the @code{store}
  7503. parameter is now implicit and is ``threaded'' in the calls to the
  7504. @code{package->derivation} and @code{gexp->derivation} monadic
  7505. procedures, and the monadic value returned by @code{package->derivation}
  7506. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  7507. As it turns out, the call to @code{package->derivation} can even be
  7508. omitted since it will take place implicitly, as we will see later
  7509. (@pxref{G-Expressions}):
  7510. @lisp
  7511. (define (sh-symlink)
  7512. (gexp->derivation "sh"
  7513. #~(symlink (string-append #$bash "/bin/bash")
  7514. #$output)))
  7515. @end lisp
  7516. @c See
  7517. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  7518. @c for the funny quote.
  7519. Calling the monadic @code{sh-symlink} has no effect. As someone once
  7520. said, ``you exit a monad like you exit a building on fire: by running''.
  7521. So, to exit the monad and get the desired effect, one must use
  7522. @code{run-with-store}:
  7523. @lisp
  7524. (run-with-store (open-connection) (sh-symlink))
  7525. @result{} /gnu/store/...-sh-symlink
  7526. @end lisp
  7527. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  7528. new ``meta-commands'' to make it easier to deal with monadic procedures:
  7529. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  7530. to ``run'' a single monadic value through the store:
  7531. @example
  7532. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  7533. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7534. @end example
  7535. The latter enters a recursive REPL, where all the return values are
  7536. automatically run through the store:
  7537. @example
  7538. scheme@@(guile-user)> ,enter-store-monad
  7539. store-monad@@(guile-user) [1]> (package->derivation hello)
  7540. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7541. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  7542. $3 = "/gnu/store/@dots{}-foo"
  7543. store-monad@@(guile-user) [1]> ,q
  7544. scheme@@(guile-user)>
  7545. @end example
  7546. @noindent
  7547. Note that non-monadic values cannot be returned in the
  7548. @code{store-monad} REPL.
  7549. The main syntactic forms to deal with monads in general are provided by
  7550. the @code{(guix monads)} module and are described below.
  7551. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  7552. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  7553. in @var{monad}.
  7554. @end deffn
  7555. @deffn {Scheme Syntax} return @var{val}
  7556. Return a monadic value that encapsulates @var{val}.
  7557. @end deffn
  7558. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  7559. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  7560. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  7561. referred to as ``bind'', but that name denotes an unrelated procedure in
  7562. Guile. Thus we use this somewhat cryptic symbol inherited from the
  7563. Haskell language.}. There can be one @var{mproc} or several of them, as
  7564. in this example:
  7565. @lisp
  7566. (run-with-state
  7567. (with-monad %state-monad
  7568. (>>= (return 1)
  7569. (lambda (x) (return (+ 1 x)))
  7570. (lambda (x) (return (* 2 x)))))
  7571. 'some-state)
  7572. @result{} 4
  7573. @result{} some-state
  7574. @end lisp
  7575. @end deffn
  7576. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  7577. @var{body} ...
  7578. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  7579. @var{body} ...
  7580. Bind the variables @var{var} to the monadic values @var{mval} in
  7581. @var{body}, which is a sequence of expressions. As with the bind
  7582. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  7583. value ``contained'' in @var{mval} and making @var{var} refer to that
  7584. raw, non-monadic value within the scope of the @var{body}. The form
  7585. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  7586. @var{val}, as per @code{let}. The binding operations occur in sequence
  7587. from left to right. The last expression of @var{body} must be a monadic
  7588. expression, and its result will become the result of the @code{mlet} or
  7589. @code{mlet*} when run in the @var{monad}.
  7590. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  7591. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  7592. @end deffn
  7593. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  7594. Bind @var{mexp} and the following monadic expressions in sequence,
  7595. returning the result of the last expression. Every expression in the
  7596. sequence must be a monadic expression.
  7597. This is akin to @code{mlet}, except that the return values of the
  7598. monadic expressions are ignored. In that sense, it is analogous to
  7599. @code{begin}, but applied to monadic expressions.
  7600. @end deffn
  7601. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  7602. When @var{condition} is true, evaluate the sequence of monadic
  7603. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7604. @var{condition} is false, return @code{*unspecified*} in the current
  7605. monad. Every expression in the sequence must be a monadic expression.
  7606. @end deffn
  7607. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  7608. When @var{condition} is false, evaluate the sequence of monadic
  7609. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7610. @var{condition} is true, return @code{*unspecified*} in the current
  7611. monad. Every expression in the sequence must be a monadic expression.
  7612. @end deffn
  7613. @cindex state monad
  7614. The @code{(guix monads)} module provides the @dfn{state monad}, which
  7615. allows an additional value---the state---to be @emph{threaded} through
  7616. monadic procedure calls.
  7617. @defvr {Scheme Variable} %state-monad
  7618. The state monad. Procedures in the state monad can access and change
  7619. the state that is threaded.
  7620. Consider the example below. The @code{square} procedure returns a value
  7621. in the state monad. It returns the square of its argument, but also
  7622. increments the current state value:
  7623. @lisp
  7624. (define (square x)
  7625. (mlet %state-monad ((count (current-state)))
  7626. (mbegin %state-monad
  7627. (set-current-state (+ 1 count))
  7628. (return (* x x)))))
  7629. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  7630. @result{} (0 1 4)
  7631. @result{} 3
  7632. @end lisp
  7633. When ``run'' through @code{%state-monad}, we obtain that additional state
  7634. value, which is the number of @code{square} calls.
  7635. @end defvr
  7636. @deffn {Monadic Procedure} current-state
  7637. Return the current state as a monadic value.
  7638. @end deffn
  7639. @deffn {Monadic Procedure} set-current-state @var{value}
  7640. Set the current state to @var{value} and return the previous state as a
  7641. monadic value.
  7642. @end deffn
  7643. @deffn {Monadic Procedure} state-push @var{value}
  7644. Push @var{value} to the current state, which is assumed to be a list,
  7645. and return the previous state as a monadic value.
  7646. @end deffn
  7647. @deffn {Monadic Procedure} state-pop
  7648. Pop a value from the current state and return it as a monadic value.
  7649. The state is assumed to be a list.
  7650. @end deffn
  7651. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  7652. Run monadic value @var{mval} starting with @var{state} as the initial
  7653. state. Return two values: the resulting value, and the resulting state.
  7654. @end deffn
  7655. The main interface to the store monad, provided by the @code{(guix
  7656. store)} module, is as follows.
  7657. @defvr {Scheme Variable} %store-monad
  7658. The store monad---an alias for @code{%state-monad}.
  7659. Values in the store monad encapsulate accesses to the store. When its
  7660. effect is needed, a value of the store monad must be ``evaluated'' by
  7661. passing it to the @code{run-with-store} procedure (see below).
  7662. @end defvr
  7663. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  7664. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  7665. open store connection.
  7666. @end deffn
  7667. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  7668. Return as a monadic value the absolute file name in the store of the file
  7669. containing @var{text}, a string. @var{references} is a list of store items that the
  7670. resulting text file refers to; it defaults to the empty list.
  7671. @end deffn
  7672. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  7673. Return as a monadic value the absolute file name in the store of the file
  7674. containing @var{data}, a bytevector. @var{references} is a list of store
  7675. items that the resulting binary file refers to; it defaults to the empty list.
  7676. @end deffn
  7677. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  7678. [#:recursive? #t] [#:select? (const #t)]
  7679. Return the name of @var{file} once interned in the store. Use
  7680. @var{name} as its store name, or the basename of @var{file} if
  7681. @var{name} is omitted.
  7682. When @var{recursive?} is true, the contents of @var{file} are added
  7683. recursively; if @var{file} designates a flat file and @var{recursive?}
  7684. is true, its contents are added, and its permission bits are kept.
  7685. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7686. @var{stat})} for each directory entry, where @var{file} is the entry's
  7687. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7688. entries for which @var{select?} does not return true.
  7689. The example below adds a file to the store, under two different names:
  7690. @lisp
  7691. (run-with-store (open-connection)
  7692. (mlet %store-monad ((a (interned-file "README"))
  7693. (b (interned-file "README" "LEGU-MIN")))
  7694. (return (list a b))))
  7695. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  7696. @end lisp
  7697. @end deffn
  7698. The @code{(guix packages)} module exports the following package-related
  7699. monadic procedures:
  7700. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  7701. [#:system (%current-system)] [#:target #f] @
  7702. [#:output "out"]
  7703. Return as a monadic
  7704. value in the absolute file name of @var{file} within the @var{output}
  7705. directory of @var{package}. When @var{file} is omitted, return the name
  7706. of the @var{output} directory of @var{package}. When @var{target} is
  7707. true, use it as a cross-compilation target triplet.
  7708. Note that this procedure does @emph{not} build @var{package}. Thus, the
  7709. result might or might not designate an existing file. We recommend not
  7710. using this procedure unless you know what you are doing.
  7711. @end deffn
  7712. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  7713. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  7714. @var{target} [@var{system}]
  7715. Monadic version of @code{package-derivation} and
  7716. @code{package-cross-derivation} (@pxref{Defining Packages}).
  7717. @end deffn
  7718. @node G-Expressions
  7719. @section G-Expressions
  7720. @cindex G-expression
  7721. @cindex build code quoting
  7722. So we have ``derivations'', which represent a sequence of build actions
  7723. to be performed to produce an item in the store (@pxref{Derivations}).
  7724. These build actions are performed when asking the daemon to actually
  7725. build the derivations; they are run by the daemon in a container
  7726. (@pxref{Invoking guix-daemon}).
  7727. @cindex code staging
  7728. @cindex staging, of code
  7729. @cindex strata of code
  7730. It should come as no surprise that we like to write these build actions
  7731. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  7732. code@footnote{The term @dfn{stratum} in this context was coined by
  7733. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  7734. Kiselyov, who has written insightful
  7735. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  7736. on this topic}, refers to this kind of code generation as
  7737. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  7738. to the daemon, etc.---and the ``build code''---code that actually
  7739. performs build actions, such as making directories, invoking
  7740. @command{make}, and so on (@pxref{Build Phases}).
  7741. To describe a derivation and its build actions, one typically needs to
  7742. embed build code inside host code. It boils down to manipulating build
  7743. code as data, and the homoiconicity of Scheme---code has a direct
  7744. representation as data---comes in handy for that. But we need more than
  7745. the normal @code{quasiquote} mechanism in Scheme to construct build
  7746. expressions.
  7747. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  7748. S-expressions adapted to build expressions. G-expressions, or
  7749. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  7750. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  7751. @code{#$}, and @code{#$@@}), which are comparable to
  7752. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  7753. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  7754. GNU Guile Reference Manual}). However, there are major differences:
  7755. @itemize
  7756. @item
  7757. Gexps are meant to be written to a file and run or manipulated by other
  7758. processes.
  7759. @item
  7760. When a high-level object such as a package or derivation is unquoted
  7761. inside a gexp, the result is as if its output file name had been
  7762. introduced.
  7763. @item
  7764. Gexps carry information about the packages or derivations they refer to,
  7765. and these dependencies are automatically added as inputs to the build
  7766. processes that use them.
  7767. @end itemize
  7768. @cindex lowering, of high-level objects in gexps
  7769. This mechanism is not limited to package and derivation
  7770. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  7771. derivations or files in the store can be defined,
  7772. such that these objects can also be inserted
  7773. into gexps. For example, a useful type of high-level objects that can be
  7774. inserted in a gexp is ``file-like objects'', which make it easy to
  7775. add files to the store and to refer to them in
  7776. derivations and such (see @code{local-file} and @code{plain-file}
  7777. below).
  7778. To illustrate the idea, here is an example of a gexp:
  7779. @lisp
  7780. (define build-exp
  7781. #~(begin
  7782. (mkdir #$output)
  7783. (chdir #$output)
  7784. (symlink (string-append #$coreutils "/bin/ls")
  7785. "list-files")))
  7786. @end lisp
  7787. This gexp can be passed to @code{gexp->derivation}; we obtain a
  7788. derivation that builds a directory containing exactly one symlink to
  7789. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  7790. @lisp
  7791. (gexp->derivation "the-thing" build-exp)
  7792. @end lisp
  7793. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  7794. substituted to the reference to the @var{coreutils} package in the
  7795. actual build code, and @var{coreutils} is automatically made an input to
  7796. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  7797. output)}) is replaced by a string containing the directory name of the
  7798. output of the derivation.
  7799. @cindex cross compilation
  7800. In a cross-compilation context, it is useful to distinguish between
  7801. references to the @emph{native} build of a package---that can run on the
  7802. host---versus references to cross builds of a package. To that end, the
  7803. @code{#+} plays the same role as @code{#$}, but is a reference to a
  7804. native package build:
  7805. @lisp
  7806. (gexp->derivation "vi"
  7807. #~(begin
  7808. (mkdir #$output)
  7809. (mkdir (string-append #$output "/bin"))
  7810. (system* (string-append #+coreutils "/bin/ln")
  7811. "-s"
  7812. (string-append #$emacs "/bin/emacs")
  7813. (string-append #$output "/bin/vi")))
  7814. #:target "aarch64-linux-gnu")
  7815. @end lisp
  7816. @noindent
  7817. In the example above, the native build of @var{coreutils} is used, so
  7818. that @command{ln} can actually run on the host; but then the
  7819. cross-compiled build of @var{emacs} is referenced.
  7820. @cindex imported modules, for gexps
  7821. @findex with-imported-modules
  7822. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  7823. able to use certain Guile modules from the ``host environment'' in the
  7824. gexp, so those modules should be imported in the ``build environment''.
  7825. The @code{with-imported-modules} form allows you to express that:
  7826. @lisp
  7827. (let ((build (with-imported-modules '((guix build utils))
  7828. #~(begin
  7829. (use-modules (guix build utils))
  7830. (mkdir-p (string-append #$output "/bin"))))))
  7831. (gexp->derivation "empty-dir"
  7832. #~(begin
  7833. #$build
  7834. (display "success!\n")
  7835. #t)))
  7836. @end lisp
  7837. @noindent
  7838. In this example, the @code{(guix build utils)} module is automatically
  7839. pulled into the isolated build environment of our gexp, such that
  7840. @code{(use-modules (guix build utils))} works as expected.
  7841. @cindex module closure
  7842. @findex source-module-closure
  7843. Usually you want the @emph{closure} of the module to be imported---i.e.,
  7844. the module itself and all the modules it depends on---rather than just
  7845. the module; failing to do that, attempts to use the module will fail
  7846. because of missing dependent modules. The @code{source-module-closure}
  7847. procedure computes the closure of a module by looking at its source file
  7848. headers, which comes in handy in this case:
  7849. @lisp
  7850. (use-modules (guix modules)) ;for 'source-module-closure'
  7851. (with-imported-modules (source-module-closure
  7852. '((guix build utils)
  7853. (gnu build vm)))
  7854. (gexp->derivation "something-with-vms"
  7855. #~(begin
  7856. (use-modules (guix build utils)
  7857. (gnu build vm))
  7858. @dots{})))
  7859. @end lisp
  7860. @cindex extensions, for gexps
  7861. @findex with-extensions
  7862. In the same vein, sometimes you want to import not just pure-Scheme
  7863. modules, but also ``extensions'' such as Guile bindings to C libraries
  7864. or other ``full-blown'' packages. Say you need the @code{guile-json}
  7865. package available on the build side, here's how you would do it:
  7866. @lisp
  7867. (use-modules (gnu packages guile)) ;for 'guile-json'
  7868. (with-extensions (list guile-json)
  7869. (gexp->derivation "something-with-json"
  7870. #~(begin
  7871. (use-modules (json))
  7872. @dots{})))
  7873. @end lisp
  7874. The syntactic form to construct gexps is summarized below.
  7875. @deffn {Scheme Syntax} #~@var{exp}
  7876. @deffnx {Scheme Syntax} (gexp @var{exp})
  7877. Return a G-expression containing @var{exp}. @var{exp} may contain one
  7878. or more of the following forms:
  7879. @table @code
  7880. @item #$@var{obj}
  7881. @itemx (ungexp @var{obj})
  7882. Introduce a reference to @var{obj}. @var{obj} may have one of the
  7883. supported types, for example a package or a
  7884. derivation, in which case the @code{ungexp} form is replaced by its
  7885. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  7886. If @var{obj} is a list, it is traversed and references to supported
  7887. objects are substituted similarly.
  7888. If @var{obj} is another gexp, its contents are inserted and its
  7889. dependencies are added to those of the containing gexp.
  7890. If @var{obj} is another kind of object, it is inserted as is.
  7891. @item #$@var{obj}:@var{output}
  7892. @itemx (ungexp @var{obj} @var{output})
  7893. This is like the form above, but referring explicitly to the
  7894. @var{output} of @var{obj}---this is useful when @var{obj} produces
  7895. multiple outputs (@pxref{Packages with Multiple Outputs}).
  7896. @item #+@var{obj}
  7897. @itemx #+@var{obj}:output
  7898. @itemx (ungexp-native @var{obj})
  7899. @itemx (ungexp-native @var{obj} @var{output})
  7900. Same as @code{ungexp}, but produces a reference to the @emph{native}
  7901. build of @var{obj} when used in a cross compilation context.
  7902. @item #$output[:@var{output}]
  7903. @itemx (ungexp output [@var{output}])
  7904. Insert a reference to derivation output @var{output}, or to the main
  7905. output when @var{output} is omitted.
  7906. This only makes sense for gexps passed to @code{gexp->derivation}.
  7907. @item #$@@@var{lst}
  7908. @itemx (ungexp-splicing @var{lst})
  7909. Like the above, but splices the contents of @var{lst} inside the
  7910. containing list.
  7911. @item #+@@@var{lst}
  7912. @itemx (ungexp-native-splicing @var{lst})
  7913. Like the above, but refers to native builds of the objects listed in
  7914. @var{lst}.
  7915. @end table
  7916. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  7917. of the @code{gexp?} type (see below).
  7918. @end deffn
  7919. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  7920. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  7921. in their execution environment.
  7922. Each item in @var{modules} can be the name of a module, such as
  7923. @code{(guix build utils)}, or it can be a module name, followed by an
  7924. arrow, followed by a file-like object:
  7925. @lisp
  7926. `((guix build utils)
  7927. (guix gcrypt)
  7928. ((guix config) => ,(scheme-file "config.scm"
  7929. #~(define-module @dots{}))))
  7930. @end lisp
  7931. @noindent
  7932. In the example above, the first two modules are taken from the search
  7933. path, and the last one is created from the given file-like object.
  7934. This form has @emph{lexical} scope: it has an effect on the gexps
  7935. directly defined in @var{body}@dots{}, but not on those defined, say, in
  7936. procedures called from @var{body}@dots{}.
  7937. @end deffn
  7938. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  7939. Mark the gexps defined in @var{body}@dots{} as requiring
  7940. @var{extensions} in their build and execution environment.
  7941. @var{extensions} is typically a list of package objects such as those
  7942. defined in the @code{(gnu packages guile)} module.
  7943. Concretely, the packages listed in @var{extensions} are added to the
  7944. load path while compiling imported modules in @var{body}@dots{}; they
  7945. are also added to the load path of the gexp returned by
  7946. @var{body}@dots{}.
  7947. @end deffn
  7948. @deffn {Scheme Procedure} gexp? @var{obj}
  7949. Return @code{#t} if @var{obj} is a G-expression.
  7950. @end deffn
  7951. G-expressions are meant to be written to disk, either as code building
  7952. some derivation, or as plain files in the store. The monadic procedures
  7953. below allow you to do that (@pxref{The Store Monad}, for more
  7954. information about monads).
  7955. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  7956. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  7957. [#:hash #f] [#:hash-algo #f] @
  7958. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7959. [#:module-path @code{%load-path}] @
  7960. [#:effective-version "2.2"] @
  7961. [#:references-graphs #f] [#:allowed-references #f] @
  7962. [#:disallowed-references #f] @
  7963. [#:leaked-env-vars #f] @
  7964. [#:script-name (string-append @var{name} "-builder")] @
  7965. [#:deprecation-warnings #f] @
  7966. [#:local-build? #f] [#:substitutable? #t] @
  7967. [#:properties '()] [#:guile-for-build #f]
  7968. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  7969. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  7970. stored in a file called @var{script-name}. When @var{target} is true,
  7971. it is used as the cross-compilation target triplet for packages referred
  7972. to by @var{exp}.
  7973. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  7974. Its meaning is to
  7975. make @var{modules} available in the evaluation context of @var{exp};
  7976. @var{modules} is a list of names of Guile modules searched in
  7977. @var{module-path} to be copied in the store, compiled, and made available in
  7978. the load path during the execution of @var{exp}---e.g., @code{((guix
  7979. build utils) (guix build gnu-build-system))}.
  7980. @var{effective-version} determines the string to use when adding extensions of
  7981. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  7982. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  7983. applicable.
  7984. When @var{references-graphs} is true, it must be a list of tuples of one of the
  7985. following forms:
  7986. @example
  7987. (@var{file-name} @var{package})
  7988. (@var{file-name} @var{package} @var{output})
  7989. (@var{file-name} @var{derivation})
  7990. (@var{file-name} @var{derivation} @var{output})
  7991. (@var{file-name} @var{store-item})
  7992. @end example
  7993. The right-hand-side of each element of @var{references-graphs} is automatically made
  7994. an input of the build process of @var{exp}. In the build environment, each
  7995. @var{file-name} contains the reference graph of the corresponding item, in a simple
  7996. text format.
  7997. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  7998. In the latter case, the list denotes store items that the result is allowed to
  7999. refer to. Any reference to another store item will lead to a build error.
  8000. Similarly for @var{disallowed-references}, which can list items that must not be
  8001. referenced by the outputs.
  8002. @var{deprecation-warnings} determines whether to show deprecation warnings while
  8003. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  8004. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  8005. @end deffn
  8006. @cindex file-like objects
  8007. The @code{local-file}, @code{plain-file}, @code{computed-file},
  8008. @code{program-file}, and @code{scheme-file} procedures below return
  8009. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  8010. these objects lead to a file in the store. Consider this G-expression:
  8011. @lisp
  8012. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  8013. #$(local-file "/tmp/my-nscd.conf"))
  8014. @end lisp
  8015. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  8016. to the store. Once expanded, for instance @i{via}
  8017. @code{gexp->derivation}, the G-expression refers to that copy under
  8018. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  8019. does not have any effect on what the G-expression does.
  8020. @code{plain-file} can be used similarly; it differs in that the file
  8021. content is directly passed as a string.
  8022. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  8023. [#:recursive? #f] [#:select? (const #t)]
  8024. Return an object representing local file @var{file} to add to the store;
  8025. this object can be used in a gexp. If @var{file} is a literal string
  8026. denoting a relative file name, it is looked up relative to the source
  8027. file where it appears; if @var{file} is not a literal string, it is
  8028. looked up relative to the current working directory at run time.
  8029. @var{file} will be added to the store under @var{name}--by default the
  8030. base name of @var{file}.
  8031. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  8032. designates a flat file and @var{recursive?} is true, its contents are added, and its
  8033. permission bits are kept.
  8034. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8035. @var{stat})} for each directory entry, where @var{file} is the entry's
  8036. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8037. entries for which @var{select?} does not return true.
  8038. This is the declarative counterpart of the @code{interned-file} monadic
  8039. procedure (@pxref{The Store Monad, @code{interned-file}}).
  8040. @end deffn
  8041. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  8042. Return an object representing a text file called @var{name} with the given
  8043. @var{content} (a string or a bytevector) to be added to the store.
  8044. This is the declarative counterpart of @code{text-file}.
  8045. @end deffn
  8046. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  8047. [#:local-build? #t]
  8048. [#:options '()]
  8049. Return an object representing the store item @var{name}, a file or
  8050. directory computed by @var{gexp}. When @var{local-build?} is true (the
  8051. default), the derivation is built locally. @var{options} is a list of
  8052. additional arguments to pass to @code{gexp->derivation}.
  8053. This is the declarative counterpart of @code{gexp->derivation}.
  8054. @end deffn
  8055. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  8056. [#:guile (default-guile)] [#:module-path %load-path] @
  8057. [#:system (%current-system)] [#:target #f]
  8058. Return an executable script @var{name} that runs @var{exp} using
  8059. @var{guile}, with @var{exp}'s imported modules in its search path.
  8060. Look up @var{exp}'s modules in @var{module-path}.
  8061. The example below builds a script that simply invokes the @command{ls}
  8062. command:
  8063. @lisp
  8064. (use-modules (guix gexp) (gnu packages base))
  8065. (gexp->script "list-files"
  8066. #~(execl #$(file-append coreutils "/bin/ls")
  8067. "ls"))
  8068. @end lisp
  8069. When ``running'' it through the store (@pxref{The Store Monad,
  8070. @code{run-with-store}}), we obtain a derivation that produces an
  8071. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  8072. @example
  8073. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  8074. !#
  8075. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  8076. @end example
  8077. @end deffn
  8078. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  8079. [#:guile #f] [#:module-path %load-path]
  8080. Return an object representing the executable store item @var{name} that
  8081. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  8082. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  8083. This is the declarative counterpart of @code{gexp->script}.
  8084. @end deffn
  8085. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  8086. [#:set-load-path? #t] [#:module-path %load-path] @
  8087. [#:splice? #f] @
  8088. [#:guile (default-guile)]
  8089. Return a derivation that builds a file @var{name} containing @var{exp}.
  8090. When @var{splice?} is true, @var{exp} is considered to be a list of
  8091. expressions that will be spliced in the resulting file.
  8092. When @var{set-load-path?} is true, emit code in the resulting file to
  8093. set @code{%load-path} and @code{%load-compiled-path} to honor
  8094. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  8095. @var{module-path}.
  8096. The resulting file holds references to all the dependencies of @var{exp}
  8097. or a subset thereof.
  8098. @end deffn
  8099. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  8100. [#:splice? #f] [#:set-load-path? #t]
  8101. Return an object representing the Scheme file @var{name} that contains
  8102. @var{exp}.
  8103. This is the declarative counterpart of @code{gexp->file}.
  8104. @end deffn
  8105. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  8106. Return as a monadic value a derivation that builds a text file
  8107. containing all of @var{text}. @var{text} may list, in addition to
  8108. strings, objects of any type that can be used in a gexp: packages,
  8109. derivations, local file objects, etc. The resulting store file holds
  8110. references to all these.
  8111. This variant should be preferred over @code{text-file} anytime the file
  8112. to create will reference items from the store. This is typically the
  8113. case when building a configuration file that embeds store file names,
  8114. like this:
  8115. @lisp
  8116. (define (profile.sh)
  8117. ;; Return the name of a shell script in the store that
  8118. ;; initializes the 'PATH' environment variable.
  8119. (text-file* "profile.sh"
  8120. "export PATH=" coreutils "/bin:"
  8121. grep "/bin:" sed "/bin\n"))
  8122. @end lisp
  8123. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  8124. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  8125. preventing them from being garbage-collected during its lifetime.
  8126. @end deffn
  8127. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  8128. Return an object representing store file @var{name} containing
  8129. @var{text}. @var{text} is a sequence of strings and file-like objects,
  8130. as in:
  8131. @lisp
  8132. (mixed-text-file "profile"
  8133. "export PATH=" coreutils "/bin:" grep "/bin")
  8134. @end lisp
  8135. This is the declarative counterpart of @code{text-file*}.
  8136. @end deffn
  8137. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  8138. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  8139. Each item in @var{files} must be a two-element list where the first element is the
  8140. file name to use in the new directory, and the second element is a gexp
  8141. denoting the target file. Here's an example:
  8142. @lisp
  8143. (file-union "etc"
  8144. `(("hosts" ,(plain-file "hosts"
  8145. "127.0.0.1 localhost"))
  8146. ("bashrc" ,(plain-file "bashrc"
  8147. "alias ls='ls --color=auto'"))))
  8148. @end lisp
  8149. This yields an @code{etc} directory containing these two files.
  8150. @end deffn
  8151. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  8152. Return a directory that is the union of @var{things}, where @var{things} is a list of
  8153. file-like objects denoting directories. For example:
  8154. @lisp
  8155. (directory-union "guile+emacs" (list guile emacs))
  8156. @end lisp
  8157. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  8158. @end deffn
  8159. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  8160. Return a file-like object that expands to the concatenation of @var{obj}
  8161. and @var{suffix}, where @var{obj} is a lowerable object and each
  8162. @var{suffix} is a string.
  8163. As an example, consider this gexp:
  8164. @lisp
  8165. (gexp->script "run-uname"
  8166. #~(system* #$(file-append coreutils
  8167. "/bin/uname")))
  8168. @end lisp
  8169. The same effect could be achieved with:
  8170. @lisp
  8171. (gexp->script "run-uname"
  8172. #~(system* (string-append #$coreutils
  8173. "/bin/uname")))
  8174. @end lisp
  8175. There is one difference though: in the @code{file-append} case, the
  8176. resulting script contains the absolute file name as a string, whereas in
  8177. the second case, the resulting script contains a @code{(string-append
  8178. @dots{})} expression to construct the file name @emph{at run time}.
  8179. @end deffn
  8180. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  8181. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  8182. Bind @var{system} to the currently targeted system---e.g.,
  8183. @code{"x86_64-linux"}---within @var{body}.
  8184. In the second case, additionally bind @var{target} to the current
  8185. cross-compilation target---a GNU triplet such as
  8186. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  8187. cross-compiling.
  8188. @code{let-system} is useful in the occasional case where the object
  8189. spliced into the gexp depends on the target system, as in this example:
  8190. @lisp
  8191. #~(system*
  8192. #+(let-system system
  8193. (cond ((string-prefix? "armhf-" system)
  8194. (file-append qemu "/bin/qemu-system-arm"))
  8195. ((string-prefix? "x86_64-" system)
  8196. (file-append qemu "/bin/qemu-system-x86_64"))
  8197. (else
  8198. (error "dunno!"))))
  8199. "-net" "user" #$image)
  8200. @end lisp
  8201. @end deffn
  8202. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  8203. This macro is similar to the @code{parameterize} form for
  8204. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  8205. Guile Reference Manual}). The key difference is that it takes effect
  8206. when the file-like object returned by @var{exp} is lowered to a
  8207. derivation or store item.
  8208. A typical use of @code{with-parameters} is to force the system in effect
  8209. for a given object:
  8210. @lisp
  8211. (with-parameters ((%current-system "i686-linux"))
  8212. coreutils)
  8213. @end lisp
  8214. The example above returns an object that corresponds to the i686 build
  8215. of Coreutils, regardless of the current value of @code{%current-system}.
  8216. @end deffn
  8217. Of course, in addition to gexps embedded in ``host'' code, there are
  8218. also modules containing build tools. To make it clear that they are
  8219. meant to be used in the build stratum, these modules are kept in the
  8220. @code{(guix build @dots{})} name space.
  8221. @cindex lowering, of high-level objects in gexps
  8222. Internally, high-level objects are @dfn{lowered}, using their compiler,
  8223. to either derivations or store items. For instance, lowering a package
  8224. yields a derivation, and lowering a @code{plain-file} yields a store
  8225. item. This is achieved using the @code{lower-object} monadic procedure.
  8226. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  8227. [#:target #f]
  8228. Return as a value in @code{%store-monad} the derivation or store item
  8229. corresponding to @var{obj} for @var{system}, cross-compiling for
  8230. @var{target} if @var{target} is true. @var{obj} must be an object that
  8231. has an associated gexp compiler, such as a @code{<package>}.
  8232. @end deffn
  8233. @node Invoking guix repl
  8234. @section Invoking @command{guix repl}
  8235. @cindex REPL, read-eval-print loop, script
  8236. The @command{guix repl} command makes it easier to program Guix in Guile
  8237. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  8238. programming (@pxref{Using Guile Interactively,,, guile,
  8239. GNU Guile Reference Manual}), or by running Guile scripts
  8240. (@pxref{Running Guile Scripts,,, guile,
  8241. GNU Guile Reference Manual}).
  8242. Compared to just launching the @command{guile}
  8243. command, @command{guix repl} guarantees that all the Guix modules and all its
  8244. dependencies are available in the search path.
  8245. The general syntax is:
  8246. @example
  8247. guix repl @var{options} [@var{file} @var{args}]
  8248. @end example
  8249. When a @var{file} argument is provided, @var{file} is
  8250. executed as a Guile scripts:
  8251. @example
  8252. guix repl my-script.scm
  8253. @end example
  8254. To pass arguments to the script, use @code{--} to prevent them from
  8255. being interpreted as arguments to @command{guix repl} itself:
  8256. @example
  8257. guix repl -- my-script.scm --input=foo.txt
  8258. @end example
  8259. To make a script executable directly from the shell, using the guix
  8260. executable that is on the user's search path, add the following two
  8261. lines at the top of the script:
  8262. @example
  8263. @code{#!/usr/bin/env -S guix repl --}
  8264. @code{!#}
  8265. @end example
  8266. Without a file name argument, a Guile REPL is started:
  8267. @example
  8268. $ guix repl
  8269. scheme@@(guile-user)> ,use (gnu packages base)
  8270. scheme@@(guile-user)> coreutils
  8271. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  8272. @end example
  8273. @cindex inferiors
  8274. In addition, @command{guix repl} implements a simple machine-readable REPL
  8275. protocol for use by @code{(guix inferior)}, a facility to interact with
  8276. @dfn{inferiors}, separate processes running a potentially different revision
  8277. of Guix.
  8278. The available options are as follows:
  8279. @table @code
  8280. @item --type=@var{type}
  8281. @itemx -t @var{type}
  8282. Start a REPL of the given @var{TYPE}, which can be one of the following:
  8283. @table @code
  8284. @item guile
  8285. This is default, and it spawns a standard full-featured Guile REPL.
  8286. @item machine
  8287. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  8288. that the @code{(guix inferior)} module speaks.
  8289. @end table
  8290. @item --listen=@var{endpoint}
  8291. By default, @command{guix repl} reads from standard input and writes to
  8292. standard output. When this option is passed, it will instead listen for
  8293. connections on @var{endpoint}. Here are examples of valid options:
  8294. @table @code
  8295. @item --listen=tcp:37146
  8296. Accept connections on localhost on port 37146.
  8297. @item --listen=unix:/tmp/socket
  8298. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  8299. @end table
  8300. @item --load-path=@var{directory}
  8301. @itemx -L @var{directory}
  8302. Add @var{directory} to the front of the package module search path
  8303. (@pxref{Package Modules}).
  8304. This allows users to define their own packages and make them visible to
  8305. the script or REPL.
  8306. @item -q
  8307. Inhibit loading of the @file{~/.guile} file. By default, that
  8308. configuration file is loaded when spawning a @code{guile} REPL.
  8309. @end table
  8310. @c *********************************************************************
  8311. @node Utilities
  8312. @chapter Utilities
  8313. This section describes Guix command-line utilities. Some of them are
  8314. primarily targeted at developers and users who write new package
  8315. definitions, while others are more generally useful. They complement
  8316. the Scheme programming interface of Guix in a convenient way.
  8317. @menu
  8318. * Invoking guix build:: Building packages from the command line.
  8319. * Invoking guix edit:: Editing package definitions.
  8320. * Invoking guix download:: Downloading a file and printing its hash.
  8321. * Invoking guix hash:: Computing the cryptographic hash of a file.
  8322. * Invoking guix import:: Importing package definitions.
  8323. * Invoking guix refresh:: Updating package definitions.
  8324. * Invoking guix lint:: Finding errors in package definitions.
  8325. * Invoking guix size:: Profiling disk usage.
  8326. * Invoking guix graph:: Visualizing the graph of packages.
  8327. * Invoking guix publish:: Sharing substitutes.
  8328. * Invoking guix challenge:: Challenging substitute servers.
  8329. * Invoking guix copy:: Copying to and from a remote store.
  8330. * Invoking guix container:: Process isolation.
  8331. * Invoking guix weather:: Assessing substitute availability.
  8332. * Invoking guix processes:: Listing client processes.
  8333. @end menu
  8334. @node Invoking guix build
  8335. @section Invoking @command{guix build}
  8336. @cindex package building
  8337. @cindex @command{guix build}
  8338. The @command{guix build} command builds packages or derivations and
  8339. their dependencies, and prints the resulting store paths. Note that it
  8340. does not modify the user's profile---this is the job of the
  8341. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  8342. it is mainly useful for distribution developers.
  8343. The general syntax is:
  8344. @example
  8345. guix build @var{options} @var{package-or-derivation}@dots{}
  8346. @end example
  8347. As an example, the following command builds the latest versions of Emacs
  8348. and of Guile, displays their build logs, and finally displays the
  8349. resulting directories:
  8350. @example
  8351. guix build emacs guile
  8352. @end example
  8353. Similarly, the following command builds all the available packages:
  8354. @example
  8355. guix build --quiet --keep-going \
  8356. $(guix package -A | cut -f1,2 --output-delimiter=@@)
  8357. @end example
  8358. @var{package-or-derivation} may be either the name of a package found in
  8359. the software distribution such as @code{coreutils} or
  8360. @code{coreutils@@8.20}, or a derivation such as
  8361. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  8362. package with the corresponding name (and optionally version) is searched
  8363. for among the GNU distribution modules (@pxref{Package Modules}).
  8364. Alternatively, the @option{--expression} option may be used to specify a
  8365. Scheme expression that evaluates to a package; this is useful when
  8366. disambiguating among several same-named packages or package variants is
  8367. needed.
  8368. There may be zero or more @var{options}. The available options are
  8369. described in the subsections below.
  8370. @menu
  8371. * Common Build Options:: Build options for most commands.
  8372. * Package Transformation Options:: Creating variants of packages.
  8373. * Additional Build Options:: Options specific to 'guix build'.
  8374. * Debugging Build Failures:: Real life packaging experience.
  8375. @end menu
  8376. @node Common Build Options
  8377. @subsection Common Build Options
  8378. A number of options that control the build process are common to
  8379. @command{guix build} and other commands that can spawn builds, such as
  8380. @command{guix package} or @command{guix archive}. These are the
  8381. following:
  8382. @table @code
  8383. @item --load-path=@var{directory}
  8384. @itemx -L @var{directory}
  8385. Add @var{directory} to the front of the package module search path
  8386. (@pxref{Package Modules}).
  8387. This allows users to define their own packages and make them visible to
  8388. the command-line tools.
  8389. @item --keep-failed
  8390. @itemx -K
  8391. Keep the build tree of failed builds. Thus, if a build fails, its build
  8392. tree is kept under @file{/tmp}, in a directory whose name is shown at
  8393. the end of the build log. This is useful when debugging build issues.
  8394. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  8395. build issues.
  8396. This option implies @option{--no-offload}, and it has no effect when
  8397. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  8398. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  8399. @item --keep-going
  8400. @itemx -k
  8401. Keep going when some of the derivations fail to build; return only once
  8402. all the builds have either completed or failed.
  8403. The default behavior is to stop as soon as one of the specified
  8404. derivations has failed.
  8405. @item --dry-run
  8406. @itemx -n
  8407. Do not build the derivations.
  8408. @anchor{fallback-option}
  8409. @item --fallback
  8410. When substituting a pre-built binary fails, fall back to building
  8411. packages locally (@pxref{Substitution Failure}).
  8412. @item --substitute-urls=@var{urls}
  8413. @anchor{client-substitute-urls}
  8414. Consider @var{urls} the whitespace-separated list of substitute source
  8415. URLs, overriding the default list of URLs of @command{guix-daemon}
  8416. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  8417. This means that substitutes may be downloaded from @var{urls}, provided
  8418. they are signed by a key authorized by the system administrator
  8419. (@pxref{Substitutes}).
  8420. When @var{urls} is the empty string, substitutes are effectively
  8421. disabled.
  8422. @item --no-substitutes
  8423. Do not use substitutes for build products. That is, always build things
  8424. locally instead of allowing downloads of pre-built binaries
  8425. (@pxref{Substitutes}).
  8426. @item --no-grafts
  8427. Do not ``graft'' packages. In practice, this means that package updates
  8428. available as grafts are not applied. @xref{Security Updates}, for more
  8429. information on grafts.
  8430. @item --rounds=@var{n}
  8431. Build each derivation @var{n} times in a row, and raise an error if
  8432. consecutive build results are not bit-for-bit identical.
  8433. This is a useful way to detect non-deterministic builds processes.
  8434. Non-deterministic build processes are a problem because they make it
  8435. practically impossible for users to @emph{verify} whether third-party
  8436. binaries are genuine. @xref{Invoking guix challenge}, for more.
  8437. When used in conjunction with @option{--keep-failed}, the differing
  8438. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8439. This makes it easy to look for differences between the two results.
  8440. @item --no-offload
  8441. Do not use offload builds to other machines (@pxref{Daemon Offload
  8442. Setup}). That is, always build things locally instead of offloading
  8443. builds to remote machines.
  8444. @item --max-silent-time=@var{seconds}
  8445. When the build or substitution process remains silent for more than
  8446. @var{seconds}, terminate it and report a build failure.
  8447. By default, the daemon's setting is honored (@pxref{Invoking
  8448. guix-daemon, @option{--max-silent-time}}).
  8449. @item --timeout=@var{seconds}
  8450. Likewise, when the build or substitution process lasts for more than
  8451. @var{seconds}, terminate it and report a build failure.
  8452. By default, the daemon's setting is honored (@pxref{Invoking
  8453. guix-daemon, @option{--timeout}}).
  8454. @c Note: This option is actually not part of %standard-build-options but
  8455. @c most programs honor it.
  8456. @cindex verbosity, of the command-line tools
  8457. @cindex build logs, verbosity
  8458. @item -v @var{level}
  8459. @itemx --verbosity=@var{level}
  8460. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  8461. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  8462. additionally displays download URLs; 3 shows all the build log output on
  8463. standard error.
  8464. @item --cores=@var{n}
  8465. @itemx -c @var{n}
  8466. Allow the use of up to @var{n} CPU cores for the build. The special
  8467. value @code{0} means to use as many CPU cores as available.
  8468. @item --max-jobs=@var{n}
  8469. @itemx -M @var{n}
  8470. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  8471. guix-daemon, @option{--max-jobs}}, for details about this option and the
  8472. equivalent @command{guix-daemon} option.
  8473. @item --debug=@var{level}
  8474. Produce debugging output coming from the build daemon. @var{level} must be an
  8475. integer between 0 and 5; higher means more verbose output. Setting a level of
  8476. 4 or more may be helpful when debugging setup issues with the build daemon.
  8477. @end table
  8478. Behind the scenes, @command{guix build} is essentially an interface to
  8479. the @code{package-derivation} procedure of the @code{(guix packages)}
  8480. module, and to the @code{build-derivations} procedure of the @code{(guix
  8481. derivations)} module.
  8482. In addition to options explicitly passed on the command line,
  8483. @command{guix build} and other @command{guix} commands that support
  8484. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  8485. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  8486. Users can define this variable to a list of command line options that
  8487. will automatically be used by @command{guix build} and other
  8488. @command{guix} commands that can perform builds, as in the example
  8489. below:
  8490. @example
  8491. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  8492. @end example
  8493. These options are parsed independently, and the result is appended to
  8494. the parsed command-line options.
  8495. @end defvr
  8496. @node Package Transformation Options
  8497. @subsection Package Transformation Options
  8498. @cindex package variants
  8499. Another set of command-line options supported by @command{guix build}
  8500. and also @command{guix package} are @dfn{package transformation
  8501. options}. These are options that make it possible to define @dfn{package
  8502. variants}---for instance, packages built from different source code.
  8503. This is a convenient way to create customized packages on the fly
  8504. without having to type in the definitions of package variants
  8505. (@pxref{Defining Packages}).
  8506. Package transformation options are preserved across upgrades:
  8507. @command{guix upgrade} attempts to apply transformation options
  8508. initially used when creating the profile to the upgraded packages.
  8509. The available options are listed below. Most commands support them and
  8510. also support a @option{--help-transform} option that lists all the
  8511. available options and a synopsis (these options are not shown in the
  8512. @option{--help} output for brevity).
  8513. @table @code
  8514. @item --with-source=@var{source}
  8515. @itemx --with-source=@var{package}=@var{source}
  8516. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  8517. Use @var{source} as the source of @var{package}, and @var{version} as
  8518. its version number.
  8519. @var{source} must be a file name or a URL, as for @command{guix
  8520. download} (@pxref{Invoking guix download}).
  8521. When @var{package} is omitted,
  8522. it is taken to be the package name specified on the
  8523. command line that matches the base of @var{source}---e.g.,
  8524. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  8525. package is @code{guile}.
  8526. Likewise, when @var{version} is omitted, the version string is inferred from
  8527. @var{source}; in the previous example, it is @code{2.0.10}.
  8528. This option allows users to try out versions of packages other than the
  8529. one provided by the distribution. The example below downloads
  8530. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  8531. the @code{ed} package:
  8532. @example
  8533. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  8534. @end example
  8535. As a developer, @option{--with-source} makes it easy to test release
  8536. candidates:
  8537. @example
  8538. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  8539. @end example
  8540. @dots{} or to build from a checkout in a pristine environment:
  8541. @example
  8542. $ git clone git://git.sv.gnu.org/guix.git
  8543. $ guix build guix --with-source=guix@@1.0=./guix
  8544. @end example
  8545. @item --with-input=@var{package}=@var{replacement}
  8546. Replace dependency on @var{package} by a dependency on
  8547. @var{replacement}. @var{package} must be a package name, and
  8548. @var{replacement} must be a package specification such as @code{guile}
  8549. or @code{guile@@1.8}.
  8550. For instance, the following command builds Guix, but replaces its
  8551. dependency on the current stable version of Guile with a dependency on
  8552. the legacy version of Guile, @code{guile@@2.0}:
  8553. @example
  8554. guix build --with-input=guile=guile@@2.0 guix
  8555. @end example
  8556. This is a recursive, deep replacement. So in this example, both
  8557. @code{guix} and its dependency @code{guile-json} (which also depends on
  8558. @code{guile}) get rebuilt against @code{guile@@2.0}.
  8559. This is implemented using the @code{package-input-rewriting} Scheme
  8560. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  8561. @item --with-graft=@var{package}=@var{replacement}
  8562. This is similar to @option{--with-input} but with an important difference:
  8563. instead of rebuilding the whole dependency chain, @var{replacement} is
  8564. built and then @dfn{grafted} onto the binaries that were initially
  8565. referring to @var{package}. @xref{Security Updates}, for more
  8566. information on grafts.
  8567. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  8568. and all its dependencies, replacing references to the version of GnuTLS
  8569. they currently refer to:
  8570. @example
  8571. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  8572. @end example
  8573. This has the advantage of being much faster than rebuilding everything.
  8574. But there is a caveat: it works if and only if @var{package} and
  8575. @var{replacement} are strictly compatible---for example, if they provide
  8576. a library, the application binary interface (ABI) of those libraries
  8577. must be compatible. If @var{replacement} is somehow incompatible with
  8578. @var{package}, then the resulting package may be unusable. Use with
  8579. care!
  8580. @cindex debugging info, rebuilding
  8581. @item --with-debug-info=@var{package}
  8582. Build @var{package} in a way that preserves its debugging info and graft
  8583. it onto packages that depend on it. This is useful if @var{package}
  8584. does not already provide debugging info as a @code{debug} output
  8585. (@pxref{Installing Debugging Files}).
  8586. For example, suppose you're experiencing a crash in Inkscape and would
  8587. like to see what's up in GLib, a library deep down in Inkscape's
  8588. dependency graph. GLib lacks a @code{debug} output, so debugging is
  8589. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  8590. Inkscape:
  8591. @example
  8592. guix install inkscape --with-debug-info=glib
  8593. @end example
  8594. Only GLib needs to be recompiled so this takes a reasonable amount of
  8595. time. @xref{Installing Debugging Files}, for more info.
  8596. @quotation Note
  8597. Under the hood, this option works by passing the @samp{#:strip-binaries?
  8598. #f} to the build system of the package of interest (@pxref{Build
  8599. Systems}). Most build systems support that option but some do not. In
  8600. that case, an error is raised.
  8601. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  8602. the case), debugging info will remain unavailable even when
  8603. @code{#:strip-binaries?} is false.
  8604. @end quotation
  8605. @cindex tool chain, changing the build tool chain of a package
  8606. @item --with-c-toolchain=@var{package}=@var{toolchain}
  8607. This option changes the compilation of @var{package} and everything that
  8608. depends on it so that they get built with @var{toolchain} instead of the
  8609. default GNU tool chain for C/C++.
  8610. Consider this example:
  8611. @example
  8612. guix build octave-cli \
  8613. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  8614. --with-c-toolchain=fftwf=gcc-toolchain@@10
  8615. @end example
  8616. The command above builds a variant of the @code{fftw} and @code{fftwf}
  8617. packages using version 10 of @code{gcc-toolchain} instead of the default
  8618. tool chain, and then builds a variant of the GNU@tie{}Octave
  8619. command-line interface using them. GNU@tie{}Octave itself is also built
  8620. with @code{gcc-toolchain@@10}.
  8621. This other example builds the Hardware Locality (@code{hwloc}) library
  8622. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  8623. compiler:
  8624. @example
  8625. guix build --with-c-toolchain=hwloc=clang-toolchain \
  8626. intel-mpi-benchmarks
  8627. @end example
  8628. @quotation Note
  8629. There can be application binary interface (ABI) incompatibilities among
  8630. tool chains. This is particularly true of the C++ standard library and
  8631. run-time support libraries such as that of OpenMP@. By rebuilding all
  8632. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  8633. the risks of incompatibility but cannot entirely eliminate them. Choose
  8634. @var{package} wisely.
  8635. @end quotation
  8636. @item --with-git-url=@var{package}=@var{url}
  8637. @cindex Git, using the latest commit
  8638. @cindex latest commit, building
  8639. Build @var{package} from the latest commit of the @code{master} branch of the
  8640. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  8641. recursively.
  8642. For example, the following command builds the NumPy Python library against the
  8643. latest commit of the master branch of Python itself:
  8644. @example
  8645. guix build python-numpy \
  8646. --with-git-url=python=https://github.com/python/cpython
  8647. @end example
  8648. This option can also be combined with @option{--with-branch} or
  8649. @option{--with-commit} (see below).
  8650. @cindex continuous integration
  8651. Obviously, since it uses the latest commit of the given branch, the result of
  8652. such a command varies over time. Nevertheless it is a convenient way to
  8653. rebuild entire software stacks against the latest commit of one or more
  8654. packages. This is particularly useful in the context of continuous
  8655. integration (CI).
  8656. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  8657. consecutive accesses to the same repository. You may want to clean it up once
  8658. in a while to save disk space.
  8659. @item --with-branch=@var{package}=@var{branch}
  8660. Build @var{package} from the latest commit of @var{branch}. If the
  8661. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  8662. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  8663. repository URL is taken from that @code{source}. Otherwise you have to use
  8664. @option{--with-git-url} to specify the URL of the Git repository.
  8665. For instance, the following command builds @code{guile-sqlite3} from the
  8666. latest commit of its @code{master} branch, and then builds @code{guix} (which
  8667. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  8668. specific @code{guile-sqlite3} build:
  8669. @example
  8670. guix build --with-branch=guile-sqlite3=master cuirass
  8671. @end example
  8672. @item --with-commit=@var{package}=@var{commit}
  8673. This is similar to @option{--with-branch}, except that it builds from
  8674. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  8675. Git commit SHA1 identifier or a tag.
  8676. @item --with-patch=@var{package}=@var{file}
  8677. Add @var{file} to the list of patches applied to @var{package}, where
  8678. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  8679. @var{file} must contain a patch; it is applied with the flags specified
  8680. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  8681. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  8682. Comparing and Merging Files}).
  8683. As an example, the command below rebuilds Coreutils with the GNU C
  8684. Library (glibc) patched with the given patch:
  8685. @example
  8686. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  8687. @end example
  8688. In this example, glibc itself as well as everything that leads to
  8689. Coreutils in the dependency graph is rebuilt.
  8690. @cindex upstream, latest version
  8691. @item --with-latest=@var{package}
  8692. So you like living on the bleeding edge? This option is for you! It
  8693. replaces occurrences of @var{package} in the dependency graph with its
  8694. latest upstream version, as reported by @command{guix refresh}
  8695. (@pxref{Invoking guix refresh}).
  8696. It does so by determining the latest upstream release of @var{package}
  8697. (if possible), downloading it, and authenticating it @emph{if} it comes
  8698. with an OpenPGP signature.
  8699. As an example, the command below builds Guix against the latest version
  8700. of Guile-JSON:
  8701. @example
  8702. guix build guix --with-latest=guile-json
  8703. @end example
  8704. There are limitations. First, in cases where the tool cannot or does
  8705. not know how to authenticate source code, you are at risk of running
  8706. malicious code; a warning is emitted in this case. Second, this option
  8707. simply changes the source used in the existing package definitions,
  8708. which is not always sufficient: there might be additional dependencies
  8709. that need to be added, patches to apply, and more generally the quality
  8710. assurance work that Guix developers normally do will be missing.
  8711. You've been warned! In all the other cases, it's a snappy way to stay
  8712. on top. We encourage you to submit patches updating the actual package
  8713. definitions once you have successfully tested an upgrade
  8714. (@pxref{Contributing}).
  8715. @cindex test suite, skipping
  8716. @item --without-tests=@var{package}
  8717. Build @var{package} without running its tests. This can be useful in
  8718. situations where you want to skip the lengthy test suite of a
  8719. intermediate package, or if a package's test suite fails in a
  8720. non-deterministic fashion. It should be used with care because running
  8721. the test suite is a good way to ensure a package is working as intended.
  8722. Turning off tests leads to a different store item. Consequently, when
  8723. using this option, anything that depends on @var{package} must be
  8724. rebuilt, as in this example:
  8725. @example
  8726. guix install --without-tests=python python-notebook
  8727. @end example
  8728. The command above installs @code{python-notebook} on top of
  8729. @code{python} built without running its test suite. To do so, it also
  8730. rebuilds everything that depends on @code{python}, including
  8731. @code{python-notebook} itself.
  8732. Internally, @option{--without-tests} relies on changing the
  8733. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  8734. Systems}). Note that some packages use a customized @code{check} phase
  8735. that does not respect a @code{#:tests? #f} setting. Therefore,
  8736. @option{--without-tests} has no effect on these packages.
  8737. @end table
  8738. Wondering how to achieve the same effect using Scheme code, for example
  8739. in your manifest, or how to write your own package transformation?
  8740. @xref{Defining Package Variants}, for an overview of the programming
  8741. interfaces available.
  8742. @node Additional Build Options
  8743. @subsection Additional Build Options
  8744. The command-line options presented below are specific to @command{guix
  8745. build}.
  8746. @table @code
  8747. @item --quiet
  8748. @itemx -q
  8749. Build quietly, without displaying the build log; this is equivalent to
  8750. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  8751. (or similar) and can always be retrieved using the @option{--log-file} option.
  8752. @item --file=@var{file}
  8753. @itemx -f @var{file}
  8754. Build the package, derivation, or other file-like object that the code within
  8755. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  8756. As an example, @var{file} might contain a package definition like this
  8757. (@pxref{Defining Packages}):
  8758. @lisp
  8759. @include package-hello.scm
  8760. @end lisp
  8761. The @var{file} may also contain a JSON representation of one or more
  8762. package definitions. Running @code{guix build -f} on @file{hello.json}
  8763. with the following contents would result in building the packages
  8764. @code{myhello} and @code{greeter}:
  8765. @example
  8766. @verbatiminclude package-hello.json
  8767. @end example
  8768. @item --manifest=@var{manifest}
  8769. @itemx -m @var{manifest}
  8770. Build all packages listed in the given @var{manifest}
  8771. (@pxref{profile-manifest, @option{--manifest}}).
  8772. @item --expression=@var{expr}
  8773. @itemx -e @var{expr}
  8774. Build the package or derivation @var{expr} evaluates to.
  8775. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  8776. guile-1.8)}, which unambiguously designates this specific variant of
  8777. version 1.8 of Guile.
  8778. Alternatively, @var{expr} may be a G-expression, in which case it is used
  8779. as a build program passed to @code{gexp->derivation}
  8780. (@pxref{G-Expressions}).
  8781. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  8782. (@pxref{The Store Monad}). The procedure must return a derivation as a
  8783. monadic value, which is then passed through @code{run-with-store}.
  8784. @item --source
  8785. @itemx -S
  8786. Build the source derivations of the packages, rather than the packages
  8787. themselves.
  8788. For instance, @code{guix build -S gcc} returns something like
  8789. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  8790. source tarball.
  8791. The returned source tarball is the result of applying any patches and
  8792. code snippets specified in the package @code{origin} (@pxref{Defining
  8793. Packages}).
  8794. @cindex source, verification
  8795. As with other derivations, the result of building a source derivation
  8796. can be verified using the @option{--check} option (@pxref{build-check}).
  8797. This is useful to validate that a (potentially already built or
  8798. substituted, thus cached) package source matches against its declared
  8799. hash.
  8800. Note that @command{guix build -S} compiles the sources only of the
  8801. specified packages. They do not include the sources of statically
  8802. linked dependencies and by themselves are insufficient for reproducing
  8803. the packages.
  8804. @item --sources
  8805. Fetch and return the source of @var{package-or-derivation} and all their
  8806. dependencies, recursively. This is a handy way to obtain a local copy
  8807. of all the source code needed to build @var{packages}, allowing you to
  8808. eventually build them even without network access. It is an extension
  8809. of the @option{--source} option and can accept one of the following
  8810. optional argument values:
  8811. @table @code
  8812. @item package
  8813. This value causes the @option{--sources} option to behave in the same way
  8814. as the @option{--source} option.
  8815. @item all
  8816. Build the source derivations of all packages, including any source that
  8817. might be listed as @code{inputs}. This is the default value.
  8818. @example
  8819. $ guix build --sources tzdata
  8820. The following derivations will be built:
  8821. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  8822. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8823. @end example
  8824. @item transitive
  8825. Build the source derivations of all packages, as well of all transitive
  8826. inputs to the packages. This can be used e.g.@: to
  8827. prefetch package source for later offline building.
  8828. @example
  8829. $ guix build --sources=transitive tzdata
  8830. The following derivations will be built:
  8831. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8832. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  8833. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  8834. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  8835. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  8836. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  8837. @dots{}
  8838. @end example
  8839. @end table
  8840. @item --system=@var{system}
  8841. @itemx -s @var{system}
  8842. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  8843. the system type of the build host. The @command{guix build} command allows
  8844. you to repeat this option several times, in which case it builds for all the
  8845. specified systems; other commands ignore extraneous @option{-s} options.
  8846. @quotation Note
  8847. The @option{--system} flag is for @emph{native} compilation and must not
  8848. be confused with cross-compilation. See @option{--target} below for
  8849. information on cross-compilation.
  8850. @end quotation
  8851. An example use of this is on Linux-based systems, which can emulate
  8852. different personalities. For instance, passing
  8853. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  8854. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  8855. you to build packages in a complete 32-bit environment.
  8856. @quotation Note
  8857. Building for an @code{armhf-linux} system is unconditionally enabled on
  8858. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  8859. allow for this functionality, notably the ThunderX.
  8860. @end quotation
  8861. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  8862. is enabled (@pxref{Virtualization Services,
  8863. @code{qemu-binfmt-service-type}}), you can build for any system for
  8864. which a QEMU @code{binfmt_misc} handler is installed.
  8865. Builds for a system other than that of the machine you are using can
  8866. also be offloaded to a remote machine of the right architecture.
  8867. @xref{Daemon Offload Setup}, for more information on offloading.
  8868. @item --target=@var{triplet}
  8869. @cindex cross-compilation
  8870. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  8871. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  8872. configuration triplets,, autoconf, Autoconf}).
  8873. @anchor{build-check}
  8874. @item --check
  8875. @cindex determinism, checking
  8876. @cindex reproducibility, checking
  8877. Rebuild @var{package-or-derivation}, which are already available in the
  8878. store, and raise an error if the build results are not bit-for-bit
  8879. identical.
  8880. This mechanism allows you to check whether previously installed
  8881. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  8882. of a package is deterministic. @xref{Invoking guix challenge}, for more
  8883. background information and tools.
  8884. When used in conjunction with @option{--keep-failed}, the differing
  8885. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8886. This makes it easy to look for differences between the two results.
  8887. @item --repair
  8888. @cindex repairing store items
  8889. @cindex corruption, recovering from
  8890. Attempt to repair the specified store items, if they are corrupt, by
  8891. re-downloading or rebuilding them.
  8892. This operation is not atomic and thus restricted to @code{root}.
  8893. @item --derivations
  8894. @itemx -d
  8895. Return the derivation paths, not the output paths, of the given
  8896. packages.
  8897. @item --root=@var{file}
  8898. @itemx -r @var{file}
  8899. @cindex GC roots, adding
  8900. @cindex garbage collector roots, adding
  8901. Make @var{file} a symlink to the result, and register it as a garbage
  8902. collector root.
  8903. Consequently, the results of this @command{guix build} invocation are
  8904. protected from garbage collection until @var{file} is removed. When
  8905. that option is omitted, build results are eligible for garbage
  8906. collection as soon as the build completes. @xref{Invoking guix gc}, for
  8907. more on GC roots.
  8908. @item --log-file
  8909. @cindex build logs, access
  8910. Return the build log file names or URLs for the given
  8911. @var{package-or-derivation}, or raise an error if build logs are
  8912. missing.
  8913. This works regardless of how packages or derivations are specified. For
  8914. instance, the following invocations are equivalent:
  8915. @example
  8916. guix build --log-file $(guix build -d guile)
  8917. guix build --log-file $(guix build guile)
  8918. guix build --log-file guile
  8919. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  8920. @end example
  8921. If a log is unavailable locally, and unless @option{--no-substitutes} is
  8922. passed, the command looks for a corresponding log on one of the
  8923. substitute servers (as specified with @option{--substitute-urls}).
  8924. So for instance, imagine you want to see the build log of GDB on MIPS,
  8925. but you are actually on an @code{x86_64} machine:
  8926. @example
  8927. $ guix build --log-file gdb -s aarch64-linux
  8928. https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
  8929. @end example
  8930. You can freely access a huge library of build logs!
  8931. @end table
  8932. @node Debugging Build Failures
  8933. @subsection Debugging Build Failures
  8934. @cindex build failures, debugging
  8935. When defining a new package (@pxref{Defining Packages}), you will
  8936. probably find yourself spending some time debugging and tweaking the
  8937. build until it succeeds. To do that, you need to operate the build
  8938. commands yourself in an environment as close as possible to the one the
  8939. build daemon uses.
  8940. To that end, the first thing to do is to use the @option{--keep-failed}
  8941. or @option{-K} option of @command{guix build}, which will keep the
  8942. failed build tree in @file{/tmp} or whatever directory you specified as
  8943. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  8944. From there on, you can @command{cd} to the failed build tree and source
  8945. the @file{environment-variables} file, which contains all the
  8946. environment variable definitions that were in place when the build
  8947. failed. So let's say you're debugging a build failure in package
  8948. @code{foo}; a typical session would look like this:
  8949. @example
  8950. $ guix build foo -K
  8951. @dots{} @i{build fails}
  8952. $ cd /tmp/guix-build-foo.drv-0
  8953. $ source ./environment-variables
  8954. $ cd foo-1.2
  8955. @end example
  8956. Now, you can invoke commands as if you were the daemon (almost) and
  8957. troubleshoot your build process.
  8958. Sometimes it happens that, for example, a package's tests pass when you
  8959. run them manually but they fail when the daemon runs them. This can
  8960. happen because the daemon runs builds in containers where, unlike in our
  8961. environment above, network access is missing, @file{/bin/sh} does not
  8962. exist, etc. (@pxref{Build Environment Setup}).
  8963. In such cases, you may need to run inspect the build process from within
  8964. a container similar to the one the build daemon creates:
  8965. @example
  8966. $ guix build -K foo
  8967. @dots{}
  8968. $ cd /tmp/guix-build-foo.drv-0
  8969. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  8970. [env]# source ./environment-variables
  8971. [env]# cd foo-1.2
  8972. @end example
  8973. Here, @command{guix environment -C} creates a container and spawns a new
  8974. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  8975. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  8976. the container, which you may find handy while debugging. The
  8977. @option{--no-grafts} option makes sure we get the exact same
  8978. environment, with ungrafted packages (@pxref{Security Updates}, for more
  8979. info on grafts).
  8980. To get closer to a container like that used by the build daemon, we can
  8981. remove @file{/bin/sh}:
  8982. @example
  8983. [env]# rm /bin/sh
  8984. @end example
  8985. (Don't worry, this is harmless: this is all happening in the throw-away
  8986. container created by @command{guix environment}.)
  8987. The @command{strace} command is probably not in the search path, but we
  8988. can run:
  8989. @example
  8990. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  8991. @end example
  8992. In this way, not only you will have reproduced the environment variables
  8993. the daemon uses, you will also be running the build process in a container
  8994. similar to the one the daemon uses.
  8995. @node Invoking guix edit
  8996. @section Invoking @command{guix edit}
  8997. @cindex @command{guix edit}
  8998. @cindex package definition, editing
  8999. So many packages, so many source files! The @command{guix edit} command
  9000. facilitates the life of users and packagers by pointing their editor at
  9001. the source file containing the definition of the specified packages.
  9002. For instance:
  9003. @example
  9004. guix edit gcc@@4.9 vim
  9005. @end example
  9006. @noindent
  9007. launches the program specified in the @env{VISUAL} or in the
  9008. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  9009. and that of Vim.
  9010. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  9011. have created your own packages on @env{GUIX_PACKAGE_PATH}
  9012. (@pxref{Package Modules}), you will be able to edit the package
  9013. recipes. In other cases, you will be able to examine the read-only recipes
  9014. for packages currently in the store.
  9015. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  9016. @option{--load-path=@var{directory}} (or in short @option{-L
  9017. @var{directory}}) allows you to add @var{directory} to the front of the
  9018. package module search path and so make your own packages visible.
  9019. @node Invoking guix download
  9020. @section Invoking @command{guix download}
  9021. @cindex @command{guix download}
  9022. @cindex downloading package sources
  9023. When writing a package definition, developers typically need to download
  9024. a source tarball, compute its SHA256 hash, and write that
  9025. hash in the package definition (@pxref{Defining Packages}). The
  9026. @command{guix download} tool helps with this task: it downloads a file
  9027. from the given URI, adds it to the store, and prints both its file name
  9028. in the store and its SHA256 hash.
  9029. The fact that the downloaded file is added to the store saves bandwidth:
  9030. when the developer eventually tries to build the newly defined package
  9031. with @command{guix build}, the source tarball will not have to be
  9032. downloaded again because it is already in the store. It is also a
  9033. convenient way to temporarily stash files, which may be deleted
  9034. eventually (@pxref{Invoking guix gc}).
  9035. The @command{guix download} command supports the same URIs as used in
  9036. package definitions. In particular, it supports @code{mirror://} URIs.
  9037. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  9038. Guile bindings for GnuTLS are available in the user's environment; when
  9039. they are not available, an error is raised. @xref{Guile Preparations,
  9040. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  9041. GnuTLS-Guile}, for more information.
  9042. @command{guix download} verifies HTTPS server certificates by loading
  9043. the certificates of X.509 authorities from the directory pointed to by
  9044. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  9045. Certificates}), unless @option{--no-check-certificate} is used.
  9046. The following options are available:
  9047. @table @code
  9048. @item --hash=@var{algorithm}
  9049. @itemx -H @var{algorithm}
  9050. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  9051. hash}, for more information.
  9052. @item --format=@var{fmt}
  9053. @itemx -f @var{fmt}
  9054. Write the hash in the format specified by @var{fmt}. For more
  9055. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  9056. @item --no-check-certificate
  9057. Do not validate the X.509 certificates of HTTPS servers.
  9058. When using this option, you have @emph{absolutely no guarantee} that you
  9059. are communicating with the authentic server responsible for the given
  9060. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  9061. @item --output=@var{file}
  9062. @itemx -o @var{file}
  9063. Save the downloaded file to @var{file} instead of adding it to the
  9064. store.
  9065. @end table
  9066. @node Invoking guix hash
  9067. @section Invoking @command{guix hash}
  9068. @cindex @command{guix hash}
  9069. The @command{guix hash} command computes the hash of a file.
  9070. It is primarily a convenience tool for anyone contributing to the
  9071. distribution: it computes the cryptographic hash of a file, which can be
  9072. used in the definition of a package (@pxref{Defining Packages}).
  9073. The general syntax is:
  9074. @example
  9075. guix hash @var{option} @var{file}
  9076. @end example
  9077. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  9078. hash of data read from standard input. @command{guix hash} has the
  9079. following options:
  9080. @table @code
  9081. @item --hash=@var{algorithm}
  9082. @itemx -H @var{algorithm}
  9083. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  9084. default.
  9085. @var{algorithm} must the name of a cryptographic hash algorithm
  9086. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  9087. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  9088. Reference Manual}).
  9089. @item --format=@var{fmt}
  9090. @itemx -f @var{fmt}
  9091. Write the hash in the format specified by @var{fmt}.
  9092. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  9093. (@code{hex} and @code{hexadecimal} can be used as well).
  9094. If the @option{--format} option is not specified, @command{guix hash}
  9095. will output the hash in @code{nix-base32}. This representation is used
  9096. in the definitions of packages.
  9097. @item --recursive
  9098. @itemx -r
  9099. Compute the hash on @var{file} recursively.
  9100. In this case, the hash is computed on an archive containing @var{file},
  9101. including its children if it is a directory. Some of the metadata of
  9102. @var{file} is part of the archive; for instance, when @var{file} is a
  9103. regular file, the hash is different depending on whether @var{file} is
  9104. executable or not. Metadata such as time stamps has no impact on the
  9105. hash (@pxref{Invoking guix archive}).
  9106. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  9107. @c it exists.
  9108. @item --exclude-vcs
  9109. @itemx -x
  9110. When combined with @option{--recursive}, exclude version control system
  9111. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  9112. @vindex git-fetch
  9113. As an example, here is how you would compute the hash of a Git checkout,
  9114. which is useful when using the @code{git-fetch} method (@pxref{origin
  9115. Reference}):
  9116. @example
  9117. $ git clone http://example.org/foo.git
  9118. $ cd foo
  9119. $ guix hash -rx .
  9120. @end example
  9121. @end table
  9122. @node Invoking guix import
  9123. @section Invoking @command{guix import}
  9124. @cindex importing packages
  9125. @cindex package import
  9126. @cindex package conversion
  9127. @cindex Invoking @command{guix import}
  9128. The @command{guix import} command is useful for people who would like to
  9129. add a package to the distribution with as little work as
  9130. possible---a legitimate demand. The command knows of a few
  9131. repositories from which it can ``import'' package metadata. The result
  9132. is a package definition, or a template thereof, in the format we know
  9133. (@pxref{Defining Packages}).
  9134. The general syntax is:
  9135. @example
  9136. guix import @var{importer} @var{options}@dots{}
  9137. @end example
  9138. @var{importer} specifies the source from which to import package
  9139. metadata, and @var{options} specifies a package identifier and other
  9140. options specific to @var{importer}.
  9141. Some of the importers rely on the ability to run the @command{gpgv} command.
  9142. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  9143. gnupg} if needed.
  9144. Currently, the available ``importers'' are:
  9145. @table @code
  9146. @item gnu
  9147. Import metadata for the given GNU package. This provides a template
  9148. for the latest version of that GNU package, including the hash of its
  9149. source tarball, and its canonical synopsis and description.
  9150. Additional information such as the package dependencies and its
  9151. license needs to be figured out manually.
  9152. For example, the following command returns a package definition for
  9153. GNU@tie{}Hello:
  9154. @example
  9155. guix import gnu hello
  9156. @end example
  9157. Specific command-line options are:
  9158. @table @code
  9159. @item --key-download=@var{policy}
  9160. As for @command{guix refresh}, specify the policy to handle missing
  9161. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  9162. refresh, @option{--key-download}}.
  9163. @end table
  9164. @item pypi
  9165. @cindex pypi
  9166. Import metadata from the @uref{https://pypi.python.org/, Python Package
  9167. Index}. Information is taken from the JSON-formatted description
  9168. available at @code{pypi.python.org} and usually includes all the relevant
  9169. information, including package dependencies. For maximum efficiency, it
  9170. is recommended to install the @command{unzip} utility, so that the
  9171. importer can unzip Python wheels and gather data from them.
  9172. The command below imports metadata for the @code{itsdangerous} Python
  9173. package:
  9174. @example
  9175. guix import pypi itsdangerous
  9176. @end example
  9177. @table @code
  9178. @item --recursive
  9179. @itemx -r
  9180. Traverse the dependency graph of the given upstream package recursively
  9181. and generate package expressions for all those packages that are not yet
  9182. in Guix.
  9183. @end table
  9184. @item gem
  9185. @cindex gem
  9186. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  9187. is taken from the JSON-formatted description available at
  9188. @code{rubygems.org} and includes most relevant information, including
  9189. runtime dependencies. There are some caveats, however. The metadata
  9190. doesn't distinguish between synopses and descriptions, so the same string
  9191. is used for both fields. Additionally, the details of non-Ruby
  9192. dependencies required to build native extensions is unavailable and left
  9193. as an exercise to the packager.
  9194. The command below imports metadata for the @code{rails} Ruby package:
  9195. @example
  9196. guix import gem rails
  9197. @end example
  9198. @table @code
  9199. @item --recursive
  9200. @itemx -r
  9201. Traverse the dependency graph of the given upstream package recursively
  9202. and generate package expressions for all those packages that are not yet
  9203. in Guix.
  9204. @end table
  9205. @item cpan
  9206. @cindex CPAN
  9207. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  9208. Information is taken from the JSON-formatted metadata provided through
  9209. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  9210. relevant information, such as module dependencies. License information
  9211. should be checked closely. If Perl is available in the store, then the
  9212. @code{corelist} utility will be used to filter core modules out of the
  9213. list of dependencies.
  9214. The command command below imports metadata for the Acme::Boolean Perl
  9215. module:
  9216. @example
  9217. guix import cpan Acme::Boolean
  9218. @end example
  9219. @item cran
  9220. @cindex CRAN
  9221. @cindex Bioconductor
  9222. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  9223. central repository for the @uref{https://r-project.org, GNU@tie{}R
  9224. statistical and graphical environment}.
  9225. Information is extracted from the @file{DESCRIPTION} file of the package.
  9226. The command command below imports metadata for the Cairo R package:
  9227. @example
  9228. guix import cran Cairo
  9229. @end example
  9230. When @option{--recursive} is added, the importer will traverse the
  9231. dependency graph of the given upstream package recursively and generate
  9232. package expressions for all those packages that are not yet in Guix.
  9233. When @option{--style=specification} is added, the importer will generate
  9234. package definitions whose inputs are package specifications instead of
  9235. references to package variables. This is useful when generated package
  9236. definitions are to be appended to existing user modules, as the list of
  9237. used package modules need not be changed. The default is
  9238. @option{--style=variable}.
  9239. When @option{--archive=bioconductor} is added, metadata is imported from
  9240. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  9241. packages for the analysis and comprehension of high-throughput
  9242. genomic data in bioinformatics.
  9243. Information is extracted from the @file{DESCRIPTION} file contained in the
  9244. package archive.
  9245. The command below imports metadata for the GenomicRanges R package:
  9246. @example
  9247. guix import cran --archive=bioconductor GenomicRanges
  9248. @end example
  9249. Finally, you can also import R packages that have not yet been published on
  9250. CRAN or Bioconductor as long as they are in a git repository. Use
  9251. @option{--archive=git} followed by the URL of the git repository:
  9252. @example
  9253. guix import cran --archive=git https://github.com/immunogenomics/harmony
  9254. @end example
  9255. @item texlive
  9256. @cindex TeX Live
  9257. @cindex CTAN
  9258. Import metadata from @uref{https://www.ctan.org/, CTAN}, the
  9259. comprehensive TeX archive network for TeX packages that are part of the
  9260. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  9261. Information about the package is obtained through the XML API provided
  9262. by CTAN, while the source code is downloaded from the SVN repository of
  9263. the Tex Live project. This is done because the CTAN does not keep
  9264. versioned archives.
  9265. The command command below imports metadata for the @code{fontspec}
  9266. TeX package:
  9267. @example
  9268. guix import texlive fontspec
  9269. @end example
  9270. When @option{--archive=@var{directory}} is added, the source code is
  9271. downloaded not from the @file{latex} sub-directory of the
  9272. @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
  9273. the specified sibling @var{directory} under the same root.
  9274. The command below imports metadata for the @code{ifxetex} package from
  9275. CTAN while fetching the sources from the directory
  9276. @file{texmf/source/generic}:
  9277. @example
  9278. guix import texlive --archive=generic ifxetex
  9279. @end example
  9280. @item json
  9281. @cindex JSON, import
  9282. Import package metadata from a local JSON file. Consider the following
  9283. example package definition in JSON format:
  9284. @example
  9285. @{
  9286. "name": "hello",
  9287. "version": "2.10",
  9288. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  9289. "build-system": "gnu",
  9290. "home-page": "https://www.gnu.org/software/hello/",
  9291. "synopsis": "Hello, GNU world: An example GNU package",
  9292. "description": "GNU Hello prints a greeting.",
  9293. "license": "GPL-3.0+",
  9294. "native-inputs": ["gettext"]
  9295. @}
  9296. @end example
  9297. The field names are the same as for the @code{<package>} record
  9298. (@xref{Defining Packages}). References to other packages are provided
  9299. as JSON lists of quoted package specification strings such as
  9300. @code{guile} or @code{guile@@2.0}.
  9301. The importer also supports a more explicit source definition using the
  9302. common fields for @code{<origin>} records:
  9303. @example
  9304. @{
  9305. @dots{}
  9306. "source": @{
  9307. "method": "url-fetch",
  9308. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  9309. "sha256": @{
  9310. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  9311. @}
  9312. @}
  9313. @dots{}
  9314. @}
  9315. @end example
  9316. The command below reads metadata from the JSON file @code{hello.json}
  9317. and outputs a package expression:
  9318. @example
  9319. guix import json hello.json
  9320. @end example
  9321. @item nix
  9322. Import metadata from a local copy of the source of the
  9323. @uref{https://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  9324. relies on the @command{nix-instantiate} command of
  9325. @uref{https://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  9326. typically written in a mixture of Nix-language and Bash code. This
  9327. command only imports the high-level package structure that is written in
  9328. the Nix language. It normally includes all the basic fields of a
  9329. package definition.
  9330. When importing a GNU package, the synopsis and descriptions are replaced
  9331. by their canonical upstream variant.
  9332. Usually, you will first need to do:
  9333. @example
  9334. export NIX_REMOTE=daemon
  9335. @end example
  9336. @noindent
  9337. so that @command{nix-instantiate} does not try to open the Nix database.
  9338. As an example, the command below imports the package definition of
  9339. LibreOffice (more precisely, it imports the definition of the package
  9340. bound to the @code{libreoffice} top-level attribute):
  9341. @example
  9342. guix import nix ~/path/to/nixpkgs libreoffice
  9343. @end example
  9344. @item hackage
  9345. @cindex hackage
  9346. Import metadata from the Haskell community's central package archive
  9347. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  9348. Cabal files and includes all the relevant information, including package
  9349. dependencies.
  9350. Specific command-line options are:
  9351. @table @code
  9352. @item --stdin
  9353. @itemx -s
  9354. Read a Cabal file from standard input.
  9355. @item --no-test-dependencies
  9356. @itemx -t
  9357. Do not include dependencies required only by the test suites.
  9358. @item --cabal-environment=@var{alist}
  9359. @itemx -e @var{alist}
  9360. @var{alist} is a Scheme alist defining the environment in which the
  9361. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  9362. @code{arch}, @code{impl} and a string representing the name of a flag.
  9363. The value associated with a flag has to be either the symbol
  9364. @code{true} or @code{false}. The value associated with other keys
  9365. has to conform to the Cabal file format definition. The default value
  9366. associated with the keys @code{os}, @code{arch} and @code{impl} is
  9367. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  9368. @item --recursive
  9369. @itemx -r
  9370. Traverse the dependency graph of the given upstream package recursively
  9371. and generate package expressions for all those packages that are not yet
  9372. in Guix.
  9373. @end table
  9374. The command below imports metadata for the latest version of the
  9375. HTTP Haskell package without including test dependencies and
  9376. specifying the value of the flag @samp{network-uri} as @code{false}:
  9377. @example
  9378. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  9379. @end example
  9380. A specific package version may optionally be specified by following the
  9381. package name by an at-sign and a version number as in the following example:
  9382. @example
  9383. guix import hackage mtl@@2.1.3.1
  9384. @end example
  9385. @item stackage
  9386. @cindex stackage
  9387. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  9388. It takes a package name, looks up the package version included in a
  9389. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  9390. release and uses the @code{hackage} importer to retrieve its metadata.
  9391. Note that it is up to you to select an LTS release compatible with the
  9392. GHC compiler used by Guix.
  9393. Specific command-line options are:
  9394. @table @code
  9395. @item --no-test-dependencies
  9396. @itemx -t
  9397. Do not include dependencies required only by the test suites.
  9398. @item --lts-version=@var{version}
  9399. @itemx -l @var{version}
  9400. @var{version} is the desired LTS release version. If omitted the latest
  9401. release is used.
  9402. @item --recursive
  9403. @itemx -r
  9404. Traverse the dependency graph of the given upstream package recursively
  9405. and generate package expressions for all those packages that are not yet
  9406. in Guix.
  9407. @end table
  9408. The command below imports metadata for the HTTP Haskell package
  9409. included in the LTS Stackage release version 7.18:
  9410. @example
  9411. guix import stackage --lts-version=7.18 HTTP
  9412. @end example
  9413. @item elpa
  9414. @cindex elpa
  9415. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  9416. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  9417. Specific command-line options are:
  9418. @table @code
  9419. @item --archive=@var{repo}
  9420. @itemx -a @var{repo}
  9421. @var{repo} identifies the archive repository from which to retrieve the
  9422. information. Currently the supported repositories and their identifiers
  9423. are:
  9424. @itemize -
  9425. @item
  9426. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  9427. identifier. This is the default.
  9428. Packages from @code{elpa.gnu.org} are signed with one of the keys
  9429. contained in the GnuPG keyring at
  9430. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  9431. @code{emacs} package (@pxref{Package Installation, ELPA package
  9432. signatures,, emacs, The GNU Emacs Manual}).
  9433. @item
  9434. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  9435. @code{melpa-stable} identifier.
  9436. @item
  9437. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  9438. identifier.
  9439. @end itemize
  9440. @item --recursive
  9441. @itemx -r
  9442. Traverse the dependency graph of the given upstream package recursively
  9443. and generate package expressions for all those packages that are not yet
  9444. in Guix.
  9445. @end table
  9446. @item crate
  9447. @cindex crate
  9448. Import metadata from the crates.io Rust package repository
  9449. @uref{https://crates.io, crates.io}, as in this example:
  9450. @example
  9451. guix import crate blake2-rfc
  9452. @end example
  9453. The crate importer also allows you to specify a version string:
  9454. @example
  9455. guix import crate constant-time-eq@@0.1.0
  9456. @end example
  9457. Additional options include:
  9458. @table @code
  9459. @item --recursive
  9460. @itemx -r
  9461. Traverse the dependency graph of the given upstream package recursively
  9462. and generate package expressions for all those packages that are not yet
  9463. in Guix.
  9464. @end table
  9465. @item opam
  9466. @cindex OPAM
  9467. @cindex OCaml
  9468. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  9469. repository used by the OCaml community.
  9470. Additional options include:
  9471. @table @code
  9472. @item --recursive
  9473. @itemx -r
  9474. Traverse the dependency graph of the given upstream package recursively
  9475. and generate package expressions for all those packages that are not yet
  9476. in Guix.
  9477. @item --repo
  9478. Select the given repository (a repository name). Possible values include:
  9479. @itemize
  9480. @item @code{opam}, the default opam repository,
  9481. @item @code{coq} or @code{coq-released}, the stable repository for coq packages,
  9482. @item @code{coq-core-dev}, the repository that contains development versions of coq,
  9483. @item @code{coq-extra-dev}, the repository that contains development versions
  9484. of coq packages.
  9485. @end itemize
  9486. @end table
  9487. @item go
  9488. @cindex go
  9489. Import metadata for a Go module using
  9490. @uref{https://proxy.golang.org, proxy.golang.org}.
  9491. @example
  9492. guix import go gopkg.in/yaml.v2
  9493. @end example
  9494. It is possible to use a package specification with a @code{@@VERSION}
  9495. suffix to import a specific version.
  9496. Additional options include:
  9497. @table @code
  9498. @item --recursive
  9499. @itemx -r
  9500. Traverse the dependency graph of the given upstream package recursively
  9501. and generate package expressions for all those packages that are not yet
  9502. in Guix.
  9503. @item --pin-versions
  9504. When using this option, the importer preserves the exact versions of the
  9505. Go modules dependencies instead of using their latest available
  9506. versions. This can be useful when attempting to import packages that
  9507. recursively depend on former versions of themselves to build. When
  9508. using this mode, the symbol of the package is made by appending the
  9509. version to its name, so that multiple versions of the same package can
  9510. coexist.
  9511. @end table
  9512. @end table
  9513. The structure of the @command{guix import} code is modular. It would be
  9514. useful to have more importers for other package formats, and your help
  9515. is welcome here (@pxref{Contributing}).
  9516. @node Invoking guix refresh
  9517. @section Invoking @command{guix refresh}
  9518. @cindex @command {guix refresh}
  9519. The primary audience of the @command{guix refresh} command is packagers.
  9520. As a user, you may be interested in the @option{--with-latest} option,
  9521. which can bring you package update superpowers built upon @command{guix
  9522. refresh} (@pxref{Package Transformation Options,
  9523. @option{--with-latest}}). By default, @command{guix refresh} reports
  9524. any packages provided by the distribution that are outdated compared to
  9525. the latest upstream version, like this:
  9526. @example
  9527. $ guix refresh
  9528. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  9529. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  9530. @end example
  9531. Alternatively, one can specify packages to consider, in which case a
  9532. warning is emitted for packages that lack an updater:
  9533. @example
  9534. $ guix refresh coreutils guile guile-ssh
  9535. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  9536. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  9537. @end example
  9538. @command{guix refresh} browses the upstream repository of each package and determines
  9539. the highest version number of the releases therein. The command
  9540. knows how to update specific types of packages: GNU packages, ELPA
  9541. packages, etc.---see the documentation for @option{--type} below. There
  9542. are many packages, though, for which it lacks a method to determine
  9543. whether a new upstream release is available. However, the mechanism is
  9544. extensible, so feel free to get in touch with us to add a new method!
  9545. @table @code
  9546. @item --recursive
  9547. Consider the packages specified, and all the packages upon which they depend.
  9548. @example
  9549. $ guix refresh --recursive coreutils
  9550. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  9551. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  9552. gnu/packages/xml.scm:68:2: warning: no updater for expat
  9553. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  9554. @dots{}
  9555. @end example
  9556. @end table
  9557. Sometimes the upstream name differs from the package name used in Guix,
  9558. and @command{guix refresh} needs a little help. Most updaters honor the
  9559. @code{upstream-name} property in package definitions, which can be used
  9560. to that effect:
  9561. @lisp
  9562. (define-public network-manager
  9563. (package
  9564. (name "network-manager")
  9565. ;; @dots{}
  9566. (properties '((upstream-name . "NetworkManager")))))
  9567. @end lisp
  9568. When passed @option{--update}, it modifies distribution source files to
  9569. update the version numbers and source tarball hashes of those package
  9570. recipes (@pxref{Defining Packages}). This is achieved by downloading
  9571. each package's latest source tarball and its associated OpenPGP
  9572. signature, authenticating the downloaded tarball against its signature
  9573. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  9574. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  9575. When the public
  9576. key used to sign the tarball is missing from the user's keyring, an
  9577. attempt is made to automatically retrieve it from a public key server;
  9578. when this is successful, the key is added to the user's keyring; otherwise,
  9579. @command{guix refresh} reports an error.
  9580. The following options are supported:
  9581. @table @code
  9582. @item --expression=@var{expr}
  9583. @itemx -e @var{expr}
  9584. Consider the package @var{expr} evaluates to.
  9585. This is useful to precisely refer to a package, as in this example:
  9586. @example
  9587. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  9588. @end example
  9589. This command lists the dependents of the ``final'' libc (essentially all
  9590. the packages).
  9591. @item --update
  9592. @itemx -u
  9593. Update distribution source files (package recipes) in place. This is
  9594. usually run from a checkout of the Guix source tree (@pxref{Running
  9595. Guix Before It Is Installed}):
  9596. @example
  9597. $ ./pre-inst-env guix refresh -s non-core -u
  9598. @end example
  9599. @xref{Defining Packages}, for more information on package definitions.
  9600. @item --select=[@var{subset}]
  9601. @itemx -s @var{subset}
  9602. Select all the packages in @var{subset}, one of @code{core} or
  9603. @code{non-core}.
  9604. The @code{core} subset refers to all the packages at the core of the
  9605. distribution---i.e., packages that are used to build ``everything
  9606. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  9607. changing one of these packages in the distribution entails a rebuild of
  9608. all the others. Thus, such updates are an inconvenience to users in
  9609. terms of build time or bandwidth used to achieve the upgrade.
  9610. The @code{non-core} subset refers to the remaining packages. It is
  9611. typically useful in cases where an update of the core packages would be
  9612. inconvenient.
  9613. @item --manifest=@var{file}
  9614. @itemx -m @var{file}
  9615. Select all the packages from the manifest in @var{file}. This is useful to
  9616. check if any packages of the user manifest can be updated.
  9617. @item --type=@var{updater}
  9618. @itemx -t @var{updater}
  9619. Select only packages handled by @var{updater} (may be a comma-separated
  9620. list of updaters). Currently, @var{updater} may be one of:
  9621. @table @code
  9622. @item gnu
  9623. the updater for GNU packages;
  9624. @item savannah
  9625. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  9626. @item sourceforge
  9627. the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
  9628. @item gnome
  9629. the updater for GNOME packages;
  9630. @item kde
  9631. the updater for KDE packages;
  9632. @item xorg
  9633. the updater for X.org packages;
  9634. @item kernel.org
  9635. the updater for packages hosted on kernel.org;
  9636. @item elpa
  9637. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  9638. @item cran
  9639. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  9640. @item bioconductor
  9641. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  9642. @item cpan
  9643. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  9644. @item pypi
  9645. the updater for @uref{https://pypi.python.org, PyPI} packages.
  9646. @item gem
  9647. the updater for @uref{https://rubygems.org, RubyGems} packages.
  9648. @item github
  9649. the updater for @uref{https://github.com, GitHub} packages.
  9650. @item hackage
  9651. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  9652. @item stackage
  9653. the updater for @uref{https://www.stackage.org, Stackage} packages.
  9654. @item crate
  9655. the updater for @uref{https://crates.io, Crates} packages.
  9656. @item launchpad
  9657. the updater for @uref{https://launchpad.net, Launchpad} packages.
  9658. @item generic-html
  9659. a generic updater that crawls the HTML page where the source tarball of
  9660. the package is hosted, when applicable.
  9661. @end table
  9662. For instance, the following command only checks for updates of Emacs
  9663. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  9664. @example
  9665. $ guix refresh --type=elpa,cran
  9666. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  9667. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  9668. @end example
  9669. @item --list-updaters
  9670. @itemx -L
  9671. List available updaters and exit (see @option{--type} above).
  9672. For each updater, display the fraction of packages it covers; at the
  9673. end, display the fraction of packages covered by all these updaters.
  9674. @end table
  9675. In addition, @command{guix refresh} can be passed one or more package
  9676. names, as in this example:
  9677. @example
  9678. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  9679. @end example
  9680. @noindent
  9681. The command above specifically updates the @code{emacs} and
  9682. @code{idutils} packages. The @option{--select} option would have no
  9683. effect in this case. You might also want to update definitions that
  9684. correspond to the packages installed in your profile:
  9685. @example
  9686. $ ./pre-inst-env guix refresh -u \
  9687. $(guix package --list-installed | cut -f1)
  9688. @end example
  9689. When considering whether to upgrade a package, it is sometimes
  9690. convenient to know which packages would be affected by the upgrade and
  9691. should be checked for compatibility. For this the following option may
  9692. be used when passing @command{guix refresh} one or more package names:
  9693. @table @code
  9694. @item --list-dependent
  9695. @itemx -l
  9696. List top-level dependent packages that would need to be rebuilt as a
  9697. result of upgrading one or more packages.
  9698. @xref{Invoking guix graph, the @code{reverse-package} type of
  9699. @command{guix graph}}, for information on how to visualize the list of
  9700. dependents of a package.
  9701. @end table
  9702. Be aware that the @option{--list-dependent} option only
  9703. @emph{approximates} the rebuilds that would be required as a result of
  9704. an upgrade. More rebuilds might be required under some circumstances.
  9705. @example
  9706. $ guix refresh --list-dependent flex
  9707. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  9708. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  9709. @end example
  9710. The command above lists a set of packages that could be built to check
  9711. for compatibility with an upgraded @code{flex} package.
  9712. @table @code
  9713. @item --list-transitive
  9714. List all the packages which one or more packages depend upon.
  9715. @example
  9716. $ guix refresh --list-transitive flex
  9717. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  9718. 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{}
  9719. @end example
  9720. @end table
  9721. The command above lists a set of packages which, when changed, would cause
  9722. @code{flex} to be rebuilt.
  9723. The following options can be used to customize GnuPG operation:
  9724. @table @code
  9725. @item --gpg=@var{command}
  9726. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  9727. for in @code{$PATH}.
  9728. @item --keyring=@var{file}
  9729. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  9730. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  9731. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  9732. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  9733. information on a tool to manipulate keybox files).
  9734. When this option is omitted, @command{guix refresh} uses
  9735. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  9736. signing keys. OpenPGP signatures are checked against keys from this keyring;
  9737. missing keys are downloaded to this keyring as well (see
  9738. @option{--key-download} below).
  9739. You can export keys from your default GPG keyring into a keybox file using
  9740. commands like this one:
  9741. @example
  9742. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  9743. @end example
  9744. Likewise, you can fetch keys to a specific keybox file like this:
  9745. @example
  9746. gpg --no-default-keyring --keyring mykeyring.kbx \
  9747. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  9748. @end example
  9749. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  9750. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  9751. @item --key-download=@var{policy}
  9752. Handle missing OpenPGP keys according to @var{policy}, which may be one
  9753. of:
  9754. @table @code
  9755. @item always
  9756. Always download missing OpenPGP keys from the key server, and add them
  9757. to the user's GnuPG keyring.
  9758. @item never
  9759. Never try to download missing OpenPGP keys. Instead just bail out.
  9760. @item interactive
  9761. When a package signed with an unknown OpenPGP key is encountered, ask
  9762. the user whether to download it or not. This is the default behavior.
  9763. @end table
  9764. @item --key-server=@var{host}
  9765. Use @var{host} as the OpenPGP key server when importing a public key.
  9766. @item --load-path=@var{directory}
  9767. Add @var{directory} to the front of the package module search path
  9768. (@pxref{Package Modules}).
  9769. This allows users to define their own packages and make them visible to
  9770. the command-line tools.
  9771. @end table
  9772. The @code{github} updater uses the
  9773. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  9774. releases. When used repeatedly e.g.@: when refreshing all packages,
  9775. GitHub will eventually refuse to answer any further API requests. By
  9776. default 60 API requests per hour are allowed, and a full refresh on all
  9777. GitHub packages in Guix requires more than this. Authentication with
  9778. GitHub through the use of an API token alleviates these limits. To use
  9779. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  9780. token procured from @uref{https://github.com/settings/tokens} or
  9781. otherwise.
  9782. @node Invoking guix lint
  9783. @section Invoking @command{guix lint}
  9784. @cindex @command{guix lint}
  9785. @cindex package, checking for errors
  9786. The @command{guix lint} command is meant to help package developers avoid
  9787. common errors and use a consistent style. It runs a number of checks on
  9788. a given set of packages in order to find common mistakes in their
  9789. definitions. Available @dfn{checkers} include (see
  9790. @option{--list-checkers} for a complete list):
  9791. @table @code
  9792. @item synopsis
  9793. @itemx description
  9794. Validate certain typographical and stylistic rules about package
  9795. descriptions and synopses.
  9796. @item inputs-should-be-native
  9797. Identify inputs that should most likely be native inputs.
  9798. @item source
  9799. @itemx home-page
  9800. @itemx mirror-url
  9801. @itemx github-url
  9802. @itemx source-file-name
  9803. Probe @code{home-page} and @code{source} URLs and report those that are
  9804. invalid. Suggest a @code{mirror://} URL when applicable. If the
  9805. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  9806. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  9807. version number or ``git-checkout'', without a declared @code{file-name}
  9808. (@pxref{origin Reference}).
  9809. @item source-unstable-tarball
  9810. Parse the @code{source} URL to determine if a tarball from GitHub is
  9811. autogenerated or if it is a release tarball. Unfortunately GitHub's
  9812. autogenerated tarballs are sometimes regenerated.
  9813. @item derivation
  9814. Check that the derivation of the given packages can be successfully
  9815. computed for all the supported systems (@pxref{Derivations}).
  9816. @item profile-collisions
  9817. Check whether installing the given packages in a profile would lead to
  9818. collisions. Collisions occur when several packages with the same name
  9819. but a different version or a different store file name are propagated.
  9820. @xref{package Reference, @code{propagated-inputs}}, for more information
  9821. on propagated inputs.
  9822. @item archival
  9823. @cindex Software Heritage, source code archive
  9824. @cindex archival of source code, Software Heritage
  9825. Checks whether the package's source code is archived at
  9826. @uref{https://www.softwareheritage.org, Software Heritage}.
  9827. When the source code that is not archived comes from a version-control system
  9828. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  9829. ``save'' request so that it eventually archives it. This ensures that the
  9830. source will remain available in the long term, and that Guix can fall back to
  9831. Software Heritage should the source code disappear from its original host.
  9832. The status of recent ``save'' requests can be
  9833. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  9834. When source code is a tarball obtained with @code{url-fetch}, simply print a
  9835. message when it is not archived. As of this writing, Software Heritage does
  9836. not allow requests to save arbitrary tarballs; we are working on ways to
  9837. ensure that non-VCS source code is also archived.
  9838. Software Heritage
  9839. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  9840. request rate per IP address}. When the limit is reached, @command{guix lint}
  9841. prints a message and the @code{archival} checker stops doing anything until
  9842. that limit has been reset.
  9843. @item cve
  9844. @cindex security vulnerabilities
  9845. @cindex CVE, Common Vulnerabilities and Exposures
  9846. Report known vulnerabilities found in the Common Vulnerabilities and
  9847. Exposures (CVE) databases of the current and past year
  9848. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  9849. NIST}.
  9850. To view information about a particular vulnerability, visit pages such as:
  9851. @itemize
  9852. @item
  9853. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  9854. @item
  9855. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  9856. @end itemize
  9857. @noindent
  9858. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  9859. @code{CVE-2015-7554}.
  9860. Package developers can specify in package recipes the
  9861. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  9862. name and version of the package when they differ from the name or version
  9863. that Guix uses, as in this example:
  9864. @lisp
  9865. (package
  9866. (name "grub")
  9867. ;; @dots{}
  9868. ;; CPE calls this package "grub2".
  9869. (properties '((cpe-name . "grub2")
  9870. (cpe-version . "2.3"))))
  9871. @end lisp
  9872. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  9873. Some entries in the CVE database do not specify which version of a
  9874. package they apply to, and would thus ``stick around'' forever. Package
  9875. developers who found CVE alerts and verified they can be ignored can
  9876. declare them as in this example:
  9877. @lisp
  9878. (package
  9879. (name "t1lib")
  9880. ;; @dots{}
  9881. ;; These CVEs no longer apply and can be safely ignored.
  9882. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  9883. "CVE-2011-1553"
  9884. "CVE-2011-1554"
  9885. "CVE-2011-5244")))))
  9886. @end lisp
  9887. @item formatting
  9888. Warn about obvious source code formatting issues: trailing white space,
  9889. use of tabulations, etc.
  9890. @end table
  9891. The general syntax is:
  9892. @example
  9893. guix lint @var{options} @var{package}@dots{}
  9894. @end example
  9895. If no package is given on the command line, then all packages are checked.
  9896. The @var{options} may be zero or more of the following:
  9897. @table @code
  9898. @item --list-checkers
  9899. @itemx -l
  9900. List and describe all the available checkers that will be run on packages
  9901. and exit.
  9902. @item --checkers
  9903. @itemx -c
  9904. Only enable the checkers specified in a comma-separated list using the
  9905. names returned by @option{--list-checkers}.
  9906. @item --exclude
  9907. @itemx -x
  9908. Only disable the checkers specified in a comma-separated list using the
  9909. names returned by @option{--list-checkers}.
  9910. @item --no-network
  9911. @itemx -n
  9912. Only enable the checkers that do not depend on Internet access.
  9913. @item --load-path=@var{directory}
  9914. @itemx -L @var{directory}
  9915. Add @var{directory} to the front of the package module search path
  9916. (@pxref{Package Modules}).
  9917. This allows users to define their own packages and make them visible to
  9918. the command-line tools.
  9919. @end table
  9920. @node Invoking guix size
  9921. @section Invoking @command{guix size}
  9922. @cindex size
  9923. @cindex package size
  9924. @cindex closure
  9925. @cindex @command{guix size}
  9926. The @command{guix size} command helps package developers profile the
  9927. disk usage of packages. It is easy to overlook the impact of an
  9928. additional dependency added to a package, or the impact of using a
  9929. single output for a package that could easily be split (@pxref{Packages
  9930. with Multiple Outputs}). Such are the typical issues that
  9931. @command{guix size} can highlight.
  9932. The command can be passed one or more package specifications
  9933. such as @code{gcc@@4.8}
  9934. or @code{guile:debug}, or a file name in the store. Consider this
  9935. example:
  9936. @example
  9937. $ guix size coreutils
  9938. store item total self
  9939. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  9940. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  9941. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  9942. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  9943. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  9944. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  9945. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  9946. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  9947. total: 78.9 MiB
  9948. @end example
  9949. @cindex closure
  9950. The store items listed here constitute the @dfn{transitive closure} of
  9951. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  9952. would be returned by:
  9953. @example
  9954. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  9955. @end example
  9956. Here the output shows three columns next to store items. The first column,
  9957. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  9958. the store item---that is, its own size plus the size of all its
  9959. dependencies. The next column, labeled ``self'', shows the size of the
  9960. item itself. The last column shows the ratio of the size of the item
  9961. itself to the space occupied by all the items listed here.
  9962. In this example, we see that the closure of Coreutils weighs in at
  9963. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  9964. libraries. (That libc and GCC's libraries represent a large fraction of
  9965. the closure is not a problem @i{per se} because they are always available
  9966. on the system anyway.)
  9967. Since the command also accepts store file names, assessing the size of
  9968. a build result is straightforward:
  9969. @example
  9970. guix size $(guix system build config.scm)
  9971. @end example
  9972. When the package(s) passed to @command{guix size} are available in the
  9973. store@footnote{More precisely, @command{guix size} looks for the
  9974. @emph{ungrafted} variant of the given package(s), as returned by
  9975. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  9976. for information on grafts.}, @command{guix size} queries the daemon to determine its
  9977. dependencies, and measures its size in the store, similar to @command{du
  9978. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  9979. Coreutils}).
  9980. When the given packages are @emph{not} in the store, @command{guix size}
  9981. reports information based on the available substitutes
  9982. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  9983. store items that are not even on disk, only available remotely.
  9984. You can also specify several package names:
  9985. @example
  9986. $ guix size coreutils grep sed bash
  9987. store item total self
  9988. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  9989. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  9990. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  9991. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  9992. @dots{}
  9993. total: 102.3 MiB
  9994. @end example
  9995. @noindent
  9996. In this example we see that the combination of the four packages takes
  9997. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  9998. since they have a lot of dependencies in common.
  9999. When looking at the profile returned by @command{guix size}, you may
  10000. find yourself wondering why a given package shows up in the profile at
  10001. all. To understand it, you can use @command{guix graph --path -t
  10002. references} to display the shortest path between the two packages
  10003. (@pxref{Invoking guix graph}).
  10004. The available options are:
  10005. @table @option
  10006. @item --substitute-urls=@var{urls}
  10007. Use substitute information from @var{urls}.
  10008. @xref{client-substitute-urls, the same option for @code{guix build}}.
  10009. @item --sort=@var{key}
  10010. Sort lines according to @var{key}, one of the following options:
  10011. @table @code
  10012. @item self
  10013. the size of each item (the default);
  10014. @item closure
  10015. the total size of the item's closure.
  10016. @end table
  10017. @item --map-file=@var{file}
  10018. Write a graphical map of disk usage in PNG format to @var{file}.
  10019. For the example above, the map looks like this:
  10020. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  10021. produced by @command{guix size}}
  10022. This option requires that
  10023. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  10024. installed and visible in Guile's module search path. When that is not
  10025. the case, @command{guix size} fails as it tries to load it.
  10026. @item --system=@var{system}
  10027. @itemx -s @var{system}
  10028. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  10029. @item --load-path=@var{directory}
  10030. @itemx -L @var{directory}
  10031. Add @var{directory} to the front of the package module search path
  10032. (@pxref{Package Modules}).
  10033. This allows users to define their own packages and make them visible to
  10034. the command-line tools.
  10035. @end table
  10036. @node Invoking guix graph
  10037. @section Invoking @command{guix graph}
  10038. @cindex DAG
  10039. @cindex @command{guix graph}
  10040. @cindex package dependencies
  10041. Packages and their dependencies form a @dfn{graph}, specifically a
  10042. directed acyclic graph (DAG). It can quickly become difficult to have a
  10043. mental model of the package DAG, so the @command{guix graph} command
  10044. provides a visual representation of the DAG@. By default,
  10045. @command{guix graph} emits a DAG representation in the input format of
  10046. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  10047. directly to the @command{dot} command of Graphviz. It can also emit an
  10048. HTML page with embedded JavaScript code to display a ``chord diagram''
  10049. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  10050. emit Cypher queries to construct a graph in a graph database supporting
  10051. the @uref{https://www.opencypher.org/, openCypher} query language. With
  10052. @option{--path}, it simply displays the shortest path between two
  10053. packages. The general syntax is:
  10054. @example
  10055. guix graph @var{options} @var{package}@dots{}
  10056. @end example
  10057. For example, the following command generates a PDF file representing the
  10058. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  10059. dependencies:
  10060. @example
  10061. guix graph coreutils | dot -Tpdf > dag.pdf
  10062. @end example
  10063. The output looks like this:
  10064. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  10065. Nice little graph, no?
  10066. You may find it more pleasant to navigate the graph interactively with
  10067. @command{xdot} (from the @code{xdot} package):
  10068. @example
  10069. guix graph coreutils | xdot -
  10070. @end example
  10071. But there is more than one graph! The one above is concise: it is the
  10072. graph of package objects, omitting implicit inputs such as GCC, libc,
  10073. grep, etc. It is often useful to have such a concise graph, but
  10074. sometimes one may want to see more details. @command{guix graph} supports
  10075. several types of graphs, allowing you to choose the level of detail:
  10076. @table @code
  10077. @item package
  10078. This is the default type used in the example above. It shows the DAG of
  10079. package objects, excluding implicit dependencies. It is concise, but
  10080. filters out many details.
  10081. @item reverse-package
  10082. This shows the @emph{reverse} DAG of packages. For example:
  10083. @example
  10084. guix graph --type=reverse-package ocaml
  10085. @end example
  10086. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  10087. you are also interested in cases where OCaml is an implicit dependency, see
  10088. @code{reverse-bag} below).
  10089. Note that for core packages this can yield huge graphs. If all you want
  10090. is to know the number of packages that depend on a given package, use
  10091. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  10092. @option{--list-dependent}}).
  10093. @item bag-emerged
  10094. This is the package DAG, @emph{including} implicit inputs.
  10095. For instance, the following command:
  10096. @example
  10097. guix graph --type=bag-emerged coreutils
  10098. @end example
  10099. ...@: yields this bigger graph:
  10100. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  10101. At the bottom of the graph, we see all the implicit inputs of
  10102. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  10103. Now, note that the dependencies of these implicit inputs---that is, the
  10104. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  10105. here, for conciseness.
  10106. @item bag
  10107. Similar to @code{bag-emerged}, but this time including all the bootstrap
  10108. dependencies.
  10109. @item bag-with-origins
  10110. Similar to @code{bag}, but also showing origins and their dependencies.
  10111. @item reverse-bag
  10112. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  10113. it also takes implicit dependencies into account. For example:
  10114. @example
  10115. guix graph -t reverse-bag dune
  10116. @end example
  10117. @noindent
  10118. ...@: yields the graph of all packages that depend on Dune, directly or
  10119. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  10120. @i{via} @code{dune-build-system}, this shows a large number of packages,
  10121. whereas @code{reverse-package} would show very few if any.
  10122. @item derivation
  10123. This is the most detailed representation: It shows the DAG of
  10124. derivations (@pxref{Derivations}) and plain store items. Compared to
  10125. the above representation, many additional nodes are visible, including
  10126. build scripts, patches, Guile modules, etc.
  10127. For this type of graph, it is also possible to pass a @file{.drv} file
  10128. name instead of a package name, as in:
  10129. @example
  10130. guix graph -t derivation $(guix system build -d my-config.scm)
  10131. @end example
  10132. @item module
  10133. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  10134. For example, the following command shows the graph for the package
  10135. module that defines the @code{guile} package:
  10136. @example
  10137. guix graph -t module guile | xdot -
  10138. @end example
  10139. @end table
  10140. All the types above correspond to @emph{build-time dependencies}. The
  10141. following graph type represents the @emph{run-time dependencies}:
  10142. @table @code
  10143. @item references
  10144. This is the graph of @dfn{references} of a package output, as returned
  10145. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  10146. If the given package output is not available in the store, @command{guix
  10147. graph} attempts to obtain dependency information from substitutes.
  10148. Here you can also pass a store file name instead of a package name. For
  10149. example, the command below produces the reference graph of your profile
  10150. (which can be big!):
  10151. @example
  10152. guix graph -t references $(readlink -f ~/.guix-profile)
  10153. @end example
  10154. @item referrers
  10155. This is the graph of the @dfn{referrers} of a store item, as returned by
  10156. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  10157. This relies exclusively on local information from your store. For
  10158. instance, let us suppose that the current Inkscape is available in 10
  10159. profiles on your machine; @command{guix graph -t referrers inkscape}
  10160. will show a graph rooted at Inkscape and with those 10 profiles linked
  10161. to it.
  10162. It can help determine what is preventing a store item from being garbage
  10163. collected.
  10164. @end table
  10165. @cindex shortest path, between packages
  10166. Often, the graph of the package you are interested in does not fit on
  10167. your screen, and anyway all you want to know is @emph{why} that package
  10168. actually depends on some seemingly unrelated package. The
  10169. @option{--path} option instructs @command{guix graph} to display the
  10170. shortest path between two packages (or derivations, or store items,
  10171. etc.):
  10172. @example
  10173. $ guix graph --path emacs libunistring
  10174. emacs@@26.3
  10175. mailutils@@3.9
  10176. libunistring@@0.9.10
  10177. $ guix graph --path -t derivation emacs libunistring
  10178. /gnu/store/@dots{}-emacs-26.3.drv
  10179. /gnu/store/@dots{}-mailutils-3.9.drv
  10180. /gnu/store/@dots{}-libunistring-0.9.10.drv
  10181. $ guix graph --path -t references emacs libunistring
  10182. /gnu/store/@dots{}-emacs-26.3
  10183. /gnu/store/@dots{}-libidn2-2.2.0
  10184. /gnu/store/@dots{}-libunistring-0.9.10
  10185. @end example
  10186. The available options are the following:
  10187. @table @option
  10188. @item --type=@var{type}
  10189. @itemx -t @var{type}
  10190. Produce a graph output of @var{type}, where @var{type} must be one of
  10191. the values listed above.
  10192. @item --list-types
  10193. List the supported graph types.
  10194. @item --backend=@var{backend}
  10195. @itemx -b @var{backend}
  10196. Produce a graph using the selected @var{backend}.
  10197. @item --list-backends
  10198. List the supported graph backends.
  10199. Currently, the available backends are Graphviz and d3.js.
  10200. @item --path
  10201. Display the shortest path between two nodes of the type specified by
  10202. @option{--type}. The example below shows the shortest path between
  10203. @code{libreoffice} and @code{llvm} according to the references of
  10204. @code{libreoffice}:
  10205. @example
  10206. $ guix graph --path -t references libreoffice llvm
  10207. /gnu/store/@dots{}-libreoffice-6.4.2.2
  10208. /gnu/store/@dots{}-libepoxy-1.5.4
  10209. /gnu/store/@dots{}-mesa-19.3.4
  10210. /gnu/store/@dots{}-llvm-9.0.1
  10211. @end example
  10212. @item --expression=@var{expr}
  10213. @itemx -e @var{expr}
  10214. Consider the package @var{expr} evaluates to.
  10215. This is useful to precisely refer to a package, as in this example:
  10216. @example
  10217. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  10218. @end example
  10219. @item --system=@var{system}
  10220. @itemx -s @var{system}
  10221. Display the graph for @var{system}---e.g., @code{i686-linux}.
  10222. The package dependency graph is largely architecture-independent, but there
  10223. are some architecture-dependent bits that this option allows you to visualize.
  10224. @item --load-path=@var{directory}
  10225. @itemx -L @var{directory}
  10226. Add @var{directory} to the front of the package module search path
  10227. (@pxref{Package Modules}).
  10228. This allows users to define their own packages and make them visible to
  10229. the command-line tools.
  10230. @end table
  10231. On top of that, @command{guix graph} supports all the usual package
  10232. transformation options (@pxref{Package Transformation Options}). This
  10233. makes it easy to view the effect of a graph-rewriting transformation
  10234. such as @option{--with-input}. For example, the command below outputs
  10235. the graph of @code{git} once @code{openssl} has been replaced by
  10236. @code{libressl} everywhere in the graph:
  10237. @example
  10238. guix graph git --with-input=openssl=libressl
  10239. @end example
  10240. So many possibilities, so much fun!
  10241. @node Invoking guix publish
  10242. @section Invoking @command{guix publish}
  10243. @cindex @command{guix publish}
  10244. The purpose of @command{guix publish} is to enable users to easily share
  10245. their store with others, who can then use it as a substitute server
  10246. (@pxref{Substitutes}).
  10247. When @command{guix publish} runs, it spawns an HTTP server which allows
  10248. anyone with network access to obtain substitutes from it. This means
  10249. that any machine running Guix can also act as if it were a build farm,
  10250. since the HTTP interface is compatible with Cuirass, the software behind
  10251. the @code{@value{SUBSTITUTE-SERVER}} build farm.
  10252. For security, each substitute is signed, allowing recipients to check
  10253. their authenticity and integrity (@pxref{Substitutes}). Because
  10254. @command{guix publish} uses the signing key of the system, which is only
  10255. readable by the system administrator, it must be started as root; the
  10256. @option{--user} option makes it drop root privileges early on.
  10257. The signing key pair must be generated before @command{guix publish} is
  10258. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  10259. guix archive}).
  10260. When the @option{--advertise} option is passed, the server advertises
  10261. its availability on the local network using multicast DNS (mDNS) and DNS
  10262. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  10263. guile-avahi, Using Avahi in Guile Scheme Programs}).
  10264. The general syntax is:
  10265. @example
  10266. guix publish @var{options}@dots{}
  10267. @end example
  10268. Running @command{guix publish} without any additional arguments will
  10269. spawn an HTTP server on port 8080:
  10270. @example
  10271. guix publish
  10272. @end example
  10273. Once a publishing server has been authorized, the daemon may download
  10274. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  10275. By default, @command{guix publish} compresses archives on the fly as it
  10276. serves them. This ``on-the-fly'' mode is convenient in that it requires
  10277. no setup and is immediately available. However, when serving lots of
  10278. clients, we recommend using the @option{--cache} option, which enables
  10279. caching of the archives before they are sent to clients---see below for
  10280. details. The @command{guix weather} command provides a handy way to
  10281. check what a server provides (@pxref{Invoking guix weather}).
  10282. As a bonus, @command{guix publish} also serves as a content-addressed
  10283. mirror for source files referenced in @code{origin} records
  10284. (@pxref{origin Reference}). For instance, assuming @command{guix
  10285. publish} is running on @code{example.org}, the following URL returns the
  10286. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  10287. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  10288. @example
  10289. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  10290. @end example
  10291. Obviously, these URLs only work for files that are in the store; in
  10292. other cases, they return 404 (``Not Found'').
  10293. @cindex build logs, publication
  10294. Build logs are available from @code{/log} URLs like:
  10295. @example
  10296. http://example.org/log/gwspk@dots{}-guile-2.2.3
  10297. @end example
  10298. @noindent
  10299. When @command{guix-daemon} is configured to save compressed build logs,
  10300. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  10301. URLs return the compressed log as-is, with an appropriate
  10302. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  10303. running @command{guix-daemon} with @option{--log-compression=gzip} since
  10304. Web browsers can automatically decompress it, which is not the case with
  10305. Bzip2 compression.
  10306. The following options are available:
  10307. @table @code
  10308. @item --port=@var{port}
  10309. @itemx -p @var{port}
  10310. Listen for HTTP requests on @var{port}.
  10311. @item --listen=@var{host}
  10312. Listen on the network interface for @var{host}. The default is to
  10313. accept connections from any interface.
  10314. @item --user=@var{user}
  10315. @itemx -u @var{user}
  10316. Change privileges to @var{user} as soon as possible---i.e., once the
  10317. server socket is open and the signing key has been read.
  10318. @item --compression[=@var{method}[:@var{level}]]
  10319. @itemx -C [@var{method}[:@var{level}]]
  10320. Compress data using the given @var{method} and @var{level}. @var{method} is
  10321. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  10322. omitted, @code{gzip} is used.
  10323. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  10324. to different compression levels: 1 is the fastest, and 9 is the best
  10325. (CPU-intensive). The default is 3.
  10326. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  10327. small increase in CPU usage; see
  10328. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  10329. Web page}. However, @code{lzip} achieves low decompression throughput
  10330. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  10331. bottleneck for someone who downloads over a fast network connection.
  10332. The compression ratio of @code{zstd} is between that of @code{lzip} and
  10333. that of @code{gzip}; its main advantage is a
  10334. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  10335. Unless @option{--cache} is used, compression occurs on the fly and
  10336. the compressed streams are not
  10337. cached. Thus, to reduce load on the machine that runs @command{guix
  10338. publish}, it may be a good idea to choose a low compression level, to
  10339. run @command{guix publish} behind a caching proxy, or to use
  10340. @option{--cache}. Using @option{--cache} has the advantage that it
  10341. allows @command{guix publish} to add @code{Content-Length} HTTP header
  10342. to its responses.
  10343. This option can be repeated, in which case every substitute gets compressed
  10344. using all the selected methods, and all of them are advertised. This is
  10345. useful when users may not support all the compression methods: they can select
  10346. the one they support.
  10347. @item --cache=@var{directory}
  10348. @itemx -c @var{directory}
  10349. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  10350. and only serve archives that are in cache.
  10351. When this option is omitted, archives and meta-data are created
  10352. on-the-fly. This can reduce the available bandwidth, especially when
  10353. compression is enabled, since this may become CPU-bound. Another
  10354. drawback of the default mode is that the length of archives is not known
  10355. in advance, so @command{guix publish} does not add a
  10356. @code{Content-Length} HTTP header to its responses, which in turn
  10357. prevents clients from knowing the amount of data being downloaded.
  10358. Conversely, when @option{--cache} is used, the first request for a store
  10359. item (@i{via} a @code{.narinfo} URL) triggers a
  10360. background process to @dfn{bake} the archive---computing its
  10361. @code{.narinfo} and compressing the archive, if needed. Once the
  10362. archive is cached in @var{directory}, subsequent requests succeed and
  10363. are served directly from the cache, which guarantees that clients get
  10364. the best possible bandwidth.
  10365. That first @code{.narinfo} request nonetheless returns 200, provided the
  10366. requested store item is ``small enough'', below the cache bypass
  10367. threshold---see @option{--cache-bypass-threshold} below. That way,
  10368. clients do not have to wait until the archive is baked. For larger
  10369. store items, the first @code{.narinfo} request returns 404, meaning that
  10370. clients have to wait until the archive is baked.
  10371. The ``baking'' process is performed by worker threads. By default, one
  10372. thread per CPU core is created, but this can be customized. See
  10373. @option{--workers} below.
  10374. When @option{--ttl} is used, cached entries are automatically deleted
  10375. when they have expired.
  10376. @item --workers=@var{N}
  10377. When @option{--cache} is used, request the allocation of @var{N} worker
  10378. threads to ``bake'' archives.
  10379. @item --ttl=@var{ttl}
  10380. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  10381. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  10382. days, @code{1m} means 1 month, and so on.
  10383. This allows the user's Guix to keep substitute information in cache for
  10384. @var{ttl}. However, note that @code{guix publish} does not itself
  10385. guarantee that the store items it provides will indeed remain available
  10386. for as long as @var{ttl}.
  10387. Additionally, when @option{--cache} is used, cached entries that have
  10388. not been accessed for @var{ttl} and that no longer have a corresponding
  10389. item in the store, may be deleted.
  10390. @item --cache-bypass-threshold=@var{size}
  10391. When used in conjunction with @option{--cache}, store items smaller than
  10392. @var{size} are immediately available, even when they are not yet in
  10393. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  10394. for megabytes and so on. The default is @code{10M}.
  10395. ``Cache bypass'' allows you to reduce the publication delay for clients
  10396. at the expense of possibly additional I/O and CPU use on the server
  10397. side: depending on the client access patterns, those store items can end
  10398. up being baked several times until a copy is available in cache.
  10399. Increasing the threshold may be useful for sites that have few users, or
  10400. to guarantee that users get substitutes even for store items that are
  10401. not popular.
  10402. @item --nar-path=@var{path}
  10403. Use @var{path} as the prefix for the URLs of ``nar'' files
  10404. (@pxref{Invoking guix archive, normalized archives}).
  10405. By default, nars are served at a URL such as
  10406. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  10407. change the @code{/nar} part to @var{path}.
  10408. @item --public-key=@var{file}
  10409. @itemx --private-key=@var{file}
  10410. Use the specific @var{file}s as the public/private key pair used to sign
  10411. the store items being published.
  10412. The files must correspond to the same key pair (the private key is used
  10413. for signing and the public key is merely advertised in the signature
  10414. metadata). They must contain keys in the canonical s-expression format
  10415. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  10416. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  10417. @file{/etc/guix/signing-key.sec} are used.
  10418. @item --repl[=@var{port}]
  10419. @itemx -r [@var{port}]
  10420. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  10421. Reference Manual}) on @var{port} (37146 by default). This is used
  10422. primarily for debugging a running @command{guix publish} server.
  10423. @end table
  10424. Enabling @command{guix publish} on Guix System is a one-liner: just
  10425. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  10426. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  10427. @code{guix-publish-service-type}}).
  10428. If you are instead running Guix on a ``foreign distro'', follow these
  10429. instructions:
  10430. @itemize
  10431. @item
  10432. If your host distro uses the systemd init system:
  10433. @example
  10434. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  10435. /etc/systemd/system/
  10436. # systemctl start guix-publish && systemctl enable guix-publish
  10437. @end example
  10438. @item
  10439. If your host distro uses the Upstart init system:
  10440. @example
  10441. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  10442. # start guix-publish
  10443. @end example
  10444. @item
  10445. Otherwise, proceed similarly with your distro's init system.
  10446. @end itemize
  10447. @node Invoking guix challenge
  10448. @section Invoking @command{guix challenge}
  10449. @cindex reproducible builds
  10450. @cindex verifiable builds
  10451. @cindex @command{guix challenge}
  10452. @cindex challenge
  10453. Do the binaries provided by this server really correspond to the source
  10454. code it claims to build? Is a package build process deterministic?
  10455. These are the questions the @command{guix challenge} command attempts to
  10456. answer.
  10457. The former is obviously an important question: Before using a substitute
  10458. server (@pxref{Substitutes}), one had better @emph{verify} that it
  10459. provides the right binaries, and thus @emph{challenge} it. The latter
  10460. is what enables the former: If package builds are deterministic, then
  10461. independent builds of the package should yield the exact same result,
  10462. bit for bit; if a server provides a binary different from the one
  10463. obtained locally, it may be either corrupt or malicious.
  10464. We know that the hash that shows up in @file{/gnu/store} file names is
  10465. the hash of all the inputs of the process that built the file or
  10466. directory---compilers, libraries, build scripts,
  10467. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  10468. one store file name should map to exactly one build output.
  10469. @command{guix challenge} checks whether there is, indeed, a single
  10470. mapping by comparing the build outputs of several independent builds of
  10471. any given store item.
  10472. The command output looks like this:
  10473. @smallexample
  10474. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10475. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
  10476. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10477. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  10478. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10479. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10480. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  10481. differing files:
  10482. /lib/libcrypto.so.1.1
  10483. /lib/libssl.so.1.1
  10484. /gnu/store/@dots{}-git-2.5.0 contents differ:
  10485. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  10486. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  10487. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  10488. differing file:
  10489. /libexec/git-core/git-fsck
  10490. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  10491. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10492. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10493. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  10494. differing file:
  10495. /share/man/man1/pius.1.gz
  10496. @dots{}
  10497. 6,406 store items were analyzed:
  10498. - 4,749 (74.1%) were identical
  10499. - 525 (8.2%) differed
  10500. - 1,132 (17.7%) were inconclusive
  10501. @end smallexample
  10502. @noindent
  10503. In this example, @command{guix challenge} first scans the store to
  10504. determine the set of locally-built derivations---as opposed to store
  10505. items that were downloaded from a substitute server---and then queries
  10506. all the substitute servers. It then reports those store items for which
  10507. the servers obtained a result different from the local build.
  10508. @cindex non-determinism, in package builds
  10509. As an example, @code{guix.example.org} always gets a different answer.
  10510. Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
  10511. case of Git. This might indicate that the build process of Git is
  10512. non-deterministic, meaning that its output varies as a function of
  10513. various things that Guix does not fully control, in spite of building
  10514. packages in isolated environments (@pxref{Features}). Most common
  10515. sources of non-determinism include the addition of timestamps in build
  10516. results, the inclusion of random numbers, and directory listings sorted
  10517. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  10518. more information.
  10519. To find out what is wrong with this Git binary, the easiest approach is
  10520. to run:
  10521. @example
  10522. guix challenge git \
  10523. --diff=diffoscope \
  10524. --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10525. @end example
  10526. This automatically invokes @command{diffoscope}, which displays detailed
  10527. information about files that differ.
  10528. Alternatively, we can do something along these lines (@pxref{Invoking guix
  10529. archive}):
  10530. @example
  10531. $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-git-2.5.0 \
  10532. | lzip -d | guix archive -x /tmp/git
  10533. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  10534. @end example
  10535. This command shows the difference between the files resulting from the
  10536. local build, and the files resulting from the build on
  10537. @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
  10538. diffutils, Comparing and Merging Files}). The @command{diff} command
  10539. works great for text files. When binary files differ, a better option
  10540. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  10541. visualize differences for all kinds of files.
  10542. Once you have done that work, you can tell whether the differences are due
  10543. to a non-deterministic build process or to a malicious server. We try
  10544. hard to remove sources of non-determinism in packages to make it easier
  10545. to verify substitutes, but of course, this is a process that
  10546. involves not just Guix, but a large part of the free software community.
  10547. In the meantime, @command{guix challenge} is one tool to help address
  10548. the problem.
  10549. If you are writing packages for Guix, you are encouraged to check
  10550. whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
  10551. same build result as you did with:
  10552. @example
  10553. $ guix challenge @var{package}
  10554. @end example
  10555. @noindent
  10556. where @var{package} is a package specification such as
  10557. @code{guile@@2.0} or @code{glibc:debug}.
  10558. The general syntax is:
  10559. @example
  10560. guix challenge @var{options} [@var{packages}@dots{}]
  10561. @end example
  10562. When a difference is found between the hash of a locally-built item and
  10563. that of a server-provided substitute, or among substitutes provided by
  10564. different servers, the command displays it as in the example above and
  10565. its exit code is 2 (other non-zero exit codes denote other kinds of
  10566. errors).
  10567. The one option that matters is:
  10568. @table @code
  10569. @item --substitute-urls=@var{urls}
  10570. Consider @var{urls} the whitespace-separated list of substitute source
  10571. URLs to compare to.
  10572. @item --diff=@var{mode}
  10573. Upon mismatches, show differences according to @var{mode}, one of:
  10574. @table @asis
  10575. @item @code{simple} (the default)
  10576. Show the list of files that differ.
  10577. @item @code{diffoscope}
  10578. @itemx @var{command}
  10579. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  10580. two directories whose contents do not match.
  10581. When @var{command} is an absolute file name, run @var{command} instead
  10582. of Diffoscope.
  10583. @item @code{none}
  10584. Do not show further details about the differences.
  10585. @end table
  10586. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  10587. downloads the store items from the given substitute servers so that it
  10588. can compare them.
  10589. @item --verbose
  10590. @itemx -v
  10591. Show details about matches (identical contents) in addition to
  10592. information about mismatches.
  10593. @end table
  10594. @node Invoking guix copy
  10595. @section Invoking @command{guix copy}
  10596. @cindex copy, of store items, over SSH
  10597. @cindex SSH, copy of store items
  10598. @cindex sharing store items across machines
  10599. @cindex transferring store items across machines
  10600. The @command{guix copy} command copies items from the store of one
  10601. machine to that of another machine over a secure shell (SSH)
  10602. connection@footnote{This command is available only when Guile-SSH was
  10603. found. @xref{Requirements}, for details.}. For example, the following
  10604. command copies the @code{coreutils} package, the user's profile, and all
  10605. their dependencies over to @var{host}, logged in as @var{user}:
  10606. @example
  10607. guix copy --to=@var{user}@@@var{host} \
  10608. coreutils $(readlink -f ~/.guix-profile)
  10609. @end example
  10610. If some of the items to be copied are already present on @var{host},
  10611. they are not actually sent.
  10612. The command below retrieves @code{libreoffice} and @code{gimp} from
  10613. @var{host}, assuming they are available there:
  10614. @example
  10615. guix copy --from=@var{host} libreoffice gimp
  10616. @end example
  10617. The SSH connection is established using the Guile-SSH client, which is
  10618. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  10619. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  10620. The key used to sign items that are sent must be accepted by the remote
  10621. machine. Likewise, the key used by the remote machine to sign items you
  10622. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  10623. own daemon. @xref{Invoking guix archive}, for more information about
  10624. store item authentication.
  10625. The general syntax is:
  10626. @example
  10627. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  10628. @end example
  10629. You must always specify one of the following options:
  10630. @table @code
  10631. @item --to=@var{spec}
  10632. @itemx --from=@var{spec}
  10633. Specify the host to send to or receive from. @var{spec} must be an SSH
  10634. spec such as @code{example.org}, @code{charlie@@example.org}, or
  10635. @code{charlie@@example.org:2222}.
  10636. @end table
  10637. The @var{items} can be either package names, such as @code{gimp}, or
  10638. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  10639. When specifying the name of a package to send, it is first built if
  10640. needed, unless @option{--dry-run} was specified. Common build options
  10641. are supported (@pxref{Common Build Options}).
  10642. @node Invoking guix container
  10643. @section Invoking @command{guix container}
  10644. @cindex container
  10645. @cindex @command{guix container}
  10646. @quotation Note
  10647. As of version @value{VERSION}, this tool is experimental. The interface
  10648. is subject to radical change in the future.
  10649. @end quotation
  10650. The purpose of @command{guix container} is to manipulate processes
  10651. running within an isolated environment, commonly known as a
  10652. ``container'', typically created by the @command{guix environment}
  10653. (@pxref{Invoking guix environment}) and @command{guix system container}
  10654. (@pxref{Invoking guix system}) commands.
  10655. The general syntax is:
  10656. @example
  10657. guix container @var{action} @var{options}@dots{}
  10658. @end example
  10659. @var{action} specifies the operation to perform with a container, and
  10660. @var{options} specifies the context-specific arguments for the action.
  10661. The following actions are available:
  10662. @table @code
  10663. @item exec
  10664. Execute a command within the context of a running container.
  10665. The syntax is:
  10666. @example
  10667. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  10668. @end example
  10669. @var{pid} specifies the process ID of the running container.
  10670. @var{program} specifies an executable file name within the root file
  10671. system of the container. @var{arguments} are the additional options that
  10672. will be passed to @var{program}.
  10673. The following command launches an interactive login shell inside a
  10674. Guix system container, started by @command{guix system container}, and whose
  10675. process ID is 9001:
  10676. @example
  10677. guix container exec 9001 /run/current-system/profile/bin/bash --login
  10678. @end example
  10679. Note that the @var{pid} cannot be the parent process of a container. It
  10680. must be PID 1 of the container or one of its child processes.
  10681. @end table
  10682. @node Invoking guix weather
  10683. @section Invoking @command{guix weather}
  10684. Occasionally you're grumpy because substitutes are lacking and you end
  10685. up building packages by yourself (@pxref{Substitutes}). The
  10686. @command{guix weather} command reports on substitute availability on the
  10687. specified servers so you can have an idea of whether you'll be grumpy
  10688. today. It can sometimes be useful info as a user, but it is primarily
  10689. useful to people running @command{guix publish} (@pxref{Invoking guix
  10690. publish}).
  10691. @cindex statistics, for substitutes
  10692. @cindex availability of substitutes
  10693. @cindex substitute availability
  10694. @cindex weather, substitute availability
  10695. Here's a sample run:
  10696. @example
  10697. $ guix weather --substitute-urls=https://guix.example.org
  10698. computing 5,872 package derivations for x86_64-linux...
  10699. looking for 6,128 store items on https://guix.example.org..
  10700. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10701. https://guix.example.org
  10702. 43.4% substitutes available (2,658 out of 6,128)
  10703. 7,032.5 MiB of nars (compressed)
  10704. 19,824.2 MiB on disk (uncompressed)
  10705. 0.030 seconds per request (182.9 seconds in total)
  10706. 33.5 requests per second
  10707. 9.8% (342 out of 3,470) of the missing items are queued
  10708. 867 queued builds
  10709. x86_64-linux: 518 (59.7%)
  10710. i686-linux: 221 (25.5%)
  10711. aarch64-linux: 128 (14.8%)
  10712. build rate: 23.41 builds per hour
  10713. x86_64-linux: 11.16 builds per hour
  10714. i686-linux: 6.03 builds per hour
  10715. aarch64-linux: 6.41 builds per hour
  10716. @end example
  10717. @cindex continuous integration, statistics
  10718. As you can see, it reports the fraction of all the packages for which
  10719. substitutes are available on the server---regardless of whether
  10720. substitutes are enabled, and regardless of whether this server's signing
  10721. key is authorized. It also reports the size of the compressed archives
  10722. (``nars'') provided by the server, the size the corresponding store
  10723. items occupy in the store (assuming deduplication is turned off), and
  10724. the server's throughput. The second part gives continuous integration
  10725. (CI) statistics, if the server supports it. In addition, using the
  10726. @option{--coverage} option, @command{guix weather} can list ``important''
  10727. package substitutes missing on the server (see below).
  10728. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  10729. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  10730. challenge}, it ignores signatures on those substitutes, which is
  10731. innocuous since the command only gathers statistics and cannot install
  10732. those substitutes.
  10733. The general syntax is:
  10734. @example
  10735. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  10736. @end example
  10737. When @var{packages} is omitted, @command{guix weather} checks the availability
  10738. of substitutes for @emph{all} the packages, or for those specified with
  10739. @option{--manifest}; otherwise it only considers the specified packages. It
  10740. is also possible to query specific system types with @option{--system}.
  10741. @command{guix weather} exits with a non-zero code when the fraction of
  10742. available substitutes is below 100%.
  10743. The available options are listed below.
  10744. @table @code
  10745. @item --substitute-urls=@var{urls}
  10746. @var{urls} is the space-separated list of substitute server URLs to
  10747. query. When this option is omitted, the default set of substitute
  10748. servers is queried.
  10749. @item --system=@var{system}
  10750. @itemx -s @var{system}
  10751. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  10752. option can be repeated, in which case @command{guix weather} will query
  10753. substitutes for several system types.
  10754. @item --manifest=@var{file}
  10755. Instead of querying substitutes for all the packages, only ask for those
  10756. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  10757. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  10758. guix package}).
  10759. This option can be repeated several times, in which case the manifests
  10760. are concatenated.
  10761. @item --coverage[=@var{count}]
  10762. @itemx -c [@var{count}]
  10763. Report on substitute coverage for packages: list packages with at least
  10764. @var{count} dependents (zero by default) for which substitutes are
  10765. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  10766. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  10767. @var{b} usually lacks substitutes as well. The result looks like this:
  10768. @example
  10769. $ guix weather --substitute-urls=@value{SUBSTITUTE-URL} -c 10
  10770. computing 8,983 package derivations for x86_64-linux...
  10771. looking for 9,343 store items on @value{SUBSTITUTE-URL}...
  10772. updating substitutes from '@value{SUBSTITUTE-URL}'... 100.0%
  10773. @value{SUBSTITUTE-URL}
  10774. 64.7% substitutes available (6,047 out of 9,343)
  10775. @dots{}
  10776. 2502 packages are missing from '@value{SUBSTITUTE-URL}' for 'x86_64-linux', among which:
  10777. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  10778. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  10779. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  10780. @dots{}
  10781. @end example
  10782. What this example shows is that @code{kcoreaddons} and presumably the 58
  10783. packages that depend on it have no substitutes at
  10784. @code{@value{SUBSTITUTE-SERVER}}; likewise for @code{qgpgme} and the 46
  10785. packages that depend on it.
  10786. If you are a Guix developer, or if you are taking care of this build farm,
  10787. you'll probably want to have a closer look at these packages: they may simply
  10788. fail to build.
  10789. @item --display-missing
  10790. Display the list of store items for which substitutes are missing.
  10791. @end table
  10792. @node Invoking guix processes
  10793. @section Invoking @command{guix processes}
  10794. The @command{guix processes} command can be useful to developers and system
  10795. administrators, especially on multi-user machines and on build farms: it lists
  10796. the current sessions (connections to the daemon), as well as information about
  10797. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  10798. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  10799. listed.}. Here's an example of the information it returns:
  10800. @example
  10801. $ sudo guix processes
  10802. SessionPID: 19002
  10803. ClientPID: 19090
  10804. ClientCommand: guix environment --ad-hoc python
  10805. SessionPID: 19402
  10806. ClientPID: 19367
  10807. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  10808. SessionPID: 19444
  10809. ClientPID: 19419
  10810. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10811. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  10812. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  10813. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  10814. ChildPID: 20495
  10815. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10816. ChildPID: 27733
  10817. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10818. ChildPID: 27793
  10819. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10820. @end example
  10821. In this example we see that @command{guix-daemon} has three clients:
  10822. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  10823. integration tool; their process identifier (PID) is given by the
  10824. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  10825. @command{guix-daemon} sub-process of this particular session.
  10826. The @code{LockHeld} fields show which store items are currently locked
  10827. by this session, which corresponds to store items being built or
  10828. substituted (the @code{LockHeld} field is not displayed when
  10829. @command{guix processes} is not running as root). Last, by looking at
  10830. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  10831. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  10832. The output is in Recutils format so we can use the handy @command{recsel}
  10833. command to select sessions of interest (@pxref{Selection Expressions,,,
  10834. recutils, GNU recutils manual}). As an example, the command shows the command
  10835. line and PID of the client that triggered the build of a Perl package:
  10836. @example
  10837. $ sudo guix processes | \
  10838. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  10839. ClientPID: 19419
  10840. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10841. @end example
  10842. Additional options are listed below.
  10843. @table @code
  10844. @item --format=@var{format}
  10845. @itemx -f @var{format}
  10846. Produce output in the specified @var{format}, one of:
  10847. @table @code
  10848. @item recutils
  10849. The default option. It outputs a set of Session recutils records
  10850. that include each @code{ChildProcess} as a field.
  10851. @item normalized
  10852. Normalize the output records into record sets (@pxref{Record Sets,,,
  10853. recutils, GNU recutils manual}). Normalizing into record sets allows
  10854. joins across record types. The example below lists the PID of each
  10855. @code{ChildProcess} and the associated PID for @code{Session} that
  10856. spawned the @code{ChildProcess} where the @code{Session} was started
  10857. using @command{guix build}.
  10858. @example
  10859. $ guix processes --format=normalized | \
  10860. recsel \
  10861. -j Session \
  10862. -t ChildProcess \
  10863. -p Session.PID,PID \
  10864. -e 'Session.ClientCommand ~ "guix build"'
  10865. PID: 4435
  10866. Session_PID: 4278
  10867. PID: 4554
  10868. Session_PID: 4278
  10869. PID: 4646
  10870. Session_PID: 4278
  10871. @end example
  10872. @end table
  10873. @end table
  10874. @node System Configuration
  10875. @chapter System Configuration
  10876. @cindex system configuration
  10877. Guix System supports a consistent whole-system configuration
  10878. mechanism. By that we mean that all aspects of the global system
  10879. configuration---such as the available system services, timezone and
  10880. locale settings, user accounts---are declared in a single place. Such
  10881. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  10882. One of the advantages of putting all the system configuration under the
  10883. control of Guix is that it supports transactional system upgrades, and
  10884. makes it possible to roll back to a previous system instantiation,
  10885. should something go wrong with the new one (@pxref{Features}). Another
  10886. advantage is that it makes it easy to replicate the exact same configuration
  10887. across different machines, or at different points in time, without
  10888. having to resort to additional administration tools layered on top of
  10889. the own tools of the system.
  10890. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  10891. This section describes this mechanism. First we focus on the system
  10892. administrator's viewpoint---explaining how the system is configured and
  10893. instantiated. Then we show how this mechanism can be extended, for
  10894. instance to support new system services.
  10895. @menu
  10896. * Using the Configuration System:: Customizing your GNU system.
  10897. * operating-system Reference:: Detail of operating-system declarations.
  10898. * File Systems:: Configuring file system mounts.
  10899. * Mapped Devices:: Block device extra processing.
  10900. * User Accounts:: Specifying user accounts.
  10901. * Keyboard Layout:: How the system interprets key strokes.
  10902. * Locales:: Language and cultural convention settings.
  10903. * Services:: Specifying system services.
  10904. * Setuid Programs:: Programs running with root privileges.
  10905. * X.509 Certificates:: Authenticating HTTPS servers.
  10906. * Name Service Switch:: Configuring libc's name service switch.
  10907. * Initial RAM Disk:: Linux-Libre bootstrapping.
  10908. * Bootloader Configuration:: Configuring the boot loader.
  10909. * Invoking guix system:: Instantiating a system configuration.
  10910. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  10911. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  10912. * Defining Services:: Adding new service definitions.
  10913. @end menu
  10914. @node Using the Configuration System
  10915. @section Using the Configuration System
  10916. The operating system is configured by providing an
  10917. @code{operating-system} declaration in a file that can then be passed to
  10918. the @command{guix system} command (@pxref{Invoking guix system}). A
  10919. simple setup, with the default system services, the default Linux-Libre
  10920. kernel, initial RAM disk, and boot loader looks like this:
  10921. @findex operating-system
  10922. @lisp
  10923. @include os-config-bare-bones.texi
  10924. @end lisp
  10925. This example should be self-describing. Some of the fields defined
  10926. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  10927. Others, such as @code{packages} and @code{services}, can be omitted, in
  10928. which case they get a default value.
  10929. Below we discuss the effect of some of the most important fields
  10930. (@pxref{operating-system Reference}, for details about all the available
  10931. fields), and how to @dfn{instantiate} the operating system using
  10932. @command{guix system}.
  10933. @unnumberedsubsec Bootloader
  10934. @cindex legacy boot, on Intel machines
  10935. @cindex BIOS boot, on Intel machines
  10936. @cindex UEFI boot
  10937. @cindex EFI boot
  10938. The @code{bootloader} field describes the method that will be used to boot
  10939. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  10940. mode, as in the example above. However, more recent machines rely instead on
  10941. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  10942. the @code{bootloader} field should contain something along these lines:
  10943. @lisp
  10944. (bootloader-configuration
  10945. (bootloader grub-efi-bootloader)
  10946. (target "/boot/efi"))
  10947. @end lisp
  10948. @xref{Bootloader Configuration}, for more information on the available
  10949. configuration options.
  10950. @unnumberedsubsec Globally-Visible Packages
  10951. @vindex %base-packages
  10952. The @code{packages} field lists packages that will be globally visible
  10953. on the system, for all user accounts---i.e., in every user's @env{PATH}
  10954. environment variable---in addition to the per-user profiles
  10955. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  10956. provides all the tools one would expect for basic user and administrator
  10957. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  10958. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  10959. etc. The example above adds GNU@tie{}Screen to those,
  10960. taken from the @code{(gnu packages screen)}
  10961. module (@pxref{Package Modules}). The
  10962. @code{(list package output)} syntax can be used to add a specific output
  10963. of a package:
  10964. @lisp
  10965. (use-modules (gnu packages))
  10966. (use-modules (gnu packages dns))
  10967. (operating-system
  10968. ;; ...
  10969. (packages (cons (list bind "utils")
  10970. %base-packages)))
  10971. @end lisp
  10972. @findex specification->package
  10973. Referring to packages by variable name, like @code{bind} above, has
  10974. the advantage of being unambiguous; it also allows typos and such to be
  10975. diagnosed right away as ``unbound variables''. The downside is that one
  10976. needs to know which module defines which package, and to augment the
  10977. @code{use-package-modules} line accordingly. To avoid that, one can use
  10978. the @code{specification->package} procedure of the @code{(gnu packages)}
  10979. module, which returns the best package for a given name or name and
  10980. version:
  10981. @lisp
  10982. (use-modules (gnu packages))
  10983. (operating-system
  10984. ;; ...
  10985. (packages (append (map specification->package
  10986. '("tcpdump" "htop" "gnupg@@2.0"))
  10987. %base-packages)))
  10988. @end lisp
  10989. @unnumberedsubsec System Services
  10990. @cindex services
  10991. @vindex %base-services
  10992. The @code{services} field lists @dfn{system services} to be made
  10993. available when the system starts (@pxref{Services}).
  10994. The @code{operating-system} declaration above specifies that, in
  10995. addition to the basic services, we want the OpenSSH secure shell
  10996. daemon listening on port 2222 (@pxref{Networking Services,
  10997. @code{openssh-service-type}}). Under the hood,
  10998. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  10999. right command-line options, possibly with supporting configuration files
  11000. generated as needed (@pxref{Defining Services}).
  11001. @cindex customization, of services
  11002. @findex modify-services
  11003. Occasionally, instead of using the base services as is, you will want to
  11004. customize them. To do this, use @code{modify-services} (@pxref{Service
  11005. Reference, @code{modify-services}}) to modify the list.
  11006. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  11007. (the console log-in) in the @code{%base-services} list (@pxref{Base
  11008. Services, @code{%base-services}}). To do that, you can write the
  11009. following in your operating system declaration:
  11010. @lisp
  11011. (define %my-services
  11012. ;; My very own list of services.
  11013. (modify-services %base-services
  11014. (guix-service-type config =>
  11015. (guix-configuration
  11016. (inherit config)
  11017. ;; Fetch substitutes from example.org.
  11018. (substitute-urls
  11019. (list "https://example.org/guix"
  11020. "https://ci.guix.gnu.org"))))
  11021. (mingetty-service-type config =>
  11022. (mingetty-configuration
  11023. (inherit config)
  11024. ;; Automatially log in as "guest".
  11025. (auto-login "guest")))))
  11026. (operating-system
  11027. ;; @dots{}
  11028. (services %my-services))
  11029. @end lisp
  11030. This changes the configuration---i.e., the service parameters---of the
  11031. @code{guix-service-type} instance, and that of all the
  11032. @code{mingetty-service-type} instances in the @code{%base-services} list.
  11033. Observe how this is accomplished: first, we arrange for the original
  11034. configuration to be bound to the identifier @code{config} in the
  11035. @var{body}, and then we write the @var{body} so that it evaluates to the
  11036. desired configuration. In particular, notice how we use @code{inherit}
  11037. to create a new configuration which has the same values as the old
  11038. configuration, but with a few modifications.
  11039. @cindex encrypted disk
  11040. The configuration for a typical ``desktop'' usage, with an encrypted
  11041. root partition, the X11 display
  11042. server, GNOME and Xfce (users can choose which of these desktop
  11043. environments to use at the log-in screen by pressing @kbd{F1}), network
  11044. management, power management, and more, would look like this:
  11045. @lisp
  11046. @include os-config-desktop.texi
  11047. @end lisp
  11048. A graphical system with a choice of lightweight window managers
  11049. instead of full-blown desktop environments would look like this:
  11050. @lisp
  11051. @include os-config-lightweight-desktop.texi
  11052. @end lisp
  11053. This example refers to the @file{/boot/efi} file system by its UUID,
  11054. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  11055. as returned by the @command{blkid} command.
  11056. @xref{Desktop Services}, for the exact list of services provided by
  11057. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  11058. information about the @code{nss-certs} package that is used here.
  11059. Again, @code{%desktop-services} is just a list of service objects. If
  11060. you want to remove services from there, you can do so using the
  11061. procedures for list filtering (@pxref{SRFI-1 Filtering and
  11062. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  11063. following expression returns a list that contains all the services in
  11064. @code{%desktop-services} minus the Avahi service:
  11065. @lisp
  11066. (remove (lambda (service)
  11067. (eq? (service-kind service) avahi-service-type))
  11068. %desktop-services)
  11069. @end lisp
  11070. Alternatively, the @code{modify-services} macro can be used:
  11071. @lisp
  11072. (modify-services %desktop-services
  11073. (delete avahi-service-type))
  11074. @end lisp
  11075. @unnumberedsubsec Instantiating the System
  11076. Assuming the @code{operating-system} declaration
  11077. is stored in the @file{my-system-config.scm}
  11078. file, the @command{guix system reconfigure my-system-config.scm} command
  11079. instantiates that configuration, and makes it the default GRUB boot
  11080. entry (@pxref{Invoking guix system}).
  11081. The normal way to change the system configuration is by updating this
  11082. file and re-running @command{guix system reconfigure}. One should never
  11083. have to touch files in @file{/etc} or to run commands that modify the
  11084. system state such as @command{useradd} or @command{grub-install}. In
  11085. fact, you must avoid that since that would not only void your warranty
  11086. but also prevent you from rolling back to previous versions of your
  11087. system, should you ever need to.
  11088. @cindex roll-back, of the operating system
  11089. Speaking of roll-back, each time you run @command{guix system
  11090. reconfigure}, a new @dfn{generation} of the system is created---without
  11091. modifying or deleting previous generations. Old system generations get
  11092. an entry in the bootloader boot menu, allowing you to boot them in case
  11093. something went wrong with the latest generation. Reassuring, no? The
  11094. @command{guix system list-generations} command lists the system
  11095. generations available on disk. It is also possible to roll back the
  11096. system via the commands @command{guix system roll-back} and
  11097. @command{guix system switch-generation}.
  11098. Although the @command{guix system reconfigure} command will not modify
  11099. previous generations, you must take care when the current generation is not
  11100. the latest (e.g., after invoking @command{guix system roll-back}), since
  11101. the operation might overwrite a later generation (@pxref{Invoking guix
  11102. system}).
  11103. @unnumberedsubsec The Programming Interface
  11104. At the Scheme level, the bulk of an @code{operating-system} declaration
  11105. is instantiated with the following monadic procedure (@pxref{The Store
  11106. Monad}):
  11107. @deffn {Monadic Procedure} operating-system-derivation os
  11108. Return a derivation that builds @var{os}, an @code{operating-system}
  11109. object (@pxref{Derivations}).
  11110. The output of the derivation is a single directory that refers to all
  11111. the packages, configuration files, and other supporting files needed to
  11112. instantiate @var{os}.
  11113. @end deffn
  11114. This procedure is provided by the @code{(gnu system)} module. Along
  11115. with @code{(gnu services)} (@pxref{Services}), this module contains the
  11116. guts of Guix System. Make sure to visit it!
  11117. @node operating-system Reference
  11118. @section @code{operating-system} Reference
  11119. This section summarizes all the options available in
  11120. @code{operating-system} declarations (@pxref{Using the Configuration
  11121. System}).
  11122. @deftp {Data Type} operating-system
  11123. This is the data type representing an operating system configuration.
  11124. By that, we mean all the global system configuration, not per-user
  11125. configuration (@pxref{Using the Configuration System}).
  11126. @table @asis
  11127. @item @code{kernel} (default: @code{linux-libre})
  11128. The package object of the operating system kernel to
  11129. use@footnote{Currently only the Linux-libre kernel is fully supported.
  11130. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  11131. available when building a virtual machine disk image.}.
  11132. @cindex hurd
  11133. @item @code{hurd} (default: @code{#f})
  11134. The package object of the Hurd to be started by the kernel. When this
  11135. field is set, produce a GNU/Hurd operating system. In that case,
  11136. @code{kernel} must also be set to the @code{gnumach} package---the
  11137. microkernel the Hurd runs on.
  11138. @quotation Warning
  11139. This feature is experimental and only supported for disk images.
  11140. @end quotation
  11141. @item @code{kernel-loadable-modules} (default: '())
  11142. A list of objects (usually packages) to collect loadable kernel modules
  11143. from--e.g. @code{(list ddcci-driver-linux)}.
  11144. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  11145. List of strings or gexps representing additional arguments to pass on
  11146. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  11147. @item @code{bootloader}
  11148. The system bootloader configuration object. @xref{Bootloader Configuration}.
  11149. @item @code{label}
  11150. This is the label (a string) as it appears in the bootloader's menu entry.
  11151. The default label includes the kernel name and version.
  11152. @item @code{keyboard-layout} (default: @code{#f})
  11153. This field specifies the keyboard layout to use in the console. It can be
  11154. either @code{#f}, in which case the default keyboard layout is used (usually
  11155. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  11156. for more information.
  11157. This keyboard layout is in effect as soon as the kernel has booted. For
  11158. instance, it is the keyboard layout in effect when you type a passphrase if
  11159. your root file system is on a @code{luks-device-mapping} mapped device
  11160. (@pxref{Mapped Devices}).
  11161. @quotation Note
  11162. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  11163. that used by the graphical display server. @xref{Bootloader Configuration},
  11164. for information on how to specify the bootloader's keyboard layout. @xref{X
  11165. Window}, for information on how to specify the keyboard layout used by the X
  11166. Window System.
  11167. @end quotation
  11168. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  11169. @cindex initrd
  11170. @cindex initial RAM disk
  11171. The list of Linux kernel modules that need to be available in the
  11172. initial RAM disk. @xref{Initial RAM Disk}.
  11173. @item @code{initrd} (default: @code{base-initrd})
  11174. A procedure that returns an initial RAM disk for the Linux
  11175. kernel. This field is provided to support low-level customization and
  11176. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  11177. @item @code{firmware} (default: @code{%base-firmware})
  11178. @cindex firmware
  11179. List of firmware packages loadable by the operating system kernel.
  11180. The default includes firmware needed for Atheros- and Broadcom-based
  11181. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  11182. respectively). @xref{Hardware Considerations}, for more info on
  11183. supported hardware.
  11184. @item @code{host-name}
  11185. The host name.
  11186. @item @code{hosts-file}
  11187. @cindex hosts file
  11188. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  11189. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  11190. Reference Manual}). The default is a file with entries for
  11191. @code{localhost} and @var{host-name}.
  11192. @item @code{mapped-devices} (default: @code{'()})
  11193. A list of mapped devices. @xref{Mapped Devices}.
  11194. @item @code{file-systems}
  11195. A list of file systems. @xref{File Systems}.
  11196. @cindex swap devices
  11197. @cindex swap space
  11198. @item @code{swap-devices} (default: @code{'()})
  11199. A list of UUIDs, file system labels, or strings identifying devices or
  11200. files to be used for ``swap
  11201. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  11202. Manual}). Here are some examples:
  11203. @table @code
  11204. @item (list (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))
  11205. Use the swap partition with the given UUID@. You can learn the UUID of a
  11206. Linux swap partition by running @command{swaplabel @var{device}}, where
  11207. @var{device} is the @file{/dev} file name of that partition.
  11208. @item (list (file-system-label "swap"))
  11209. Use the partition with label @code{swap}. Again, the
  11210. @command{swaplabel} command allows you to view and change the label of a
  11211. Linux swap partition.
  11212. @item (list "/swapfile")
  11213. Use the file @file{/swapfile} as swap space.
  11214. @item (list "/dev/sda3" "/dev/sdb2")
  11215. Use the @file{/dev/sda3} and @file{/dev/sdb2} partitions as swap space.
  11216. We recommend referring to swap devices by UUIDs or labels as shown above
  11217. instead.
  11218. @end table
  11219. It is possible to specify a swap file in a file system on a mapped
  11220. device (under @file{/dev/mapper}), provided that the necessary device
  11221. mapping and file system are also specified. @xref{Mapped Devices} and
  11222. @ref{File Systems}.
  11223. @item @code{users} (default: @code{%base-user-accounts})
  11224. @itemx @code{groups} (default: @code{%base-groups})
  11225. List of user accounts and groups. @xref{User Accounts}.
  11226. If the @code{users} list lacks a user account with UID@tie{}0, a
  11227. ``root'' account with UID@tie{}0 is automatically added.
  11228. @item @code{skeletons} (default: @code{(default-skeletons)})
  11229. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  11230. file-like objects}). These are the skeleton files that will be added to
  11231. the home directory of newly-created user accounts.
  11232. For instance, a valid value may look like this:
  11233. @lisp
  11234. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  11235. (".guile" ,(plain-file "guile"
  11236. "(use-modules (ice-9 readline))
  11237. (activate-readline)")))
  11238. @end lisp
  11239. @item @code{issue} (default: @code{%default-issue})
  11240. A string denoting the contents of the @file{/etc/issue} file, which is
  11241. displayed when users log in on a text console.
  11242. @item @code{packages} (default: @code{%base-packages})
  11243. A list of packages to be installed in the global profile, which is accessible
  11244. at @file{/run/current-system/profile}. Each element is either a package
  11245. variable or a package/output tuple. Here's a simple example of both:
  11246. @lisp
  11247. (cons* git ; the default "out" output
  11248. (list git "send-email") ; another output of git
  11249. %base-packages) ; the default set
  11250. @end lisp
  11251. The default set includes core utilities and it is good practice to
  11252. install non-core utilities in user profiles (@pxref{Invoking guix
  11253. package}).
  11254. @item @code{timezone}
  11255. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  11256. You can run the @command{tzselect} command to find out which timezone
  11257. string corresponds to your region. Choosing an invalid timezone name
  11258. causes @command{guix system} to fail.
  11259. @item @code{locale} (default: @code{"en_US.utf8"})
  11260. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  11261. Library Reference Manual}). @xref{Locales}, for more information.
  11262. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  11263. The list of locale definitions to be compiled and that may be used at
  11264. run time. @xref{Locales}.
  11265. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  11266. The list of GNU@tie{}libc packages whose locale data and tools are used
  11267. to build the locale definitions. @xref{Locales}, for compatibility
  11268. considerations that justify this option.
  11269. @item @code{name-service-switch} (default: @code{%default-nss})
  11270. Configuration of the libc name service switch (NSS)---a
  11271. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  11272. details.
  11273. @item @code{services} (default: @code{%base-services})
  11274. A list of service objects denoting system services. @xref{Services}.
  11275. @cindex essential services
  11276. @item @code{essential-services} (default: ...)
  11277. The list of ``essential services''---i.e., things like instances of
  11278. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  11279. Reference}), which are derived from the operating system definition itself.
  11280. As a user you should @emph{never} need to touch this field.
  11281. @item @code{pam-services} (default: @code{(base-pam-services)})
  11282. @cindex PAM
  11283. @cindex pluggable authentication modules
  11284. Linux @dfn{pluggable authentication module} (PAM) services.
  11285. @c FIXME: Add xref to PAM services section.
  11286. @item @code{setuid-programs} (default: @code{%setuid-programs})
  11287. List of string-valued G-expressions denoting setuid programs.
  11288. @xref{Setuid Programs}.
  11289. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  11290. @cindex sudoers file
  11291. The contents of the @file{/etc/sudoers} file as a file-like object
  11292. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  11293. This file specifies which users can use the @command{sudo} command, what
  11294. they are allowed to do, and what privileges they may gain. The default
  11295. is that only @code{root} and members of the @code{wheel} group may use
  11296. @code{sudo}.
  11297. @end table
  11298. @deffn {Scheme Syntax} this-operating-system
  11299. When used in the @emph{lexical scope} of an operating system field definition,
  11300. this identifier resolves to the operating system being defined.
  11301. The example below shows how to refer to the operating system being defined in
  11302. the definition of the @code{label} field:
  11303. @lisp
  11304. (use-modules (gnu) (guix))
  11305. (operating-system
  11306. ;; ...
  11307. (label (package-full-name
  11308. (operating-system-kernel this-operating-system))))
  11309. @end lisp
  11310. It is an error to refer to @code{this-operating-system} outside an operating
  11311. system definition.
  11312. @end deffn
  11313. @end deftp
  11314. @node File Systems
  11315. @section File Systems
  11316. The list of file systems to be mounted is specified in the
  11317. @code{file-systems} field of the operating system declaration
  11318. (@pxref{Using the Configuration System}). Each file system is declared
  11319. using the @code{file-system} form, like this:
  11320. @lisp
  11321. (file-system
  11322. (mount-point "/home")
  11323. (device "/dev/sda3")
  11324. (type "ext4"))
  11325. @end lisp
  11326. As usual, some of the fields are mandatory---those shown in the example
  11327. above---while others can be omitted. These are described below.
  11328. @deftp {Data Type} file-system
  11329. Objects of this type represent file systems to be mounted. They
  11330. contain the following members:
  11331. @table @asis
  11332. @item @code{type}
  11333. This is a string specifying the type of the file system---e.g.,
  11334. @code{"ext4"}.
  11335. @item @code{mount-point}
  11336. This designates the place where the file system is to be mounted.
  11337. @item @code{device}
  11338. This names the ``source'' of the file system. It can be one of three
  11339. things: a file system label, a file system UUID, or the name of a
  11340. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  11341. systems without having to hard-code their actual device
  11342. name@footnote{Note that, while it is tempting to use
  11343. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  11344. result, this is not recommended: These special device nodes are created
  11345. by the udev daemon and may be unavailable at the time the device is
  11346. mounted.}.
  11347. @findex file-system-label
  11348. File system labels are created using the @code{file-system-label}
  11349. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  11350. plain strings. Here's an example of a file system referred to by its
  11351. label, as shown by the @command{e2label} command:
  11352. @lisp
  11353. (file-system
  11354. (mount-point "/home")
  11355. (type "ext4")
  11356. (device (file-system-label "my-home")))
  11357. @end lisp
  11358. @findex uuid
  11359. UUIDs are converted from their string representation (as shown by the
  11360. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  11361. @code{uuid} form expects 16-byte UUIDs as defined in
  11362. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  11363. form of UUID used by the ext2 family of file systems and others, but it
  11364. is different from ``UUIDs'' found in FAT file systems, for instance.},
  11365. like this:
  11366. @lisp
  11367. (file-system
  11368. (mount-point "/home")
  11369. (type "ext4")
  11370. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  11371. @end lisp
  11372. When the source of a file system is a mapped device (@pxref{Mapped
  11373. Devices}), its @code{device} field @emph{must} refer to the mapped
  11374. device name---e.g., @file{"/dev/mapper/root-partition"}.
  11375. This is required so that
  11376. the system knows that mounting the file system depends on having the
  11377. corresponding device mapping established.
  11378. @item @code{flags} (default: @code{'()})
  11379. This is a list of symbols denoting mount flags. Recognized flags
  11380. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  11381. access to special files), @code{no-suid} (ignore setuid and setgid
  11382. bits), @code{no-atime} (do not update file access times),
  11383. @code{strict-atime} (update file access time), @code{lazy-time} (only
  11384. update time on the in-memory version of the file inode), and
  11385. @code{no-exec} (disallow program execution).
  11386. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  11387. Manual}, for more information on these flags.
  11388. @item @code{options} (default: @code{#f})
  11389. This is either @code{#f}, or a string denoting mount options passed to
  11390. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  11391. Library Reference Manual}, for details and run @command{man 8 mount} for
  11392. options for various file systems. Note that the
  11393. @code{file-system-options->alist} and @code{alist->file-system-options}
  11394. procedures from @code{(gnu system file-systems)} can be used to convert
  11395. file system options given as an association list to the string
  11396. representation, and vice-versa.
  11397. @item @code{mount?} (default: @code{#t})
  11398. This value indicates whether to automatically mount the file system when
  11399. the system is brought up. When set to @code{#f}, the file system gets
  11400. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  11401. is not automatically mounted.
  11402. @item @code{needed-for-boot?} (default: @code{#f})
  11403. This Boolean value indicates whether the file system is needed when
  11404. booting. If that is true, then the file system is mounted when the
  11405. initial RAM disk (initrd) is loaded. This is always the case, for
  11406. instance, for the root file system.
  11407. @item @code{check?} (default: @code{#t})
  11408. This Boolean indicates whether the file system needs to be checked for
  11409. errors before being mounted.
  11410. @item @code{create-mount-point?} (default: @code{#f})
  11411. When true, the mount point is created if it does not exist yet.
  11412. @item @code{mount-may-fail?} (default: @code{#f})
  11413. When true, this indicates that mounting this file system can fail but
  11414. that should not be considered an error. This is useful in unusual
  11415. cases; an example of this is @code{efivarfs}, a file system that can
  11416. only be mounted on EFI/UEFI systems.
  11417. @item @code{dependencies} (default: @code{'()})
  11418. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  11419. representing file systems that must be mounted or mapped devices that
  11420. must be opened before (and unmounted or closed after) this one.
  11421. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  11422. a dependency of @file{/sys/fs/cgroup/cpu} and
  11423. @file{/sys/fs/cgroup/memory}.
  11424. Another example is a file system that depends on a mapped device, for
  11425. example for an encrypted partition (@pxref{Mapped Devices}).
  11426. @end table
  11427. @end deftp
  11428. @deffn {Scheme Procedure} file-system-label @var{str}
  11429. This procedure returns an opaque file system label from @var{str}, a
  11430. string:
  11431. @lisp
  11432. (file-system-label "home")
  11433. @result{} #<file-system-label "home">
  11434. @end lisp
  11435. File system labels are used to refer to file systems by label rather
  11436. than by device name. See above for examples.
  11437. @end deffn
  11438. The @code{(gnu system file-systems)} exports the following useful
  11439. variables.
  11440. @defvr {Scheme Variable} %base-file-systems
  11441. These are essential file systems that are required on normal systems,
  11442. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  11443. below). Operating system declarations should always contain at least
  11444. these.
  11445. @end defvr
  11446. @defvr {Scheme Variable} %pseudo-terminal-file-system
  11447. This is the file system to be mounted as @file{/dev/pts}. It supports
  11448. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  11449. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  11450. Manual}). Pseudo-terminals are used by terminal emulators such as
  11451. @command{xterm}.
  11452. @end defvr
  11453. @defvr {Scheme Variable} %shared-memory-file-system
  11454. This file system is mounted as @file{/dev/shm} and is used to support
  11455. memory sharing across processes (@pxref{Memory-mapped I/O,
  11456. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  11457. @end defvr
  11458. @defvr {Scheme Variable} %immutable-store
  11459. This file system performs a read-only ``bind mount'' of
  11460. @file{/gnu/store}, making it read-only for all the users including
  11461. @code{root}. This prevents against accidental modification by software
  11462. running as @code{root} or by system administrators.
  11463. The daemon itself is still able to write to the store: it remounts it
  11464. read-write in its own ``name space.''
  11465. @end defvr
  11466. @defvr {Scheme Variable} %binary-format-file-system
  11467. The @code{binfmt_misc} file system, which allows handling of arbitrary
  11468. executable file types to be delegated to user space. This requires the
  11469. @code{binfmt.ko} kernel module to be loaded.
  11470. @end defvr
  11471. @defvr {Scheme Variable} %fuse-control-file-system
  11472. The @code{fusectl} file system, which allows unprivileged users to mount
  11473. and unmount user-space FUSE file systems. This requires the
  11474. @code{fuse.ko} kernel module to be loaded.
  11475. @end defvr
  11476. The @code{(gnu system uuid)} module provides tools to deal with file
  11477. system ``unique identifiers'' (UUIDs).
  11478. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  11479. Return an opaque UUID (unique identifier) object of the given @var{type}
  11480. (a symbol) by parsing @var{str} (a string):
  11481. @lisp
  11482. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  11483. @result{} #<<uuid> type: dce bv: @dots{}>
  11484. (uuid "1234-ABCD" 'fat)
  11485. @result{} #<<uuid> type: fat bv: @dots{}>
  11486. @end lisp
  11487. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  11488. @code{ntfs}, or one of the commonly found synonyms for these.
  11489. UUIDs are another way to unambiguously refer to file systems in
  11490. operating system configuration. See the examples above.
  11491. @end deffn
  11492. @node Btrfs file system
  11493. @subsection Btrfs file system
  11494. The Btrfs has special features, such as subvolumes, that merit being
  11495. explained in more details. The following section attempts to cover
  11496. basic as well as complex uses of a Btrfs file system with the Guix
  11497. System.
  11498. In its simplest usage, a Btrfs file system can be described, for
  11499. example, by:
  11500. @lisp
  11501. (file-system
  11502. (mount-point "/home")
  11503. (type "btrfs")
  11504. (device (file-system-label "my-home")))
  11505. @end lisp
  11506. The example below is more complex, as it makes use of a Btrfs
  11507. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  11508. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  11509. dependency on @code{mapped-devices}):
  11510. @lisp
  11511. (file-system
  11512. (device (file-system-label "my-btrfs-pool"))
  11513. (mount-point "/")
  11514. (type "btrfs")
  11515. (options "subvol=rootfs")
  11516. (dependencies mapped-devices))
  11517. @end lisp
  11518. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  11519. top level during the early boot, and rely on their configuration to
  11520. refer to the correct subvolume path within that top level. The
  11521. bootloaders operating in this way typically produce their configuration
  11522. on a running system where the Btrfs partitions are already mounted and
  11523. where the subvolume information is readily available. As an example,
  11524. @command{grub-mkconfig}, the configuration generator command shipped
  11525. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  11526. path of a subvolume.
  11527. The Guix System produces a bootloader configuration using the operating
  11528. system configuration as its sole input; it is therefore necessary to
  11529. extract the subvolume name on which @file{/gnu/store} lives (if any)
  11530. from that operating system configuration. To better illustrate,
  11531. consider a subvolume named 'rootfs' which contains the root file system
  11532. data. In such situation, the GRUB bootloader would only see the top
  11533. level of the root Btrfs partition, e.g.:
  11534. @example
  11535. / (top level)
  11536. ├── rootfs (subvolume directory)
  11537. ├── gnu (normal directory)
  11538. ├── store (normal directory)
  11539. [...]
  11540. @end example
  11541. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  11542. of the kernel, initrd binaries and any other files referred to in the
  11543. GRUB configuration that must be found during the early boot.
  11544. The next example shows a nested hierarchy of subvolumes and
  11545. directories:
  11546. @example
  11547. / (top level)
  11548. ├── rootfs (subvolume)
  11549. ├── gnu (normal directory)
  11550. ├── store (subvolume)
  11551. [...]
  11552. @end example
  11553. This scenario would work without mounting the 'store' subvolume.
  11554. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  11555. intended mount point in the file system hierarchy. Alternatively, the
  11556. 'store' subvolume could be referred to by setting the @code{subvol}
  11557. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  11558. Finally, a more contrived example of nested subvolumes:
  11559. @example
  11560. / (top level)
  11561. ├── root-snapshots (subvolume)
  11562. ├── root-current (subvolume)
  11563. ├── guix-store (subvolume)
  11564. [...]
  11565. @end example
  11566. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  11567. so it is necessary to mount it. The subvolume must be fully specified,
  11568. by passing its file name to the @code{subvol} option. To illustrate,
  11569. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  11570. a file system declaration such as:
  11571. @lisp
  11572. (file-system
  11573. (device (file-system-label "btrfs-pool-1"))
  11574. (mount-point "/gnu/store")
  11575. (type "btrfs")
  11576. (options "subvol=root-snapshots/root-current/guix-store,\
  11577. compress-force=zstd,space_cache=v2"))
  11578. @end lisp
  11579. @node Mapped Devices
  11580. @section Mapped Devices
  11581. @cindex device mapping
  11582. @cindex mapped devices
  11583. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  11584. such as a hard disk partition, can be @dfn{mapped} into another device,
  11585. usually in @code{/dev/mapper/},
  11586. with additional processing over the data that flows through
  11587. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  11588. concept of a ``mapped device'' and that of a file system: both boil down
  11589. to @emph{translating} input/output operations made on a file to
  11590. operations on its backing store. Thus, the Hurd implements mapped
  11591. devices, like file systems, using the generic @dfn{translator} mechanism
  11592. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  11593. typical example is encryption device mapping: all writes to the mapped
  11594. device are encrypted, and all reads are deciphered, transparently.
  11595. Guix extends this notion by considering any device or set of devices that
  11596. are @dfn{transformed} in some way to create a new device; for instance,
  11597. RAID devices are obtained by @dfn{assembling} several other devices, such
  11598. as hard disks or partitions, into a new one that behaves as one partition.
  11599. Mapped devices are declared using the @code{mapped-device} form,
  11600. defined as follows; for examples, see below.
  11601. @deftp {Data Type} mapped-device
  11602. Objects of this type represent device mappings that will be made when
  11603. the system boots up.
  11604. @table @code
  11605. @item source
  11606. This is either a string specifying the name of the block device to be mapped,
  11607. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  11608. need to be assembled for creating a new one. In case of LVM this is a
  11609. string specifying name of the volume group to be mapped.
  11610. @item target
  11611. This string specifies the name of the resulting mapped device. For
  11612. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  11613. specifying @code{"my-partition"} leads to the creation of
  11614. the @code{"/dev/mapper/my-partition"} device.
  11615. For RAID devices of type @code{raid-device-mapping}, the full device name
  11616. such as @code{"/dev/md0"} needs to be given.
  11617. LVM logical volumes of type @code{lvm-device-mapping} need to
  11618. be specified as @code{"VGNAME-LVNAME"}.
  11619. @item targets
  11620. This list of strings specifies names of the resulting mapped devices in case
  11621. there are several. The format is identical to @var{target}.
  11622. @item type
  11623. This must be a @code{mapped-device-kind} object, which specifies how
  11624. @var{source} is mapped to @var{target}.
  11625. @end table
  11626. @end deftp
  11627. @defvr {Scheme Variable} luks-device-mapping
  11628. This defines LUKS block device encryption using the @command{cryptsetup}
  11629. command from the package with the same name. It relies on the
  11630. @code{dm-crypt} Linux kernel module.
  11631. @end defvr
  11632. @defvr {Scheme Variable} raid-device-mapping
  11633. This defines a RAID device, which is assembled using the @code{mdadm}
  11634. command from the package with the same name. It requires a Linux kernel
  11635. module for the appropriate RAID level to be loaded, such as @code{raid456}
  11636. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  11637. @end defvr
  11638. @cindex LVM, logical volume manager
  11639. @defvr {Scheme Variable} lvm-device-mapping
  11640. This defines one or more logical volumes for the Linux
  11641. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  11642. The volume group is activated by the @command{vgchange} command from the
  11643. @code{lvm2} package.
  11644. @end defvr
  11645. @cindex disk encryption
  11646. @cindex LUKS
  11647. The following example specifies a mapping from @file{/dev/sda3} to
  11648. @file{/dev/mapper/home} using LUKS---the
  11649. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  11650. standard mechanism for disk encryption.
  11651. The @file{/dev/mapper/home}
  11652. device can then be used as the @code{device} of a @code{file-system}
  11653. declaration (@pxref{File Systems}).
  11654. @lisp
  11655. (mapped-device
  11656. (source "/dev/sda3")
  11657. (target "home")
  11658. (type luks-device-mapping))
  11659. @end lisp
  11660. Alternatively, to become independent of device numbering, one may obtain
  11661. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  11662. command like:
  11663. @example
  11664. cryptsetup luksUUID /dev/sda3
  11665. @end example
  11666. and use it as follows:
  11667. @lisp
  11668. (mapped-device
  11669. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  11670. (target "home")
  11671. (type luks-device-mapping))
  11672. @end lisp
  11673. @cindex swap encryption
  11674. It is also desirable to encrypt swap space, since swap space may contain
  11675. sensitive data. One way to accomplish that is to use a swap file in a
  11676. file system on a device mapped via LUKS encryption. In this way, the
  11677. swap file is encrypted because the entire device is encrypted.
  11678. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  11679. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  11680. may be declared as follows:
  11681. @lisp
  11682. (mapped-device
  11683. (source (list "/dev/sda1" "/dev/sdb1"))
  11684. (target "/dev/md0")
  11685. (type raid-device-mapping))
  11686. @end lisp
  11687. The @file{/dev/md0} device can then be used as the @code{device} of a
  11688. @code{file-system} declaration (@pxref{File Systems}).
  11689. Note that the RAID level need not be given; it is chosen during the
  11690. initial creation and formatting of the RAID device and is determined
  11691. automatically later.
  11692. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  11693. be declared as follows:
  11694. @lisp
  11695. (mapped-device
  11696. (source "vg0")
  11697. (targets (list "vg0-alpha" "vg0-beta"))
  11698. (type lvm-device-mapping))
  11699. @end lisp
  11700. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  11701. then be used as the @code{device} of a @code{file-system} declaration
  11702. (@pxref{File Systems}).
  11703. @node User Accounts
  11704. @section User Accounts
  11705. @cindex users
  11706. @cindex accounts
  11707. @cindex user accounts
  11708. User accounts and groups are entirely managed through the
  11709. @code{operating-system} declaration. They are specified with the
  11710. @code{user-account} and @code{user-group} forms:
  11711. @lisp
  11712. (user-account
  11713. (name "alice")
  11714. (group "users")
  11715. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  11716. "audio" ;sound card
  11717. "video" ;video devices such as webcams
  11718. "cdrom")) ;the good ol' CD-ROM
  11719. (comment "Bob's sister"))
  11720. @end lisp
  11721. Here's a user account that uses a different shell and a custom home
  11722. directory (the default would be @file{"/home/bob"}):
  11723. @lisp
  11724. (user-account
  11725. (name "bob")
  11726. (group "users")
  11727. (comment "Alice's bro")
  11728. (shell (file-append zsh "/bin/zsh"))
  11729. (home-directory "/home/robert"))
  11730. @end lisp
  11731. When booting or upon completion of @command{guix system reconfigure},
  11732. the system ensures that only the user accounts and groups specified in
  11733. the @code{operating-system} declaration exist, and with the specified
  11734. properties. Thus, account or group creations or modifications made by
  11735. directly invoking commands such as @command{useradd} are lost upon
  11736. reconfiguration or reboot. This ensures that the system remains exactly
  11737. as declared.
  11738. @deftp {Data Type} user-account
  11739. Objects of this type represent user accounts. The following members may
  11740. be specified:
  11741. @table @asis
  11742. @item @code{name}
  11743. The name of the user account.
  11744. @item @code{group}
  11745. @cindex groups
  11746. This is the name (a string) or identifier (a number) of the user group
  11747. this account belongs to.
  11748. @item @code{supplementary-groups} (default: @code{'()})
  11749. Optionally, this can be defined as a list of group names that this
  11750. account belongs to.
  11751. @item @code{uid} (default: @code{#f})
  11752. This is the user ID for this account (a number), or @code{#f}. In the
  11753. latter case, a number is automatically chosen by the system when the
  11754. account is created.
  11755. @item @code{comment} (default: @code{""})
  11756. A comment about the account, such as the account owner's full name.
  11757. @item @code{home-directory}
  11758. This is the name of the home directory for the account.
  11759. @item @code{create-home-directory?} (default: @code{#t})
  11760. Indicates whether the home directory of this account should be created
  11761. if it does not exist yet.
  11762. @item @code{shell} (default: Bash)
  11763. This is a G-expression denoting the file name of a program to be used as
  11764. the shell (@pxref{G-Expressions}). For example, you would refer to the
  11765. Bash executable like this:
  11766. @lisp
  11767. (file-append bash "/bin/bash")
  11768. @end lisp
  11769. @noindent
  11770. ... and to the Zsh executable like that:
  11771. @lisp
  11772. (file-append zsh "/bin/zsh")
  11773. @end lisp
  11774. @item @code{system?} (default: @code{#f})
  11775. This Boolean value indicates whether the account is a ``system''
  11776. account. System accounts are sometimes treated specially; for instance,
  11777. graphical login managers do not list them.
  11778. @anchor{user-account-password}
  11779. @cindex password, for user accounts
  11780. @item @code{password} (default: @code{#f})
  11781. You would normally leave this field to @code{#f}, initialize user
  11782. passwords as @code{root} with the @command{passwd} command, and then let
  11783. users change it with @command{passwd}. Passwords set with
  11784. @command{passwd} are of course preserved across reboot and
  11785. reconfiguration.
  11786. If you @emph{do} want to set an initial password for an account, then
  11787. this field must contain the encrypted password, as a string. You can use the
  11788. @code{crypt} procedure for this purpose:
  11789. @lisp
  11790. (user-account
  11791. (name "charlie")
  11792. (group "users")
  11793. ;; Specify a SHA-512-hashed initial password.
  11794. (password (crypt "InitialPassword!" "$6$abc")))
  11795. @end lisp
  11796. @quotation Note
  11797. The hash of this initial password will be available in a file in
  11798. @file{/gnu/store}, readable by all the users, so this method must be used with
  11799. care.
  11800. @end quotation
  11801. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  11802. more information on password encryption, and @ref{Encryption,,, guile, GNU
  11803. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  11804. @end table
  11805. @end deftp
  11806. @cindex groups
  11807. User group declarations are even simpler:
  11808. @lisp
  11809. (user-group (name "students"))
  11810. @end lisp
  11811. @deftp {Data Type} user-group
  11812. This type is for, well, user groups. There are just a few fields:
  11813. @table @asis
  11814. @item @code{name}
  11815. The name of the group.
  11816. @item @code{id} (default: @code{#f})
  11817. The group identifier (a number). If @code{#f}, a new number is
  11818. automatically allocated when the group is created.
  11819. @item @code{system?} (default: @code{#f})
  11820. This Boolean value indicates whether the group is a ``system'' group.
  11821. System groups have low numerical IDs.
  11822. @item @code{password} (default: @code{#f})
  11823. What, user groups can have a password? Well, apparently yes. Unless
  11824. @code{#f}, this field specifies the password of the group.
  11825. @end table
  11826. @end deftp
  11827. For convenience, a variable lists all the basic user groups one may
  11828. expect:
  11829. @defvr {Scheme Variable} %base-groups
  11830. This is the list of basic user groups that users and/or packages expect
  11831. to be present on the system. This includes groups such as ``root'',
  11832. ``wheel'', and ``users'', as well as groups used to control access to
  11833. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  11834. @end defvr
  11835. @defvr {Scheme Variable} %base-user-accounts
  11836. This is the list of basic system accounts that programs may expect to
  11837. find on a GNU/Linux system, such as the ``nobody'' account.
  11838. Note that the ``root'' account is not included here. It is a
  11839. special-case and is automatically added whether or not it is specified.
  11840. @end defvr
  11841. @node Keyboard Layout
  11842. @section Keyboard Layout
  11843. @cindex keyboard layout
  11844. @cindex keymap
  11845. To specify what each key of your keyboard does, you need to tell the operating
  11846. system what @dfn{keyboard layout} you want to use. The default, when nothing
  11847. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  11848. However, German speakers will usually prefer the German QWERTZ layout, French
  11849. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  11850. or bépo, and they might even want to further customize the effect of some of
  11851. the keys. This section explains how to get that done.
  11852. @cindex keyboard layout, definition
  11853. There are three components that will want to know about your keyboard layout:
  11854. @itemize
  11855. @item
  11856. The @emph{bootloader} may want to know what keyboard layout you want to use
  11857. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  11858. you want, for instance, to make sure that you can type the passphrase of your
  11859. encrypted root partition using the right layout.
  11860. @item
  11861. The @emph{operating system kernel}, Linux, will need that so that the console
  11862. is properly configured (@pxref{operating-system Reference,
  11863. @code{keyboard-layout}}).
  11864. @item
  11865. The @emph{graphical display server}, usually Xorg, also has its own idea of
  11866. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  11867. @end itemize
  11868. Guix allows you to configure all three separately but, fortunately, it allows
  11869. you to share the same keyboard layout for all three components.
  11870. @cindex XKB, keyboard layouts
  11871. Keyboard layouts are represented by records created by the
  11872. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  11873. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  11874. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  11875. optional variant name, an optional keyboard model name, and a possibly empty
  11876. list of additional options. In most cases the layout name is all you care
  11877. about.
  11878. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  11879. [#:model] [#:options '()]
  11880. Return a new keyboard layout with the given @var{name} and @var{variant}.
  11881. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  11882. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  11883. @code{xkeyboard-config} package for valid options.
  11884. @end deffn
  11885. Here are a few examples:
  11886. @lisp
  11887. ;; The German QWERTZ layout. Here we assume a standard
  11888. ;; "pc105" keyboard model.
  11889. (keyboard-layout "de")
  11890. ;; The bépo variant of the French layout.
  11891. (keyboard-layout "fr" "bepo")
  11892. ;; The Catalan layout.
  11893. (keyboard-layout "es" "cat")
  11894. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  11895. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  11896. ;; The Latin American Spanish layout. In addition, the
  11897. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  11898. ;; and the "Menu" key is used as a "Compose" key to enter
  11899. ;; accented letters.
  11900. (keyboard-layout "latam"
  11901. #:options '("ctrl:nocaps" "compose:menu"))
  11902. ;; The Russian layout for a ThinkPad keyboard.
  11903. (keyboard-layout "ru" #:model "thinkpad")
  11904. ;; The "US international" layout, which is the US layout plus
  11905. ;; dead keys to enter accented characters. This is for an
  11906. ;; Apple MacBook keyboard.
  11907. (keyboard-layout "us" "intl" #:model "macbook78")
  11908. @end lisp
  11909. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  11910. for a complete list of supported layouts, variants, and models.
  11911. @cindex keyboard layout, configuration
  11912. Let's say you want your system to use the Turkish keyboard layout throughout
  11913. your system---bootloader, console, and Xorg. Here's what your system
  11914. configuration would look like:
  11915. @findex set-xorg-configuration
  11916. @lisp
  11917. ;; Using the Turkish layout for the bootloader, the console,
  11918. ;; and for Xorg.
  11919. (operating-system
  11920. ;; ...
  11921. (keyboard-layout (keyboard-layout "tr")) ;for the console
  11922. (bootloader (bootloader-configuration
  11923. (bootloader grub-efi-bootloader)
  11924. (target "/boot/efi")
  11925. (keyboard-layout keyboard-layout))) ;for GRUB
  11926. (services (cons (set-xorg-configuration
  11927. (xorg-configuration ;for Xorg
  11928. (keyboard-layout keyboard-layout)))
  11929. %desktop-services)))
  11930. @end lisp
  11931. In the example above, for GRUB and for Xorg, we just refer to the
  11932. @code{keyboard-layout} field defined above, but we could just as well refer to
  11933. a different layout. The @code{set-xorg-configuration} procedure communicates
  11934. the desired Xorg configuration to the graphical log-in manager, by default
  11935. GDM.
  11936. We've discussed how to specify the @emph{default} keyboard layout of your
  11937. system when it starts, but you can also adjust it at run time:
  11938. @itemize
  11939. @item
  11940. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  11941. where you can select one or more keyboard layouts.
  11942. @item
  11943. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  11944. allows you to change the current layout. For example, this is how you would
  11945. change the layout to US Dvorak:
  11946. @example
  11947. setxkbmap us dvorak
  11948. @end example
  11949. @item
  11950. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  11951. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  11952. keyboard layout categorization described above. The command below loads the
  11953. French bépo layout:
  11954. @example
  11955. loadkeys fr-bepo
  11956. @end example
  11957. @end itemize
  11958. @node Locales
  11959. @section Locales
  11960. @cindex locale
  11961. A @dfn{locale} defines cultural conventions for a particular language
  11962. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  11963. Reference Manual}). Each locale has a name that typically has the form
  11964. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  11965. @code{fr_LU.utf8} designates the locale for the French language, with
  11966. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  11967. @cindex locale definition
  11968. Usually, you will want to specify the default locale for the machine
  11969. using the @code{locale} field of the @code{operating-system} declaration
  11970. (@pxref{operating-system Reference, @code{locale}}).
  11971. The selected locale is automatically added to the @dfn{locale
  11972. definitions} known to the system if needed, with its codeset inferred
  11973. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  11974. @code{UTF-8} codeset. Additional locale definitions can be specified in
  11975. the @code{locale-definitions} slot of @code{operating-system}---this is
  11976. useful, for instance, if the codeset could not be inferred from the
  11977. locale name. The default set of locale definitions includes some widely
  11978. used locales, but not all the available locales, in order to save space.
  11979. For instance, to add the North Frisian locale for Germany, the value of
  11980. that field may be:
  11981. @lisp
  11982. (cons (locale-definition
  11983. (name "fy_DE.utf8") (source "fy_DE"))
  11984. %default-locale-definitions)
  11985. @end lisp
  11986. Likewise, to save space, one might want @code{locale-definitions} to
  11987. list only the locales that are actually used, as in:
  11988. @lisp
  11989. (list (locale-definition
  11990. (name "ja_JP.eucjp") (source "ja_JP")
  11991. (charset "EUC-JP")))
  11992. @end lisp
  11993. @vindex LOCPATH
  11994. The compiled locale definitions are available at
  11995. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  11996. version, which is the default location where the GNU@tie{}libc provided
  11997. by Guix looks for locale data. This can be overridden using the
  11998. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  11999. @env{LOCPATH} and locale packages}).
  12000. The @code{locale-definition} form is provided by the @code{(gnu system
  12001. locale)} module. Details are given below.
  12002. @deftp {Data Type} locale-definition
  12003. This is the data type of a locale definition.
  12004. @table @asis
  12005. @item @code{name}
  12006. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  12007. Reference Manual}, for more information on locale names.
  12008. @item @code{source}
  12009. The name of the source for that locale. This is typically the
  12010. @code{@var{language}_@var{territory}} part of the locale name.
  12011. @item @code{charset} (default: @code{"UTF-8"})
  12012. The ``character set'' or ``code set'' for that locale,
  12013. @uref{https://www.iana.org/assignments/character-sets, as defined by
  12014. IANA}.
  12015. @end table
  12016. @end deftp
  12017. @defvr {Scheme Variable} %default-locale-definitions
  12018. A list of commonly used UTF-8 locales, used as the default
  12019. value of the @code{locale-definitions} field of @code{operating-system}
  12020. declarations.
  12021. @cindex locale name
  12022. @cindex normalized codeset in locale names
  12023. These locale definitions use the @dfn{normalized codeset} for the part
  12024. that follows the dot in the name (@pxref{Using gettextized software,
  12025. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  12026. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  12027. @code{uk_UA.UTF-8}.
  12028. @end defvr
  12029. @subsection Locale Data Compatibility Considerations
  12030. @cindex incompatibility, of locale data
  12031. @code{operating-system} declarations provide a @code{locale-libcs} field
  12032. to specify the GNU@tie{}libc packages that are used to compile locale
  12033. declarations (@pxref{operating-system Reference}). ``Why would I
  12034. care?'', you may ask. Well, it turns out that the binary format of
  12035. locale data is occasionally incompatible from one libc version to
  12036. another.
  12037. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  12038. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  12039. For instance, a program linked against libc version 2.21 is unable to
  12040. read locale data produced with libc 2.22; worse, that program
  12041. @emph{aborts} instead of simply ignoring the incompatible locale
  12042. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  12043. the incompatible locale data, which is already an improvement.}.
  12044. Similarly, a program linked against libc 2.22 can read most, but not
  12045. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  12046. data is incompatible); thus calls to @code{setlocale} may fail, but
  12047. programs will not abort.
  12048. The ``problem'' with Guix is that users have a lot of freedom: They can
  12049. choose whether and when to upgrade software in their profiles, and might
  12050. be using a libc version different from the one the system administrator
  12051. used to build the system-wide locale data.
  12052. Fortunately, unprivileged users can also install their own locale data
  12053. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  12054. @env{GUIX_LOCPATH} and locale packages}).
  12055. Still, it is best if the system-wide locale data at
  12056. @file{/run/current-system/locale} is built for all the libc versions
  12057. actually in use on the system, so that all the programs can access
  12058. it---this is especially crucial on a multi-user system. To do that, the
  12059. administrator can specify several libc packages in the
  12060. @code{locale-libcs} field of @code{operating-system}:
  12061. @lisp
  12062. (use-package-modules base)
  12063. (operating-system
  12064. ;; @dots{}
  12065. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  12066. @end lisp
  12067. This example would lead to a system containing locale definitions for
  12068. both libc 2.21 and the current version of libc in
  12069. @file{/run/current-system/locale}.
  12070. @node Services
  12071. @section Services
  12072. @cindex system services
  12073. An important part of preparing an @code{operating-system} declaration is
  12074. listing @dfn{system services} and their configuration (@pxref{Using the
  12075. Configuration System}). System services are typically daemons launched
  12076. when the system boots, or other actions needed at that time---e.g.,
  12077. configuring network access.
  12078. Guix has a broad definition of ``service'' (@pxref{Service
  12079. Composition}), but many services are managed by the GNU@tie{}Shepherd
  12080. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  12081. command allows you to list the available services, show their status,
  12082. start and stop them, or do other specific operations (@pxref{Jump
  12083. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  12084. @example
  12085. # herd status
  12086. @end example
  12087. The above command, run as @code{root}, lists the currently defined
  12088. services. The @command{herd doc} command shows a synopsis of the given
  12089. service and its associated actions:
  12090. @example
  12091. # herd doc nscd
  12092. Run libc's name service cache daemon (nscd).
  12093. # herd doc nscd action invalidate
  12094. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  12095. @end example
  12096. The @command{start}, @command{stop}, and @command{restart} sub-commands
  12097. have the effect you would expect. For instance, the commands below stop
  12098. the nscd service and restart the Xorg display server:
  12099. @example
  12100. # herd stop nscd
  12101. Service nscd has been stopped.
  12102. # herd restart xorg-server
  12103. Service xorg-server has been stopped.
  12104. Service xorg-server has been started.
  12105. @end example
  12106. The following sections document the available services, starting with
  12107. the core services, that may be used in an @code{operating-system}
  12108. declaration.
  12109. @menu
  12110. * Base Services:: Essential system services.
  12111. * Scheduled Job Execution:: The mcron service.
  12112. * Log Rotation:: The rottlog service.
  12113. * Networking Services:: Network setup, SSH daemon, etc.
  12114. * Unattended Upgrades:: Automated system upgrades.
  12115. * X Window:: Graphical display.
  12116. * Printing Services:: Local and remote printer support.
  12117. * Desktop Services:: D-Bus and desktop services.
  12118. * Sound Services:: ALSA and Pulseaudio services.
  12119. * Database Services:: SQL databases, key-value stores, etc.
  12120. * Mail Services:: IMAP, POP3, SMTP, and all that.
  12121. * Messaging Services:: Messaging services.
  12122. * Telephony Services:: Telephony services.
  12123. * File-Sharing Services:: File-sharing services.
  12124. * Monitoring Services:: Monitoring services.
  12125. * Kerberos Services:: Kerberos services.
  12126. * LDAP Services:: LDAP services.
  12127. * Web Services:: Web servers.
  12128. * Certificate Services:: TLS certificates via Let's Encrypt.
  12129. * DNS Services:: DNS daemons.
  12130. * VPN Services:: VPN daemons.
  12131. * Network File System:: NFS related services.
  12132. * Continuous Integration:: Cuirass and Laminar services.
  12133. * Power Management Services:: Extending battery life.
  12134. * Audio Services:: The MPD.
  12135. * Virtualization Services:: Virtualization services.
  12136. * Version Control Services:: Providing remote access to Git repositories.
  12137. * Game Services:: Game servers.
  12138. * PAM Mount Service:: Service to mount volumes when logging in.
  12139. * Guix Services:: Services relating specifically to Guix.
  12140. * Linux Services:: Services tied to the Linux kernel.
  12141. * Hurd Services:: Services specific for a Hurd System.
  12142. * Miscellaneous Services:: Other services.
  12143. @end menu
  12144. @node Base Services
  12145. @subsection Base Services
  12146. The @code{(gnu services base)} module provides definitions for the basic
  12147. services that one expects from the system. The services exported by
  12148. this module are listed below.
  12149. @defvr {Scheme Variable} %base-services
  12150. This variable contains a list of basic services (@pxref{Service Types
  12151. and Services}, for more information on service objects) one would
  12152. expect from the system: a login service (mingetty) on each tty, syslogd,
  12153. the libc name service cache daemon (nscd), the udev device manager, and
  12154. more.
  12155. This is the default value of the @code{services} field of
  12156. @code{operating-system} declarations. Usually, when customizing a
  12157. system, you will want to append services to @code{%base-services}, like
  12158. this:
  12159. @lisp
  12160. (append (list (service avahi-service-type)
  12161. (service openssh-service-type))
  12162. %base-services)
  12163. @end lisp
  12164. @end defvr
  12165. @defvr {Scheme Variable} special-files-service-type
  12166. This is the service that sets up ``special files'' such as
  12167. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  12168. The value associated with @code{special-files-service-type} services
  12169. must be a list of tuples where the first element is the ``special file''
  12170. and the second element is its target. By default it is:
  12171. @cindex @file{/bin/sh}
  12172. @cindex @file{sh}, in @file{/bin}
  12173. @lisp
  12174. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  12175. @end lisp
  12176. @cindex @file{/usr/bin/env}
  12177. @cindex @file{env}, in @file{/usr/bin}
  12178. If you want to add, say, @code{/usr/bin/env} to your system, you can
  12179. change it to:
  12180. @lisp
  12181. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  12182. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  12183. @end lisp
  12184. Since this is part of @code{%base-services}, you can use
  12185. @code{modify-services} to customize the set of special files
  12186. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  12187. to add a special file is @i{via} the @code{extra-special-file} procedure
  12188. (see below).
  12189. @end defvr
  12190. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  12191. Use @var{target} as the ``special file'' @var{file}.
  12192. For example, adding the following lines to the @code{services} field of
  12193. your operating system declaration leads to a @file{/usr/bin/env}
  12194. symlink:
  12195. @lisp
  12196. (extra-special-file "/usr/bin/env"
  12197. (file-append coreutils "/bin/env"))
  12198. @end lisp
  12199. @end deffn
  12200. @deffn {Scheme Procedure} host-name-service @var{name}
  12201. Return a service that sets the host name to @var{name}.
  12202. @end deffn
  12203. @defvr {Scheme Variable} console-font-service-type
  12204. Install the given fonts on the specified ttys (fonts are per
  12205. virtual console on the kernel Linux). The value of this service is a list of
  12206. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  12207. package or any valid argument to @command{setfont}, as in this example:
  12208. @lisp
  12209. `(("tty1" . "LatGrkCyr-8x16")
  12210. ("tty2" . ,(file-append
  12211. font-tamzen
  12212. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  12213. ("tty3" . ,(file-append
  12214. font-terminus
  12215. "/share/consolefonts/ter-132n"))) ; for HDPI
  12216. @end lisp
  12217. @end defvr
  12218. @deffn {Scheme Procedure} login-service @var{config}
  12219. Return a service to run login according to @var{config}, a
  12220. @code{<login-configuration>} object, which specifies the message of the day,
  12221. among other things.
  12222. @end deffn
  12223. @deftp {Data Type} login-configuration
  12224. This is the data type representing the configuration of login.
  12225. @table @asis
  12226. @item @code{motd}
  12227. @cindex message of the day
  12228. A file-like object containing the ``message of the day''.
  12229. @item @code{allow-empty-passwords?} (default: @code{#t})
  12230. Allow empty passwords by default so that first-time users can log in when
  12231. the 'root' account has just been created.
  12232. @end table
  12233. @end deftp
  12234. @deffn {Scheme Procedure} mingetty-service @var{config}
  12235. Return a service to run mingetty according to @var{config}, a
  12236. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  12237. other things.
  12238. @end deffn
  12239. @deftp {Data Type} mingetty-configuration
  12240. This is the data type representing the configuration of Mingetty, which
  12241. provides the default implementation of virtual console log-in.
  12242. @table @asis
  12243. @item @code{tty}
  12244. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  12245. @item @code{auto-login} (default: @code{#f})
  12246. When true, this field must be a string denoting the user name under
  12247. which the system automatically logs in. When it is @code{#f}, a
  12248. user name and password must be entered to log in.
  12249. @item @code{login-program} (default: @code{#f})
  12250. This must be either @code{#f}, in which case the default log-in program
  12251. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  12252. the name of the log-in program.
  12253. @item @code{login-pause?} (default: @code{#f})
  12254. When set to @code{#t} in conjunction with @var{auto-login}, the user
  12255. will have to press a key before the log-in shell is launched.
  12256. @item @code{clear-on-logout?} (default: @code{#t})
  12257. When set to @code{#t}, the screen will be cleared after logout.
  12258. @item @code{mingetty} (default: @var{mingetty})
  12259. The Mingetty package to use.
  12260. @end table
  12261. @end deftp
  12262. @deffn {Scheme Procedure} agetty-service @var{config}
  12263. Return a service to run agetty according to @var{config}, an
  12264. @code{<agetty-configuration>} object, which specifies the tty to run,
  12265. among other things.
  12266. @end deffn
  12267. @deftp {Data Type} agetty-configuration
  12268. This is the data type representing the configuration of agetty, which
  12269. implements virtual and serial console log-in. See the @code{agetty(8)}
  12270. man page for more information.
  12271. @table @asis
  12272. @item @code{tty}
  12273. The name of the console this agetty runs on, as a string---e.g.,
  12274. @code{"ttyS0"}. This argument is optional, it will default to
  12275. a reasonable default serial port used by the kernel Linux.
  12276. For this, if there is a value for an option @code{agetty.tty} in the kernel
  12277. command line, agetty will extract the device name of the serial port
  12278. from it and use that.
  12279. If not and if there is a value for an option @code{console} with a tty in
  12280. the Linux command line, agetty will extract the device name of the
  12281. serial port from it and use that.
  12282. In both cases, agetty will leave the other serial device settings
  12283. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  12284. correct values.
  12285. @item @code{baud-rate} (default: @code{#f})
  12286. A string containing a comma-separated list of one or more baud rates, in
  12287. descending order.
  12288. @item @code{term} (default: @code{#f})
  12289. A string containing the value used for the @env{TERM} environment
  12290. variable.
  12291. @item @code{eight-bits?} (default: @code{#f})
  12292. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  12293. disabled.
  12294. @item @code{auto-login} (default: @code{#f})
  12295. When passed a login name, as a string, the specified user will be logged
  12296. in automatically without prompting for their login name or password.
  12297. @item @code{no-reset?} (default: @code{#f})
  12298. When @code{#t}, don't reset terminal cflags (control modes).
  12299. @item @code{host} (default: @code{#f})
  12300. This accepts a string containing the ``login_host'', which will be written
  12301. into the @file{/var/run/utmpx} file.
  12302. @item @code{remote?} (default: @code{#f})
  12303. When set to @code{#t} in conjunction with @var{host}, this will add an
  12304. @code{-r} fakehost option to the command line of the login program
  12305. specified in @var{login-program}.
  12306. @item @code{flow-control?} (default: @code{#f})
  12307. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  12308. @item @code{no-issue?} (default: @code{#f})
  12309. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  12310. not be displayed before presenting the login prompt.
  12311. @item @code{init-string} (default: @code{#f})
  12312. This accepts a string that will be sent to the tty or modem before
  12313. sending anything else. It can be used to initialize a modem.
  12314. @item @code{no-clear?} (default: @code{#f})
  12315. When set to @code{#t}, agetty will not clear the screen before showing
  12316. the login prompt.
  12317. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  12318. This must be either a gexp denoting the name of a log-in program, or
  12319. unset, in which case the default value is the @command{login} from the
  12320. Shadow tool suite.
  12321. @item @code{local-line} (default: @code{#f})
  12322. Control the CLOCAL line flag. This accepts one of three symbols as
  12323. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  12324. the default value chosen by agetty is @code{'auto}.
  12325. @item @code{extract-baud?} (default: @code{#f})
  12326. When set to @code{#t}, instruct agetty to try to extract the baud rate
  12327. from the status messages produced by certain types of modems.
  12328. @item @code{skip-login?} (default: @code{#f})
  12329. When set to @code{#t}, do not prompt the user for a login name. This
  12330. can be used with @var{login-program} field to use non-standard login
  12331. systems.
  12332. @item @code{no-newline?} (default: @code{#f})
  12333. When set to @code{#t}, do not print a newline before printing the
  12334. @file{/etc/issue} file.
  12335. @c Is this dangerous only when used with login-program, or always?
  12336. @item @code{login-options} (default: @code{#f})
  12337. This option accepts a string containing options that are passed to the
  12338. login program. When used with the @var{login-program}, be aware that a
  12339. malicious user could try to enter a login name containing embedded
  12340. options that could be parsed by the login program.
  12341. @item @code{login-pause} (default: @code{#f})
  12342. When set to @code{#t}, wait for any key before showing the login prompt.
  12343. This can be used in conjunction with @var{auto-login} to save memory by
  12344. lazily spawning shells.
  12345. @item @code{chroot} (default: @code{#f})
  12346. Change root to the specified directory. This option accepts a directory
  12347. path as a string.
  12348. @item @code{hangup?} (default: @code{#f})
  12349. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  12350. specified terminal.
  12351. @item @code{keep-baud?} (default: @code{#f})
  12352. When set to @code{#t}, try to keep the existing baud rate. The baud
  12353. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  12354. character.
  12355. @item @code{timeout} (default: @code{#f})
  12356. When set to an integer value, terminate if no user name could be read
  12357. within @var{timeout} seconds.
  12358. @item @code{detect-case?} (default: @code{#f})
  12359. When set to @code{#t}, turn on support for detecting an uppercase-only
  12360. terminal. This setting will detect a login name containing only
  12361. uppercase letters as indicating an uppercase-only terminal and turn on
  12362. some upper-to-lower case conversions. Note that this will not support
  12363. Unicode characters.
  12364. @item @code{wait-cr?} (default: @code{#f})
  12365. When set to @code{#t}, wait for the user or modem to send a
  12366. carriage-return or linefeed character before displaying
  12367. @file{/etc/issue} or login prompt. This is typically used with the
  12368. @var{init-string} option.
  12369. @item @code{no-hints?} (default: @code{#f})
  12370. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  12371. locks.
  12372. @item @code{no-hostname?} (default: @code{#f})
  12373. By default, the hostname is printed. When this option is set to
  12374. @code{#t}, no hostname will be shown at all.
  12375. @item @code{long-hostname?} (default: @code{#f})
  12376. By default, the hostname is only printed until the first dot. When this
  12377. option is set to @code{#t}, the fully qualified hostname by
  12378. @code{gethostname} or @code{getaddrinfo} is shown.
  12379. @item @code{erase-characters} (default: @code{#f})
  12380. This option accepts a string of additional characters that should be
  12381. interpreted as backspace when the user types their login name.
  12382. @item @code{kill-characters} (default: @code{#f})
  12383. This option accepts a string that should be interpreted to mean ``ignore
  12384. all previous characters'' (also called a ``kill'' character) when the user
  12385. types their login name.
  12386. @item @code{chdir} (default: @code{#f})
  12387. This option accepts, as a string, a directory path that will be changed
  12388. to before login.
  12389. @item @code{delay} (default: @code{#f})
  12390. This options accepts, as an integer, the number of seconds to sleep
  12391. before opening the tty and displaying the login prompt.
  12392. @item @code{nice} (default: @code{#f})
  12393. This option accepts, as an integer, the nice value with which to run the
  12394. @command{login} program.
  12395. @item @code{extra-options} (default: @code{'()})
  12396. This option provides an ``escape hatch'' for the user to provide arbitrary
  12397. command-line arguments to @command{agetty} as a list of strings.
  12398. @end table
  12399. @end deftp
  12400. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  12401. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  12402. according to @var{config}, a @code{<kmscon-configuration>} object, which
  12403. specifies the tty to run, among other things.
  12404. @end deffn
  12405. @deftp {Data Type} kmscon-configuration
  12406. This is the data type representing the configuration of Kmscon, which
  12407. implements virtual console log-in.
  12408. @table @asis
  12409. @item @code{virtual-terminal}
  12410. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  12411. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  12412. A gexp denoting the name of the log-in program. The default log-in program is
  12413. @command{login} from the Shadow tool suite.
  12414. @item @code{login-arguments} (default: @code{'("-p")})
  12415. A list of arguments to pass to @command{login}.
  12416. @item @code{auto-login} (default: @code{#f})
  12417. When passed a login name, as a string, the specified user will be logged
  12418. in automatically without prompting for their login name or password.
  12419. @item @code{hardware-acceleration?} (default: #f)
  12420. Whether to use hardware acceleration.
  12421. @item @code{font-engine} (default: @code{"pango"})
  12422. Font engine used in Kmscon.
  12423. @item @code{font-size} (default: @code{12})
  12424. Font size used in Kmscon.
  12425. @item @code{kmscon} (default: @var{kmscon})
  12426. The Kmscon package to use.
  12427. @end table
  12428. @end deftp
  12429. @cindex name service cache daemon
  12430. @cindex nscd
  12431. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  12432. [#:name-services '()]
  12433. Return a service that runs the libc name service cache daemon (nscd) with the
  12434. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  12435. Service Switch}, for an example.
  12436. For convenience, the Shepherd service for nscd provides the following actions:
  12437. @table @code
  12438. @item invalidate
  12439. @cindex cache invalidation, nscd
  12440. @cindex nscd, cache invalidation
  12441. This invalidate the given cache. For instance, running:
  12442. @example
  12443. herd invalidate nscd hosts
  12444. @end example
  12445. @noindent
  12446. invalidates the host name lookup cache of nscd.
  12447. @item statistics
  12448. Running @command{herd statistics nscd} displays information about nscd usage
  12449. and caches.
  12450. @end table
  12451. @end deffn
  12452. @defvr {Scheme Variable} %nscd-default-configuration
  12453. This is the default @code{<nscd-configuration>} value (see below) used
  12454. by @code{nscd-service}. It uses the caches defined by
  12455. @code{%nscd-default-caches}; see below.
  12456. @end defvr
  12457. @deftp {Data Type} nscd-configuration
  12458. This is the data type representing the name service cache daemon (nscd)
  12459. configuration.
  12460. @table @asis
  12461. @item @code{name-services} (default: @code{'()})
  12462. List of packages denoting @dfn{name services} that must be visible to
  12463. the nscd---e.g., @code{(list @var{nss-mdns})}.
  12464. @item @code{glibc} (default: @var{glibc})
  12465. Package object denoting the GNU C Library providing the @command{nscd}
  12466. command.
  12467. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  12468. Name of the nscd log file. This is where debugging output goes when
  12469. @code{debug-level} is strictly positive.
  12470. @item @code{debug-level} (default: @code{0})
  12471. Integer denoting the debugging levels. Higher numbers mean that more
  12472. debugging output is logged.
  12473. @item @code{caches} (default: @code{%nscd-default-caches})
  12474. List of @code{<nscd-cache>} objects denoting things to be cached; see
  12475. below.
  12476. @end table
  12477. @end deftp
  12478. @deftp {Data Type} nscd-cache
  12479. Data type representing a cache database of nscd and its parameters.
  12480. @table @asis
  12481. @item @code{database}
  12482. This is a symbol representing the name of the database to be cached.
  12483. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  12484. @code{services}, which designate the corresponding NSS database
  12485. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  12486. @item @code{positive-time-to-live}
  12487. @itemx @code{negative-time-to-live} (default: @code{20})
  12488. A number representing the number of seconds during which a positive or
  12489. negative lookup result remains in cache.
  12490. @item @code{check-files?} (default: @code{#t})
  12491. Whether to check for updates of the files corresponding to
  12492. @var{database}.
  12493. For instance, when @var{database} is @code{hosts}, setting this flag
  12494. instructs nscd to check for updates in @file{/etc/hosts} and to take
  12495. them into account.
  12496. @item @code{persistent?} (default: @code{#t})
  12497. Whether the cache should be stored persistently on disk.
  12498. @item @code{shared?} (default: @code{#t})
  12499. Whether the cache should be shared among users.
  12500. @item @code{max-database-size} (default: 32@tie{}MiB)
  12501. Maximum size in bytes of the database cache.
  12502. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  12503. @c settings, so leave them out.
  12504. @end table
  12505. @end deftp
  12506. @defvr {Scheme Variable} %nscd-default-caches
  12507. List of @code{<nscd-cache>} objects used by default by
  12508. @code{nscd-configuration} (see above).
  12509. It enables persistent and aggressive caching of service and host name
  12510. lookups. The latter provides better host name lookup performance,
  12511. resilience in the face of unreliable name servers, and also better
  12512. privacy---often the result of host name lookups is in local cache, so
  12513. external name servers do not even need to be queried.
  12514. @end defvr
  12515. @anchor{syslog-configuration-type}
  12516. @cindex syslog
  12517. @cindex logging
  12518. @deftp {Data Type} syslog-configuration
  12519. This data type represents the configuration of the syslog daemon.
  12520. @table @asis
  12521. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  12522. The syslog daemon to use.
  12523. @item @code{config-file} (default: @code{%default-syslog.conf})
  12524. The syslog configuration file to use.
  12525. @end table
  12526. @end deftp
  12527. @anchor{syslog-service}
  12528. @cindex syslog
  12529. @deffn {Scheme Procedure} syslog-service @var{config}
  12530. Return a service that runs a syslog daemon according to @var{config}.
  12531. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  12532. information on the configuration file syntax.
  12533. @end deffn
  12534. @defvr {Scheme Variable} guix-service-type
  12535. This is the type of the service that runs the build daemon,
  12536. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  12537. @code{guix-configuration} record as described below.
  12538. @end defvr
  12539. @anchor{guix-configuration-type}
  12540. @deftp {Data Type} guix-configuration
  12541. This data type represents the configuration of the Guix build daemon.
  12542. @xref{Invoking guix-daemon}, for more information.
  12543. @table @asis
  12544. @item @code{guix} (default: @var{guix})
  12545. The Guix package to use.
  12546. @item @code{build-group} (default: @code{"guixbuild"})
  12547. Name of the group for build user accounts.
  12548. @item @code{build-accounts} (default: @code{10})
  12549. Number of build user accounts to create.
  12550. @item @code{authorize-key?} (default: @code{#t})
  12551. @cindex substitutes, authorization thereof
  12552. Whether to authorize the substitute keys listed in
  12553. @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
  12554. (@pxref{Substitutes}).
  12555. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  12556. changed by invoking @command{guix archive --authorize}. You must
  12557. instead adjust @code{guix-configuration} as you wish and reconfigure the
  12558. system. This ensures that your operating system configuration file is
  12559. self-contained.
  12560. @quotation Note
  12561. When booting or reconfiguring to a system where @code{authorize-key?}
  12562. is true, the existing @file{/etc/guix/acl} file is backed up as
  12563. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  12564. file. This is to facilitate migration from earlier versions, which
  12565. allowed for in-place modifications to @file{/etc/guix/acl}.
  12566. @end quotation
  12567. @vindex %default-authorized-guix-keys
  12568. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  12569. The list of authorized key files for archive imports, as a list of
  12570. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  12571. contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
  12572. See @code{substitute-urls} below for an example on how to change it.
  12573. @item @code{use-substitutes?} (default: @code{#t})
  12574. Whether to use substitutes.
  12575. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  12576. The list of URLs where to look for substitutes by default.
  12577. Suppose you would like to fetch substitutes from @code{guix.example.org}
  12578. in addition to @code{@value{SUBSTITUTE-SERVER}}. You will need to do
  12579. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  12580. and (2) authorize its signing key, having done appropriate checks
  12581. (@pxref{Substitute Server Authorization}). The configuration below does
  12582. exactly that:
  12583. @lisp
  12584. (guix-configuration
  12585. (substitute-urls
  12586. (append (list "https://guix.example.org")
  12587. %default-substitute-urls))
  12588. (authorized-keys
  12589. (append (list (local-file "./guix.example.org-key.pub"))
  12590. %default-authorized-guix-keys)))
  12591. @end lisp
  12592. This example assumes that the file @file{./guix.example.org-key.pub}
  12593. contains the public key that @code{guix.example.org} uses to sign
  12594. substitutes.
  12595. @item @code{max-silent-time} (default: @code{0})
  12596. @itemx @code{timeout} (default: @code{0})
  12597. The number of seconds of silence and the number of seconds of activity,
  12598. respectively, after which a build process times out. A value of zero
  12599. disables the timeout.
  12600. @item @code{log-compression} (default: @code{'bzip2})
  12601. The type of compression used for build logs---one of @code{gzip},
  12602. @code{bzip2}, or @code{none}.
  12603. @item @code{discover?} (default: @code{#f})
  12604. Whether to discover substitute servers on the local network using mDNS
  12605. and DNS-SD.
  12606. @item @code{extra-options} (default: @code{'()})
  12607. List of extra command-line options for @command{guix-daemon}.
  12608. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  12609. File where @command{guix-daemon}'s standard output and standard error
  12610. are written.
  12611. @cindex HTTP proxy, for @code{guix-daemon}
  12612. @cindex proxy, for @code{guix-daemon} HTTP access
  12613. @item @code{http-proxy} (default: @code{#f})
  12614. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  12615. derivations and substitutes.
  12616. It is also possible to change the daemon's proxy at run time through the
  12617. @code{set-http-proxy} action, which restarts it:
  12618. @example
  12619. herd set-http-proxy guix-daemon http://localhost:8118
  12620. @end example
  12621. To clear the proxy settings, run:
  12622. @example
  12623. herd set-http-proxy guix-daemon
  12624. @end example
  12625. @item @code{tmpdir} (default: @code{#f})
  12626. A directory path where the @command{guix-daemon} will perform builds.
  12627. @end table
  12628. @end deftp
  12629. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  12630. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  12631. udev rules can be provided as a list of files through the @var{rules}
  12632. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  12633. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  12634. creation of such rule files.
  12635. The @command{herd rules udev} command, as root, returns the name of the
  12636. directory containing all the active udev rules.
  12637. @end deffn
  12638. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  12639. Return a udev-rule file named @var{file-name} containing the rules
  12640. defined by the @var{contents} literal.
  12641. In the following example, a rule for a USB device is defined to be
  12642. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  12643. upon detecting a USB device with a given product identifier.
  12644. @lisp
  12645. (define %example-udev-rule
  12646. (udev-rule
  12647. "90-usb-thing.rules"
  12648. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  12649. "ATTR@{product@}==\"Example\", "
  12650. "RUN+=\"/path/to/script\"")))
  12651. @end lisp
  12652. @end deffn
  12653. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  12654. [#:groups @var{groups}]
  12655. Return a service that extends @code{udev-service-type } with @var{rules}
  12656. and @code{account-service-type} with @var{groups} as system groups.
  12657. This works by creating a singleton service type
  12658. @code{@var{name}-udev-rules}, of which the returned service is an
  12659. instance.
  12660. Here we show how it can be used to extend @code{udev-service-type} with the
  12661. previously defined rule @code{%example-udev-rule}.
  12662. @lisp
  12663. (operating-system
  12664. ;; @dots{}
  12665. (services
  12666. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  12667. %desktop-services)))
  12668. @end lisp
  12669. @end deffn
  12670. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  12671. Return a udev file named @var{file-name} containing the rules defined
  12672. within @var{file}, a file-like object.
  12673. The following example showcases how we can use an existing rule file.
  12674. @lisp
  12675. (use-modules (guix download) ;for url-fetch
  12676. (guix packages) ;for origin
  12677. @dots{})
  12678. (define %android-udev-rules
  12679. (file->udev-rule
  12680. "51-android-udev.rules"
  12681. (let ((version "20170910"))
  12682. (origin
  12683. (method url-fetch)
  12684. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  12685. "android-udev-rules/" version "/51-android.rules"))
  12686. (sha256
  12687. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  12688. @end lisp
  12689. @end deffn
  12690. Additionally, Guix package definitions can be included in @var{rules} in
  12691. order to extend the udev rules with the definitions found under their
  12692. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  12693. @var{file->udev-rule} example, we could have used the
  12694. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  12695. packages android)} module.
  12696. The following example shows how to use the @var{android-udev-rules}
  12697. package so that the Android tool @command{adb} can detect devices
  12698. without root privileges. It also details how to create the
  12699. @code{adbusers} group, which is required for the proper functioning of
  12700. the rules defined within the @code{android-udev-rules} package. To
  12701. create such a group, we must define it both as part of the
  12702. @code{supplementary-groups} of our @code{user-account} declaration, as
  12703. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  12704. @lisp
  12705. (use-modules (gnu packages android) ;for android-udev-rules
  12706. (gnu system shadow) ;for user-group
  12707. @dots{})
  12708. (operating-system
  12709. ;; @dots{}
  12710. (users (cons (user-account
  12711. ;; @dots{}
  12712. (supplementary-groups
  12713. '("adbusers" ;for adb
  12714. "wheel" "netdev" "audio" "video")))))
  12715. ;; @dots{}
  12716. (services
  12717. (cons (udev-rules-service 'android android-udev-rules
  12718. #:groups '("adbusers"))
  12719. %desktop-services)))
  12720. @end lisp
  12721. @defvr {Scheme Variable} urandom-seed-service-type
  12722. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  12723. when rebooting. It also tries to seed @file{/dev/urandom} from
  12724. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  12725. readable.
  12726. @end defvr
  12727. @defvr {Scheme Variable} %random-seed-file
  12728. This is the name of the file where some random bytes are saved by
  12729. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  12730. It defaults to @file{/var/lib/random-seed}.
  12731. @end defvr
  12732. @cindex mouse
  12733. @cindex gpm
  12734. @defvr {Scheme Variable} gpm-service-type
  12735. This is the type of the service that runs GPM, the @dfn{general-purpose
  12736. mouse daemon}, which provides mouse support to the Linux console. GPM
  12737. allows users to use the mouse in the console, notably to select, copy,
  12738. and paste text.
  12739. The value for services of this type must be a @code{gpm-configuration}
  12740. (see below). This service is not part of @code{%base-services}.
  12741. @end defvr
  12742. @deftp {Data Type} gpm-configuration
  12743. Data type representing the configuration of GPM.
  12744. @table @asis
  12745. @item @code{options} (default: @code{%default-gpm-options})
  12746. Command-line options passed to @command{gpm}. The default set of
  12747. options instruct @command{gpm} to listen to mouse events on
  12748. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  12749. more information.
  12750. @item @code{gpm} (default: @code{gpm})
  12751. The GPM package to use.
  12752. @end table
  12753. @end deftp
  12754. @anchor{guix-publish-service-type}
  12755. @deffn {Scheme Variable} guix-publish-service-type
  12756. This is the service type for @command{guix publish} (@pxref{Invoking
  12757. guix publish}). Its value must be a @code{guix-publish-configuration}
  12758. object, as described below.
  12759. This assumes that @file{/etc/guix} already contains a signing key pair as
  12760. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  12761. archive}). If that is not the case, the service will fail to start.
  12762. @end deffn
  12763. @deftp {Data Type} guix-publish-configuration
  12764. Data type representing the configuration of the @code{guix publish}
  12765. service.
  12766. @table @asis
  12767. @item @code{guix} (default: @code{guix})
  12768. The Guix package to use.
  12769. @item @code{port} (default: @code{80})
  12770. The TCP port to listen for connections.
  12771. @item @code{host} (default: @code{"localhost"})
  12772. The host (and thus, network interface) to listen to. Use
  12773. @code{"0.0.0.0"} to listen on all the network interfaces.
  12774. @item @code{advertise?} (default: @code{#f})
  12775. When true, advertise the service on the local network @i{via} the DNS-SD
  12776. protocol, using Avahi.
  12777. This allows neighboring Guix devices with discovery on (see
  12778. @code{guix-configuration} above) to discover this @command{guix publish}
  12779. instance and to automatically download substitutes from it.
  12780. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  12781. This is a list of compression method/level tuple used when compressing
  12782. substitutes. For example, to compress all substitutes with @emph{both} lzip
  12783. at level 7 and gzip at level 9, write:
  12784. @lisp
  12785. '(("lzip" 7) ("gzip" 9))
  12786. @end lisp
  12787. Level 9 achieves the best compression ratio at the expense of increased CPU
  12788. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  12789. publish}, for more information on the available compression methods and
  12790. the tradeoffs involved.
  12791. An empty list disables compression altogether.
  12792. @item @code{nar-path} (default: @code{"nar"})
  12793. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  12794. publish, @option{--nar-path}}, for details.
  12795. @item @code{cache} (default: @code{#f})
  12796. When it is @code{#f}, disable caching and instead generate archives on
  12797. demand. Otherwise, this should be the name of a directory---e.g.,
  12798. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  12799. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  12800. @option{--cache}}, for more information on the tradeoffs involved.
  12801. @item @code{workers} (default: @code{#f})
  12802. When it is an integer, this is the number of worker threads used for
  12803. caching; when @code{#f}, the number of processors is used.
  12804. @xref{Invoking guix publish, @option{--workers}}, for more information.
  12805. @item @code{cache-bypass-threshold} (default: 10 MiB)
  12806. When @code{cache} is true, this is the maximum size in bytes of a store
  12807. item for which @command{guix publish} may bypass its cache in case of a
  12808. cache miss. @xref{Invoking guix publish,
  12809. @option{--cache-bypass-threshold}}, for more information.
  12810. @item @code{ttl} (default: @code{#f})
  12811. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  12812. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  12813. for more information.
  12814. @end table
  12815. @end deftp
  12816. @anchor{rngd-service}
  12817. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  12818. [#:device "/dev/hwrng"]
  12819. Return a service that runs the @command{rngd} program from @var{rng-tools}
  12820. to add @var{device} to the kernel's entropy pool. The service will fail if
  12821. @var{device} does not exist.
  12822. @end deffn
  12823. @anchor{pam-limits-service}
  12824. @cindex session limits
  12825. @cindex ulimit
  12826. @cindex priority
  12827. @cindex realtime
  12828. @cindex jackd
  12829. @cindex nofile
  12830. @cindex open file descriptors
  12831. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  12832. Return a service that installs a configuration file for the
  12833. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  12834. @code{pam_limits} module}. The procedure optionally takes a list of
  12835. @code{pam-limits-entry} values, which can be used to specify
  12836. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  12837. The following limits definition sets two hard and soft limits for all
  12838. login sessions of users in the @code{realtime} group:
  12839. @lisp
  12840. (pam-limits-service
  12841. (list
  12842. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  12843. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  12844. @end lisp
  12845. The first entry increases the maximum realtime priority for
  12846. non-privileged processes; the second entry lifts any restriction of the
  12847. maximum address space that can be locked in memory. These settings are
  12848. commonly used for real-time audio systems.
  12849. Another useful example is raising the maximum number of open file
  12850. descriptors that can be used:
  12851. @lisp
  12852. (pam-limits-service
  12853. (list
  12854. (pam-limits-entry "*" 'both 'nofile 100000)))
  12855. @end lisp
  12856. In the above example, the asterisk means the limit should apply to any
  12857. user. It is important to ensure the chosen value doesn't exceed the
  12858. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  12859. else the users would be prevented from login in. For more information
  12860. about the Pluggable Authentication Module (PAM) limits, refer to the
  12861. @samp{pam_limits} man page from the @code{linux-pam} package.
  12862. @end deffn
  12863. @node Scheduled Job Execution
  12864. @subsection Scheduled Job Execution
  12865. @cindex cron
  12866. @cindex mcron
  12867. @cindex scheduling jobs
  12868. The @code{(gnu services mcron)} module provides an interface to
  12869. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  12870. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  12871. Unix @command{cron} daemon; the main difference is that it is
  12872. implemented in Guile Scheme, which provides a lot of flexibility when
  12873. specifying the scheduling of jobs and their actions.
  12874. The example below defines an operating system that runs the
  12875. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  12876. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  12877. well as the @command{mkid} command on behalf of an unprivileged user
  12878. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  12879. gexps to introduce job definitions that are passed to mcron
  12880. (@pxref{G-Expressions}).
  12881. @lisp
  12882. (use-modules (guix) (gnu) (gnu services mcron))
  12883. (use-package-modules base idutils)
  12884. (define updatedb-job
  12885. ;; Run 'updatedb' at 3AM every day. Here we write the
  12886. ;; job's action as a Scheme procedure.
  12887. #~(job '(next-hour '(3))
  12888. (lambda ()
  12889. (execl (string-append #$findutils "/bin/updatedb")
  12890. "updatedb"
  12891. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  12892. (define garbage-collector-job
  12893. ;; Collect garbage 5 minutes after midnight every day.
  12894. ;; The job's action is a shell command.
  12895. #~(job "5 0 * * *" ;Vixie cron syntax
  12896. "guix gc -F 1G"))
  12897. (define idutils-job
  12898. ;; Update the index database as user "charlie" at 12:15PM
  12899. ;; and 19:15PM. This runs from the user's home directory.
  12900. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  12901. (string-append #$idutils "/bin/mkid src")
  12902. #:user "charlie"))
  12903. (operating-system
  12904. ;; @dots{}
  12905. ;; %BASE-SERVICES already includes an instance of
  12906. ;; 'mcron-service-type', which we extend with additional
  12907. ;; jobs using 'simple-service'.
  12908. (services (cons (simple-service 'my-cron-jobs
  12909. mcron-service-type
  12910. (list garbage-collector-job
  12911. updatedb-job
  12912. idutils-job))
  12913. %base-services)))
  12914. @end lisp
  12915. For more complex jobs defined in Scheme where you need control over the top
  12916. level, for instance to introduce a @code{use-modules} form, you can move your
  12917. code to a separate program using the @code{program-file} procedure of the
  12918. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  12919. illustrates that.
  12920. @lisp
  12921. (define %battery-alert-job
  12922. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  12923. #~(job
  12924. '(next-minute (range 0 60 1))
  12925. #$(program-file
  12926. "battery-alert.scm"
  12927. (with-imported-modules (source-module-closure
  12928. '((guix build utils)))
  12929. #~(begin
  12930. (use-modules (guix build utils)
  12931. (ice-9 popen)
  12932. (ice-9 regex)
  12933. (ice-9 textual-ports)
  12934. (srfi srfi-2))
  12935. (define %min-level 20)
  12936. (setenv "LC_ALL" "C") ;ensure English output
  12937. (and-let* ((input-pipe (open-pipe*
  12938. OPEN_READ
  12939. #$(file-append acpi "/bin/acpi")))
  12940. (output (get-string-all input-pipe))
  12941. (m (string-match "Discharging, ([0-9]+)%" output))
  12942. (level (string->number (match:substring m 1)))
  12943. ((< level %min-level)))
  12944. (format #t "warning: Battery level is low (~a%)~%" level)
  12945. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  12946. @end lisp
  12947. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  12948. for more information on mcron job specifications. Below is the
  12949. reference of the mcron service.
  12950. On a running system, you can use the @code{schedule} action of the service to
  12951. visualize the mcron jobs that will be executed next:
  12952. @example
  12953. # herd schedule mcron
  12954. @end example
  12955. @noindent
  12956. The example above lists the next five tasks that will be executed, but you can
  12957. also specify the number of tasks to display:
  12958. @example
  12959. # herd schedule mcron 10
  12960. @end example
  12961. @defvr {Scheme Variable} mcron-service-type
  12962. This is the type of the @code{mcron} service, whose value is an
  12963. @code{mcron-configuration} object.
  12964. This service type can be the target of a service extension that provides
  12965. it additional job specifications (@pxref{Service Composition}). In
  12966. other words, it is possible to define services that provide additional
  12967. mcron jobs to run.
  12968. @end defvr
  12969. @deftp {Data Type} mcron-configuration
  12970. Data type representing the configuration of mcron.
  12971. @table @asis
  12972. @item @code{mcron} (default: @var{mcron})
  12973. The mcron package to use.
  12974. @item @code{jobs}
  12975. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  12976. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  12977. specifications,, mcron, GNU@tie{}mcron}).
  12978. @end table
  12979. @end deftp
  12980. @node Log Rotation
  12981. @subsection Log Rotation
  12982. @cindex rottlog
  12983. @cindex log rotation
  12984. @cindex logging
  12985. Log files such as those found in @file{/var/log} tend to grow endlessly,
  12986. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  12987. their contents in separate files, possibly compressed. The @code{(gnu
  12988. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  12989. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  12990. This service is part of @code{%base-services}, and thus enabled by
  12991. default, with the default settings, for commonly encountered log files.
  12992. The example below shows how to extend it with an additional
  12993. @dfn{rotation}, should you need to do that (usually, services that
  12994. produce log files already take care of that):
  12995. @lisp
  12996. (use-modules (guix) (gnu))
  12997. (use-service-modules admin)
  12998. (define my-log-files
  12999. ;; Log files that I want to rotate.
  13000. '("/var/log/something.log" "/var/log/another.log"))
  13001. (operating-system
  13002. ;; @dots{}
  13003. (services (cons (simple-service 'rotate-my-stuff
  13004. rottlog-service-type
  13005. (list (log-rotation
  13006. (frequency 'daily)
  13007. (files my-log-files))))
  13008. %base-services)))
  13009. @end lisp
  13010. @defvr {Scheme Variable} rottlog-service-type
  13011. This is the type of the Rottlog service, whose value is a
  13012. @code{rottlog-configuration} object.
  13013. Other services can extend this one with new @code{log-rotation} objects
  13014. (see below), thereby augmenting the set of files to be rotated.
  13015. This service type can define mcron jobs (@pxref{Scheduled Job
  13016. Execution}) to run the rottlog service.
  13017. @end defvr
  13018. @deftp {Data Type} rottlog-configuration
  13019. Data type representing the configuration of rottlog.
  13020. @table @asis
  13021. @item @code{rottlog} (default: @code{rottlog})
  13022. The Rottlog package to use.
  13023. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  13024. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  13025. rottlog, GNU Rot[t]log Manual}).
  13026. @item @code{rotations} (default: @code{%default-rotations})
  13027. A list of @code{log-rotation} objects as defined below.
  13028. @item @code{jobs}
  13029. This is a list of gexps where each gexp corresponds to an mcron job
  13030. specification (@pxref{Scheduled Job Execution}).
  13031. @end table
  13032. @end deftp
  13033. @deftp {Data Type} log-rotation
  13034. Data type representing the rotation of a group of log files.
  13035. Taking an example from the Rottlog manual (@pxref{Period Related File
  13036. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  13037. defined like this:
  13038. @lisp
  13039. (log-rotation
  13040. (frequency 'daily)
  13041. (files '("/var/log/apache/*"))
  13042. (options '("storedir apache-archives"
  13043. "rotate 6"
  13044. "notifempty"
  13045. "nocompress")))
  13046. @end lisp
  13047. The list of fields is as follows:
  13048. @table @asis
  13049. @item @code{frequency} (default: @code{'weekly})
  13050. The log rotation frequency, a symbol.
  13051. @item @code{files}
  13052. The list of files or file glob patterns to rotate.
  13053. @item @code{options} (default: @code{'()})
  13054. The list of rottlog options for this rotation (@pxref{Configuration
  13055. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  13056. @item @code{post-rotate} (default: @code{#f})
  13057. Either @code{#f} or a gexp to execute once the rotation has completed.
  13058. @end table
  13059. @end deftp
  13060. @defvr {Scheme Variable} %default-rotations
  13061. Specifies weekly rotation of @code{%rotated-files} and of
  13062. @file{/var/log/guix-daemon.log}.
  13063. @end defvr
  13064. @defvr {Scheme Variable} %rotated-files
  13065. The list of syslog-controlled files to be rotated. By default it is:
  13066. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  13067. "/var/log/maillog")}.
  13068. @end defvr
  13069. @node Networking Services
  13070. @subsection Networking Services
  13071. The @code{(gnu services networking)} module provides services to configure
  13072. the network interface.
  13073. @cindex DHCP, networking service
  13074. @defvr {Scheme Variable} dhcp-client-service-type
  13075. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  13076. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  13077. is the DHCP client package to use, @code{isc-dhcp} by default.
  13078. @end defvr
  13079. @deffn {Scheme Procedure} dhcpd-service-type
  13080. This type defines a service that runs a DHCP daemon. To create a
  13081. service of this type, you must supply a @code{<dhcpd-configuration>}.
  13082. For example:
  13083. @lisp
  13084. (service dhcpd-service-type
  13085. (dhcpd-configuration
  13086. (config-file (local-file "my-dhcpd.conf"))
  13087. (interfaces '("enp0s25"))))
  13088. @end lisp
  13089. @end deffn
  13090. @deftp {Data Type} dhcpd-configuration
  13091. @table @asis
  13092. @item @code{package} (default: @code{isc-dhcp})
  13093. The package that provides the DHCP daemon. This package is expected to
  13094. provide the daemon at @file{sbin/dhcpd} relative to its output
  13095. directory. The default package is the
  13096. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  13097. @item @code{config-file} (default: @code{#f})
  13098. The configuration file to use. This is required. It will be passed to
  13099. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  13100. object (@pxref{G-Expressions, file-like objects}). See @code{man
  13101. dhcpd.conf} for details on the configuration file syntax.
  13102. @item @code{version} (default: @code{"4"})
  13103. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  13104. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  13105. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  13106. details.
  13107. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  13108. The run directory to use. At service activation time, this directory
  13109. will be created if it does not exist.
  13110. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  13111. The PID file to use. This corresponds to the @code{-pf} option of
  13112. @code{dhcpd}. See @code{man dhcpd} for details.
  13113. @item @code{interfaces} (default: @code{'()})
  13114. The names of the network interfaces on which dhcpd should listen for
  13115. broadcasts. If this list is not empty, then its elements (which must be
  13116. strings) will be appended to the @code{dhcpd} invocation when starting
  13117. the daemon. It may not be necessary to explicitly specify any
  13118. interfaces here; see @code{man dhcpd} for details.
  13119. @end table
  13120. @end deftp
  13121. @defvr {Scheme Variable} static-networking-service-type
  13122. This is the type for statically-configured network interfaces.
  13123. @c TODO Document <static-networking> data structures.
  13124. @end defvr
  13125. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  13126. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  13127. [#:requirement @code{'(udev)}]
  13128. Return a service that starts @var{interface} with address @var{ip}. If
  13129. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  13130. it must be a string specifying the default network gateway. @var{requirement}
  13131. can be used to declare a dependency on another service before configuring the
  13132. interface.
  13133. This procedure can be called several times, one for each network
  13134. interface of interest. Behind the scenes what it does is extend
  13135. @code{static-networking-service-type} with additional network interfaces
  13136. to handle.
  13137. For example:
  13138. @lisp
  13139. (static-networking-service "eno1" "192.168.1.82"
  13140. #:gateway "192.168.1.2"
  13141. #:name-servers '("192.168.1.2"))
  13142. @end lisp
  13143. @end deffn
  13144. @cindex wicd
  13145. @cindex wireless
  13146. @cindex WiFi
  13147. @cindex network management
  13148. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  13149. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  13150. management daemon that aims to simplify wired and wireless networking.
  13151. This service adds the @var{wicd} package to the global profile, providing
  13152. several commands to interact with the daemon and configure networking:
  13153. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  13154. and @command{wicd-curses} user interfaces.
  13155. @end deffn
  13156. @cindex ModemManager
  13157. @defvr {Scheme Variable} modem-manager-service-type
  13158. This is the service type for the
  13159. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  13160. service. The value for this service type is a
  13161. @code{modem-manager-configuration} record.
  13162. This service is part of @code{%desktop-services} (@pxref{Desktop
  13163. Services}).
  13164. @end defvr
  13165. @deftp {Data Type} modem-manager-configuration
  13166. Data type representing the configuration of ModemManager.
  13167. @table @asis
  13168. @item @code{modem-manager} (default: @code{modem-manager})
  13169. The ModemManager package to use.
  13170. @end table
  13171. @end deftp
  13172. @cindex USB_ModeSwitch
  13173. @cindex Modeswitching
  13174. @defvr {Scheme Variable} usb-modeswitch-service-type
  13175. This is the service type for the
  13176. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  13177. service. The value for this service type is
  13178. a @code{usb-modeswitch-configuration} record.
  13179. When plugged in, some USB modems (and other USB devices) initially present
  13180. themselves as a read-only storage medium and not as a modem. They need to be
  13181. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  13182. installs udev rules to automatically modeswitch these devices when they are
  13183. plugged in.
  13184. This service is part of @code{%desktop-services} (@pxref{Desktop
  13185. Services}).
  13186. @end defvr
  13187. @deftp {Data Type} usb-modeswitch-configuration
  13188. Data type representing the configuration of USB_ModeSwitch.
  13189. @table @asis
  13190. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  13191. The USB_ModeSwitch package providing the binaries for modeswitching.
  13192. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  13193. The package providing the device data and udev rules file used by
  13194. USB_ModeSwitch.
  13195. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  13196. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  13197. config file shipped with USB_ModeSwitch is used which disables logging to
  13198. @file{/var/log} among other default settings. If set to @code{#f}, no config
  13199. file is used.
  13200. @end table
  13201. @end deftp
  13202. @cindex NetworkManager
  13203. @defvr {Scheme Variable} network-manager-service-type
  13204. This is the service type for the
  13205. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  13206. service. The value for this service type is a
  13207. @code{network-manager-configuration} record.
  13208. This service is part of @code{%desktop-services} (@pxref{Desktop
  13209. Services}).
  13210. @end defvr
  13211. @deftp {Data Type} network-manager-configuration
  13212. Data type representing the configuration of NetworkManager.
  13213. @table @asis
  13214. @item @code{network-manager} (default: @code{network-manager})
  13215. The NetworkManager package to use.
  13216. @item @code{dns} (default: @code{"default"})
  13217. Processing mode for DNS, which affects how NetworkManager uses the
  13218. @code{resolv.conf} configuration file.
  13219. @table @samp
  13220. @item default
  13221. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  13222. provided by currently active connections.
  13223. @item dnsmasq
  13224. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  13225. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  13226. then update @code{resolv.conf} to point to the local nameserver.
  13227. With this setting, you can share your network connection. For example when
  13228. you want to share your network connection to another laptop @i{via} an
  13229. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  13230. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  13231. and reestablish the connection (or reboot).
  13232. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  13233. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  13234. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  13235. browser on your host system, or connect to the VM @i{via} SSH
  13236. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  13237. host-to-guest connection, run this command once:
  13238. @example
  13239. nmcli connection add type tun \
  13240. connection.interface-name tap0 \
  13241. tun.mode tap tun.owner $(id -u) \
  13242. ipv4.method shared \
  13243. ipv4.addresses 172.28.112.1/24
  13244. @end example
  13245. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  13246. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  13247. @command{qemu-system-...}.
  13248. @item none
  13249. NetworkManager will not modify @code{resolv.conf}.
  13250. @end table
  13251. @item @code{vpn-plugins} (default: @code{'()})
  13252. This is the list of available plugins for virtual private networks
  13253. (VPNs). An example of this is the @code{network-manager-openvpn}
  13254. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  13255. @end table
  13256. @end deftp
  13257. @cindex Connman
  13258. @deffn {Scheme Variable} connman-service-type
  13259. This is the service type to run @url{https://01.org/connman,Connman},
  13260. a network connection manager.
  13261. Its value must be an
  13262. @code{connman-configuration} record as in this example:
  13263. @lisp
  13264. (service connman-service-type
  13265. (connman-configuration
  13266. (disable-vpn? #t)))
  13267. @end lisp
  13268. See below for details about @code{connman-configuration}.
  13269. @end deffn
  13270. @deftp {Data Type} connman-configuration
  13271. Data Type representing the configuration of connman.
  13272. @table @asis
  13273. @item @code{connman} (default: @var{connman})
  13274. The connman package to use.
  13275. @item @code{disable-vpn?} (default: @code{#f})
  13276. When true, disable connman's vpn plugin.
  13277. @end table
  13278. @end deftp
  13279. @cindex WPA Supplicant
  13280. @defvr {Scheme Variable} wpa-supplicant-service-type
  13281. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  13282. supplicant}, an authentication daemon required to authenticate against
  13283. encrypted WiFi or ethernet networks.
  13284. @end defvr
  13285. @deftp {Data Type} wpa-supplicant-configuration
  13286. Data type representing the configuration of WPA Supplicant.
  13287. It takes the following parameters:
  13288. @table @asis
  13289. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  13290. The WPA Supplicant package to use.
  13291. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  13292. List of services that should be started before WPA Supplicant starts.
  13293. @item @code{dbus?} (default: @code{#t})
  13294. Whether to listen for requests on D-Bus.
  13295. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  13296. Where to store the PID file.
  13297. @item @code{interface} (default: @code{#f})
  13298. If this is set, it must specify the name of a network interface that
  13299. WPA supplicant will control.
  13300. @item @code{config-file} (default: @code{#f})
  13301. Optional configuration file to use.
  13302. @item @code{extra-options} (default: @code{'()})
  13303. List of additional command-line arguments to pass to the daemon.
  13304. @end table
  13305. @end deftp
  13306. @cindex hostapd service, for Wi-Fi access points
  13307. @cindex Wi-Fi access points, hostapd service
  13308. @defvr {Scheme Variable} hostapd-service-type
  13309. This is the service type to run the @uref{https://w1.fi/hostapd/,
  13310. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  13311. authentication servers. Its associated value must be a
  13312. @code{hostapd-configuration} as shown below:
  13313. @lisp
  13314. ;; Use wlan1 to run the access point for "My Network".
  13315. (service hostapd-service-type
  13316. (hostapd-configuration
  13317. (interface "wlan1")
  13318. (ssid "My Network")
  13319. (channel 12)))
  13320. @end lisp
  13321. @end defvr
  13322. @deftp {Data Type} hostapd-configuration
  13323. This data type represents the configuration of the hostapd service, with
  13324. the following fields:
  13325. @table @asis
  13326. @item @code{package} (default: @code{hostapd})
  13327. The hostapd package to use.
  13328. @item @code{interface} (default: @code{"wlan0"})
  13329. The network interface to run the WiFi access point.
  13330. @item @code{ssid}
  13331. The SSID (@dfn{service set identifier}), a string that identifies this
  13332. network.
  13333. @item @code{broadcast-ssid?} (default: @code{#t})
  13334. Whether to broadcast this SSID.
  13335. @item @code{channel} (default: @code{1})
  13336. The WiFi channel to use.
  13337. @item @code{driver} (default: @code{"nl80211"})
  13338. The driver interface type. @code{"nl80211"} is used with all Linux
  13339. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  13340. RADIUS server that does # not control any wireless/wired driver.
  13341. @item @code{extra-settings} (default: @code{""})
  13342. Extra settings to append as-is to the hostapd configuration file. See
  13343. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  13344. configuration file reference.
  13345. @end table
  13346. @end deftp
  13347. @defvr {Scheme Variable} simulated-wifi-service-type
  13348. This is the type of a service to simulate WiFi networking, which can be
  13349. useful in virtual machines for testing purposes. The service loads the
  13350. Linux kernel
  13351. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  13352. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  13353. network that can be seen on @code{wlan0}, by default.
  13354. The service's value is a @code{hostapd-configuration} record.
  13355. @end defvr
  13356. @cindex iptables
  13357. @defvr {Scheme Variable} iptables-service-type
  13358. This is the service type to set up an iptables configuration. iptables is a
  13359. packet filtering framework supported by the Linux kernel. This service
  13360. supports configuring iptables for both IPv4 and IPv6. A simple example
  13361. configuration rejecting all incoming connections except those to the ssh port
  13362. 22 is shown below.
  13363. @lisp
  13364. (service iptables-service-type
  13365. (iptables-configuration
  13366. (ipv4-rules (plain-file "iptables.rules" "*filter
  13367. :INPUT ACCEPT
  13368. :FORWARD ACCEPT
  13369. :OUTPUT ACCEPT
  13370. -A INPUT -p tcp --dport 22 -j ACCEPT
  13371. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  13372. COMMIT
  13373. "))
  13374. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  13375. :INPUT ACCEPT
  13376. :FORWARD ACCEPT
  13377. :OUTPUT ACCEPT
  13378. -A INPUT -p tcp --dport 22 -j ACCEPT
  13379. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  13380. COMMIT
  13381. "))))
  13382. @end lisp
  13383. @end defvr
  13384. @deftp {Data Type} iptables-configuration
  13385. The data type representing the configuration of iptables.
  13386. @table @asis
  13387. @item @code{iptables} (default: @code{iptables})
  13388. The iptables package that provides @code{iptables-restore} and
  13389. @code{ip6tables-restore}.
  13390. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  13391. The iptables rules to use. It will be passed to @code{iptables-restore}.
  13392. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13393. objects}).
  13394. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  13395. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  13396. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13397. objects}).
  13398. @end table
  13399. @end deftp
  13400. @cindex nftables
  13401. @defvr {Scheme Variable} nftables-service-type
  13402. This is the service type to set up a nftables configuration. nftables is a
  13403. netfilter project that aims to replace the existing iptables, ip6tables,
  13404. arptables and ebtables framework. It provides a new packet filtering
  13405. framework, a new user-space utility @command{nft}, and a compatibility layer
  13406. for iptables. This service comes with a default ruleset
  13407. @code{%default-nftables-ruleset} that rejecting all incoming connections
  13408. except those to the ssh port 22. To use it, simply write:
  13409. @lisp
  13410. (service nftables-service-type)
  13411. @end lisp
  13412. @end defvr
  13413. @deftp {Data Type} nftables-configuration
  13414. The data type representing the configuration of nftables.
  13415. @table @asis
  13416. @item @code{package} (default: @code{nftables})
  13417. The nftables package that provides @command{nft}.
  13418. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  13419. The nftables ruleset to use. This may be any ``file-like'' object
  13420. (@pxref{G-Expressions, file-like objects}).
  13421. @end table
  13422. @end deftp
  13423. @cindex NTP (Network Time Protocol), service
  13424. @cindex ntpd, service for the Network Time Protocol daemon
  13425. @cindex real time clock
  13426. @defvr {Scheme Variable} ntp-service-type
  13427. This is the type of the service running the @uref{https://www.ntp.org,
  13428. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  13429. system clock synchronized with that of the specified NTP servers.
  13430. The value of this service is an @code{ntpd-configuration} object, as described
  13431. below.
  13432. @end defvr
  13433. @deftp {Data Type} ntp-configuration
  13434. This is the data type for the NTP service configuration.
  13435. @table @asis
  13436. @item @code{servers} (default: @code{%ntp-servers})
  13437. This is the list of servers (@code{<ntp-server>} records) with which
  13438. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  13439. definition below.
  13440. @item @code{allow-large-adjustment?} (default: @code{#t})
  13441. This determines whether @command{ntpd} is allowed to make an initial
  13442. adjustment of more than 1,000 seconds.
  13443. @item @code{ntp} (default: @code{ntp})
  13444. The NTP package to use.
  13445. @end table
  13446. @end deftp
  13447. @defvr {Scheme Variable} %ntp-servers
  13448. List of host names used as the default NTP servers. These are servers of the
  13449. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  13450. @end defvr
  13451. @deftp {Data Type} ntp-server
  13452. The data type representing the configuration of a NTP server.
  13453. @table @asis
  13454. @item @code{type} (default: @code{'server})
  13455. The type of the NTP server, given as a symbol. One of @code{'pool},
  13456. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  13457. @item @code{address}
  13458. The address of the server, as a string.
  13459. @item @code{options}
  13460. NTPD options to use with that specific server, given as a list of option names
  13461. and/or of option names and values tuples. The following example define a server
  13462. to use with the options @option{iburst} and @option{prefer}, as well as
  13463. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  13464. @example
  13465. (ntp-server
  13466. (type 'server)
  13467. (address "some.ntp.server.org")
  13468. (options `(iburst (version 3) (maxpoll 16) prefer))))
  13469. @end example
  13470. @end table
  13471. @end deftp
  13472. @cindex OpenNTPD
  13473. @deffn {Scheme Procedure} openntpd-service-type
  13474. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  13475. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  13476. clock synchronized with that of the given servers.
  13477. @lisp
  13478. (service
  13479. openntpd-service-type
  13480. (openntpd-configuration
  13481. (listen-on '("127.0.0.1" "::1"))
  13482. (sensor '("udcf0 correction 70000"))
  13483. (constraint-from '("www.gnu.org"))
  13484. (constraints-from '("https://www.google.com/"))))
  13485. @end lisp
  13486. @end deffn
  13487. @defvr {Scheme Variable} %openntpd-servers
  13488. This variable is a list of the server addresses defined in
  13489. @code{%ntp-servers}.
  13490. @end defvr
  13491. @deftp {Data Type} openntpd-configuration
  13492. @table @asis
  13493. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  13494. The openntpd executable to use.
  13495. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  13496. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  13497. @item @code{query-from} (default: @code{'()})
  13498. A list of local IP address the ntpd daemon should use for outgoing queries.
  13499. @item @code{sensor} (default: @code{'()})
  13500. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  13501. will listen to each sensor that actually exists and ignore non-existent ones.
  13502. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  13503. information.
  13504. @item @code{server} (default: @code{'()})
  13505. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  13506. @item @code{servers} (default: @code{%openntp-servers})
  13507. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  13508. @item @code{constraint-from} (default: @code{'()})
  13509. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  13510. This time information is not used for precision but acts as an authenticated
  13511. constraint, thereby reducing the impact of unauthenticated NTP
  13512. man-in-the-middle attacks.
  13513. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  13514. a constraint.
  13515. @item @code{constraints-from} (default: @code{'()})
  13516. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  13517. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  13518. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  13519. @end table
  13520. @end deftp
  13521. @cindex inetd
  13522. @deffn {Scheme variable} inetd-service-type
  13523. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  13524. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  13525. connections on internet sockets, and lazily starts the specified server
  13526. program when a connection is made on one of these sockets.
  13527. The value of this service is an @code{inetd-configuration} object. The
  13528. following example configures the @command{inetd} daemon to provide the
  13529. built-in @command{echo} service, as well as an smtp service which
  13530. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  13531. gateway @code{hostname}:
  13532. @lisp
  13533. (service
  13534. inetd-service-type
  13535. (inetd-configuration
  13536. (entries (list
  13537. (inetd-entry
  13538. (name "echo")
  13539. (socket-type 'stream)
  13540. (protocol "tcp")
  13541. (wait? #f)
  13542. (user "root"))
  13543. (inetd-entry
  13544. (node "127.0.0.1")
  13545. (name "smtp")
  13546. (socket-type 'stream)
  13547. (protocol "tcp")
  13548. (wait? #f)
  13549. (user "root")
  13550. (program (file-append openssh "/bin/ssh"))
  13551. (arguments
  13552. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  13553. "-W" "smtp-server:25" "user@@hostname")))))))
  13554. @end lisp
  13555. See below for more details about @code{inetd-configuration}.
  13556. @end deffn
  13557. @deftp {Data Type} inetd-configuration
  13558. Data type representing the configuration of @command{inetd}.
  13559. @table @asis
  13560. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  13561. The @command{inetd} executable to use.
  13562. @item @code{entries} (default: @code{'()})
  13563. A list of @command{inetd} service entries. Each entry should be created
  13564. by the @code{inetd-entry} constructor.
  13565. @end table
  13566. @end deftp
  13567. @deftp {Data Type} inetd-entry
  13568. Data type representing an entry in the @command{inetd} configuration.
  13569. Each entry corresponds to a socket where @command{inetd} will listen for
  13570. requests.
  13571. @table @asis
  13572. @item @code{node} (default: @code{#f})
  13573. Optional string, a comma-separated list of local addresses
  13574. @command{inetd} should use when listening for this service.
  13575. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  13576. description of all options.
  13577. @item @code{name}
  13578. A string, the name must correspond to an entry in @code{/etc/services}.
  13579. @item @code{socket-type}
  13580. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  13581. @code{'seqpacket}.
  13582. @item @code{protocol}
  13583. A string, must correspond to an entry in @code{/etc/protocols}.
  13584. @item @code{wait?} (default: @code{#t})
  13585. Whether @command{inetd} should wait for the server to exit before
  13586. listening to new service requests.
  13587. @item @code{user}
  13588. A string containing the user (and, optionally, group) name of the user
  13589. as whom the server should run. The group name can be specified in a
  13590. suffix, separated by a colon or period, i.e.@: @code{"user"},
  13591. @code{"user:group"} or @code{"user.group"}.
  13592. @item @code{program} (default: @code{"internal"})
  13593. The server program which will serve the requests, or @code{"internal"}
  13594. if @command{inetd} should use a built-in service.
  13595. @item @code{arguments} (default: @code{'()})
  13596. A list strings or file-like objects, which are the server program's
  13597. arguments, starting with the zeroth argument, i.e.@: the name of the
  13598. program itself. For @command{inetd}'s internal services, this entry
  13599. must be @code{'()} or @code{'("internal")}.
  13600. @end table
  13601. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  13602. detailed discussion of each configuration field.
  13603. @end deftp
  13604. @cindex Tor
  13605. @defvr {Scheme Variable} tor-service-type
  13606. This is the type for a service that runs the @uref{https://torproject.org,
  13607. Tor} anonymous networking daemon. The service is configured using a
  13608. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  13609. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  13610. @end defvr
  13611. @deftp {Data Type} tor-configuration
  13612. @table @asis
  13613. @item @code{tor} (default: @code{tor})
  13614. The package that provides the Tor daemon. This package is expected to provide
  13615. the daemon at @file{bin/tor} relative to its output directory. The default
  13616. package is the @uref{https://www.torproject.org, Tor Project's}
  13617. implementation.
  13618. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  13619. The configuration file to use. It will be appended to a default configuration
  13620. file, and the final configuration file will be passed to @code{tor} via its
  13621. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  13622. file-like objects}). See @code{man tor} for details on the configuration file
  13623. syntax.
  13624. @item @code{hidden-services} (default: @code{'()})
  13625. The list of @code{<hidden-service>} records to use. For any hidden service
  13626. you include in this list, appropriate configuration to enable the hidden
  13627. service will be automatically added to the default configuration file. You
  13628. may conveniently create @code{<hidden-service>} records using the
  13629. @code{tor-hidden-service} procedure described below.
  13630. @item @code{socks-socket-type} (default: @code{'tcp})
  13631. The default socket type that Tor should use for its SOCKS socket. This must
  13632. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  13633. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  13634. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  13635. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  13636. @code{tor} group.
  13637. If you want to customize the SOCKS socket in more detail, leave
  13638. @code{socks-socket-type} at its default value of @code{'tcp} and use
  13639. @code{config-file} to override the default by providing your own
  13640. @code{SocksPort} option.
  13641. @item @code{control-socket?} (default: @code{#f})
  13642. Whether or not to provide a ``control socket'' by which Tor can be
  13643. controlled to, for instance, dynamically instantiate tor onion services.
  13644. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  13645. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  13646. @code{tor} group.
  13647. @end table
  13648. @end deftp
  13649. @cindex hidden service
  13650. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  13651. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  13652. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  13653. @example
  13654. '((22 "127.0.0.1:22")
  13655. (80 "127.0.0.1:8080"))
  13656. @end example
  13657. In this example, port 22 of the hidden service is mapped to local port 22, and
  13658. port 80 is mapped to local port 8080.
  13659. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  13660. the @file{hostname} file contains the @code{.onion} host name for the hidden
  13661. service.
  13662. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  13663. project's documentation} for more information.
  13664. @end deffn
  13665. The @code{(gnu services rsync)} module provides the following services:
  13666. You might want an rsync daemon if you have files that you want available
  13667. so anyone (or just yourself) can download existing files or upload new
  13668. files.
  13669. @deffn {Scheme Variable} rsync-service-type
  13670. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  13671. The value for this service type is a
  13672. @command{rsync-configuration} record as in this example:
  13673. @lisp
  13674. (service rsync-service-type)
  13675. @end lisp
  13676. See below for details about @code{rsync-configuration}.
  13677. @end deffn
  13678. @deftp {Data Type} rsync-configuration
  13679. Data type representing the configuration for @code{rsync-service}.
  13680. @table @asis
  13681. @item @code{package} (default: @var{rsync})
  13682. @code{rsync} package to use.
  13683. @item @code{port-number} (default: @code{873})
  13684. TCP port on which @command{rsync} listens for incoming connections. If port
  13685. is less than @code{1024} @command{rsync} needs to be started as the
  13686. @code{root} user and group.
  13687. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  13688. Name of the file where @command{rsync} writes its PID.
  13689. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  13690. Name of the file where @command{rsync} writes its lock file.
  13691. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  13692. Name of the file where @command{rsync} writes its log file.
  13693. @item @code{use-chroot?} (default: @var{#t})
  13694. Whether to use chroot for @command{rsync} shared directory.
  13695. @item @code{share-path} (default: @file{/srv/rsync})
  13696. Location of the @command{rsync} shared directory.
  13697. @item @code{share-comment} (default: @code{"Rsync share"})
  13698. Comment of the @command{rsync} shared directory.
  13699. @item @code{read-only?} (default: @var{#f})
  13700. Read-write permissions to shared directory.
  13701. @item @code{timeout} (default: @code{300})
  13702. I/O timeout in seconds.
  13703. @item @code{user} (default: @var{"root"})
  13704. Owner of the @code{rsync} process.
  13705. @item @code{group} (default: @var{"root"})
  13706. Group of the @code{rsync} process.
  13707. @item @code{uid} (default: @var{"rsyncd"})
  13708. User name or user ID that file transfers to and from that module should take
  13709. place as when the daemon was run as @code{root}.
  13710. @item @code{gid} (default: @var{"rsyncd"})
  13711. Group name or group ID that will be used when accessing the module.
  13712. @end table
  13713. @end deftp
  13714. The @code{(gnu services syncthing)} module provides the following services:
  13715. @cindex syncthing
  13716. You might want a syncthing daemon if you have files between two or more
  13717. computers and want to sync them in real time, safely protected from
  13718. prying eyes.
  13719. @deffn {Scheme Variable} syncthing-service-type
  13720. This is the service type for the @uref{https://syncthing.net/,
  13721. syncthing} daemon, The value for this service type is a
  13722. @command{syncthing-configuration} record as in this example:
  13723. @lisp
  13724. (service syncthing-service-type
  13725. (syncthing-configuration (user "alice")))
  13726. @end lisp
  13727. See below for details about @code{syncthing-configuration}.
  13728. @deftp {Data Type} syncthing-configuration
  13729. Data type representing the configuration for @code{syncthing-service-type}.
  13730. @table @asis
  13731. @item @code{syncthing} (default: @var{syncthing})
  13732. @code{syncthing} package to use.
  13733. @item @code{arguments} (default: @var{'()})
  13734. List of command-line arguments passing to @code{syncthing} binary.
  13735. @item @code{logflags} (default: @var{0})
  13736. Sum of logging flags, see
  13737. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  13738. @item @code{user} (default: @var{#f})
  13739. The user as which the Syncthing service is to be run.
  13740. This assumes that the specified user exists.
  13741. @item @code{group} (default: @var{"users"})
  13742. The group as which the Syncthing service is to be run.
  13743. This assumes that the specified group exists.
  13744. @item @code{home} (default: @var{#f})
  13745. Common configuration and data directory. The default configuration
  13746. directory is @file{$HOME} of the specified Syncthing @code{user}.
  13747. @end table
  13748. @end deftp
  13749. @end deffn
  13750. Furthermore, @code{(gnu services ssh)} provides the following services.
  13751. @cindex SSH
  13752. @cindex SSH server
  13753. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  13754. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  13755. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  13756. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  13757. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  13758. [#:public-key-authentication? #t] [#:initialize? #t]
  13759. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  13760. @var{host-key} must designate a file containing the host key, and readable
  13761. only by root.
  13762. When @var{daemonic?} is true, @command{lshd} will detach from the
  13763. controlling terminal and log its output to syslogd, unless one sets
  13764. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  13765. depend on existence of syslogd service. When @var{pid-file?} is true,
  13766. @command{lshd} writes its PID to the file called @var{pid-file}.
  13767. When @var{initialize?} is true, automatically create the seed and host key
  13768. upon service activation if they do not exist yet. This may take long and
  13769. require interaction.
  13770. When @var{initialize?} is false, it is up to the user to initialize the
  13771. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  13772. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  13773. basics,,, lsh, LSH Manual}).
  13774. When @var{interfaces} is empty, lshd listens for connections on all the
  13775. network interfaces; otherwise, @var{interfaces} must be a list of host names
  13776. or addresses.
  13777. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  13778. passwords, and @var{root-login?} specifies whether to accept log-ins as
  13779. root.
  13780. The other options should be self-descriptive.
  13781. @end deffn
  13782. @cindex SSH
  13783. @cindex SSH server
  13784. @deffn {Scheme Variable} openssh-service-type
  13785. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  13786. shell daemon, @command{sshd}. Its value must be an
  13787. @code{openssh-configuration} record as in this example:
  13788. @lisp
  13789. (service openssh-service-type
  13790. (openssh-configuration
  13791. (x11-forwarding? #t)
  13792. (permit-root-login 'without-password)
  13793. (authorized-keys
  13794. `(("alice" ,(local-file "alice.pub"))
  13795. ("bob" ,(local-file "bob.pub"))))))
  13796. @end lisp
  13797. See below for details about @code{openssh-configuration}.
  13798. This service can be extended with extra authorized keys, as in this
  13799. example:
  13800. @lisp
  13801. (service-extension openssh-service-type
  13802. (const `(("charlie"
  13803. ,(local-file "charlie.pub")))))
  13804. @end lisp
  13805. @end deffn
  13806. @deftp {Data Type} openssh-configuration
  13807. This is the configuration record for OpenSSH's @command{sshd}.
  13808. @table @asis
  13809. @item @code{openssh} (default @var{openssh})
  13810. The Openssh package to use.
  13811. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  13812. Name of the file where @command{sshd} writes its PID.
  13813. @item @code{port-number} (default: @code{22})
  13814. TCP port on which @command{sshd} listens for incoming connections.
  13815. @item @code{permit-root-login} (default: @code{#f})
  13816. This field determines whether and when to allow logins as root. If
  13817. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  13818. If it's the symbol @code{'without-password}, then root logins are
  13819. permitted but not with password-based authentication.
  13820. @item @code{allow-empty-passwords?} (default: @code{#f})
  13821. When true, users with empty passwords may log in. When false, they may
  13822. not.
  13823. @item @code{password-authentication?} (default: @code{#t})
  13824. When true, users may log in with their password. When false, they have
  13825. other authentication methods.
  13826. @item @code{public-key-authentication?} (default: @code{#t})
  13827. When true, users may log in using public key authentication. When
  13828. false, users have to use other authentication method.
  13829. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  13830. This is used only by protocol version 2.
  13831. @item @code{x11-forwarding?} (default: @code{#f})
  13832. When true, forwarding of X11 graphical client connections is
  13833. enabled---in other words, @command{ssh} options @option{-X} and
  13834. @option{-Y} will work.
  13835. @item @code{allow-agent-forwarding?} (default: @code{#t})
  13836. Whether to allow agent forwarding.
  13837. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  13838. Whether to allow TCP forwarding.
  13839. @item @code{gateway-ports?} (default: @code{#f})
  13840. Whether to allow gateway ports.
  13841. @item @code{challenge-response-authentication?} (default: @code{#f})
  13842. Specifies whether challenge response authentication is allowed (e.g.@: via
  13843. PAM).
  13844. @item @code{use-pam?} (default: @code{#t})
  13845. Enables the Pluggable Authentication Module interface. If set to
  13846. @code{#t}, this will enable PAM authentication using
  13847. @code{challenge-response-authentication?} and
  13848. @code{password-authentication?}, in addition to PAM account and session
  13849. module processing for all authentication types.
  13850. Because PAM challenge response authentication usually serves an
  13851. equivalent role to password authentication, you should disable either
  13852. @code{challenge-response-authentication?} or
  13853. @code{password-authentication?}.
  13854. @item @code{print-last-log?} (default: @code{#t})
  13855. Specifies whether @command{sshd} should print the date and time of the
  13856. last user login when a user logs in interactively.
  13857. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  13858. Configures external subsystems (e.g.@: file transfer daemon).
  13859. This is a list of two-element lists, each of which containing the
  13860. subsystem name and a command (with optional arguments) to execute upon
  13861. subsystem request.
  13862. The command @command{internal-sftp} implements an in-process SFTP
  13863. server. Alternatively, one can specify the @command{sftp-server} command:
  13864. @lisp
  13865. (service openssh-service-type
  13866. (openssh-configuration
  13867. (subsystems
  13868. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  13869. @end lisp
  13870. @item @code{accepted-environment} (default: @code{'()})
  13871. List of strings describing which environment variables may be exported.
  13872. Each string gets on its own line. See the @code{AcceptEnv} option in
  13873. @code{man sshd_config}.
  13874. This example allows ssh-clients to export the @env{COLORTERM} variable.
  13875. It is set by terminal emulators, which support colors. You can use it in
  13876. your shell's resource file to enable colors for the prompt and commands
  13877. if this variable is set.
  13878. @lisp
  13879. (service openssh-service-type
  13880. (openssh-configuration
  13881. (accepted-environment '("COLORTERM"))))
  13882. @end lisp
  13883. @item @code{authorized-keys} (default: @code{'()})
  13884. @cindex authorized keys, SSH
  13885. @cindex SSH authorized keys
  13886. This is the list of authorized keys. Each element of the list is a user
  13887. name followed by one or more file-like objects that represent SSH public
  13888. keys. For example:
  13889. @lisp
  13890. (openssh-configuration
  13891. (authorized-keys
  13892. `(("rekado" ,(local-file "rekado.pub"))
  13893. ("chris" ,(local-file "chris.pub"))
  13894. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  13895. @end lisp
  13896. @noindent
  13897. registers the specified public keys for user accounts @code{rekado},
  13898. @code{chris}, and @code{root}.
  13899. Additional authorized keys can be specified @i{via}
  13900. @code{service-extension}.
  13901. Note that this does @emph{not} interfere with the use of
  13902. @file{~/.ssh/authorized_keys}.
  13903. @item @code{log-level} (default: @code{'info})
  13904. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  13905. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  13906. page for @file{sshd_config} for the full list of level names.
  13907. @item @code{extra-content} (default: @code{""})
  13908. This field can be used to append arbitrary text to the configuration file. It
  13909. is especially useful for elaborate configurations that cannot be expressed
  13910. otherwise. This configuration, for example, would generally disable root
  13911. logins, but permit them from one specific IP address:
  13912. @lisp
  13913. (openssh-configuration
  13914. (extra-content "\
  13915. Match Address 192.168.0.1
  13916. PermitRootLogin yes"))
  13917. @end lisp
  13918. @end table
  13919. @end deftp
  13920. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  13921. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  13922. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  13923. object.
  13924. For example, to specify a Dropbear service listening on port 1234, add
  13925. this call to the operating system's @code{services} field:
  13926. @lisp
  13927. (dropbear-service (dropbear-configuration
  13928. (port-number 1234)))
  13929. @end lisp
  13930. @end deffn
  13931. @deftp {Data Type} dropbear-configuration
  13932. This data type represents the configuration of a Dropbear SSH daemon.
  13933. @table @asis
  13934. @item @code{dropbear} (default: @var{dropbear})
  13935. The Dropbear package to use.
  13936. @item @code{port-number} (default: 22)
  13937. The TCP port where the daemon waits for incoming connections.
  13938. @item @code{syslog-output?} (default: @code{#t})
  13939. Whether to enable syslog output.
  13940. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  13941. File name of the daemon's PID file.
  13942. @item @code{root-login?} (default: @code{#f})
  13943. Whether to allow @code{root} logins.
  13944. @item @code{allow-empty-passwords?} (default: @code{#f})
  13945. Whether to allow empty passwords.
  13946. @item @code{password-authentication?} (default: @code{#t})
  13947. Whether to enable password-based authentication.
  13948. @end table
  13949. @end deftp
  13950. @cindex AutoSSH
  13951. @deffn {Scheme Variable} autossh-service-type
  13952. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  13953. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  13954. restarting it as necessary should it die or stop passing traffic.
  13955. AutoSSH can be run manually from the command-line by passing arguments
  13956. to the binary @command{autossh} from the package @code{autossh}, but it
  13957. can also be run as a Guix service. This latter use case is documented
  13958. here.
  13959. AutoSSH can be used to forward local traffic to a remote machine using
  13960. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  13961. is run as.
  13962. For example, to specify a service running autossh as the user
  13963. @code{pino} and forwarding all local connections to port @code{8081} to
  13964. @code{remote:8081} using an SSH tunnel, add this call to the operating
  13965. system's @code{services} field:
  13966. @lisp
  13967. (service autossh-service-type
  13968. (autossh-configuration
  13969. (user "pino")
  13970. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  13971. @end lisp
  13972. @end deffn
  13973. @deftp {Data Type} autossh-configuration
  13974. This data type represents the configuration of an AutoSSH service.
  13975. @table @asis
  13976. @item @code{user} (default @code{"autossh"})
  13977. The user as which the AutoSSH service is to be run.
  13978. This assumes that the specified user exists.
  13979. @item @code{poll} (default @code{600})
  13980. Specifies the connection poll time in seconds.
  13981. @item @code{first-poll} (default @code{#f})
  13982. Specifies how many seconds AutoSSH waits before the first connection
  13983. test. After this first test, polling is resumed at the pace defined in
  13984. @code{poll}. When set to @code{#f}, the first poll is not treated
  13985. specially and will also use the connection poll specified in
  13986. @code{poll}.
  13987. @item @code{gate-time} (default @code{30})
  13988. Specifies how many seconds an SSH connection must be active before it is
  13989. considered successful.
  13990. @item @code{log-level} (default @code{1})
  13991. The log level, corresponding to the levels used by syslog---so @code{0}
  13992. is the most silent while @code{7} is the chattiest.
  13993. @item @code{max-start} (default @code{#f})
  13994. The maximum number of times SSH may be (re)started before AutoSSH exits.
  13995. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  13996. @item @code{message} (default @code{""})
  13997. The message to append to the echo message sent when testing connections.
  13998. @item @code{port} (default @code{"0"})
  13999. The ports used for monitoring the connection. When set to @code{"0"},
  14000. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  14001. a positive integer, ports @var{n} and @var{n}+1 are used for
  14002. monitoring the connection, such that port @var{n} is the base
  14003. monitoring port and @code{n+1} is the echo port. When set to
  14004. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  14005. integers, the ports @var{n} and @var{m} are used for monitoring the
  14006. connection, such that port @var{n} is the base monitoring port and
  14007. @var{m} is the echo port.
  14008. @item @code{ssh-options} (default @code{'()})
  14009. The list of command-line arguments to pass to @command{ssh} when it is
  14010. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  14011. may cause undefined behaviour.
  14012. @end table
  14013. @end deftp
  14014. @cindex WebSSH
  14015. @deffn {Scheme Variable} webssh-service-type
  14016. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  14017. program that runs a web SSH client. WebSSH can be run manually from the
  14018. command-line by passing arguments to the binary @command{wssh} from the
  14019. package @code{webssh}, but it can also be run as a Guix service. This
  14020. latter use case is documented here.
  14021. For example, to specify a service running WebSSH on loopback interface
  14022. on port @code{8888} with reject policy with a list of allowed to
  14023. connection hosts, and NGINX as a reverse-proxy to this service listening
  14024. for HTTPS connection, add this call to the operating system's
  14025. @code{services} field:
  14026. @lisp
  14027. (service webssh-service-type
  14028. (webssh-configuration (address "127.0.0.1")
  14029. (port 8888)
  14030. (policy 'reject)
  14031. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  14032. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  14033. (service nginx-service-type
  14034. (nginx-configuration
  14035. (server-blocks
  14036. (list
  14037. (nginx-server-configuration
  14038. (inherit %webssh-configuration-nginx)
  14039. (server-name '("webssh.example.com"))
  14040. (listen '("443 ssl"))
  14041. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  14042. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  14043. (locations
  14044. (cons (nginx-location-configuration
  14045. (uri "/.well-known")
  14046. (body '("root /var/www;")))
  14047. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  14048. @end lisp
  14049. @end deffn
  14050. @deftp {Data Type} webssh-configuration
  14051. Data type representing the configuration for @code{webssh-service}.
  14052. @table @asis
  14053. @item @code{package} (default: @var{webssh})
  14054. @code{webssh} package to use.
  14055. @item @code{user-name} (default: @var{"webssh"})
  14056. User name or user ID that file transfers to and from that module should take
  14057. place.
  14058. @item @code{group-name} (default: @var{"webssh"})
  14059. Group name or group ID that will be used when accessing the module.
  14060. @item @code{address} (default: @var{#f})
  14061. IP address on which @command{webssh} listens for incoming connections.
  14062. @item @code{port} (default: @var{8888})
  14063. TCP port on which @command{webssh} listens for incoming connections.
  14064. @item @code{policy} (default: @var{#f})
  14065. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  14066. @item @code{known-hosts} (default: @var{'()})
  14067. List of hosts which allowed for SSH connection from @command{webssh}.
  14068. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  14069. Name of the file where @command{webssh} writes its log file.
  14070. @item @code{log-level} (default: @var{#f})
  14071. Logging level.
  14072. @end table
  14073. @end deftp
  14074. @defvr {Scheme Variable} %facebook-host-aliases
  14075. This variable contains a string for use in @file{/etc/hosts}
  14076. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  14077. line contains a entry that maps a known server name of the Facebook
  14078. on-line service---e.g., @code{www.facebook.com}---to the local
  14079. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  14080. This variable is typically used in the @code{hosts-file} field of an
  14081. @code{operating-system} declaration (@pxref{operating-system Reference,
  14082. @file{/etc/hosts}}):
  14083. @lisp
  14084. (use-modules (gnu) (guix))
  14085. (operating-system
  14086. (host-name "mymachine")
  14087. ;; ...
  14088. (hosts-file
  14089. ;; Create a /etc/hosts file with aliases for "localhost"
  14090. ;; and "mymachine", as well as for Facebook servers.
  14091. (plain-file "hosts"
  14092. (string-append (local-host-aliases host-name)
  14093. %facebook-host-aliases))))
  14094. @end lisp
  14095. This mechanism can prevent programs running locally, such as Web
  14096. browsers, from accessing Facebook.
  14097. @end defvr
  14098. The @code{(gnu services avahi)} provides the following definition.
  14099. @defvr {Scheme Variable} avahi-service-type
  14100. This is the service that runs @command{avahi-daemon}, a system-wide
  14101. mDNS/DNS-SD responder that allows for service discovery and
  14102. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  14103. Its value must be an @code{avahi-configuration} record---see below.
  14104. This service extends the name service cache daemon (nscd) so that it can
  14105. resolve @code{.local} host names using
  14106. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  14107. Service Switch}, for information on host name resolution.
  14108. Additionally, add the @var{avahi} package to the system profile so that
  14109. commands such as @command{avahi-browse} are directly usable.
  14110. @end defvr
  14111. @deftp {Data Type} avahi-configuration
  14112. Data type representation the configuration for Avahi.
  14113. @table @asis
  14114. @item @code{host-name} (default: @code{#f})
  14115. If different from @code{#f}, use that as the host name to
  14116. publish for this machine; otherwise, use the machine's actual host name.
  14117. @item @code{publish?} (default: @code{#t})
  14118. When true, allow host names and services to be published (broadcast) over the
  14119. network.
  14120. @item @code{publish-workstation?} (default: @code{#t})
  14121. When true, @command{avahi-daemon} publishes the machine's host name and IP
  14122. address via mDNS on the local network. To view the host names published on
  14123. your local network, you can run:
  14124. @example
  14125. avahi-browse _workstation._tcp
  14126. @end example
  14127. @item @code{wide-area?} (default: @code{#f})
  14128. When true, DNS-SD over unicast DNS is enabled.
  14129. @item @code{ipv4?} (default: @code{#t})
  14130. @itemx @code{ipv6?} (default: @code{#t})
  14131. These fields determine whether to use IPv4/IPv6 sockets.
  14132. @item @code{domains-to-browse} (default: @code{'()})
  14133. This is a list of domains to browse.
  14134. @end table
  14135. @end deftp
  14136. @deffn {Scheme Variable} openvswitch-service-type
  14137. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  14138. service, whose value should be an @code{openvswitch-configuration}
  14139. object.
  14140. @end deffn
  14141. @deftp {Data Type} openvswitch-configuration
  14142. Data type representing the configuration of Open vSwitch, a multilayer
  14143. virtual switch which is designed to enable massive network automation
  14144. through programmatic extension.
  14145. @table @asis
  14146. @item @code{package} (default: @var{openvswitch})
  14147. Package object of the Open vSwitch.
  14148. @end table
  14149. @end deftp
  14150. @defvr {Scheme Variable} pagekite-service-type
  14151. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  14152. a tunneling solution for making localhost servers publicly visible, even from
  14153. behind restrictive firewalls or NAT without forwarded ports. The value for
  14154. this service type is a @code{pagekite-configuration} record.
  14155. Here's an example exposing the local HTTP and SSH daemons:
  14156. @lisp
  14157. (service pagekite-service-type
  14158. (pagekite-configuration
  14159. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  14160. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  14161. (extra-file "/etc/pagekite.rc")))
  14162. @end lisp
  14163. @end defvr
  14164. @deftp {Data Type} pagekite-configuration
  14165. Data type representing the configuration of PageKite.
  14166. @table @asis
  14167. @item @code{package} (default: @var{pagekite})
  14168. Package object of PageKite.
  14169. @item @code{kitename} (default: @code{#f})
  14170. PageKite name for authenticating to the frontend server.
  14171. @item @code{kitesecret} (default: @code{#f})
  14172. Shared secret for authenticating to the frontend server. You should probably
  14173. put this inside @code{extra-file} instead.
  14174. @item @code{frontend} (default: @code{#f})
  14175. Connect to the named PageKite frontend server instead of the
  14176. @uref{https://pagekite.net,,pagekite.net} service.
  14177. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  14178. List of service kites to use. Exposes HTTP on port 80 by default. The format
  14179. is @code{proto:kitename:host:port:secret}.
  14180. @item @code{extra-file} (default: @code{#f})
  14181. Extra configuration file to read, which you are expected to create manually.
  14182. Use this to add additional options and manage shared secrets out-of-band.
  14183. @end table
  14184. @end deftp
  14185. @defvr {Scheme Variable} yggdrasil-service-type
  14186. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  14187. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  14188. encrypted IPv6 network.
  14189. @quotation
  14190. Yggdrasil provides name-independent routing with cryptographically generated
  14191. addresses. Static addressing means you can keep the same address as long as
  14192. you want, even if you move to a new location, or generate a new address (by
  14193. generating new keys) whenever you want.
  14194. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  14195. @end quotation
  14196. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  14197. peers and/or local peers.
  14198. Here is an example using public peers and a static address. The static
  14199. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  14200. (the default value for @code{config-file}).
  14201. @lisp
  14202. ;; part of the operating-system declaration
  14203. (service yggdrasil-service-type
  14204. (yggdrasil-configuration
  14205. (autoconf? #f) ;; use only the public peers
  14206. (json-config
  14207. ;; choose one from
  14208. ;; https://github.com/yggdrasil-network/public-peers
  14209. '((peers . #("tcp://1.2.3.4:1337"))))
  14210. ;; /etc/yggdrasil-private.conf is the default value for config-file
  14211. ))
  14212. @end lisp
  14213. @example
  14214. # sample content for /etc/yggdrasil-private.conf
  14215. @{
  14216. # Your public encryption key. Your peers may ask you for this to put
  14217. # into their AllowedEncryptionPublicKeys configuration.
  14218. EncryptionPublicKey: 378dc5...
  14219. # Your private encryption key. DO NOT share this with anyone!
  14220. EncryptionPrivateKey: 0777...
  14221. # Your public signing key. You should not ordinarily need to share
  14222. # this with anyone.
  14223. SigningPublicKey: e1664...
  14224. # Your private signing key. DO NOT share this with anyone!
  14225. SigningPrivateKey: 0589d...
  14226. @}
  14227. @end example
  14228. @end defvr
  14229. @deftp {Data Type} yggdrasil-configuration
  14230. Data type representing the configuration of Yggdrasil.
  14231. @table @asis
  14232. @item @code{package} (default: @code{yggdrasil})
  14233. Package object of Yggdrasil.
  14234. @item @code{json-config} (default: @code{'()})
  14235. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  14236. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  14237. the Guix store, which is readable to all users. @strong{Do not store your
  14238. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  14239. quick overview of valid keys and their default values.
  14240. @item @code{autoconf?} (default: @code{#f})
  14241. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  14242. and peer with IPv6 neighbors.
  14243. @item @code{log-level} (default: @code{'info})
  14244. How much detail to include in logs. Use @code{'debug} for more detail.
  14245. @item @code{log-to} (default: @code{'stdout})
  14246. Where to send logs. By default, the service logs standard output to
  14247. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  14248. sends output to the running syslog service.
  14249. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  14250. What HJSON file to load sensitive data from. This is where private keys
  14251. should be stored, which are necessary to specify if you don't want a
  14252. randomized address after each restart. Use @code{#f} to disable. Options
  14253. defined in this file take precedence over @code{json-config}. Use the output
  14254. of @code{yggdrasil -genconf} as a starting point. To configure a static
  14255. address, delete everything except these options:
  14256. @itemize
  14257. @item @code{EncryptionPublicKey}
  14258. @item @code{EncryptionPrivateKey}
  14259. @item @code{SigningPublicKey}
  14260. @item @code{SigningPrivateKey}
  14261. @end itemize
  14262. @end table
  14263. @end deftp
  14264. @cindex IPFS
  14265. @defvr {Scheme Variable} ipfs-service-type
  14266. The service type for connecting to the @uref{https://ipfs.io,IPFS network},
  14267. a global, versioned, peer-to-peer file system. Pass it a
  14268. @code{ipfs-configuration} to change the ports used for the gateway and API.
  14269. Here's an example configuration, using some non-standard ports:
  14270. @lisp
  14271. (service ipfs-service-type
  14272. (ipfs-configuration
  14273. (gateway "/ip4/127.0.0.1/tcp/8880")
  14274. (api "/ip4/127.0.0.1/tcp/8881")))
  14275. @end lisp
  14276. @end defvr
  14277. @deftp {Data Type} ipfs-configuration
  14278. Data type representing the configuration of IPFS.
  14279. @table @asis
  14280. @item @code{package} (default: @code{go-ipfs})
  14281. Package object of IPFS.
  14282. @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
  14283. Address of the gateway, in ‘multiaddress’ format.
  14284. @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
  14285. Address of the API endpoint, in ‘multiaddress’ format.
  14286. @end table
  14287. @end deftp
  14288. @cindex keepalived
  14289. @deffn {Scheme Variable} keepalived-service-type
  14290. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  14291. routing software, @command{keepalived}. Its value must be an
  14292. @code{keepalived-configuration} record as in this example for master
  14293. machine:
  14294. @lisp
  14295. (service keepalived-service-type
  14296. (keepalived-configuration
  14297. (config-file (local-file "keepalived-master.conf"))))
  14298. @end lisp
  14299. where @file{keepalived-master.conf}:
  14300. @example
  14301. vrrp_instance my-group @{
  14302. state MASTER
  14303. interface enp9s0
  14304. virtual_router_id 100
  14305. priority 100
  14306. unicast_peer @{ 10.0.0.2 @}
  14307. virtual_ipaddress @{
  14308. 10.0.0.4/24
  14309. @}
  14310. @}
  14311. @end example
  14312. and for backup machine:
  14313. @lisp
  14314. (service keepalived-service-type
  14315. (keepalived-configuration
  14316. (config-file (local-file "keepalived-backup.conf"))))
  14317. @end lisp
  14318. where @file{keepalived-backup.conf}:
  14319. @example
  14320. vrrp_instance my-group @{
  14321. state BACKUP
  14322. interface enp9s0
  14323. virtual_router_id 100
  14324. priority 99
  14325. unicast_peer @{ 10.0.0.3 @}
  14326. virtual_ipaddress @{
  14327. 10.0.0.4/24
  14328. @}
  14329. @}
  14330. @end example
  14331. @end deffn
  14332. @node Unattended Upgrades
  14333. @subsection Unattended Upgrades
  14334. @cindex unattended upgrades
  14335. @cindex upgrades, unattended
  14336. Guix provides a service to perform @emph{unattended upgrades}:
  14337. periodically, the system automatically reconfigures itself from the
  14338. latest Guix. Guix System has several properties that make unattended
  14339. upgrades safe:
  14340. @itemize
  14341. @item
  14342. upgrades are transactional (either the upgrade succeeds or it fails, but
  14343. you cannot end up with an ``in-between'' system state);
  14344. @item
  14345. the upgrade log is kept---you can view it with @command{guix system
  14346. list-generations}---and you can roll back to any previous generation,
  14347. should the upgraded system fail to behave as intended;
  14348. @item
  14349. channel code is authenticated so you know you can only run genuine code
  14350. (@pxref{Channels});
  14351. @item
  14352. @command{guix system reconfigure} prevents downgrades, which makes it
  14353. immune to @dfn{downgrade attacks}.
  14354. @end itemize
  14355. To set up unattended upgrades, add an instance of
  14356. @code{unattended-upgrade-service-type} like the one below to the list of
  14357. your operating system services:
  14358. @lisp
  14359. (service unattended-upgrade-service-type)
  14360. @end lisp
  14361. The defaults above set up weekly upgrades: every Sunday at midnight.
  14362. You do not need to provide the operating system configuration file: it
  14363. uses @file{/run/current-system/configuration.scm}, which ensures it
  14364. always uses your latest configuration---@pxref{provenance-service-type},
  14365. for more information about this file.
  14366. There are several things that can be configured, in particular the
  14367. periodicity and services (daemons) to be restarted upon completion.
  14368. When the upgrade is successful, the service takes care of deleting
  14369. system generations older that some threshold, as per @command{guix
  14370. system delete-generations}. See the reference below for details.
  14371. To ensure that upgrades are actually happening, you can run
  14372. @command{guix system describe}. To investigate upgrade failures, visit
  14373. the unattended upgrade log file (see below).
  14374. @defvr {Scheme Variable} unattended-upgrade-service-type
  14375. This is the service type for unattended upgrades. It sets up an mcron
  14376. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  14377. reconfigure} from the latest version of the specified channels.
  14378. Its value must be a @code{unattended-upgrade-configuration} record (see
  14379. below).
  14380. @end defvr
  14381. @deftp {Data Type} unattended-upgrade-configuration
  14382. This data type represents the configuration of the unattended upgrade
  14383. service. The following fields are available:
  14384. @table @asis
  14385. @item @code{schedule} (default: @code{"30 01 * * 0"})
  14386. This is the schedule of upgrades, expressed as a gexp containing an
  14387. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  14388. mcron, GNU@tie{}mcron}).
  14389. @item @code{channels} (default: @code{#~%default-channels})
  14390. This gexp specifies the channels to use for the upgrade
  14391. (@pxref{Channels}). By default, the tip of the official @code{guix}
  14392. channel is used.
  14393. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  14394. This field specifies the operating system configuration file to use.
  14395. The default is to reuse the config file of the current configuration.
  14396. There are cases, though, where referring to
  14397. @file{/run/current-system/configuration.scm} is not enough, for instance
  14398. because that file refers to extra files (SSH public keys, extra
  14399. configuration files, etc.) @i{via} @code{local-file} and similar
  14400. constructs. For those cases, we recommend something along these lines:
  14401. @lisp
  14402. (unattended-upgrade-configuration
  14403. (operating-system-file
  14404. (file-append (local-file "." "config-dir" #:recursive? #t)
  14405. "/config.scm")))
  14406. @end lisp
  14407. The effect here is to import all of the current directory into the
  14408. store, and to refer to @file{config.scm} within that directory.
  14409. Therefore, uses of @code{local-file} within @file{config.scm} will work
  14410. as expected. @xref{G-Expressions}, for information about
  14411. @code{local-file} and @code{file-append}.
  14412. @item @code{services-to-restart} (default: @code{'(mcron)})
  14413. This field specifies the Shepherd services to restart when the upgrade
  14414. completes.
  14415. Those services are restarted right away upon completion, as with
  14416. @command{herd restart}, which ensures that the latest version is
  14417. running---remember that by default @command{guix system reconfigure}
  14418. only restarts services that are not currently running, which is
  14419. conservative: it minimizes disruption but leaves outdated services
  14420. running.
  14421. Use @command{herd status} to find out candidates for restarting.
  14422. @xref{Services}, for general information about services. Common
  14423. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  14424. By default, the @code{mcron} service is restarted. This ensures that
  14425. the latest version of the unattended upgrade job will be used next time.
  14426. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  14427. This is the expiration time in seconds for system generations. System
  14428. generations older that this amount of time are deleted with
  14429. @command{guix system delete-generations} when an upgrade completes.
  14430. @quotation Note
  14431. The unattended upgrade service does not run the garbage collector. You
  14432. will probably want to set up your own mcron job to run @command{guix gc}
  14433. periodically.
  14434. @end quotation
  14435. @item @code{maximum-duration} (default: @code{3600})
  14436. Maximum duration in seconds for the upgrade; past that time, the upgrade
  14437. aborts.
  14438. This is primarily useful to ensure the upgrade does not end up
  14439. rebuilding or re-downloading ``the world''.
  14440. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  14441. File where unattended upgrades are logged.
  14442. @end table
  14443. @end deftp
  14444. @node X Window
  14445. @subsection X Window
  14446. @cindex X11
  14447. @cindex X Window System
  14448. @cindex login manager
  14449. Support for the X Window graphical display system---specifically
  14450. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  14451. there is no @code{xorg-service} procedure. Instead, the X server is
  14452. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  14453. @cindex GDM
  14454. @cindex GNOME, login manager
  14455. GDM of course allows users to log in into window managers and desktop
  14456. environments other than GNOME; for those using GNOME, GDM is required for
  14457. features such as automatic screen locking.
  14458. @cindex window manager
  14459. To use X11, you must install at least one @dfn{window manager}---for
  14460. example the @code{windowmaker} or @code{openbox} packages---preferably
  14461. by adding it to the @code{packages} field of your operating system
  14462. definition (@pxref{operating-system Reference, system-wide packages}).
  14463. @defvr {Scheme Variable} gdm-service-type
  14464. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  14465. Desktop Manager} (GDM), a program that manages graphical display servers and
  14466. handles graphical user logins. Its value must be a @code{gdm-configuration}
  14467. (see below).
  14468. @cindex session types (X11)
  14469. @cindex X11 session types
  14470. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  14471. @file{/run/current-system/profile/share/xsessions} and allows users to choose
  14472. a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
  14473. and @code{i3} provide @file{.desktop} files; adding them to the system-wide
  14474. set of packages automatically makes them available at the log-in screen.
  14475. In addition, @file{~/.xsession} files are honored. When available,
  14476. @file{~/.xsession} must be an executable that starts a window manager
  14477. and/or other X clients.
  14478. @end defvr
  14479. @deftp {Data Type} gdm-configuration
  14480. @table @asis
  14481. @item @code{auto-login?} (default: @code{#f})
  14482. @itemx @code{default-user} (default: @code{#f})
  14483. When @code{auto-login?} is false, GDM presents a log-in screen.
  14484. When @code{auto-login?} is true, GDM logs in directly as
  14485. @code{default-user}.
  14486. @item @code{debug?} (default: @code{#f})
  14487. When true, GDM writes debug messages to its log.
  14488. @item @code{gnome-shell-assets} (default: ...)
  14489. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  14490. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  14491. Configuration of the Xorg graphical server.
  14492. @item @code{xsession} (default: @code{(xinitrc)})
  14493. Script to run before starting a X session.
  14494. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  14495. File name of the @code{dbus-daemon} executable.
  14496. @item @code{gdm} (default: @code{gdm})
  14497. The GDM package to use.
  14498. @end table
  14499. @end deftp
  14500. @defvr {Scheme Variable} slim-service-type
  14501. This is the type for the SLiM graphical login manager for X11.
  14502. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  14503. allows users to choose a session from the log-in screen using @kbd{F1}. It
  14504. also honors @file{~/.xsession} files.
  14505. Unlike GDM, SLiM does not spawn the user session on a different VT after
  14506. logging in, which means that you can only start one graphical session. If you
  14507. want to be able to run multiple graphical sessions at the same time you have
  14508. to add multiple SLiM services to your system services. The following example
  14509. shows how to replace the default GDM service with two SLiM services on tty7
  14510. and tty8.
  14511. @lisp
  14512. (use-modules (gnu services)
  14513. (gnu services desktop)
  14514. (gnu services xorg)
  14515. (srfi srfi-1)) ;for 'remove'
  14516. (operating-system
  14517. ;; ...
  14518. (services (cons* (service slim-service-type (slim-configuration
  14519. (display ":0")
  14520. (vt "vt7")))
  14521. (service slim-service-type (slim-configuration
  14522. (display ":1")
  14523. (vt "vt8")))
  14524. (modify-services %desktop-services
  14525. (delete gdm-service-type)))))
  14526. @end lisp
  14527. @end defvr
  14528. @deftp {Data Type} slim-configuration
  14529. Data type representing the configuration of @code{slim-service-type}.
  14530. @table @asis
  14531. @item @code{allow-empty-passwords?} (default: @code{#t})
  14532. Whether to allow logins with empty passwords.
  14533. @item @code{auto-login?} (default: @code{#f})
  14534. @itemx @code{default-user} (default: @code{""})
  14535. When @code{auto-login?} is false, SLiM presents a log-in screen.
  14536. When @code{auto-login?} is true, SLiM logs in directly as
  14537. @code{default-user}.
  14538. @item @code{theme} (default: @code{%default-slim-theme})
  14539. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  14540. The graphical theme to use and its name.
  14541. @item @code{auto-login-session} (default: @code{#f})
  14542. If true, this must be the name of the executable to start as the default
  14543. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  14544. If false, a session described by one of the available @file{.desktop}
  14545. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  14546. will be used.
  14547. @quotation Note
  14548. You must install at least one window manager in the system profile or in
  14549. your user profile. Failing to do that, if @code{auto-login-session} is
  14550. false, you will be unable to log in.
  14551. @end quotation
  14552. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14553. Configuration of the Xorg graphical server.
  14554. @item @code{display} (default @code{":0"})
  14555. The display on which to start the Xorg graphical server.
  14556. @item @code{vt} (default @code{"vt7"})
  14557. The VT on which to start the Xorg graphical server.
  14558. @item @code{xauth} (default: @code{xauth})
  14559. The XAuth package to use.
  14560. @item @code{shepherd} (default: @code{shepherd})
  14561. The Shepherd package used when invoking @command{halt} and
  14562. @command{reboot}.
  14563. @item @code{sessreg} (default: @code{sessreg})
  14564. The sessreg package used in order to register the session.
  14565. @item @code{slim} (default: @code{slim})
  14566. The SLiM package to use.
  14567. @end table
  14568. @end deftp
  14569. @defvr {Scheme Variable} %default-theme
  14570. @defvrx {Scheme Variable} %default-theme-name
  14571. The default SLiM theme and its name.
  14572. @end defvr
  14573. @deftp {Data Type} sddm-configuration
  14574. This is the data type representing the SDDM service configuration.
  14575. @table @asis
  14576. @item @code{display-server} (default: "x11")
  14577. Select display server to use for the greeter. Valid values are
  14578. @samp{"x11"} or @samp{"wayland"}.
  14579. @item @code{numlock} (default: "on")
  14580. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  14581. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  14582. Command to run when halting.
  14583. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  14584. Command to run when rebooting.
  14585. @item @code{theme} (default "maldives")
  14586. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  14587. @samp{"maldives"} or @samp{"maya"}.
  14588. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  14589. Directory to look for themes.
  14590. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  14591. Directory to look for faces.
  14592. @item @code{default-path} (default "/run/current-system/profile/bin")
  14593. Default PATH to use.
  14594. @item @code{minimum-uid} (default: 1000)
  14595. Minimum UID displayed in SDDM and allowed for log-in.
  14596. @item @code{maximum-uid} (default: 2000)
  14597. Maximum UID to display in SDDM.
  14598. @item @code{remember-last-user?} (default #t)
  14599. Remember last user.
  14600. @item @code{remember-last-session?} (default #t)
  14601. Remember last session.
  14602. @item @code{hide-users} (default "")
  14603. Usernames to hide from SDDM greeter.
  14604. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  14605. Users with shells listed will be hidden from the SDDM greeter.
  14606. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  14607. Script to run before starting a wayland session.
  14608. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  14609. Directory to look for desktop files starting wayland sessions.
  14610. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14611. Configuration of the Xorg graphical server.
  14612. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  14613. Path to xauth.
  14614. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  14615. Path to Xephyr.
  14616. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  14617. Script to run after starting xorg-server.
  14618. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  14619. Script to run before stopping xorg-server.
  14620. @item @code{xsession-command} (default: @code{xinitrc})
  14621. Script to run before starting a X session.
  14622. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  14623. Directory to look for desktop files starting X sessions.
  14624. @item @code{minimum-vt} (default: 7)
  14625. Minimum VT to use.
  14626. @item @code{auto-login-user} (default "")
  14627. User to use for auto-login.
  14628. @item @code{auto-login-session} (default "")
  14629. Desktop file to use for auto-login.
  14630. @item @code{relogin?} (default #f)
  14631. Relogin after logout.
  14632. @end table
  14633. @end deftp
  14634. @cindex login manager
  14635. @cindex X11 login
  14636. @defvr {Scheme Variable} sddm-service-type
  14637. This is the type of the service to run the
  14638. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  14639. must be a @code{sddm-configuration} record (see below).
  14640. Here's an example use:
  14641. @lisp
  14642. (service sddm-service-type
  14643. (sddm-configuration
  14644. (auto-login-user "alice")
  14645. (auto-login-session "xfce.desktop")))
  14646. @end lisp
  14647. @end defvr
  14648. @deftp {Data Type} sddm-configuration
  14649. This data type represents the configuration of the SDDM login manager.
  14650. The available fields are:
  14651. @table @asis
  14652. @item @code{sddm} (default: @code{sddm})
  14653. The SDDM package to use.
  14654. @item @code{display-server} (default: @code{"x11"})
  14655. This must be either @code{"x11"} or @code{"wayland"}.
  14656. @c FIXME: Add more fields.
  14657. @item @code{auto-login-user} (default: @code{""})
  14658. If non-empty, this is the user account under which to log in
  14659. automatically.
  14660. @item @code{auto-login-session} (default: @code{""})
  14661. If non-empty, this is the @file{.desktop} file name to use as the
  14662. auto-login session.
  14663. @end table
  14664. @end deftp
  14665. @cindex Xorg, configuration
  14666. @deftp {Data Type} xorg-configuration
  14667. This data type represents the configuration of the Xorg graphical display
  14668. server. Note that there is no Xorg service; instead, the X server is started
  14669. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  14670. of these display managers aggregates an @code{xorg-configuration} record.
  14671. @table @asis
  14672. @item @code{modules} (default: @code{%default-xorg-modules})
  14673. This is a list of @dfn{module packages} loaded by the Xorg
  14674. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  14675. @item @code{fonts} (default: @code{%default-xorg-fonts})
  14676. This is a list of font directories to add to the server's @dfn{font path}.
  14677. @item @code{drivers} (default: @code{'()})
  14678. This must be either the empty list, in which case Xorg chooses a graphics
  14679. driver automatically, or a list of driver names that will be tried in this
  14680. order---e.g., @code{("modesetting" "vesa")}.
  14681. @item @code{resolutions} (default: @code{'()})
  14682. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  14683. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  14684. 768) (640 480))}.
  14685. @cindex keyboard layout, for Xorg
  14686. @cindex keymap, for Xorg
  14687. @item @code{keyboard-layout} (default: @code{#f})
  14688. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  14689. English (``qwerty'') for a 105-key PC keyboard.
  14690. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  14691. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  14692. information on how to specify the keyboard layout.
  14693. @item @code{extra-config} (default: @code{'()})
  14694. This is a list of strings or objects appended to the configuration file. It
  14695. is used to pass extra text to be added verbatim to the configuration file.
  14696. @item @code{server} (default: @code{xorg-server})
  14697. This is the package providing the Xorg server.
  14698. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  14699. This is the list of command-line arguments to pass to the X server. The
  14700. default is @code{-nolisten tcp}.
  14701. @end table
  14702. @end deftp
  14703. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  14704. [@var{login-manager-service-type}]
  14705. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  14706. @var{config}, an @code{<xorg-configuration>} record.
  14707. Since the Xorg configuration is embedded in the log-in manager's
  14708. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  14709. shorthand to set the Xorg configuration.
  14710. @end deffn
  14711. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  14712. Return a @code{startx} script in which the modules, fonts, etc. specified
  14713. in @var{config}, are available. The result should be used in place of
  14714. @code{startx}.
  14715. Usually the X server is started by a login manager.
  14716. @end deffn
  14717. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  14718. Add @var{package}, a package for a screen locker or screen saver whose
  14719. command is @var{program}, to the set of setuid programs and add a PAM entry
  14720. for it. For example:
  14721. @lisp
  14722. (screen-locker-service xlockmore "xlock")
  14723. @end lisp
  14724. makes the good ol' XlockMore usable.
  14725. @end deffn
  14726. @node Printing Services
  14727. @subsection Printing Services
  14728. @cindex printer support with CUPS
  14729. The @code{(gnu services cups)} module provides a Guix service definition
  14730. for the CUPS printing service. To add printer support to a Guix
  14731. system, add a @code{cups-service} to the operating system definition:
  14732. @deffn {Scheme Variable} cups-service-type
  14733. The service type for the CUPS print server. Its value should be a valid
  14734. CUPS configuration (see below). To use the default settings, simply
  14735. write:
  14736. @lisp
  14737. (service cups-service-type)
  14738. @end lisp
  14739. @end deffn
  14740. The CUPS configuration controls the basic things about your CUPS
  14741. installation: what interfaces it listens on, what to do if a print job
  14742. fails, how much logging to do, and so on. To actually add a printer,
  14743. you have to visit the @url{http://localhost:631} URL, or use a tool such
  14744. as GNOME's printer configuration services. By default, configuring a
  14745. CUPS service will generate a self-signed certificate if needed, for
  14746. secure connections to the print server.
  14747. Suppose you want to enable the Web interface of CUPS and also add
  14748. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  14749. package and for HP printers @i{via} the @code{hplip-minimal} package.
  14750. You can do that directly, like this (you need to use the
  14751. @code{(gnu packages cups)} module):
  14752. @lisp
  14753. (service cups-service-type
  14754. (cups-configuration
  14755. (web-interface? #t)
  14756. (extensions
  14757. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  14758. @end lisp
  14759. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  14760. package then it is suggested that you install the @code{hplip} package,
  14761. either in your OS configuration file or as your user.
  14762. The available configuration parameters follow. Each parameter
  14763. definition is preceded by its type; for example, @samp{string-list foo}
  14764. indicates that the @code{foo} parameter should be specified as a list of
  14765. strings. There is also a way to specify the configuration as a string,
  14766. if you have an old @code{cupsd.conf} file that you want to port over
  14767. from some other system; see the end for more details.
  14768. @c The following documentation was initially generated by
  14769. @c (generate-documentation) in (gnu services cups). Manually maintained
  14770. @c documentation is better, so we shouldn't hesitate to edit below as
  14771. @c needed. However if the change you want to make to this documentation
  14772. @c can be done in an automated way, it's probably easier to change
  14773. @c (generate-documentation) than to make it below and have to deal with
  14774. @c the churn as CUPS updates.
  14775. Available @code{cups-configuration} fields are:
  14776. @deftypevr {@code{cups-configuration} parameter} package cups
  14777. The CUPS package.
  14778. @end deftypevr
  14779. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  14780. Drivers and other extensions to the CUPS package.
  14781. @end deftypevr
  14782. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  14783. Configuration of where to write logs, what directories to use for print
  14784. spools, and related privileged configuration parameters.
  14785. Available @code{files-configuration} fields are:
  14786. @deftypevr {@code{files-configuration} parameter} log-location access-log
  14787. Defines the access log filename. Specifying a blank filename disables
  14788. access log generation. The value @code{stderr} causes log entries to be
  14789. sent to the standard error file when the scheduler is running in the
  14790. foreground, or to the system log daemon when run in the background. The
  14791. value @code{syslog} causes log entries to be sent to the system log
  14792. daemon. The server name may be included in filenames using the string
  14793. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  14794. Defaults to @samp{"/var/log/cups/access_log"}.
  14795. @end deftypevr
  14796. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  14797. Where CUPS should cache data.
  14798. Defaults to @samp{"/var/cache/cups"}.
  14799. @end deftypevr
  14800. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  14801. Specifies the permissions for all configuration files that the scheduler
  14802. writes.
  14803. Note that the permissions for the printers.conf file are currently
  14804. masked to only allow access from the scheduler user (typically root).
  14805. This is done because printer device URIs sometimes contain sensitive
  14806. authentication information that should not be generally known on the
  14807. system. There is no way to disable this security feature.
  14808. Defaults to @samp{"0640"}.
  14809. @end deftypevr
  14810. @deftypevr {@code{files-configuration} parameter} log-location error-log
  14811. Defines the error log filename. Specifying a blank filename disables
  14812. error log generation. The value @code{stderr} causes log entries to be
  14813. sent to the standard error file when the scheduler is running in the
  14814. foreground, or to the system log daemon when run in the background. The
  14815. value @code{syslog} causes log entries to be sent to the system log
  14816. daemon. The server name may be included in filenames using the string
  14817. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  14818. Defaults to @samp{"/var/log/cups/error_log"}.
  14819. @end deftypevr
  14820. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  14821. Specifies which errors are fatal, causing the scheduler to exit. The
  14822. kind strings are:
  14823. @table @code
  14824. @item none
  14825. No errors are fatal.
  14826. @item all
  14827. All of the errors below are fatal.
  14828. @item browse
  14829. Browsing initialization errors are fatal, for example failed connections
  14830. to the DNS-SD daemon.
  14831. @item config
  14832. Configuration file syntax errors are fatal.
  14833. @item listen
  14834. Listen or Port errors are fatal, except for IPv6 failures on the
  14835. loopback or @code{any} addresses.
  14836. @item log
  14837. Log file creation or write errors are fatal.
  14838. @item permissions
  14839. Bad startup file permissions are fatal, for example shared TLS
  14840. certificate and key files with world-read permissions.
  14841. @end table
  14842. Defaults to @samp{"all -browse"}.
  14843. @end deftypevr
  14844. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  14845. Specifies whether the file pseudo-device can be used for new printer
  14846. queues. The URI @uref{file:///dev/null} is always allowed.
  14847. Defaults to @samp{#f}.
  14848. @end deftypevr
  14849. @deftypevr {@code{files-configuration} parameter} string group
  14850. Specifies the group name or ID that will be used when executing external
  14851. programs.
  14852. Defaults to @samp{"lp"}.
  14853. @end deftypevr
  14854. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  14855. Specifies the permissions for all log files that the scheduler writes.
  14856. Defaults to @samp{"0644"}.
  14857. @end deftypevr
  14858. @deftypevr {@code{files-configuration} parameter} log-location page-log
  14859. Defines the page log filename. Specifying a blank filename disables
  14860. page log generation. The value @code{stderr} causes log entries to be
  14861. sent to the standard error file when the scheduler is running in the
  14862. foreground, or to the system log daemon when run in the background. The
  14863. value @code{syslog} causes log entries to be sent to the system log
  14864. daemon. The server name may be included in filenames using the string
  14865. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  14866. Defaults to @samp{"/var/log/cups/page_log"}.
  14867. @end deftypevr
  14868. @deftypevr {@code{files-configuration} parameter} string remote-root
  14869. Specifies the username that is associated with unauthenticated accesses
  14870. by clients claiming to be the root user. The default is @code{remroot}.
  14871. Defaults to @samp{"remroot"}.
  14872. @end deftypevr
  14873. @deftypevr {@code{files-configuration} parameter} file-name request-root
  14874. Specifies the directory that contains print jobs and other HTTP request
  14875. data.
  14876. Defaults to @samp{"/var/spool/cups"}.
  14877. @end deftypevr
  14878. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  14879. Specifies the level of security sandboxing that is applied to print
  14880. filters, backends, and other child processes of the scheduler; either
  14881. @code{relaxed} or @code{strict}. This directive is currently only
  14882. used/supported on macOS.
  14883. Defaults to @samp{strict}.
  14884. @end deftypevr
  14885. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  14886. Specifies the location of TLS certificates and private keys. CUPS will
  14887. look for public and private keys in this directory: @file{.crt} files
  14888. for PEM-encoded certificates and corresponding @file{.key} files for
  14889. PEM-encoded private keys.
  14890. Defaults to @samp{"/etc/cups/ssl"}.
  14891. @end deftypevr
  14892. @deftypevr {@code{files-configuration} parameter} file-name server-root
  14893. Specifies the directory containing the server configuration files.
  14894. Defaults to @samp{"/etc/cups"}.
  14895. @end deftypevr
  14896. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  14897. Specifies whether the scheduler calls fsync(2) after writing
  14898. configuration or state files.
  14899. Defaults to @samp{#f}.
  14900. @end deftypevr
  14901. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  14902. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  14903. @end deftypevr
  14904. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  14905. Specifies the directory where temporary files are stored.
  14906. Defaults to @samp{"/var/spool/cups/tmp"}.
  14907. @end deftypevr
  14908. @deftypevr {@code{files-configuration} parameter} string user
  14909. Specifies the user name or ID that is used when running external
  14910. programs.
  14911. Defaults to @samp{"lp"}.
  14912. @end deftypevr
  14913. @deftypevr {@code{files-configuration} parameter} string set-env
  14914. Set the specified environment variable to be passed to child processes.
  14915. Defaults to @samp{"variable value"}.
  14916. @end deftypevr
  14917. @end deftypevr
  14918. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  14919. Specifies the logging level for the AccessLog file. The @code{config}
  14920. level logs when printers and classes are added, deleted, or modified and
  14921. when configuration files are accessed or updated. The @code{actions}
  14922. level logs when print jobs are submitted, held, released, modified, or
  14923. canceled, and any of the conditions for @code{config}. The @code{all}
  14924. level logs all requests.
  14925. Defaults to @samp{actions}.
  14926. @end deftypevr
  14927. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  14928. Specifies whether to purge job history data automatically when it is no
  14929. longer required for quotas.
  14930. Defaults to @samp{#f}.
  14931. @end deftypevr
  14932. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  14933. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  14934. For example, @samp{"_cups" "_print"} will tell network clients that both
  14935. CUPS sharing and IPP Everywhere are supported.
  14936. Defaults to @samp{"_cups"}.
  14937. @end deftypevr
  14938. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  14939. Specifies which protocols to use for local printer sharing.
  14940. Defaults to @samp{dnssd}.
  14941. @end deftypevr
  14942. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  14943. Specifies whether the CUPS web interface is advertised.
  14944. Defaults to @samp{#f}.
  14945. @end deftypevr
  14946. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  14947. Specifies whether shared printers are advertised.
  14948. Defaults to @samp{#f}.
  14949. @end deftypevr
  14950. @deftypevr {@code{cups-configuration} parameter} string classification
  14951. Specifies the security classification of the server. Any valid banner
  14952. name can be used, including @samp{"classified"}, @samp{"confidential"},
  14953. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  14954. banner can be omitted to disable secure printing functions.
  14955. Defaults to @samp{""}.
  14956. @end deftypevr
  14957. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  14958. Specifies whether users may override the classification (cover page) of
  14959. individual print jobs using the @code{job-sheets} option.
  14960. Defaults to @samp{#f}.
  14961. @end deftypevr
  14962. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  14963. Specifies the default type of authentication to use.
  14964. Defaults to @samp{Basic}.
  14965. @end deftypevr
  14966. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  14967. Specifies whether encryption will be used for authenticated requests.
  14968. Defaults to @samp{Required}.
  14969. @end deftypevr
  14970. @deftypevr {@code{cups-configuration} parameter} string default-language
  14971. Specifies the default language to use for text and web content.
  14972. Defaults to @samp{"en"}.
  14973. @end deftypevr
  14974. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  14975. Specifies the default paper size for new print queues. @samp{"Auto"}
  14976. uses a locale-specific default, while @samp{"None"} specifies there is
  14977. no default paper size. Specific size names are typically
  14978. @samp{"Letter"} or @samp{"A4"}.
  14979. Defaults to @samp{"Auto"}.
  14980. @end deftypevr
  14981. @deftypevr {@code{cups-configuration} parameter} string default-policy
  14982. Specifies the default access policy to use.
  14983. Defaults to @samp{"default"}.
  14984. @end deftypevr
  14985. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  14986. Specifies whether local printers are shared by default.
  14987. Defaults to @samp{#t}.
  14988. @end deftypevr
  14989. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  14990. Specifies the delay for updating of configuration and state files, in
  14991. seconds. A value of 0 causes the update to happen as soon as possible,
  14992. typically within a few milliseconds.
  14993. Defaults to @samp{30}.
  14994. @end deftypevr
  14995. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  14996. Specifies what to do when an error occurs. Possible values are
  14997. @code{abort-job}, which will discard the failed print job;
  14998. @code{retry-job}, which will retry the job at a later time;
  14999. @code{retry-current-job}, which retries the failed job immediately; and
  15000. @code{stop-printer}, which stops the printer.
  15001. Defaults to @samp{stop-printer}.
  15002. @end deftypevr
  15003. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  15004. Specifies the maximum cost of filters that are run concurrently, which
  15005. can be used to minimize disk, memory, and CPU resource problems. A
  15006. limit of 0 disables filter limiting. An average print to a
  15007. non-PostScript printer needs a filter limit of about 200. A PostScript
  15008. printer needs about half that (100). Setting the limit below these
  15009. thresholds will effectively limit the scheduler to printing a single job
  15010. at any time.
  15011. Defaults to @samp{0}.
  15012. @end deftypevr
  15013. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  15014. Specifies the scheduling priority of filters that are run to print a
  15015. job. The nice value ranges from 0, the highest priority, to 19, the
  15016. lowest priority.
  15017. Defaults to @samp{0}.
  15018. @end deftypevr
  15019. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  15020. Specifies whether to do reverse lookups on connecting clients. The
  15021. @code{double} setting causes @code{cupsd} to verify that the hostname
  15022. resolved from the address matches one of the addresses returned for that
  15023. hostname. Double lookups also prevent clients with unregistered
  15024. addresses from connecting to your server. Only set this option to
  15025. @code{#t} or @code{double} if absolutely required.
  15026. Defaults to @samp{#f}.
  15027. @end deftypevr
  15028. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  15029. Specifies the number of seconds to wait before killing the filters and
  15030. backend associated with a canceled or held job.
  15031. Defaults to @samp{30}.
  15032. @end deftypevr
  15033. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  15034. Specifies the interval between retries of jobs in seconds. This is
  15035. typically used for fax queues but can also be used with normal print
  15036. queues whose error policy is @code{retry-job} or
  15037. @code{retry-current-job}.
  15038. Defaults to @samp{30}.
  15039. @end deftypevr
  15040. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  15041. Specifies the number of retries that are done for jobs. This is
  15042. typically used for fax queues but can also be used with normal print
  15043. queues whose error policy is @code{retry-job} or
  15044. @code{retry-current-job}.
  15045. Defaults to @samp{5}.
  15046. @end deftypevr
  15047. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  15048. Specifies whether to support HTTP keep-alive connections.
  15049. Defaults to @samp{#t}.
  15050. @end deftypevr
  15051. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  15052. Specifies how long an idle client connection remains open, in seconds.
  15053. Defaults to @samp{30}.
  15054. @end deftypevr
  15055. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  15056. Specifies the maximum size of print files, IPP requests, and HTML form
  15057. data. A limit of 0 disables the limit check.
  15058. Defaults to @samp{0}.
  15059. @end deftypevr
  15060. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  15061. Listens on the specified interfaces for connections. Valid values are
  15062. of the form @var{address}:@var{port}, where @var{address} is either an
  15063. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  15064. indicate all addresses. Values can also be file names of local UNIX
  15065. domain sockets. The Listen directive is similar to the Port directive
  15066. but allows you to restrict access to specific interfaces or networks.
  15067. @end deftypevr
  15068. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  15069. Specifies the number of pending connections that will be allowed. This
  15070. normally only affects very busy servers that have reached the MaxClients
  15071. limit, but can also be triggered by large numbers of simultaneous
  15072. connections. When the limit is reached, the operating system will
  15073. refuse additional connections until the scheduler can accept the pending
  15074. ones.
  15075. Defaults to @samp{128}.
  15076. @end deftypevr
  15077. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  15078. Specifies a set of additional access controls.
  15079. Available @code{location-access-controls} fields are:
  15080. @deftypevr {@code{location-access-controls} parameter} file-name path
  15081. Specifies the URI path to which the access control applies.
  15082. @end deftypevr
  15083. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  15084. Access controls for all access to this path, in the same format as the
  15085. @code{access-controls} of @code{operation-access-control}.
  15086. Defaults to @samp{()}.
  15087. @end deftypevr
  15088. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  15089. Access controls for method-specific access to this path.
  15090. Defaults to @samp{()}.
  15091. Available @code{method-access-controls} fields are:
  15092. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  15093. If @code{#t}, apply access controls to all methods except the listed
  15094. methods. Otherwise apply to only the listed methods.
  15095. Defaults to @samp{#f}.
  15096. @end deftypevr
  15097. @deftypevr {@code{method-access-controls} parameter} method-list methods
  15098. Methods to which this access control applies.
  15099. Defaults to @samp{()}.
  15100. @end deftypevr
  15101. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  15102. Access control directives, as a list of strings. Each string should be
  15103. one directive, such as @samp{"Order allow,deny"}.
  15104. Defaults to @samp{()}.
  15105. @end deftypevr
  15106. @end deftypevr
  15107. @end deftypevr
  15108. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  15109. Specifies the number of debugging messages that are retained for logging
  15110. if an error occurs in a print job. Debug messages are logged regardless
  15111. of the LogLevel setting.
  15112. Defaults to @samp{100}.
  15113. @end deftypevr
  15114. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  15115. Specifies the level of logging for the ErrorLog file. The value
  15116. @code{none} stops all logging while @code{debug2} logs everything.
  15117. Defaults to @samp{info}.
  15118. @end deftypevr
  15119. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  15120. Specifies the format of the date and time in the log files. The value
  15121. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  15122. Defaults to @samp{standard}.
  15123. @end deftypevr
  15124. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  15125. Specifies the maximum number of simultaneous clients that are allowed by
  15126. the scheduler.
  15127. Defaults to @samp{100}.
  15128. @end deftypevr
  15129. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  15130. Specifies the maximum number of simultaneous clients that are allowed
  15131. from a single address.
  15132. Defaults to @samp{100}.
  15133. @end deftypevr
  15134. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  15135. Specifies the maximum number of copies that a user can print of each
  15136. job.
  15137. Defaults to @samp{9999}.
  15138. @end deftypevr
  15139. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  15140. Specifies the maximum time a job may remain in the @code{indefinite}
  15141. hold state before it is canceled. A value of 0 disables cancellation of
  15142. held jobs.
  15143. Defaults to @samp{0}.
  15144. @end deftypevr
  15145. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  15146. Specifies the maximum number of simultaneous jobs that are allowed. Set
  15147. to 0 to allow an unlimited number of jobs.
  15148. Defaults to @samp{500}.
  15149. @end deftypevr
  15150. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  15151. Specifies the maximum number of simultaneous jobs that are allowed per
  15152. printer. A value of 0 allows up to MaxJobs jobs per printer.
  15153. Defaults to @samp{0}.
  15154. @end deftypevr
  15155. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  15156. Specifies the maximum number of simultaneous jobs that are allowed per
  15157. user. A value of 0 allows up to MaxJobs jobs per user.
  15158. Defaults to @samp{0}.
  15159. @end deftypevr
  15160. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  15161. Specifies the maximum time a job may take to print before it is
  15162. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  15163. Defaults to @samp{10800}.
  15164. @end deftypevr
  15165. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  15166. Specifies the maximum size of the log files before they are rotated, in
  15167. bytes. The value 0 disables log rotation.
  15168. Defaults to @samp{1048576}.
  15169. @end deftypevr
  15170. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  15171. Specifies the maximum amount of time to allow between files in a
  15172. multiple file print job, in seconds.
  15173. Defaults to @samp{300}.
  15174. @end deftypevr
  15175. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  15176. Specifies the format of PageLog lines. Sequences beginning with percent
  15177. (@samp{%}) characters are replaced with the corresponding information,
  15178. while all other characters are copied literally. The following percent
  15179. sequences are recognized:
  15180. @table @samp
  15181. @item %%
  15182. insert a single percent character
  15183. @item %@{name@}
  15184. insert the value of the specified IPP attribute
  15185. @item %C
  15186. insert the number of copies for the current page
  15187. @item %P
  15188. insert the current page number
  15189. @item %T
  15190. insert the current date and time in common log format
  15191. @item %j
  15192. insert the job ID
  15193. @item %p
  15194. insert the printer name
  15195. @item %u
  15196. insert the username
  15197. @end table
  15198. A value of the empty string disables page logging. The string @code{%p
  15199. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  15200. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  15201. standard items.
  15202. Defaults to @samp{""}.
  15203. @end deftypevr
  15204. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  15205. Passes the specified environment variable(s) to child processes; a list
  15206. of strings.
  15207. Defaults to @samp{()}.
  15208. @end deftypevr
  15209. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  15210. Specifies named access control policies.
  15211. Available @code{policy-configuration} fields are:
  15212. @deftypevr {@code{policy-configuration} parameter} string name
  15213. Name of the policy.
  15214. @end deftypevr
  15215. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  15216. Specifies an access list for a job's private values. @code{@@ACL} maps
  15217. to the printer's requesting-user-name-allowed or
  15218. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15219. owner. @code{@@SYSTEM} maps to the groups listed for the
  15220. @code{system-group} field of the @code{files-config} configuration,
  15221. which is reified into the @code{cups-files.conf(5)} file. Other
  15222. possible elements of the access list include specific user names, and
  15223. @code{@@@var{group}} to indicate members of a specific group. The
  15224. access list may also be simply @code{all} or @code{default}.
  15225. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15226. @end deftypevr
  15227. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  15228. Specifies the list of job values to make private, or @code{all},
  15229. @code{default}, or @code{none}.
  15230. Defaults to @samp{"job-name job-originating-host-name
  15231. job-originating-user-name phone"}.
  15232. @end deftypevr
  15233. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  15234. Specifies an access list for a subscription's private values.
  15235. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  15236. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15237. owner. @code{@@SYSTEM} maps to the groups listed for the
  15238. @code{system-group} field of the @code{files-config} configuration,
  15239. which is reified into the @code{cups-files.conf(5)} file. Other
  15240. possible elements of the access list include specific user names, and
  15241. @code{@@@var{group}} to indicate members of a specific group. The
  15242. access list may also be simply @code{all} or @code{default}.
  15243. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15244. @end deftypevr
  15245. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  15246. Specifies the list of job values to make private, or @code{all},
  15247. @code{default}, or @code{none}.
  15248. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  15249. notify-subscriber-user-name notify-user-data"}.
  15250. @end deftypevr
  15251. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  15252. Access control by IPP operation.
  15253. Defaults to @samp{()}.
  15254. @end deftypevr
  15255. @end deftypevr
  15256. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  15257. Specifies whether job files (documents) are preserved after a job is
  15258. printed. If a numeric value is specified, job files are preserved for
  15259. the indicated number of seconds after printing. Otherwise a boolean
  15260. value applies indefinitely.
  15261. Defaults to @samp{86400}.
  15262. @end deftypevr
  15263. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  15264. Specifies whether the job history is preserved after a job is printed.
  15265. If a numeric value is specified, the job history is preserved for the
  15266. indicated number of seconds after printing. If @code{#t}, the job
  15267. history is preserved until the MaxJobs limit is reached.
  15268. Defaults to @samp{#t}.
  15269. @end deftypevr
  15270. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  15271. Specifies the amount of time to wait for job completion before
  15272. restarting the scheduler.
  15273. Defaults to @samp{30}.
  15274. @end deftypevr
  15275. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  15276. Specifies the maximum amount of memory to use when converting documents
  15277. into bitmaps for a printer.
  15278. Defaults to @samp{"128m"}.
  15279. @end deftypevr
  15280. @deftypevr {@code{cups-configuration} parameter} string server-admin
  15281. Specifies the email address of the server administrator.
  15282. Defaults to @samp{"root@@localhost.localdomain"}.
  15283. @end deftypevr
  15284. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  15285. The ServerAlias directive is used for HTTP Host header validation when
  15286. clients connect to the scheduler from external interfaces. Using the
  15287. special name @code{*} can expose your system to known browser-based DNS
  15288. rebinding attacks, even when accessing sites through a firewall. If the
  15289. auto-discovery of alternate names does not work, we recommend listing
  15290. each alternate name with a ServerAlias directive instead of using
  15291. @code{*}.
  15292. Defaults to @samp{*}.
  15293. @end deftypevr
  15294. @deftypevr {@code{cups-configuration} parameter} string server-name
  15295. Specifies the fully-qualified host name of the server.
  15296. Defaults to @samp{"localhost"}.
  15297. @end deftypevr
  15298. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  15299. Specifies what information is included in the Server header of HTTP
  15300. responses. @code{None} disables the Server header. @code{ProductOnly}
  15301. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  15302. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  15303. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  15304. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  15305. 2.0.0 (@var{uname}) IPP/2.0}.
  15306. Defaults to @samp{Minimal}.
  15307. @end deftypevr
  15308. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  15309. Listens on the specified interfaces for encrypted connections. Valid
  15310. values are of the form @var{address}:@var{port}, where @var{address} is
  15311. either an IPv6 address enclosed in brackets, an IPv4 address, or
  15312. @code{*} to indicate all addresses.
  15313. Defaults to @samp{()}.
  15314. @end deftypevr
  15315. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  15316. Sets encryption options. By default, CUPS only supports encryption
  15317. using TLS v1.0 or higher using known secure cipher suites. Security is
  15318. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  15319. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  15320. suites, which are required for some older clients. The @code{AllowSSL3} option
  15321. enables SSL v3.0, which is required for some older clients that do not support
  15322. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  15323. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  15324. protocol version to TLS v1.1.
  15325. Defaults to @samp{()}.
  15326. @end deftypevr
  15327. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  15328. Specifies whether the scheduler requires clients to strictly adhere to
  15329. the IPP specifications.
  15330. Defaults to @samp{#f}.
  15331. @end deftypevr
  15332. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  15333. Specifies the HTTP request timeout, in seconds.
  15334. Defaults to @samp{300}.
  15335. @end deftypevr
  15336. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  15337. Specifies whether the web interface is enabled.
  15338. Defaults to @samp{#f}.
  15339. @end deftypevr
  15340. At this point you're probably thinking ``oh dear, Guix manual, I like
  15341. you but you can stop already with the configuration options''. Indeed.
  15342. However, one more point: it could be that you have an existing
  15343. @code{cupsd.conf} that you want to use. In that case, you can pass an
  15344. @code{opaque-cups-configuration} as the configuration of a
  15345. @code{cups-service-type}.
  15346. Available @code{opaque-cups-configuration} fields are:
  15347. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  15348. The CUPS package.
  15349. @end deftypevr
  15350. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  15351. The contents of the @code{cupsd.conf}, as a string.
  15352. @end deftypevr
  15353. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  15354. The contents of the @code{cups-files.conf} file, as a string.
  15355. @end deftypevr
  15356. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  15357. strings of the same name, you could instantiate a CUPS service like
  15358. this:
  15359. @lisp
  15360. (service cups-service-type
  15361. (opaque-cups-configuration
  15362. (cupsd.conf cupsd.conf)
  15363. (cups-files.conf cups-files.conf)))
  15364. @end lisp
  15365. @node Desktop Services
  15366. @subsection Desktop Services
  15367. The @code{(gnu services desktop)} module provides services that are
  15368. usually useful in the context of a ``desktop'' setup---that is, on a
  15369. machine running a graphical display server, possibly with graphical user
  15370. interfaces, etc. It also defines services that provide specific desktop
  15371. environments like GNOME, Xfce or MATE.
  15372. To simplify things, the module defines a variable containing the set of
  15373. services that users typically expect on a machine with a graphical
  15374. environment and networking:
  15375. @defvr {Scheme Variable} %desktop-services
  15376. This is a list of services that builds upon @code{%base-services} and
  15377. adds or adjusts services for a typical ``desktop'' setup.
  15378. In particular, it adds a graphical login manager (@pxref{X Window,
  15379. @code{gdm-service-type}}), screen lockers, a network management tool
  15380. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  15381. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  15382. energy and color management services, the @code{elogind} login and seat
  15383. manager, the Polkit privilege service, the GeoClue location service, the
  15384. AccountsService daemon that allows authorized users change system passwords,
  15385. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  15386. name service switch service configured to be able to use @code{nss-mdns}
  15387. (@pxref{Name Service Switch, mDNS}).
  15388. @end defvr
  15389. The @code{%desktop-services} variable can be used as the @code{services}
  15390. field of an @code{operating-system} declaration (@pxref{operating-system
  15391. Reference, @code{services}}).
  15392. Additionally, the @code{gnome-desktop-service-type},
  15393. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  15394. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  15395. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  15396. ``add GNOME'' means that system-level services like the backlight adjustment
  15397. helpers and the power management utilities are added to the system, extending
  15398. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  15399. elevated privileges on a limited number of special-purpose system interfaces.
  15400. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  15401. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  15402. service not only adds the @code{xfce} metapackage to the system profile, but
  15403. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  15404. management window, if the user authenticates using the administrator's
  15405. password via the standard polkit graphical interface. To ``add MATE'' means
  15406. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  15407. to operate with elevated privileges on a limited number of special-purpose
  15408. system interfaces. Additionally, adding a service of type
  15409. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  15410. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  15411. appropriately, and several of Enlightenment's binaries are set as setuid,
  15412. allowing Enlightenment's screen locker and other functionality to work as
  15413. expected.
  15414. The desktop environments in Guix use the Xorg display server by
  15415. default. If you'd like to use the newer display server protocol
  15416. called Wayland, you need to use the @code{sddm-service} instead of
  15417. GDM as the graphical login manager. You should then
  15418. select the ``GNOME (Wayland)'' session in SDDM@. Alternatively you can
  15419. also try starting GNOME on Wayland manually from a TTY with the
  15420. command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  15421. gnome-session``. Currently only GNOME has support for Wayland.
  15422. @defvr {Scheme Variable} gnome-desktop-service-type
  15423. This is the type of the service that adds the @uref{https://www.gnome.org,
  15424. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  15425. object (see below).
  15426. This service adds the @code{gnome} package to the system profile, and extends
  15427. polkit with the actions from @code{gnome-settings-daemon}.
  15428. @end defvr
  15429. @deftp {Data Type} gnome-desktop-configuration
  15430. Configuration record for the GNOME desktop environment.
  15431. @table @asis
  15432. @item @code{gnome} (default: @code{gnome})
  15433. The GNOME package to use.
  15434. @end table
  15435. @end deftp
  15436. @defvr {Scheme Variable} xfce-desktop-service-type
  15437. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  15438. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  15439. (see below).
  15440. This service adds the @code{xfce} package to the system profile, and
  15441. extends polkit with the ability for @code{thunar} to manipulate the file
  15442. system as root from within a user session, after the user has authenticated
  15443. with the administrator's password.
  15444. Note that @code{xfce4-panel} and its plugin packages should be installed in
  15445. the same profile to ensure compatibility. When using this service, you should
  15446. add extra plugins (@code{xfce4-whiskermenu-plugin},
  15447. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  15448. @code{operating-system}.
  15449. @end defvr
  15450. @deftp {Data Type} xfce-desktop-configuration
  15451. Configuration record for the Xfce desktop environment.
  15452. @table @asis
  15453. @item @code{xfce} (default: @code{xfce})
  15454. The Xfce package to use.
  15455. @end table
  15456. @end deftp
  15457. @deffn {Scheme Variable} mate-desktop-service-type
  15458. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  15459. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  15460. object (see below).
  15461. This service adds the @code{mate} package to the system
  15462. profile, and extends polkit with the actions from
  15463. @code{mate-settings-daemon}.
  15464. @end deffn
  15465. @deftp {Data Type} mate-desktop-configuration
  15466. Configuration record for the MATE desktop environment.
  15467. @table @asis
  15468. @item @code{mate} (default: @code{mate})
  15469. The MATE package to use.
  15470. @end table
  15471. @end deftp
  15472. @deffn {Scheme Variable} lxqt-desktop-service-type
  15473. This is the type of the service that runs the @uref{https://lxqt.github.io,
  15474. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  15475. object (see below).
  15476. This service adds the @code{lxqt} package to the system
  15477. profile.
  15478. @end deffn
  15479. @deftp {Data Type} lxqt-desktop-configuration
  15480. Configuration record for the LXQt desktop environment.
  15481. @table @asis
  15482. @item @code{lxqt} (default: @code{lxqt})
  15483. The LXQT package to use.
  15484. @end table
  15485. @end deftp
  15486. @deffn {Scheme Variable} enlightenment-desktop-service-type
  15487. Return a service that adds the @code{enlightenment} package to the system
  15488. profile, and extends dbus with actions from @code{efl}.
  15489. @end deffn
  15490. @deftp {Data Type} enlightenment-desktop-service-configuration
  15491. @table @asis
  15492. @item @code{enlightenment} (default: @code{enlightenment})
  15493. The enlightenment package to use.
  15494. @end table
  15495. @end deftp
  15496. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  15497. the default @code{%desktop-services} variable doesn't include any of
  15498. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  15499. @code{%desktop-services} in the @code{services} field of your
  15500. @code{operating-system}:
  15501. @lisp
  15502. (use-modules (gnu))
  15503. (use-service-modules desktop)
  15504. (operating-system
  15505. ...
  15506. ;; cons* adds items to the list given as its last argument.
  15507. (services (cons* (service gnome-desktop-service-type)
  15508. (service xfce-desktop-service)
  15509. %desktop-services))
  15510. ...)
  15511. @end lisp
  15512. These desktop environments will then be available as options in the
  15513. graphical login window.
  15514. The actual service definitions included in @code{%desktop-services} and
  15515. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  15516. are described below.
  15517. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  15518. Return a service that runs the ``system bus'', using @var{dbus}, with
  15519. support for @var{services}.
  15520. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  15521. facility. Its system bus is used to allow system services to communicate
  15522. and to be notified of system-wide events.
  15523. @var{services} must be a list of packages that provide an
  15524. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  15525. and policy files. For example, to allow avahi-daemon to use the system bus,
  15526. @var{services} must be equal to @code{(list avahi)}.
  15527. @end deffn
  15528. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  15529. Return a service that runs the @code{elogind} login and
  15530. seat management daemon. @uref{https://github.com/elogind/elogind,
  15531. Elogind} exposes a D-Bus interface that can be used to know which users
  15532. are logged in, know what kind of sessions they have open, suspend the
  15533. system, inhibit system suspend, reboot the system, and other tasks.
  15534. Elogind handles most system-level power events for a computer, for
  15535. example suspending the system when a lid is closed, or shutting it down
  15536. when the power button is pressed.
  15537. The @var{config} keyword argument specifies the configuration for
  15538. elogind, and should be the result of an @code{(elogind-configuration
  15539. (@var{parameter} @var{value})...)} invocation. Available parameters and
  15540. their default values are:
  15541. @table @code
  15542. @item kill-user-processes?
  15543. @code{#f}
  15544. @item kill-only-users
  15545. @code{()}
  15546. @item kill-exclude-users
  15547. @code{("root")}
  15548. @item inhibit-delay-max-seconds
  15549. @code{5}
  15550. @item handle-power-key
  15551. @code{poweroff}
  15552. @item handle-suspend-key
  15553. @code{suspend}
  15554. @item handle-hibernate-key
  15555. @code{hibernate}
  15556. @item handle-lid-switch
  15557. @code{suspend}
  15558. @item handle-lid-switch-docked
  15559. @code{ignore}
  15560. @item handle-lid-switch-external-power
  15561. @code{ignore}
  15562. @item power-key-ignore-inhibited?
  15563. @code{#f}
  15564. @item suspend-key-ignore-inhibited?
  15565. @code{#f}
  15566. @item hibernate-key-ignore-inhibited?
  15567. @code{#f}
  15568. @item lid-switch-ignore-inhibited?
  15569. @code{#t}
  15570. @item holdoff-timeout-seconds
  15571. @code{30}
  15572. @item idle-action
  15573. @code{ignore}
  15574. @item idle-action-seconds
  15575. @code{(* 30 60)}
  15576. @item runtime-directory-size-percent
  15577. @code{10}
  15578. @item runtime-directory-size
  15579. @code{#f}
  15580. @item remove-ipc?
  15581. @code{#t}
  15582. @item suspend-state
  15583. @code{("mem" "standby" "freeze")}
  15584. @item suspend-mode
  15585. @code{()}
  15586. @item hibernate-state
  15587. @code{("disk")}
  15588. @item hibernate-mode
  15589. @code{("platform" "shutdown")}
  15590. @item hybrid-sleep-state
  15591. @code{("disk")}
  15592. @item hybrid-sleep-mode
  15593. @code{("suspend" "platform" "shutdown")}
  15594. @end table
  15595. @end deffn
  15596. @deffn {Scheme Procedure} accountsservice-service @
  15597. [#:accountsservice @var{accountsservice}]
  15598. Return a service that runs AccountsService, a system service that can
  15599. list available accounts, change their passwords, and so on.
  15600. AccountsService integrates with PolicyKit to enable unprivileged users
  15601. to acquire the capability to modify their system configuration.
  15602. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  15603. accountsservice web site} for more information.
  15604. The @var{accountsservice} keyword argument is the @code{accountsservice}
  15605. package to expose as a service.
  15606. @end deffn
  15607. @deffn {Scheme Procedure} polkit-service @
  15608. [#:polkit @var{polkit}]
  15609. Return a service that runs the
  15610. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  15611. management service}, which allows system administrators to grant access to
  15612. privileged operations in a structured way. By querying the Polkit service, a
  15613. privileged system component can know when it should grant additional
  15614. capabilities to ordinary users. For example, an ordinary user can be granted
  15615. the capability to suspend the system if the user is logged in locally.
  15616. @end deffn
  15617. @defvr {Scheme Variable} polkit-wheel-service
  15618. Service that adds the @code{wheel} group as admins to the Polkit
  15619. service. This makes it so that users in the @code{wheel} group are queried
  15620. for their own passwords when performing administrative actions instead of
  15621. @code{root}'s, similar to the behaviour used by @code{sudo}.
  15622. @end defvr
  15623. @defvr {Scheme Variable} upower-service-type
  15624. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  15625. system-wide monitor for power consumption and battery levels, with the given
  15626. configuration settings.
  15627. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  15628. notably used by GNOME.
  15629. @end defvr
  15630. @deftp {Data Type} upower-configuration
  15631. Data type representation the configuration for UPower.
  15632. @table @asis
  15633. @item @code{upower} (default: @var{upower})
  15634. Package to use for @code{upower}.
  15635. @item @code{watts-up-pro?} (default: @code{#f})
  15636. Enable the Watts Up Pro device.
  15637. @item @code{poll-batteries?} (default: @code{#t})
  15638. Enable polling the kernel for battery level changes.
  15639. @item @code{ignore-lid?} (default: @code{#f})
  15640. Ignore the lid state, this can be useful if it's incorrect on a device.
  15641. @item @code{use-percentage-for-policy?} (default: @code{#f})
  15642. Whether battery percentage based policy should be used. The default is to use
  15643. the time left, change to @code{#t} to use the percentage.
  15644. @item @code{percentage-low} (default: @code{10})
  15645. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15646. at which the battery is considered low.
  15647. @item @code{percentage-critical} (default: @code{3})
  15648. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15649. at which the battery is considered critical.
  15650. @item @code{percentage-action} (default: @code{2})
  15651. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15652. at which action will be taken.
  15653. @item @code{time-low} (default: @code{1200})
  15654. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15655. seconds at which the battery is considered low.
  15656. @item @code{time-critical} (default: @code{300})
  15657. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15658. seconds at which the battery is considered critical.
  15659. @item @code{time-action} (default: @code{120})
  15660. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15661. seconds at which action will be taken.
  15662. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  15663. The action taken when @code{percentage-action} or @code{time-action} is
  15664. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  15665. Possible values are:
  15666. @itemize @bullet
  15667. @item
  15668. @code{'power-off}
  15669. @item
  15670. @code{'hibernate}
  15671. @item
  15672. @code{'hybrid-sleep}.
  15673. @end itemize
  15674. @end table
  15675. @end deftp
  15676. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  15677. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  15678. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  15679. with notifications and ways to mount/unmount disks. Programs that talk
  15680. to UDisks include the @command{udisksctl} command, part of UDisks, and
  15681. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  15682. it will only be able to use the file-system utilities installed in the
  15683. system profile. For example if you want to be able to mount NTFS
  15684. file-systems in read and write fashion, you'll need to have
  15685. @code{ntfs-3g} installed system-wide.
  15686. @end deffn
  15687. @deffn {Scheme Variable} colord-service-type
  15688. This is the type of the service that runs @command{colord}, a system
  15689. service with a D-Bus
  15690. interface to manage the color profiles of input and output devices such as
  15691. screens and scanners. It is notably used by the GNOME Color Manager graphical
  15692. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  15693. site} for more information.
  15694. @end deffn
  15695. @cindex scanner access
  15696. @defvr {Scheme Variable} sane-service-type
  15697. This service provides access to scanners @i{via}
  15698. @uref{http://www.sane-project.org, SANE} by installing the necessary
  15699. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  15700. Services}) and relies by default on @code{sane-backends-minimal} package
  15701. (see below) for hardware support.
  15702. @end defvr
  15703. @defvr {Scheme Variable} sane-backends-minimal
  15704. The default package which the @code{sane-service-type} installs. It
  15705. supports many recent scanners.
  15706. @end defvr
  15707. @defvr {Scheme Variable} sane-backends
  15708. This package includes support for all scanners that
  15709. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  15710. scanners supported by @code{hplip} package. In order to use this on
  15711. a system which relies on @code{%desktop-services}, you may use
  15712. @code{modify-services} (@pxref{Service Reference,
  15713. @code{modify-services}}) as illustrated below:
  15714. @lisp
  15715. (use-modules (gnu))
  15716. (use-service-modules
  15717. @dots{}
  15718. desktop)
  15719. (use-package-modules
  15720. @dots{}
  15721. scanner)
  15722. (define %my-desktop-services
  15723. ;; List of desktop services that supports a broader range of scanners.
  15724. (modify-services %desktop-services
  15725. (sane-service-type _ => sane-backends)))
  15726. (operating-system
  15727. @dots{}
  15728. (services %my-desktop-services)
  15729. @end lisp
  15730. @end defvr
  15731. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  15732. Return a configuration allowing an application to access GeoClue
  15733. location data. @var{name} is the Desktop ID of the application, without
  15734. the @code{.desktop} part. If @var{allowed?} is true, the application
  15735. will have access to location information by default. The boolean
  15736. @var{system?} value indicates whether an application is a system component
  15737. or not. Finally @var{users} is a list of UIDs of all users for which
  15738. this application is allowed location info access. An empty users list
  15739. means that all users are allowed.
  15740. @end deffn
  15741. @defvr {Scheme Variable} %standard-geoclue-applications
  15742. The standard list of well-known GeoClue application configurations,
  15743. granting authority to the GNOME date-and-time utility to ask for the
  15744. current location in order to set the time zone, and allowing the
  15745. IceCat and Epiphany web browsers to request location information.
  15746. IceCat and Epiphany both query the user before allowing a web page to
  15747. know the user's location.
  15748. @end defvr
  15749. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  15750. [#:whitelist '()] @
  15751. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  15752. [#:submit-data? #f]
  15753. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  15754. [#:submission-nick "geoclue"] @
  15755. [#:applications %standard-geoclue-applications]
  15756. Return a service that runs the GeoClue location service. This service
  15757. provides a D-Bus interface to allow applications to request access to a
  15758. user's physical location, and optionally to add information to online
  15759. location databases. See
  15760. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  15761. web site} for more information.
  15762. @end deffn
  15763. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  15764. [@w{#:auto-enable? #f}]
  15765. Return a service that runs the @command{bluetoothd} daemon, which
  15766. manages all the Bluetooth devices and provides a number of D-Bus
  15767. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  15768. powered automatically at boot, which can be useful when using a
  15769. bluetooth keyboard or mouse.
  15770. Users need to be in the @code{lp} group to access the D-Bus service.
  15771. @end deffn
  15772. @defvr {Scheme Variable} gnome-keyring-service-type
  15773. This is the type of the service that adds the
  15774. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  15775. value is a @code{gnome-keyring-configuration} object (see below).
  15776. This service adds the @code{gnome-keyring} package to the system profile
  15777. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  15778. a user's login keyring when they log in or setting its password with passwd.
  15779. @end defvr
  15780. @deftp {Data Type} gnome-keyring-configuration
  15781. Configuration record for the GNOME Keyring service.
  15782. @table @asis
  15783. @item @code{keyring} (default: @code{gnome-keyring})
  15784. The GNOME keyring package to use.
  15785. @item @code{pam-services}
  15786. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  15787. services to extend, where @var{service} is the name of an existing
  15788. service to extend and @var{kind} is one of @code{login} or
  15789. @code{passwd}.
  15790. If @code{login} is given, it adds an optional
  15791. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  15792. the session block with @code{auto_start}. If @code{passwd} is given, it
  15793. adds an optional @code{pam_gnome_keyring.so} to the password block
  15794. without arguments.
  15795. By default, this field contains ``gdm-password'' with the value @code{login}
  15796. and ``passwd'' is with the value @code{passwd}.
  15797. @end table
  15798. @end deftp
  15799. @node Sound Services
  15800. @subsection Sound Services
  15801. @cindex sound support
  15802. @cindex ALSA
  15803. @cindex PulseAudio, sound support
  15804. The @code{(gnu services sound)} module provides a service to configure the
  15805. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  15806. preferred ALSA output driver.
  15807. @deffn {Scheme Variable} alsa-service-type
  15808. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  15809. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  15810. configuration file. The value for this type is a @command{alsa-configuration}
  15811. record as in this example:
  15812. @lisp
  15813. (service alsa-service-type)
  15814. @end lisp
  15815. See below for details about @code{alsa-configuration}.
  15816. @end deffn
  15817. @deftp {Data Type} alsa-configuration
  15818. Data type representing the configuration for @code{alsa-service}.
  15819. @table @asis
  15820. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  15821. @code{alsa-plugins} package to use.
  15822. @item @code{pulseaudio?} (default: @var{#t})
  15823. Whether ALSA applications should transparently be made to use the
  15824. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  15825. Using PulseAudio allows you to run several sound-producing applications
  15826. at the same time and to individual control them @i{via}
  15827. @command{pavucontrol}, among other things.
  15828. @item @code{extra-options} (default: @var{""})
  15829. String to append to the @file{/etc/asound.conf} file.
  15830. @end table
  15831. @end deftp
  15832. Individual users who want to override the system configuration of ALSA can do
  15833. it with the @file{~/.asoundrc} file:
  15834. @example
  15835. # In guix, we have to specify the absolute path for plugins.
  15836. pcm_type.jack @{
  15837. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  15838. @}
  15839. # Routing ALSA to jack:
  15840. # <http://jackaudio.org/faq/routing_alsa.html>.
  15841. pcm.rawjack @{
  15842. type jack
  15843. playback_ports @{
  15844. 0 system:playback_1
  15845. 1 system:playback_2
  15846. @}
  15847. capture_ports @{
  15848. 0 system:capture_1
  15849. 1 system:capture_2
  15850. @}
  15851. @}
  15852. pcm.!default @{
  15853. type plug
  15854. slave @{
  15855. pcm "rawjack"
  15856. @}
  15857. @}
  15858. @end example
  15859. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  15860. details.
  15861. @deffn {Scheme Variable} pulseaudio-service-type
  15862. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  15863. sound server. It exists to allow system overrides of the default settings
  15864. via @code{pulseaudio-configuration}, see below.
  15865. @quotation Warning
  15866. This service overrides per-user configuration files. If you want
  15867. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  15868. have to unset the environment variables @env{PULSE_CONFIG} and
  15869. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  15870. @end quotation
  15871. @quotation Warning
  15872. This service on its own does not ensure, that the @code{pulseaudio} package
  15873. exists on your machine. It merely adds configuration files for it, as
  15874. detailed below. In the (admittedly unlikely) case, that you find yourself
  15875. without a @code{pulseaudio} package, consider enabling it through the
  15876. @code{alsa-service-type} above.
  15877. @end quotation
  15878. @end deffn
  15879. @deftp {Data Type} pulseaudio-configuration
  15880. Data type representing the configuration for @code{pulseaudio-service}.
  15881. @table @asis
  15882. @item @code{client-conf} (default: @code{'()})
  15883. List of settings to set in @file{client.conf}.
  15884. Accepts a list of strings or a symbol-value pairs. A string will be
  15885. inserted as-is with a newline added. A pair will be formatted as
  15886. ``key = value'', again with a newline added.
  15887. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  15888. List of settings to set in @file{daemon.conf}, formatted just like
  15889. @var{client-conf}.
  15890. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  15891. Script file to use as @file{default.pa}.
  15892. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  15893. Script file to use as @file{system.pa}.
  15894. @end table
  15895. @end deftp
  15896. @deffn {Scheme Variable} ladspa-service-type
  15897. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  15898. respect it, e.g. PulseAudio, can load LADSPA plugins.
  15899. The following example will setup the service to enable modules from the
  15900. @code{swh-plugins} package:
  15901. @lisp
  15902. (service ladspa-service-type
  15903. (ladspa-configuration (plugins (list swh-plugins))))
  15904. @end lisp
  15905. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  15906. details.
  15907. @end deffn
  15908. @node Database Services
  15909. @subsection Database Services
  15910. @cindex database
  15911. @cindex SQL
  15912. The @code{(gnu services databases)} module provides the following services.
  15913. @subsubheading PostgreSQL
  15914. The following example describes a PostgreSQL service with the default
  15915. configuration.
  15916. @lisp
  15917. (service postgresql-service-type
  15918. (postgresql-configuration
  15919. (postgresql postgresql-10)))
  15920. @end lisp
  15921. If the services fails to start, it may be due to an incompatible
  15922. cluster already present in @var{data-directory}. Adjust it (or, if you
  15923. don't need the cluster anymore, delete @var{data-directory}), then
  15924. restart the service.
  15925. Peer authentication is used by default and the @code{postgres} user
  15926. account has no shell, which prevents the direct execution of @code{psql}
  15927. commands as this user. To use @code{psql}, you can temporarily log in
  15928. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  15929. same name as one of the system users and then create the associated
  15930. database.
  15931. @example
  15932. sudo -u postgres -s /bin/sh
  15933. createuser --interactive
  15934. createdb $MY_USER_LOGIN # Replace appropriately.
  15935. @end example
  15936. @deftp {Data Type} postgresql-configuration
  15937. Data type representing the configuration for the
  15938. @code{postgresql-service-type}.
  15939. @table @asis
  15940. @item @code{postgresql}
  15941. PostgreSQL package to use for the service.
  15942. @item @code{port} (default: @code{5432})
  15943. Port on which PostgreSQL should listen.
  15944. @item @code{locale} (default: @code{"en_US.utf8"})
  15945. Locale to use as the default when creating the database cluster.
  15946. @item @code{config-file} (default: @code{(postgresql-config-file)})
  15947. The configuration file to use when running PostgreSQL@. The default
  15948. behaviour uses the postgresql-config-file record with the default values
  15949. for the fields.
  15950. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  15951. The directory where @command{pg_ctl} output will be written in a file
  15952. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  15953. configuration errors for instance.
  15954. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  15955. Directory in which to store the data.
  15956. @item @code{extension-packages} (default: @code{'()})
  15957. @cindex postgresql extension-packages
  15958. Additional extensions are loaded from packages listed in
  15959. @var{extension-packages}. Extensions are available at runtime. For instance,
  15960. to create a geographic database using the @code{postgis} extension, a user can
  15961. configure the postgresql-service as in this example:
  15962. @cindex postgis
  15963. @lisp
  15964. (use-package-modules databases geo)
  15965. (operating-system
  15966. ...
  15967. ;; postgresql is required to run `psql' but postgis is not required for
  15968. ;; proper operation.
  15969. (packages (cons* postgresql %base-packages))
  15970. (services
  15971. (cons*
  15972. (service postgresql-service-type
  15973. (postgresql-configuration
  15974. (postgresql postgresql-10)
  15975. (extension-packages (list postgis))))
  15976. %base-services)))
  15977. @end lisp
  15978. Then the extension becomes visible and you can initialise an empty geographic
  15979. database in this way:
  15980. @example
  15981. psql -U postgres
  15982. > create database postgistest;
  15983. > \connect postgistest;
  15984. > create extension postgis;
  15985. > create extension postgis_topology;
  15986. @end example
  15987. There is no need to add this field for contrib extensions such as hstore or
  15988. dblink as they are already loadable by postgresql. This field is only
  15989. required to add extensions provided by other packages.
  15990. @end table
  15991. @end deftp
  15992. @deftp {Data Type} postgresql-config-file
  15993. Data type representing the PostgreSQL configuration file. As shown in
  15994. the following example, this can be used to customize the configuration
  15995. of PostgreSQL@. Note that you can use any G-expression or filename in
  15996. place of this record, if you already have a configuration file you'd
  15997. like to use for example.
  15998. @lisp
  15999. (service postgresql-service-type
  16000. (postgresql-configuration
  16001. (config-file
  16002. (postgresql-config-file
  16003. (log-destination "stderr")
  16004. (hba-file
  16005. (plain-file "pg_hba.conf"
  16006. "
  16007. local all all trust
  16008. host all all 127.0.0.1/32 md5
  16009. host all all ::1/128 md5"))
  16010. (extra-config
  16011. '(("session_preload_libraries" "auto_explain")
  16012. ("random_page_cost" 2)
  16013. ("auto_explain.log_min_duration" "100 ms")
  16014. ("work_mem" "500 MB")
  16015. ("logging_collector" #t)
  16016. ("log_directory" "/var/log/postgresql")))))))
  16017. @end lisp
  16018. @table @asis
  16019. @item @code{log-destination} (default: @code{"syslog"})
  16020. The logging method to use for PostgreSQL@. Multiple values are accepted,
  16021. separated by commas.
  16022. @item @code{hba-file} (default: @code{%default-postgres-hba})
  16023. Filename or G-expression for the host-based authentication
  16024. configuration.
  16025. @item @code{ident-file} (default: @code{%default-postgres-ident})
  16026. Filename or G-expression for the user name mapping configuration.
  16027. @item @code{socket-directory} (default: @code{#false})
  16028. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  16029. is to listen for connections from client applications. If set to
  16030. @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
  16031. which case only TCP/IP sockets can be used to connect to the server.
  16032. By default, the @code{#false} value means the PostgreSQL default value
  16033. will be used, which is currently @samp{/tmp}.
  16034. @item @code{extra-config} (default: @code{'()})
  16035. List of additional keys and values to include in the PostgreSQL config
  16036. file. Each entry in the list should be a list where the first element
  16037. is the key, and the remaining elements are the values.
  16038. The values can be numbers, booleans or strings and will be mapped to
  16039. PostgreSQL parameters types @code{Boolean}, @code{String},
  16040. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  16041. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  16042. here}.
  16043. @end table
  16044. @end deftp
  16045. @deffn {Scheme Variable} postgresql-role-service-type
  16046. This service allows to create PostgreSQL roles and databases after
  16047. PostgreSQL service start. Here is an example of its use.
  16048. @lisp
  16049. (service postgresql-role-service-type
  16050. (postgresql-role-configuration
  16051. (roles
  16052. (list (postgresql-role
  16053. (name "test")
  16054. (create-database? #t))))))
  16055. @end lisp
  16056. This service can be extended with extra roles, as in this
  16057. example:
  16058. @lisp
  16059. (service-extension postgresql-role-service-type
  16060. (const (postgresql-role
  16061. (name "alice")
  16062. (create-database? #t))))
  16063. @end lisp
  16064. @end deffn
  16065. @deftp {Data Type} postgresql-role
  16066. PostgreSQL manages database access permissions using the concept of
  16067. roles. A role can be thought of as either a database user, or a group
  16068. of database users, depending on how the role is set up. Roles can own
  16069. database objects (for example, tables) and can assign privileges on
  16070. those objects to other roles to control who has access to which objects.
  16071. @table @asis
  16072. @item @code{name}
  16073. The role name.
  16074. @item @code{permissions} (default: @code{'(createdb login)})
  16075. The role permissions list. Supported permissions are @code{bypassrls},
  16076. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  16077. @code{superuser}.
  16078. @item @code{create-database?} (default: @code{#f})
  16079. Whether to create a database with the same name as the role.
  16080. @end table
  16081. @end deftp
  16082. @deftp {Data Type} postgresql-role-configuration
  16083. Data type representing the configuration of
  16084. @var{postgresql-role-service-type}.
  16085. @table @asis
  16086. @item @code{host} (default: @code{"/var/run/postgresql"})
  16087. The PostgreSQL host to connect to.
  16088. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  16089. File name of the log file.
  16090. @item @code{roles} (default: @code{'()})
  16091. The initial PostgreSQL roles to create.
  16092. @end table
  16093. @end deftp
  16094. @subsubheading MariaDB/MySQL
  16095. @defvr {Scheme Variable} mysql-service-type
  16096. This is the service type for a MySQL or MariaDB database server. Its value
  16097. is a @code{mysql-configuration} object that specifies which package to use,
  16098. as well as various settings for the @command{mysqld} daemon.
  16099. @end defvr
  16100. @deftp {Data Type} mysql-configuration
  16101. Data type representing the configuration of @var{mysql-service-type}.
  16102. @table @asis
  16103. @item @code{mysql} (default: @var{mariadb})
  16104. Package object of the MySQL database server, can be either @var{mariadb}
  16105. or @var{mysql}.
  16106. For MySQL, a temporary root password will be displayed at activation time.
  16107. For MariaDB, the root password is empty.
  16108. @item @code{bind-address} (default: @code{"127.0.0.1"})
  16109. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  16110. to bind to all available network interfaces.
  16111. @item @code{port} (default: @code{3306})
  16112. TCP port on which the database server listens for incoming connections.
  16113. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  16114. Socket file to use for local (non-network) connections.
  16115. @item @code{extra-content} (default: @code{""})
  16116. Additional settings for the @file{my.cnf} configuration file.
  16117. @item @code{auto-upgrade?} (default: @code{#t})
  16118. Whether to automatically run @command{mysql_upgrade} after starting the
  16119. service. This is necessary to upgrade the @dfn{system schema} after
  16120. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  16121. be disabled if you would rather do that manually.
  16122. @end table
  16123. @end deftp
  16124. @subsubheading Memcached
  16125. @defvr {Scheme Variable} memcached-service-type
  16126. This is the service type for the @uref{https://memcached.org/,
  16127. Memcached} service, which provides a distributed in memory cache. The
  16128. value for the service type is a @code{memcached-configuration} object.
  16129. @end defvr
  16130. @lisp
  16131. (service memcached-service-type)
  16132. @end lisp
  16133. @deftp {Data Type} memcached-configuration
  16134. Data type representing the configuration of memcached.
  16135. @table @asis
  16136. @item @code{memcached} (default: @code{memcached})
  16137. The Memcached package to use.
  16138. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  16139. Network interfaces on which to listen.
  16140. @item @code{tcp-port} (default: @code{11211})
  16141. Port on which to accept connections.
  16142. @item @code{udp-port} (default: @code{11211})
  16143. Port on which to accept UDP connections on, a value of 0 will disable
  16144. listening on a UDP socket.
  16145. @item @code{additional-options} (default: @code{'()})
  16146. Additional command line options to pass to @code{memcached}.
  16147. @end table
  16148. @end deftp
  16149. @subsubheading Redis
  16150. @defvr {Scheme Variable} redis-service-type
  16151. This is the service type for the @uref{https://redis.io/, Redis}
  16152. key/value store, whose value is a @code{redis-configuration} object.
  16153. @end defvr
  16154. @deftp {Data Type} redis-configuration
  16155. Data type representing the configuration of redis.
  16156. @table @asis
  16157. @item @code{redis} (default: @code{redis})
  16158. The Redis package to use.
  16159. @item @code{bind} (default: @code{"127.0.0.1"})
  16160. Network interface on which to listen.
  16161. @item @code{port} (default: @code{6379})
  16162. Port on which to accept connections on, a value of 0 will disable
  16163. listening on a TCP socket.
  16164. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  16165. Directory in which to store the database and related files.
  16166. @end table
  16167. @end deftp
  16168. @node Mail Services
  16169. @subsection Mail Services
  16170. @cindex mail
  16171. @cindex email
  16172. The @code{(gnu services mail)} module provides Guix service definitions
  16173. for email services: IMAP, POP3, and LMTP servers, as well as mail
  16174. transport agents (MTAs). Lots of acronyms! These services are detailed
  16175. in the subsections below.
  16176. @subsubheading Dovecot Service
  16177. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  16178. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  16179. @end deffn
  16180. By default, Dovecot does not need much configuration; the default
  16181. configuration object created by @code{(dovecot-configuration)} will
  16182. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  16183. certificate will be generated for TLS-protected connections, though
  16184. Dovecot will also listen on cleartext ports by default. There are a
  16185. number of options, though, which mail administrators might need to change,
  16186. and as is the case with other services, Guix allows the system
  16187. administrator to specify these parameters via a uniform Scheme interface.
  16188. For example, to specify that mail is located at @code{maildir~/.mail},
  16189. one would instantiate the Dovecot service like this:
  16190. @lisp
  16191. (dovecot-service #:config
  16192. (dovecot-configuration
  16193. (mail-location "maildir:~/.mail")))
  16194. @end lisp
  16195. The available configuration parameters follow. Each parameter
  16196. definition is preceded by its type; for example, @samp{string-list foo}
  16197. indicates that the @code{foo} parameter should be specified as a list of
  16198. strings. There is also a way to specify the configuration as a string,
  16199. if you have an old @code{dovecot.conf} file that you want to port over
  16200. from some other system; see the end for more details.
  16201. @c The following documentation was initially generated by
  16202. @c (generate-documentation) in (gnu services mail). Manually maintained
  16203. @c documentation is better, so we shouldn't hesitate to edit below as
  16204. @c needed. However if the change you want to make to this documentation
  16205. @c can be done in an automated way, it's probably easier to change
  16206. @c (generate-documentation) than to make it below and have to deal with
  16207. @c the churn as dovecot updates.
  16208. Available @code{dovecot-configuration} fields are:
  16209. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  16210. The dovecot package.
  16211. @end deftypevr
  16212. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  16213. A list of IPs or hosts where to listen for connections. @samp{*}
  16214. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  16215. interfaces. If you want to specify non-default ports or anything more
  16216. complex, customize the address and port fields of the
  16217. @samp{inet-listener} of the specific services you are interested in.
  16218. @end deftypevr
  16219. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  16220. List of protocols we want to serve. Available protocols include
  16221. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  16222. Available @code{protocol-configuration} fields are:
  16223. @deftypevr {@code{protocol-configuration} parameter} string name
  16224. The name of the protocol.
  16225. @end deftypevr
  16226. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  16227. UNIX socket path to the master authentication server to find users.
  16228. This is used by imap (for shared users) and lda.
  16229. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16230. @end deftypevr
  16231. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  16232. Space separated list of plugins to load.
  16233. @end deftypevr
  16234. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  16235. Maximum number of IMAP connections allowed for a user from each IP
  16236. address. NOTE: The username is compared case-sensitively.
  16237. Defaults to @samp{10}.
  16238. @end deftypevr
  16239. @end deftypevr
  16240. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  16241. List of services to enable. Available services include @samp{imap},
  16242. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  16243. @samp{lmtp}.
  16244. Available @code{service-configuration} fields are:
  16245. @deftypevr {@code{service-configuration} parameter} string kind
  16246. The service kind. Valid values include @code{director},
  16247. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  16248. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  16249. @code{tcpwrap}, @code{quota-warning}, or anything else.
  16250. @end deftypevr
  16251. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  16252. Listeners for the service. A listener is either a
  16253. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  16254. an @code{inet-listener-configuration}.
  16255. Defaults to @samp{()}.
  16256. Available @code{unix-listener-configuration} fields are:
  16257. @deftypevr {@code{unix-listener-configuration} parameter} string path
  16258. Path to the file, relative to @code{base-dir} field. This is also used as
  16259. the section name.
  16260. @end deftypevr
  16261. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  16262. The access mode for the socket.
  16263. Defaults to @samp{"0600"}.
  16264. @end deftypevr
  16265. @deftypevr {@code{unix-listener-configuration} parameter} string user
  16266. The user to own the socket.
  16267. Defaults to @samp{""}.
  16268. @end deftypevr
  16269. @deftypevr {@code{unix-listener-configuration} parameter} string group
  16270. The group to own the socket.
  16271. Defaults to @samp{""}.
  16272. @end deftypevr
  16273. Available @code{fifo-listener-configuration} fields are:
  16274. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  16275. Path to the file, relative to @code{base-dir} field. This is also used as
  16276. the section name.
  16277. @end deftypevr
  16278. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  16279. The access mode for the socket.
  16280. Defaults to @samp{"0600"}.
  16281. @end deftypevr
  16282. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  16283. The user to own the socket.
  16284. Defaults to @samp{""}.
  16285. @end deftypevr
  16286. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  16287. The group to own the socket.
  16288. Defaults to @samp{""}.
  16289. @end deftypevr
  16290. Available @code{inet-listener-configuration} fields are:
  16291. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  16292. The protocol to listen for.
  16293. @end deftypevr
  16294. @deftypevr {@code{inet-listener-configuration} parameter} string address
  16295. The address on which to listen, or empty for all addresses.
  16296. Defaults to @samp{""}.
  16297. @end deftypevr
  16298. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  16299. The port on which to listen.
  16300. @end deftypevr
  16301. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  16302. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  16303. @samp{required}.
  16304. Defaults to @samp{#t}.
  16305. @end deftypevr
  16306. @end deftypevr
  16307. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  16308. Maximum number of simultaneous client connections per process. Once
  16309. this number of connections is received, the next incoming connection
  16310. will prompt Dovecot to spawn another process. If set to 0,
  16311. @code{default-client-limit} is used instead.
  16312. Defaults to @samp{0}.
  16313. @end deftypevr
  16314. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  16315. Number of connections to handle before starting a new process.
  16316. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  16317. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  16318. Defaults to @samp{1}.
  16319. @end deftypevr
  16320. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  16321. Maximum number of processes that can exist for this service. If set to
  16322. 0, @code{default-process-limit} is used instead.
  16323. Defaults to @samp{0}.
  16324. @end deftypevr
  16325. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  16326. Number of processes to always keep waiting for more connections.
  16327. Defaults to @samp{0}.
  16328. @end deftypevr
  16329. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  16330. If you set @samp{service-count 0}, you probably need to grow
  16331. this.
  16332. Defaults to @samp{256000000}.
  16333. @end deftypevr
  16334. @end deftypevr
  16335. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  16336. Dict configuration, as created by the @code{dict-configuration}
  16337. constructor.
  16338. Available @code{dict-configuration} fields are:
  16339. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  16340. A list of key-value pairs that this dict should hold.
  16341. Defaults to @samp{()}.
  16342. @end deftypevr
  16343. @end deftypevr
  16344. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  16345. A list of passdb configurations, each one created by the
  16346. @code{passdb-configuration} constructor.
  16347. Available @code{passdb-configuration} fields are:
  16348. @deftypevr {@code{passdb-configuration} parameter} string driver
  16349. The driver that the passdb should use. Valid values include
  16350. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  16351. @samp{static}.
  16352. Defaults to @samp{"pam"}.
  16353. @end deftypevr
  16354. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  16355. Space separated list of arguments to the passdb driver.
  16356. Defaults to @samp{""}.
  16357. @end deftypevr
  16358. @end deftypevr
  16359. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  16360. List of userdb configurations, each one created by the
  16361. @code{userdb-configuration} constructor.
  16362. Available @code{userdb-configuration} fields are:
  16363. @deftypevr {@code{userdb-configuration} parameter} string driver
  16364. The driver that the userdb should use. Valid values include
  16365. @samp{passwd} and @samp{static}.
  16366. Defaults to @samp{"passwd"}.
  16367. @end deftypevr
  16368. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  16369. Space separated list of arguments to the userdb driver.
  16370. Defaults to @samp{""}.
  16371. @end deftypevr
  16372. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  16373. Override fields from passwd.
  16374. Defaults to @samp{()}.
  16375. @end deftypevr
  16376. @end deftypevr
  16377. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  16378. Plug-in configuration, created by the @code{plugin-configuration}
  16379. constructor.
  16380. @end deftypevr
  16381. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  16382. List of namespaces. Each item in the list is created by the
  16383. @code{namespace-configuration} constructor.
  16384. Available @code{namespace-configuration} fields are:
  16385. @deftypevr {@code{namespace-configuration} parameter} string name
  16386. Name for this namespace.
  16387. @end deftypevr
  16388. @deftypevr {@code{namespace-configuration} parameter} string type
  16389. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  16390. Defaults to @samp{"private"}.
  16391. @end deftypevr
  16392. @deftypevr {@code{namespace-configuration} parameter} string separator
  16393. Hierarchy separator to use. You should use the same separator for
  16394. all namespaces or some clients get confused. @samp{/} is usually a good
  16395. one. The default however depends on the underlying mail storage
  16396. format.
  16397. Defaults to @samp{""}.
  16398. @end deftypevr
  16399. @deftypevr {@code{namespace-configuration} parameter} string prefix
  16400. Prefix required to access this namespace. This needs to be
  16401. different for all namespaces. For example @samp{Public/}.
  16402. Defaults to @samp{""}.
  16403. @end deftypevr
  16404. @deftypevr {@code{namespace-configuration} parameter} string location
  16405. Physical location of the mailbox. This is in the same format as
  16406. mail_location, which is also the default for it.
  16407. Defaults to @samp{""}.
  16408. @end deftypevr
  16409. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  16410. There can be only one INBOX, and this setting defines which
  16411. namespace has it.
  16412. Defaults to @samp{#f}.
  16413. @end deftypevr
  16414. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  16415. If namespace is hidden, it's not advertised to clients via NAMESPACE
  16416. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  16417. useful when converting from another server with different namespaces
  16418. which you want to deprecate but still keep working. For example you can
  16419. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  16420. and @samp{mail/}.
  16421. Defaults to @samp{#f}.
  16422. @end deftypevr
  16423. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  16424. Show the mailboxes under this namespace with the LIST command. This
  16425. makes the namespace visible for clients that do not support the NAMESPACE
  16426. extension. The special @code{children} value lists child mailboxes, but
  16427. hides the namespace prefix.
  16428. Defaults to @samp{#t}.
  16429. @end deftypevr
  16430. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  16431. Namespace handles its own subscriptions. If set to @code{#f}, the
  16432. parent namespace handles them. The empty prefix should always have this
  16433. as @code{#t}).
  16434. Defaults to @samp{#t}.
  16435. @end deftypevr
  16436. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  16437. List of predefined mailboxes in this namespace.
  16438. Defaults to @samp{()}.
  16439. Available @code{mailbox-configuration} fields are:
  16440. @deftypevr {@code{mailbox-configuration} parameter} string name
  16441. Name for this mailbox.
  16442. @end deftypevr
  16443. @deftypevr {@code{mailbox-configuration} parameter} string auto
  16444. @samp{create} will automatically create this mailbox.
  16445. @samp{subscribe} will both create and subscribe to the mailbox.
  16446. Defaults to @samp{"no"}.
  16447. @end deftypevr
  16448. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  16449. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  16450. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  16451. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  16452. Defaults to @samp{()}.
  16453. @end deftypevr
  16454. @end deftypevr
  16455. @end deftypevr
  16456. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  16457. Base directory where to store runtime data.
  16458. Defaults to @samp{"/var/run/dovecot/"}.
  16459. @end deftypevr
  16460. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  16461. Greeting message for clients.
  16462. Defaults to @samp{"Dovecot ready."}.
  16463. @end deftypevr
  16464. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  16465. List of trusted network ranges. Connections from these IPs are
  16466. allowed to override their IP addresses and ports (for logging and for
  16467. authentication checks). @samp{disable-plaintext-auth} is also ignored
  16468. for these networks. Typically you would specify your IMAP proxy servers
  16469. here.
  16470. Defaults to @samp{()}.
  16471. @end deftypevr
  16472. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  16473. List of login access check sockets (e.g.@: tcpwrap).
  16474. Defaults to @samp{()}.
  16475. @end deftypevr
  16476. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  16477. Show more verbose process titles (in ps). Currently shows user name
  16478. and IP address. Useful for seeing who is actually using the IMAP
  16479. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  16480. accounts).
  16481. Defaults to @samp{#f}.
  16482. @end deftypevr
  16483. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  16484. Should all processes be killed when Dovecot master process shuts down.
  16485. Setting this to @code{#f} means that Dovecot can be upgraded without
  16486. forcing existing client connections to close (although that could also
  16487. be a problem if the upgrade is e.g.@: due to a security fix).
  16488. Defaults to @samp{#t}.
  16489. @end deftypevr
  16490. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  16491. If non-zero, run mail commands via this many connections to doveadm
  16492. server, instead of running them directly in the same process.
  16493. Defaults to @samp{0}.
  16494. @end deftypevr
  16495. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  16496. UNIX socket or host:port used for connecting to doveadm server.
  16497. Defaults to @samp{"doveadm-server"}.
  16498. @end deftypevr
  16499. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  16500. List of environment variables that are preserved on Dovecot startup
  16501. and passed down to all of its child processes. You can also give
  16502. key=value pairs to always set specific settings.
  16503. @end deftypevr
  16504. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  16505. Disable LOGIN command and all other plaintext authentications unless
  16506. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  16507. matches the local IP (i.e.@: you're connecting from the same computer),
  16508. the connection is considered secure and plaintext authentication is
  16509. allowed. See also ssl=required setting.
  16510. Defaults to @samp{#t}.
  16511. @end deftypevr
  16512. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  16513. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  16514. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  16515. for caching to be used.
  16516. Defaults to @samp{0}.
  16517. @end deftypevr
  16518. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  16519. Time to live for cached data. After TTL expires the cached record
  16520. is no longer used, *except* if the main database lookup returns internal
  16521. failure. We also try to handle password changes automatically: If
  16522. user's previous authentication was successful, but this one wasn't, the
  16523. cache isn't used. For now this works only with plaintext
  16524. authentication.
  16525. Defaults to @samp{"1 hour"}.
  16526. @end deftypevr
  16527. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  16528. TTL for negative hits (user not found, password mismatch).
  16529. 0 disables caching them completely.
  16530. Defaults to @samp{"1 hour"}.
  16531. @end deftypevr
  16532. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  16533. List of realms for SASL authentication mechanisms that need them.
  16534. You can leave it empty if you don't want to support multiple realms.
  16535. Many clients simply use the first one listed here, so keep the default
  16536. realm first.
  16537. Defaults to @samp{()}.
  16538. @end deftypevr
  16539. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  16540. Default realm/domain to use if none was specified. This is used for
  16541. both SASL realms and appending @@domain to username in plaintext
  16542. logins.
  16543. Defaults to @samp{""}.
  16544. @end deftypevr
  16545. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  16546. List of allowed characters in username. If the user-given username
  16547. contains a character not listed in here, the login automatically fails.
  16548. This is just an extra check to make sure user can't exploit any
  16549. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  16550. you want to allow all characters, set this value to empty.
  16551. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  16552. @end deftypevr
  16553. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  16554. Username character translations before it's looked up from
  16555. databases. The value contains series of from -> to characters. For
  16556. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  16557. translated to @samp{@@}.
  16558. Defaults to @samp{""}.
  16559. @end deftypevr
  16560. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  16561. Username formatting before it's looked up from databases. You can
  16562. use the standard variables here, e.g.@: %Lu would lowercase the username,
  16563. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  16564. change the @samp{@@} into @samp{-AT-}. This translation is done after
  16565. @samp{auth-username-translation} changes.
  16566. Defaults to @samp{"%Lu"}.
  16567. @end deftypevr
  16568. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  16569. If you want to allow master users to log in by specifying the master
  16570. username within the normal username string (i.e.@: not using SASL
  16571. mechanism's support for it), you can specify the separator character
  16572. here. The format is then <username><separator><master username>.
  16573. UW-IMAP uses @samp{*} as the separator, so that could be a good
  16574. choice.
  16575. Defaults to @samp{""}.
  16576. @end deftypevr
  16577. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  16578. Username to use for users logging in with ANONYMOUS SASL
  16579. mechanism.
  16580. Defaults to @samp{"anonymous"}.
  16581. @end deftypevr
  16582. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  16583. Maximum number of dovecot-auth worker processes. They're used to
  16584. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  16585. They're automatically created and destroyed as needed.
  16586. Defaults to @samp{30}.
  16587. @end deftypevr
  16588. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  16589. Host name to use in GSSAPI principal names. The default is to use
  16590. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  16591. allow all keytab entries.
  16592. Defaults to @samp{""}.
  16593. @end deftypevr
  16594. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  16595. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  16596. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  16597. need to change the auth service to run as root to be able to read this
  16598. file.
  16599. Defaults to @samp{""}.
  16600. @end deftypevr
  16601. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  16602. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  16603. and @samp{ntlm-auth} helper.
  16604. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  16605. Defaults to @samp{#f}.
  16606. @end deftypevr
  16607. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  16608. Path for Samba's @samp{ntlm-auth} helper binary.
  16609. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  16610. @end deftypevr
  16611. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  16612. Time to delay before replying to failed authentications.
  16613. Defaults to @samp{"2 secs"}.
  16614. @end deftypevr
  16615. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  16616. Require a valid SSL client certificate or the authentication
  16617. fails.
  16618. Defaults to @samp{#f}.
  16619. @end deftypevr
  16620. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  16621. Take the username from client's SSL certificate, using
  16622. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  16623. CommonName.
  16624. Defaults to @samp{#f}.
  16625. @end deftypevr
  16626. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  16627. List of wanted authentication mechanisms. Supported mechanisms are:
  16628. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  16629. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  16630. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  16631. @samp{disable-plaintext-auth} setting.
  16632. @end deftypevr
  16633. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  16634. List of IPs or hostnames to all director servers, including ourself.
  16635. Ports can be specified as ip:port. The default port is the same as what
  16636. director service's @samp{inet-listener} is using.
  16637. Defaults to @samp{()}.
  16638. @end deftypevr
  16639. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  16640. List of IPs or hostnames to all backend mail servers. Ranges are
  16641. allowed too, like 10.0.0.10-10.0.0.30.
  16642. Defaults to @samp{()}.
  16643. @end deftypevr
  16644. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  16645. How long to redirect users to a specific server after it no longer
  16646. has any connections.
  16647. Defaults to @samp{"15 min"}.
  16648. @end deftypevr
  16649. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  16650. How the username is translated before being hashed. Useful values
  16651. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  16652. are shared within domain.
  16653. Defaults to @samp{"%Lu"}.
  16654. @end deftypevr
  16655. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  16656. Log file to use for error messages. @samp{syslog} logs to syslog,
  16657. @samp{/dev/stderr} logs to stderr.
  16658. Defaults to @samp{"syslog"}.
  16659. @end deftypevr
  16660. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  16661. Log file to use for informational messages. Defaults to
  16662. @samp{log-path}.
  16663. Defaults to @samp{""}.
  16664. @end deftypevr
  16665. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  16666. Log file to use for debug messages. Defaults to
  16667. @samp{info-log-path}.
  16668. Defaults to @samp{""}.
  16669. @end deftypevr
  16670. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  16671. Syslog facility to use if you're logging to syslog. Usually if you
  16672. don't want to use @samp{mail}, you'll use local0..local7. Also other
  16673. standard facilities are supported.
  16674. Defaults to @samp{"mail"}.
  16675. @end deftypevr
  16676. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  16677. Log unsuccessful authentication attempts and the reasons why they
  16678. failed.
  16679. Defaults to @samp{#f}.
  16680. @end deftypevr
  16681. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  16682. In case of password mismatches, log the attempted password. Valid
  16683. values are no, plain and sha1. sha1 can be useful for detecting brute
  16684. force password attempts vs. user simply trying the same password over
  16685. and over again. You can also truncate the value to n chars by appending
  16686. ":n" (e.g.@: sha1:6).
  16687. Defaults to @samp{"no"}.
  16688. @end deftypevr
  16689. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  16690. Even more verbose logging for debugging purposes. Shows for example
  16691. SQL queries.
  16692. Defaults to @samp{#f}.
  16693. @end deftypevr
  16694. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  16695. In case of password mismatches, log the passwords and used scheme so
  16696. the problem can be debugged. Enabling this also enables
  16697. @samp{auth-debug}.
  16698. Defaults to @samp{#f}.
  16699. @end deftypevr
  16700. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  16701. Enable mail process debugging. This can help you figure out why
  16702. Dovecot isn't finding your mails.
  16703. Defaults to @samp{#f}.
  16704. @end deftypevr
  16705. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  16706. Show protocol level SSL errors.
  16707. Defaults to @samp{#f}.
  16708. @end deftypevr
  16709. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  16710. Prefix for each line written to log file. % codes are in
  16711. strftime(3) format.
  16712. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  16713. @end deftypevr
  16714. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  16715. List of elements we want to log. The elements which have a
  16716. non-empty variable value are joined together to form a comma-separated
  16717. string.
  16718. @end deftypevr
  16719. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  16720. Login log format. %s contains @samp{login-log-format-elements}
  16721. string, %$ contains the data we want to log.
  16722. Defaults to @samp{"%$: %s"}.
  16723. @end deftypevr
  16724. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  16725. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  16726. of possible variables you can use.
  16727. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  16728. @end deftypevr
  16729. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  16730. Format to use for logging mail deliveries. You can use variables:
  16731. @table @code
  16732. @item %$
  16733. Delivery status message (e.g.@: @samp{saved to INBOX})
  16734. @item %m
  16735. Message-ID
  16736. @item %s
  16737. Subject
  16738. @item %f
  16739. From address
  16740. @item %p
  16741. Physical size
  16742. @item %w
  16743. Virtual size.
  16744. @end table
  16745. Defaults to @samp{"msgid=%m: %$"}.
  16746. @end deftypevr
  16747. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  16748. Location for users' mailboxes. The default is empty, which means
  16749. that Dovecot tries to find the mailboxes automatically. This won't work
  16750. if the user doesn't yet have any mail, so you should explicitly tell
  16751. Dovecot the full location.
  16752. If you're using mbox, giving a path to the INBOX
  16753. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  16754. where the other mailboxes are kept. This is called the @emph{root mail
  16755. directory}, and it must be the first path given in the
  16756. @samp{mail-location} setting.
  16757. There are a few special variables you can use, e.g.:
  16758. @table @samp
  16759. @item %u
  16760. username
  16761. @item %n
  16762. user part in user@@domain, same as %u if there's no domain
  16763. @item %d
  16764. domain part in user@@domain, empty if there's no domain
  16765. @item %h
  16766. home director
  16767. @end table
  16768. See doc/wiki/Variables.txt for full list. Some examples:
  16769. @table @samp
  16770. @item maildir:~/Maildir
  16771. @item mbox:~/mail:INBOX=/var/mail/%u
  16772. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  16773. @end table
  16774. Defaults to @samp{""}.
  16775. @end deftypevr
  16776. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  16777. System user and group used to access mails. If you use multiple,
  16778. userdb can override these by returning uid or gid fields. You can use
  16779. either numbers or names. <doc/wiki/UserIds.txt>.
  16780. Defaults to @samp{""}.
  16781. @end deftypevr
  16782. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  16783. Defaults to @samp{""}.
  16784. @end deftypevr
  16785. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  16786. Group to enable temporarily for privileged operations. Currently
  16787. this is used only with INBOX when either its initial creation or
  16788. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  16789. @file{/var/mail}.
  16790. Defaults to @samp{""}.
  16791. @end deftypevr
  16792. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  16793. Grant access to these supplementary groups for mail processes.
  16794. Typically these are used to set up access to shared mailboxes. Note
  16795. that it may be dangerous to set these if users can create symlinks
  16796. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  16797. could allow a user to delete others' mailboxes, or @code{ln -s
  16798. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  16799. @samp{""}.
  16800. @end deftypevr
  16801. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  16802. Allow full file system access to clients. There's no access checks
  16803. other than what the operating system does for the active UID/GID@. It
  16804. works with both maildir and mboxes, allowing you to prefix mailboxes
  16805. names with e.g.@: @file{/path/} or @file{~user/}.
  16806. Defaults to @samp{#f}.
  16807. @end deftypevr
  16808. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  16809. Don't use @code{mmap()} at all. This is required if you store indexes to
  16810. shared file systems (NFS or clustered file system).
  16811. Defaults to @samp{#f}.
  16812. @end deftypevr
  16813. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  16814. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  16815. supports @samp{O_EXCL} since version 3, so this should be safe to use
  16816. nowadays by default.
  16817. Defaults to @samp{#t}.
  16818. @end deftypevr
  16819. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  16820. When to use fsync() or fdatasync() calls:
  16821. @table @code
  16822. @item optimized
  16823. Whenever necessary to avoid losing important data
  16824. @item always
  16825. Useful with e.g.@: NFS when @code{write()}s are delayed
  16826. @item never
  16827. Never use it (best performance, but crashes can lose data).
  16828. @end table
  16829. Defaults to @samp{"optimized"}.
  16830. @end deftypevr
  16831. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  16832. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  16833. NFS caches whenever needed. If you're using only a single mail server
  16834. this isn't needed.
  16835. Defaults to @samp{#f}.
  16836. @end deftypevr
  16837. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  16838. Mail index files also exist in NFS@. Setting this to yes requires
  16839. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  16840. Defaults to @samp{#f}.
  16841. @end deftypevr
  16842. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  16843. Locking method for index files. Alternatives are fcntl, flock and
  16844. dotlock. Dotlocking uses some tricks which may create more disk I/O
  16845. than other locking methods. NFS users: flock doesn't work, remember to
  16846. change @samp{mmap-disable}.
  16847. Defaults to @samp{"fcntl"}.
  16848. @end deftypevr
  16849. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  16850. Directory in which LDA/LMTP temporarily stores incoming mails >128
  16851. kB.
  16852. Defaults to @samp{"/tmp"}.
  16853. @end deftypevr
  16854. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  16855. Valid UID range for users. This is mostly to make sure that users can't
  16856. log in as daemons or other system users. Note that denying root logins is
  16857. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  16858. is set to 0.
  16859. Defaults to @samp{500}.
  16860. @end deftypevr
  16861. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  16862. Defaults to @samp{0}.
  16863. @end deftypevr
  16864. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  16865. Valid GID range for users. Users having non-valid GID as primary group ID
  16866. aren't allowed to log in. If user belongs to supplementary groups with
  16867. non-valid GIDs, those groups are not set.
  16868. Defaults to @samp{1}.
  16869. @end deftypevr
  16870. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  16871. Defaults to @samp{0}.
  16872. @end deftypevr
  16873. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  16874. Maximum allowed length for mail keyword name. It's only forced when
  16875. trying to create new keywords.
  16876. Defaults to @samp{50}.
  16877. @end deftypevr
  16878. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  16879. List of directories under which chrooting is allowed for mail
  16880. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  16881. too). This setting doesn't affect @samp{login-chroot}
  16882. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  16883. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  16884. which local users can modify, that may lead to root exploit. Usually
  16885. this should be done only if you don't allow shell access for users.
  16886. <doc/wiki/Chrooting.txt>.
  16887. Defaults to @samp{()}.
  16888. @end deftypevr
  16889. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  16890. Default chroot directory for mail processes. This can be overridden
  16891. for specific users in user database by giving @samp{/./} in user's home
  16892. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  16893. there is no real need to do chrooting, Dovecot doesn't allow users to
  16894. access files outside their mail directory anyway. If your home
  16895. directories are prefixed with the chroot directory, append @samp{/.} to
  16896. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  16897. Defaults to @samp{""}.
  16898. @end deftypevr
  16899. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  16900. UNIX socket path to master authentication server to find users.
  16901. This is used by imap (for shared users) and lda.
  16902. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16903. @end deftypevr
  16904. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  16905. Directory where to look up mail plugins.
  16906. Defaults to @samp{"/usr/lib/dovecot"}.
  16907. @end deftypevr
  16908. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  16909. List of plugins to load for all services. Plugins specific to IMAP,
  16910. LDA, etc.@: are added to this list in their own .conf files.
  16911. Defaults to @samp{()}.
  16912. @end deftypevr
  16913. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  16914. The minimum number of mails in a mailbox before updates are done to
  16915. cache file. This allows optimizing Dovecot's behavior to do less disk
  16916. writes at the cost of more disk reads.
  16917. Defaults to @samp{0}.
  16918. @end deftypevr
  16919. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  16920. When IDLE command is running, mailbox is checked once in a while to
  16921. see if there are any new mails or other changes. This setting defines
  16922. the minimum time to wait between those checks. Dovecot can also use
  16923. dnotify, inotify and kqueue to find out immediately when changes
  16924. occur.
  16925. Defaults to @samp{"30 secs"}.
  16926. @end deftypevr
  16927. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  16928. Save mails with CR+LF instead of plain LF@. This makes sending those
  16929. mails take less CPU, especially with sendfile() syscall with Linux and
  16930. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  16931. slower. Also note that if other software reads the mboxes/maildirs,
  16932. they may handle the extra CRs wrong and cause problems.
  16933. Defaults to @samp{#f}.
  16934. @end deftypevr
  16935. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  16936. By default LIST command returns all entries in maildir beginning
  16937. with a dot. Enabling this option makes Dovecot return only entries
  16938. which are directories. This is done by stat()ing each entry, so it
  16939. causes more disk I/O.
  16940. (For systems setting struct @samp{dirent->d_type} this check is free
  16941. and it's done always regardless of this setting).
  16942. Defaults to @samp{#f}.
  16943. @end deftypevr
  16944. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  16945. When copying a message, do it with hard links whenever possible.
  16946. This makes the performance much better, and it's unlikely to have any
  16947. side effects.
  16948. Defaults to @samp{#t}.
  16949. @end deftypevr
  16950. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  16951. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  16952. directory only when its mtime changes unexpectedly or when we can't find
  16953. the mail otherwise.
  16954. Defaults to @samp{#f}.
  16955. @end deftypevr
  16956. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  16957. Which locking methods to use for locking mbox. There are four
  16958. available:
  16959. @table @code
  16960. @item dotlock
  16961. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  16962. solution. If you want to use /var/mail/ like directory, the users will
  16963. need write access to that directory.
  16964. @item dotlock-try
  16965. Same as dotlock, but if it fails because of permissions or because there
  16966. isn't enough disk space, just skip it.
  16967. @item fcntl
  16968. Use this if possible. Works with NFS too if lockd is used.
  16969. @item flock
  16970. May not exist in all systems. Doesn't work with NFS.
  16971. @item lockf
  16972. May not exist in all systems. Doesn't work with NFS.
  16973. @end table
  16974. You can use multiple locking methods; if you do the order they're declared
  16975. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  16976. locking methods as well. Some operating systems don't allow using some of
  16977. them simultaneously.
  16978. @end deftypevr
  16979. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  16980. @end deftypevr
  16981. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  16982. Maximum time to wait for lock (all of them) before aborting.
  16983. Defaults to @samp{"5 mins"}.
  16984. @end deftypevr
  16985. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  16986. If dotlock exists but the mailbox isn't modified in any way,
  16987. override the lock file after this much time.
  16988. Defaults to @samp{"2 mins"}.
  16989. @end deftypevr
  16990. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  16991. When mbox changes unexpectedly we have to fully read it to find out
  16992. what changed. If the mbox is large this can take a long time. Since
  16993. the change is usually just a newly appended mail, it'd be faster to
  16994. simply read the new mails. If this setting is enabled, Dovecot does
  16995. this but still safely fallbacks to re-reading the whole mbox file
  16996. whenever something in mbox isn't how it's expected to be. The only real
  16997. downside to this setting is that if some other MUA changes message
  16998. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  16999. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  17000. Defaults to @samp{#t}.
  17001. @end deftypevr
  17002. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  17003. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  17004. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  17005. @samp{mbox-dirty-syncs} is ignored.
  17006. Defaults to @samp{#f}.
  17007. @end deftypevr
  17008. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  17009. Delay writing mbox headers until doing a full write sync (EXPUNGE
  17010. and CHECK commands and when closing the mailbox). This is especially
  17011. useful for POP3 where clients often delete all mails. The downside is
  17012. that our changes aren't immediately visible to other MUAs.
  17013. Defaults to @samp{#t}.
  17014. @end deftypevr
  17015. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  17016. If mbox size is smaller than this (e.g.@: 100k), don't write index
  17017. files. If an index file already exists it's still read, just not
  17018. updated.
  17019. Defaults to @samp{0}.
  17020. @end deftypevr
  17021. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  17022. Maximum dbox file size until it's rotated.
  17023. Defaults to @samp{10000000}.
  17024. @end deftypevr
  17025. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  17026. Maximum dbox file age until it's rotated. Typically in days. Day
  17027. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  17028. disabled.
  17029. Defaults to @samp{"1d"}.
  17030. @end deftypevr
  17031. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  17032. When creating new mdbox files, immediately preallocate their size to
  17033. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  17034. with some file systems (ext4, xfs).
  17035. Defaults to @samp{#f}.
  17036. @end deftypevr
  17037. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  17038. sdbox and mdbox support saving mail attachments to external files,
  17039. which also allows single instance storage for them. Other backends
  17040. don't support this for now.
  17041. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  17042. Directory root where to store mail attachments. Disabled, if empty.
  17043. Defaults to @samp{""}.
  17044. @end deftypevr
  17045. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  17046. Attachments smaller than this aren't saved externally. It's also
  17047. possible to write a plugin to disable saving specific attachments
  17048. externally.
  17049. Defaults to @samp{128000}.
  17050. @end deftypevr
  17051. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  17052. File system backend to use for saving attachments:
  17053. @table @code
  17054. @item posix
  17055. No SiS done by Dovecot (but this might help FS's own deduplication)
  17056. @item sis posix
  17057. SiS with immediate byte-by-byte comparison during saving
  17058. @item sis-queue posix
  17059. SiS with delayed comparison and deduplication.
  17060. @end table
  17061. Defaults to @samp{"sis posix"}.
  17062. @end deftypevr
  17063. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  17064. Hash format to use in attachment filenames. You can add any text and
  17065. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  17066. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  17067. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  17068. Defaults to @samp{"%@{sha1@}"}.
  17069. @end deftypevr
  17070. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  17071. Defaults to @samp{100}.
  17072. @end deftypevr
  17073. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  17074. Defaults to @samp{1000}.
  17075. @end deftypevr
  17076. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  17077. Default VSZ (virtual memory size) limit for service processes.
  17078. This is mainly intended to catch and kill processes that leak memory
  17079. before they eat up everything.
  17080. Defaults to @samp{256000000}.
  17081. @end deftypevr
  17082. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  17083. Login user is internally used by login processes. This is the most
  17084. untrusted user in Dovecot system. It shouldn't have access to anything
  17085. at all.
  17086. Defaults to @samp{"dovenull"}.
  17087. @end deftypevr
  17088. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  17089. Internal user is used by unprivileged processes. It should be
  17090. separate from login user, so that login processes can't disturb other
  17091. processes.
  17092. Defaults to @samp{"dovecot"}.
  17093. @end deftypevr
  17094. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  17095. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  17096. Defaults to @samp{"required"}.
  17097. @end deftypevr
  17098. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  17099. PEM encoded X.509 SSL/TLS certificate (public key).
  17100. Defaults to @samp{"</etc/dovecot/default.pem"}.
  17101. @end deftypevr
  17102. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  17103. PEM encoded SSL/TLS private key. The key is opened before
  17104. dropping root privileges, so keep the key file unreadable by anyone but
  17105. root.
  17106. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  17107. @end deftypevr
  17108. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  17109. If key file is password protected, give the password here.
  17110. Alternatively give it when starting dovecot with -p parameter. Since
  17111. this file is often world-readable, you may want to place this setting
  17112. instead to a different.
  17113. Defaults to @samp{""}.
  17114. @end deftypevr
  17115. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  17116. PEM encoded trusted certificate authority. Set this only if you
  17117. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  17118. contain the CA certificate(s) followed by the matching
  17119. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  17120. Defaults to @samp{""}.
  17121. @end deftypevr
  17122. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  17123. Require that CRL check succeeds for client certificates.
  17124. Defaults to @samp{#t}.
  17125. @end deftypevr
  17126. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  17127. Request client to send a certificate. If you also want to require
  17128. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  17129. Defaults to @samp{#f}.
  17130. @end deftypevr
  17131. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  17132. Which field from certificate to use for username. commonName and
  17133. x500UniqueIdentifier are the usual choices. You'll also need to set
  17134. @samp{auth-ssl-username-from-cert? #t}.
  17135. Defaults to @samp{"commonName"}.
  17136. @end deftypevr
  17137. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  17138. Minimum SSL protocol version to accept.
  17139. Defaults to @samp{"TLSv1"}.
  17140. @end deftypevr
  17141. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  17142. SSL ciphers to use.
  17143. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  17144. @end deftypevr
  17145. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  17146. SSL crypto device to use, for valid values run "openssl engine".
  17147. Defaults to @samp{""}.
  17148. @end deftypevr
  17149. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  17150. Address to use when sending rejection mails.
  17151. %d expands to recipient domain.
  17152. Defaults to @samp{"postmaster@@%d"}.
  17153. @end deftypevr
  17154. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  17155. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  17156. and in LMTP replies. Default is the system's real hostname@@domain.
  17157. Defaults to @samp{""}.
  17158. @end deftypevr
  17159. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  17160. If user is over quota, return with temporary failure instead of
  17161. bouncing the mail.
  17162. Defaults to @samp{#f}.
  17163. @end deftypevr
  17164. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  17165. Binary to use for sending mails.
  17166. Defaults to @samp{"/usr/sbin/sendmail"}.
  17167. @end deftypevr
  17168. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  17169. If non-empty, send mails via this SMTP host[:port] instead of
  17170. sendmail.
  17171. Defaults to @samp{""}.
  17172. @end deftypevr
  17173. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  17174. Subject: header to use for rejection mails. You can use the same
  17175. variables as for @samp{rejection-reason} below.
  17176. Defaults to @samp{"Rejected: %s"}.
  17177. @end deftypevr
  17178. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  17179. Human readable error message for rejection mails. You can use
  17180. variables:
  17181. @table @code
  17182. @item %n
  17183. CRLF
  17184. @item %r
  17185. reason
  17186. @item %s
  17187. original subject
  17188. @item %t
  17189. recipient
  17190. @end table
  17191. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  17192. @end deftypevr
  17193. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  17194. Delimiter character between local-part and detail in email
  17195. address.
  17196. Defaults to @samp{"+"}.
  17197. @end deftypevr
  17198. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  17199. Header where the original recipient address (SMTP's RCPT TO:
  17200. address) is taken from if not available elsewhere. With dovecot-lda -a
  17201. parameter overrides this. A commonly used header for this is
  17202. X-Original-To.
  17203. Defaults to @samp{""}.
  17204. @end deftypevr
  17205. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  17206. Should saving a mail to a nonexistent mailbox automatically create
  17207. it?.
  17208. Defaults to @samp{#f}.
  17209. @end deftypevr
  17210. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  17211. Should automatically created mailboxes be also automatically
  17212. subscribed?.
  17213. Defaults to @samp{#f}.
  17214. @end deftypevr
  17215. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  17216. Maximum IMAP command line length. Some clients generate very long
  17217. command lines with huge mailboxes, so you may need to raise this if you
  17218. get "Too long argument" or "IMAP command line too large" errors
  17219. often.
  17220. Defaults to @samp{64000}.
  17221. @end deftypevr
  17222. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  17223. IMAP logout format string:
  17224. @table @code
  17225. @item %i
  17226. total number of bytes read from client
  17227. @item %o
  17228. total number of bytes sent to client.
  17229. @end table
  17230. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  17231. 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@}"}.
  17232. @end deftypevr
  17233. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  17234. Override the IMAP CAPABILITY response. If the value begins with '+',
  17235. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  17236. Defaults to @samp{""}.
  17237. @end deftypevr
  17238. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  17239. How long to wait between "OK Still here" notifications when client
  17240. is IDLEing.
  17241. Defaults to @samp{"2 mins"}.
  17242. @end deftypevr
  17243. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  17244. ID field names and values to send to clients. Using * as the value
  17245. makes Dovecot use the default value. The following fields have default
  17246. values currently: name, version, os, os-version, support-url,
  17247. support-email.
  17248. Defaults to @samp{""}.
  17249. @end deftypevr
  17250. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  17251. ID fields sent by client to log. * means everything.
  17252. Defaults to @samp{""}.
  17253. @end deftypevr
  17254. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  17255. Workarounds for various client bugs:
  17256. @table @code
  17257. @item delay-newmail
  17258. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  17259. CHECK commands. Some clients ignore them otherwise, for example OSX
  17260. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  17261. may show user "Message no longer in server" errors. Note that OE6
  17262. still breaks even with this workaround if synchronization is set to
  17263. "Headers Only".
  17264. @item tb-extra-mailbox-sep
  17265. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  17266. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  17267. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  17268. @item tb-lsub-flags
  17269. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  17270. This makes Thunderbird realize they aren't selectable and show them
  17271. greyed out, instead of only later giving "not selectable" popup error.
  17272. @end table
  17273. Defaults to @samp{()}.
  17274. @end deftypevr
  17275. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  17276. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  17277. Defaults to @samp{""}.
  17278. @end deftypevr
  17279. Whew! Lots of configuration options. The nice thing about it though is
  17280. that Guix has a complete interface to Dovecot's configuration
  17281. language. This allows not only a nice way to declare configurations,
  17282. but also offers reflective capabilities as well: users can write code to
  17283. inspect and transform configurations from within Scheme.
  17284. However, it could be that you just want to get a @code{dovecot.conf} up
  17285. and running. In that case, you can pass an
  17286. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  17287. @code{dovecot-service}. As its name indicates, an opaque configuration
  17288. does not have easy reflective capabilities.
  17289. Available @code{opaque-dovecot-configuration} fields are:
  17290. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  17291. The dovecot package.
  17292. @end deftypevr
  17293. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  17294. The contents of the @code{dovecot.conf}, as a string.
  17295. @end deftypevr
  17296. For example, if your @code{dovecot.conf} is just the empty string, you
  17297. could instantiate a dovecot service like this:
  17298. @lisp
  17299. (dovecot-service #:config
  17300. (opaque-dovecot-configuration
  17301. (string "")))
  17302. @end lisp
  17303. @subsubheading OpenSMTPD Service
  17304. @deffn {Scheme Variable} opensmtpd-service-type
  17305. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  17306. service, whose value should be an @code{opensmtpd-configuration} object
  17307. as in this example:
  17308. @lisp
  17309. (service opensmtpd-service-type
  17310. (opensmtpd-configuration
  17311. (config-file (local-file "./my-smtpd.conf"))))
  17312. @end lisp
  17313. @end deffn
  17314. @deftp {Data Type} opensmtpd-configuration
  17315. Data type representing the configuration of opensmtpd.
  17316. @table @asis
  17317. @item @code{package} (default: @var{opensmtpd})
  17318. Package object of the OpenSMTPD SMTP server.
  17319. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  17320. File-like object of the OpenSMTPD configuration file to use. By default
  17321. it listens on the loopback network interface, and allows for mail from
  17322. users and daemons on the local machine, as well as permitting email to
  17323. remote servers. Run @command{man smtpd.conf} for more information.
  17324. @end table
  17325. @end deftp
  17326. @subsubheading Exim Service
  17327. @cindex mail transfer agent (MTA)
  17328. @cindex MTA (mail transfer agent)
  17329. @cindex SMTP
  17330. @deffn {Scheme Variable} exim-service-type
  17331. This is the type of the @uref{https://exim.org, Exim} mail transfer
  17332. agent (MTA), whose value should be an @code{exim-configuration} object
  17333. as in this example:
  17334. @lisp
  17335. (service exim-service-type
  17336. (exim-configuration
  17337. (config-file (local-file "./my-exim.conf"))))
  17338. @end lisp
  17339. @end deffn
  17340. In order to use an @code{exim-service-type} service you must also have a
  17341. @code{mail-aliases-service-type} service present in your
  17342. @code{operating-system} (even if it has no aliases).
  17343. @deftp {Data Type} exim-configuration
  17344. Data type representing the configuration of exim.
  17345. @table @asis
  17346. @item @code{package} (default: @var{exim})
  17347. Package object of the Exim server.
  17348. @item @code{config-file} (default: @code{#f})
  17349. File-like object of the Exim configuration file to use. If its value is
  17350. @code{#f} then use the default configuration file from the package
  17351. provided in @code{package}. The resulting configuration file is loaded
  17352. after setting the @code{exim_user} and @code{exim_group} configuration
  17353. variables.
  17354. @end table
  17355. @end deftp
  17356. @subsubheading Getmail service
  17357. @cindex IMAP
  17358. @cindex POP
  17359. @deffn {Scheme Variable} getmail-service-type
  17360. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  17361. mail retriever, whose value should be an @code{getmail-configuration}.
  17362. @end deffn
  17363. Available @code{getmail-configuration} fields are:
  17364. @deftypevr {@code{getmail-configuration} parameter} symbol name
  17365. A symbol to identify the getmail service.
  17366. Defaults to @samp{"unset"}.
  17367. @end deftypevr
  17368. @deftypevr {@code{getmail-configuration} parameter} package package
  17369. The getmail package to use.
  17370. @end deftypevr
  17371. @deftypevr {@code{getmail-configuration} parameter} string user
  17372. The user to run getmail as.
  17373. Defaults to @samp{"getmail"}.
  17374. @end deftypevr
  17375. @deftypevr {@code{getmail-configuration} parameter} string group
  17376. The group to run getmail as.
  17377. Defaults to @samp{"getmail"}.
  17378. @end deftypevr
  17379. @deftypevr {@code{getmail-configuration} parameter} string directory
  17380. The getmail directory to use.
  17381. Defaults to @samp{"/var/lib/getmail/default"}.
  17382. @end deftypevr
  17383. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  17384. The getmail configuration file to use.
  17385. Available @code{getmail-configuration-file} fields are:
  17386. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  17387. What mail account to retrieve mail from, and how to access that account.
  17388. Available @code{getmail-retriever-configuration} fields are:
  17389. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  17390. The type of mail retriever to use. Valid values include @samp{passwd}
  17391. and @samp{static}.
  17392. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  17393. @end deftypevr
  17394. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  17395. Username to login to the mail server with.
  17396. Defaults to @samp{unset}.
  17397. @end deftypevr
  17398. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  17399. Username to login to the mail server with.
  17400. Defaults to @samp{unset}.
  17401. @end deftypevr
  17402. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  17403. Port number to connect to.
  17404. Defaults to @samp{#f}.
  17405. @end deftypevr
  17406. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  17407. Override fields from passwd.
  17408. Defaults to @samp{""}.
  17409. @end deftypevr
  17410. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  17411. Override fields from passwd.
  17412. Defaults to @samp{()}.
  17413. @end deftypevr
  17414. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  17415. PEM-formatted key file to use for the TLS negotiation.
  17416. Defaults to @samp{""}.
  17417. @end deftypevr
  17418. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  17419. PEM-formatted certificate file to use for the TLS negotiation.
  17420. Defaults to @samp{""}.
  17421. @end deftypevr
  17422. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  17423. CA certificates to use.
  17424. Defaults to @samp{""}.
  17425. @end deftypevr
  17426. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  17427. Extra retriever parameters.
  17428. Defaults to @samp{()}.
  17429. @end deftypevr
  17430. @end deftypevr
  17431. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  17432. What to do with retrieved messages.
  17433. Available @code{getmail-destination-configuration} fields are:
  17434. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  17435. The type of mail destination. Valid values include @samp{Maildir},
  17436. @samp{Mboxrd} and @samp{MDA_external}.
  17437. Defaults to @samp{unset}.
  17438. @end deftypevr
  17439. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  17440. The path option for the mail destination. The behaviour depends on the
  17441. chosen type.
  17442. Defaults to @samp{""}.
  17443. @end deftypevr
  17444. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  17445. Extra destination parameters
  17446. Defaults to @samp{()}.
  17447. @end deftypevr
  17448. @end deftypevr
  17449. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  17450. Configure getmail.
  17451. Available @code{getmail-options-configuration} fields are:
  17452. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  17453. If set to @samp{0}, getmail will only print warnings and errors. A
  17454. value of @samp{1} means that messages will be printed about retrieving
  17455. and deleting messages. If set to @samp{2}, getmail will print messages
  17456. about each of it's actions.
  17457. Defaults to @samp{1}.
  17458. @end deftypevr
  17459. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  17460. If true, getmail will retrieve all available messages. Otherwise it
  17461. will only retrieve messages it hasn't seen previously.
  17462. Defaults to @samp{#t}.
  17463. @end deftypevr
  17464. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  17465. If set to true, messages will be deleted from the server after
  17466. retrieving and successfully delivering them. Otherwise, messages will
  17467. be left on the server.
  17468. Defaults to @samp{#f}.
  17469. @end deftypevr
  17470. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  17471. Getmail will delete messages this number of days after seeing them, if
  17472. they have been delivered. This means messages will be left on the
  17473. server this number of days after delivering them. A value of @samp{0}
  17474. disabled this feature.
  17475. Defaults to @samp{0}.
  17476. @end deftypevr
  17477. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  17478. Delete messages larger than this of bytes after retrieving them, even if
  17479. the delete and delete-after options are disabled. A value of @samp{0}
  17480. disables this feature.
  17481. Defaults to @samp{0}.
  17482. @end deftypevr
  17483. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  17484. Retrieve messages totalling up to this number of bytes before closing
  17485. the session with the server. A value of @samp{0} disables this feature.
  17486. Defaults to @samp{0}.
  17487. @end deftypevr
  17488. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  17489. Don't retrieve messages larger than this number of bytes. A value of
  17490. @samp{0} disables this feature.
  17491. Defaults to @samp{0}.
  17492. @end deftypevr
  17493. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  17494. If true, getmail will add a Delivered-To header to messages.
  17495. Defaults to @samp{#t}.
  17496. @end deftypevr
  17497. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  17498. If set, getmail adds a Received header to the messages.
  17499. Defaults to @samp{#t}.
  17500. @end deftypevr
  17501. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  17502. Getmail will record a log of its actions to the named file. A value of
  17503. @samp{""} disables this feature.
  17504. Defaults to @samp{""}.
  17505. @end deftypevr
  17506. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  17507. If true, getmail will record a log of its actions using the system
  17508. logger.
  17509. Defaults to @samp{#f}.
  17510. @end deftypevr
  17511. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  17512. If true, getmail will log information about messages not retrieved and
  17513. the reason for not retrieving them, as well as starting and ending
  17514. information lines.
  17515. Defaults to @samp{#f}.
  17516. @end deftypevr
  17517. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  17518. Extra options to include.
  17519. Defaults to @samp{()}.
  17520. @end deftypevr
  17521. @end deftypevr
  17522. @end deftypevr
  17523. @deftypevr {@code{getmail-configuration} parameter} list idle
  17524. A list of mailboxes that getmail should wait on the server for new mail
  17525. notifications. This depends on the server supporting the IDLE
  17526. extension.
  17527. Defaults to @samp{()}.
  17528. @end deftypevr
  17529. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  17530. Environment variables to set for getmail.
  17531. Defaults to @samp{()}.
  17532. @end deftypevr
  17533. @subsubheading Mail Aliases Service
  17534. @cindex email aliases
  17535. @cindex aliases, for email addresses
  17536. @deffn {Scheme Variable} mail-aliases-service-type
  17537. This is the type of the service which provides @code{/etc/aliases},
  17538. specifying how to deliver mail to users on this system.
  17539. @lisp
  17540. (service mail-aliases-service-type
  17541. '(("postmaster" "bob")
  17542. ("bob" "bob@@example.com" "bob@@example2.com")))
  17543. @end lisp
  17544. @end deffn
  17545. The configuration for a @code{mail-aliases-service-type} service is an
  17546. association list denoting how to deliver mail that comes to this
  17547. system. Each entry is of the form @code{(alias addresses ...)}, with
  17548. @code{alias} specifying the local alias and @code{addresses} specifying
  17549. where to deliver this user's mail.
  17550. The aliases aren't required to exist as users on the local system. In
  17551. the above example, there doesn't need to be a @code{postmaster} entry in
  17552. the @code{operating-system}'s @code{user-accounts} in order to deliver
  17553. the @code{postmaster} mail to @code{bob} (which subsequently would
  17554. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  17555. @subsubheading GNU Mailutils IMAP4 Daemon
  17556. @cindex GNU Mailutils IMAP4 Daemon
  17557. @deffn {Scheme Variable} imap4d-service-type
  17558. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  17559. mailutils, GNU Mailutils Manual}), whose value should be an
  17560. @code{imap4d-configuration} object as in this example:
  17561. @lisp
  17562. (service imap4d-service-type
  17563. (imap4d-configuration
  17564. (config-file (local-file "imap4d.conf"))))
  17565. @end lisp
  17566. @end deffn
  17567. @deftp {Data Type} imap4d-configuration
  17568. Data type representing the configuration of @command{imap4d}.
  17569. @table @asis
  17570. @item @code{package} (default: @code{mailutils})
  17571. The package that provides @command{imap4d}.
  17572. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  17573. File-like object of the configuration file to use, by default it will listen
  17574. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  17575. Mailutils Manual}, for details.
  17576. @end table
  17577. @end deftp
  17578. @subsubheading Radicale Service
  17579. @cindex CalDAV
  17580. @cindex CardDAV
  17581. @deffn {Scheme Variable} radicale-service-type
  17582. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  17583. server whose value should be a @code{radicale-configuration}.
  17584. @end deffn
  17585. @deftp {Data Type} radicale-configuration
  17586. Data type representing the configuration of @command{radicale}.
  17587. @table @asis
  17588. @item @code{package} (default: @code{radicale})
  17589. The package that provides @command{radicale}.
  17590. @item @code{config-file} (default: @code{%default-radicale-config-file})
  17591. File-like object of the configuration file to use, by default it will listen
  17592. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  17593. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  17594. @end table
  17595. @end deftp
  17596. @node Messaging Services
  17597. @subsection Messaging Services
  17598. @cindex messaging
  17599. @cindex jabber
  17600. @cindex XMPP
  17601. The @code{(gnu services messaging)} module provides Guix service
  17602. definitions for messaging services. Currently it provides the following
  17603. services:
  17604. @subsubheading Prosody Service
  17605. @deffn {Scheme Variable} prosody-service-type
  17606. This is the type for the @uref{https://prosody.im, Prosody XMPP
  17607. communication server}. Its value must be a @code{prosody-configuration}
  17608. record as in this example:
  17609. @lisp
  17610. (service prosody-service-type
  17611. (prosody-configuration
  17612. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  17613. (int-components
  17614. (list
  17615. (int-component-configuration
  17616. (hostname "conference.example.net")
  17617. (plugin "muc")
  17618. (mod-muc (mod-muc-configuration)))))
  17619. (virtualhosts
  17620. (list
  17621. (virtualhost-configuration
  17622. (domain "example.net"))))))
  17623. @end lisp
  17624. See below for details about @code{prosody-configuration}.
  17625. @end deffn
  17626. By default, Prosody does not need much configuration. Only one
  17627. @code{virtualhosts} field is needed: it specifies the domain you wish
  17628. Prosody to serve.
  17629. You can perform various sanity checks on the generated configuration
  17630. with the @code{prosodyctl check} command.
  17631. Prosodyctl will also help you to import certificates from the
  17632. @code{letsencrypt} directory so that the @code{prosody} user can access
  17633. them. See @url{https://prosody.im/doc/letsencrypt}.
  17634. @example
  17635. prosodyctl --root cert import /etc/letsencrypt/live
  17636. @end example
  17637. The available configuration parameters follow. Each parameter
  17638. definition is preceded by its type; for example, @samp{string-list foo}
  17639. indicates that the @code{foo} parameter should be specified as a list of
  17640. strings. Types starting with @code{maybe-} denote parameters that won't
  17641. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  17642. There is also a way to specify the configuration as a string, if you
  17643. have an old @code{prosody.cfg.lua} file that you want to port over from
  17644. some other system; see the end for more details.
  17645. The @code{file-object} type designates either a file-like object
  17646. (@pxref{G-Expressions, file-like objects}) or a file name.
  17647. @c The following documentation was initially generated by
  17648. @c (generate-documentation) in (gnu services messaging). Manually maintained
  17649. @c documentation is better, so we shouldn't hesitate to edit below as
  17650. @c needed. However if the change you want to make to this documentation
  17651. @c can be done in an automated way, it's probably easier to change
  17652. @c (generate-documentation) than to make it below and have to deal with
  17653. @c the churn as Prosody updates.
  17654. Available @code{prosody-configuration} fields are:
  17655. @deftypevr {@code{prosody-configuration} parameter} package prosody
  17656. The Prosody package.
  17657. @end deftypevr
  17658. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  17659. Location of the Prosody data storage directory. See
  17660. @url{https://prosody.im/doc/configure}.
  17661. Defaults to @samp{"/var/lib/prosody"}.
  17662. @end deftypevr
  17663. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  17664. Additional plugin directories. They are searched in all the specified
  17665. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  17666. Defaults to @samp{()}.
  17667. @end deftypevr
  17668. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  17669. Every virtual host and component needs a certificate so that clients and
  17670. servers can securely verify its identity. Prosody will automatically load
  17671. certificates/keys from the directory specified here.
  17672. Defaults to @samp{"/etc/prosody/certs"}.
  17673. @end deftypevr
  17674. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  17675. This is a list of accounts that are admins for the server. Note that you
  17676. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  17677. @url{https://prosody.im/doc/creating_accounts}.
  17678. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  17679. Defaults to @samp{()}.
  17680. @end deftypevr
  17681. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  17682. Enable use of libevent for better performance under high load. See
  17683. @url{https://prosody.im/doc/libevent}.
  17684. Defaults to @samp{#f}.
  17685. @end deftypevr
  17686. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  17687. This is the list of modules Prosody will load on startup. It looks for
  17688. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  17689. Documentation on modules can be found at:
  17690. @url{https://prosody.im/doc/modules}.
  17691. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  17692. @end deftypevr
  17693. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  17694. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  17695. should you want to disable them then add them to this list.
  17696. Defaults to @samp{()}.
  17697. @end deftypevr
  17698. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  17699. Path to a text file where the shared groups are defined. If this path is
  17700. empty then @samp{mod_groups} does nothing. See
  17701. @url{https://prosody.im/doc/modules/mod_groups}.
  17702. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  17703. @end deftypevr
  17704. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  17705. Disable account creation by default, for security. See
  17706. @url{https://prosody.im/doc/creating_accounts}.
  17707. Defaults to @samp{#f}.
  17708. @end deftypevr
  17709. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  17710. These are the SSL/TLS-related settings. Most of them are disabled so to
  17711. use Prosody's defaults. If you do not completely understand these options, do
  17712. not add them to your config, it is easy to lower the security of your server
  17713. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  17714. Available @code{ssl-configuration} fields are:
  17715. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  17716. This determines what handshake to use.
  17717. @end deftypevr
  17718. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  17719. Path to your private key file.
  17720. @end deftypevr
  17721. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  17722. Path to your certificate file.
  17723. @end deftypevr
  17724. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  17725. Path to directory containing root certificates that you wish Prosody to
  17726. trust when verifying the certificates of remote servers.
  17727. Defaults to @samp{"/etc/ssl/certs"}.
  17728. @end deftypevr
  17729. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  17730. Path to a file containing root certificates that you wish Prosody to trust.
  17731. Similar to @code{capath} but with all certificates concatenated together.
  17732. @end deftypevr
  17733. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  17734. A list of verification options (these mostly map to OpenSSL's
  17735. @code{set_verify()} flags).
  17736. @end deftypevr
  17737. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  17738. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  17739. @code{set_options()}. For a full list of options available in LuaSec, see the
  17740. LuaSec source.
  17741. @end deftypevr
  17742. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  17743. How long a chain of certificate authorities to check when looking for a
  17744. trusted root certificate.
  17745. @end deftypevr
  17746. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  17747. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  17748. clients, and in what order.
  17749. @end deftypevr
  17750. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  17751. A path to a file containing parameters for Diffie-Hellman key exchange. You
  17752. can create such a file with:
  17753. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  17754. @end deftypevr
  17755. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  17756. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  17757. @samp{"secp384r1"}.
  17758. @end deftypevr
  17759. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  17760. A list of ``extra'' verification options.
  17761. @end deftypevr
  17762. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  17763. Password for encrypted private keys.
  17764. @end deftypevr
  17765. @end deftypevr
  17766. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  17767. Whether to force all client-to-server connections to be encrypted or not.
  17768. See @url{https://prosody.im/doc/modules/mod_tls}.
  17769. Defaults to @samp{#f}.
  17770. @end deftypevr
  17771. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  17772. Set of mechanisms that will never be offered. See
  17773. @url{https://prosody.im/doc/modules/mod_saslauth}.
  17774. Defaults to @samp{("DIGEST-MD5")}.
  17775. @end deftypevr
  17776. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  17777. Whether to force all server-to-server connections to be encrypted or not.
  17778. See @url{https://prosody.im/doc/modules/mod_tls}.
  17779. Defaults to @samp{#f}.
  17780. @end deftypevr
  17781. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  17782. Whether to require encryption and certificate authentication. This
  17783. provides ideal security, but requires servers you communicate with to support
  17784. encryption AND present valid, trusted certificates. See
  17785. @url{https://prosody.im/doc/s2s#security}.
  17786. Defaults to @samp{#f}.
  17787. @end deftypevr
  17788. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  17789. Many servers don't support encryption or have invalid or self-signed
  17790. certificates. You can list domains here that will not be required to
  17791. authenticate using certificates. They will be authenticated using DNS@. See
  17792. @url{https://prosody.im/doc/s2s#security}.
  17793. Defaults to @samp{()}.
  17794. @end deftypevr
  17795. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  17796. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  17797. valid certificates for some domains by specifying a list here. See
  17798. @url{https://prosody.im/doc/s2s#security}.
  17799. Defaults to @samp{()}.
  17800. @end deftypevr
  17801. @deftypevr {@code{prosody-configuration} parameter} string authentication
  17802. Select the authentication backend to use. The default provider stores
  17803. passwords in plaintext and uses Prosody's configured data storage to store the
  17804. authentication data. If you do not trust your server please see
  17805. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  17806. about using the hashed backend. See also
  17807. @url{https://prosody.im/doc/authentication}
  17808. Defaults to @samp{"internal_plain"}.
  17809. @end deftypevr
  17810. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  17811. Set logging options. Advanced logging configuration is not yet supported
  17812. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  17813. Defaults to @samp{"*syslog"}.
  17814. @end deftypevr
  17815. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  17816. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  17817. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  17818. @end deftypevr
  17819. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  17820. Maximum allowed size of the HTTP body (in bytes).
  17821. @end deftypevr
  17822. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  17823. Some modules expose their own URL in various ways. This URL is built
  17824. from the protocol, host and port used. If Prosody sits behind a proxy, the
  17825. public URL will be @code{http-external-url} instead. See
  17826. @url{https://prosody.im/doc/http#external_url}.
  17827. @end deftypevr
  17828. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  17829. A host in Prosody is a domain on which user accounts can be created. For
  17830. example if you want your users to have addresses like
  17831. @samp{"john.smith@@example.com"} then you need to add a host
  17832. @samp{"example.com"}. All options in this list will apply only to this host.
  17833. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  17834. the actual physical host that Prosody is installed on. A single Prosody
  17835. instance can serve many domains, each one defined as a VirtualHost entry in
  17836. Prosody's configuration. Conversely a server that hosts a single domain would
  17837. have just one VirtualHost entry.
  17838. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  17839. Available @code{virtualhost-configuration} fields are:
  17840. 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:
  17841. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  17842. Domain you wish Prosody to serve.
  17843. @end deftypevr
  17844. @end deftypevr
  17845. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  17846. Components are extra services on a server which are available to clients,
  17847. usually on a subdomain of the main server (such as
  17848. @samp{"mycomponent.example.com"}). Example components might be chatroom
  17849. servers, user directories, or gateways to other protocols.
  17850. Internal components are implemented with Prosody-specific plugins. To add an
  17851. internal component, you simply fill the hostname field, and the plugin you wish
  17852. to use for the component.
  17853. See @url{https://prosody.im/doc/components}.
  17854. Defaults to @samp{()}.
  17855. Available @code{int-component-configuration} fields are:
  17856. 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:
  17857. @deftypevr {@code{int-component-configuration} parameter} string hostname
  17858. Hostname of the component.
  17859. @end deftypevr
  17860. @deftypevr {@code{int-component-configuration} parameter} string plugin
  17861. Plugin you wish to use for the component.
  17862. @end deftypevr
  17863. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  17864. Multi-user chat (MUC) is Prosody's module for allowing you to create
  17865. hosted chatrooms/conferences for XMPP users.
  17866. General information on setting up and using multi-user chatrooms can be found
  17867. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  17868. which you should read if you are new to XMPP chatrooms.
  17869. See also @url{https://prosody.im/doc/modules/mod_muc}.
  17870. Available @code{mod-muc-configuration} fields are:
  17871. @deftypevr {@code{mod-muc-configuration} parameter} string name
  17872. The name to return in service discovery responses.
  17873. Defaults to @samp{"Prosody Chatrooms"}.
  17874. @end deftypevr
  17875. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  17876. If @samp{#t}, this will only allow admins to create new chatrooms.
  17877. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  17878. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  17879. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  17880. restricts to service administrators only.
  17881. Defaults to @samp{#f}.
  17882. @end deftypevr
  17883. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  17884. Maximum number of history messages that will be sent to the member that has
  17885. just joined the room.
  17886. Defaults to @samp{20}.
  17887. @end deftypevr
  17888. @end deftypevr
  17889. @end deftypevr
  17890. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  17891. External components use XEP-0114, which most standalone components
  17892. support. To add an external component, you simply fill the hostname field. See
  17893. @url{https://prosody.im/doc/components}.
  17894. Defaults to @samp{()}.
  17895. Available @code{ext-component-configuration} fields are:
  17896. 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:
  17897. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  17898. Password which the component will use to log in.
  17899. @end deftypevr
  17900. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  17901. Hostname of the component.
  17902. @end deftypevr
  17903. @end deftypevr
  17904. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  17905. Port(s) Prosody listens on for component connections.
  17906. Defaults to @samp{(5347)}.
  17907. @end deftypevr
  17908. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  17909. Interface Prosody listens on for component connections.
  17910. Defaults to @samp{"127.0.0.1"}.
  17911. @end deftypevr
  17912. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  17913. Raw content that will be added to the configuration file.
  17914. @end deftypevr
  17915. It could be that you just want to get a @code{prosody.cfg.lua}
  17916. up and running. In that case, you can pass an
  17917. @code{opaque-prosody-configuration} record as the value of
  17918. @code{prosody-service-type}. As its name indicates, an opaque configuration
  17919. does not have easy reflective capabilities.
  17920. Available @code{opaque-prosody-configuration} fields are:
  17921. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  17922. The prosody package.
  17923. @end deftypevr
  17924. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  17925. The contents of the @code{prosody.cfg.lua} to use.
  17926. @end deftypevr
  17927. For example, if your @code{prosody.cfg.lua} is just the empty
  17928. string, you could instantiate a prosody service like this:
  17929. @lisp
  17930. (service prosody-service-type
  17931. (opaque-prosody-configuration
  17932. (prosody.cfg.lua "")))
  17933. @end lisp
  17934. @c end of Prosody auto-generated documentation
  17935. @subsubheading BitlBee Service
  17936. @cindex IRC (Internet Relay Chat)
  17937. @cindex IRC gateway
  17938. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  17939. interface to a variety of messaging protocols such as XMPP.
  17940. @defvr {Scheme Variable} bitlbee-service-type
  17941. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  17942. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  17943. below).
  17944. To have BitlBee listen on port 6667 on localhost, add this line to your
  17945. services:
  17946. @lisp
  17947. (service bitlbee-service-type)
  17948. @end lisp
  17949. @end defvr
  17950. @deftp {Data Type} bitlbee-configuration
  17951. This is the configuration for BitlBee, with the following fields:
  17952. @table @asis
  17953. @item @code{interface} (default: @code{"127.0.0.1"})
  17954. @itemx @code{port} (default: @code{6667})
  17955. Listen on the network interface corresponding to the IP address
  17956. specified in @var{interface}, on @var{port}.
  17957. When @var{interface} is @code{127.0.0.1}, only local clients can
  17958. connect; when it is @code{0.0.0.0}, connections can come from any
  17959. networking interface.
  17960. @item @code{bitlbee} (default: @code{bitlbee})
  17961. The BitlBee package to use.
  17962. @item @code{plugins} (default: @code{'()})
  17963. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  17964. @item @code{extra-settings} (default: @code{""})
  17965. Configuration snippet added as-is to the BitlBee configuration file.
  17966. @end table
  17967. @end deftp
  17968. @subsubheading Quassel Service
  17969. @cindex IRC (Internet Relay Chat)
  17970. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  17971. meaning that one or more clients can attach to and detach from the
  17972. central core.
  17973. @defvr {Scheme Variable} quassel-service-type
  17974. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  17975. IRC backend daemon. Its value is a @code{quassel-configuration}
  17976. (see below).
  17977. @end defvr
  17978. @deftp {Data Type} quassel-configuration
  17979. This is the configuration for Quassel, with the following fields:
  17980. @table @asis
  17981. @item @code{quassel} (default: @code{quassel})
  17982. The Quassel package to use.
  17983. @item @code{interface} (default: @code{"::,0.0.0.0"})
  17984. @item @code{port} (default: @code{4242})
  17985. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  17986. interfaces specified in the comma delimited @var{interface}, on
  17987. @var{port}.
  17988. @item @code{loglevel} (default: @code{"Info"})
  17989. The level of logging desired. Accepted values are Debug, Info, Warning
  17990. and Error.
  17991. @end table
  17992. @end deftp
  17993. @node Telephony Services
  17994. @subsection Telephony Services
  17995. @cindex Murmur (VoIP server)
  17996. @cindex VoIP server
  17997. This section describes how to set up and run a Murmur server. Murmur is
  17998. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  17999. (VoIP) suite.
  18000. @deftp {Data Type} murmur-configuration
  18001. The service type for the Murmur server. An example configuration can
  18002. look like this:
  18003. @lisp
  18004. (service murmur-service-type
  18005. (murmur-configuration
  18006. (welcome-text
  18007. "Welcome to this Mumble server running on Guix!")
  18008. (cert-required? #t) ;disallow text password logins
  18009. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  18010. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  18011. @end lisp
  18012. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  18013. password with the command that is printed during the activation phase.
  18014. It is recommended to register a normal Mumble user account
  18015. and grant it admin or moderator rights.
  18016. You can use the @code{mumble} client to
  18017. login as new normal user, register yourself, and log out.
  18018. For the next step login with the name @code{SuperUser} use
  18019. the @code{SuperUser} password that you set previously,
  18020. and grant your newly registered mumble user administrator or moderator
  18021. rights and create some channels.
  18022. Available @code{murmur-configuration} fields are:
  18023. @table @asis
  18024. @item @code{package} (default: @code{mumble})
  18025. Package that contains @code{bin/murmurd}.
  18026. @item @code{user} (default: @code{"murmur"})
  18027. User who will run the Murmur server.
  18028. @item @code{group} (default: @code{"murmur"})
  18029. Group of the user who will run the murmur server.
  18030. @item @code{port} (default: @code{64738})
  18031. Port on which the server will listen.
  18032. @item @code{welcome-text} (default: @code{""})
  18033. Welcome text sent to clients when they connect.
  18034. @item @code{server-password} (default: @code{""})
  18035. Password the clients have to enter in order to connect.
  18036. @item @code{max-users} (default: @code{100})
  18037. Maximum of users that can be connected to the server at once.
  18038. @item @code{max-user-bandwidth} (default: @code{#f})
  18039. Maximum voice traffic a user can send per second.
  18040. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  18041. File name of the sqlite database.
  18042. The service's user will become the owner of the directory.
  18043. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  18044. File name of the log file.
  18045. The service's user will become the owner of the directory.
  18046. @item @code{autoban-attempts} (default: @code{10})
  18047. Maximum number of logins a user can make in @code{autoban-timeframe}
  18048. without getting auto banned for @code{autoban-time}.
  18049. @item @code{autoban-timeframe} (default: @code{120})
  18050. Timeframe for autoban in seconds.
  18051. @item @code{autoban-time} (default: @code{300})
  18052. Amount of time in seconds for which a client gets banned
  18053. when violating the autoban limits.
  18054. @item @code{opus-threshold} (default: @code{100})
  18055. Percentage of clients that need to support opus
  18056. before switching over to opus audio codec.
  18057. @item @code{channel-nesting-limit} (default: @code{10})
  18058. How deep channels can be nested at maximum.
  18059. @item @code{channelname-regex} (default: @code{#f})
  18060. A string in form of a Qt regular expression that channel names must conform to.
  18061. @item @code{username-regex} (default: @code{#f})
  18062. A string in form of a Qt regular expression that user names must conform to.
  18063. @item @code{text-message-length} (default: @code{5000})
  18064. Maximum size in bytes that a user can send in one text chat message.
  18065. @item @code{image-message-length} (default: @code{(* 128 1024)})
  18066. Maximum size in bytes that a user can send in one image message.
  18067. @item @code{cert-required?} (default: @code{#f})
  18068. If it is set to @code{#t} clients that use weak password authentication
  18069. will not be accepted. Users must have completed the certificate wizard to join.
  18070. @item @code{remember-channel?} (default: @code{#f})
  18071. Should murmur remember the last channel each user was in when they disconnected
  18072. and put them into the remembered channel when they rejoin.
  18073. @item @code{allow-html?} (default: @code{#f})
  18074. Should html be allowed in text messages, user comments, and channel descriptions.
  18075. @item @code{allow-ping?} (default: @code{#f})
  18076. Setting to true exposes the current user count, the maximum user count, and
  18077. the server's maximum bandwidth per client to unauthenticated users. In the
  18078. Mumble client, this information is shown in the Connect dialog.
  18079. Disabling this setting will prevent public listing of the server.
  18080. @item @code{bonjour?} (default: @code{#f})
  18081. Should the server advertise itself in the local network through the bonjour protocol.
  18082. @item @code{send-version?} (default: @code{#f})
  18083. Should the murmur server version be exposed in ping requests.
  18084. @item @code{log-days} (default: @code{31})
  18085. Murmur also stores logs in the database, which are accessible via RPC.
  18086. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  18087. or -1 to disable logging to the database.
  18088. @item @code{obfuscate-ips?} (default: @code{#t})
  18089. Should logged ips be obfuscated to protect the privacy of users.
  18090. @item @code{ssl-cert} (default: @code{#f})
  18091. File name of the SSL/TLS certificate used for encrypted connections.
  18092. @lisp
  18093. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  18094. @end lisp
  18095. @item @code{ssl-key} (default: @code{#f})
  18096. Filepath to the ssl private key used for encrypted connections.
  18097. @lisp
  18098. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  18099. @end lisp
  18100. @item @code{ssl-dh-params} (default: @code{#f})
  18101. File name of a PEM-encoded file with Diffie-Hellman parameters
  18102. for the SSL/TLS encryption. Alternatively you set it to
  18103. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  18104. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  18105. @item @code{ssl-ciphers} (default: @code{#f})
  18106. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  18107. in SSL/TLS.
  18108. This option is specified using
  18109. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  18110. OpenSSL cipher list notation}.
  18111. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  18112. before setting it here, to get a feel for which cipher suites you will get.
  18113. After setting this option, it is recommend that you inspect your Murmur log
  18114. to ensure that Murmur is using the cipher suites that you expected it to.
  18115. Note: Changing this option may impact the backwards compatibility of your
  18116. Murmur server, and can remove the ability for older Mumble clients to be able
  18117. to connect to it.
  18118. @item @code{public-registration} (default: @code{#f})
  18119. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  18120. You can optionally register your server in the public server list that the
  18121. @code{mumble} client shows on startup.
  18122. You cannot register your server if you have set a @code{server-password},
  18123. or set @code{allow-ping} to @code{#f}.
  18124. It might take a few hours until it shows up in the public list.
  18125. @item @code{file} (default: @code{#f})
  18126. Optional alternative override for this configuration.
  18127. @end table
  18128. @end deftp
  18129. @deftp {Data Type} murmur-public-registration-configuration
  18130. Configuration for public registration of a murmur service.
  18131. @table @asis
  18132. @item @code{name}
  18133. This is a display name for your server. Not to be confused with the hostname.
  18134. @item @code{password}
  18135. A password to identify your registration.
  18136. Subsequent updates will need the same password. Don't lose your password.
  18137. @item @code{url}
  18138. This should be a @code{http://} or @code{https://} link to your web
  18139. site.
  18140. @item @code{hostname} (default: @code{#f})
  18141. By default your server will be listed by its IP address.
  18142. If it is set your server will be linked by this host name instead.
  18143. @end table
  18144. @end deftp
  18145. @node File-Sharing Services
  18146. @subsection File-Sharing Services
  18147. The @code{(gnu services file-sharing)} module provides services that
  18148. assist with transferring files over peer-to-peer file-sharing networks.
  18149. @subsubheading Transmission Daemon Service
  18150. @uref{https://transmissionbt.com/, Transmission} is a flexible
  18151. BitTorrent client that offers a variety of graphical and command-line
  18152. interfaces. A @code{transmission-daemon-service-type} service provides
  18153. Transmission's headless variant, @command{transmission-daemon}, as a
  18154. system service, allowing users to share files via BitTorrent even when
  18155. they are not logged in.
  18156. @deffn {Scheme Variable} transmission-daemon-service-type
  18157. The service type for the Transmission Daemon BitTorrent client. Its
  18158. value must be a @code{transmission-daemon-configuration} object as in
  18159. this example:
  18160. @lisp
  18161. (service transmission-daemon-service-type
  18162. (transmission-daemon-configuration
  18163. ;; Restrict access to the RPC ("control") interface
  18164. (rpc-authentication-required? #t)
  18165. (rpc-username "transmission")
  18166. (rpc-password
  18167. (transmission-password-hash
  18168. "transmission" ; desired password
  18169. "uKd1uMs9")) ; arbitrary salt value
  18170. ;; Accept requests from this and other hosts on the
  18171. ;; local network
  18172. (rpc-whitelist-enabled? #t)
  18173. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  18174. ;; Limit bandwidth use during work hours
  18175. (alt-speed-down (* 1024 2)) ; 2 MB/s
  18176. (alt-speed-up 512) ; 512 kB/s
  18177. (alt-speed-time-enabled? #t)
  18178. (alt-speed-time-day 'weekdays)
  18179. (alt-speed-time-begin
  18180. (+ (* 60 8) 30)) ; 8:30 am
  18181. (alt-speed-time-end
  18182. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  18183. @end lisp
  18184. @end deffn
  18185. Once the service is started, users can interact with the daemon through
  18186. its Web interface (at @code{http://localhost:9091/}) or by using the
  18187. @command{transmission-remote} command-line tool, available in the
  18188. @code{transmission} package. (Emacs users may want to also consider the
  18189. @code{emacs-transmission} package.) Both communicate with the daemon
  18190. through its remote procedure call (RPC) interface, which by default is
  18191. available to all users on the system; you may wish to change this by
  18192. assigning values to the @code{rpc-authentication-required?},
  18193. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  18194. example above and documented further below.
  18195. The value for @code{rpc-password} must be a password hash of the type
  18196. generated and used by Transmission clients. This can be copied verbatim
  18197. from an existing @file{settings.json} file, if another Transmission
  18198. client is already being used. Otherwise, the
  18199. @code{transmission-password-hash} and @code{transmission-random-salt}
  18200. procedures provided by this module can be used to obtain a suitable hash
  18201. value.
  18202. @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
  18203. Returns a string containing the result of hashing @var{password}
  18204. together with @var{salt}, in the format recognized by Transmission
  18205. clients for their @code{rpc-password} configuration setting.
  18206. @var{salt} must be an eight-character string. The
  18207. @code{transmission-random-salt} procedure can be used to generate a
  18208. suitable salt value at random.
  18209. @end deffn
  18210. @deffn {Scheme Procedure} transmission-random-salt
  18211. Returns a string containing a random, eight-character salt value of the
  18212. type generated and used by Transmission clients, suitable for passing to
  18213. the @code{transmission-password-hash} procedure.
  18214. @end deffn
  18215. These procedures are accessible from within a Guile REPL started with
  18216. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  18217. useful for obtaining a random salt value to provide as the second
  18218. parameter to `transmission-password-hash`, as in this example session:
  18219. @example
  18220. $ guix repl
  18221. scheme@@(guix-user)> ,use (gnu services file-sharing)
  18222. scheme@@(guix-user)> (transmission-random-salt)
  18223. $1 = "uKd1uMs9"
  18224. @end example
  18225. Alternatively, a complete password hash can generated in a single step:
  18226. @example
  18227. scheme@@(guix-user)> (transmission-password-hash "transmission"
  18228. (transmission-random-salt))
  18229. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  18230. @end example
  18231. The resulting string can be used as-is for the value of
  18232. @code{rpc-password}, allowing the password to be kept hidden even in the
  18233. operating-system configuration.
  18234. Torrent files downloaded by the daemon are directly accessible only to
  18235. users in the ``transmission'' user group, who receive read-only access
  18236. to the directory specified by the @code{download-dir} configuration
  18237. setting (and also the directory specified by @code{incomplete-dir}, if
  18238. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  18239. moved to another directory or deleted altogether using
  18240. @command{transmission-remote} with its @code{--move} and
  18241. @code{--remove-and-delete} options.
  18242. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  18243. the ``transmission'' group are able also to place @file{.torrent} files
  18244. in the directory specified by @code{watch-dir} to have the corresponding
  18245. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  18246. setting controls whether the daemon deletes these files after processing
  18247. them.)
  18248. Some of the daemon's configuration settings can be changed temporarily
  18249. by @command{transmission-remote} and similar tools. To undo these
  18250. changes, use the service's @code{reload} action to have the daemon
  18251. reload its settings from disk:
  18252. @example
  18253. # herd reload transmission-daemon
  18254. @end example
  18255. The full set of available configuration settings is defined by the
  18256. @code{transmission-daemon-configuration} data type.
  18257. @deftp {Data Type} transmission-daemon-configuration
  18258. The data type representing configuration settings for Transmission
  18259. Daemon. These correspond directly to the settings recognized by
  18260. Transmission clients in their @file{settings.json} file.
  18261. @end deftp
  18262. @c The following documentation was initially generated by
  18263. @c (generate-transmission-daemon-documentation) in (gnu services
  18264. @c file-sharing). Manually maintained documentation is better, so we
  18265. @c shouldn't hesitate to edit below as needed. However if the change
  18266. @c you want to make to this documentation can be done in an automated
  18267. @c way, it's probably easier to change (generate-documentation) than to
  18268. @c make it below and have to deal with the churn as Transmission Daemon
  18269. @c updates.
  18270. @c %start of fragment
  18271. Available @code{transmission-daemon-configuration} fields are:
  18272. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  18273. The Transmission package to use.
  18274. @end deftypevr
  18275. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  18276. The period, in seconds, to wait when stopping the service for
  18277. @command{transmission-daemon} to exit before killing its process. This
  18278. allows the daemon time to complete its housekeeping and send a final
  18279. update to trackers as it shuts down. On slow hosts, or hosts with a
  18280. slow network connection, this value may need to be increased.
  18281. Defaults to @samp{10}.
  18282. @end deftypevr
  18283. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  18284. The directory to which torrent files are downloaded.
  18285. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  18286. @end deftypevr
  18287. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  18288. If @code{#t}, files will be held in @code{incomplete-dir} while their
  18289. torrent is being downloaded, then moved to @code{download-dir} once the
  18290. torrent is complete. Otherwise, files for all torrents (including those
  18291. still being downloaded) will be placed in @code{download-dir}.
  18292. Defaults to @samp{#f}.
  18293. @end deftypevr
  18294. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  18295. The directory in which files from incompletely downloaded torrents will
  18296. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  18297. Defaults to @samp{disabled}.
  18298. @end deftypevr
  18299. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  18300. The file mode creation mask used for downloaded files. (See the
  18301. @command{umask} man page for more information.)
  18302. Defaults to @samp{18}.
  18303. @end deftypevr
  18304. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  18305. When @code{#t}, ``.part'' is appended to the name of partially
  18306. downloaded files.
  18307. Defaults to @samp{#t}.
  18308. @end deftypevr
  18309. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  18310. The mode by which space should be preallocated for downloaded files, one
  18311. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  18312. Specifying @code{full} will minimize disk fragmentation at a cost to
  18313. file-creation speed.
  18314. Defaults to @samp{fast}.
  18315. @end deftypevr
  18316. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  18317. If @code{#t}, the directory specified by @code{watch-dir} will be
  18318. watched for new @file{.torrent} files and the torrents they describe
  18319. added automatically (and the original files removed, if
  18320. @code{trash-original-torrent-files?} is @code{#t}).
  18321. Defaults to @samp{#f}.
  18322. @end deftypevr
  18323. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  18324. The directory to be watched for @file{.torrent} files indicating new
  18325. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  18326. Defaults to @samp{disabled}.
  18327. @end deftypevr
  18328. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  18329. When @code{#t}, @file{.torrent} files will be deleted from the watch
  18330. directory once their torrent has been added (see
  18331. @code{watch-directory-enabled?}).
  18332. Defaults to @samp{#f}.
  18333. @end deftypevr
  18334. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  18335. When @code{#t}, the daemon's download speed will be limited to the rate
  18336. specified by @code{speed-limit-down}.
  18337. Defaults to @samp{#f}.
  18338. @end deftypevr
  18339. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  18340. The default global-maximum download speed, in kilobytes per second.
  18341. Defaults to @samp{100}.
  18342. @end deftypevr
  18343. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  18344. When @code{#t}, the daemon's upload speed will be limited to the rate
  18345. specified by @code{speed-limit-up}.
  18346. Defaults to @samp{#f}.
  18347. @end deftypevr
  18348. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  18349. The default global-maximum upload speed, in kilobytes per second.
  18350. Defaults to @samp{100}.
  18351. @end deftypevr
  18352. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  18353. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18354. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  18355. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  18356. bandwidth usage. This can be scheduled to occur automatically at
  18357. certain times during the week; see @code{alt-speed-time-enabled?}.
  18358. Defaults to @samp{#f}.
  18359. @end deftypevr
  18360. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  18361. The alternate global-maximum download speed, in kilobytes per second.
  18362. Defaults to @samp{50}.
  18363. @end deftypevr
  18364. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  18365. The alternate global-maximum upload speed, in kilobytes per second.
  18366. Defaults to @samp{50}.
  18367. @end deftypevr
  18368. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  18369. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18370. @code{alt-speed-up} will be enabled automatically during the periods
  18371. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  18372. @code{alt-time-speed-end}.
  18373. Defaults to @samp{#f}.
  18374. @end deftypevr
  18375. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  18376. The days of the week on which the alternate-speed schedule should be
  18377. used, specified either as a list of days (@code{sunday}, @code{monday},
  18378. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  18379. or @code{all}.
  18380. Defaults to @samp{all}.
  18381. @end deftypevr
  18382. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  18383. The time of day at which to enable the alternate speed limits, expressed
  18384. as a number of minutes since midnight.
  18385. Defaults to @samp{540}.
  18386. @end deftypevr
  18387. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  18388. The time of day at which to disable the alternate speed limits,
  18389. expressed as a number of minutes since midnight.
  18390. Defaults to @samp{1020}.
  18391. @end deftypevr
  18392. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  18393. The IP address at which to listen for peer connections, or ``0.0.0.0''
  18394. to listen at all available IP addresses.
  18395. Defaults to @samp{"0.0.0.0"}.
  18396. @end deftypevr
  18397. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  18398. The IPv6 address at which to listen for peer connections, or ``::'' to
  18399. listen at all available IPv6 addresses.
  18400. Defaults to @samp{"::"}.
  18401. @end deftypevr
  18402. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  18403. If @code{#t}, when the daemon starts it will select a port at random on
  18404. which to listen for peer connections, from the range specified
  18405. (inclusively) by @code{peer-port-random-low} and
  18406. @code{peer-port-random-high}. Otherwise, it listens on the port
  18407. specified by @code{peer-port}.
  18408. Defaults to @samp{#f}.
  18409. @end deftypevr
  18410. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  18411. The lowest selectable port number when @code{peer-port-random-on-start?}
  18412. is @code{#t}.
  18413. Defaults to @samp{49152}.
  18414. @end deftypevr
  18415. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  18416. The highest selectable port number when @code{peer-port-random-on-start}
  18417. is @code{#t}.
  18418. Defaults to @samp{65535}.
  18419. @end deftypevr
  18420. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  18421. The port on which to listen for peer connections when
  18422. @code{peer-port-random-on-start?} is @code{#f}.
  18423. Defaults to @samp{51413}.
  18424. @end deftypevr
  18425. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  18426. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  18427. upstream gateway automatically using @acronym{UPnP} and
  18428. @acronym{NAT-PMP}.
  18429. Defaults to @samp{#t}.
  18430. @end deftypevr
  18431. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  18432. The encryption preference for peer connections, one of
  18433. @code{prefer-unencrypted-connections},
  18434. @code{prefer-encrypted-connections} or
  18435. @code{require-encrypted-connections}.
  18436. Defaults to @samp{prefer-encrypted-connections}.
  18437. @end deftypevr
  18438. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  18439. The TCP congestion-control algorithm to use for peer connections,
  18440. specified using a string recognized by the operating system in calls to
  18441. @code{setsockopt} (or set to @code{disabled}, in which case the
  18442. operating-system default is used).
  18443. Note that on GNU/Linux systems, the kernel must be configured to allow
  18444. processes to use a congestion-control algorithm not in the default set;
  18445. otherwise, it will deny these requests with ``Operation not permitted''.
  18446. To see which algorithms are available on your system and which are
  18447. currently permitted for use, look at the contents of the files
  18448. @file{tcp_available_congestion_control} and
  18449. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  18450. directory.
  18451. As an example, to have Transmission Daemon use
  18452. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  18453. congestion-control algorithm}, you'll need to modify your kernel
  18454. configuration to build in support for the algorithm, then update your
  18455. operating-system configuration to allow its use by adding a
  18456. @code{sysctl-service-type} service (or updating the existing one's
  18457. configuration) with lines like the following:
  18458. @lisp
  18459. (service sysctl-service-type
  18460. (sysctl-configuration
  18461. (settings
  18462. ("net.ipv4.tcp_allowed_congestion_control" .
  18463. "reno cubic lp"))))
  18464. @end lisp
  18465. The Transmission Daemon configuration can then be updated with
  18466. @lisp
  18467. (peer-congestion-algorithm "lp")
  18468. @end lisp
  18469. and the system reconfigured to have the changes take effect.
  18470. Defaults to @samp{disabled}.
  18471. @end deftypevr
  18472. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  18473. The type of service to request in outgoing @acronym{TCP} packets, one of
  18474. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  18475. @code{reliability}.
  18476. Defaults to @samp{default}.
  18477. @end deftypevr
  18478. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  18479. The global limit on the number of connected peers.
  18480. Defaults to @samp{200}.
  18481. @end deftypevr
  18482. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  18483. The per-torrent limit on the number of connected peers.
  18484. Defaults to @samp{50}.
  18485. @end deftypevr
  18486. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  18487. The maximum number of peers to which the daemon will upload data
  18488. simultaneously for each torrent.
  18489. Defaults to @samp{14}.
  18490. @end deftypevr
  18491. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  18492. The maximum lifespan, in hours, of the peer ID associated with each
  18493. public torrent before it is regenerated.
  18494. Defaults to @samp{6}.
  18495. @end deftypevr
  18496. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  18497. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  18498. it has most recently downloaded from @code{blocklist-url}.
  18499. Defaults to @samp{#f}.
  18500. @end deftypevr
  18501. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  18502. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  18503. @file{.dat} format) to be periodically downloaded and applied when
  18504. @code{blocklist-enabled?} is @code{#t}.
  18505. Defaults to @samp{disabled}.
  18506. @end deftypevr
  18507. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  18508. If @code{#t}, the daemon will be limited to downloading at most
  18509. @code{download-queue-size} non-stalled torrents simultaneously.
  18510. Defaults to @samp{#t}.
  18511. @end deftypevr
  18512. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  18513. The size of the daemon's download queue, which limits the number of
  18514. non-stalled torrents it will download at any one time when
  18515. @code{download-queue-enabled?} is @code{#t}.
  18516. Defaults to @samp{5}.
  18517. @end deftypevr
  18518. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  18519. If @code{#t}, the daemon will be limited to seeding at most
  18520. @code{seed-queue-size} non-stalled torrents simultaneously.
  18521. Defaults to @samp{#f}.
  18522. @end deftypevr
  18523. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  18524. The size of the daemon's seed queue, which limits the number of
  18525. non-stalled torrents it will seed at any one time when
  18526. @code{seed-queue-enabled?} is @code{#t}.
  18527. Defaults to @samp{10}.
  18528. @end deftypevr
  18529. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  18530. When @code{#t}, the daemon will consider torrents for which it has not
  18531. shared data in the past @code{queue-stalled-minutes} minutes to be
  18532. stalled and not count them against its @code{download-queue-size} and
  18533. @code{seed-queue-size} limits.
  18534. Defaults to @samp{#t}.
  18535. @end deftypevr
  18536. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  18537. The maximum period, in minutes, a torrent may be idle before it is
  18538. considered to be stalled, when @code{queue-stalled-enabled?} is
  18539. @code{#t}.
  18540. Defaults to @samp{30}.
  18541. @end deftypevr
  18542. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  18543. When @code{#t}, a torrent being seeded will automatically be paused once
  18544. it reaches the ratio specified by @code{ratio-limit}.
  18545. Defaults to @samp{#f}.
  18546. @end deftypevr
  18547. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  18548. The ratio at which a torrent being seeded will be paused, when
  18549. @code{ratio-limit-enabled?} is @code{#t}.
  18550. Defaults to @samp{2.0}.
  18551. @end deftypevr
  18552. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  18553. When @code{#t}, a torrent being seeded will automatically be paused once
  18554. it has been idle for @code{idle-seeding-limit} minutes.
  18555. Defaults to @samp{#f}.
  18556. @end deftypevr
  18557. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  18558. The maximum period, in minutes, a torrent being seeded may be idle
  18559. before it is paused, when @code{idle-seeding-limit-enabled?} is
  18560. @code{#t}.
  18561. Defaults to @samp{30}.
  18562. @end deftypevr
  18563. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  18564. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  18565. hash table (@acronym{DHT}) protocol}, which supports the use of
  18566. trackerless torrents.
  18567. Defaults to @samp{#t}.
  18568. @end deftypevr
  18569. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  18570. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  18571. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  18572. the local network and may reduce the amount of data sent over the public
  18573. Internet.
  18574. Defaults to @samp{#f}.
  18575. @end deftypevr
  18576. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  18577. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  18578. (@acronym{PEX}), which reduces the daemon's reliance on external
  18579. trackers and may improve its performance.
  18580. Defaults to @samp{#t}.
  18581. @end deftypevr
  18582. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  18583. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  18584. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  18585. BitTorrent traffic on other users of the local network while maintaining
  18586. full utilization of the available bandwidth.
  18587. Defaults to @samp{#t}.
  18588. @end deftypevr
  18589. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  18590. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  18591. interface, which allows remote control of the daemon via its Web
  18592. interface, the @command{transmission-remote} command-line client, and
  18593. similar tools.
  18594. Defaults to @samp{#t}.
  18595. @end deftypevr
  18596. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  18597. The IP address at which to listen for @acronym{RPC} connections, or
  18598. ``0.0.0.0'' to listen at all available IP addresses.
  18599. Defaults to @samp{"0.0.0.0"}.
  18600. @end deftypevr
  18601. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  18602. The port on which to listen for @acronym{RPC} connections.
  18603. Defaults to @samp{9091}.
  18604. @end deftypevr
  18605. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  18606. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  18607. Defaults to @samp{"/transmission/"}.
  18608. @end deftypevr
  18609. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  18610. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  18611. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  18612. has the side effect of disabling host-name whitelisting (see
  18613. @code{rpc-host-whitelist-enabled?}.
  18614. Defaults to @samp{#f}.
  18615. @end deftypevr
  18616. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  18617. The username required by clients to access the @acronym{RPC} interface
  18618. when @code{rpc-authentication-required?} is @code{#t}.
  18619. Defaults to @samp{disabled}.
  18620. @end deftypevr
  18621. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  18622. The password required by clients to access the @acronym{RPC} interface
  18623. when @code{rpc-authentication-required?} is @code{#t}. This must be
  18624. specified using a password hash in the format recognized by Transmission
  18625. clients, either copied from an existing @file{settings.json} file or
  18626. generated using the @code{transmission-password-hash} procedure.
  18627. Defaults to @samp{disabled}.
  18628. @end deftypevr
  18629. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  18630. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  18631. originate from an address specified in @code{rpc-whitelist}.
  18632. Defaults to @samp{#t}.
  18633. @end deftypevr
  18634. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  18635. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  18636. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  18637. may be specified using @samp{*}.
  18638. Defaults to @samp{("127.0.0.1" "::1")}.
  18639. @end deftypevr
  18640. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  18641. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  18642. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  18643. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  18644. are always accepted regardless of these settings.
  18645. Note also this functionality is disabled when
  18646. @code{rpc-authentication-required?} is @code{#t}.
  18647. Defaults to @samp{#t}.
  18648. @end deftypevr
  18649. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  18650. The list of host names recognized by the @acronym{RPC} server when
  18651. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  18652. Defaults to @samp{()}.
  18653. @end deftypevr
  18654. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  18655. The minimum severity level of messages to be logged (to
  18656. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  18657. logging), @code{error}, @code{info} and @code{debug}.
  18658. Defaults to @samp{info}.
  18659. @end deftypevr
  18660. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  18661. When @code{#t}, torrents are started as soon as they are added;
  18662. otherwise, they are added in ``paused'' state.
  18663. Defaults to @samp{#t}.
  18664. @end deftypevr
  18665. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  18666. When @code{#t}, the script specified by
  18667. @code{script-torrent-done-filename} will be invoked each time a torrent
  18668. completes.
  18669. Defaults to @samp{#f}.
  18670. @end deftypevr
  18671. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  18672. A file name or file-like object specifying a script to run each time a
  18673. torrent completes, when @code{script-torrent-done-enabled?} is
  18674. @code{#t}.
  18675. Defaults to @samp{disabled}.
  18676. @end deftypevr
  18677. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  18678. When @code{#t}, the daemon will scrape trackers for a torrent even when
  18679. the torrent is paused.
  18680. Defaults to @samp{#t}.
  18681. @end deftypevr
  18682. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  18683. The amount of memory, in megabytes, to allocate for the daemon's
  18684. in-memory cache. A larger value may increase performance by reducing
  18685. the frequency of disk I/O.
  18686. Defaults to @samp{4}.
  18687. @end deftypevr
  18688. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  18689. When @code{#t}, the daemon will try to improve I/O performance by
  18690. hinting to the operating system which data is likely to be read next
  18691. from disk to satisfy requests from peers.
  18692. Defaults to @samp{#t}.
  18693. @end deftypevr
  18694. @c %end of fragment
  18695. @node Monitoring Services
  18696. @subsection Monitoring Services
  18697. @subsubheading Tailon Service
  18698. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  18699. viewing and searching log files.
  18700. The following example will configure the service with default values.
  18701. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  18702. @lisp
  18703. (service tailon-service-type)
  18704. @end lisp
  18705. The following example customises more of the Tailon configuration,
  18706. adding @command{sed} to the list of allowed commands.
  18707. @lisp
  18708. (service tailon-service-type
  18709. (tailon-configuration
  18710. (config-file
  18711. (tailon-configuration-file
  18712. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  18713. @end lisp
  18714. @deftp {Data Type} tailon-configuration
  18715. Data type representing the configuration of Tailon.
  18716. This type has the following parameters:
  18717. @table @asis
  18718. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  18719. The configuration file to use for Tailon. This can be set to a
  18720. @dfn{tailon-configuration-file} record value, or any gexp
  18721. (@pxref{G-Expressions}).
  18722. For example, to instead use a local file, the @code{local-file} function
  18723. can be used:
  18724. @lisp
  18725. (service tailon-service-type
  18726. (tailon-configuration
  18727. (config-file (local-file "./my-tailon.conf"))))
  18728. @end lisp
  18729. @item @code{package} (default: @code{tailon})
  18730. The tailon package to use.
  18731. @end table
  18732. @end deftp
  18733. @deftp {Data Type} tailon-configuration-file
  18734. Data type representing the configuration options for Tailon.
  18735. This type has the following parameters:
  18736. @table @asis
  18737. @item @code{files} (default: @code{(list "/var/log")})
  18738. List of files to display. The list can include strings for a single file
  18739. or directory, or a list, where the first item is the name of a
  18740. subsection, and the remaining items are the files or directories in that
  18741. subsection.
  18742. @item @code{bind} (default: @code{"localhost:8080"})
  18743. Address and port to which Tailon should bind on.
  18744. @item @code{relative-root} (default: @code{#f})
  18745. URL path to use for Tailon, set to @code{#f} to not use a path.
  18746. @item @code{allow-transfers?} (default: @code{#t})
  18747. Allow downloading the log files in the web interface.
  18748. @item @code{follow-names?} (default: @code{#t})
  18749. Allow tailing of not-yet existent files.
  18750. @item @code{tail-lines} (default: @code{200})
  18751. Number of lines to read initially from each file.
  18752. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  18753. Commands to allow running. By default, @code{sed} is disabled.
  18754. @item @code{debug?} (default: @code{#f})
  18755. Set @code{debug?} to @code{#t} to show debug messages.
  18756. @item @code{wrap-lines} (default: @code{#t})
  18757. Initial line wrapping state in the web interface. Set to @code{#t} to
  18758. initially wrap lines (the default), or to @code{#f} to initially not
  18759. wrap lines.
  18760. @item @code{http-auth} (default: @code{#f})
  18761. HTTP authentication type to use. Set to @code{#f} to disable
  18762. authentication (the default). Supported values are @code{"digest"} or
  18763. @code{"basic"}.
  18764. @item @code{users} (default: @code{#f})
  18765. If HTTP authentication is enabled (see @code{http-auth}), access will be
  18766. restricted to the credentials provided here. To configure users, use a
  18767. list of pairs, where the first element of the pair is the username, and
  18768. the 2nd element of the pair is the password.
  18769. @lisp
  18770. (tailon-configuration-file
  18771. (http-auth "basic")
  18772. (users '(("user1" . "password1")
  18773. ("user2" . "password2"))))
  18774. @end lisp
  18775. @end table
  18776. @end deftp
  18777. @subsubheading Darkstat Service
  18778. @cindex darkstat
  18779. Darkstat is a packet sniffer that captures network traffic, calculates
  18780. statistics about usage, and serves reports over HTTP.
  18781. @defvar {Scheme Variable} darkstat-service-type
  18782. This is the service type for the
  18783. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  18784. service, its value must be a @code{darkstat-configuration} record as in
  18785. this example:
  18786. @lisp
  18787. (service darkstat-service-type
  18788. (darkstat-configuration
  18789. (interface "eno1")))
  18790. @end lisp
  18791. @end defvar
  18792. @deftp {Data Type} darkstat-configuration
  18793. Data type representing the configuration of @command{darkstat}.
  18794. @table @asis
  18795. @item @code{package} (default: @code{darkstat})
  18796. The darkstat package to use.
  18797. @item @code{interface}
  18798. Capture traffic on the specified network interface.
  18799. @item @code{port} (default: @code{"667"})
  18800. Bind the web interface to the specified port.
  18801. @item @code{bind-address} (default: @code{"127.0.0.1"})
  18802. Bind the web interface to the specified address.
  18803. @item @code{base} (default: @code{"/"})
  18804. Specify the path of the base URL@. This can be useful if
  18805. @command{darkstat} is accessed via a reverse proxy.
  18806. @end table
  18807. @end deftp
  18808. @subsubheading Prometheus Node Exporter Service
  18809. @cindex prometheus-node-exporter
  18810. The Prometheus ``node exporter'' makes hardware and operating system statistics
  18811. provided by the Linux kernel available for the Prometheus monitoring system.
  18812. This service should be deployed on all physical nodes and virtual machines,
  18813. where monitoring these statistics is desirable.
  18814. @defvar {Scheme variable} prometheus-node-exporter-service-type
  18815. This is the service type for the
  18816. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  18817. service, its value must be a @code{prometheus-node-exporter-configuration}.
  18818. @lisp
  18819. (service prometheus-node-exporter-service-type)
  18820. @end lisp
  18821. @end defvar
  18822. @deftp {Data Type} prometheus-node-exporter-configuration
  18823. Data type representing the configuration of @command{node_exporter}.
  18824. @table @asis
  18825. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  18826. The prometheus-node-exporter package to use.
  18827. @item @code{web-listen-address} (default: @code{":9100"})
  18828. Bind the web interface to the specified address.
  18829. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  18830. This directory can be used to export metrics specific to this machine.
  18831. Files containing metrics in the text format, with the filename ending in
  18832. @code{.prom} should be placed in this directory.
  18833. @item @code{extra-options} (default: @code{'()})
  18834. Extra options to pass to the Prometheus node exporter.
  18835. @end table
  18836. @end deftp
  18837. @subsubheading Zabbix server
  18838. @cindex zabbix zabbix-server
  18839. Zabbix provides monitoring metrics, among others network utilization, CPU load
  18840. and disk space consumption:
  18841. @itemize
  18842. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  18843. @item Auto-discovery of servers and network devices and interfaces.
  18844. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  18845. @item Distributed monitoring with centralized web administration.
  18846. @item Native high performance agents.
  18847. @item SLA, and ITIL KPI metrics on reporting.
  18848. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  18849. @item Remote command execution through Zabbix proxies.
  18850. @end itemize
  18851. @c %start of fragment
  18852. Available @code{zabbix-server-configuration} fields are:
  18853. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  18854. The zabbix-server package.
  18855. @end deftypevr
  18856. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  18857. User who will run the Zabbix server.
  18858. Defaults to @samp{"zabbix"}.
  18859. @end deftypevr
  18860. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  18861. Group who will run the Zabbix server.
  18862. Defaults to @samp{"zabbix"}.
  18863. @end deftypevr
  18864. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  18865. Database host name.
  18866. Defaults to @samp{"127.0.0.1"}.
  18867. @end deftypevr
  18868. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  18869. Database name.
  18870. Defaults to @samp{"zabbix"}.
  18871. @end deftypevr
  18872. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  18873. Database user.
  18874. Defaults to @samp{"zabbix"}.
  18875. @end deftypevr
  18876. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  18877. Database password. Please, use @code{include-files} with
  18878. @code{DBPassword=SECRET} inside a specified file instead.
  18879. Defaults to @samp{""}.
  18880. @end deftypevr
  18881. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  18882. Database port.
  18883. Defaults to @samp{5432}.
  18884. @end deftypevr
  18885. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  18886. Specifies where log messages are written to:
  18887. @itemize @bullet
  18888. @item
  18889. @code{system} - syslog.
  18890. @item
  18891. @code{file} - file specified with @code{log-file} parameter.
  18892. @item
  18893. @code{console} - standard output.
  18894. @end itemize
  18895. Defaults to @samp{""}.
  18896. @end deftypevr
  18897. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  18898. Log file name for @code{log-type} @code{file} parameter.
  18899. Defaults to @samp{"/var/log/zabbix/server.log"}.
  18900. @end deftypevr
  18901. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  18902. Name of PID file.
  18903. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  18904. @end deftypevr
  18905. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  18906. The location of certificate authority (CA) files for SSL server
  18907. certificate verification.
  18908. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  18909. @end deftypevr
  18910. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  18911. Location of SSL client certificates.
  18912. Defaults to @samp{"/etc/ssl/certs"}.
  18913. @end deftypevr
  18914. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  18915. Extra options will be appended to Zabbix server configuration file.
  18916. Defaults to @samp{""}.
  18917. @end deftypevr
  18918. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  18919. You may include individual files or all files in a directory in the
  18920. configuration file.
  18921. Defaults to @samp{()}.
  18922. @end deftypevr
  18923. @c %end of fragment
  18924. @subsubheading Zabbix agent
  18925. @cindex zabbix zabbix-agent
  18926. Zabbix agent gathers information for Zabbix server.
  18927. @c %start of fragment
  18928. Available @code{zabbix-agent-configuration} fields are:
  18929. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  18930. The zabbix-agent package.
  18931. @end deftypevr
  18932. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  18933. User who will run the Zabbix agent.
  18934. Defaults to @samp{"zabbix"}.
  18935. @end deftypevr
  18936. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  18937. Group who will run the Zabbix agent.
  18938. Defaults to @samp{"zabbix"}.
  18939. @end deftypevr
  18940. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  18941. Unique, case sensitive hostname which is required for active checks and
  18942. must match hostname as configured on the server.
  18943. Defaults to @samp{""}.
  18944. @end deftypevr
  18945. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  18946. Specifies where log messages are written to:
  18947. @itemize @bullet
  18948. @item
  18949. @code{system} - syslog.
  18950. @item
  18951. @code{file} - file specified with @code{log-file} parameter.
  18952. @item
  18953. @code{console} - standard output.
  18954. @end itemize
  18955. Defaults to @samp{""}.
  18956. @end deftypevr
  18957. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  18958. Log file name for @code{log-type} @code{file} parameter.
  18959. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  18960. @end deftypevr
  18961. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  18962. Name of PID file.
  18963. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  18964. @end deftypevr
  18965. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  18966. List of IP addresses, optionally in CIDR notation, or hostnames of
  18967. Zabbix servers and Zabbix proxies. Incoming connections will be
  18968. accepted only from the hosts listed here.
  18969. Defaults to @samp{("127.0.0.1")}.
  18970. @end deftypevr
  18971. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  18972. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  18973. proxies for active checks. If port is not specified, default port is
  18974. used. If this parameter is not specified, active checks are disabled.
  18975. Defaults to @samp{("127.0.0.1")}.
  18976. @end deftypevr
  18977. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  18978. Extra options will be appended to Zabbix server configuration file.
  18979. Defaults to @samp{""}.
  18980. @end deftypevr
  18981. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  18982. You may include individual files or all files in a directory in the
  18983. configuration file.
  18984. Defaults to @samp{()}.
  18985. @end deftypevr
  18986. @c %end of fragment
  18987. @subsubheading Zabbix front-end
  18988. @cindex zabbix zabbix-front-end
  18989. This service provides a WEB interface to Zabbix server.
  18990. @c %start of fragment
  18991. Available @code{zabbix-front-end-configuration} fields are:
  18992. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  18993. NGINX configuration.
  18994. @end deftypevr
  18995. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  18996. Database host name.
  18997. Defaults to @samp{"localhost"}.
  18998. @end deftypevr
  18999. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  19000. Database port.
  19001. Defaults to @samp{5432}.
  19002. @end deftypevr
  19003. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  19004. Database name.
  19005. Defaults to @samp{"zabbix"}.
  19006. @end deftypevr
  19007. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  19008. Database user.
  19009. Defaults to @samp{"zabbix"}.
  19010. @end deftypevr
  19011. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  19012. Database password. Please, use @code{db-secret-file} instead.
  19013. Defaults to @samp{""}.
  19014. @end deftypevr
  19015. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  19016. Secret file containing the credentials for the Zabbix front-end. The value
  19017. must be a local file name, not a G-expression. You are expected to create
  19018. this file manually. Its contents will be copied into @file{zabbix.conf.php}
  19019. as the value of @code{$DB['PASSWORD']}.
  19020. Defaults to @samp{""}.
  19021. @end deftypevr
  19022. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  19023. Zabbix server hostname.
  19024. Defaults to @samp{"localhost"}.
  19025. @end deftypevr
  19026. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  19027. Zabbix server port.
  19028. Defaults to @samp{10051}.
  19029. @end deftypevr
  19030. @c %end of fragment
  19031. @node Kerberos Services
  19032. @subsection Kerberos Services
  19033. @cindex Kerberos
  19034. The @code{(gnu services kerberos)} module provides services relating to
  19035. the authentication protocol @dfn{Kerberos}.
  19036. @subsubheading Krb5 Service
  19037. Programs using a Kerberos client library normally
  19038. expect a configuration file in @file{/etc/krb5.conf}.
  19039. This service generates such a file from a definition provided in the
  19040. operating system declaration.
  19041. It does not cause any daemon to be started.
  19042. No ``keytab'' files are provided by this service---you must explicitly create them.
  19043. This service is known to work with the MIT client library, @code{mit-krb5}.
  19044. Other implementations have not been tested.
  19045. @defvr {Scheme Variable} krb5-service-type
  19046. A service type for Kerberos 5 clients.
  19047. @end defvr
  19048. @noindent
  19049. Here is an example of its use:
  19050. @lisp
  19051. (service krb5-service-type
  19052. (krb5-configuration
  19053. (default-realm "EXAMPLE.COM")
  19054. (allow-weak-crypto? #t)
  19055. (realms (list
  19056. (krb5-realm
  19057. (name "EXAMPLE.COM")
  19058. (admin-server "groucho.example.com")
  19059. (kdc "karl.example.com"))
  19060. (krb5-realm
  19061. (name "ARGRX.EDU")
  19062. (admin-server "kerb-admin.argrx.edu")
  19063. (kdc "keys.argrx.edu"))))))
  19064. @end lisp
  19065. @noindent
  19066. This example provides a Kerberos@tie{}5 client configuration which:
  19067. @itemize
  19068. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  19069. of which have distinct administration servers and key distribution centers;
  19070. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  19071. specified by clients;
  19072. @item Accepts services which only support encryption types known to be weak.
  19073. @end itemize
  19074. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  19075. Only the most commonly used ones are described here.
  19076. For a full list, and more detailed explanation of each, see the MIT
  19077. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  19078. documentation.
  19079. @deftp {Data Type} krb5-realm
  19080. @cindex realm, kerberos
  19081. @table @asis
  19082. @item @code{name}
  19083. This field is a string identifying the name of the realm.
  19084. A common convention is to use the fully qualified DNS name of your organization,
  19085. converted to upper case.
  19086. @item @code{admin-server}
  19087. This field is a string identifying the host where the administration server is
  19088. running.
  19089. @item @code{kdc}
  19090. This field is a string identifying the key distribution center
  19091. for the realm.
  19092. @end table
  19093. @end deftp
  19094. @deftp {Data Type} krb5-configuration
  19095. @table @asis
  19096. @item @code{allow-weak-crypto?} (default: @code{#f})
  19097. If this flag is @code{#t} then services which only offer encryption algorithms
  19098. known to be weak will be accepted.
  19099. @item @code{default-realm} (default: @code{#f})
  19100. This field should be a string identifying the default Kerberos
  19101. realm for the client.
  19102. You should set this field to the name of your Kerberos realm.
  19103. If this value is @code{#f}
  19104. then a realm must be specified with every Kerberos principal when invoking programs
  19105. such as @command{kinit}.
  19106. @item @code{realms}
  19107. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  19108. access.
  19109. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  19110. field.
  19111. @end table
  19112. @end deftp
  19113. @subsubheading PAM krb5 Service
  19114. @cindex pam-krb5
  19115. The @code{pam-krb5} service allows for login authentication and password
  19116. management via Kerberos.
  19117. You will need this service if you want PAM enabled applications to authenticate
  19118. users using Kerberos.
  19119. @defvr {Scheme Variable} pam-krb5-service-type
  19120. A service type for the Kerberos 5 PAM module.
  19121. @end defvr
  19122. @deftp {Data Type} pam-krb5-configuration
  19123. Data type representing the configuration of the Kerberos 5 PAM module.
  19124. This type has the following parameters:
  19125. @table @asis
  19126. @item @code{pam-krb5} (default: @code{pam-krb5})
  19127. The pam-krb5 package to use.
  19128. @item @code{minimum-uid} (default: @code{1000})
  19129. The smallest user ID for which Kerberos authentications should be attempted.
  19130. Local accounts with lower values will silently fail to authenticate.
  19131. @end table
  19132. @end deftp
  19133. @node LDAP Services
  19134. @subsection LDAP Services
  19135. @cindex LDAP
  19136. @cindex nslcd, LDAP service
  19137. The @code{(gnu services authentication)} module provides the
  19138. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  19139. server. In addition to configuring the service itself, you may want to add
  19140. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  19141. Switch} for detailed information.
  19142. Here is a simple operating system declaration with a default configuration of
  19143. the @code{nslcd-service-type} and a Name Service Switch configuration that
  19144. consults the @code{ldap} name service last:
  19145. @lisp
  19146. (use-service-modules authentication)
  19147. (use-modules (gnu system nss))
  19148. ...
  19149. (operating-system
  19150. ...
  19151. (services
  19152. (cons*
  19153. (service nslcd-service-type)
  19154. (service dhcp-client-service-type)
  19155. %base-services))
  19156. (name-service-switch
  19157. (let ((services (list (name-service (name "db"))
  19158. (name-service (name "files"))
  19159. (name-service (name "ldap")))))
  19160. (name-service-switch
  19161. (inherit %mdns-host-lookup-nss)
  19162. (password services)
  19163. (shadow services)
  19164. (group services)
  19165. (netgroup services)
  19166. (gshadow services)))))
  19167. @end lisp
  19168. @c %start of generated documentation for nslcd-configuration
  19169. Available @code{nslcd-configuration} fields are:
  19170. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  19171. The @code{nss-pam-ldapd} package to use.
  19172. @end deftypevr
  19173. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  19174. The number of threads to start that can handle requests and perform LDAP
  19175. queries. Each thread opens a separate connection to the LDAP server.
  19176. The default is to start 5 threads.
  19177. Defaults to @samp{disabled}.
  19178. @end deftypevr
  19179. @deftypevr {@code{nslcd-configuration} parameter} string uid
  19180. This specifies the user id with which the daemon should be run.
  19181. Defaults to @samp{"nslcd"}.
  19182. @end deftypevr
  19183. @deftypevr {@code{nslcd-configuration} parameter} string gid
  19184. This specifies the group id with which the daemon should be run.
  19185. Defaults to @samp{"nslcd"}.
  19186. @end deftypevr
  19187. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  19188. This option controls the way logging is done via a list containing
  19189. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  19190. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  19191. argument is optional and specifies the log level. The log level may be
  19192. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  19193. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  19194. specified log level or higher are logged.
  19195. Defaults to @samp{("/var/log/nslcd" info)}.
  19196. @end deftypevr
  19197. @deftypevr {@code{nslcd-configuration} parameter} list uri
  19198. The list of LDAP server URIs. Normally, only the first server will be
  19199. used with the following servers as fall-back.
  19200. Defaults to @samp{("ldap://localhost:389/")}.
  19201. @end deftypevr
  19202. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  19203. The version of the LDAP protocol to use. The default is to use the
  19204. maximum version supported by the LDAP library.
  19205. Defaults to @samp{disabled}.
  19206. @end deftypevr
  19207. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  19208. Specifies the distinguished name with which to bind to the directory
  19209. server for lookups. The default is to bind anonymously.
  19210. Defaults to @samp{disabled}.
  19211. @end deftypevr
  19212. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  19213. Specifies the credentials with which to bind. This option is only
  19214. applicable when used with binddn.
  19215. Defaults to @samp{disabled}.
  19216. @end deftypevr
  19217. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  19218. Specifies the distinguished name to use when the root user tries to
  19219. modify a user's password using the PAM module.
  19220. Defaults to @samp{disabled}.
  19221. @end deftypevr
  19222. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  19223. Specifies the credentials with which to bind if the root user tries to
  19224. change a user's password. This option is only applicable when used with
  19225. rootpwmoddn
  19226. Defaults to @samp{disabled}.
  19227. @end deftypevr
  19228. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  19229. Specifies the SASL mechanism to be used when performing SASL
  19230. authentication.
  19231. Defaults to @samp{disabled}.
  19232. @end deftypevr
  19233. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  19234. Specifies the SASL realm to be used when performing SASL authentication.
  19235. Defaults to @samp{disabled}.
  19236. @end deftypevr
  19237. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  19238. Specifies the authentication identity to be used when performing SASL
  19239. authentication.
  19240. Defaults to @samp{disabled}.
  19241. @end deftypevr
  19242. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  19243. Specifies the authorization identity to be used when performing SASL
  19244. authentication.
  19245. Defaults to @samp{disabled}.
  19246. @end deftypevr
  19247. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  19248. Determines whether the LDAP server host name should be canonicalised. If
  19249. this is enabled the LDAP library will do a reverse host name lookup. By
  19250. default, it is left up to the LDAP library whether this check is
  19251. performed or not.
  19252. Defaults to @samp{disabled}.
  19253. @end deftypevr
  19254. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  19255. Set the name for the GSS-API Kerberos credentials cache.
  19256. Defaults to @samp{disabled}.
  19257. @end deftypevr
  19258. @deftypevr {@code{nslcd-configuration} parameter} string base
  19259. The directory search base.
  19260. Defaults to @samp{"dc=example,dc=com"}.
  19261. @end deftypevr
  19262. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  19263. Specifies the search scope (subtree, onelevel, base or children). The
  19264. default scope is subtree; base scope is almost never useful for name
  19265. service lookups; children scope is not supported on all servers.
  19266. Defaults to @samp{(subtree)}.
  19267. @end deftypevr
  19268. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  19269. Specifies the policy for dereferencing aliases. The default policy is
  19270. to never dereference aliases.
  19271. Defaults to @samp{disabled}.
  19272. @end deftypevr
  19273. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  19274. Specifies whether automatic referral chasing should be enabled. The
  19275. default behaviour is to chase referrals.
  19276. Defaults to @samp{disabled}.
  19277. @end deftypevr
  19278. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  19279. This option allows for custom attributes to be looked up instead of the
  19280. default RFC 2307 attributes. It is a list of maps, each consisting of
  19281. the name of a map, the RFC 2307 attribute to match and the query
  19282. expression for the attribute as it is available in the directory.
  19283. Defaults to @samp{()}.
  19284. @end deftypevr
  19285. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  19286. A list of filters consisting of the name of a map to which the filter
  19287. applies and an LDAP search filter expression.
  19288. Defaults to @samp{()}.
  19289. @end deftypevr
  19290. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  19291. Specifies the time limit in seconds to use when connecting to the
  19292. directory server. The default value is 10 seconds.
  19293. Defaults to @samp{disabled}.
  19294. @end deftypevr
  19295. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  19296. Specifies the time limit (in seconds) to wait for a response from the
  19297. LDAP server. A value of zero, which is the default, is to wait
  19298. indefinitely for searches to be completed.
  19299. Defaults to @samp{disabled}.
  19300. @end deftypevr
  19301. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  19302. Specifies the period if inactivity (in seconds) after which the con‐
  19303. nection to the LDAP server will be closed. The default is not to time
  19304. out connections.
  19305. Defaults to @samp{disabled}.
  19306. @end deftypevr
  19307. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  19308. Specifies the number of seconds to sleep when connecting to all LDAP
  19309. servers fails. By default one second is waited between the first
  19310. failure and the first retry.
  19311. Defaults to @samp{disabled}.
  19312. @end deftypevr
  19313. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  19314. Specifies the time after which the LDAP server is considered to be
  19315. permanently unavailable. Once this time is reached retries will be done
  19316. only once per this time period. The default value is 10 seconds.
  19317. Defaults to @samp{disabled}.
  19318. @end deftypevr
  19319. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  19320. Specifies whether to use SSL/TLS or not (the default is not to). If
  19321. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  19322. SSL.
  19323. Defaults to @samp{disabled}.
  19324. @end deftypevr
  19325. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  19326. Specifies what checks to perform on a server-supplied certificate. The
  19327. meaning of the values is described in the ldap.conf(5) manual page.
  19328. Defaults to @samp{disabled}.
  19329. @end deftypevr
  19330. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  19331. Specifies the directory containing X.509 certificates for peer authen‐
  19332. tication. This parameter is ignored when using GnuTLS.
  19333. Defaults to @samp{disabled}.
  19334. @end deftypevr
  19335. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  19336. Specifies the path to the X.509 certificate for peer authentication.
  19337. Defaults to @samp{disabled}.
  19338. @end deftypevr
  19339. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  19340. Specifies the path to an entropy source. This parameter is ignored when
  19341. using GnuTLS.
  19342. Defaults to @samp{disabled}.
  19343. @end deftypevr
  19344. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  19345. Specifies the ciphers to use for TLS as a string.
  19346. Defaults to @samp{disabled}.
  19347. @end deftypevr
  19348. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  19349. Specifies the path to the file containing the local certificate for
  19350. client TLS authentication.
  19351. Defaults to @samp{disabled}.
  19352. @end deftypevr
  19353. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  19354. Specifies the path to the file containing the private key for client TLS
  19355. authentication.
  19356. Defaults to @samp{disabled}.
  19357. @end deftypevr
  19358. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  19359. Set this to a number greater than 0 to request paged results from the
  19360. LDAP server in accordance with RFC2696. The default (0) is to not
  19361. request paged results.
  19362. Defaults to @samp{disabled}.
  19363. @end deftypevr
  19364. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  19365. This option prevents group membership lookups through LDAP for the
  19366. specified users. Alternatively, the value 'all-local may be used. With
  19367. that value nslcd builds a full list of non-LDAP users on startup.
  19368. Defaults to @samp{disabled}.
  19369. @end deftypevr
  19370. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  19371. This option ensures that LDAP users with a numeric user id lower than
  19372. the specified value are ignored.
  19373. Defaults to @samp{disabled}.
  19374. @end deftypevr
  19375. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  19376. This option specifies an offset that is added to all LDAP numeric user
  19377. ids. This can be used to avoid user id collisions with local users.
  19378. Defaults to @samp{disabled}.
  19379. @end deftypevr
  19380. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  19381. This option specifies an offset that is added to all LDAP numeric group
  19382. ids. This can be used to avoid user id collisions with local groups.
  19383. Defaults to @samp{disabled}.
  19384. @end deftypevr
  19385. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  19386. If this option is set, the member attribute of a group may point to
  19387. another group. Members of nested groups are also returned in the higher
  19388. level group and parent groups are returned when finding groups for a
  19389. specific user. The default is not to perform extra searches for nested
  19390. groups.
  19391. Defaults to @samp{disabled}.
  19392. @end deftypevr
  19393. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  19394. If this option is set, the group member list is not retrieved when
  19395. looking up groups. Lookups for finding which groups a user belongs to
  19396. will remain functional so the user will likely still get the correct
  19397. groups assigned on login.
  19398. Defaults to @samp{disabled}.
  19399. @end deftypevr
  19400. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  19401. If this option is set, functions which cause all user/group entries to
  19402. be loaded from the directory will not succeed in doing so. This can
  19403. dramatically reduce LDAP server load in situations where there are a
  19404. great number of users and/or groups. This option is not recommended for
  19405. most configurations.
  19406. Defaults to @samp{disabled}.
  19407. @end deftypevr
  19408. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  19409. This option can be used to specify how user and group names are verified
  19410. within the system. This pattern is used to check all user and group
  19411. names that are requested and returned from LDAP.
  19412. Defaults to @samp{disabled}.
  19413. @end deftypevr
  19414. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  19415. This specifies whether or not to perform searches using case-insensitive
  19416. matching. Enabling this could open up the system to authorization
  19417. bypass vulnerabilities and introduce nscd cache poisoning
  19418. vulnerabilities which allow denial of service.
  19419. Defaults to @samp{disabled}.
  19420. @end deftypevr
  19421. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  19422. This option specifies whether password policy controls are requested and
  19423. handled from the LDAP server when performing user authentication.
  19424. Defaults to @samp{disabled}.
  19425. @end deftypevr
  19426. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  19427. By default nslcd performs an LDAP search with the user's credentials
  19428. after BIND (authentication) to ensure that the BIND operation was
  19429. successful. The default search is a simple check to see if the user's
  19430. DN exists. A search filter can be specified that will be used instead.
  19431. It should return at least one entry.
  19432. Defaults to @samp{disabled}.
  19433. @end deftypevr
  19434. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  19435. This option allows flexible fine tuning of the authorisation check that
  19436. should be performed. The search filter specified is executed and if any
  19437. entries match, access is granted, otherwise access is denied.
  19438. Defaults to @samp{disabled}.
  19439. @end deftypevr
  19440. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  19441. If this option is set password modification using pam_ldap will be
  19442. denied and the specified message will be presented to the user instead.
  19443. The message can be used to direct the user to an alternative means of
  19444. changing their password.
  19445. Defaults to @samp{disabled}.
  19446. @end deftypevr
  19447. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  19448. List of pam service names for which LDAP authentication should suffice.
  19449. Defaults to @samp{()}.
  19450. @end deftypevr
  19451. @c %end of generated documentation for nslcd-configuration
  19452. @node Web Services
  19453. @subsection Web Services
  19454. @cindex web
  19455. @cindex www
  19456. @cindex HTTP
  19457. The @code{(gnu services web)} module provides the Apache HTTP Server,
  19458. the nginx web server, and also a fastcgi wrapper daemon.
  19459. @subsubheading Apache HTTP Server
  19460. @deffn {Scheme Variable} httpd-service-type
  19461. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  19462. (@dfn{httpd}). The value for this service type is a
  19463. @code{httpd-configuration} record.
  19464. A simple example configuration is given below.
  19465. @lisp
  19466. (service httpd-service-type
  19467. (httpd-configuration
  19468. (config
  19469. (httpd-config-file
  19470. (server-name "www.example.com")
  19471. (document-root "/srv/http/www.example.com")))))
  19472. @end lisp
  19473. Other services can also extend the @code{httpd-service-type} to add to
  19474. the configuration.
  19475. @lisp
  19476. (simple-service 'www.example.com-server httpd-service-type
  19477. (list
  19478. (httpd-virtualhost
  19479. "*:80"
  19480. (list (string-join '("ServerName www.example.com"
  19481. "DocumentRoot /srv/http/www.example.com")
  19482. "\n")))))
  19483. @end lisp
  19484. @end deffn
  19485. The details for the @code{httpd-configuration}, @code{httpd-module},
  19486. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  19487. given below.
  19488. @deffn {Data Type} httpd-configuration
  19489. This data type represents the configuration for the httpd service.
  19490. @table @asis
  19491. @item @code{package} (default: @code{httpd})
  19492. The httpd package to use.
  19493. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  19494. The pid file used by the shepherd-service.
  19495. @item @code{config} (default: @code{(httpd-config-file)})
  19496. The configuration file to use with the httpd service. The default value
  19497. is a @code{httpd-config-file} record, but this can also be a different
  19498. G-expression that generates a file, for example a @code{plain-file}. A
  19499. file outside of the store can also be specified through a string.
  19500. @end table
  19501. @end deffn
  19502. @deffn {Data Type} httpd-module
  19503. This data type represents a module for the httpd service.
  19504. @table @asis
  19505. @item @code{name}
  19506. The name of the module.
  19507. @item @code{file}
  19508. The file for the module. This can be relative to the httpd package being
  19509. used, the absolute location of a file, or a G-expression for a file
  19510. within the store, for example @code{(file-append mod-wsgi
  19511. "/modules/mod_wsgi.so")}.
  19512. @end table
  19513. @end deffn
  19514. @defvr {Scheme Variable} %default-httpd-modules
  19515. A default list of @code{httpd-module} objects.
  19516. @end defvr
  19517. @deffn {Data Type} httpd-config-file
  19518. This data type represents a configuration file for the httpd service.
  19519. @table @asis
  19520. @item @code{modules} (default: @code{%default-httpd-modules})
  19521. The modules to load. Additional modules can be added here, or loaded by
  19522. additional configuration.
  19523. For example, in order to handle requests for PHP files, you can use Apache’s
  19524. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  19525. @lisp
  19526. (service httpd-service-type
  19527. (httpd-configuration
  19528. (config
  19529. (httpd-config-file
  19530. (modules (cons*
  19531. (httpd-module
  19532. (name "proxy_module")
  19533. (file "modules/mod_proxy.so"))
  19534. (httpd-module
  19535. (name "proxy_fcgi_module")
  19536. (file "modules/mod_proxy_fcgi.so"))
  19537. %default-httpd-modules))
  19538. (extra-config (list "\
  19539. <FilesMatch \\.php$>
  19540. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  19541. </FilesMatch>"))))))
  19542. (service php-fpm-service-type
  19543. (php-fpm-configuration
  19544. (socket "/var/run/php-fpm.sock")
  19545. (socket-group "httpd")))
  19546. @end lisp
  19547. @item @code{server-root} (default: @code{httpd})
  19548. The @code{ServerRoot} in the configuration file, defaults to the httpd
  19549. package. Directives including @code{Include} and @code{LoadModule} are
  19550. taken as relative to the server root.
  19551. @item @code{server-name} (default: @code{#f})
  19552. The @code{ServerName} in the configuration file, used to specify the
  19553. request scheme, hostname and port that the server uses to identify
  19554. itself.
  19555. This doesn't need to be set in the server config, and can be specified
  19556. in virtual hosts. The default is @code{#f} to not specify a
  19557. @code{ServerName}.
  19558. @item @code{document-root} (default: @code{"/srv/http"})
  19559. The @code{DocumentRoot} from which files will be served.
  19560. @item @code{listen} (default: @code{'("80")})
  19561. The list of values for the @code{Listen} directives in the config
  19562. file. The value should be a list of strings, when each string can
  19563. specify the port number to listen on, and optionally the IP address and
  19564. protocol to use.
  19565. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  19566. The @code{PidFile} to use. This should match the @code{pid-file} set in
  19567. the @code{httpd-configuration} so that the Shepherd service is
  19568. configured correctly.
  19569. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  19570. The @code{ErrorLog} to which the server will log errors.
  19571. @item @code{user} (default: @code{"httpd"})
  19572. The @code{User} which the server will answer requests as.
  19573. @item @code{group} (default: @code{"httpd"})
  19574. The @code{Group} which the server will answer requests as.
  19575. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  19576. A flat list of strings and G-expressions which will be added to the end
  19577. of the configuration file.
  19578. Any values which the service is extended with will be appended to this
  19579. list.
  19580. @end table
  19581. @end deffn
  19582. @deffn {Data Type} httpd-virtualhost
  19583. This data type represents a virtualhost configuration block for the httpd service.
  19584. These should be added to the extra-config for the httpd-service.
  19585. @lisp
  19586. (simple-service 'www.example.com-server httpd-service-type
  19587. (list
  19588. (httpd-virtualhost
  19589. "*:80"
  19590. (list (string-join '("ServerName www.example.com"
  19591. "DocumentRoot /srv/http/www.example.com")
  19592. "\n")))))
  19593. @end lisp
  19594. @table @asis
  19595. @item @code{addresses-and-ports}
  19596. The addresses and ports for the @code{VirtualHost} directive.
  19597. @item @code{contents}
  19598. The contents of the @code{VirtualHost} directive, this should be a list
  19599. of strings and G-expressions.
  19600. @end table
  19601. @end deffn
  19602. @subsubheading NGINX
  19603. @deffn {Scheme Variable} nginx-service-type
  19604. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  19605. value for this service type is a @code{<nginx-configuration>} record.
  19606. A simple example configuration is given below.
  19607. @lisp
  19608. (service nginx-service-type
  19609. (nginx-configuration
  19610. (server-blocks
  19611. (list (nginx-server-configuration
  19612. (server-name '("www.example.com"))
  19613. (root "/srv/http/www.example.com"))))))
  19614. @end lisp
  19615. In addition to adding server blocks to the service configuration
  19616. directly, this service can be extended by other services to add server
  19617. blocks, as in this example:
  19618. @lisp
  19619. (simple-service 'my-extra-server nginx-service-type
  19620. (list (nginx-server-configuration
  19621. (root "/srv/http/extra-website")
  19622. (try-files (list "$uri" "$uri/index.html")))))
  19623. @end lisp
  19624. @end deffn
  19625. At startup, @command{nginx} has not yet read its configuration file, so
  19626. it uses a default file to log error messages. If it fails to load its
  19627. configuration file, that is where error messages are logged. After the
  19628. configuration file is loaded, the default error log file changes as per
  19629. configuration. In our case, startup error messages can be found in
  19630. @file{/var/run/nginx/logs/error.log}, and after configuration in
  19631. @file{/var/log/nginx/error.log}. The second location can be changed
  19632. with the @var{log-directory} configuration option.
  19633. @deffn {Data Type} nginx-configuration
  19634. This data type represents the configuration for NGinx. Some
  19635. configuration can be done through this and the other provided record
  19636. types, or alternatively, a config file can be provided.
  19637. @table @asis
  19638. @item @code{nginx} (default: @code{nginx})
  19639. The nginx package to use.
  19640. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  19641. The directory to which NGinx will write log files.
  19642. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  19643. The directory in which NGinx will create a pid file, and write temporary
  19644. files.
  19645. @item @code{server-blocks} (default: @code{'()})
  19646. A list of @dfn{server blocks} to create in the generated configuration
  19647. file, the elements should be of type
  19648. @code{<nginx-server-configuration>}.
  19649. The following example would setup NGinx to serve @code{www.example.com}
  19650. from the @code{/srv/http/www.example.com} directory, without using
  19651. HTTPS.
  19652. @lisp
  19653. (service nginx-service-type
  19654. (nginx-configuration
  19655. (server-blocks
  19656. (list (nginx-server-configuration
  19657. (server-name '("www.example.com"))
  19658. (root "/srv/http/www.example.com"))))))
  19659. @end lisp
  19660. @item @code{upstream-blocks} (default: @code{'()})
  19661. A list of @dfn{upstream blocks} to create in the generated configuration
  19662. file, the elements should be of type
  19663. @code{<nginx-upstream-configuration>}.
  19664. Configuring upstreams through the @code{upstream-blocks} can be useful
  19665. when combined with @code{locations} in the
  19666. @code{<nginx-server-configuration>} records. The following example
  19667. creates a server configuration with one location configuration, that
  19668. will proxy requests to a upstream configuration, which will handle
  19669. requests with two servers.
  19670. @lisp
  19671. (service
  19672. nginx-service-type
  19673. (nginx-configuration
  19674. (server-blocks
  19675. (list (nginx-server-configuration
  19676. (server-name '("www.example.com"))
  19677. (root "/srv/http/www.example.com")
  19678. (locations
  19679. (list
  19680. (nginx-location-configuration
  19681. (uri "/path1")
  19682. (body '("proxy_pass http://server-proxy;"))))))))
  19683. (upstream-blocks
  19684. (list (nginx-upstream-configuration
  19685. (name "server-proxy")
  19686. (servers (list "server1.example.com"
  19687. "server2.example.com")))))))
  19688. @end lisp
  19689. @item @code{file} (default: @code{#f})
  19690. If a configuration @var{file} is provided, this will be used, rather than
  19691. generating a configuration file from the provided @code{log-directory},
  19692. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  19693. proper operation, these arguments should match what is in @var{file} to ensure
  19694. that the directories are created when the service is activated.
  19695. This can be useful if you have an existing configuration file, or it's
  19696. not possible to do what is required through the other parts of the
  19697. nginx-configuration record.
  19698. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  19699. Bucket size for the server names hash tables, defaults to @code{#f} to
  19700. use the size of the processors cache line.
  19701. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  19702. Maximum bucket size for the server names hash tables.
  19703. @item @code{modules} (default: @code{'()})
  19704. List of nginx dynamic modules to load. This should be a list of file
  19705. names of loadable modules, as in this example:
  19706. @lisp
  19707. (modules
  19708. (list
  19709. (file-append nginx-accept-language-module "\
  19710. /etc/nginx/modules/ngx_http_accept_language_module.so")
  19711. (file-append nginx-lua-module "\
  19712. /etc/nginx/modules/ngx_http_lua_module.so")))
  19713. @end lisp
  19714. @item @code{lua-package-path} (default: @code{'()})
  19715. List of nginx lua packages to load. This should be a list of package
  19716. names of loadable lua modules, as in this example:
  19717. @lisp
  19718. (lua-package-path (list lua-resty-core
  19719. lua-resty-lrucache
  19720. lua-resty-signal
  19721. lua-tablepool
  19722. lua-resty-shell))
  19723. @end lisp
  19724. @item @code{lua-package-cpath} (default: @code{'()})
  19725. List of nginx lua C packages to load. This should be a list of package
  19726. names of loadable lua C modules, as in this example:
  19727. @lisp
  19728. (lua-package-cpath (list lua-resty-signal))
  19729. @end lisp
  19730. @item @code{global-directives} (default: @code{'((events . ()))})
  19731. Association list of global directives for the top level of the nginx
  19732. configuration. Values may themselves be association lists.
  19733. @lisp
  19734. (global-directives
  19735. `((worker_processes . 16)
  19736. (pcre_jit . on)
  19737. (events . ((worker_connections . 1024)))))
  19738. @end lisp
  19739. @item @code{extra-content} (default: @code{""})
  19740. Extra content for the @code{http} block. Should be string or a string
  19741. valued G-expression.
  19742. @end table
  19743. @end deffn
  19744. @deftp {Data Type} nginx-server-configuration
  19745. Data type representing the configuration of an nginx server block.
  19746. This type has the following parameters:
  19747. @table @asis
  19748. @item @code{listen} (default: @code{'("80" "443 ssl")})
  19749. Each @code{listen} directive sets the address and port for IP, or the
  19750. path for a UNIX-domain socket on which the server will accept requests.
  19751. Both address and port, or only address or only port can be specified.
  19752. An address may also be a hostname, for example:
  19753. @lisp
  19754. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  19755. @end lisp
  19756. @item @code{server-name} (default: @code{(list 'default)})
  19757. A list of server names this server represents. @code{'default} represents the
  19758. default server for connections matching no other server.
  19759. @item @code{root} (default: @code{"/srv/http"})
  19760. Root of the website nginx will serve.
  19761. @item @code{locations} (default: @code{'()})
  19762. A list of @dfn{nginx-location-configuration} or
  19763. @dfn{nginx-named-location-configuration} records to use within this
  19764. server block.
  19765. @item @code{index} (default: @code{(list "index.html")})
  19766. Index files to look for when clients ask for a directory. If it cannot be found,
  19767. Nginx will send the list of files in the directory.
  19768. @item @code{try-files} (default: @code{'()})
  19769. A list of files whose existence is checked in the specified order.
  19770. @code{nginx} will use the first file it finds to process the request.
  19771. @item @code{ssl-certificate} (default: @code{#f})
  19772. Where to find the certificate for secure connections. Set it to @code{#f} if
  19773. you don't have a certificate or you don't want to use HTTPS.
  19774. @item @code{ssl-certificate-key} (default: @code{#f})
  19775. Where to find the private key for secure connections. Set it to @code{#f} if
  19776. you don't have a key or you don't want to use HTTPS.
  19777. @item @code{server-tokens?} (default: @code{#f})
  19778. Whether the server should add its configuration to response.
  19779. @item @code{raw-content} (default: @code{'()})
  19780. A list of raw lines added to the server block.
  19781. @end table
  19782. @end deftp
  19783. @deftp {Data Type} nginx-upstream-configuration
  19784. Data type representing the configuration of an nginx @code{upstream}
  19785. block. This type has the following parameters:
  19786. @table @asis
  19787. @item @code{name}
  19788. Name for this group of servers.
  19789. @item @code{servers}
  19790. Specify the addresses of the servers in the group. The address can be
  19791. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  19792. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  19793. prefix @samp{unix:}. For addresses using an IP address or domain name,
  19794. the default port is 80, and a different port can be specified
  19795. explicitly.
  19796. @end table
  19797. @end deftp
  19798. @deftp {Data Type} nginx-location-configuration
  19799. Data type representing the configuration of an nginx @code{location}
  19800. block. This type has the following parameters:
  19801. @table @asis
  19802. @item @code{uri}
  19803. URI which this location block matches.
  19804. @anchor{nginx-location-configuration body}
  19805. @item @code{body}
  19806. Body of the location block, specified as a list of strings. This can contain
  19807. many
  19808. configuration directives. For example, to pass requests to a upstream
  19809. server group defined using an @code{nginx-upstream-configuration} block,
  19810. the following directive would be specified in the body @samp{(list "proxy_pass
  19811. http://upstream-name;")}.
  19812. @end table
  19813. @end deftp
  19814. @deftp {Data Type} nginx-named-location-configuration
  19815. Data type representing the configuration of an nginx named location
  19816. block. Named location blocks are used for request redirection, and not
  19817. used for regular request processing. This type has the following
  19818. parameters:
  19819. @table @asis
  19820. @item @code{name}
  19821. Name to identify this location block.
  19822. @item @code{body}
  19823. @xref{nginx-location-configuration body}, as the body for named location
  19824. blocks can be used in a similar way to the
  19825. @code{nginx-location-configuration body}. One restriction is that the
  19826. body of a named location block cannot contain location blocks.
  19827. @end table
  19828. @end deftp
  19829. @subsubheading Varnish Cache
  19830. @cindex Varnish
  19831. Varnish is a fast cache server that sits in between web applications
  19832. and end users. It proxies requests from clients and caches the
  19833. accessed URLs such that multiple requests for the same resource only
  19834. creates one request to the back-end.
  19835. @defvr {Scheme Variable} varnish-service-type
  19836. Service type for the Varnish daemon.
  19837. @end defvr
  19838. @deftp {Data Type} varnish-configuration
  19839. Data type representing the @code{varnish} service configuration.
  19840. This type has the following parameters:
  19841. @table @asis
  19842. @item @code{package} (default: @code{varnish})
  19843. The Varnish package to use.
  19844. @item @code{name} (default: @code{"default"})
  19845. A name for this Varnish instance. Varnish will create a directory in
  19846. @file{/var/varnish/} with this name and keep temporary files there. If
  19847. the name starts with a forward slash, it is interpreted as an absolute
  19848. directory name.
  19849. Pass the @code{-n} argument to other Varnish programs to connect to the
  19850. named instance, e.g.@: @command{varnishncsa -n default}.
  19851. @item @code{backend} (default: @code{"localhost:8080"})
  19852. The backend to use. This option has no effect if @code{vcl} is set.
  19853. @item @code{vcl} (default: #f)
  19854. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  19855. is @code{#f}, Varnish will proxy @code{backend} using the default
  19856. configuration. Otherwise this must be a file-like object with valid
  19857. VCL syntax.
  19858. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  19859. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  19860. can do something along these lines:
  19861. @lisp
  19862. (define %gnu-mirror
  19863. (plain-file "gnu.vcl"
  19864. "vcl 4.1;
  19865. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  19866. (operating-system
  19867. ;; @dots{}
  19868. (services (cons (service varnish-service-type
  19869. (varnish-configuration
  19870. (listen '(":80"))
  19871. (vcl %gnu-mirror)))
  19872. %base-services)))
  19873. @end lisp
  19874. The configuration of an already running Varnish instance can be inspected
  19875. and changed using the @command{varnishadm} program.
  19876. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  19877. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  19878. comprehensive documentation on Varnish and its configuration language.
  19879. @item @code{listen} (default: @code{'("localhost:80")})
  19880. List of addresses Varnish will listen on.
  19881. @item @code{storage} (default: @code{'("malloc,128m")})
  19882. List of storage backends that will be available in VCL.
  19883. @item @code{parameters} (default: @code{'()})
  19884. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  19885. @item @code{extra-options} (default: @code{'()})
  19886. Additional arguments to pass to the @command{varnishd} process.
  19887. @end table
  19888. @end deftp
  19889. @subsubheading Patchwork
  19890. @cindex Patchwork
  19891. Patchwork is a patch tracking system. It can collect patches sent to a
  19892. mailing list, and display them in a web interface.
  19893. @defvr {Scheme Variable} patchwork-service-type
  19894. Service type for Patchwork.
  19895. @end defvr
  19896. The following example is an example of a minimal service for Patchwork, for
  19897. the @code{patchwork.example.com} domain.
  19898. @lisp
  19899. (service patchwork-service-type
  19900. (patchwork-configuration
  19901. (domain "patchwork.example.com")
  19902. (settings-module
  19903. (patchwork-settings-module
  19904. (allowed-hosts (list domain))
  19905. (default-from-email "patchwork@@patchwork.example.com")))
  19906. (getmail-retriever-config
  19907. (getmail-retriever-configuration
  19908. (type "SimpleIMAPSSLRetriever")
  19909. (server "imap.example.com")
  19910. (port 993)
  19911. (username "patchwork")
  19912. (password-command
  19913. (list (file-append coreutils "/bin/cat")
  19914. "/etc/getmail-patchwork-imap-password"))
  19915. (extra-parameters
  19916. '((mailboxes . ("Patches"))))))))
  19917. @end lisp
  19918. There are three records for configuring the Patchwork service. The
  19919. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  19920. within the HTTPD service.
  19921. The @code{settings-module} field within the @code{<patchwork-configuration>}
  19922. record can be populated with the @code{<patchwork-settings-module>} record,
  19923. which describes a settings module that is generated within the Guix store.
  19924. For the @code{database-configuration} field within the
  19925. @code{<patchwork-settings-module>}, the
  19926. @code{<patchwork-database-configuration>} must be used.
  19927. @deftp {Data Type} patchwork-configuration
  19928. Data type representing the Patchwork service configuration. This type has the
  19929. following parameters:
  19930. @table @asis
  19931. @item @code{patchwork} (default: @code{patchwork})
  19932. The Patchwork package to use.
  19933. @item @code{domain}
  19934. The domain to use for Patchwork, this is used in the HTTPD service virtual
  19935. host.
  19936. @item @code{settings-module}
  19937. The settings module to use for Patchwork. As a Django application, Patchwork
  19938. is configured with a Python module containing the settings. This can either be
  19939. an instance of the @code{<patchwork-settings-module>} record, any other record
  19940. that represents the settings in the store, or a directory outside of the
  19941. store.
  19942. @item @code{static-path} (default: @code{"/static/"})
  19943. The path under which the HTTPD service should serve the static files.
  19944. @item @code{getmail-retriever-config}
  19945. The getmail-retriever-configuration record value to use with
  19946. Patchwork. Getmail will be configured with this value, the messages will be
  19947. delivered to Patchwork.
  19948. @end table
  19949. @end deftp
  19950. @deftp {Data Type} patchwork-settings-module
  19951. Data type representing a settings module for Patchwork. Some of these
  19952. settings relate directly to Patchwork, but others relate to Django, the web
  19953. framework used by Patchwork, or the Django Rest Framework library. This type
  19954. has the following parameters:
  19955. @table @asis
  19956. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  19957. The database connection settings used for Patchwork. See the
  19958. @code{<patchwork-database-configuration>} record type for more information.
  19959. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  19960. Patchwork, as a Django web application uses a secret key for cryptographically
  19961. signing values. This file should contain a unique unpredictable value.
  19962. If this file does not exist, it will be created and populated with a random
  19963. value by the patchwork-setup shepherd service.
  19964. This setting relates to Django.
  19965. @item @code{allowed-hosts}
  19966. A list of valid hosts for this Patchwork service. This should at least include
  19967. the domain specified in the @code{<patchwork-configuration>} record.
  19968. This is a Django setting.
  19969. @item @code{default-from-email}
  19970. The email address from which Patchwork should send email by default.
  19971. This is a Patchwork setting.
  19972. @item @code{static-url} (default: @code{#f})
  19973. The URL to use when serving static assets. It can be part of a URL, or a full
  19974. URL, but must end in a @code{/}.
  19975. If the default value is used, the @code{static-path} value from the
  19976. @code{<patchwork-configuration>} record will be used.
  19977. This is a Django setting.
  19978. @item @code{admins} (default: @code{'()})
  19979. Email addresses to send the details of errors that occur. Each value should
  19980. be a list containing two elements, the name and then the email address.
  19981. This is a Django setting.
  19982. @item @code{debug?} (default: @code{#f})
  19983. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  19984. messages will be shown.
  19985. This is a Django setting.
  19986. @item @code{enable-rest-api?} (default: @code{#t})
  19987. Whether to enable the Patchwork REST API.
  19988. This is a Patchwork setting.
  19989. @item @code{enable-xmlrpc?} (default: @code{#t})
  19990. Whether to enable the XML RPC API.
  19991. This is a Patchwork setting.
  19992. @item @code{force-https-links?} (default: @code{#t})
  19993. Whether to use HTTPS links on Patchwork pages.
  19994. This is a Patchwork setting.
  19995. @item @code{extra-settings} (default: @code{""})
  19996. Extra code to place at the end of the Patchwork settings module.
  19997. @end table
  19998. @end deftp
  19999. @deftp {Data Type} patchwork-database-configuration
  20000. Data type representing the database configuration for Patchwork.
  20001. @table @asis
  20002. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  20003. The database engine to use.
  20004. @item @code{name} (default: @code{"patchwork"})
  20005. The name of the database to use.
  20006. @item @code{user} (default: @code{"httpd"})
  20007. The user to connect to the database as.
  20008. @item @code{password} (default: @code{""})
  20009. The password to use when connecting to the database.
  20010. @item @code{host} (default: @code{""})
  20011. The host to make the database connection to.
  20012. @item @code{port} (default: @code{""})
  20013. The port on which to connect to the database.
  20014. @end table
  20015. @end deftp
  20016. @subsubheading Mumi
  20017. @cindex Mumi, Debbugs Web interface
  20018. @cindex Debbugs, Mumi Web interface
  20019. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  20020. Web interface to the Debbugs bug tracker, by default for
  20021. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  20022. but it also fetches and indexes mail retrieved from Debbugs.
  20023. @defvr {Scheme Variable} mumi-service-type
  20024. This is the service type for Mumi.
  20025. @end defvr
  20026. @deftp {Data Type} mumi-configuration
  20027. Data type representing the Mumi service configuration. This type has the
  20028. following fields:
  20029. @table @asis
  20030. @item @code{mumi} (default: @code{mumi})
  20031. The Mumi package to use.
  20032. @item @code{mailer?} (default: @code{#true})
  20033. Whether to enable or disable the mailer component.
  20034. @item @code{mumi-configuration-sender}
  20035. The email address used as the sender for comments.
  20036. @item @code{mumi-configuration-smtp}
  20037. A URI to configure the SMTP settings for Mailutils. This could be
  20038. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  20039. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  20040. mailutils, GNU@tie{}Mailutils}.
  20041. @end table
  20042. @end deftp
  20043. @subsubheading FastCGI
  20044. @cindex fastcgi
  20045. @cindex fcgiwrap
  20046. FastCGI is an interface between the front-end and the back-end of a web
  20047. service. It is a somewhat legacy facility; new web services should
  20048. generally just talk HTTP between the front-end and the back-end.
  20049. However there are a number of back-end services such as PHP or the
  20050. optimized HTTP Git repository access that use FastCGI, so we have
  20051. support for it in Guix.
  20052. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  20053. dispatch some subset of its requests to the fastcgi backend, which
  20054. listens on a local TCP or UNIX socket. There is an intermediary
  20055. @code{fcgiwrap} program that sits between the actual backend process and
  20056. the web server. The front-end indicates which backend program to run,
  20057. passing that information to the @code{fcgiwrap} process.
  20058. @defvr {Scheme Variable} fcgiwrap-service-type
  20059. A service type for the @code{fcgiwrap} FastCGI proxy.
  20060. @end defvr
  20061. @deftp {Data Type} fcgiwrap-configuration
  20062. Data type representing the configuration of the @code{fcgiwrap} service.
  20063. This type has the following parameters:
  20064. @table @asis
  20065. @item @code{package} (default: @code{fcgiwrap})
  20066. The fcgiwrap package to use.
  20067. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  20068. The socket on which the @code{fcgiwrap} process should listen, as a
  20069. string. Valid @var{socket} values include
  20070. @code{unix:@var{/path/to/unix/socket}},
  20071. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  20072. @code{tcp6:[@var{ipv6_addr}]:port}.
  20073. @item @code{user} (default: @code{fcgiwrap})
  20074. @itemx @code{group} (default: @code{fcgiwrap})
  20075. The user and group names, as strings, under which to run the
  20076. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  20077. the user asks for the specific user or group names @code{fcgiwrap} that
  20078. the corresponding user and/or group is present on the system.
  20079. It is possible to configure a FastCGI-backed web service to pass HTTP
  20080. authentication information from the front-end to the back-end, and to
  20081. allow @code{fcgiwrap} to run the back-end process as a corresponding
  20082. local user. To enable this capability on the back-end, run
  20083. @code{fcgiwrap} as the @code{root} user and group. Note that this
  20084. capability also has to be configured on the front-end as well.
  20085. @end table
  20086. @end deftp
  20087. @cindex php-fpm
  20088. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  20089. with some additional features useful for sites of any size.
  20090. These features include:
  20091. @itemize @bullet
  20092. @item Adaptive process spawning
  20093. @item Basic statistics (similar to Apache's mod_status)
  20094. @item Advanced process management with graceful stop/start
  20095. @item Ability to start workers with different uid/gid/chroot/environment
  20096. and different php.ini (replaces safe_mode)
  20097. @item Stdout & stderr logging
  20098. @item Emergency restart in case of accidental opcode cache destruction
  20099. @item Accelerated upload support
  20100. @item Support for a "slowlog"
  20101. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  20102. a special function to finish request & flush all data while continuing to do
  20103. something time-consuming (video converting, stats processing, etc.)
  20104. @end itemize
  20105. ...@: and much more.
  20106. @defvr {Scheme Variable} php-fpm-service-type
  20107. A Service type for @code{php-fpm}.
  20108. @end defvr
  20109. @deftp {Data Type} php-fpm-configuration
  20110. Data Type for php-fpm service configuration.
  20111. @table @asis
  20112. @item @code{php} (default: @code{php})
  20113. The php package to use.
  20114. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  20115. The address on which to accept FastCGI requests. Valid syntaxes are:
  20116. @table @asis
  20117. @item @code{"ip.add.re.ss:port"}
  20118. Listen on a TCP socket to a specific address on a specific port.
  20119. @item @code{"port"}
  20120. Listen on a TCP socket to all addresses on a specific port.
  20121. @item @code{"/path/to/unix/socket"}
  20122. Listen on a unix socket.
  20123. @end table
  20124. @item @code{user} (default: @code{php-fpm})
  20125. User who will own the php worker processes.
  20126. @item @code{group} (default: @code{php-fpm})
  20127. Group of the worker processes.
  20128. @item @code{socket-user} (default: @code{php-fpm})
  20129. User who can speak to the php-fpm socket.
  20130. @item @code{socket-group} (default: @code{nginx})
  20131. Group that can speak to the php-fpm socket.
  20132. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  20133. The process id of the php-fpm process is written to this file
  20134. once the service has started.
  20135. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  20136. Log for the php-fpm master process.
  20137. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  20138. Detailed settings for the php-fpm process manager.
  20139. Must be one of:
  20140. @table @asis
  20141. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  20142. @item @code{<php-fpm-static-process-manager-configuration>}
  20143. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  20144. @end table
  20145. @item @code{display-errors} (default @code{#f})
  20146. Determines whether php errors and warning should be sent to clients
  20147. and displayed in their browsers.
  20148. This is useful for local php development, but a security risk for public sites,
  20149. as error messages can reveal passwords and personal data.
  20150. @item @code{timezone} (default @code{#f})
  20151. Specifies @code{php_admin_value[date.timezone]} parameter.
  20152. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  20153. This file will log the @code{stderr} outputs of php worker processes.
  20154. Can be set to @code{#f} to disable logging.
  20155. @item @code{file} (default @code{#f})
  20156. An optional override of the whole configuration.
  20157. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  20158. @item @code{php-ini-file} (default @code{#f})
  20159. An optional override of the default php settings.
  20160. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  20161. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  20162. For local development it is useful to set a higher timeout and memory
  20163. limit for spawned php processes. This be accomplished with the
  20164. following operating system configuration snippet:
  20165. @lisp
  20166. (define %local-php-ini
  20167. (plain-file "php.ini"
  20168. "memory_limit = 2G
  20169. max_execution_time = 1800"))
  20170. (operating-system
  20171. ;; @dots{}
  20172. (services (cons (service php-fpm-service-type
  20173. (php-fpm-configuration
  20174. (php-ini-file %local-php-ini)))
  20175. %base-services)))
  20176. @end lisp
  20177. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  20178. directives} for comprehensive documentation on the acceptable
  20179. @file{php.ini} directives.
  20180. @end table
  20181. @end deftp
  20182. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  20183. Data Type for the @code{dynamic} php-fpm process manager. With the
  20184. @code{dynamic} process manager, spare worker processes are kept around
  20185. based on it's configured limits.
  20186. @table @asis
  20187. @item @code{max-children} (default: @code{5})
  20188. Maximum of worker processes.
  20189. @item @code{start-servers} (default: @code{2})
  20190. How many worker processes should be started on start-up.
  20191. @item @code{min-spare-servers} (default: @code{1})
  20192. How many spare worker processes should be kept around at minimum.
  20193. @item @code{max-spare-servers} (default: @code{3})
  20194. How many spare worker processes should be kept around at maximum.
  20195. @end table
  20196. @end deftp
  20197. @deftp {Data type} php-fpm-static-process-manager-configuration
  20198. Data Type for the @code{static} php-fpm process manager. With the
  20199. @code{static} process manager, an unchanging number of worker processes
  20200. are created.
  20201. @table @asis
  20202. @item @code{max-children} (default: @code{5})
  20203. Maximum of worker processes.
  20204. @end table
  20205. @end deftp
  20206. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  20207. Data Type for the @code{on-demand} php-fpm process manager. With the
  20208. @code{on-demand} process manager, worker processes are only created as
  20209. requests arrive.
  20210. @table @asis
  20211. @item @code{max-children} (default: @code{5})
  20212. Maximum of worker processes.
  20213. @item @code{process-idle-timeout} (default: @code{10})
  20214. The time in seconds after which a process with no requests is killed.
  20215. @end table
  20216. @end deftp
  20217. @deffn {Scheme Procedure} nginx-php-location @
  20218. [#:nginx-package nginx] @
  20219. [socket (string-append "/var/run/php" @
  20220. (version-major (package-version php)) @
  20221. "-fpm.sock")]
  20222. A helper function to quickly add php to an @code{nginx-server-configuration}.
  20223. @end deffn
  20224. A simple services setup for nginx with php can look like this:
  20225. @lisp
  20226. (services (cons* (service dhcp-client-service-type)
  20227. (service php-fpm-service-type)
  20228. (service nginx-service-type
  20229. (nginx-server-configuration
  20230. (server-name '("example.com"))
  20231. (root "/srv/http/")
  20232. (locations
  20233. (list (nginx-php-location)))
  20234. (listen '("80"))
  20235. (ssl-certificate #f)
  20236. (ssl-certificate-key #f)))
  20237. %base-services))
  20238. @end lisp
  20239. @cindex cat-avatar-generator
  20240. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  20241. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  20242. the hash of a user's email address.
  20243. @deffn {Scheme Procedure} cat-avatar-generator-service @
  20244. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  20245. [#:package cat-avatar-generator] @
  20246. [#:configuration (nginx-server-configuration)]
  20247. Returns an nginx-server-configuration that inherits @code{configuration}. It
  20248. extends the nginx configuration to add a server block that serves @code{package},
  20249. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  20250. be able to use @code{cache-dir} as its cache directory.
  20251. @end deffn
  20252. A simple setup for cat-avatar-generator can look like this:
  20253. @lisp
  20254. (services (cons* (cat-avatar-generator-service
  20255. #:configuration
  20256. (nginx-server-configuration
  20257. (server-name '("example.com"))))
  20258. ...
  20259. %base-services))
  20260. @end lisp
  20261. @subsubheading Hpcguix-web
  20262. @cindex hpcguix-web
  20263. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  20264. program is a customizable web interface to browse Guix packages,
  20265. initially designed for users of high-performance computing (HPC)
  20266. clusters.
  20267. @defvr {Scheme Variable} hpcguix-web-service-type
  20268. The service type for @code{hpcguix-web}.
  20269. @end defvr
  20270. @deftp {Data Type} hpcguix-web-configuration
  20271. Data type for the hpcguix-web service configuration.
  20272. @table @asis
  20273. @item @code{specs}
  20274. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  20275. configuration. The main items available in this spec are:
  20276. @table @asis
  20277. @item @code{title-prefix} (default: @code{"hpcguix | "})
  20278. The page title prefix.
  20279. @item @code{guix-command} (default: @code{"guix"})
  20280. The @command{guix} command.
  20281. @item @code{package-filter-proc} (default: @code{(const #t)})
  20282. A procedure specifying how to filter packages that are displayed.
  20283. @item @code{package-page-extension-proc} (default: @code{(const '())})
  20284. Extension package for @code{hpcguix-web}.
  20285. @item @code{menu} (default: @code{'()})
  20286. Additional entry in page @code{menu}.
  20287. @item @code{channels} (default: @code{%default-channels})
  20288. List of channels from which the package list is built (@pxref{Channels}).
  20289. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  20290. The expiration time, in seconds, after which the package list is rebuilt from
  20291. the latest instances of the given channels.
  20292. @end table
  20293. See the hpcguix-web repository for a
  20294. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  20295. complete example}.
  20296. @item @code{package} (default: @code{hpcguix-web})
  20297. The hpcguix-web package to use.
  20298. @end table
  20299. @end deftp
  20300. A typical hpcguix-web service declaration looks like this:
  20301. @lisp
  20302. (service hpcguix-web-service-type
  20303. (hpcguix-web-configuration
  20304. (specs
  20305. #~(define site-config
  20306. (hpcweb-configuration
  20307. (title-prefix "Guix-HPC - ")
  20308. (menu '(("/about" "ABOUT"))))))))
  20309. @end lisp
  20310. @quotation Note
  20311. The hpcguix-web service periodically updates the package list it publishes by
  20312. pulling channels from Git. To that end, it needs to access X.509 certificates
  20313. so that it can authenticate Git servers when communicating over HTTPS, and it
  20314. assumes that @file{/etc/ssl/certs} contains those certificates.
  20315. Thus, make sure to add @code{nss-certs} or another certificate package to the
  20316. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  20317. more information on X.509 certificates.
  20318. @end quotation
  20319. @subsubheading gmnisrv
  20320. @cindex gmnisrv
  20321. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  20322. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  20323. @deffn {Scheme Variable} gmnisrv-service-type
  20324. This is the type of the gmnisrv service, whose value should be a
  20325. @code{gmnisrv-configuration} object, as in this example:
  20326. @lisp
  20327. (service gmnisrv-service-type
  20328. (gmnisrv-configuration
  20329. (config-file (local-file "./my-gmnisrv.ini"))))
  20330. @end lisp
  20331. @end deffn
  20332. @deftp {Data Type} gmnisrv-configuration
  20333. Data type representing the configuration of gmnisrv.
  20334. @table @asis
  20335. @item @code{package} (default: @var{gmnisrv})
  20336. Package object of the gmnisrv server.
  20337. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  20338. File-like object of the gmnisrv configuration file to use. The default
  20339. configuration listens on port 1965 and serves files from
  20340. @file{/srv/gemini}. Certificates are stored in
  20341. @file{/var/lib/gemini/certs}. For more information, run @command{man
  20342. gmnisrv} and @command{man gmnisrv.ini}.
  20343. @end table
  20344. @end deftp
  20345. @subsubheading Agate
  20346. @cindex agate
  20347. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  20348. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  20349. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  20350. protocol server written in Rust.
  20351. @deffn {Scheme Variable} agate-service-type
  20352. This is the type of the agate service, whose value should be an
  20353. @code{agate-service-type} object, as in this example:
  20354. @lisp
  20355. (service agate-service-type
  20356. (agate-configuration
  20357. (content "/srv/gemini")
  20358. (cert "/srv/cert.pem")
  20359. (key "/srv/key.rsa")))
  20360. @end lisp
  20361. The example above represents the minimal tweaking necessary to get Agate
  20362. up and running. Specifying the path to the certificate and key is
  20363. always necessary, as the Gemini protocol requires TLS by default.
  20364. To obtain a certificate and a key, you could, for example, use OpenSSL,
  20365. running a command similar to the following example:
  20366. @example
  20367. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  20368. -days 3650 -nodes -subj "/CN=example.com"
  20369. @end example
  20370. Of course, you'll have to replace @i{example.com} with your own domain
  20371. name, and then point the Agate configuration towards the path of the
  20372. generated key and certificate.
  20373. @end deffn
  20374. @deftp {Data Type} agate-configuration
  20375. Data type representing the configuration of Agate.
  20376. @table @asis
  20377. @item @code{package} (default: @code{agate})
  20378. The package object of the Agate server.
  20379. @item @code{content} (default: @file{"/srv/gemini"})
  20380. The directory from which Agate will serve files.
  20381. @item @code{cert} (default: @code{#f})
  20382. The path to the TLS certificate PEM file to be used for encrypted
  20383. connections. Must be filled in with a value from the user.
  20384. @item @code{key} (default: @code{#f})
  20385. The path to the PKCS8 private key file to be used for encrypted
  20386. connections. Must be filled in with a value from the user.
  20387. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  20388. A list of the addresses to listen on.
  20389. @item @code{hostname} (default: @code{#f})
  20390. The domain name of this Gemini server. Optional.
  20391. @item @code{lang} (default: @code{#f})
  20392. RFC 4646 language code(s) for text/gemini documents. Optional.
  20393. @item @code{silent?} (default: @code{#f})
  20394. Set to @code{#t} to disable logging output.
  20395. @item @code{serve-secret?} (default: @code{#f})
  20396. Set to @code{#t} to serve secret files (files/directories starting with
  20397. a dot).
  20398. @item @code{log-ip?} (default: @code{#t})
  20399. Whether or not to output IP addresses when logging.
  20400. @item @code{user} (default: @code{"agate"})
  20401. Owner of the @code{agate} process.
  20402. @item @code{group} (default: @code{"agate"})
  20403. Owner's group of the @code{agate} process.
  20404. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  20405. The file which should store the logging output of Agate.
  20406. @end table
  20407. @end deftp
  20408. @node Certificate Services
  20409. @subsection Certificate Services
  20410. @cindex Web
  20411. @cindex HTTP, HTTPS
  20412. @cindex Let's Encrypt
  20413. @cindex TLS certificates
  20414. The @code{(gnu services certbot)} module provides a service to
  20415. automatically obtain a valid TLS certificate from the Let's Encrypt
  20416. certificate authority. These certificates can then be used to serve
  20417. content securely over HTTPS or other TLS-based protocols, with the
  20418. knowledge that the client will be able to verify the server's
  20419. authenticity.
  20420. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  20421. @code{certbot} tool to automate the certification process. This tool
  20422. first securely generates a key on the server. It then makes a request
  20423. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  20424. checks that the request originates from the host in question by using a
  20425. challenge-response protocol, requiring the server to provide its
  20426. response over HTTP@. If that protocol completes successfully, the CA
  20427. signs the key, resulting in a certificate. That certificate is valid
  20428. for a limited period of time, and therefore to continue to provide TLS
  20429. services, the server needs to periodically ask the CA to renew its
  20430. signature.
  20431. The certbot service automates this process: the initial key
  20432. generation, the initial certification request to the Let's Encrypt
  20433. service, the web server challenge/response integration, writing the
  20434. certificate to disk, the automated periodic renewals, and the deployment
  20435. tasks associated with the renewal (e.g.@: reloading services, copying keys
  20436. with different permissions).
  20437. Certbot is run twice a day, at a random minute within the hour. It
  20438. won't do anything until your certificates are due for renewal or
  20439. revoked, but running it regularly would give your service a chance of
  20440. staying online in case a Let's Encrypt-initiated revocation happened for
  20441. some reason.
  20442. By using this service, you agree to the ACME Subscriber Agreement, which
  20443. can be found there:
  20444. @url{https://acme-v01.api.letsencrypt.org/directory}.
  20445. @defvr {Scheme Variable} certbot-service-type
  20446. A service type for the @code{certbot} Let's Encrypt client. Its value
  20447. must be a @code{certbot-configuration} record as in this example:
  20448. @lisp
  20449. (define %nginx-deploy-hook
  20450. (program-file
  20451. "nginx-deploy-hook"
  20452. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  20453. (kill pid SIGHUP))))
  20454. (service certbot-service-type
  20455. (certbot-configuration
  20456. (email "foo@@example.net")
  20457. (certificates
  20458. (list
  20459. (certificate-configuration
  20460. (domains '("example.net" "www.example.net"))
  20461. (deploy-hook %nginx-deploy-hook))
  20462. (certificate-configuration
  20463. (domains '("bar.example.net")))))))
  20464. @end lisp
  20465. See below for details about @code{certbot-configuration}.
  20466. @end defvr
  20467. @deftp {Data Type} certbot-configuration
  20468. Data type representing the configuration of the @code{certbot} service.
  20469. This type has the following parameters:
  20470. @table @asis
  20471. @item @code{package} (default: @code{certbot})
  20472. The certbot package to use.
  20473. @item @code{webroot} (default: @code{/var/www})
  20474. The directory from which to serve the Let's Encrypt challenge/response
  20475. files.
  20476. @item @code{certificates} (default: @code{()})
  20477. A list of @code{certificates-configuration}s for which to generate
  20478. certificates and request signatures. Each certificate has a @code{name}
  20479. and several @code{domains}.
  20480. @item @code{email} (default: @code{#f})
  20481. Optional email address used for registration and recovery contact.
  20482. Setting this is encouraged as it allows you to receive important
  20483. notifications about the account and issued certificates.
  20484. @item @code{server} (default: @code{#f})
  20485. Optional URL of ACME server. Setting this overrides certbot's default,
  20486. which is the Let's Encrypt server.
  20487. @item @code{rsa-key-size} (default: @code{2048})
  20488. Size of the RSA key.
  20489. @item @code{default-location} (default: @i{see below})
  20490. The default @code{nginx-location-configuration}. Because @code{certbot}
  20491. needs to be able to serve challenges and responses, it needs to be able
  20492. to run a web server. It does so by extending the @code{nginx} web
  20493. service with an @code{nginx-server-configuration} listening on the
  20494. @var{domains} on port 80, and which has a
  20495. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  20496. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  20497. these nginx configuration data types.
  20498. Requests to other URL paths will be matched by the
  20499. @code{default-location}, which if present is added to all
  20500. @code{nginx-server-configuration}s.
  20501. By default, the @code{default-location} will issue a redirect from
  20502. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  20503. you to define what to serve on your site via @code{https}.
  20504. Pass @code{#f} to not issue a default location.
  20505. @end table
  20506. @end deftp
  20507. @deftp {Data Type} certificate-configuration
  20508. Data type representing the configuration of a certificate.
  20509. This type has the following parameters:
  20510. @table @asis
  20511. @item @code{name} (default: @i{see below})
  20512. This name is used by Certbot for housekeeping and in file paths; it
  20513. doesn't affect the content of the certificate itself. To see
  20514. certificate names, run @code{certbot certificates}.
  20515. Its default is the first provided domain.
  20516. @item @code{domains} (default: @code{()})
  20517. The first domain provided will be the subject CN of the certificate, and
  20518. all domains will be Subject Alternative Names on the certificate.
  20519. @item @code{challenge} (default: @code{#f})
  20520. The challenge type that has to be run by certbot. If @code{#f} is specified,
  20521. default to the HTTP challenge. If a value is specified, defaults to the
  20522. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  20523. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  20524. and gives Let's Encrypt permission to log the public IP address of the
  20525. requesting machine.
  20526. @item @code{authentication-hook} (default: @code{#f})
  20527. Command to be run in a shell once for each certificate challenge to be
  20528. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  20529. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  20530. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  20531. file name of the resource requested when performing an HTTP-01 challenge.
  20532. @item @code{cleanup-hook} (default: @code{#f})
  20533. Command to be run in a shell once for each certificate challenge that
  20534. have been answered by the @code{auth-hook}. For this command, the shell
  20535. variables available in the @code{auth-hook} script are still available, and
  20536. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  20537. of the @code{auth-hook} script.
  20538. @item @code{deploy-hook} (default: @code{#f})
  20539. Command to be run in a shell once for each successfully issued
  20540. certificate. For this command, the shell variable
  20541. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  20542. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  20543. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  20544. contain a space-delimited list of renewed certificate domains (for
  20545. example, @samp{"example.com www.example.com"}.
  20546. @end table
  20547. @end deftp
  20548. For each @code{certificate-configuration}, the certificate is saved to
  20549. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  20550. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  20551. @node DNS Services
  20552. @subsection DNS Services
  20553. @cindex DNS (domain name system)
  20554. @cindex domain name system (DNS)
  20555. The @code{(gnu services dns)} module provides services related to the
  20556. @dfn{domain name system} (DNS). It provides a server service for hosting
  20557. an @emph{authoritative} DNS server for multiple zones, slave or master.
  20558. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  20559. caching and forwarding DNS server for the LAN, which uses
  20560. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  20561. @subsubheading Knot Service
  20562. An example configuration of an authoritative server for two zones, one master
  20563. and one slave, is:
  20564. @lisp
  20565. (define-zone-entries example.org.zone
  20566. ;; Name TTL Class Type Data
  20567. ("@@" "" "IN" "A" "127.0.0.1")
  20568. ("@@" "" "IN" "NS" "ns")
  20569. ("ns" "" "IN" "A" "127.0.0.1"))
  20570. (define master-zone
  20571. (knot-zone-configuration
  20572. (domain "example.org")
  20573. (zone (zone-file
  20574. (origin "example.org")
  20575. (entries example.org.zone)))))
  20576. (define slave-zone
  20577. (knot-zone-configuration
  20578. (domain "plop.org")
  20579. (dnssec-policy "default")
  20580. (master (list "plop-master"))))
  20581. (define plop-master
  20582. (knot-remote-configuration
  20583. (id "plop-master")
  20584. (address (list "208.76.58.171"))))
  20585. (operating-system
  20586. ;; ...
  20587. (services (cons* (service knot-service-type
  20588. (knot-configuration
  20589. (remotes (list plop-master))
  20590. (zones (list master-zone slave-zone))))
  20591. ;; ...
  20592. %base-services)))
  20593. @end lisp
  20594. @deffn {Scheme Variable} knot-service-type
  20595. This is the type for the Knot DNS server.
  20596. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  20597. zones, that is to say domain names you would buy from a registrar. This server
  20598. is not a resolver, meaning that it can only resolve names for which it is
  20599. authoritative. This server can be configured to serve zones as a master server
  20600. or a slave server as a per-zone basis. Slave zones will get their data from
  20601. masters, and will serve it as an authoritative server. From the point of view
  20602. of a resolver, there is no difference between master and slave.
  20603. The following data types are used to configure the Knot DNS server:
  20604. @end deffn
  20605. @deftp {Data Type} knot-key-configuration
  20606. Data type representing a key.
  20607. This type has the following parameters:
  20608. @table @asis
  20609. @item @code{id} (default: @code{""})
  20610. An identifier for other configuration fields to refer to this key. IDs must
  20611. be unique and must not be empty.
  20612. @item @code{algorithm} (default: @code{#f})
  20613. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  20614. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  20615. and @code{'hmac-sha512}.
  20616. @item @code{secret} (default: @code{""})
  20617. The secret key itself.
  20618. @end table
  20619. @end deftp
  20620. @deftp {Data Type} knot-acl-configuration
  20621. Data type representing an Access Control List (ACL) configuration.
  20622. This type has the following parameters:
  20623. @table @asis
  20624. @item @code{id} (default: @code{""})
  20625. An identifier for other configuration fields to refer to this key. IDs must be
  20626. unique and must not be empty.
  20627. @item @code{address} (default: @code{'()})
  20628. An ordered list of IP addresses, network subnets, or network ranges represented
  20629. with strings. The query must match one of them. Empty value means that
  20630. address match is not required.
  20631. @item @code{key} (default: @code{'()})
  20632. An ordered list of references to keys represented with strings. The string
  20633. must match a key ID defined in a @code{knot-key-configuration}. No key means
  20634. that a key is not require to match that ACL.
  20635. @item @code{action} (default: @code{'()})
  20636. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  20637. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  20638. and @code{'update}.
  20639. @item @code{deny?} (default: @code{#f})
  20640. When true, the ACL defines restrictions. Listed actions are forbidden. When
  20641. false, listed actions are allowed.
  20642. @end table
  20643. @end deftp
  20644. @deftp {Data Type} zone-entry
  20645. Data type representing a record entry in a zone file.
  20646. This type has the following parameters:
  20647. @table @asis
  20648. @item @code{name} (default: @code{"@@"})
  20649. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  20650. are relative to the origin of the zone. For example, in the @code{example.org}
  20651. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  20652. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  20653. refers to @code{ns.example.org}.
  20654. @item @code{ttl} (default: @code{""})
  20655. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  20656. @item @code{class} (default: @code{"IN"})
  20657. The class of the record. Knot currently supports only @code{"IN"} and
  20658. partially @code{"CH"}.
  20659. @item @code{type} (default: @code{"A"})
  20660. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  20661. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  20662. defined.
  20663. @item @code{data} (default: @code{""})
  20664. The data contained in the record. For instance an IP address associated with
  20665. an A record, or a domain name associated with an NS record. Remember that
  20666. domain names are relative to the origin unless they end with a dot.
  20667. @end table
  20668. @end deftp
  20669. @deftp {Data Type} zone-file
  20670. Data type representing the content of a zone file.
  20671. This type has the following parameters:
  20672. @table @asis
  20673. @item @code{entries} (default: @code{'()})
  20674. The list of entries. The SOA record is taken care of, so you don't need to
  20675. put it in the list of entries. This list should probably contain an entry
  20676. for your primary authoritative DNS server. Other than using a list of entries
  20677. directly, you can use @code{define-zone-entries} to define a object containing
  20678. the list of entries more easily, that you can later pass to the @code{entries}
  20679. field of the @code{zone-file}.
  20680. @item @code{origin} (default: @code{""})
  20681. The name of your zone. This parameter cannot be empty.
  20682. @item @code{ns} (default: @code{"ns"})
  20683. The domain of your primary authoritative DNS server. The name is relative to
  20684. the origin, unless it ends with a dot. It is mandatory that this primary
  20685. DNS server corresponds to an NS record in the zone and that it is associated
  20686. to an IP address in the list of entries.
  20687. @item @code{mail} (default: @code{"hostmaster"})
  20688. An email address people can contact you at, as the owner of the zone. This
  20689. is translated as @code{<mail>@@<origin>}.
  20690. @item @code{serial} (default: @code{1})
  20691. The serial number of the zone. As this is used to keep track of changes by
  20692. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  20693. Always increment it when you make a change in your zone.
  20694. @item @code{refresh} (default: @code{(* 2 24 3600)})
  20695. The frequency at which slaves will do a zone transfer. This value is a number
  20696. of seconds. It can be computed by multiplications or with
  20697. @code{(string->duration)}.
  20698. @item @code{retry} (default: @code{(* 15 60)})
  20699. The period after which a slave will retry to contact its master when it fails
  20700. to do so a first time.
  20701. @item @code{expiry} (default: @code{(* 14 24 3600)})
  20702. Default TTL of records. Existing records are considered correct for at most
  20703. this amount of time. After this period, resolvers will invalidate their cache
  20704. and check again that it still exists.
  20705. @item @code{nx} (default: @code{3600})
  20706. Default TTL of inexistent records. This delay is usually short because you want
  20707. your new domains to reach everyone quickly.
  20708. @end table
  20709. @end deftp
  20710. @deftp {Data Type} knot-remote-configuration
  20711. Data type representing a remote configuration.
  20712. This type has the following parameters:
  20713. @table @asis
  20714. @item @code{id} (default: @code{""})
  20715. An identifier for other configuration fields to refer to this remote. IDs must
  20716. be unique and must not be empty.
  20717. @item @code{address} (default: @code{'()})
  20718. An ordered list of destination IP addresses. Addresses are tried in sequence.
  20719. An optional port can be given with the @@ separator. For instance:
  20720. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  20721. @item @code{via} (default: @code{'()})
  20722. An ordered list of source IP addresses. An empty list will have Knot choose
  20723. an appropriate source IP@. An optional port can be given with the @@ separator.
  20724. The default is to choose at random.
  20725. @item @code{key} (default: @code{#f})
  20726. A reference to a key, that is a string containing the identifier of a key
  20727. defined in a @code{knot-key-configuration} field.
  20728. @end table
  20729. @end deftp
  20730. @deftp {Data Type} knot-keystore-configuration
  20731. Data type representing a keystore to hold dnssec keys.
  20732. This type has the following parameters:
  20733. @table @asis
  20734. @item @code{id} (default: @code{""})
  20735. The id of the keystore. It must not be empty.
  20736. @item @code{backend} (default: @code{'pem})
  20737. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  20738. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  20739. The configuration string of the backend. An example for the PKCS#11 is:
  20740. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  20741. For the pem backend, the string represents a path in the file system.
  20742. @end table
  20743. @end deftp
  20744. @deftp {Data Type} knot-policy-configuration
  20745. Data type representing a dnssec policy. Knot DNS is able to automatically
  20746. sign your zones. It can either generate and manage your keys automatically or
  20747. use keys that you generate.
  20748. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  20749. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  20750. zone. In order to be trusted, the KSK needs to be present in the parent zone
  20751. (usually a top-level domain). If your registrar supports dnssec, you will
  20752. have to send them your KSK's hash so they can add a DS record in their zone.
  20753. This is not automated and need to be done each time you change your KSK.
  20754. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  20755. easily and use weaker cryptographic functions (they use lower parameters) in
  20756. order to sign records quickly, so they are changed often. The KSK however
  20757. requires manual interaction with the registrar, so they are changed less often
  20758. and use stronger parameters because they sign only one record.
  20759. This type has the following parameters:
  20760. @table @asis
  20761. @item @code{id} (default: @code{""})
  20762. The id of the policy. It must not be empty.
  20763. @item @code{keystore} (default: @code{"default"})
  20764. A reference to a keystore, that is a string containing the identifier of a
  20765. keystore defined in a @code{knot-keystore-configuration} field. The
  20766. @code{"default"} identifier means the default keystore (a kasp database that
  20767. was setup by this service).
  20768. @item @code{manual?} (default: @code{#f})
  20769. Whether the key management is manual or automatic.
  20770. @item @code{single-type-signing?} (default: @code{#f})
  20771. When @code{#t}, use the Single-Type Signing Scheme.
  20772. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  20773. An algorithm of signing keys and issued signatures.
  20774. @item @code{ksk-size} (default: @code{256})
  20775. The length of the KSK@. Note that this value is correct for the default
  20776. algorithm, but would be unsecure for other algorithms.
  20777. @item @code{zsk-size} (default: @code{256})
  20778. The length of the ZSK@. Note that this value is correct for the default
  20779. algorithm, but would be unsecure for other algorithms.
  20780. @item @code{dnskey-ttl} (default: @code{'default})
  20781. The TTL value for DNSKEY records added into zone apex. The special
  20782. @code{'default} value means same as the zone SOA TTL.
  20783. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  20784. The period between ZSK publication and the next rollover initiation.
  20785. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  20786. An extra delay added for each key rollover step. This value should be high
  20787. enough to cover propagation of data from the master server to all slaves.
  20788. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  20789. A validity period of newly issued signatures.
  20790. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  20791. A period how long before a signature expiration the signature will be refreshed.
  20792. @item @code{nsec3?} (default: @code{#f})
  20793. When @code{#t}, NSEC3 will be used instead of NSEC.
  20794. @item @code{nsec3-iterations} (default: @code{5})
  20795. The number of additional times the hashing is performed.
  20796. @item @code{nsec3-salt-length} (default: @code{8})
  20797. The length of a salt field in octets, which is appended to the original owner
  20798. name before hashing.
  20799. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  20800. The validity period of newly issued salt field.
  20801. @end table
  20802. @end deftp
  20803. @deftp {Data Type} knot-zone-configuration
  20804. Data type representing a zone served by Knot.
  20805. This type has the following parameters:
  20806. @table @asis
  20807. @item @code{domain} (default: @code{""})
  20808. The domain served by this configuration. It must not be empty.
  20809. @item @code{file} (default: @code{""})
  20810. The file where this zone is saved. This parameter is ignored by master zones.
  20811. Empty means default location that depends on the domain name.
  20812. @item @code{zone} (default: @code{(zone-file)})
  20813. The content of the zone file. This parameter is ignored by slave zones. It
  20814. must contain a zone-file record.
  20815. @item @code{master} (default: @code{'()})
  20816. A list of master remotes. When empty, this zone is a master. When set, this
  20817. zone is a slave. This is a list of remotes identifiers.
  20818. @item @code{ddns-master} (default: @code{#f})
  20819. The main master. When empty, it defaults to the first master in the list of
  20820. masters.
  20821. @item @code{notify} (default: @code{'()})
  20822. A list of slave remote identifiers.
  20823. @item @code{acl} (default: @code{'()})
  20824. A list of acl identifiers.
  20825. @item @code{semantic-checks?} (default: @code{#f})
  20826. When set, this adds more semantic checks to the zone.
  20827. @item @code{disable-any?} (default: @code{#f})
  20828. When set, this forbids queries of the ANY type.
  20829. @item @code{zonefile-sync} (default: @code{0})
  20830. The delay between a modification in memory and on disk. 0 means immediate
  20831. synchronization.
  20832. @item @code{zonefile-load} (default: @code{#f})
  20833. The way the zone file contents are applied during zone load. Possible values
  20834. are:
  20835. @itemize
  20836. @item @code{#f} for using the default value from Knot,
  20837. @item @code{'none} for not using the zone file at all,
  20838. @item @code{'difference} for computing the difference between already available
  20839. contents and zone contents and applying it to the current zone contents,
  20840. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  20841. ignoring the SOA serial in the zone file, while the server takes care of it
  20842. automatically.
  20843. @item @code{'whole} for loading zone contents from the zone file.
  20844. @end itemize
  20845. @item @code{journal-content} (default: @code{#f})
  20846. The way the journal is used to store zone and its changes. Possible values
  20847. are @code{'none} to not use it at all, @code{'changes} to store changes and
  20848. @code{'all} to store contents. @code{#f} does not set this option, so the
  20849. default value from Knot is used.
  20850. @item @code{max-journal-usage} (default: @code{#f})
  20851. The maximum size for the journal on disk. @code{#f} does not set this option,
  20852. so the default value from Knot is used.
  20853. @item @code{max-journal-depth} (default: @code{#f})
  20854. The maximum size of the history. @code{#f} does not set this option, so the
  20855. default value from Knot is used.
  20856. @item @code{max-zone-size} (default: @code{#f})
  20857. The maximum size of the zone file. This limit is enforced for incoming
  20858. transfer and updates. @code{#f} does not set this option, so the default
  20859. value from Knot is used.
  20860. @item @code{dnssec-policy} (default: @code{#f})
  20861. A reference to a @code{knot-policy-configuration} record, or the special
  20862. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  20863. on this zone.
  20864. @item @code{serial-policy} (default: @code{'increment})
  20865. A policy between @code{'increment} and @code{'unixtime}.
  20866. @end table
  20867. @end deftp
  20868. @deftp {Data Type} knot-configuration
  20869. Data type representing the Knot configuration.
  20870. This type has the following parameters:
  20871. @table @asis
  20872. @item @code{knot} (default: @code{knot})
  20873. The Knot package.
  20874. @item @code{run-directory} (default: @code{"/var/run/knot"})
  20875. The run directory. This directory will be used for pid file and sockets.
  20876. @item @code{includes} (default: @code{'()})
  20877. A list of strings or file-like objects denoting other files that must be
  20878. included at the top of the configuration file.
  20879. @cindex secrets, Knot service
  20880. This can be used to manage secrets out-of-band. For example, secret
  20881. keys may be stored in an out-of-band file not managed by Guix, and
  20882. thus not visible in @file{/gnu/store}---e.g., you could store secret
  20883. key configuration in @file{/etc/knot/secrets.conf} and add this file
  20884. to the @code{includes} list.
  20885. One can generate a secret tsig key (for nsupdate and zone transfers with the
  20886. keymgr command from the knot package. Note that the package is not automatically
  20887. installed by the service. The following example shows how to generate a new
  20888. tsig key:
  20889. @example
  20890. keymgr -t mysecret > /etc/knot/secrets.conf
  20891. chmod 600 /etc/knot/secrets.conf
  20892. @end example
  20893. Also note that the generated key will be named @var{mysecret}, so it is the
  20894. name that needs to be used in the @var{key} field of the
  20895. @code{knot-acl-configuration} record and in other places that need to refer
  20896. to that key.
  20897. It can also be used to add configuration not supported by this interface.
  20898. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  20899. An ip address on which to listen.
  20900. @item @code{listen-v6} (default: @code{"::"})
  20901. An ip address on which to listen.
  20902. @item @code{listen-port} (default: @code{53})
  20903. A port on which to listen.
  20904. @item @code{keys} (default: @code{'()})
  20905. The list of knot-key-configuration used by this configuration.
  20906. @item @code{acls} (default: @code{'()})
  20907. The list of knot-acl-configuration used by this configuration.
  20908. @item @code{remotes} (default: @code{'()})
  20909. The list of knot-remote-configuration used by this configuration.
  20910. @item @code{zones} (default: @code{'()})
  20911. The list of knot-zone-configuration used by this configuration.
  20912. @end table
  20913. @end deftp
  20914. @subsubheading Knot Resolver Service
  20915. @deffn {Scheme Variable} knot-resolver-service-type
  20916. This is the type of the knot resolver service, whose value should be
  20917. an @code{knot-resolver-configuration} object as in this example:
  20918. @lisp
  20919. (service knot-resolver-service-type
  20920. (knot-resolver-configuration
  20921. (kresd-config-file (plain-file "kresd.conf" "
  20922. net.listen('192.168.0.1', 5353)
  20923. user('knot-resolver', 'knot-resolver')
  20924. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  20925. cache.size = 100 * MB
  20926. "))))
  20927. @end lisp
  20928. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  20929. @end deffn
  20930. @deftp {Data Type} knot-resolver-configuration
  20931. Data type representing the configuration of knot-resolver.
  20932. @table @asis
  20933. @item @code{package} (default: @var{knot-resolver})
  20934. Package object of the knot DNS resolver.
  20935. @item @code{kresd-config-file} (default: %kresd.conf)
  20936. File-like object of the kresd configuration file to use, by default it
  20937. will listen on @code{127.0.0.1} and @code{::1}.
  20938. @item @code{garbage-collection-interval} (default: 1000)
  20939. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  20940. @end table
  20941. @end deftp
  20942. @subsubheading Dnsmasq Service
  20943. @deffn {Scheme Variable} dnsmasq-service-type
  20944. This is the type of the dnsmasq service, whose value should be an
  20945. @code{dnsmasq-configuration} object as in this example:
  20946. @lisp
  20947. (service dnsmasq-service-type
  20948. (dnsmasq-configuration
  20949. (no-resolv? #t)
  20950. (servers '("192.168.1.1"))))
  20951. @end lisp
  20952. @end deffn
  20953. @deftp {Data Type} dnsmasq-configuration
  20954. Data type representing the configuration of dnsmasq.
  20955. @table @asis
  20956. @item @code{package} (default: @var{dnsmasq})
  20957. Package object of the dnsmasq server.
  20958. @item @code{no-hosts?} (default: @code{#f})
  20959. When true, don't read the hostnames in /etc/hosts.
  20960. @item @code{port} (default: @code{53})
  20961. The port to listen on. Setting this to zero completely disables DNS
  20962. responses, leaving only DHCP and/or TFTP functions.
  20963. @item @code{local-service?} (default: @code{#t})
  20964. Accept DNS queries only from hosts whose address is on a local subnet,
  20965. ie a subnet for which an interface exists on the server.
  20966. @item @code{listen-addresses} (default: @code{'()})
  20967. Listen on the given IP addresses.
  20968. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  20969. The file to read the IP address of the upstream nameservers from.
  20970. @item @code{no-resolv?} (default: @code{#f})
  20971. When true, don't read @var{resolv-file}.
  20972. @item @code{servers} (default: @code{'()})
  20973. Specify IP address of upstream servers directly.
  20974. @item @code{addresses} (default: @code{'()})
  20975. For each entry, specify an IP address to return for any host in the
  20976. given domains. Queries in the domains are never forwarded and always
  20977. replied to with the specified IP address.
  20978. This is useful for redirecting hosts locally, for example:
  20979. @lisp
  20980. (service dnsmasq-service-type
  20981. (dnsmasq-configuration
  20982. (addresses
  20983. '(; Redirect to a local web-server.
  20984. "/example.org/127.0.0.1"
  20985. ; Redirect subdomain to a specific IP.
  20986. "/subdomain.example.org/192.168.1.42"))))
  20987. @end lisp
  20988. Note that rules in @file{/etc/hosts} take precedence over this.
  20989. @item @code{cache-size} (default: @code{150})
  20990. Set the size of dnsmasq's cache. Setting the cache size to zero
  20991. disables caching.
  20992. @item @code{negative-cache?} (default: @code{#t})
  20993. When false, disable negative caching.
  20994. @item @code{tftp-enable?} (default: @code{#f})
  20995. Whether to enable the built-in TFTP server.
  20996. @item @code{tftp-no-fail?} (default: @code{#f})
  20997. If true, does not fail dnsmasq if the TFTP server could not start up.
  20998. @item @code{tftp-single-port?} (default: @code{#f})
  20999. Whether to use only one single port for TFTP.
  21000. @item @code{tftp-secure?} (default: @code{#f})
  21001. If true, only files owned by the user running the dnsmasq process are accessible.
  21002. If dnsmasq is being run as root, different rules apply:
  21003. @code{tftp-secure?} has no effect, but only files which have the
  21004. world-readable bit set are accessible.
  21005. @item @code{tftp-max} (default: @code{#f})
  21006. If set, sets the maximal number of concurrent connections allowed.
  21007. @item @code{tftp-mtu} (default: @code{#f})
  21008. If set, sets the MTU for TFTP packets to that value.
  21009. @item @code{tftp-no-blocksize?} (default: @code{#f})
  21010. If true, stops the TFTP server from negotiating the blocksize with a client.
  21011. @item @code{tftp-lowercase?} (default: @code{#f})
  21012. Whether to convert all filenames in TFTP requests to lowercase.
  21013. @item @code{tftp-port-range} (default: @code{#f})
  21014. If set, fixes the dynamical ports (one per client) to the given range
  21015. (@code{"<start>,<end>"}).
  21016. @item @code{tftp-root} (default: @code{/var/empty,lo})
  21017. Look for files to transfer using TFTP relative to the given directory.
  21018. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  21019. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  21020. allowed, but they must be within the TFTP-root. If the optional interface
  21021. argument is given, the directory is only used for TFTP requests via that
  21022. interface.
  21023. @item @code{tftp-unique-root} (default: @code{#f})
  21024. If set, add the IP or hardware address of the TFTP client as a path component
  21025. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  21026. directory exists. Defaults to adding IP address (in standard dotted-quad
  21027. format).
  21028. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  21029. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  21030. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  21031. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  21032. append the MAC address instead, using lowercase zero padded digits
  21033. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  21034. resolving MAC addresses is only possible if the client is in the local
  21035. network or obtained a DHCP lease from dnsmasq.
  21036. @end table
  21037. @end deftp
  21038. @subsubheading ddclient Service
  21039. @cindex ddclient
  21040. The ddclient service described below runs the ddclient daemon, which takes
  21041. care of automatically updating DNS entries for service providers such as
  21042. @uref{https://dyn.com/dns/, Dyn}.
  21043. The following example show instantiates the service with its default
  21044. configuration:
  21045. @lisp
  21046. (service ddclient-service-type)
  21047. @end lisp
  21048. Note that ddclient needs to access credentials that are stored in a
  21049. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  21050. @code{secret-file} below). You are expected to create this file manually, in
  21051. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  21052. service configuration, for instance by using @code{plain-file}, but it will be
  21053. world-readable @i{via} @file{/gnu/store}). See the examples in the
  21054. @file{share/ddclient} directory of the @code{ddclient} package.
  21055. @c %start of fragment
  21056. Available @code{ddclient-configuration} fields are:
  21057. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  21058. The ddclient package.
  21059. @end deftypevr
  21060. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  21061. The period after which ddclient will retry to check IP and domain name.
  21062. Defaults to @samp{300}.
  21063. @end deftypevr
  21064. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  21065. Use syslog for the output.
  21066. Defaults to @samp{#t}.
  21067. @end deftypevr
  21068. @deftypevr {@code{ddclient-configuration} parameter} string mail
  21069. Mail to user.
  21070. Defaults to @samp{"root"}.
  21071. @end deftypevr
  21072. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  21073. Mail failed update to user.
  21074. Defaults to @samp{"root"}.
  21075. @end deftypevr
  21076. @deftypevr {@code{ddclient-configuration} parameter} string pid
  21077. The ddclient PID file.
  21078. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  21079. @end deftypevr
  21080. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  21081. Enable SSL support.
  21082. Defaults to @samp{#t}.
  21083. @end deftypevr
  21084. @deftypevr {@code{ddclient-configuration} parameter} string user
  21085. Specifies the user name or ID that is used when running ddclient
  21086. program.
  21087. Defaults to @samp{"ddclient"}.
  21088. @end deftypevr
  21089. @deftypevr {@code{ddclient-configuration} parameter} string group
  21090. Group of the user who will run the ddclient program.
  21091. Defaults to @samp{"ddclient"}.
  21092. @end deftypevr
  21093. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  21094. Secret file which will be appended to @file{ddclient.conf} file. This
  21095. file contains credentials for use by ddclient. You are expected to
  21096. create it manually.
  21097. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  21098. @end deftypevr
  21099. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  21100. Extra options will be appended to @file{ddclient.conf} file.
  21101. Defaults to @samp{()}.
  21102. @end deftypevr
  21103. @c %end of fragment
  21104. @node VPN Services
  21105. @subsection VPN Services
  21106. @cindex VPN (virtual private network)
  21107. @cindex virtual private network (VPN)
  21108. The @code{(gnu services vpn)} module provides services related to
  21109. @dfn{virtual private networks} (VPNs).
  21110. @subsubheading OpenVPN
  21111. It provides a @emph{client} service for your machine to connect to a
  21112. VPN, and a @emph{server} service for your machine to host a VPN@.
  21113. @deffn {Scheme Procedure} openvpn-client-service @
  21114. [#:config (openvpn-client-configuration)]
  21115. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  21116. @end deffn
  21117. @deffn {Scheme Procedure} openvpn-server-service @
  21118. [#:config (openvpn-server-configuration)]
  21119. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  21120. Both can be run simultaneously.
  21121. @end deffn
  21122. @c %automatically generated documentation
  21123. Available @code{openvpn-client-configuration} fields are:
  21124. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  21125. The OpenVPN package.
  21126. @end deftypevr
  21127. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  21128. The OpenVPN pid file.
  21129. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  21130. @end deftypevr
  21131. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  21132. The protocol (UDP or TCP) used to open a channel between clients and
  21133. servers.
  21134. Defaults to @samp{udp}.
  21135. @end deftypevr
  21136. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  21137. The device type used to represent the VPN connection.
  21138. Defaults to @samp{tun}.
  21139. @end deftypevr
  21140. If you do not have some of these files (eg.@: you use a username and
  21141. password), you can disable any of the following three fields by setting
  21142. it to @code{'disabled}.
  21143. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  21144. The certificate authority to check connections against.
  21145. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  21146. @end deftypevr
  21147. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  21148. The certificate of the machine the daemon is running on. It should be
  21149. signed by the authority given in @code{ca}.
  21150. Defaults to @samp{"/etc/openvpn/client.crt"}.
  21151. @end deftypevr
  21152. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  21153. The key of the machine the daemon is running on. It must be the key whose
  21154. certificate is @code{cert}.
  21155. Defaults to @samp{"/etc/openvpn/client.key"}.
  21156. @end deftypevr
  21157. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  21158. Whether to use the lzo compression algorithm.
  21159. Defaults to @samp{#t}.
  21160. @end deftypevr
  21161. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  21162. Don't re-read key files across SIGUSR1 or --ping-restart.
  21163. Defaults to @samp{#t}.
  21164. @end deftypevr
  21165. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  21166. Don't close and reopen TUN/TAP device or run up/down scripts across
  21167. SIGUSR1 or --ping-restart restarts.
  21168. Defaults to @samp{#t}.
  21169. @end deftypevr
  21170. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  21171. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21172. poll/epoll/select prior to the write operation.
  21173. Defaults to @samp{#f}.
  21174. @end deftypevr
  21175. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  21176. Verbosity level.
  21177. Defaults to @samp{3}.
  21178. @end deftypevr
  21179. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  21180. Add an additional layer of HMAC authentication on top of the TLS control
  21181. channel to protect against DoS attacks.
  21182. Defaults to @samp{#f}.
  21183. @end deftypevr
  21184. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  21185. Authenticate with server using username/password. The option is a file
  21186. containing username/password on 2 lines. Do not use a file-like object as it
  21187. would be added to the store and readable by any user.
  21188. Defaults to @samp{'disabled}.
  21189. @end deftypevr
  21190. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  21191. Whether to check the server certificate has server usage extension.
  21192. Defaults to @samp{#t}.
  21193. @end deftypevr
  21194. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  21195. Bind to a specific local port number.
  21196. Defaults to @samp{#f}.
  21197. @end deftypevr
  21198. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  21199. Retry resolving server address.
  21200. Defaults to @samp{#t}.
  21201. @end deftypevr
  21202. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  21203. A list of remote servers to connect to.
  21204. Defaults to @samp{()}.
  21205. Available @code{openvpn-remote-configuration} fields are:
  21206. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  21207. Server name.
  21208. Defaults to @samp{"my-server"}.
  21209. @end deftypevr
  21210. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  21211. Port number the server listens to.
  21212. Defaults to @samp{1194}.
  21213. @end deftypevr
  21214. @end deftypevr
  21215. @c %end of automatic openvpn-client documentation
  21216. @c %automatically generated documentation
  21217. Available @code{openvpn-server-configuration} fields are:
  21218. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  21219. The OpenVPN package.
  21220. @end deftypevr
  21221. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  21222. The OpenVPN pid file.
  21223. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  21224. @end deftypevr
  21225. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  21226. The protocol (UDP or TCP) used to open a channel between clients and
  21227. servers.
  21228. Defaults to @samp{udp}.
  21229. @end deftypevr
  21230. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  21231. The device type used to represent the VPN connection.
  21232. Defaults to @samp{tun}.
  21233. @end deftypevr
  21234. If you do not have some of these files (eg.@: you use a username and
  21235. password), you can disable any of the following three fields by setting
  21236. it to @code{'disabled}.
  21237. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  21238. The certificate authority to check connections against.
  21239. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  21240. @end deftypevr
  21241. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  21242. The certificate of the machine the daemon is running on. It should be
  21243. signed by the authority given in @code{ca}.
  21244. Defaults to @samp{"/etc/openvpn/client.crt"}.
  21245. @end deftypevr
  21246. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  21247. The key of the machine the daemon is running on. It must be the key whose
  21248. certificate is @code{cert}.
  21249. Defaults to @samp{"/etc/openvpn/client.key"}.
  21250. @end deftypevr
  21251. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  21252. Whether to use the lzo compression algorithm.
  21253. Defaults to @samp{#t}.
  21254. @end deftypevr
  21255. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  21256. Don't re-read key files across SIGUSR1 or --ping-restart.
  21257. Defaults to @samp{#t}.
  21258. @end deftypevr
  21259. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  21260. Don't close and reopen TUN/TAP device or run up/down scripts across
  21261. SIGUSR1 or --ping-restart restarts.
  21262. Defaults to @samp{#t}.
  21263. @end deftypevr
  21264. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  21265. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21266. poll/epoll/select prior to the write operation.
  21267. Defaults to @samp{#f}.
  21268. @end deftypevr
  21269. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  21270. Verbosity level.
  21271. Defaults to @samp{3}.
  21272. @end deftypevr
  21273. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  21274. Add an additional layer of HMAC authentication on top of the TLS control
  21275. channel to protect against DoS attacks.
  21276. Defaults to @samp{#f}.
  21277. @end deftypevr
  21278. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  21279. Specifies the port number on which the server listens.
  21280. Defaults to @samp{1194}.
  21281. @end deftypevr
  21282. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  21283. An ip and mask specifying the subnet inside the virtual network.
  21284. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  21285. @end deftypevr
  21286. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  21287. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  21288. Defaults to @samp{#f}.
  21289. @end deftypevr
  21290. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  21291. The Diffie-Hellman parameters file.
  21292. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  21293. @end deftypevr
  21294. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  21295. The file that records client IPs.
  21296. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  21297. @end deftypevr
  21298. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  21299. When true, the server will act as a gateway for its clients.
  21300. Defaults to @samp{#f}.
  21301. @end deftypevr
  21302. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  21303. When true, clients are allowed to talk to each other inside the VPN.
  21304. Defaults to @samp{#f}.
  21305. @end deftypevr
  21306. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  21307. Causes ping-like messages to be sent back and forth over the link so
  21308. that each side knows when the other side has gone down. @code{keepalive}
  21309. requires a pair. The first element is the period of the ping sending,
  21310. and the second element is the timeout before considering the other side
  21311. down.
  21312. @end deftypevr
  21313. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  21314. The maximum number of clients.
  21315. Defaults to @samp{100}.
  21316. @end deftypevr
  21317. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  21318. The status file. This file shows a small report on current connection.
  21319. It is truncated and rewritten every minute.
  21320. Defaults to @samp{"/var/run/openvpn/status"}.
  21321. @end deftypevr
  21322. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  21323. The list of configuration for some clients.
  21324. Defaults to @samp{()}.
  21325. Available @code{openvpn-ccd-configuration} fields are:
  21326. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  21327. Client name.
  21328. Defaults to @samp{"client"}.
  21329. @end deftypevr
  21330. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  21331. Client own network
  21332. Defaults to @samp{#f}.
  21333. @end deftypevr
  21334. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  21335. Client VPN IP.
  21336. Defaults to @samp{#f}.
  21337. @end deftypevr
  21338. @end deftypevr
  21339. @c %end of automatic openvpn-server documentation
  21340. @subsubheading Wireguard
  21341. @defvr {Scheme Variable} wireguard-service-type
  21342. A service type for a Wireguard tunnel interface. Its value must be a
  21343. @code{wireguard-configuration} record as in this example:
  21344. @lisp
  21345. (service wireguard-service-type
  21346. (wireguard-configuration
  21347. (peers
  21348. (list
  21349. (wireguard-peer
  21350. (name "my-peer")
  21351. (endpoint "my.wireguard.com:51820")
  21352. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  21353. (allowed-ips '("10.0.0.2/32")))))))
  21354. @end lisp
  21355. @end defvr
  21356. @deftp {Data Type} wireguard-configuration
  21357. Data type representing the configuration of the Wireguard service.
  21358. @table @asis
  21359. @item @code{wireguard}
  21360. The wireguard package to use for this service.
  21361. @item @code{interface} (default: @code{"wg0"})
  21362. The interface name for the VPN.
  21363. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  21364. The IP addresses to be assigned to the above interface.
  21365. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  21366. The private key file for the interface. It is automatically generated if
  21367. the file does not exist.
  21368. @item @code{peers} (default: @code{'()})
  21369. The authorized peers on this interface. This is a list of
  21370. @var{wireguard-peer} records.
  21371. @end table
  21372. @end deftp
  21373. @deftp {Data Type} wireguard-peer
  21374. Data type representing a Wireguard peer attached to a given interface.
  21375. @table @asis
  21376. @item @code{name}
  21377. The peer name.
  21378. @item @code{endpoint} (default: @code{#f})
  21379. The optional endpoint for the peer, such as
  21380. @code{"demo.wireguard.com:51820"}.
  21381. @item @code{public-key}
  21382. The peer public-key represented as a base64 string.
  21383. @item @code{allowed-ips}
  21384. A list of IP addresses from which incoming traffic for this peer is
  21385. allowed and to which incoming traffic for this peer is directed.
  21386. @end table
  21387. @end deftp
  21388. @node Network File System
  21389. @subsection Network File System
  21390. @cindex NFS
  21391. The @code{(gnu services nfs)} module provides the following services,
  21392. which are most commonly used in relation to mounting or exporting
  21393. directory trees as @dfn{network file systems} (NFS).
  21394. While it is possible to use the individual components that together make
  21395. up a Network File System service, we recommended to configure an NFS
  21396. server with the @code{nfs-service-type}.
  21397. @subsubheading NFS Service
  21398. @cindex NFS, server
  21399. The NFS service takes care of setting up all NFS component services,
  21400. kernel configuration file systems, and installs configuration files in
  21401. the locations that NFS expects.
  21402. @defvr {Scheme Variable} nfs-service-type
  21403. A service type for a complete NFS server.
  21404. @end defvr
  21405. @deftp {Data Type} nfs-configuration
  21406. This data type represents the configuration of the NFS service and all
  21407. of its subsystems.
  21408. It has the following parameters:
  21409. @table @asis
  21410. @item @code{nfs-utils} (default: @code{nfs-utils})
  21411. The nfs-utils package to use.
  21412. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  21413. If a list of string values is provided, the @command{rpc.nfsd} daemon
  21414. will be limited to supporting the given versions of the NFS protocol.
  21415. @item @code{exports} (default: @code{'()})
  21416. This is a list of directories the NFS server should export. Each entry
  21417. is a list consisting of two elements: a directory name and a string
  21418. containing all options. This is an example in which the directory
  21419. @file{/export} is served to all NFS clients as a read-only share:
  21420. @lisp
  21421. (nfs-configuration
  21422. (exports
  21423. '(("/export"
  21424. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  21425. @end lisp
  21426. @item @code{rpcmountd-port} (default: @code{#f})
  21427. The network port that the @command{rpc.mountd} daemon should use.
  21428. @item @code{rpcstatd-port} (default: @code{#f})
  21429. The network port that the @command{rpc.statd} daemon should use.
  21430. @item @code{rpcbind} (default: @code{rpcbind})
  21431. The rpcbind package to use.
  21432. @item @code{idmap-domain} (default: @code{"localdomain"})
  21433. The local NFSv4 domain name.
  21434. @item @code{nfsd-port} (default: @code{2049})
  21435. The network port that the @command{nfsd} daemon should use.
  21436. @item @code{nfsd-threads} (default: @code{8})
  21437. The number of threads used by the @command{nfsd} daemon.
  21438. @item @code{nfsd-tcp?} (default: @code{#t})
  21439. Whether the @command{nfsd} daemon should listen on a TCP socket.
  21440. @item @code{nfsd-udp?} (default: @code{#f})
  21441. Whether the @command{nfsd} daemon should listen on a UDP socket.
  21442. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21443. The directory where the pipefs file system is mounted.
  21444. @item @code{debug} (default: @code{'()"})
  21445. A list of subsystems for which debugging output should be enabled. This
  21446. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  21447. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  21448. @end table
  21449. @end deftp
  21450. If you don't need a complete NFS service or prefer to build it yourself
  21451. you can use the individual component services that are documented below.
  21452. @subsubheading RPC Bind Service
  21453. @cindex rpcbind
  21454. The RPC Bind service provides a facility to map program numbers into
  21455. universal addresses.
  21456. Many NFS related services use this facility. Hence it is automatically
  21457. started when a dependent service starts.
  21458. @defvr {Scheme Variable} rpcbind-service-type
  21459. A service type for the RPC portmapper daemon.
  21460. @end defvr
  21461. @deftp {Data Type} rpcbind-configuration
  21462. Data type representing the configuration of the RPC Bind Service.
  21463. This type has the following parameters:
  21464. @table @asis
  21465. @item @code{rpcbind} (default: @code{rpcbind})
  21466. The rpcbind package to use.
  21467. @item @code{warm-start?} (default: @code{#t})
  21468. If this parameter is @code{#t}, then the daemon will read a
  21469. state file on startup thus reloading state information saved by a previous
  21470. instance.
  21471. @end table
  21472. @end deftp
  21473. @subsubheading Pipefs Pseudo File System
  21474. @cindex pipefs
  21475. @cindex rpc_pipefs
  21476. The pipefs file system is used to transfer NFS related data
  21477. between the kernel and user space programs.
  21478. @defvr {Scheme Variable} pipefs-service-type
  21479. A service type for the pipefs pseudo file system.
  21480. @end defvr
  21481. @deftp {Data Type} pipefs-configuration
  21482. Data type representing the configuration of the pipefs pseudo file system service.
  21483. This type has the following parameters:
  21484. @table @asis
  21485. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21486. The directory to which the file system is to be attached.
  21487. @end table
  21488. @end deftp
  21489. @subsubheading GSS Daemon Service
  21490. @cindex GSSD
  21491. @cindex GSS
  21492. @cindex global security system
  21493. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  21494. based protocols.
  21495. Before exchanging RPC requests an RPC client must establish a security
  21496. context. Typically this is done using the Kerberos command @command{kinit}
  21497. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  21498. @defvr {Scheme Variable} gss-service-type
  21499. A service type for the Global Security System (GSS) daemon.
  21500. @end defvr
  21501. @deftp {Data Type} gss-configuration
  21502. Data type representing the configuration of the GSS daemon service.
  21503. This type has the following parameters:
  21504. @table @asis
  21505. @item @code{nfs-utils} (default: @code{nfs-utils})
  21506. The package in which the @command{rpc.gssd} command is to be found.
  21507. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21508. The directory where the pipefs file system is mounted.
  21509. @end table
  21510. @end deftp
  21511. @subsubheading IDMAP Daemon Service
  21512. @cindex idmapd
  21513. @cindex name mapper
  21514. The idmap daemon service provides mapping between user IDs and user names.
  21515. Typically it is required in order to access file systems mounted via NFSv4.
  21516. @defvr {Scheme Variable} idmap-service-type
  21517. A service type for the Identity Mapper (IDMAP) daemon.
  21518. @end defvr
  21519. @deftp {Data Type} idmap-configuration
  21520. Data type representing the configuration of the IDMAP daemon service.
  21521. This type has the following parameters:
  21522. @table @asis
  21523. @item @code{nfs-utils} (default: @code{nfs-utils})
  21524. The package in which the @command{rpc.idmapd} command is to be found.
  21525. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21526. The directory where the pipefs file system is mounted.
  21527. @item @code{domain} (default: @code{#f})
  21528. The local NFSv4 domain name.
  21529. This must be a string or @code{#f}.
  21530. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  21531. @item @code{verbosity} (default: @code{0})
  21532. The verbosity level of the daemon.
  21533. @end table
  21534. @end deftp
  21535. @node Continuous Integration
  21536. @subsection Continuous Integration
  21537. @cindex continuous integration
  21538. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  21539. integration tool for Guix. It can be used both for development and for
  21540. providing substitutes to others (@pxref{Substitutes}).
  21541. The @code{(gnu services cuirass)} module provides the following service.
  21542. @defvr {Scheme Procedure} cuirass-service-type
  21543. The type of the Cuirass service. Its value must be a
  21544. @code{cuirass-configuration} object, as described below.
  21545. @end defvr
  21546. To add build jobs, you have to set the @code{specifications} field of
  21547. the configuration. For instance, the following example will build all
  21548. the packages provided by the @code{my-channel} channel.
  21549. @lisp
  21550. (define %cuirass-specs
  21551. #~(list (specification
  21552. (name "my-channel")
  21553. (build '(channels my-channel))
  21554. (channels
  21555. (cons (channel
  21556. (name 'my-channel)
  21557. (url "https://my-channel.git"))
  21558. %default-channels)))))
  21559. (service cuirass-service-type
  21560. (cuirass-configuration
  21561. (specifications %cuirass-specs)))
  21562. @end lisp
  21563. To build the @code{linux-libre} package defined by the default Guix
  21564. channel, one can use the following configuration.
  21565. @lisp
  21566. (define %cuirass-specs
  21567. #~(list (specification
  21568. (name "my-linux")
  21569. (build '(packages "linux-libre")))))
  21570. (service cuirass-service-type
  21571. (cuirass-configuration
  21572. (specifications %cuirass-specs)))
  21573. @end lisp
  21574. The other configuration possibilities, as well as the specification
  21575. record itself are described in the Cuirass manual
  21576. (@pxref{Specifications,,, cuirass, Cuirass}).
  21577. While information related to build jobs is located directly in the
  21578. specifications, global settings for the @command{cuirass} process are
  21579. accessible in other @code{cuirass-configuration} fields.
  21580. @deftp {Data Type} cuirass-configuration
  21581. Data type representing the configuration of Cuirass.
  21582. @table @asis
  21583. @item @code{cuirass} (default: @code{cuirass})
  21584. The Cuirass package to use.
  21585. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  21586. Location of the log file.
  21587. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  21588. Location of the log file used by the web interface.
  21589. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  21590. Location of the repository cache.
  21591. @item @code{user} (default: @code{"cuirass"})
  21592. Owner of the @code{cuirass} process.
  21593. @item @code{group} (default: @code{"cuirass"})
  21594. Owner's group of the @code{cuirass} process.
  21595. @item @code{interval} (default: @code{60})
  21596. Number of seconds between the poll of the repositories followed by the
  21597. Cuirass jobs.
  21598. @item @code{parameters} (default: @code{#f})
  21599. Read parameters from the given @var{parameters} file. The supported
  21600. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  21601. @item @code{remote-server} (default: @code{#f})
  21602. A @code{cuirass-remote-server-configuration} record to use the build
  21603. remote mechanism or @code{#f} to use the default build mechanism.
  21604. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  21605. Use @var{database} as the database containing the jobs and the past
  21606. build results. Since Cuirass uses PostgreSQL as a database engine,
  21607. @var{database} must be a string such as @code{"dbname=cuirass
  21608. host=localhost"}.
  21609. @item @code{port} (default: @code{8081})
  21610. Port number used by the HTTP server.
  21611. @item @code{host} (default: @code{"localhost"})
  21612. Listen on the network interface for @var{host}. The default is to
  21613. accept connections from localhost.
  21614. @item @code{specifications} (default: @code{#~'()})
  21615. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  21616. specifications records. The specification record is described in the
  21617. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  21618. @item @code{use-substitutes?} (default: @code{#f})
  21619. This allows using substitutes to avoid building every dependencies of a job
  21620. from source.
  21621. @item @code{one-shot?} (default: @code{#f})
  21622. Only evaluate specifications and build derivations once.
  21623. @item @code{fallback?} (default: @code{#f})
  21624. When substituting a pre-built binary fails, fall back to building
  21625. packages locally.
  21626. @item @code{extra-options} (default: @code{'()})
  21627. Extra options to pass when running the Cuirass processes.
  21628. @end table
  21629. @end deftp
  21630. @cindex remote build
  21631. @subsubheading Cuirass remote building
  21632. Cuirass supports two mechanisms to build derivations.
  21633. @itemize
  21634. @item Using the local Guix daemon.
  21635. This is the default build mechanism. Once the build jobs are
  21636. evaluated, they are sent to the local Guix daemon. Cuirass then
  21637. listens to the Guix daemon output to detect the various build events.
  21638. @item Using the remote build mechanism.
  21639. The build jobs are not submitted to the local Guix daemon. Instead, a
  21640. remote server dispatches build requests to the connect remote workers,
  21641. according to the build priorities.
  21642. @end itemize
  21643. To enable this build mode a @code{cuirass-remote-server-configuration}
  21644. record must be passed as @code{remote-server} argument of the
  21645. @code{cuirass-configuration} record. The
  21646. @code{cuirass-remote-server-configuration} record is described below.
  21647. This build mode scales way better than the default build mode. This is
  21648. the build mode that is used on the GNU Guix build farm at
  21649. @url{https://ci.guix.gnu.org}. It should be preferred when using
  21650. Cuirass to build large amount of packages.
  21651. @deftp {Data Type} cuirass-remote-server-configuration
  21652. Data type representing the configuration of the Cuirass remote-server.
  21653. @table @asis
  21654. @item @code{backend-port} (default: @code{5555})
  21655. The TCP port for communicating with @code{remote-worker} processes
  21656. using ZMQ. It defaults to @code{5555}.
  21657. @item @code{log-port} (default: @code{5556})
  21658. The TCP port of the log server. It defaults to @code{5556}.
  21659. @item @code{publish-port} (default: @code{5557})
  21660. The TCP port of the publish server. It defaults to @code{5557}.
  21661. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  21662. Location of the log file.
  21663. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  21664. Use @var{cache} directory to cache build log files.
  21665. @item @code{trigger-url} (default: @code{#f})
  21666. Once a substitute is successfully fetched, trigger substitute baking at
  21667. @var{trigger-url}.
  21668. @item @code{public-key}
  21669. @item @code{private-key}
  21670. Use the specific @var{file}s as the public/private key pair used to sign
  21671. the store items being published.
  21672. @end table
  21673. @end deftp
  21674. At least one remote worker must also be started on any machine of the
  21675. local network to actually perform the builds and report their status.
  21676. @deftp {Data Type} cuirass-remote-worker-configuration
  21677. Data type representing the configuration of the Cuirass remote-worker.
  21678. @table @asis
  21679. @item @code{cuirass} (default: @code{cuirass})
  21680. The Cuirass package to use.
  21681. @item @code{workers} (default: @code{1})
  21682. Start @var{workers} parallel workers.
  21683. @item @code{server} (default: @code{#f})
  21684. Do not use Avahi discovery and connect to the given @code{server} IP
  21685. address instead.
  21686. @item @code{systems} (default: @code{(list (%current-system))})
  21687. Only request builds for the given @var{systems}.
  21688. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  21689. Location of the log file.
  21690. @item @code{publish-port} (default: @code{5558})
  21691. The TCP port of the publish server. It defaults to @code{5558}.
  21692. @item @code{public-key}
  21693. @item @code{private-key}
  21694. Use the specific @var{file}s as the public/private key pair used to sign
  21695. the store items being published.
  21696. @end table
  21697. @end deftp
  21698. @subsubheading Laminar
  21699. @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
  21700. Continuous Integration service. It doesn't have a configuration web UI
  21701. instead uses version-controllable configuration files and scripts.
  21702. Laminar encourages the use of existing tools such as bash and cron
  21703. instead of reinventing them.
  21704. @defvr {Scheme Procedure} laminar-service-type
  21705. The type of the Laminar service. Its value must be a
  21706. @code{laminar-configuration} object, as described below.
  21707. All configuration values have defaults, a minimal configuration to get
  21708. Laminar running is shown below. By default, the web interface is
  21709. available on port 8080.
  21710. @lisp
  21711. (service laminar-service-type)
  21712. @end lisp
  21713. @end defvr
  21714. @deftp {Data Type} laminar-configuration
  21715. Data type representing the configuration of Laminar.
  21716. @table @asis
  21717. @item @code{laminar} (default: @code{laminar})
  21718. The Laminar package to use.
  21719. @item @code{home-directory} (default: @code{"/var/lib/laminar"})
  21720. The directory for job configurations and run directories.
  21721. @item @code{bind-http} (default: @code{"*:8080"})
  21722. The interface/port or unix socket on which laminard should listen for
  21723. incoming connections to the web frontend.
  21724. @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
  21725. The interface/port or unix socket on which laminard should listen for
  21726. incoming commands such as build triggers.
  21727. @item @code{title} (default: @code{"Laminar"})
  21728. The page title to show in the web frontend.
  21729. @item @code{keep-rundirs} (default: @code{0})
  21730. Set to an integer defining how many rundirs to keep per job. The
  21731. lowest-numbered ones will be deleted. The default is 0, meaning all run
  21732. dirs will be immediately deleted.
  21733. @item @code{archive-url} (default: @code{#f})
  21734. The web frontend served by laminard will use this URL to form links to
  21735. artefacts archived jobs.
  21736. @item @code{base-url} (default: @code{#f})
  21737. Base URL to use for links to laminar itself.
  21738. @end table
  21739. @end deftp
  21740. @node Power Management Services
  21741. @subsection Power Management Services
  21742. @cindex tlp
  21743. @cindex power management with TLP
  21744. @subsubheading TLP daemon
  21745. The @code{(gnu services pm)} module provides a Guix service definition
  21746. for the Linux power management tool TLP.
  21747. TLP enables various powersaving modes in userspace and kernel.
  21748. Contrary to @code{upower-service}, it is not a passive,
  21749. monitoring tool, as it will apply custom settings each time a new power
  21750. source is detected. More information can be found at
  21751. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  21752. @deffn {Scheme Variable} tlp-service-type
  21753. The service type for the TLP tool. The default settings are optimised
  21754. for battery life on most systems, but you can tweak them to your heart's
  21755. content by adding a valid @code{tlp-configuration}:
  21756. @lisp
  21757. (service tlp-service-type
  21758. (tlp-configuration
  21759. (cpu-scaling-governor-on-ac (list "performance"))
  21760. (sched-powersave-on-bat? #t)))
  21761. @end lisp
  21762. @end deffn
  21763. Each parameter definition is preceded by its type; for example,
  21764. @samp{boolean foo} indicates that the @code{foo} parameter
  21765. should be specified as a boolean. Types starting with
  21766. @code{maybe-} denote parameters that won't show up in TLP config file
  21767. when their value is @code{'disabled}.
  21768. @c The following documentation was initially generated by
  21769. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  21770. @c documentation is better, so we shouldn't hesitate to edit below as
  21771. @c needed. However if the change you want to make to this documentation
  21772. @c can be done in an automated way, it's probably easier to change
  21773. @c (generate-documentation) than to make it below and have to deal with
  21774. @c the churn as TLP updates.
  21775. Available @code{tlp-configuration} fields are:
  21776. @deftypevr {@code{tlp-configuration} parameter} package tlp
  21777. The TLP package.
  21778. @end deftypevr
  21779. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  21780. Set to true if you wish to enable TLP.
  21781. Defaults to @samp{#t}.
  21782. @end deftypevr
  21783. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  21784. Default mode when no power supply can be detected. Alternatives are AC
  21785. and BAT.
  21786. Defaults to @samp{"AC"}.
  21787. @end deftypevr
  21788. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  21789. Number of seconds Linux kernel has to wait after the disk goes idle,
  21790. before syncing on AC.
  21791. Defaults to @samp{0}.
  21792. @end deftypevr
  21793. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  21794. Same as @code{disk-idle-ac} but on BAT mode.
  21795. Defaults to @samp{2}.
  21796. @end deftypevr
  21797. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  21798. Dirty pages flushing periodicity, expressed in seconds.
  21799. Defaults to @samp{15}.
  21800. @end deftypevr
  21801. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  21802. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  21803. Defaults to @samp{60}.
  21804. @end deftypevr
  21805. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  21806. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  21807. alternatives are powersave and performance. With acpi-cpufreq driver,
  21808. alternatives are ondemand, powersave, performance and conservative.
  21809. Defaults to @samp{disabled}.
  21810. @end deftypevr
  21811. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  21812. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  21813. Defaults to @samp{disabled}.
  21814. @end deftypevr
  21815. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  21816. Set the min available frequency for the scaling governor on AC.
  21817. Defaults to @samp{disabled}.
  21818. @end deftypevr
  21819. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  21820. Set the max available frequency for the scaling governor on AC.
  21821. Defaults to @samp{disabled}.
  21822. @end deftypevr
  21823. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  21824. Set the min available frequency for the scaling governor on BAT.
  21825. Defaults to @samp{disabled}.
  21826. @end deftypevr
  21827. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  21828. Set the max available frequency for the scaling governor on BAT.
  21829. Defaults to @samp{disabled}.
  21830. @end deftypevr
  21831. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  21832. Limit the min P-state to control the power dissipation of the CPU, in AC
  21833. mode. Values are stated as a percentage of the available performance.
  21834. Defaults to @samp{disabled}.
  21835. @end deftypevr
  21836. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  21837. Limit the max P-state to control the power dissipation of the CPU, in AC
  21838. mode. Values are stated as a percentage of the available performance.
  21839. Defaults to @samp{disabled}.
  21840. @end deftypevr
  21841. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  21842. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  21843. Defaults to @samp{disabled}.
  21844. @end deftypevr
  21845. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  21846. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  21847. Defaults to @samp{disabled}.
  21848. @end deftypevr
  21849. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  21850. Enable CPU turbo boost feature on AC mode.
  21851. Defaults to @samp{disabled}.
  21852. @end deftypevr
  21853. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  21854. Same as @code{cpu-boost-on-ac?} on BAT mode.
  21855. Defaults to @samp{disabled}.
  21856. @end deftypevr
  21857. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  21858. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  21859. used under light load conditions.
  21860. Defaults to @samp{#f}.
  21861. @end deftypevr
  21862. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  21863. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  21864. Defaults to @samp{#t}.
  21865. @end deftypevr
  21866. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  21867. Enable Linux kernel NMI watchdog.
  21868. Defaults to @samp{#f}.
  21869. @end deftypevr
  21870. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  21871. For Linux kernels with PHC patch applied, change CPU voltages. An
  21872. example value would be @samp{"F:V F:V F:V F:V"}.
  21873. Defaults to @samp{disabled}.
  21874. @end deftypevr
  21875. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  21876. Set CPU performance versus energy saving policy on AC@. Alternatives are
  21877. performance, normal, powersave.
  21878. Defaults to @samp{"performance"}.
  21879. @end deftypevr
  21880. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  21881. Same as @code{energy-perf-policy-ac} but on BAT mode.
  21882. Defaults to @samp{"powersave"}.
  21883. @end deftypevr
  21884. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  21885. Hard disk devices.
  21886. @end deftypevr
  21887. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  21888. Hard disk advanced power management level.
  21889. @end deftypevr
  21890. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  21891. Same as @code{disk-apm-bat} but on BAT mode.
  21892. @end deftypevr
  21893. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  21894. Hard disk spin down timeout. One value has to be specified for each
  21895. declared hard disk.
  21896. Defaults to @samp{disabled}.
  21897. @end deftypevr
  21898. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  21899. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  21900. Defaults to @samp{disabled}.
  21901. @end deftypevr
  21902. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  21903. Select IO scheduler for disk devices. One value has to be specified for
  21904. each declared hard disk. Example alternatives are cfq, deadline and
  21905. noop.
  21906. Defaults to @samp{disabled}.
  21907. @end deftypevr
  21908. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  21909. SATA aggressive link power management (ALPM) level. Alternatives are
  21910. min_power, medium_power, max_performance.
  21911. Defaults to @samp{"max_performance"}.
  21912. @end deftypevr
  21913. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  21914. Same as @code{sata-linkpwr-ac} but on BAT mode.
  21915. Defaults to @samp{"min_power"}.
  21916. @end deftypevr
  21917. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  21918. Exclude specified SATA host devices for link power management.
  21919. Defaults to @samp{disabled}.
  21920. @end deftypevr
  21921. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  21922. Enable Runtime Power Management for AHCI controller and disks on AC
  21923. mode.
  21924. Defaults to @samp{disabled}.
  21925. @end deftypevr
  21926. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  21927. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  21928. Defaults to @samp{disabled}.
  21929. @end deftypevr
  21930. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  21931. Seconds of inactivity before disk is suspended.
  21932. Defaults to @samp{15}.
  21933. @end deftypevr
  21934. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  21935. PCI Express Active State Power Management level. Alternatives are
  21936. default, performance, powersave.
  21937. Defaults to @samp{"performance"}.
  21938. @end deftypevr
  21939. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  21940. Same as @code{pcie-aspm-ac} but on BAT mode.
  21941. Defaults to @samp{"powersave"}.
  21942. @end deftypevr
  21943. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  21944. Radeon graphics clock speed level. Alternatives are low, mid, high,
  21945. auto, default.
  21946. Defaults to @samp{"high"}.
  21947. @end deftypevr
  21948. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  21949. Same as @code{radeon-power-ac} but on BAT mode.
  21950. Defaults to @samp{"low"}.
  21951. @end deftypevr
  21952. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  21953. Radeon dynamic power management method (DPM). Alternatives are battery,
  21954. performance.
  21955. Defaults to @samp{"performance"}.
  21956. @end deftypevr
  21957. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  21958. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  21959. Defaults to @samp{"battery"}.
  21960. @end deftypevr
  21961. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  21962. Radeon DPM performance level. Alternatives are auto, low, high.
  21963. Defaults to @samp{"auto"}.
  21964. @end deftypevr
  21965. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  21966. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  21967. Defaults to @samp{"auto"}.
  21968. @end deftypevr
  21969. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  21970. Wifi power saving mode.
  21971. Defaults to @samp{#f}.
  21972. @end deftypevr
  21973. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  21974. Same as @code{wifi-power-ac?} but on BAT mode.
  21975. Defaults to @samp{#t}.
  21976. @end deftypevr
  21977. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  21978. Disable wake on LAN.
  21979. Defaults to @samp{#t}.
  21980. @end deftypevr
  21981. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  21982. Timeout duration in seconds before activating audio power saving on
  21983. Intel HDA and AC97 devices. A value of 0 disables power saving.
  21984. Defaults to @samp{0}.
  21985. @end deftypevr
  21986. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  21987. Same as @code{sound-powersave-ac} but on BAT mode.
  21988. Defaults to @samp{1}.
  21989. @end deftypevr
  21990. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  21991. Disable controller in powersaving mode on Intel HDA devices.
  21992. Defaults to @samp{#t}.
  21993. @end deftypevr
  21994. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  21995. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  21996. powered on again by releasing (and reinserting) the eject lever or by
  21997. pressing the disc eject button on newer models.
  21998. Defaults to @samp{#f}.
  21999. @end deftypevr
  22000. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  22001. Name of the optical drive device to power off.
  22002. Defaults to @samp{"sr0"}.
  22003. @end deftypevr
  22004. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  22005. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  22006. and auto.
  22007. Defaults to @samp{"on"}.
  22008. @end deftypevr
  22009. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  22010. Same as @code{runtime-pm-ac} but on BAT mode.
  22011. Defaults to @samp{"auto"}.
  22012. @end deftypevr
  22013. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  22014. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  22015. ones.
  22016. Defaults to @samp{#t}.
  22017. @end deftypevr
  22018. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  22019. Exclude specified PCI(e) device addresses from Runtime Power Management.
  22020. Defaults to @samp{disabled}.
  22021. @end deftypevr
  22022. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  22023. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  22024. Power Management.
  22025. @end deftypevr
  22026. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  22027. Enable USB autosuspend feature.
  22028. Defaults to @samp{#t}.
  22029. @end deftypevr
  22030. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  22031. Exclude specified devices from USB autosuspend.
  22032. Defaults to @samp{disabled}.
  22033. @end deftypevr
  22034. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  22035. Exclude WWAN devices from USB autosuspend.
  22036. Defaults to @samp{#t}.
  22037. @end deftypevr
  22038. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  22039. Include specified devices into USB autosuspend, even if they are already
  22040. excluded by the driver or via @code{usb-blacklist-wwan?}.
  22041. Defaults to @samp{disabled}.
  22042. @end deftypevr
  22043. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  22044. Enable USB autosuspend before shutdown.
  22045. Defaults to @samp{disabled}.
  22046. @end deftypevr
  22047. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  22048. Restore radio device state (bluetooth, wifi, wwan) from previous
  22049. shutdown on system startup.
  22050. Defaults to @samp{#f}.
  22051. @end deftypevr
  22052. @cindex thermald
  22053. @cindex CPU frequency scaling with thermald
  22054. @subsubheading Thermald daemon
  22055. The @code{(gnu services pm)} module provides an interface to
  22056. thermald, a CPU frequency scaling service which helps prevent overheating.
  22057. @defvr {Scheme Variable} thermald-service-type
  22058. This is the service type for
  22059. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  22060. Thermal Daemon, which is responsible for controlling the thermal state
  22061. of processors and preventing overheating.
  22062. @end defvr
  22063. @deftp {Data Type} thermald-configuration
  22064. Data type representing the configuration of @code{thermald-service-type}.
  22065. @table @asis
  22066. @item @code{ignore-cpuid-check?} (default: @code{#f})
  22067. Ignore cpuid check for supported CPU models.
  22068. @item @code{thermald} (default: @var{thermald})
  22069. Package object of thermald.
  22070. @end table
  22071. @end deftp
  22072. @node Audio Services
  22073. @subsection Audio Services
  22074. The @code{(gnu services audio)} module provides a service to start MPD
  22075. (the Music Player Daemon).
  22076. @cindex mpd
  22077. @subsubheading Music Player Daemon
  22078. The Music Player Daemon (MPD) is a service that can play music while
  22079. being controlled from the local machine or over the network by a variety
  22080. of clients.
  22081. The following example shows how one might run @code{mpd} as user
  22082. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  22083. @lisp
  22084. (service mpd-service-type
  22085. (mpd-configuration
  22086. (user "bob")
  22087. (port "6666")))
  22088. @end lisp
  22089. @defvr {Scheme Variable} mpd-service-type
  22090. The service type for @command{mpd}
  22091. @end defvr
  22092. @deftp {Data Type} mpd-configuration
  22093. Data type representing the configuration of @command{mpd}.
  22094. @table @asis
  22095. @item @code{user} (default: @code{"mpd"})
  22096. The user to run mpd as.
  22097. @item @code{music-dir} (default: @code{"~/Music"})
  22098. The directory to scan for music files.
  22099. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  22100. The directory to store playlists.
  22101. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  22102. The location of the music database.
  22103. @item @code{state-file} (default: @code{"~/.mpd/state"})
  22104. The location of the file that stores current MPD's state.
  22105. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  22106. The location of the sticker database.
  22107. @item @code{port} (default: @code{"6600"})
  22108. The port to run mpd on.
  22109. @item @code{address} (default: @code{"any"})
  22110. The address that mpd will bind to. To use a Unix domain socket,
  22111. an absolute path can be specified here.
  22112. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  22113. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  22114. @end table
  22115. @end deftp
  22116. @deftp {Data Type} mpd-output
  22117. Data type representing an @command{mpd} audio output.
  22118. @table @asis
  22119. @item @code{name} (default: @code{"MPD"})
  22120. The name of the audio output.
  22121. @item @code{type} (default: @code{"pulse"})
  22122. The type of audio output.
  22123. @item @code{enabled?} (default: @code{#t})
  22124. Specifies whether this audio output is enabled when MPD is started. By
  22125. default, all audio outputs are enabled. This is just the default
  22126. setting when there is no state file; with a state file, the previous
  22127. state is restored.
  22128. @item @code{tags?} (default: @code{#t})
  22129. If set to @code{#f}, then MPD will not send tags to this output. This
  22130. is only useful for output plugins that can receive tags, for example the
  22131. @code{httpd} output plugin.
  22132. @item @code{always-on?} (default: @code{#f})
  22133. If set to @code{#t}, then MPD attempts to keep this audio output always
  22134. open. This may be useful for streaming servers, when you don’t want to
  22135. disconnect all listeners even when playback is accidentally stopped.
  22136. @item @code{mixer-type}
  22137. This field accepts a symbol that specifies which mixer should be used
  22138. for this audio output: the @code{hardware} mixer, the @code{software}
  22139. mixer, the @code{null} mixer (allows setting the volume, but with no
  22140. effect; this can be used as a trick to implement an external mixer
  22141. External Mixer) or no mixer (@code{none}).
  22142. @item @code{extra-options} (default: @code{'()})
  22143. An association list of option symbols to string values to be appended to
  22144. the audio output configuration.
  22145. @end table
  22146. @end deftp
  22147. The following example shows a configuration of @code{mpd} that provides
  22148. an HTTP audio streaming output.
  22149. @lisp
  22150. (service mpd-service-type
  22151. (mpd-configuration
  22152. (outputs
  22153. (list (mpd-output
  22154. (name "streaming")
  22155. (type "httpd")
  22156. (mixer-type 'null)
  22157. (extra-options
  22158. `((encoder . "vorbis")
  22159. (port . "8080"))))))))
  22160. @end lisp
  22161. @node Virtualization Services
  22162. @subsection Virtualization Services
  22163. The @code{(gnu services virtualization)} module provides services for
  22164. the libvirt and virtlog daemons, as well as other virtualization-related
  22165. services.
  22166. @subsubheading Libvirt daemon
  22167. @code{libvirtd} is the server side daemon component of the libvirt
  22168. virtualization management system. This daemon runs on host servers
  22169. and performs required management tasks for virtualized guests.
  22170. @deffn {Scheme Variable} libvirt-service-type
  22171. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  22172. Its value must be a @code{libvirt-configuration}.
  22173. @lisp
  22174. (service libvirt-service-type
  22175. (libvirt-configuration
  22176. (unix-sock-group "libvirt")
  22177. (tls-port "16555")))
  22178. @end lisp
  22179. @end deffn
  22180. @c Auto-generated with (generate-libvirt-documentation)
  22181. Available @code{libvirt-configuration} fields are:
  22182. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  22183. Libvirt package.
  22184. @end deftypevr
  22185. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  22186. Flag listening for secure TLS connections on the public TCP/IP port.
  22187. You must set @code{listen} for this to have any effect.
  22188. It is necessary to setup a CA and issue server certificates before using
  22189. this capability.
  22190. Defaults to @samp{#t}.
  22191. @end deftypevr
  22192. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  22193. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  22194. set @code{listen} for this to have any effect.
  22195. Using the TCP socket requires SASL authentication by default. Only SASL
  22196. mechanisms which support data encryption are allowed. This is
  22197. DIGEST_MD5 and GSSAPI (Kerberos5).
  22198. Defaults to @samp{#f}.
  22199. @end deftypevr
  22200. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  22201. Port for accepting secure TLS connections. This can be a port number,
  22202. or service name.
  22203. Defaults to @samp{"16514"}.
  22204. @end deftypevr
  22205. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  22206. Port for accepting insecure TCP connections. This can be a port number,
  22207. or service name.
  22208. Defaults to @samp{"16509"}.
  22209. @end deftypevr
  22210. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  22211. IP address or hostname used for client connections.
  22212. Defaults to @samp{"0.0.0.0"}.
  22213. @end deftypevr
  22214. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  22215. Flag toggling mDNS advertisement of the libvirt service.
  22216. Alternatively can disable for all services on a host by stopping the
  22217. Avahi daemon.
  22218. Defaults to @samp{#f}.
  22219. @end deftypevr
  22220. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  22221. Default mDNS advertisement name. This must be unique on the immediate
  22222. broadcast network.
  22223. Defaults to @samp{"Virtualization Host <hostname>"}.
  22224. @end deftypevr
  22225. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  22226. UNIX domain socket group ownership. This can be used to allow a
  22227. 'trusted' set of users access to management capabilities without
  22228. becoming root.
  22229. Defaults to @samp{"root"}.
  22230. @end deftypevr
  22231. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  22232. UNIX socket permissions for the R/O socket. This is used for monitoring
  22233. VM status only.
  22234. Defaults to @samp{"0777"}.
  22235. @end deftypevr
  22236. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  22237. UNIX socket permissions for the R/W socket. Default allows only root.
  22238. If PolicyKit is enabled on the socket, the default will change to allow
  22239. everyone (eg, 0777)
  22240. Defaults to @samp{"0770"}.
  22241. @end deftypevr
  22242. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  22243. UNIX socket permissions for the admin socket. Default allows only owner
  22244. (root), do not change it unless you are sure to whom you are exposing
  22245. the access to.
  22246. Defaults to @samp{"0777"}.
  22247. @end deftypevr
  22248. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  22249. The directory in which sockets will be found/created.
  22250. Defaults to @samp{"/var/run/libvirt"}.
  22251. @end deftypevr
  22252. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  22253. Authentication scheme for UNIX read-only sockets. By default socket
  22254. permissions allow anyone to connect
  22255. Defaults to @samp{"polkit"}.
  22256. @end deftypevr
  22257. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  22258. Authentication scheme for UNIX read-write sockets. By default socket
  22259. permissions only allow root. If PolicyKit support was compiled into
  22260. libvirt, the default will be to use 'polkit' auth.
  22261. Defaults to @samp{"polkit"}.
  22262. @end deftypevr
  22263. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  22264. Authentication scheme for TCP sockets. If you don't enable SASL, then
  22265. all TCP traffic is cleartext. Don't do this outside of a dev/test
  22266. scenario.
  22267. Defaults to @samp{"sasl"}.
  22268. @end deftypevr
  22269. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  22270. Authentication scheme for TLS sockets. TLS sockets already have
  22271. encryption provided by the TLS layer, and limited authentication is done
  22272. by certificates.
  22273. It is possible to make use of any SASL authentication mechanism as well,
  22274. by using 'sasl' for this option
  22275. Defaults to @samp{"none"}.
  22276. @end deftypevr
  22277. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  22278. API access control scheme.
  22279. By default an authenticated user is allowed access to all APIs. Access
  22280. drivers can place restrictions on this.
  22281. Defaults to @samp{()}.
  22282. @end deftypevr
  22283. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  22284. Server key file path. If set to an empty string, then no private key is
  22285. loaded.
  22286. Defaults to @samp{""}.
  22287. @end deftypevr
  22288. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  22289. Server key file path. If set to an empty string, then no certificate is
  22290. loaded.
  22291. Defaults to @samp{""}.
  22292. @end deftypevr
  22293. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  22294. Server key file path. If set to an empty string, then no CA certificate
  22295. is loaded.
  22296. Defaults to @samp{""}.
  22297. @end deftypevr
  22298. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  22299. Certificate revocation list path. If set to an empty string, then no
  22300. CRL is loaded.
  22301. Defaults to @samp{""}.
  22302. @end deftypevr
  22303. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  22304. Disable verification of our own server certificates.
  22305. When libvirtd starts it performs some sanity checks against its own
  22306. certificates.
  22307. Defaults to @samp{#f}.
  22308. @end deftypevr
  22309. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  22310. Disable verification of client certificates.
  22311. Client certificate verification is the primary authentication mechanism.
  22312. Any client which does not present a certificate signed by the CA will be
  22313. rejected.
  22314. Defaults to @samp{#f}.
  22315. @end deftypevr
  22316. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  22317. Whitelist of allowed x509 Distinguished Name.
  22318. Defaults to @samp{()}.
  22319. @end deftypevr
  22320. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  22321. Whitelist of allowed SASL usernames. The format for username depends on
  22322. the SASL authentication mechanism.
  22323. Defaults to @samp{()}.
  22324. @end deftypevr
  22325. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  22326. Override the compile time default TLS priority string. The default is
  22327. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  22328. is desired for libvirt to deviate from the global default settings.
  22329. Defaults to @samp{"NORMAL"}.
  22330. @end deftypevr
  22331. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  22332. Maximum number of concurrent client connections to allow over all
  22333. sockets combined.
  22334. Defaults to @samp{5000}.
  22335. @end deftypevr
  22336. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  22337. Maximum length of queue of connections waiting to be accepted by the
  22338. daemon. Note, that some protocols supporting retransmission may obey
  22339. this so that a later reattempt at connection succeeds.
  22340. Defaults to @samp{1000}.
  22341. @end deftypevr
  22342. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  22343. Maximum length of queue of accepted but not yet authenticated clients.
  22344. Set this to zero to turn this feature off
  22345. Defaults to @samp{20}.
  22346. @end deftypevr
  22347. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  22348. Number of workers to start up initially.
  22349. Defaults to @samp{5}.
  22350. @end deftypevr
  22351. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  22352. Maximum number of worker threads.
  22353. If the number of active clients exceeds @code{min-workers}, then more
  22354. threads are spawned, up to max_workers limit. Typically you'd want
  22355. max_workers to equal maximum number of clients allowed.
  22356. Defaults to @samp{20}.
  22357. @end deftypevr
  22358. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  22359. Number of priority workers. If all workers from above pool are stuck,
  22360. some calls marked as high priority (notably domainDestroy) can be
  22361. executed in this pool.
  22362. Defaults to @samp{5}.
  22363. @end deftypevr
  22364. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  22365. Total global limit on concurrent RPC calls.
  22366. Defaults to @samp{20}.
  22367. @end deftypevr
  22368. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  22369. Limit on concurrent requests from a single client connection. To avoid
  22370. one client monopolizing the server this should be a small fraction of
  22371. the global max_requests and max_workers parameter.
  22372. Defaults to @samp{5}.
  22373. @end deftypevr
  22374. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  22375. Same as @code{min-workers} but for the admin interface.
  22376. Defaults to @samp{1}.
  22377. @end deftypevr
  22378. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  22379. Same as @code{max-workers} but for the admin interface.
  22380. Defaults to @samp{5}.
  22381. @end deftypevr
  22382. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  22383. Same as @code{max-clients} but for the admin interface.
  22384. Defaults to @samp{5}.
  22385. @end deftypevr
  22386. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  22387. Same as @code{max-queued-clients} but for the admin interface.
  22388. Defaults to @samp{5}.
  22389. @end deftypevr
  22390. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  22391. Same as @code{max-client-requests} but for the admin interface.
  22392. Defaults to @samp{5}.
  22393. @end deftypevr
  22394. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  22395. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  22396. Defaults to @samp{3}.
  22397. @end deftypevr
  22398. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  22399. Logging filters.
  22400. A filter allows to select a different logging level for a given category
  22401. of logs. The format for a filter is one of:
  22402. @itemize @bullet
  22403. @item
  22404. x:name
  22405. @item
  22406. x:+name
  22407. @end itemize
  22408. where @code{name} is a string which is matched against the category
  22409. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  22410. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  22411. name in the filter can be a substring of the full category name, in
  22412. order to match multiple similar categories), the optional @samp{"+"}
  22413. prefix tells libvirt to log stack trace for each message matching name,
  22414. and @code{x} is the minimal level where matching messages should be
  22415. logged:
  22416. @itemize @bullet
  22417. @item
  22418. 1: DEBUG
  22419. @item
  22420. 2: INFO
  22421. @item
  22422. 3: WARNING
  22423. @item
  22424. 4: ERROR
  22425. @end itemize
  22426. Multiple filters can be defined in a single filters statement, they just
  22427. need to be separated by spaces.
  22428. Defaults to @samp{"3:remote 4:event"}.
  22429. @end deftypevr
  22430. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  22431. Logging outputs.
  22432. An output is one of the places to save logging information. The format
  22433. for an output can be:
  22434. @table @code
  22435. @item x:stderr
  22436. output goes to stderr
  22437. @item x:syslog:name
  22438. use syslog for the output and use the given name as the ident
  22439. @item x:file:file_path
  22440. output to a file, with the given filepath
  22441. @item x:journald
  22442. output to journald logging system
  22443. @end table
  22444. In all case the x prefix is the minimal level, acting as a filter
  22445. @itemize @bullet
  22446. @item
  22447. 1: DEBUG
  22448. @item
  22449. 2: INFO
  22450. @item
  22451. 3: WARNING
  22452. @item
  22453. 4: ERROR
  22454. @end itemize
  22455. Multiple outputs can be defined, they just need to be separated by
  22456. spaces.
  22457. Defaults to @samp{"3:stderr"}.
  22458. @end deftypevr
  22459. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  22460. Allows usage of the auditing subsystem to be altered
  22461. @itemize @bullet
  22462. @item
  22463. 0: disable all auditing
  22464. @item
  22465. 1: enable auditing, only if enabled on host
  22466. @item
  22467. 2: enable auditing, and exit if disabled on host.
  22468. @end itemize
  22469. Defaults to @samp{1}.
  22470. @end deftypevr
  22471. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  22472. Send audit messages via libvirt logging infrastructure.
  22473. Defaults to @samp{#f}.
  22474. @end deftypevr
  22475. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  22476. Host UUID@. UUID must not have all digits be the same.
  22477. Defaults to @samp{""}.
  22478. @end deftypevr
  22479. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  22480. Source to read host UUID.
  22481. @itemize @bullet
  22482. @item
  22483. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  22484. @item
  22485. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  22486. @end itemize
  22487. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  22488. be generated.
  22489. Defaults to @samp{"smbios"}.
  22490. @end deftypevr
  22491. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  22492. A keepalive message is sent to a client after @code{keepalive_interval}
  22493. seconds of inactivity to check if the client is still responding. If
  22494. set to -1, libvirtd will never send keepalive requests; however clients
  22495. can still send them and the daemon will send responses.
  22496. Defaults to @samp{5}.
  22497. @end deftypevr
  22498. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  22499. Maximum number of keepalive messages that are allowed to be sent to the
  22500. client without getting any response before the connection is considered
  22501. broken.
  22502. In other words, the connection is automatically closed approximately
  22503. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  22504. the last message received from the client. When @code{keepalive-count}
  22505. is set to 0, connections will be automatically closed after
  22506. @code{keepalive-interval} seconds of inactivity without sending any
  22507. keepalive messages.
  22508. Defaults to @samp{5}.
  22509. @end deftypevr
  22510. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  22511. Same as above but for admin interface.
  22512. Defaults to @samp{5}.
  22513. @end deftypevr
  22514. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  22515. Same as above but for admin interface.
  22516. Defaults to @samp{5}.
  22517. @end deftypevr
  22518. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  22519. Timeout for Open vSwitch calls.
  22520. The @code{ovs-vsctl} utility is used for the configuration and its
  22521. timeout option is set by default to 5 seconds to avoid potential
  22522. infinite waits blocking libvirt.
  22523. Defaults to @samp{5}.
  22524. @end deftypevr
  22525. @c %end of autogenerated docs
  22526. @subsubheading Virtlog daemon
  22527. The virtlogd service is a server side daemon component of libvirt that is
  22528. used to manage logs from virtual machine consoles.
  22529. This daemon is not used directly by libvirt client applications, rather it
  22530. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  22531. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  22532. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  22533. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  22534. @deffn {Scheme Variable} virtlog-service-type
  22535. This is the type of the virtlog daemon.
  22536. Its value must be a @code{virtlog-configuration}.
  22537. @lisp
  22538. (service virtlog-service-type
  22539. (virtlog-configuration
  22540. (max-clients 1000)))
  22541. @end lisp
  22542. @end deffn
  22543. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  22544. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  22545. Defaults to @samp{3}.
  22546. @end deftypevr
  22547. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  22548. Logging filters.
  22549. A filter allows to select a different logging level for a given category
  22550. of logs The format for a filter is one of:
  22551. @itemize @bullet
  22552. @item
  22553. x:name
  22554. @item
  22555. x:+name
  22556. @end itemize
  22557. where @code{name} is a string which is matched against the category
  22558. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  22559. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  22560. be a substring of the full category name, in order to match multiple
  22561. similar categories), the optional "+" prefix tells libvirt to log stack
  22562. trace for each message matching name, and @code{x} is the minimal level
  22563. where matching messages should be logged:
  22564. @itemize @bullet
  22565. @item
  22566. 1: DEBUG
  22567. @item
  22568. 2: INFO
  22569. @item
  22570. 3: WARNING
  22571. @item
  22572. 4: ERROR
  22573. @end itemize
  22574. Multiple filters can be defined in a single filters statement, they just
  22575. need to be separated by spaces.
  22576. Defaults to @samp{"3:remote 4:event"}.
  22577. @end deftypevr
  22578. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  22579. Logging outputs.
  22580. An output is one of the places to save logging information The format
  22581. for an output can be:
  22582. @table @code
  22583. @item x:stderr
  22584. output goes to stderr
  22585. @item x:syslog:name
  22586. use syslog for the output and use the given name as the ident
  22587. @item x:file:file_path
  22588. output to a file, with the given filepath
  22589. @item x:journald
  22590. output to journald logging system
  22591. @end table
  22592. In all case the x prefix is the minimal level, acting as a filter
  22593. @itemize @bullet
  22594. @item
  22595. 1: DEBUG
  22596. @item
  22597. 2: INFO
  22598. @item
  22599. 3: WARNING
  22600. @item
  22601. 4: ERROR
  22602. @end itemize
  22603. Multiple outputs can be defined, they just need to be separated by
  22604. spaces.
  22605. Defaults to @samp{"3:stderr"}.
  22606. @end deftypevr
  22607. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  22608. Maximum number of concurrent client connections to allow over all
  22609. sockets combined.
  22610. Defaults to @samp{1024}.
  22611. @end deftypevr
  22612. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  22613. Maximum file size before rolling over.
  22614. Defaults to @samp{2MB}
  22615. @end deftypevr
  22616. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  22617. Maximum number of backup files to keep.
  22618. Defaults to @samp{3}
  22619. @end deftypevr
  22620. @anchor{transparent-emulation-qemu}
  22621. @subsubheading Transparent Emulation with QEMU
  22622. @cindex emulation
  22623. @cindex @code{binfmt_misc}
  22624. @code{qemu-binfmt-service-type} provides support for transparent
  22625. emulation of program binaries built for different architectures---e.g.,
  22626. it allows you to transparently execute an ARMv7 program on an x86_64
  22627. machine. It achieves this by combining the @uref{https://www.qemu.org,
  22628. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  22629. This feature only allows you to emulate GNU/Linux on a different
  22630. architecture, but see below for GNU/Hurd support.
  22631. @defvr {Scheme Variable} qemu-binfmt-service-type
  22632. This is the type of the QEMU/binfmt service for transparent emulation.
  22633. Its value must be a @code{qemu-binfmt-configuration} object, which
  22634. specifies the QEMU package to use as well as the architecture we want to
  22635. emulated:
  22636. @lisp
  22637. (service qemu-binfmt-service-type
  22638. (qemu-binfmt-configuration
  22639. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  22640. @end lisp
  22641. In this example, we enable transparent emulation for the ARM and aarch64
  22642. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  22643. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  22644. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  22645. @end defvr
  22646. @deftp {Data Type} qemu-binfmt-configuration
  22647. This is the configuration for the @code{qemu-binfmt} service.
  22648. @table @asis
  22649. @item @code{platforms} (default: @code{'()})
  22650. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  22651. object} as returned by @code{lookup-qemu-platforms} (see below).
  22652. For example, let's suppose you're on an x86_64 machine and you have this
  22653. service:
  22654. @lisp
  22655. (service qemu-binfmt-service-type
  22656. (qemu-binfmt-configuration
  22657. (platforms (lookup-qemu-platforms "arm"))))
  22658. @end lisp
  22659. You can run:
  22660. @example
  22661. guix build -s armhf-linux inkscape
  22662. @end example
  22663. @noindent
  22664. and it will build Inkscape for ARMv7 @emph{as if it were a native
  22665. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  22666. if you'd like to test a package build for an architecture you don't have
  22667. access to!
  22668. @item @code{qemu} (default: @code{qemu})
  22669. The QEMU package to use.
  22670. @end table
  22671. @end deftp
  22672. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  22673. Return the list of QEMU platform objects corresponding to
  22674. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  22675. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  22676. @code{"mips64el"}, and so on.
  22677. @end deffn
  22678. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  22679. Return true if @var{obj} is a platform object.
  22680. @end deffn
  22681. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  22682. Return the name of @var{platform}---a string such as @code{"arm"}.
  22683. @end deffn
  22684. @subsubheading The Hurd in a Virtual Machine
  22685. @cindex @code{hurd}
  22686. @cindex the Hurd
  22687. @cindex childhurd
  22688. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  22689. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  22690. to be used on GNU/Linux and the given GNU/Hurd operating system
  22691. configuration is cross-compiled. The virtual machine is a Shepherd
  22692. service that can be referred to by the names @code{hurd-vm} and
  22693. @code{childhurd} and be controlled with commands such as:
  22694. @example
  22695. herd start hurd-vm
  22696. herd stop childhurd
  22697. @end example
  22698. When the service is running, you can view its console by connecting to
  22699. it with a VNC client, for example with:
  22700. @example
  22701. guix environment --ad-hoc tigervnc-client -- \
  22702. vncviewer localhost:5900
  22703. @end example
  22704. The default configuration (see @code{hurd-vm-configuration} below)
  22705. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  22706. (the virtual machine emulator) redirects to port 10222 on the host.
  22707. Thus, you can connect over SSH to the childhurd with:
  22708. @example
  22709. ssh root@@localhost -p 10022
  22710. @end example
  22711. The childhurd is volatile and stateless: it starts with a fresh root
  22712. file system every time you restart it. By default though, all the files
  22713. under @file{/etc/childhurd} on the host are copied as is to the root
  22714. file system of the childhurd when it boots. This allows you to
  22715. initialize ``secrets'' inside the VM: SSH host keys, authorized
  22716. substitute keys, and so on---see the explanation of @code{secret-root}
  22717. below.
  22718. @defvr {Scheme Variable} hurd-vm-service-type
  22719. This is the type of the Hurd in a Virtual Machine service. Its value
  22720. must be a @code{hurd-vm-configuration} object, which specifies the
  22721. operating system (@pxref{operating-system Reference}) and the disk size
  22722. for the Hurd Virtual Machine, the QEMU package to use as well as the
  22723. options for running it.
  22724. For example:
  22725. @lisp
  22726. (service hurd-vm-service-type
  22727. (hurd-vm-configuration
  22728. (disk-size (* 5000 (expt 2 20))) ;5G
  22729. (memory-size 1024))) ;1024MiB
  22730. @end lisp
  22731. would create a disk image big enough to build GNU@tie{}Hello, with some
  22732. extra memory.
  22733. @end defvr
  22734. @deftp {Data Type} hurd-vm-configuration
  22735. The data type representing the configuration for
  22736. @code{hurd-vm-service-type}.
  22737. @table @asis
  22738. @item @code{os} (default: @var{%hurd-vm-operating-system})
  22739. The operating system to instantiate. This default is bare-bones with a
  22740. permissive OpenSSH secure shell daemon listening on port 2222
  22741. (@pxref{Networking Services, @code{openssh-service-type}}).
  22742. @item @code{qemu} (default: @code{qemu-minimal})
  22743. The QEMU package to use.
  22744. @item @code{image} (default: @var{hurd-vm-disk-image})
  22745. The procedure used to build the disk-image built from this
  22746. configuration.
  22747. @item @code{disk-size} (default: @code{'guess})
  22748. The size of the disk image.
  22749. @item @code{memory-size} (default: @code{512})
  22750. The memory size of the Virtual Machine in mebibytes.
  22751. @item @code{options} (default: @code{'("--snapshot")})
  22752. The extra options for running QEMU.
  22753. @item @code{id} (default: @code{#f})
  22754. If set, a non-zero positive integer used to parameterize Childhurd
  22755. instances. It is appended to the service's name,
  22756. e.g. @code{childhurd1}.
  22757. @item @code{net-options} (default: @var{hurd-vm-net-options})
  22758. The procedure used to produce the list of QEMU networking options.
  22759. By default, it produces
  22760. @lisp
  22761. '("--device" "rtl8139,netdev=net0"
  22762. "--netdev" "user,id=net0\
  22763. ,hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004\
  22764. ,hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222\
  22765. ,hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900")
  22766. @end lisp
  22767. with forwarded ports:
  22768. @example
  22769. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  22770. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  22771. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  22772. @end example
  22773. @item @code{secret-root} (default: @file{/etc/childhurd})
  22774. The root directory with out-of-band secrets to be installed into the
  22775. childhurd once it runs. Childhurds are volatile which means that on
  22776. every startup, secrets such as the SSH host keys and Guix signing key
  22777. are recreated.
  22778. If the @file{/etc/childhurd} directory does not exist, the
  22779. @code{secret-service} running in the Childhurd will be sent an empty
  22780. list of secrets.
  22781. By default, the service automatically populates @file{/etc/childhurd}
  22782. with the following non-volatile secrets, unless they already exist:
  22783. @example
  22784. /etc/childhurd/etc/guix/acl
  22785. /etc/childhurd/etc/guix/signing-key.pub
  22786. /etc/childhurd/etc/guix/signing-key.sec
  22787. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  22788. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  22789. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  22790. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  22791. @end example
  22792. These files are automatically sent to the guest Hurd VM when it boots,
  22793. including permissions.
  22794. @cindex childhurd, offloading
  22795. @cindex Hurd, offloading
  22796. Having these files in place means that only a couple of things are
  22797. missing to allow the host to offload @code{i586-gnu} builds to the
  22798. childhurd:
  22799. @enumerate
  22800. @item
  22801. Authorizing the childhurd's key on the host so that the host accepts
  22802. build results coming from the childhurd, which can be done like so:
  22803. @example
  22804. guix archive --authorize < \
  22805. /etc/childhurd/etc/guix/signing-key.pub
  22806. @end example
  22807. @item
  22808. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  22809. Offload Setup}).
  22810. @end enumerate
  22811. We're working towards making that happen automatically---get in touch
  22812. with us at @email{guix-devel@@gnu.org} to discuss it!
  22813. @end table
  22814. @end deftp
  22815. Note that by default the VM image is volatile, i.e., once stopped the
  22816. contents are lost. If you want a stateful image instead, override the
  22817. configuration's @code{image} and @code{options} without
  22818. the @code{--snapshot} flag using something along these lines:
  22819. @lisp
  22820. (service hurd-vm-service-type
  22821. (hurd-vm-configuration
  22822. (image (const "/out/of/store/writable/hurd.img"))
  22823. (options '())))
  22824. @end lisp
  22825. @subsubheading Ganeti
  22826. @cindex ganeti
  22827. @quotation Note
  22828. This service is considered experimental. Configuration options may be changed
  22829. in a backwards-incompatible manner, and not all features have been thorougly
  22830. tested. Users of this service are encouraged to share their experience at
  22831. @email{guix-devel@@gnu.org}.
  22832. @end quotation
  22833. Ganeti is a virtual machine management system. It is designed to keep virtual
  22834. machines running on a cluster of servers even in the event of hardware failures,
  22835. and to make maintenance and recovery tasks easy. It consists of multiple
  22836. services which are described later in this section. In addition to the Ganeti
  22837. service, you will need the OpenSSH service (@pxref{Networking Services,
  22838. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  22839. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  22840. and address (or use a DNS server).
  22841. All nodes participating in a Ganeti cluster should have the same Ganeti and
  22842. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  22843. cluster node that supports multiple storage backends, and installs the
  22844. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  22845. @lisp
  22846. (use-package-modules virtualization)
  22847. (use-service-modules base ganeti networking ssh)
  22848. (operating-system
  22849. ;; @dots{}
  22850. (host-name "node1")
  22851. (hosts-file (plain-file "hosts" (format #f "
  22852. 127.0.0.1 localhost
  22853. ::1 localhost
  22854. 192.168.1.200 ganeti.example.com
  22855. 192.168.1.201 node1.example.com node1
  22856. 192.168.1.202 node2.example.com node2
  22857. ")))
  22858. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  22859. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  22860. (packages (append (map specification->package
  22861. '("qemu" "lvm2" "drbd-utils" "ceph"
  22862. ;; Add the debootstrap and guix OS providers.
  22863. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  22864. %base-packages))
  22865. (services
  22866. (append (list (static-networking-service "eth0" "192.168.1.201"
  22867. #:netmask "255.255.255.0"
  22868. #:gateway "192.168.1.254"
  22869. #:name-servers '("192.168.1.252"
  22870. "192.168.1.253"))
  22871. ;; Ganeti uses SSH to communicate between nodes.
  22872. (service openssh-service-type
  22873. (openssh-configuration
  22874. (permit-root-login 'without-password)))
  22875. (service ganeti-service-type
  22876. (ganeti-configuration
  22877. ;; This list specifies allowed file system paths
  22878. ;; for storing virtual machine images.
  22879. (file-storage-paths '("/srv/ganeti/file-storage"))
  22880. ;; This variable configures a single "variant" for
  22881. ;; both Debootstrap and Guix that works with KVM.
  22882. (os %default-ganeti-os))))
  22883. %base-services)))
  22884. @end lisp
  22885. Users are advised to read the
  22886. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  22887. administrators guide} to learn about the various cluster options and
  22888. day-to-day operations. There is also a
  22889. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  22890. describing how to configure and initialize a small cluster.
  22891. @defvr {Scheme Variable} ganeti-service-type
  22892. This is a service type that includes all the various services that Ganeti
  22893. nodes should run.
  22894. Its value is a @code{ganeti-configuration} object that defines the package
  22895. to use for CLI operations, as well as configuration for the various daemons.
  22896. Allowed file storage paths and available guest operating systems are also
  22897. configured through this data type.
  22898. @end defvr
  22899. @deftp {Data Type} ganeti-configuration
  22900. The @code{ganeti} service takes the following configuration options:
  22901. @table @asis
  22902. @item @code{ganeti} (default: @code{ganeti})
  22903. The @code{ganeti} package to use. It will be installed to the system profile
  22904. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  22905. that the value specified here does not affect the other services as each refer
  22906. to a specific @code{ganeti} package (see below).
  22907. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  22908. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  22909. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  22910. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  22911. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  22912. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  22913. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  22914. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  22915. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  22916. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  22917. These options control the various daemons and cron jobs that are distributed
  22918. with Ganeti. The possible values for these are described in detail below.
  22919. To override a setting, you must use the configuration type for that service:
  22920. @lisp
  22921. (service ganeti-service-type
  22922. (ganeti-configuration
  22923. (rapi-configuration
  22924. (ganeti-rapi-configuration
  22925. (interface "eth1"))))
  22926. (watcher-configuration
  22927. (ganeti-watcher-configuration
  22928. (rapi-ip "10.0.0.1"))))
  22929. @end lisp
  22930. @item @code{file-storage-paths} (default: @code{'()})
  22931. List of allowed directories for file storage backend.
  22932. @item @code{os} (default: @code{%default-ganeti-os})
  22933. List of @code{<ganeti-os>} records.
  22934. @end table
  22935. In essence @code{ganeti-service-type} is shorthand for declaring each service
  22936. individually:
  22937. @lisp
  22938. (service ganeti-noded-service-type)
  22939. (service ganeti-confd-service-type)
  22940. (service ganeti-wconfd-service-type)
  22941. (service ganeti-luxid-service-type)
  22942. (service ganeti-kvmd-service-type)
  22943. (service ganeti-mond-service-type)
  22944. (service ganeti-metad-service-type)
  22945. (service ganeti-watcher-service-type)
  22946. (service ganeti-cleaner-service-type)
  22947. @end lisp
  22948. Plus a service extension for @code{etc-service-type} that configures the file
  22949. storage backend and OS variants.
  22950. @end deftp
  22951. @deftp {Data Type} ganeti-os
  22952. This data type is suitable for passing to the @code{os} parameter of
  22953. @code{ganeti-configuration}. It takes the following parameters:
  22954. @table @asis
  22955. @item @code{name}
  22956. The name for this OS provider. It is only used to specify where the
  22957. configuration ends up. Setting it to ``debootstrap'' will create
  22958. @file{/etc/ganeti/instance-debootstrap}.
  22959. @item @code{extension}
  22960. The file extension for variants of this OS type. For example
  22961. @file{.conf} or @file{.scm}.
  22962. @item @code{variants} (default: @code{'()})
  22963. List of @code{ganeti-os-variant} objects for this OS.
  22964. @end table
  22965. @end deftp
  22966. @deftp {Data Type} ganeti-os-variant
  22967. This is the data type for a Ganeti OS variant. It takes the following
  22968. parameters:
  22969. @table @asis
  22970. @item @code{name}
  22971. The name of this variant.
  22972. @item @code{configuration}
  22973. A configuration file for this variant.
  22974. @end table
  22975. @end deftp
  22976. @defvr {Scheme Variable} %default-debootstrap-hooks
  22977. This variable contains hooks to configure networking and the GRUB bootloader.
  22978. @end defvr
  22979. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  22980. This variable contains a list of packages suitable for a fully-virtualized guest.
  22981. @end defvr
  22982. @deftp {Data Type} debootstrap-configuration
  22983. This data type creates configuration files suitable for the debootstrap OS provider.
  22984. @table @asis
  22985. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  22986. When not @code{#f}, this must be a G-expression that specifies a directory with
  22987. scripts that will run when the OS is installed. It can also be a list of
  22988. @code{(name . file-like)} pairs. For example:
  22989. @lisp
  22990. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  22991. @end lisp
  22992. That will create a directory with one executable named @code{99-hello-world}
  22993. and run it every time this variant is installed. If set to @code{#f}, hooks
  22994. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  22995. @item @code{proxy} (default: @code{#f})
  22996. Optional HTTP proxy to use.
  22997. @item @code{mirror} (default: @code{#f})
  22998. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  22999. The default varies depending on the distribution.
  23000. @item @code{arch} (default: @code{#f})
  23001. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  23002. on an AArch64 host. Default is to use the current system architecture.
  23003. @item @code{suite} (default: @code{"stable"})
  23004. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  23005. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  23006. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  23007. List of extra packages that will get installed by dpkg in addition
  23008. to the minimal system.
  23009. @item @code{components} (default: @code{#f})
  23010. When set, must be a list of Debian repository ``components''. For example
  23011. @code{'("main" "contrib")}.
  23012. @item @code{generate-cache?} (default: @code{#t})
  23013. Whether to automatically cache the generated debootstrap archive.
  23014. @item @code{clean-cache} (default: @code{14})
  23015. Discard the cache after this amount of days. Use @code{#f} to never
  23016. clear the cache.
  23017. @item @code{partition-style} (default: @code{'msdos})
  23018. The type of partition to create. When set, it must be one of
  23019. @code{'msdos}, @code{'none} or a string.
  23020. @item @code{partition-alignment} (default: @code{2048})
  23021. Alignment of the partition in sectors.
  23022. @end table
  23023. @end deftp
  23024. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  23025. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  23026. takes two parameters: a name and a @code{debootstrap-configuration} object.
  23027. @end deffn
  23028. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  23029. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  23030. a list of variants created with @code{debootstrap-variant}.
  23031. @end deffn
  23032. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  23033. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  23034. use with the Guix OS provider. It takes a name and a G-expression that returns
  23035. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  23036. Guix System configuration.
  23037. @end deffn
  23038. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  23039. This is a helper procedure that creates a @code{ganeti-os} record. It
  23040. takes a list of variants produced by @code{guix-variant}.
  23041. @end deffn
  23042. @defvr {Scheme Variable} %default-debootstrap-variants
  23043. This is a convenience variable to make the debootstrap provider work
  23044. ``out of the box'' without users having to declare variants manually. It
  23045. contains a single debootstrap variant with the default configuration:
  23046. @lisp
  23047. (list (debootstrap-variant
  23048. "default"
  23049. (debootstrap-configuration)))
  23050. @end lisp
  23051. @end defvr
  23052. @defvr {Scheme Variable} %default-guix-variants
  23053. This is a convenience variable to make the Guix OS provider work without
  23054. additional configuration. It creates a virtual machine that has an SSH
  23055. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  23056. @lisp
  23057. (list (guix-variant
  23058. "default"
  23059. (file-append ganeti-instance-guix
  23060. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  23061. @end lisp
  23062. @end defvr
  23063. Users can implement support for OS providers unbeknownst to Guix by extending
  23064. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  23065. For example:
  23066. @lisp
  23067. (ganeti-os
  23068. (name "custom")
  23069. (extension ".conf")
  23070. (variants
  23071. (list (ganeti-os-variant
  23072. (name "foo")
  23073. (configuration (plain-file "bar" "this is fine"))))))
  23074. @end lisp
  23075. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  23076. to a file in the store with contents @code{this is fine}. It also creates
  23077. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  23078. Obviously this may not work for all OS providers out there. If you find the
  23079. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  23080. The rest of this section documents the various services that are included by
  23081. @code{ganeti-service-type}.
  23082. @defvr {Scheme Variable} ganeti-noded-service-type
  23083. @command{ganeti-noded} is the daemon responsible for node-specific functions
  23084. within the Ganeti system. The value of this service must be a
  23085. @code{ganeti-noded-configuration} object.
  23086. @end defvr
  23087. @deftp {Data Type} ganeti-noded-configuration
  23088. This is the configuration for the @code{ganeti-noded} service.
  23089. @table @asis
  23090. @item @code{ganeti} (default: @code{ganeti})
  23091. The @code{ganeti} package to use for this service.
  23092. @item @code{port} (default: @code{1811})
  23093. The TCP port on which the node daemon listens for network requests.
  23094. @item @code{address} (default: @code{"0.0.0.0"})
  23095. The network address that the daemon will bind to. The default address means
  23096. bind to all available addresses.
  23097. @item @code{interface} (default: @code{#f})
  23098. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  23099. that the daemon will bind to.
  23100. @item @code{max-clients} (default: @code{20})
  23101. This sets a limit on the maximum number of simultaneous client connections
  23102. that the daemon will handle. Connections above this count are accepted, but
  23103. no responses will be sent until enough connections have closed.
  23104. @item @code{ssl?} (default: @code{#t})
  23105. Whether to use SSL/TLS to encrypt network communications. The certificate
  23106. is automatically provisioned by the cluster and can be rotated with
  23107. @command{gnt-cluster renew-crypto}.
  23108. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  23109. This can be used to provide a specific encryption key for TLS communications.
  23110. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  23111. This can be used to provide a specific certificate for TLS communications.
  23112. @item @code{debug?} (default: @code{#f})
  23113. When true, the daemon performs additional logging for debugging purposes.
  23114. Note that this will leak encryption details to the log files, use with caution.
  23115. @end table
  23116. @end deftp
  23117. @defvr {Scheme Variable} ganeti-confd-service-type
  23118. @command{ganeti-confd} answers queries related to the configuration of a
  23119. Ganeti cluster. The purpose of this daemon is to have a highly available
  23120. and fast way to query cluster configuration values. It is automatically
  23121. active on all @dfn{master candidates}. The value of this service must be a
  23122. @code{ganeti-confd-configuration} object.
  23123. @end defvr
  23124. @deftp {Data Type} ganeti-confd-configuration
  23125. This is the configuration for the @code{ganeti-confd} service.
  23126. @table @asis
  23127. @item @code{ganeti} (default: @code{ganeti})
  23128. The @code{ganeti} package to use for this service.
  23129. @item @code{port} (default: @code{1814})
  23130. The UDP port on which to listen for network requests.
  23131. @item @code{address} (default: @code{"0.0.0.0"})
  23132. Network address that the daemon will bind to.
  23133. @item @code{debug?} (default: @code{#f})
  23134. When true, the daemon performs additional logging for debugging purposes.
  23135. @end table
  23136. @end deftp
  23137. @defvr {Scheme Variable} ganeti-wconfd-service-type
  23138. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  23139. about the cluster configuration and is the only entity that can accept
  23140. changes to it. All jobs that need to modify the configuration will do so
  23141. by sending appropriate requests to this daemon. It only runs on the
  23142. @dfn{master node} and will automatically disable itself on other nodes.
  23143. The value of this service must be a
  23144. @code{ganeti-wconfd-configuration} object.
  23145. @end defvr
  23146. @deftp {Data Type} ganeti-wconfd-configuration
  23147. This is the configuration for the @code{ganeti-wconfd} service.
  23148. @table @asis
  23149. @item @code{ganeti} (default: @code{ganeti})
  23150. The @code{ganeti} package to use for this service.
  23151. @item @code{no-voting?} (default: @code{#f})
  23152. The daemon will refuse to start if the majority of cluster nodes does not
  23153. agree that it is running on the master node. Set to @code{#t} to start
  23154. even if a quorum can not be reached (dangerous, use with caution).
  23155. @item @code{debug?} (default: @code{#f})
  23156. When true, the daemon performs additional logging for debugging purposes.
  23157. @end table
  23158. @end deftp
  23159. @defvr {Scheme Variable} ganeti-luxid-service-type
  23160. @command{ganeti-luxid} is a daemon used to answer queries related to the
  23161. configuration and the current live state of a Ganeti cluster. Additionally,
  23162. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  23163. submitted via this daemon and it schedules and starts them.
  23164. It takes a @code{ganeti-luxid-configuration} object.
  23165. @end defvr
  23166. @deftp {Data Type} ganeti-luxid-configuration
  23167. This is the configuration for the @code{ganeti-wconfd} service.
  23168. @table @asis
  23169. @item @code{ganeti} (default: @code{ganeti})
  23170. The @code{ganeti} package to use for this service.
  23171. @item @code{no-voting?} (default: @code{#f})
  23172. The daemon will refuse to start if it cannot verify that the majority of
  23173. cluster nodes believes that it is running on the master node. Set to
  23174. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  23175. @item @code{debug?} (default: @code{#f})
  23176. When true, the daemon performs additional logging for debugging purposes.
  23177. @end table
  23178. @end deftp
  23179. @defvr {Scheme Variable} ganeti-rapi-service-type
  23180. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  23181. the master node and can be used to perform cluster actions programmatically
  23182. via a JSON-based RPC protocol.
  23183. Most query operations are allowed without authentication (unless
  23184. @var{require-authentication?} is set), whereas write operations require
  23185. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  23186. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  23187. API documentation} for more information.
  23188. The value of this service must be a @code{ganeti-rapi-configuration} object.
  23189. @end defvr
  23190. @deftp {Data Type} ganeti-rapi-configuration
  23191. This is the configuration for the @code{ganeti-rapi} service.
  23192. @table @asis
  23193. @item @code{ganeti} (default: @code{ganeti})
  23194. The @code{ganeti} package to use for this service.
  23195. @item @code{require-authentication?} (default: @code{#f})
  23196. Whether to require authentication even for read-only operations.
  23197. @item @code{port} (default: @code{5080})
  23198. The TCP port on which to listen to API requests.
  23199. @item @code{address} (default: @code{"0.0.0.0"})
  23200. The network address that the service will bind to. By default it listens
  23201. on all configured addresses.
  23202. @item @code{interface} (default: @code{#f})
  23203. When set, it must specify a specific network interface such as @code{eth0}
  23204. that the daemon will bind to.
  23205. @item @code{max-clients} (default: @code{20})
  23206. The maximum number of simultaneous client requests to handle. Further
  23207. connections are allowed, but no responses are sent until enough connections
  23208. have closed.
  23209. @item @code{ssl?} (default: @code{#t})
  23210. Whether to use SSL/TLS encryption on the RAPI port.
  23211. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  23212. This can be used to provide a specific encryption key for TLS communications.
  23213. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  23214. This can be used to provide a specific certificate for TLS communications.
  23215. @item @code{debug?} (default: @code{#f})
  23216. When true, the daemon performs additional logging for debugging purposes.
  23217. Note that this will leak encryption details to the log files, use with caution.
  23218. @end table
  23219. @end deftp
  23220. @defvr {Scheme Variable} ganeti-kvmd-service-type
  23221. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  23222. instance was shut down by an administrator or a user. Normally Ganeti will
  23223. restart an instance that was not stopped through Ganeti itself. If the
  23224. cluster option @code{user_shutdown} is true, this daemon monitors the
  23225. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  23226. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  23227. it shuts down gracefully by itself.
  23228. It takes a @code{ganeti-kvmd-configuration} object.
  23229. @end defvr
  23230. @deftp {Data Type} ganeti-kvmd-configuration
  23231. @table @asis
  23232. @item @code{ganeti} (default: @code{ganeti})
  23233. The @code{ganeti} package to use for this service.
  23234. @item @code{debug?} (default: @code{#f})
  23235. When true, the daemon performs additional logging for debugging purposes.
  23236. @end table
  23237. @end deftp
  23238. @defvr {Scheme Variable} ganeti-mond-service-type
  23239. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  23240. functionality. It is responsible for running data collectors and publish the
  23241. collected information through a HTTP interface.
  23242. It takes a @code{ganeti-mond-configuration} object.
  23243. @end defvr
  23244. @deftp {Data Type} ganeti-mond-configuration
  23245. @table @asis
  23246. @item @code{ganeti} (default: @code{ganeti})
  23247. The @code{ganeti} package to use for this service.
  23248. @item @code{port} (default: @code{1815})
  23249. The port on which the daemon will listen.
  23250. @item @code{address} (default: @code{"0.0.0.0"})
  23251. The network address that the daemon will bind to. By default it binds to all
  23252. available interfaces.
  23253. @item @code{debug?} (default: @code{#f})
  23254. When true, the daemon performs additional logging for debugging purposes.
  23255. @end table
  23256. @end deftp
  23257. @defvr {Scheme Variable} ganeti-metad-service-type
  23258. @command{ganeti-metad} is an optional daemon that can be used to provide
  23259. information about the cluster to instances or OS install scripts.
  23260. It takes a @code{ganeti-metad-configuration} object.
  23261. @end defvr
  23262. @deftp {Data Type} ganeti-metad-configuration
  23263. @table @asis
  23264. @item @code{ganeti} (default: @code{ganeti})
  23265. The @code{ganeti} package to use for this service.
  23266. @item @code{port} (default: @code{80})
  23267. The port on which the daemon will listen.
  23268. @item @code{address} (default: @code{#f})
  23269. If set, the daemon will bind to this address only. If left unset, the behavior
  23270. depends on the cluster configuration.
  23271. @item @code{debug?} (default: @code{#f})
  23272. When true, the daemon performs additional logging for debugging purposes.
  23273. @end table
  23274. @end deftp
  23275. @defvr {Scheme Variable} ganeti-watcher-service-type
  23276. @command{ganeti-watcher} is a script designed to run periodically and ensure
  23277. the health of a cluster. It will automatically restart instances that have
  23278. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  23279. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  23280. that are not running. If the cluster parameter @code{ensure_node_health}
  23281. is set, the watcher will also shutdown instances and DRBD devices if the
  23282. node it is running on is declared offline by known master candidates.
  23283. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  23284. The service takes a @code{ganeti-watcher-configuration} object.
  23285. @end defvr
  23286. @deftp {Data Type} ganeti-watcher-configuration
  23287. @table @asis
  23288. @item @code{ganeti} (default: @code{ganeti})
  23289. The @code{ganeti} package to use for this service.
  23290. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  23291. How often to run the script. The default is every five minutes.
  23292. @item @code{rapi-ip} (default: @code{#f})
  23293. This option needs to be specified only if the RAPI daemon is configured to use
  23294. a particular interface or address. By default the cluster address is used.
  23295. @item @code{job-age} (default: @code{(* 6 3600)})
  23296. Archive cluster jobs older than this age, specified in seconds. The default
  23297. is 6 hours. This keeps @command{gnt-job list} manageable.
  23298. @item @code{verify-disks?} (default: @code{#t})
  23299. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  23300. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  23301. manually instead.
  23302. @item @code{debug?} (default: @code{#f})
  23303. When @code{#t}, the script performs additional logging for debugging purposes.
  23304. @end table
  23305. @end deftp
  23306. @defvr {Scheme Variable} ganeti-cleaner-service-type
  23307. @command{ganeti-cleaner} is a script designed to run periodically and remove
  23308. old files from the cluster. This service type controls two @dfn{cron jobs}:
  23309. one intended for the master node that permanently purges old cluster jobs,
  23310. and one intended for every node that removes expired X509 certificates, keys,
  23311. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  23312. it is safe to include even on non-master nodes as it will disable itself as
  23313. necessary.
  23314. It takes a @code{ganeti-cleaner-configuration} object.
  23315. @end defvr
  23316. @deftp {Data Type} ganeti-cleaner-configuration
  23317. @table @asis
  23318. @item @code{ganeti} (default: @code{ganeti})
  23319. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  23320. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  23321. How often to run the master cleaning job. The default is once per day, at
  23322. 01:45:00.
  23323. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  23324. How often to run the node cleaning job. The default is once per day, at
  23325. 02:45:00.
  23326. @end table
  23327. @end deftp
  23328. @node Version Control Services
  23329. @subsection Version Control Services
  23330. The @code{(gnu services version-control)} module provides a service to
  23331. allow remote access to local Git repositories. There are three options:
  23332. the @code{git-daemon-service}, which provides access to repositories via
  23333. the @code{git://} unsecured TCP-based protocol, extending the
  23334. @code{nginx} web server to proxy some requests to
  23335. @code{git-http-backend}, or providing a web interface with
  23336. @code{cgit-service-type}.
  23337. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  23338. Return a service that runs @command{git daemon}, a simple TCP server to
  23339. expose repositories over the Git protocol for anonymous access.
  23340. The optional @var{config} argument should be a
  23341. @code{<git-daemon-configuration>} object, by default it allows read-only
  23342. access to exported@footnote{By creating the magic file
  23343. @file{git-daemon-export-ok} in the repository directory.} repositories under
  23344. @file{/srv/git}.
  23345. @end deffn
  23346. @deftp {Data Type} git-daemon-configuration
  23347. Data type representing the configuration for @code{git-daemon-service}.
  23348. @table @asis
  23349. @item @code{package} (default: @code{git})
  23350. Package object of the Git distributed version control system.
  23351. @item @code{export-all?} (default: @code{#f})
  23352. Whether to allow access for all Git repositories, even if they do not
  23353. have the @file{git-daemon-export-ok} file.
  23354. @item @code{base-path} (default: @file{/srv/git})
  23355. Whether to remap all the path requests as relative to the given path.
  23356. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  23357. @samp{example.com}, then if you later try to pull
  23358. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  23359. path as @file{/srv/git/hello.git}.
  23360. @item @code{user-path} (default: @code{#f})
  23361. Whether to allow @code{~user} notation to be used in requests. When
  23362. specified with empty string, requests to
  23363. @indicateurl{git://host/~alice/foo} is taken as a request to access
  23364. @code{foo} repository in the home directory of user @code{alice}. If
  23365. @code{(user-path "@var{path}")} is specified, the same request is taken
  23366. as a request to access @file{@var{path}/foo} repository in the home
  23367. directory of user @code{alice}.
  23368. @item @code{listen} (default: @code{'()})
  23369. Whether to listen on specific IP addresses or hostnames, defaults to
  23370. all.
  23371. @item @code{port} (default: @code{#f})
  23372. Whether to listen on an alternative port, which defaults to 9418.
  23373. @item @code{whitelist} (default: @code{'()})
  23374. If not empty, only allow access to this list of directories.
  23375. @item @code{extra-options} (default: @code{'()})
  23376. Extra options will be passed to @command{git daemon}, please run
  23377. @command{man git-daemon} for more information.
  23378. @end table
  23379. @end deftp
  23380. The @code{git://} protocol lacks authentication. When you pull from a
  23381. repository fetched via @code{git://}, you don't know whether the data you
  23382. receive was modified or is even coming from the specified host, and your
  23383. connection is subject to eavesdropping. It's better to use an authenticated
  23384. and encrypted transport, such as @code{https}. Although Git allows you
  23385. to serve repositories using unsophisticated file-based web servers,
  23386. there is a faster protocol implemented by the @code{git-http-backend}
  23387. program. This program is the back-end of a proper Git web service. It
  23388. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  23389. on running the necessary @code{fcgiwrap} daemon.
  23390. Guix has a separate configuration data type for serving Git repositories
  23391. over HTTP.
  23392. @deftp {Data Type} git-http-configuration
  23393. Data type representing the configuration for a future
  23394. @code{git-http-service-type}; can currently be used to configure Nginx
  23395. through @code{git-http-nginx-location-configuration}.
  23396. @table @asis
  23397. @item @code{package} (default: @var{git})
  23398. Package object of the Git distributed version control system.
  23399. @item @code{git-root} (default: @file{/srv/git})
  23400. Directory containing the Git repositories to expose to the world.
  23401. @item @code{export-all?} (default: @code{#f})
  23402. Whether to expose access for all Git repositories in @var{git-root},
  23403. even if they do not have the @file{git-daemon-export-ok} file.
  23404. @item @code{uri-path} (default: @samp{/git/})
  23405. Path prefix for Git access. With the default @samp{/git/} prefix, this
  23406. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  23407. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  23408. with this prefix are not passed on to this Git instance.
  23409. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  23410. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  23411. Services}.
  23412. @end table
  23413. @end deftp
  23414. There is no @code{git-http-service-type}, currently; instead you can
  23415. create an @code{nginx-location-configuration} from a
  23416. @code{git-http-configuration} and then add that location to a web
  23417. server.
  23418. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  23419. [config=(git-http-configuration)]
  23420. Compute an @code{nginx-location-configuration} that corresponds to the
  23421. given Git http configuration. An example nginx service definition to
  23422. serve the default @file{/srv/git} over HTTPS might be:
  23423. @lisp
  23424. (service nginx-service-type
  23425. (nginx-configuration
  23426. (server-blocks
  23427. (list
  23428. (nginx-server-configuration
  23429. (listen '("443 ssl"))
  23430. (server-name "git.my-host.org")
  23431. (ssl-certificate
  23432. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  23433. (ssl-certificate-key
  23434. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  23435. (locations
  23436. (list
  23437. (git-http-nginx-location-configuration
  23438. (git-http-configuration (uri-path "/"))))))))))
  23439. @end lisp
  23440. This example assumes that you are using Let's Encrypt to get your TLS
  23441. certificate. @xref{Certificate Services}. The default @code{certbot}
  23442. service will redirect all HTTP traffic on @code{git.my-host.org} to
  23443. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  23444. system services. @xref{Web Services}.
  23445. @end deffn
  23446. @subsubheading Cgit Service
  23447. @cindex Cgit service
  23448. @cindex Git, web interface
  23449. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  23450. repositories written in C.
  23451. The following example will configure the service with default values.
  23452. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  23453. @lisp
  23454. (service cgit-service-type)
  23455. @end lisp
  23456. The @code{file-object} type designates either a file-like object
  23457. (@pxref{G-Expressions, file-like objects}) or a string.
  23458. @c %start of fragment
  23459. Available @code{cgit-configuration} fields are:
  23460. @deftypevr {@code{cgit-configuration} parameter} package package
  23461. The CGIT package.
  23462. @end deftypevr
  23463. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  23464. NGINX configuration.
  23465. @end deftypevr
  23466. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  23467. Specifies a command which will be invoked to format the content of about
  23468. pages (both top-level and for each repository).
  23469. Defaults to @samp{""}.
  23470. @end deftypevr
  23471. @deftypevr {@code{cgit-configuration} parameter} string agefile
  23472. Specifies a path, relative to each repository path, which can be used to
  23473. specify the date and time of the youngest commit in the repository.
  23474. Defaults to @samp{""}.
  23475. @end deftypevr
  23476. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  23477. Specifies a command that will be invoked for authenticating repository
  23478. access.
  23479. Defaults to @samp{""}.
  23480. @end deftypevr
  23481. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  23482. Flag which, when set to @samp{age}, enables date ordering in the branch
  23483. ref list, and when set @samp{name} enables ordering by branch name.
  23484. Defaults to @samp{"name"}.
  23485. @end deftypevr
  23486. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  23487. Path used to store the cgit cache entries.
  23488. Defaults to @samp{"/var/cache/cgit"}.
  23489. @end deftypevr
  23490. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  23491. Number which specifies the time-to-live, in minutes, for the cached
  23492. version of repository pages accessed with a fixed SHA1.
  23493. Defaults to @samp{-1}.
  23494. @end deftypevr
  23495. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  23496. Number which specifies the time-to-live, in minutes, for the cached
  23497. version of repository pages accessed without a fixed SHA1.
  23498. Defaults to @samp{5}.
  23499. @end deftypevr
  23500. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  23501. Number which specifies the time-to-live, in minutes, for the cached
  23502. version of the repository summary page.
  23503. Defaults to @samp{5}.
  23504. @end deftypevr
  23505. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  23506. Number which specifies the time-to-live, in minutes, for the cached
  23507. version of the repository index page.
  23508. Defaults to @samp{5}.
  23509. @end deftypevr
  23510. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  23511. Number which specifies the time-to-live, in minutes, for the result of
  23512. scanning a path for Git repositories.
  23513. Defaults to @samp{15}.
  23514. @end deftypevr
  23515. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  23516. Number which specifies the time-to-live, in minutes, for the cached
  23517. version of the repository about page.
  23518. Defaults to @samp{15}.
  23519. @end deftypevr
  23520. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  23521. Number which specifies the time-to-live, in minutes, for the cached
  23522. version of snapshots.
  23523. Defaults to @samp{5}.
  23524. @end deftypevr
  23525. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  23526. The maximum number of entries in the cgit cache. When set to @samp{0},
  23527. caching is disabled.
  23528. Defaults to @samp{0}.
  23529. @end deftypevr
  23530. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  23531. Sort items in the repo list case sensitively.
  23532. Defaults to @samp{#t}.
  23533. @end deftypevr
  23534. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  23535. List of common prefixes which, when combined with a repository URL,
  23536. generates valid clone URLs for the repository.
  23537. Defaults to @samp{()}.
  23538. @end deftypevr
  23539. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  23540. List of @code{clone-url} templates.
  23541. Defaults to @samp{()}.
  23542. @end deftypevr
  23543. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  23544. Command which will be invoked to format commit messages.
  23545. Defaults to @samp{""}.
  23546. @end deftypevr
  23547. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  23548. Flag which, when set to @samp{date}, enables strict date ordering in the
  23549. commit log, and when set to @samp{topo} enables strict topological
  23550. ordering.
  23551. Defaults to @samp{"git log"}.
  23552. @end deftypevr
  23553. @deftypevr {@code{cgit-configuration} parameter} file-object css
  23554. URL which specifies the css document to include in all cgit pages.
  23555. Defaults to @samp{"/share/cgit/cgit.css"}.
  23556. @end deftypevr
  23557. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  23558. Specifies a command which will be invoked to format names and email
  23559. address of committers, authors, and taggers, as represented in various
  23560. places throughout the cgit interface.
  23561. Defaults to @samp{""}.
  23562. @end deftypevr
  23563. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  23564. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  23565. fragment suitable for embedding in other HTML pages.
  23566. Defaults to @samp{#f}.
  23567. @end deftypevr
  23568. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  23569. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  23570. commit history graph to the left of the commit messages in the
  23571. repository log page.
  23572. Defaults to @samp{#f}.
  23573. @end deftypevr
  23574. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  23575. Flag which, when set to @samp{#t}, allows all filter settings to be
  23576. overridden in repository-specific cgitrc files.
  23577. Defaults to @samp{#f}.
  23578. @end deftypevr
  23579. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  23580. Flag which, when set to @samp{#t}, allows users to follow a file in the
  23581. log view.
  23582. Defaults to @samp{#f}.
  23583. @end deftypevr
  23584. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  23585. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  23586. clones.
  23587. Defaults to @samp{#t}.
  23588. @end deftypevr
  23589. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  23590. Flag which, when set to @samp{#t}, will make cgit generate extra links
  23591. "summary", "commit", "tree" for each repo in the repository index.
  23592. Defaults to @samp{#f}.
  23593. @end deftypevr
  23594. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  23595. Flag which, when set to @samp{#t}, will make cgit display the owner of
  23596. each repo in the repository index.
  23597. Defaults to @samp{#t}.
  23598. @end deftypevr
  23599. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  23600. Flag which, when set to @samp{#t}, will make cgit print the number of
  23601. modified files for each commit on the repository log page.
  23602. Defaults to @samp{#f}.
  23603. @end deftypevr
  23604. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  23605. Flag which, when set to @samp{#t}, will make cgit print the number of
  23606. added and removed lines for each commit on the repository log page.
  23607. Defaults to @samp{#f}.
  23608. @end deftypevr
  23609. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  23610. Flag which, when set to @code{#t}, will make cgit display remote
  23611. branches in the summary and refs views.
  23612. Defaults to @samp{#f}.
  23613. @end deftypevr
  23614. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  23615. Flag which, when set to @code{1}, will make cgit use the subject of the
  23616. parent commit as link text when generating links to parent commits in
  23617. commit view.
  23618. Defaults to @samp{#f}.
  23619. @end deftypevr
  23620. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  23621. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  23622. parent commit as link text when generating links to parent commits in
  23623. commit view.
  23624. Defaults to @samp{#f}.
  23625. @end deftypevr
  23626. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  23627. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  23628. links for plaintext blobs printed in the tree view.
  23629. Defaults to @samp{#t}.
  23630. @end deftypevr
  23631. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  23632. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  23633. set any repo specific settings.
  23634. Defaults to @samp{#f}.
  23635. @end deftypevr
  23636. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  23637. URL used as link to a shortcut icon for cgit.
  23638. Defaults to @samp{"/favicon.ico"}.
  23639. @end deftypevr
  23640. @deftypevr {@code{cgit-configuration} parameter} string footer
  23641. The content of the file specified with this option will be included
  23642. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  23643. "generated by..."@: message).
  23644. Defaults to @samp{""}.
  23645. @end deftypevr
  23646. @deftypevr {@code{cgit-configuration} parameter} string head-include
  23647. The content of the file specified with this option will be included
  23648. verbatim in the HTML HEAD section on all pages.
  23649. Defaults to @samp{""}.
  23650. @end deftypevr
  23651. @deftypevr {@code{cgit-configuration} parameter} string header
  23652. The content of the file specified with this option will be included
  23653. verbatim at the top of all pages.
  23654. Defaults to @samp{""}.
  23655. @end deftypevr
  23656. @deftypevr {@code{cgit-configuration} parameter} file-object include
  23657. Name of a configfile to include before the rest of the current config-
  23658. file is parsed.
  23659. Defaults to @samp{""}.
  23660. @end deftypevr
  23661. @deftypevr {@code{cgit-configuration} parameter} string index-header
  23662. The content of the file specified with this option will be included
  23663. verbatim above the repository index.
  23664. Defaults to @samp{""}.
  23665. @end deftypevr
  23666. @deftypevr {@code{cgit-configuration} parameter} string index-info
  23667. The content of the file specified with this option will be included
  23668. verbatim below the heading on the repository index page.
  23669. Defaults to @samp{""}.
  23670. @end deftypevr
  23671. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  23672. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  23673. in the servers timezone.
  23674. Defaults to @samp{#f}.
  23675. @end deftypevr
  23676. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  23677. URL which specifies the source of an image which will be used as a logo
  23678. on all cgit pages.
  23679. Defaults to @samp{"/share/cgit/cgit.png"}.
  23680. @end deftypevr
  23681. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  23682. URL loaded when clicking on the cgit logo image.
  23683. Defaults to @samp{""}.
  23684. @end deftypevr
  23685. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  23686. Command which will be invoked to format the Owner column of the main
  23687. page.
  23688. Defaults to @samp{""}.
  23689. @end deftypevr
  23690. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  23691. Number of items to display in atom feeds view.
  23692. Defaults to @samp{10}.
  23693. @end deftypevr
  23694. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  23695. Number of entries to list per page in "log" view.
  23696. Defaults to @samp{50}.
  23697. @end deftypevr
  23698. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  23699. Number of commit message characters to display in "log" view.
  23700. Defaults to @samp{80}.
  23701. @end deftypevr
  23702. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  23703. Specifies the number of entries to list per page on the repository index
  23704. page.
  23705. Defaults to @samp{50}.
  23706. @end deftypevr
  23707. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  23708. Specifies the maximum number of repo description characters to display
  23709. on the repository index page.
  23710. Defaults to @samp{80}.
  23711. @end deftypevr
  23712. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  23713. Specifies the maximum size of a blob to display HTML for in KBytes.
  23714. Defaults to @samp{0}.
  23715. @end deftypevr
  23716. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  23717. Maximum statistics period. Valid values are @samp{week},@samp{month},
  23718. @samp{quarter} and @samp{year}.
  23719. Defaults to @samp{""}.
  23720. @end deftypevr
  23721. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  23722. Mimetype for the specified filename extension.
  23723. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  23724. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  23725. "image/png") (svg "image/svg+xml"))}.
  23726. @end deftypevr
  23727. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  23728. Specifies the file to use for automatic mimetype lookup.
  23729. Defaults to @samp{""}.
  23730. @end deftypevr
  23731. @deftypevr {@code{cgit-configuration} parameter} string module-link
  23732. Text which will be used as the formatstring for a hyperlink when a
  23733. submodule is printed in a directory listing.
  23734. Defaults to @samp{""}.
  23735. @end deftypevr
  23736. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  23737. If set to the value @samp{#t} caching will be disabled.
  23738. Defaults to @samp{#f}.
  23739. @end deftypevr
  23740. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  23741. If set to @samp{#t} showing full author email addresses will be
  23742. disabled.
  23743. Defaults to @samp{#f}.
  23744. @end deftypevr
  23745. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  23746. Flag which, when set to @samp{#t}, will make cgit omit the standard
  23747. header on all pages.
  23748. Defaults to @samp{#f}.
  23749. @end deftypevr
  23750. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  23751. A list of subdirectories inside of @code{repository-directory}, relative
  23752. to it, that should loaded as Git repositories. An empty list means that
  23753. all subdirectories will be loaded.
  23754. Defaults to @samp{()}.
  23755. @end deftypevr
  23756. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  23757. Text which will be used as default value for @code{cgit-repo-readme}.
  23758. Defaults to @samp{""}.
  23759. @end deftypevr
  23760. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  23761. If set to @code{#t} and @code{repository-directory} is enabled, if any
  23762. repositories are found with a suffix of @code{.git}, this suffix will be
  23763. removed for the URL and name.
  23764. Defaults to @samp{#f}.
  23765. @end deftypevr
  23766. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  23767. Maximum number of files to consider when detecting renames.
  23768. Defaults to @samp{-1}.
  23769. @end deftypevr
  23770. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  23771. The way in which repositories in each section are sorted.
  23772. Defaults to @samp{""}.
  23773. @end deftypevr
  23774. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  23775. Text used as content for the @code{robots} meta-tag.
  23776. Defaults to @samp{("noindex" "nofollow")}.
  23777. @end deftypevr
  23778. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  23779. Text printed below the heading on the repository index page.
  23780. Defaults to @samp{"a fast webinterface for the git dscm"}.
  23781. @end deftypevr
  23782. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  23783. The content of the file specified with this option will be included
  23784. verbatim below the ``about'' link on the repository index page.
  23785. Defaults to @samp{""}.
  23786. @end deftypevr
  23787. @deftypevr {@code{cgit-configuration} parameter} string root-title
  23788. Text printed as heading on the repository index page.
  23789. Defaults to @samp{""}.
  23790. @end deftypevr
  23791. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  23792. If set to @samp{#t} and repository-directory is enabled,
  23793. repository-directory will recurse into directories whose name starts
  23794. with a period. Otherwise, repository-directory will stay away from such
  23795. directories, considered as ``hidden''. Note that this does not apply to
  23796. the @file{.git} directory in non-bare repos.
  23797. Defaults to @samp{#f}.
  23798. @end deftypevr
  23799. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  23800. Text which specifies the default set of snapshot formats that cgit
  23801. generates links for.
  23802. Defaults to @samp{()}.
  23803. @end deftypevr
  23804. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  23805. Name of the directory to scan for repositories (represents
  23806. @code{scan-path}).
  23807. Defaults to @samp{"/srv/git"}.
  23808. @end deftypevr
  23809. @deftypevr {@code{cgit-configuration} parameter} string section
  23810. The name of the current repository section - all repositories defined
  23811. after this option will inherit the current section name.
  23812. Defaults to @samp{""}.
  23813. @end deftypevr
  23814. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  23815. Flag which, when set to @samp{1}, will sort the sections on the
  23816. repository listing by name.
  23817. Defaults to @samp{""}.
  23818. @end deftypevr
  23819. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  23820. A number which, if defined prior to repository-directory, specifies how
  23821. many path elements from each repo path to use as a default section name.
  23822. Defaults to @samp{0}.
  23823. @end deftypevr
  23824. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  23825. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  23826. default.
  23827. Defaults to @samp{#f}.
  23828. @end deftypevr
  23829. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  23830. Specifies a command which will be invoked to format plaintext blobs in
  23831. the tree view.
  23832. Defaults to @samp{""}.
  23833. @end deftypevr
  23834. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  23835. Specifies the number of branches to display in the repository ``summary''
  23836. view.
  23837. Defaults to @samp{10}.
  23838. @end deftypevr
  23839. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  23840. Specifies the number of log entries to display in the repository
  23841. ``summary'' view.
  23842. Defaults to @samp{10}.
  23843. @end deftypevr
  23844. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  23845. Specifies the number of tags to display in the repository ``summary''
  23846. view.
  23847. Defaults to @samp{10}.
  23848. @end deftypevr
  23849. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  23850. Filename which, if specified, needs to be present within the repository
  23851. for cgit to allow access to that repository.
  23852. Defaults to @samp{""}.
  23853. @end deftypevr
  23854. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  23855. URL which, if specified, will be used as root for all cgit links.
  23856. Defaults to @samp{"/"}.
  23857. @end deftypevr
  23858. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  23859. A list of @dfn{cgit-repo} records to use with config.
  23860. Defaults to @samp{()}.
  23861. Available @code{repository-cgit-configuration} fields are:
  23862. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  23863. A mask of snapshot formats for this repo that cgit generates links for,
  23864. restricted by the global @code{snapshots} setting.
  23865. Defaults to @samp{()}.
  23866. @end deftypevr
  23867. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  23868. Override the default @code{source-filter}.
  23869. Defaults to @samp{""}.
  23870. @end deftypevr
  23871. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  23872. The relative URL used to access the repository.
  23873. Defaults to @samp{""}.
  23874. @end deftypevr
  23875. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  23876. Override the default @code{about-filter}.
  23877. Defaults to @samp{""}.
  23878. @end deftypevr
  23879. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  23880. Flag which, when set to @samp{age}, enables date ordering in the branch
  23881. ref list, and when set to @samp{name} enables ordering by branch name.
  23882. Defaults to @samp{""}.
  23883. @end deftypevr
  23884. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  23885. A list of URLs which can be used to clone repo.
  23886. Defaults to @samp{()}.
  23887. @end deftypevr
  23888. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  23889. Override the default @code{commit-filter}.
  23890. Defaults to @samp{""}.
  23891. @end deftypevr
  23892. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  23893. Flag which, when set to @samp{date}, enables strict date ordering in the
  23894. commit log, and when set to @samp{topo} enables strict topological
  23895. ordering.
  23896. Defaults to @samp{""}.
  23897. @end deftypevr
  23898. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  23899. The name of the default branch for this repository. If no such branch
  23900. exists in the repository, the first branch name (when sorted) is used as
  23901. default instead. By default branch pointed to by HEAD, or ``master'' if
  23902. there is no suitable HEAD.
  23903. Defaults to @samp{""}.
  23904. @end deftypevr
  23905. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  23906. The value to show as repository description.
  23907. Defaults to @samp{""}.
  23908. @end deftypevr
  23909. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  23910. The value to show as repository homepage.
  23911. Defaults to @samp{""}.
  23912. @end deftypevr
  23913. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  23914. Override the default @code{email-filter}.
  23915. Defaults to @samp{""}.
  23916. @end deftypevr
  23917. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  23918. A flag which can be used to disable the global setting
  23919. @code{enable-commit-graph?}.
  23920. Defaults to @samp{disabled}.
  23921. @end deftypevr
  23922. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  23923. A flag which can be used to disable the global setting
  23924. @code{enable-log-filecount?}.
  23925. Defaults to @samp{disabled}.
  23926. @end deftypevr
  23927. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  23928. A flag which can be used to disable the global setting
  23929. @code{enable-log-linecount?}.
  23930. Defaults to @samp{disabled}.
  23931. @end deftypevr
  23932. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  23933. Flag which, when set to @code{#t}, will make cgit display remote
  23934. branches in the summary and refs views.
  23935. Defaults to @samp{disabled}.
  23936. @end deftypevr
  23937. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  23938. A flag which can be used to override the global setting
  23939. @code{enable-subject-links?}.
  23940. Defaults to @samp{disabled}.
  23941. @end deftypevr
  23942. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  23943. A flag which can be used to override the global setting
  23944. @code{enable-html-serving?}.
  23945. Defaults to @samp{disabled}.
  23946. @end deftypevr
  23947. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  23948. Flag which, when set to @code{#t}, hides the repository from the
  23949. repository index.
  23950. Defaults to @samp{#f}.
  23951. @end deftypevr
  23952. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  23953. Flag which, when set to @samp{#t}, ignores the repository.
  23954. Defaults to @samp{#f}.
  23955. @end deftypevr
  23956. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  23957. URL which specifies the source of an image which will be used as a logo
  23958. on this repo’s pages.
  23959. Defaults to @samp{""}.
  23960. @end deftypevr
  23961. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  23962. URL loaded when clicking on the cgit logo image.
  23963. Defaults to @samp{""}.
  23964. @end deftypevr
  23965. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  23966. Override the default @code{owner-filter}.
  23967. Defaults to @samp{""}.
  23968. @end deftypevr
  23969. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  23970. Text which will be used as the formatstring for a hyperlink when a
  23971. submodule is printed in a directory listing. The arguments for the
  23972. formatstring are the path and SHA1 of the submodule commit.
  23973. Defaults to @samp{""}.
  23974. @end deftypevr
  23975. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  23976. Text which will be used as the formatstring for a hyperlink when a
  23977. submodule with the specified subdirectory path is printed in a directory
  23978. listing.
  23979. Defaults to @samp{()}.
  23980. @end deftypevr
  23981. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  23982. Override the default maximum statistics period.
  23983. Defaults to @samp{""}.
  23984. @end deftypevr
  23985. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  23986. The value to show as repository name.
  23987. Defaults to @samp{""}.
  23988. @end deftypevr
  23989. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  23990. A value used to identify the owner of the repository.
  23991. Defaults to @samp{""}.
  23992. @end deftypevr
  23993. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  23994. An absolute path to the repository directory.
  23995. Defaults to @samp{""}.
  23996. @end deftypevr
  23997. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  23998. A path (relative to repo) which specifies a file to include verbatim as
  23999. the ``About'' page for this repo.
  24000. Defaults to @samp{""}.
  24001. @end deftypevr
  24002. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  24003. The name of the current repository section - all repositories defined
  24004. after this option will inherit the current section name.
  24005. Defaults to @samp{""}.
  24006. @end deftypevr
  24007. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  24008. Extra options will be appended to cgitrc file.
  24009. Defaults to @samp{()}.
  24010. @end deftypevr
  24011. @end deftypevr
  24012. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  24013. Extra options will be appended to cgitrc file.
  24014. Defaults to @samp{()}.
  24015. @end deftypevr
  24016. @c %end of fragment
  24017. However, it could be that you just want to get a @code{cgitrc} up and
  24018. running. In that case, you can pass an @code{opaque-cgit-configuration}
  24019. as a record to @code{cgit-service-type}. As its name indicates, an
  24020. opaque configuration does not have easy reflective capabilities.
  24021. Available @code{opaque-cgit-configuration} fields are:
  24022. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  24023. The cgit package.
  24024. @end deftypevr
  24025. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  24026. The contents of the @code{cgitrc}, as a string.
  24027. @end deftypevr
  24028. For example, if your @code{cgitrc} is just the empty string, you
  24029. could instantiate a cgit service like this:
  24030. @lisp
  24031. (service cgit-service-type
  24032. (opaque-cgit-configuration
  24033. (cgitrc "")))
  24034. @end lisp
  24035. @subsubheading Gitolite Service
  24036. @cindex Gitolite service
  24037. @cindex Git, hosting
  24038. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  24039. repositories on a central server.
  24040. Gitolite can handle multiple repositories and users, and supports flexible
  24041. configuration of the permissions for the users on the repositories.
  24042. The following example will configure Gitolite using the default @code{git}
  24043. user, and the provided SSH public key.
  24044. @lisp
  24045. (service gitolite-service-type
  24046. (gitolite-configuration
  24047. (admin-pubkey (plain-file
  24048. "yourname.pub"
  24049. "ssh-rsa AAAA... guix@@example.com"))))
  24050. @end lisp
  24051. Gitolite is configured through a special admin repository which you can clone,
  24052. for example, if you setup Gitolite on @code{example.com}, you would run the
  24053. following command to clone the admin repository.
  24054. @example
  24055. git clone git@@example.com:gitolite-admin
  24056. @end example
  24057. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  24058. be inserted in to the @file{keydir} directory in the gitolite-admin
  24059. repository. If this results in a change in the repository, it will be
  24060. committed using the message ``gitolite setup by GNU Guix''.
  24061. @deftp {Data Type} gitolite-configuration
  24062. Data type representing the configuration for @code{gitolite-service-type}.
  24063. @table @asis
  24064. @item @code{package} (default: @var{gitolite})
  24065. Gitolite package to use.
  24066. @item @code{user} (default: @var{git})
  24067. User to use for Gitolite. This will be user that you use when accessing
  24068. Gitolite over SSH.
  24069. @item @code{group} (default: @var{git})
  24070. Group to use for Gitolite.
  24071. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  24072. Directory in which to store the Gitolite configuration and repositories.
  24073. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  24074. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  24075. representing the configuration for Gitolite.
  24076. @item @code{admin-pubkey} (default: @var{#f})
  24077. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  24078. setup Gitolite. This will be inserted in to the @file{keydir} directory
  24079. within the gitolite-admin repository.
  24080. To specify the SSH key as a string, use the @code{plain-file} function.
  24081. @lisp
  24082. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  24083. @end lisp
  24084. @end table
  24085. @end deftp
  24086. @deftp {Data Type} gitolite-rc-file
  24087. Data type representing the Gitolite RC file.
  24088. @table @asis
  24089. @item @code{umask} (default: @code{#o0077})
  24090. This controls the permissions Gitolite sets on the repositories and their
  24091. contents.
  24092. A value like @code{#o0027} will give read access to the group used by Gitolite
  24093. (by default: @code{git}). This is necessary when using Gitolite with software
  24094. like cgit or gitweb.
  24095. @item @code{git-config-keys} (default: @code{""})
  24096. Gitolite allows you to set git config values using the @samp{config}
  24097. keyword. This setting allows control over the config keys to accept.
  24098. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  24099. Set the role names allowed to be used by users running the perms command.
  24100. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  24101. This setting controls the commands and features to enable within Gitolite.
  24102. @end table
  24103. @end deftp
  24104. @node Game Services
  24105. @subsection Game Services
  24106. @subsubheading The Battle for Wesnoth Service
  24107. @cindex wesnothd
  24108. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  24109. based tactical strategy game, with several single player campaigns, and
  24110. multiplayer games (both networked and local).
  24111. @defvar {Scheme Variable} wesnothd-service-type
  24112. Service type for the wesnothd service. Its value must be a
  24113. @code{wesnothd-configuration} object. To run wesnothd in the default
  24114. configuration, instantiate it as:
  24115. @lisp
  24116. (service wesnothd-service-type)
  24117. @end lisp
  24118. @end defvar
  24119. @deftp {Data Type} wesnothd-configuration
  24120. Data type representing the configuration of @command{wesnothd}.
  24121. @table @asis
  24122. @item @code{package} (default: @code{wesnoth-server})
  24123. The wesnoth server package to use.
  24124. @item @code{port} (default: @code{15000})
  24125. The port to bind the server to.
  24126. @end table
  24127. @end deftp
  24128. @node PAM Mount Service
  24129. @subsection PAM Mount Service
  24130. @cindex pam-mount
  24131. The @code{(gnu services pam-mount)} module provides a service allowing
  24132. users to mount volumes when they log in. It should be able to mount any
  24133. volume format supported by the system.
  24134. @defvar {Scheme Variable} pam-mount-service-type
  24135. Service type for PAM Mount support.
  24136. @end defvar
  24137. @deftp {Data Type} pam-mount-configuration
  24138. Data type representing the configuration of PAM Mount.
  24139. It takes the following parameters:
  24140. @table @asis
  24141. @item @code{rules}
  24142. The configuration rules that will be used to generate
  24143. @file{/etc/security/pam_mount.conf.xml}.
  24144. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  24145. Guile Reference Manual}), and the default ones don't mount anything for
  24146. anyone at login:
  24147. @lisp
  24148. `((debug (@@ (enable "0")))
  24149. (mntoptions (@@ (allow ,(string-join
  24150. '("nosuid" "nodev" "loop"
  24151. "encryption" "fsck" "nonempty"
  24152. "allow_root" "allow_other")
  24153. ","))))
  24154. (mntoptions (@@ (require "nosuid,nodev")))
  24155. (logout (@@ (wait "0")
  24156. (hup "0")
  24157. (term "no")
  24158. (kill "no")))
  24159. (mkmountpoint (@@ (enable "1")
  24160. (remove "true"))))
  24161. @end lisp
  24162. Some @code{volume} elements must be added to automatically mount volumes
  24163. at login. Here's an example allowing the user @code{alice} to mount her
  24164. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  24165. the partition where he stores his data:
  24166. @lisp
  24167. (define pam-mount-rules
  24168. `((debug (@@ (enable "0")))
  24169. (volume (@@ (user "alice")
  24170. (fstype "crypt")
  24171. (path "/dev/sda2")
  24172. (mountpoint "/home/alice")))
  24173. (volume (@@ (user "bob")
  24174. (fstype "auto")
  24175. (path "/dev/sdb3")
  24176. (mountpoint "/home/bob/data")
  24177. (options "defaults,autodefrag,compress")))
  24178. (mntoptions (@@ (allow ,(string-join
  24179. '("nosuid" "nodev" "loop"
  24180. "encryption" "fsck" "nonempty"
  24181. "allow_root" "allow_other")
  24182. ","))))
  24183. (mntoptions (@@ (require "nosuid,nodev")))
  24184. (logout (@@ (wait "0")
  24185. (hup "0")
  24186. (term "no")
  24187. (kill "no")))
  24188. (mkmountpoint (@@ (enable "1")
  24189. (remove "true")))))
  24190. (service pam-mount-service-type
  24191. (pam-mount-configuration
  24192. (rules pam-mount-rules)))
  24193. @end lisp
  24194. The complete list of possible options can be found in the man page for
  24195. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  24196. @end table
  24197. @end deftp
  24198. @node Guix Services
  24199. @subsection Guix Services
  24200. @subsubheading Guix Build Coordinator
  24201. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  24202. Coordinator} aids in distributing derivation builds among machines
  24203. running an @dfn{agent}. The build daemon is still used to build the
  24204. derivations, but the Guix Build Coordinator manages allocating builds
  24205. and working with the results.
  24206. @quotation Note
  24207. This service is considered experimental. Configuration options may be
  24208. changed in a backwards-incompatible manner, and not all features have
  24209. been thorougly tested.
  24210. @end quotation
  24211. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  24212. more connected @dfn{agent} processes. The coordinator process handles
  24213. clients submitting builds, and allocating builds to agents. The agent
  24214. processes talk to a build daemon to actually perform the builds, then
  24215. send the results back to the coordinator.
  24216. There is a script to run the coordinator component of the Guix Build
  24217. Coordinator, but the Guix service uses a custom Guile script instead, to
  24218. provide better integration with G-expressions used in the configuration.
  24219. @defvar {Scheme Variable} guix-build-coordinator-service-type
  24220. Service type for the Guix Build Coordinator. Its value must be a
  24221. @code{guix-build-coordinator-configuration} object.
  24222. @end defvar
  24223. @deftp {Data Type} guix-build-coordinator-configuration
  24224. Data type representing the configuration of the Guix Build Coordinator.
  24225. @table @asis
  24226. @item @code{package} (default: @code{guix-build-coordinator})
  24227. The Guix Build Coordinator package to use.
  24228. @item @code{user} (default: @code{"guix-build-coordinator"})
  24229. The system user to run the service as.
  24230. @item @code{group} (default: @code{"guix-build-coordinator"})
  24231. The system group to run the service as.
  24232. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  24233. The URI to use for the database.
  24234. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  24235. The URI describing how to listen to requests from agent processes.
  24236. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  24237. The URI describing how to listen to requests from clients. The client
  24238. API allows submitting builds and currently isn't authenticated, so take
  24239. care when configuring this value.
  24240. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  24241. A G-expression for the allocation strategy to be used. This is a
  24242. procedure that takes the datastore as an argument and populates the
  24243. allocation plan in the database.
  24244. @item @code{hooks} (default: @var{'()})
  24245. An association list of hooks. These provide a way to execute arbitrary
  24246. code upon certain events, like a build result being processed.
  24247. @item @code{guile} (default: @code{guile-3.0-latest})
  24248. The Guile package with which to run the Guix Build Coordinator.
  24249. @end table
  24250. @end deftp
  24251. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  24252. Service type for a Guix Build Coordinator agent. Its value must be a
  24253. @code{guix-build-coordinator-agent-configuration} object.
  24254. @end defvar
  24255. @deftp {Data Type} guix-build-coordinator-agent-configuration
  24256. Data type representing the configuration a Guix Build Coordinator agent.
  24257. @table @asis
  24258. @item @code{package} (default: @code{guix-build-coordinator})
  24259. The Guix Build Coordinator package to use.
  24260. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  24261. The system user to run the service as.
  24262. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  24263. The URI to use when connecting to the coordinator.
  24264. @item @code{authentication}
  24265. Record describing how this agent should authenticate with the
  24266. coordinator. Possible record types are described below.
  24267. @item @code{systems} (default: @code{#f})
  24268. The systems for which this agent should fetch builds. The agent process
  24269. will use the current system it's running on as the default.
  24270. @item @code{max-parallel-builds} (default: @code{1})
  24271. The number of builds to perform in parallel.
  24272. @item @code{derivation-substitute-urls} (default: @code{#f})
  24273. URLs from which to attempt to fetch substitutes for derivations, if the
  24274. derivations aren't already available.
  24275. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  24276. URLs from which to attempt to fetch substitutes for build inputs, if the
  24277. input store items aren't already available.
  24278. @end table
  24279. @end deftp
  24280. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  24281. Data type representing an agent authenticating with a coordinator via a
  24282. UUID and password.
  24283. @table @asis
  24284. @item @code{uuid}
  24285. The UUID of the agent. This should be generated by the coordinator
  24286. process, stored in the coordinator database, and used by the intended
  24287. agent.
  24288. @item @code{password}
  24289. The password to use when connecting to the coordinator.
  24290. @end table
  24291. @end deftp
  24292. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  24293. Data type representing an agent authenticating with a coordinator via a
  24294. UUID and password read from a file.
  24295. @table @asis
  24296. @item @code{uuid}
  24297. The UUID of the agent. This should be generated by the coordinator
  24298. process, stored in the coordinator database, and used by the intended
  24299. agent.
  24300. @item @code{password-file}
  24301. A file containing the password to use when connecting to the
  24302. coordinator.
  24303. @end table
  24304. @end deftp
  24305. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  24306. Data type representing an agent authenticating with a coordinator via a
  24307. dynamic auth token and agent name.
  24308. @table @asis
  24309. @item @code{agent-name}
  24310. Name of an agent, this is used to match up to an existing entry in the
  24311. database if there is one. When no existing entry is found, a new entry
  24312. is automatically added.
  24313. @item @code{token}
  24314. Dynamic auth token, this is created and stored in the coordinator
  24315. database, and is used by the agent to authenticate.
  24316. @end table
  24317. @end deftp
  24318. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  24319. Data type representing an agent authenticating with a coordinator via a
  24320. dynamic auth token read from a file and agent name.
  24321. @table @asis
  24322. @item @code{agent-name}
  24323. Name of an agent, this is used to match up to an existing entry in the
  24324. database if there is one. When no existing entry is found, a new entry
  24325. is automatically added.
  24326. @item @code{token-file}
  24327. File containing the dynamic auth token, this is created and stored in
  24328. the coordinator database, and is used by the agent to authenticate.
  24329. @end table
  24330. @end deftp
  24331. The Guix Build Coordinator package contains a script to query an
  24332. instance of the Guix Data Service for derivations to build, and then
  24333. submit builds for those derivations to the coordinator. The service
  24334. type below assists in running this script. This is an additional tool
  24335. that may be useful when building derivations contained within an
  24336. instance of the Guix Data Service.
  24337. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  24338. Service type for the
  24339. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  24340. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  24341. object.
  24342. @end defvar
  24343. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  24344. Data type representing the options to the queue builds from guix data
  24345. service script.
  24346. @table @asis
  24347. @item @code{package} (default: @code{guix-build-coordinator})
  24348. The Guix Build Coordinator package to use.
  24349. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  24350. The system user to run the service as.
  24351. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  24352. The URI to use when connecting to the coordinator.
  24353. @item @code{systems} (default: @code{#f})
  24354. The systems for which to fetch derivations to build.
  24355. @item @code{systems-and-targets} (default: @code{#f})
  24356. An association list of system and target pairs for which to fetch
  24357. derivations to build.
  24358. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  24359. The Guix Data Service instance from which to query to find out about
  24360. derivations to build.
  24361. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  24362. A file to record which commits have been processed, to avoid needlessly
  24363. processing them again if the service is restarted.
  24364. @end table
  24365. @end deftp
  24366. @subsubheading Guix Data Service
  24367. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  24368. and provides data about GNU Guix. This includes information about
  24369. packages, derivations and lint warnings.
  24370. The data is stored in a PostgreSQL database, and available through a web
  24371. interface.
  24372. @defvar {Scheme Variable} guix-data-service-type
  24373. Service type for the Guix Data Service. Its value must be a
  24374. @code{guix-data-service-configuration} object. The service optionally
  24375. extends the getmail service, as the guix-commits mailing list is used to
  24376. find out about changes in the Guix git repository.
  24377. @end defvar
  24378. @deftp {Data Type} guix-data-service-configuration
  24379. Data type representing the configuration of the Guix Data Service.
  24380. @table @asis
  24381. @item @code{package} (default: @code{guix-data-service})
  24382. The Guix Data Service package to use.
  24383. @item @code{user} (default: @code{"guix-data-service"})
  24384. The system user to run the service as.
  24385. @item @code{group} (default: @code{"guix-data-service"})
  24386. The system group to run the service as.
  24387. @item @code{port} (default: @code{8765})
  24388. The port to bind the web service to.
  24389. @item @code{host} (default: @code{"127.0.0.1"})
  24390. The host to bind the web service to.
  24391. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  24392. If set, this is the list of mailboxes that the getmail service will be
  24393. configured to listen to.
  24394. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  24395. If set, this is the @code{getmail-retriever-configuration} object with
  24396. which to configure getmail to fetch mail from the guix-commits mailing
  24397. list.
  24398. @item @code{extra-options} (default: @var{'()})
  24399. Extra command line options for @code{guix-data-service}.
  24400. @item @code{extra-process-jobs-options} (default: @var{'()})
  24401. Extra command line options for @code{guix-data-service-process-jobs}.
  24402. @end table
  24403. @end deftp
  24404. @node Linux Services
  24405. @subsection Linux Services
  24406. @cindex oom
  24407. @cindex out of memory killer
  24408. @cindex earlyoom
  24409. @cindex early out of memory daemon
  24410. @subsubheading Early OOM Service
  24411. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  24412. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  24413. space and provides a more responsive and configurable alternative to the
  24414. in-kernel OOM killer. It is useful to prevent the system from becoming
  24415. unresponsive when it runs out of memory.
  24416. @deffn {Scheme Variable} earlyoom-service-type
  24417. The service type for running @command{earlyoom}, the Early OOM daemon.
  24418. Its value must be a @code{earlyoom-configuration} object, described
  24419. below. The service can be instantiated in its default configuration
  24420. with:
  24421. @lisp
  24422. (service earlyoom-service-type)
  24423. @end lisp
  24424. @end deffn
  24425. @deftp {Data Type} earlyoom-configuration
  24426. This is the configuration record for the @code{earlyoom-service-type}.
  24427. @table @asis
  24428. @item @code{earlyoom} (default: @var{earlyoom})
  24429. The Earlyoom package to use.
  24430. @item @code{minimum-available-memory} (default: @code{10})
  24431. The threshold for the minimum @emph{available} memory, in percentages.
  24432. @item @code{minimum-free-swap} (default: @code{10})
  24433. The threshold for the minimum free swap memory, in percentages.
  24434. @item @code{prefer-regexp} (default: @code{#f})
  24435. A regular expression (as a string) to match the names of the processes
  24436. that should be preferably killed.
  24437. @item @code{avoid-regexp} (default: @code{#f})
  24438. A regular expression (as a string) to match the names of the processes
  24439. that should @emph{not} be killed.
  24440. @item @code{memory-report-interval} (default: @code{0})
  24441. The interval in seconds at which a memory report is printed. It is
  24442. disabled by default.
  24443. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  24444. A boolean indicating whether the positive adjustments set in
  24445. @file{/proc/*/oom_score_adj} should be ignored.
  24446. @item @code{show-debug-messages?} (default: @code{#f})
  24447. A boolean indicating whether debug messages should be printed. The logs
  24448. are saved at @file{/var/log/earlyoom.log}.
  24449. @item @code{send-notification-command} (default: @code{#f})
  24450. This can be used to provide a custom command used for sending
  24451. notifications.
  24452. @end table
  24453. @end deftp
  24454. @cindex modprobe
  24455. @cindex kernel module loader
  24456. @subsubheading Kernel Module Loader Service
  24457. The kernel module loader service allows one to load loadable kernel
  24458. modules at boot. This is especially useful for modules that don't
  24459. autoload and need to be manually loaded, as it's the case with
  24460. @code{ddcci}.
  24461. @deffn {Scheme Variable} kernel-module-loader-service-type
  24462. The service type for loading loadable kernel modules at boot with
  24463. @command{modprobe}. Its value must be a list of strings representing
  24464. module names. For example loading the drivers provided by
  24465. @code{ddcci-driver-linux}, in debugging mode by passing some module
  24466. parameters, can be done as follow:
  24467. @lisp
  24468. (use-modules (gnu) (gnu services))
  24469. (use-package-modules linux)
  24470. (use-service-modules linux)
  24471. (define ddcci-config
  24472. (plain-file "ddcci.conf"
  24473. "options ddcci dyndbg delay=120"))
  24474. (operating-system
  24475. ...
  24476. (services (cons* (service kernel-module-loader-service-type
  24477. '("ddcci" "ddcci_backlight"))
  24478. (simple-service 'ddcci-config etc-service-type
  24479. (list `("modprobe.d/ddcci.conf"
  24480. ,ddcci-config)))
  24481. %base-services))
  24482. (kernel-loadable-modules (list ddcci-driver-linux)))
  24483. @end lisp
  24484. @end deffn
  24485. @cindex zram
  24486. @cindex compressed swap
  24487. @cindex Compressed RAM-based block devices
  24488. @subsubheading Zram Device Service
  24489. The Zram device service provides a compressed swap device in system
  24490. memory. The Linux Kernel documentation has more information about
  24491. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  24492. devices.
  24493. @deffn {Scheme Variable} zram-device-service-type
  24494. This service creates the zram block device, formats it as swap and
  24495. enables it as a swap device. The service's value is a
  24496. @code{zram-device-configuration} record.
  24497. @deftp {Data Type} zram-device-configuration
  24498. This is the data type representing the configuration for the zram-device
  24499. service.
  24500. @table @asis
  24501. @item @code{size} (default @code{"1G"})
  24502. This is the amount of space you wish to provide for the zram device. It
  24503. accepts a string and can be a number of bytes or use a suffix, eg.:
  24504. @code{"512M"} or @code{1024000}.
  24505. @item @code{compression-algorithm} (default @code{'lzo})
  24506. This is the compression algorithm you wish to use. It is difficult to
  24507. list all the possible compression options, but common ones supported by
  24508. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  24509. @item @code{memory-limit} (default @code{0})
  24510. This is the maximum amount of memory which the zram device can use.
  24511. Setting it to '0' disables the limit. While it is generally expected
  24512. that compression will be 2:1, it is possible that uncompressable data
  24513. can be written to swap and this is a method to limit how much memory can
  24514. be used. It accepts a string and can be a number of bytes or use a
  24515. suffix, eg.: @code{"2G"}.
  24516. @item @code{priority} (default @code{-1})
  24517. This is the priority of the swap device created from the zram device.
  24518. @code{swapon} accepts values between -1 and 32767, with higher values
  24519. indicating higher priority. Higher priority swap will generally be used
  24520. first.
  24521. @end table
  24522. @end deftp
  24523. @end deffn
  24524. @node Hurd Services
  24525. @subsection Hurd Services
  24526. @defvr {Scheme Variable} hurd-console-service-type
  24527. This service starts the fancy @code{VGA} console client on the Hurd.
  24528. The service's value is a @code{hurd-console-configuration} record.
  24529. @end defvr
  24530. @deftp {Data Type} hurd-console-configuration
  24531. This is the data type representing the configuration for the
  24532. hurd-console-service.
  24533. @table @asis
  24534. @item @code{hurd} (default: @var{hurd})
  24535. The Hurd package to use.
  24536. @end table
  24537. @end deftp
  24538. @defvr {Scheme Variable} hurd-getty-service-type
  24539. This service starts a tty using the Hurd @code{getty} program.
  24540. The service's value is a @code{hurd-getty-configuration} record.
  24541. @end defvr
  24542. @deftp {Data Type} hurd-getty-configuration
  24543. This is the data type representing the configuration for the
  24544. hurd-getty-service.
  24545. @table @asis
  24546. @item @code{hurd} (default: @var{hurd})
  24547. The Hurd package to use.
  24548. @item @code{tty}
  24549. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  24550. @item @code{baud-rate} (default: @code{38400})
  24551. An integer specifying the baud rate of the tty.
  24552. @end table
  24553. @end deftp
  24554. @node Miscellaneous Services
  24555. @subsection Miscellaneous Services
  24556. @cindex fingerprint
  24557. @subsubheading Fingerprint Service
  24558. The @code{(gnu services authentication)} module provides a DBus service to
  24559. read and identify fingerprints via a fingerprint sensor.
  24560. @defvr {Scheme Variable} fprintd-service-type
  24561. The service type for @command{fprintd}, which provides the fingerprint
  24562. reading capability.
  24563. @lisp
  24564. (service fprintd-service-type)
  24565. @end lisp
  24566. @end defvr
  24567. @cindex sysctl
  24568. @subsubheading System Control Service
  24569. The @code{(gnu services sysctl)} provides a service to configure kernel
  24570. parameters at boot.
  24571. @defvr {Scheme Variable} sysctl-service-type
  24572. The service type for @command{sysctl}, which modifies kernel parameters
  24573. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  24574. instantiated as:
  24575. @lisp
  24576. (service sysctl-service-type
  24577. (sysctl-configuration
  24578. (settings '(("net.ipv4.ip_forward" . "1")))))
  24579. @end lisp
  24580. Since @code{sysctl-service-type} is used in the default lists of
  24581. services, @code{%base-services} and @code{%desktop-services}, you can
  24582. use @code{modify-services} to change its configuration and add the
  24583. kernel parameters that you want (@pxref{Service Reference,
  24584. @code{modify-services}}).
  24585. @lisp
  24586. (modify-services %base-services
  24587. (sysctl-service-type config =>
  24588. (sysctl-configuration
  24589. (settings (append '(("net.ipv4.ip_forward" . "1"))
  24590. %default-sysctl-settings)))))
  24591. @end lisp
  24592. @end defvr
  24593. @deftp {Data Type} sysctl-configuration
  24594. The data type representing the configuration of @command{sysctl}.
  24595. @table @asis
  24596. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  24597. The @command{sysctl} executable to use.
  24598. @item @code{settings} (default: @code{%default-sysctl-settings})
  24599. An association list specifies kernel parameters and their values.
  24600. @end table
  24601. @end deftp
  24602. @defvr {Scheme Variable} %default-sysctl-settings
  24603. An association list specifying the default @command{sysctl} parameters
  24604. on Guix System.
  24605. @end defvr
  24606. @cindex pcscd
  24607. @subsubheading PC/SC Smart Card Daemon Service
  24608. The @code{(gnu services security-token)} module provides the following service
  24609. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  24610. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  24611. manager that coordinates communications with smart card readers, smart cards
  24612. and cryptographic tokens that are connected to the system.
  24613. @defvr {Scheme Variable} pcscd-service-type
  24614. Service type for the @command{pcscd} service. Its value must be a
  24615. @code{pcscd-configuration} object. To run pcscd in the default
  24616. configuration, instantiate it as:
  24617. @lisp
  24618. (service pcscd-service-type)
  24619. @end lisp
  24620. @end defvr
  24621. @deftp {Data Type} pcscd-configuration
  24622. The data type representing the configuration of @command{pcscd}.
  24623. @table @asis
  24624. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  24625. The pcsc-lite package that provides pcscd.
  24626. @item @code{usb-drivers} (default: @code{(list ccid)})
  24627. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  24628. under @file{pcsc/drivers} in the store directory of the package.
  24629. @end table
  24630. @end deftp
  24631. @cindex lirc
  24632. @subsubheading Lirc Service
  24633. The @code{(gnu services lirc)} module provides the following service.
  24634. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  24635. [#:device #f] [#:driver #f] [#:config-file #f] @
  24636. [#:extra-options '()]
  24637. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  24638. decodes infrared signals from remote controls.
  24639. Optionally, @var{device}, @var{driver} and @var{config-file}
  24640. (configuration file name) may be specified. See @command{lircd} manual
  24641. for details.
  24642. Finally, @var{extra-options} is a list of additional command-line options
  24643. passed to @command{lircd}.
  24644. @end deffn
  24645. @cindex spice
  24646. @subsubheading Spice Service
  24647. The @code{(gnu services spice)} module provides the following service.
  24648. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  24649. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  24650. that enables sharing the clipboard with a vm and setting the guest display
  24651. resolution when the graphical console window resizes.
  24652. @end deffn
  24653. @cindex inputattach
  24654. @subsubheading inputattach Service
  24655. @cindex tablet input, for Xorg
  24656. @cindex touchscreen input, for Xorg
  24657. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  24658. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  24659. Xorg display server.
  24660. @deffn {Scheme Variable} inputattach-service-type
  24661. Type of a service that runs @command{inputattach} on a device and
  24662. dispatches events from it.
  24663. @end deffn
  24664. @deftp {Data Type} inputattach-configuration
  24665. @table @asis
  24666. @item @code{device-type} (default: @code{"wacom"})
  24667. The type of device to connect to. Run @command{inputattach --help}, from the
  24668. @code{inputattach} package, to see the list of supported device types.
  24669. @item @code{device} (default: @code{"/dev/ttyS0"})
  24670. The device file to connect to the device.
  24671. @item @code{baud-rate} (default: @code{#f})
  24672. Baud rate to use for the serial connection.
  24673. Should be a number or @code{#f}.
  24674. @item @code{log-file} (default: @code{#f})
  24675. If true, this must be the name of a file to log messages to.
  24676. @end table
  24677. @end deftp
  24678. @subsubheading Dictionary Service
  24679. @cindex dictionary
  24680. The @code{(gnu services dict)} module provides the following service:
  24681. @defvr {Scheme Variable} dicod-service-type
  24682. This is the type of the service that runs the @command{dicod} daemon, an
  24683. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  24684. @end defvr
  24685. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  24686. Return a service that runs the @command{dicod} daemon, an implementation
  24687. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  24688. The optional @var{config} argument specifies the configuration for
  24689. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  24690. default it serves the GNU Collaborative International Dictionary of English.
  24691. You can add @command{open localhost} to your @file{~/.dico} file to make
  24692. @code{localhost} the default server for @command{dico} client
  24693. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  24694. @end deffn
  24695. @deftp {Data Type} dicod-configuration
  24696. Data type representing the configuration of dicod.
  24697. @table @asis
  24698. @item @code{dico} (default: @var{dico})
  24699. Package object of the GNU Dico dictionary server.
  24700. @item @code{interfaces} (default: @var{'("localhost")})
  24701. This is the list of IP addresses and ports and possibly socket file
  24702. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  24703. dico, GNU Dico Manual}).
  24704. @item @code{handlers} (default: @var{'()})
  24705. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  24706. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  24707. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  24708. @end table
  24709. @end deftp
  24710. @deftp {Data Type} dicod-handler
  24711. Data type representing a dictionary handler (module instance).
  24712. @table @asis
  24713. @item @code{name}
  24714. Name of the handler (module instance).
  24715. @item @code{module} (default: @var{#f})
  24716. Name of the dicod module of the handler (instance). If it is @code{#f},
  24717. the module has the same name as the handler.
  24718. (@pxref{Modules,,, dico, GNU Dico Manual}).
  24719. @item @code{options}
  24720. List of strings or gexps representing the arguments for the module handler
  24721. @end table
  24722. @end deftp
  24723. @deftp {Data Type} dicod-database
  24724. Data type representing a dictionary database.
  24725. @table @asis
  24726. @item @code{name}
  24727. Name of the database, will be used in DICT commands.
  24728. @item @code{handler}
  24729. Name of the dicod handler (module instance) used by this database
  24730. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  24731. @item @code{complex?} (default: @var{#f})
  24732. Whether the database configuration complex. The complex configuration
  24733. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  24734. @item @code{options}
  24735. List of strings or gexps representing the arguments for the database
  24736. (@pxref{Databases,,, dico, GNU Dico Manual}).
  24737. @end table
  24738. @end deftp
  24739. @defvr {Scheme Variable} %dicod-database:gcide
  24740. A @code{<dicod-database>} object serving the GNU Collaborative International
  24741. Dictionary of English using the @code{gcide} package.
  24742. @end defvr
  24743. The following is an example @code{dicod-service} configuration.
  24744. @lisp
  24745. (dicod-service #:config
  24746. (dicod-configuration
  24747. (handlers (list (dicod-handler
  24748. (name "wordnet")
  24749. (module "dictorg")
  24750. (options
  24751. (list #~(string-append "dbdir=" #$wordnet))))))
  24752. (databases (list (dicod-database
  24753. (name "wordnet")
  24754. (complex? #t)
  24755. (handler "wordnet")
  24756. (options '("database=wn")))
  24757. %dicod-database:gcide))))
  24758. @end lisp
  24759. @cindex Docker
  24760. @subsubheading Docker Service
  24761. The @code{(gnu services docker)} module provides the following services.
  24762. @defvr {Scheme Variable} docker-service-type
  24763. This is the type of the service that runs @url{https://www.docker.com,Docker},
  24764. a daemon that can execute application bundles (sometimes referred to as
  24765. ``containers'') in isolated environments.
  24766. @end defvr
  24767. @deftp {Data Type} docker-configuration
  24768. This is the data type representing the configuration of Docker and Containerd.
  24769. @table @asis
  24770. @item @code{package} (default: @code{docker})
  24771. The Docker daemon package to use.
  24772. @item @code{package} (default: @code{docker-cli})
  24773. The Docker client package to use.
  24774. @item @code{containerd} (default: @var{containerd})
  24775. The Containerd package to use.
  24776. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  24777. The Docker user-land networking proxy package to use.
  24778. @item @code{enable-proxy?} (default @code{#t})
  24779. Enable or disable the use of the Docker user-land networking proxy.
  24780. @item @code{debug?} (default @code{#f})
  24781. Enable or disable debug output.
  24782. @item @code{enable-iptables?} (default @code{#t})
  24783. Enable or disable the addition of iptables rules.
  24784. @end table
  24785. @end deftp
  24786. @cindex Singularity, container service
  24787. @defvr {Scheme Variable} singularity-service-type
  24788. This is the type of the service that allows you to run
  24789. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  24790. create and run application bundles (aka. ``containers''). The value for this
  24791. service is the Singularity package to use.
  24792. The service does not install a daemon; instead, it installs helper programs as
  24793. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  24794. @command{singularity run} and similar commands.
  24795. @end defvr
  24796. @cindex Audit
  24797. @subsubheading Auditd Service
  24798. The @code{(gnu services auditd)} module provides the following service.
  24799. @defvr {Scheme Variable} auditd-service-type
  24800. This is the type of the service that runs
  24801. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  24802. a daemon that tracks security-relevant information on your system.
  24803. Examples of things that can be tracked:
  24804. @enumerate
  24805. @item
  24806. File accesses
  24807. @item
  24808. System calls
  24809. @item
  24810. Invoked commands
  24811. @item
  24812. Failed login attempts
  24813. @item
  24814. Firewall filtering
  24815. @item
  24816. Network access
  24817. @end enumerate
  24818. @command{auditctl} from the @code{audit} package can be used in order
  24819. to add or remove events to be tracked (until the next reboot).
  24820. In order to permanently track events, put the command line arguments
  24821. of auditctl into a file called @code{audit.rules} in the configuration
  24822. directory (see below).
  24823. @command{aureport} from the @code{audit} package can be used in order
  24824. to view a report of all recorded events.
  24825. The audit daemon by default logs into the file
  24826. @file{/var/log/audit.log}.
  24827. @end defvr
  24828. @deftp {Data Type} auditd-configuration
  24829. This is the data type representing the configuration of auditd.
  24830. @table @asis
  24831. @item @code{audit} (default: @code{audit})
  24832. The audit package to use.
  24833. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  24834. The directory containing the configuration file for the audit package, which
  24835. must be named @code{auditd.conf}, and optionally some audit rules to
  24836. instantiate on startup.
  24837. @end table
  24838. @end deftp
  24839. @cindex rshiny
  24840. @subsubheading R-Shiny service
  24841. The @code{(gnu services science)} module provides the following service.
  24842. @defvr {Scheme Variable} rshiny-service-type
  24843. This is a type of service which is used to run a webapp created with
  24844. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  24845. variable and runs the provided script to call @code{runApp}.
  24846. @deftp {Data Type} rshiny-configuration
  24847. This is the data type representing the configuration of rshiny.
  24848. @table @asis
  24849. @item @code{package} (default: @code{r-shiny})
  24850. The package to use.
  24851. @item @code{binary} (defaunlt @code{"rshiny"})
  24852. The name of the binary or shell script located at @code{package/bin/} to
  24853. run when the service is run.
  24854. The common way to create this file is as follows:
  24855. @lisp
  24856. @dots{}
  24857. (let* ((out (assoc-ref %outputs "out"))
  24858. (targetdir (string-append out "/share/" ,name))
  24859. (app (string-append out "/bin/" ,name))
  24860. (Rbin (string-append (assoc-ref %build-inputs "r-min")
  24861. "/bin/Rscript")))
  24862. ;; @dots{}
  24863. (mkdir-p (string-append out "/bin"))
  24864. (call-with-output-file app
  24865. (lambda (port)
  24866. (format port
  24867. "#!~a
  24868. library(shiny)
  24869. setwd(\"~a\")
  24870. runApp(launch.browser=0, port=4202)~%\n"
  24871. Rbin targetdir))))
  24872. @end lisp
  24873. @end table
  24874. @end deftp
  24875. @end defvr
  24876. @cindex Nix
  24877. @subsubheading Nix service
  24878. The @code{(gnu services nix)} module provides the following service.
  24879. @defvr {Scheme Variable} nix-service-type
  24880. This is the type of the service that runs build daemon of the
  24881. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  24882. how to use it:
  24883. @lisp
  24884. (use-modules (gnu))
  24885. (use-service-modules nix)
  24886. (use-package-modules package-management)
  24887. (operating-system
  24888. ;; @dots{}
  24889. (packages (append (list nix)
  24890. %base-packages))
  24891. (services (append (list (service nix-service-type))
  24892. %base-services)))
  24893. @end lisp
  24894. After @command{guix system reconfigure} configure Nix for your user:
  24895. @itemize
  24896. @item Add a Nix channel and update it. See
  24897. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  24898. @item Create a symlink to your profile and activate Nix profile:
  24899. @end itemize
  24900. @example
  24901. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  24902. $ source /run/current-system/profile/etc/profile.d/nix.sh
  24903. @end example
  24904. @end defvr
  24905. @deftp {Data Type} nix-configuration
  24906. This data type represents the configuration of the Nix daemon.
  24907. @table @asis
  24908. @item @code{nix} (default: @code{nix})
  24909. The Nix package to use.
  24910. @item @code{sandbox} (default: @code{#t})
  24911. Specifies whether builds are sandboxed by default.
  24912. @item @code{build-sandbox-items} (default: @code{'()})
  24913. This is a list of strings or objects appended to the
  24914. @code{build-sandbox-items} field of the configuration file.
  24915. @item @code{extra-config} (default: @code{'()})
  24916. This is a list of strings or objects appended to the configuration file.
  24917. It is used to pass extra text to be added verbatim to the configuration
  24918. file.
  24919. @item @code{extra-options} (default: @code{'()})
  24920. Extra command line options for @code{nix-service-type}.
  24921. @end table
  24922. @end deftp
  24923. @node Setuid Programs
  24924. @section Setuid Programs
  24925. @cindex setuid programs
  24926. Some programs need to run with ``root'' privileges, even when they are
  24927. launched by unprivileged users. A notorious example is the
  24928. @command{passwd} program, which users can run to change their
  24929. password, and which needs to access the @file{/etc/passwd} and
  24930. @file{/etc/shadow} files---something normally restricted to root, for
  24931. obvious security reasons. To address that, these executables are
  24932. @dfn{setuid-root}, meaning that they always run with root privileges
  24933. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  24934. for more info about the setuid mechanism).
  24935. The store itself @emph{cannot} contain setuid programs: that would be a
  24936. security issue since any user on the system can write derivations that
  24937. populate the store (@pxref{The Store}). Thus, a different mechanism is
  24938. used: instead of changing the setuid bit directly on files that are in
  24939. the store, we let the system administrator @emph{declare} which programs
  24940. should be setuid root.
  24941. The @code{setuid-programs} field of an @code{operating-system}
  24942. declaration contains a list of G-expressions denoting the names of
  24943. programs to be setuid-root (@pxref{Using the Configuration System}).
  24944. For instance, the @command{passwd} program, which is part of the Shadow
  24945. package, can be designated by this G-expression (@pxref{G-Expressions}):
  24946. @example
  24947. #~(string-append #$shadow "/bin/passwd")
  24948. @end example
  24949. A default set of setuid programs is defined by the
  24950. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  24951. @defvr {Scheme Variable} %setuid-programs
  24952. A list of G-expressions denoting common programs that are setuid-root.
  24953. The list includes commands such as @command{passwd}, @command{ping},
  24954. @command{su}, and @command{sudo}.
  24955. @end defvr
  24956. Under the hood, the actual setuid programs are created in the
  24957. @file{/run/setuid-programs} directory at system activation time. The
  24958. files in this directory refer to the ``real'' binaries, which are in the
  24959. store.
  24960. @node X.509 Certificates
  24961. @section X.509 Certificates
  24962. @cindex HTTPS, certificates
  24963. @cindex X.509 certificates
  24964. @cindex TLS
  24965. Web servers available over HTTPS (that is, HTTP over the transport-layer
  24966. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  24967. that the client can then use to @emph{authenticate} the server. To do
  24968. that, clients verify that the server's certificate is signed by a
  24969. so-called @dfn{certificate authority} (CA). But to verify the CA's
  24970. signature, clients must have first acquired the CA's certificate.
  24971. Web browsers such as GNU@tie{}IceCat include their own set of CA
  24972. certificates, such that they are able to verify CA signatures
  24973. out-of-the-box.
  24974. However, most other programs that can talk HTTPS---@command{wget},
  24975. @command{git}, @command{w3m}, etc.---need to be told where CA
  24976. certificates can be found.
  24977. @cindex @code{nss-certs}
  24978. In Guix, this is done by adding a package that provides certificates
  24979. to the @code{packages} field of the @code{operating-system} declaration
  24980. (@pxref{operating-system Reference}). Guix includes one such package,
  24981. @code{nss-certs}, which is a set of CA certificates provided as part of
  24982. Mozilla's Network Security Services.
  24983. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  24984. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  24985. most applications and libraries look for certificates by default, points
  24986. to the certificates installed globally.
  24987. Unprivileged users, including users of Guix on a foreign distro,
  24988. can also install their own certificate package in
  24989. their profile. A number of environment variables need to be defined so
  24990. that applications and libraries know where to find them. Namely, the
  24991. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  24992. variables. Some applications add their own environment variables; for
  24993. instance, the Git version control system honors the certificate bundle
  24994. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  24995. would typically run something like:
  24996. @example
  24997. guix install nss-certs
  24998. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  24999. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  25000. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  25001. @end example
  25002. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  25003. variable to point to a certificate bundle, so you would have to run
  25004. something like this:
  25005. @example
  25006. guix install nss-certs
  25007. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  25008. @end example
  25009. For other applications you may want to look up the required environment
  25010. variable in the relevant documentation.
  25011. @node Name Service Switch
  25012. @section Name Service Switch
  25013. @cindex name service switch
  25014. @cindex NSS
  25015. The @code{(gnu system nss)} module provides bindings to the
  25016. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  25017. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  25018. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  25019. extended with new ``name'' lookup methods for system databases, which
  25020. includes host names, service names, user accounts, and more (@pxref{Name
  25021. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  25022. C Library Reference Manual}).
  25023. The NSS configuration specifies, for each system database, which lookup
  25024. method is to be used, and how the various methods are chained
  25025. together---for instance, under which circumstances NSS should try the
  25026. next method in the list. The NSS configuration is given in the
  25027. @code{name-service-switch} field of @code{operating-system} declarations
  25028. (@pxref{operating-system Reference, @code{name-service-switch}}).
  25029. @cindex nss-mdns
  25030. @cindex .local, host name lookup
  25031. As an example, the declaration below configures the NSS to use the
  25032. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  25033. back-end}, which supports host name lookups over multicast DNS (mDNS)
  25034. for host names ending in @code{.local}:
  25035. @lisp
  25036. (name-service-switch
  25037. (hosts (list %files ;first, check /etc/hosts
  25038. ;; If the above did not succeed, try
  25039. ;; with 'mdns_minimal'.
  25040. (name-service
  25041. (name "mdns_minimal")
  25042. ;; 'mdns_minimal' is authoritative for
  25043. ;; '.local'. When it returns "not found",
  25044. ;; no need to try the next methods.
  25045. (reaction (lookup-specification
  25046. (not-found => return))))
  25047. ;; Then fall back to DNS.
  25048. (name-service
  25049. (name "dns"))
  25050. ;; Finally, try with the "full" 'mdns'.
  25051. (name-service
  25052. (name "mdns")))))
  25053. @end lisp
  25054. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  25055. contains this configuration, so you will not have to type it if all you
  25056. want is to have @code{.local} host lookup working.
  25057. Note that, in this case, in addition to setting the
  25058. @code{name-service-switch} of the @code{operating-system} declaration,
  25059. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  25060. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  25061. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  25062. to the name service cache daemon (@pxref{Base Services,
  25063. @code{nscd-service}}).
  25064. For convenience, the following variables provide typical NSS
  25065. configurations.
  25066. @defvr {Scheme Variable} %default-nss
  25067. This is the default name service switch configuration, a
  25068. @code{name-service-switch} object.
  25069. @end defvr
  25070. @defvr {Scheme Variable} %mdns-host-lookup-nss
  25071. This is the name service switch configuration with support for host name
  25072. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  25073. @end defvr
  25074. The reference for name service switch configuration is given below. It
  25075. is a direct mapping of the configuration file format of the C library , so
  25076. please refer to the C library manual for more information (@pxref{NSS
  25077. Configuration File,,, libc, The GNU C Library Reference Manual}).
  25078. Compared to the configuration file format of libc NSS, it has the advantage
  25079. not only of adding this warm parenthetic feel that we like, but also
  25080. static checks: you will know about syntax errors and typos as soon as you
  25081. run @command{guix system}.
  25082. @deftp {Data Type} name-service-switch
  25083. This is the data type representation the configuration of libc's name
  25084. service switch (NSS). Each field below represents one of the supported
  25085. system databases.
  25086. @table @code
  25087. @item aliases
  25088. @itemx ethers
  25089. @itemx group
  25090. @itemx gshadow
  25091. @itemx hosts
  25092. @itemx initgroups
  25093. @itemx netgroup
  25094. @itemx networks
  25095. @itemx password
  25096. @itemx public-key
  25097. @itemx rpc
  25098. @itemx services
  25099. @itemx shadow
  25100. The system databases handled by the NSS@. Each of these fields must be a
  25101. list of @code{<name-service>} objects (see below).
  25102. @end table
  25103. @end deftp
  25104. @deftp {Data Type} name-service
  25105. This is the data type representing an actual name service and the
  25106. associated lookup action.
  25107. @table @code
  25108. @item name
  25109. A string denoting the name service (@pxref{Services in the NSS
  25110. configuration,,, libc, The GNU C Library Reference Manual}).
  25111. Note that name services listed here must be visible to nscd. This is
  25112. achieved by passing the @code{#:name-services} argument to
  25113. @code{nscd-service} the list of packages providing the needed name
  25114. services (@pxref{Base Services, @code{nscd-service}}).
  25115. @item reaction
  25116. An action specified using the @code{lookup-specification} macro
  25117. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  25118. Reference Manual}). For example:
  25119. @lisp
  25120. (lookup-specification (unavailable => continue)
  25121. (success => return))
  25122. @end lisp
  25123. @end table
  25124. @end deftp
  25125. @node Initial RAM Disk
  25126. @section Initial RAM Disk
  25127. @cindex initrd
  25128. @cindex initial RAM disk
  25129. For bootstrapping purposes, the Linux-Libre kernel is passed an
  25130. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  25131. root file system as well as an initialization script. The latter is
  25132. responsible for mounting the real root file system, and for loading any
  25133. kernel modules that may be needed to achieve that.
  25134. The @code{initrd-modules} field of an @code{operating-system}
  25135. declaration allows you to specify Linux-libre kernel modules that must
  25136. be available in the initrd. In particular, this is where you would list
  25137. modules needed to actually drive the hard disk where your root partition
  25138. is---although the default value of @code{initrd-modules} should cover
  25139. most use cases. For example, assuming you need the @code{megaraid_sas}
  25140. module in addition to the default modules to be able to access your root
  25141. file system, you would write:
  25142. @lisp
  25143. (operating-system
  25144. ;; @dots{}
  25145. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  25146. @end lisp
  25147. @defvr {Scheme Variable} %base-initrd-modules
  25148. This is the list of kernel modules included in the initrd by default.
  25149. @end defvr
  25150. Furthermore, if you need lower-level customization, the @code{initrd}
  25151. field of an @code{operating-system} declaration allows
  25152. you to specify which initrd you would like to use. The @code{(gnu
  25153. system linux-initrd)} module provides three ways to build an initrd: the
  25154. high-level @code{base-initrd} procedure and the low-level
  25155. @code{raw-initrd} and @code{expression->initrd} procedures.
  25156. The @code{base-initrd} procedure is intended to cover most common uses.
  25157. For example, if you want to add a bunch of kernel modules to be loaded
  25158. at boot time, you can define the @code{initrd} field of the operating
  25159. system declaration like this:
  25160. @lisp
  25161. (initrd (lambda (file-systems . rest)
  25162. ;; Create a standard initrd but set up networking
  25163. ;; with the parameters QEMU expects by default.
  25164. (apply base-initrd file-systems
  25165. #:qemu-networking? #t
  25166. rest)))
  25167. @end lisp
  25168. The @code{base-initrd} procedure also handles common use cases that
  25169. involves using the system as a QEMU guest, or as a ``live'' system with
  25170. volatile root file system.
  25171. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  25172. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  25173. such as trying to guess which kernel modules and packages should be included
  25174. to the initrd. An example use of @code{raw-initrd} is when a user has
  25175. a custom Linux kernel configuration and default kernel modules included by
  25176. @code{base-initrd} are not available.
  25177. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  25178. honors several options passed on the Linux kernel command line
  25179. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  25180. @code{-append} option of QEMU), notably:
  25181. @table @code
  25182. @item --load=@var{boot}
  25183. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  25184. program, once it has mounted the root file system.
  25185. Guix uses this option to yield control to a boot program that runs the
  25186. service activation programs and then spawns the GNU@tie{}Shepherd, the
  25187. initialization system.
  25188. @item --root=@var{root}
  25189. Mount @var{root} as the root file system. @var{root} can be a device
  25190. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  25191. When unspecified, the device name from the root file system of the
  25192. operating system declaration is used.
  25193. @item --system=@var{system}
  25194. Have @file{/run/booted-system} and @file{/run/current-system} point to
  25195. @var{system}.
  25196. @item modprobe.blacklist=@var{modules}@dots{}
  25197. @cindex module, black-listing
  25198. @cindex black list, of kernel modules
  25199. Instruct the initial RAM disk as well as the @command{modprobe} command
  25200. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  25201. must be a comma-separated list of module names---e.g.,
  25202. @code{usbkbd,9pnet}.
  25203. @item --repl
  25204. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  25205. tries to load kernel modules and to mount the root file system. Our
  25206. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  25207. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  25208. Manual}, for more information on Guile's REPL.
  25209. @end table
  25210. Now that you know all the features that initial RAM disks produced by
  25211. @code{base-initrd} and @code{raw-initrd} provide,
  25212. here is how to use it and customize it further.
  25213. @cindex initrd
  25214. @cindex initial RAM disk
  25215. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  25216. [#:linux-modules '()] [#:mapped-devices '()] @
  25217. [#:keyboard-layout #f] @
  25218. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  25219. Return a derivation that builds a raw initrd. @var{file-systems} is
  25220. a list of file systems to be mounted by the initrd, possibly in addition to
  25221. the root file system specified on the kernel command line via @option{--root}.
  25222. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  25223. @var{mapped-devices} is a list of device mappings to realize before
  25224. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  25225. @var{helper-packages} is a list of packages to be copied in the initrd.
  25226. It may
  25227. include @code{e2fsck/static} or other packages needed by the initrd to check
  25228. the root file system.
  25229. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  25230. the desired console keyboard layout. This is done before @var{mapped-devices}
  25231. are set up and before @var{file-systems} are mounted such that, should the
  25232. user need to enter a passphrase or use the REPL, this happens using the
  25233. intended keyboard layout.
  25234. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  25235. parameters. When @var{virtio?} is true, load additional modules so that the
  25236. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  25237. When @var{volatile-root?} is true, the root file system is writable but any changes
  25238. to it are lost.
  25239. @end deffn
  25240. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  25241. [#:mapped-devices '()] [#:keyboard-layout #f] @
  25242. [#:qemu-networking? #f] [#:volatile-root? #f] @
  25243. [#:linux-modules '()]
  25244. Return as a file-like object a generic initrd, with kernel
  25245. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  25246. mounted by the initrd, possibly in addition to the root file system specified
  25247. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  25248. mappings to realize before @var{file-systems} are mounted.
  25249. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  25250. the desired console keyboard layout. This is done before @var{mapped-devices}
  25251. are set up and before @var{file-systems} are mounted such that, should the
  25252. user need to enter a passphrase or use the REPL, this happens using the
  25253. intended keyboard layout.
  25254. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  25255. The initrd is automatically populated with all the kernel modules necessary
  25256. for @var{file-systems} and for the given options. Additional kernel
  25257. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  25258. loaded at boot time in the order in which they appear.
  25259. @end deffn
  25260. Needless to say, the initrds we produce and use embed a
  25261. statically-linked Guile, and the initialization program is a Guile
  25262. program. That gives a lot of flexibility. The
  25263. @code{expression->initrd} procedure builds such an initrd, given the
  25264. program to run in that initrd.
  25265. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  25266. [#:guile %guile-3.0-static-stripped] [#:name "guile-initrd"]
  25267. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  25268. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  25269. upon booting. All the derivations referenced by @var{exp} are
  25270. automatically copied to the initrd.
  25271. @end deffn
  25272. @node Bootloader Configuration
  25273. @section Bootloader Configuration
  25274. @cindex bootloader
  25275. @cindex boot loader
  25276. The operating system supports multiple bootloaders. The bootloader is
  25277. configured using @code{bootloader-configuration} declaration. All the
  25278. fields of this structure are bootloader agnostic except for one field,
  25279. @code{bootloader} that indicates the bootloader to be configured and
  25280. installed.
  25281. Some of the bootloaders do not honor every field of
  25282. @code{bootloader-configuration}. For instance, the extlinux
  25283. bootloader does not support themes and thus ignores the @code{theme}
  25284. field.
  25285. @deftp {Data Type} bootloader-configuration
  25286. The type of a bootloader configuration declaration.
  25287. @table @asis
  25288. @item @code{bootloader}
  25289. @cindex EFI, bootloader
  25290. @cindex UEFI, bootloader
  25291. @cindex BIOS, bootloader
  25292. The bootloader to use, as a @code{bootloader} object. For now
  25293. @code{grub-bootloader}, @code{grub-efi-bootloader},
  25294. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  25295. @code{u-boot-bootloader} are supported.
  25296. @cindex ARM, bootloaders
  25297. @cindex AArch64, bootloaders
  25298. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  25299. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  25300. of bootloaders for a wide range of ARM and AArch64 systems, using the
  25301. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  25302. @vindex grub-efi-bootloader
  25303. @code{grub-efi-bootloader} allows to boot on modern systems using the
  25304. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  25305. use if the installation image contains a @file{/sys/firmware/efi} directory
  25306. when you boot it on your system.
  25307. @vindex grub-bootloader
  25308. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  25309. in ``legacy'' BIOS mode.
  25310. @vindex grub-efi-netboot-bootloader
  25311. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  25312. through TFTP@. In combination with an NFS root file system this allows you to
  25313. build a diskless Guix system.
  25314. The installation of the @code{grub-efi-netboot-bootloader} generates the content
  25315. of the TFTP root directory at @code{target}
  25316. (@pxref{Bootloader Configuration, @code{target}}), to be served by a TFTP server.
  25317. You may want to mount your TFTP server directory onto @code{target} to move the
  25318. required files to the TFTP server automatically.
  25319. If you plan to use an NFS root file system as well (actually if you mount the
  25320. store from an NFS share), then the TFTP server needs to serve the file
  25321. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  25322. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  25323. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  25324. files from the store will be accessed by GRUB through TFTP with their normal
  25325. store path, for example as
  25326. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  25327. Two symlinks are created to make this possible. The first symlink is
  25328. @code{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  25329. @file{../../../boot/grub/grub.cfg},
  25330. where @code{target} may be @file{/boot}. In this case the link is not leaving
  25331. the served TFTP root directory, but otherwise it does. The second link is
  25332. @code{target}@file{/gnu/store} and points to @file{../gnu/store}. This link
  25333. is leaving the served TFTP root directory.
  25334. The assumption behind all this is that you have an NFS server exporting the root
  25335. file system for your Guix system, and additionally a TFTP server exporting your
  25336. @code{target} directory—usually @file{/boot}—from that same root file system for
  25337. your Guix system. In this constellation the symlinks will work.
  25338. For other constellations you will have to program your own bootloader installer,
  25339. which then takes care to make necessary files from the store accessible through
  25340. TFTP, for example by copying them into the TFTP root directory at @code{target}.
  25341. It is important to note that symlinks pointing outside the TFTP root directory
  25342. may need to be allowed in the configuration of your TFTP server. Further the
  25343. store link exposes the whole store through TFTP@. Both points need to be
  25344. considered carefully for security aspects.
  25345. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  25346. NFS servers, you also need a properly configured DHCP server to make the booting
  25347. over netboot possible. For all this we can currently only recommend you to look
  25348. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  25349. @item @code{target}
  25350. This is a string denoting the target onto which to install the
  25351. bootloader.
  25352. The interpretation depends on the bootloader in question. For
  25353. @code{grub-bootloader}, for example, it should be a device name understood by
  25354. the bootloader @command{installer} command, such as @code{/dev/sda} or
  25355. @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
  25356. @code{grub-efi-bootloader}, it should be the mount point of the EFI file
  25357. system, usually @file{/boot/efi}. For @code{grub-efi-netboot-bootloader},
  25358. @code{target} should be the mount point corresponding to the TFTP root
  25359. directory of your TFTP server.
  25360. @item @code{menu-entries} (default: @code{()})
  25361. A possibly empty list of @code{menu-entry} objects (see below), denoting
  25362. entries to appear in the bootloader menu, in addition to the current
  25363. system entry and the entry pointing to previous system generations.
  25364. @item @code{default-entry} (default: @code{0})
  25365. The index of the default boot menu entry. Index 0 is for the entry of the
  25366. current system.
  25367. @item @code{timeout} (default: @code{5})
  25368. The number of seconds to wait for keyboard input before booting. Set to
  25369. 0 to boot immediately, and to -1 to wait indefinitely.
  25370. @cindex keyboard layout, for the bootloader
  25371. @item @code{keyboard-layout} (default: @code{#f})
  25372. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  25373. layout, usually US@tie{}English (``qwerty'').
  25374. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  25375. Layout}).
  25376. @quotation Note
  25377. This option is currently ignored by bootloaders other than @code{grub} and
  25378. @code{grub-efi}.
  25379. @end quotation
  25380. @item @code{theme} (default: @var{#f})
  25381. The bootloader theme object describing the theme to use. If no theme
  25382. is provided, some bootloaders might use a default theme, that's true
  25383. for GRUB.
  25384. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  25385. The output terminals used for the bootloader boot menu, as a list of
  25386. symbols. GRUB accepts the values: @code{console}, @code{serial},
  25387. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  25388. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  25389. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  25390. configuration,,, grub,GNU GRUB manual}).
  25391. @item @code{terminal-inputs} (default: @code{'()})
  25392. The input terminals used for the bootloader boot menu, as a list of
  25393. symbols. For GRUB, the default is the native platform terminal as
  25394. determined at run-time. GRUB accepts the values: @code{console},
  25395. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  25396. @code{usb_keyboard}. This field corresponds to the GRUB variable
  25397. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  25398. manual}).
  25399. @item @code{serial-unit} (default: @code{#f})
  25400. The serial unit used by the bootloader, as an integer from 0 to 3.
  25401. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  25402. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  25403. @item @code{serial-speed} (default: @code{#f})
  25404. The speed of the serial interface, as an integer. For GRUB, the
  25405. default value is chosen at run-time; currently GRUB chooses
  25406. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  25407. @end table
  25408. @end deftp
  25409. @cindex dual boot
  25410. @cindex boot menu
  25411. Should you want to list additional boot menu entries @i{via} the
  25412. @code{menu-entries} field above, you will need to create them with the
  25413. @code{menu-entry} form. For example, imagine you want to be able to
  25414. boot another distro (hard to imagine!), you can define a menu entry
  25415. along these lines:
  25416. @lisp
  25417. (menu-entry
  25418. (label "The Other Distro")
  25419. (linux "/boot/old/vmlinux-2.6.32")
  25420. (linux-arguments '("root=/dev/sda2"))
  25421. (initrd "/boot/old/initrd"))
  25422. @end lisp
  25423. Details below.
  25424. @deftp {Data Type} menu-entry
  25425. The type of an entry in the bootloader menu.
  25426. @table @asis
  25427. @item @code{label}
  25428. The label to show in the menu---e.g., @code{"GNU"}.
  25429. @item @code{linux} (default: @code{#f})
  25430. The Linux kernel image to boot, for example:
  25431. @lisp
  25432. (file-append linux-libre "/bzImage")
  25433. @end lisp
  25434. For GRUB, it is also possible to specify a device explicitly in the
  25435. file path using GRUB's device naming convention (@pxref{Naming
  25436. convention,,, grub, GNU GRUB manual}), for example:
  25437. @example
  25438. "(hd0,msdos1)/boot/vmlinuz"
  25439. @end example
  25440. If the device is specified explicitly as above, then the @code{device}
  25441. field is ignored entirely.
  25442. @item @code{linux-arguments} (default: @code{()})
  25443. The list of extra Linux kernel command-line arguments---e.g.,
  25444. @code{("console=ttyS0")}.
  25445. @item @code{initrd} (default: @code{#f})
  25446. A G-Expression or string denoting the file name of the initial RAM disk
  25447. to use (@pxref{G-Expressions}).
  25448. @item @code{device} (default: @code{#f})
  25449. The device where the kernel and initrd are to be found---i.e., for GRUB,
  25450. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  25451. This may be a file system label (a string), a file system UUID (a
  25452. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  25453. the bootloader will search the device containing the file specified by
  25454. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  25455. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  25456. @item @code{multiboot-kernel} (default: @code{#f})
  25457. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  25458. manual}). When this field is set, a Multiboot menu-entry is generated.
  25459. For example:
  25460. @lisp
  25461. (file-append mach "/boot/gnumach")
  25462. @end lisp
  25463. @item @code{multiboot-arguments} (default: @code{()})
  25464. The list of extra command-line arguments for the multiboot-kernel.
  25465. @item @code{multiboot-modules} (default: @code{()})
  25466. The list of commands for loading Multiboot modules. For example:
  25467. @lisp
  25468. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  25469. @dots{})
  25470. (list (file-append libc "/lib/ld.so.1") "exec"
  25471. @dots{}))
  25472. @end lisp
  25473. @end table
  25474. @end deftp
  25475. @cindex HDPI
  25476. @cindex HiDPI
  25477. @cindex resolution
  25478. @c FIXME: Write documentation once it's stable.
  25479. For now only GRUB has theme support. GRUB themes are created using
  25480. the @code{grub-theme} form, which is not fully documented yet.
  25481. @deftp {Data Type} grub-theme
  25482. Data type representing the configuration of the GRUB theme.
  25483. @table @asis
  25484. @item @code{gfxmode} (default: @code{'("auto")})
  25485. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  25486. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  25487. @end table
  25488. @end deftp
  25489. @deffn {Scheme Procedure} grub-theme
  25490. Return the default GRUB theme used by the operating system if no
  25491. @code{theme} field is specified in @code{bootloader-configuration}
  25492. record.
  25493. It comes with a fancy background image displaying the GNU and Guix
  25494. logos.
  25495. @end deffn
  25496. For example, to override the default resolution, you may use something
  25497. like
  25498. @lisp
  25499. (bootloader
  25500. (bootloader-configuration
  25501. ;; @dots{}
  25502. (theme (grub-theme
  25503. (inherit (grub-theme))
  25504. (gfxmode '("1024x786x32" "auto"))))))
  25505. @end lisp
  25506. @node Invoking guix system
  25507. @section Invoking @code{guix system}
  25508. Once you have written an operating system declaration as seen in the
  25509. previous section, it can be @dfn{instantiated} using the @command{guix
  25510. system} command. The synopsis is:
  25511. @example
  25512. guix system @var{options}@dots{} @var{action} @var{file}
  25513. @end example
  25514. @var{file} must be the name of a file containing an
  25515. @code{operating-system} declaration. @var{action} specifies how the
  25516. operating system is instantiated. Currently the following values are
  25517. supported:
  25518. @table @code
  25519. @item search
  25520. Display available service type definitions that match the given regular
  25521. expressions, sorted by relevance:
  25522. @cindex HDPI
  25523. @cindex HiDPI
  25524. @cindex resolution
  25525. @example
  25526. $ guix system search console
  25527. name: console-fonts
  25528. location: gnu/services/base.scm:806:2
  25529. extends: shepherd-root
  25530. description: Install the given fonts on the specified ttys (fonts are per
  25531. + virtual console on GNU/Linux). The value of this service is a list of
  25532. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  25533. + package or any valid argument to `setfont', as in this example:
  25534. +
  25535. + '(("tty1" . "LatGrkCyr-8x16")
  25536. + ("tty2" . (file-append
  25537. + font-tamzen
  25538. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  25539. + ("tty3" . (file-append
  25540. + font-terminus
  25541. + "/share/consolefonts/ter-132n"))) ; for HDPI
  25542. relevance: 9
  25543. name: mingetty
  25544. location: gnu/services/base.scm:1190:2
  25545. extends: shepherd-root
  25546. description: Provide console login using the `mingetty' program.
  25547. relevance: 2
  25548. name: login
  25549. location: gnu/services/base.scm:860:2
  25550. extends: pam
  25551. description: Provide a console log-in service as specified by its
  25552. + configuration value, a `login-configuration' object.
  25553. relevance: 2
  25554. @dots{}
  25555. @end example
  25556. As for @command{guix package --search}, the result is written in
  25557. @code{recutils} format, which makes it easy to filter the output
  25558. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  25559. @item reconfigure
  25560. Build the operating system described in @var{file}, activate it, and
  25561. switch to it@footnote{This action (and the related actions
  25562. @code{switch-generation} and @code{roll-back}) are usable only on
  25563. systems already running Guix System.}.
  25564. @quotation Note
  25565. @c The paragraph below refers to the problem discussed at
  25566. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  25567. It is highly recommended to run @command{guix pull} once before you run
  25568. @command{guix system reconfigure} for the first time (@pxref{Invoking
  25569. guix pull}). Failing to do that you would see an older version of Guix
  25570. once @command{reconfigure} has completed.
  25571. @end quotation
  25572. This effects all the configuration specified in @var{file}: user
  25573. accounts, system services, global package list, setuid programs, etc.
  25574. The command starts system services specified in @var{file} that are not
  25575. currently running; if a service is currently running this command will
  25576. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  25577. @code{herd stop X} or @code{herd restart X}).
  25578. This command creates a new generation whose number is one greater than
  25579. the current generation (as reported by @command{guix system
  25580. list-generations}). If that generation already exists, it will be
  25581. overwritten. This behavior mirrors that of @command{guix package}
  25582. (@pxref{Invoking guix package}).
  25583. It also adds a bootloader menu entry for the new OS configuration,
  25584. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  25585. entries for older configurations to a submenu, allowing you to choose
  25586. an older system generation at boot time should you need it.
  25587. @cindex provenance tracking, of the operating system
  25588. Upon completion, the new system is deployed under
  25589. @file{/run/current-system}. This directory contains @dfn{provenance
  25590. meta-data}: the list of channels in use (@pxref{Channels}) and
  25591. @var{file} itself, when available. You can view it by running:
  25592. @example
  25593. guix system describe
  25594. @end example
  25595. This information is useful should you later want to inspect how this
  25596. particular generation was built. In fact, assuming @var{file} is
  25597. self-contained, you can later rebuild generation @var{n} of your
  25598. operating system with:
  25599. @example
  25600. guix time-machine \
  25601. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  25602. system reconfigure \
  25603. /var/guix/profiles/system-@var{n}-link/configuration.scm
  25604. @end example
  25605. You can think of it as some sort of built-in version control! Your
  25606. system is not just a binary artifact: @emph{it carries its own source}.
  25607. @xref{Service Reference, @code{provenance-service-type}}, for more
  25608. information on provenance tracking.
  25609. By default, @command{reconfigure} @emph{prevents you from downgrading
  25610. your system}, which could (re)introduce security vulnerabilities and
  25611. also cause problems with ``stateful'' services such as database
  25612. management systems. You can override that behavior by passing
  25613. @option{--allow-downgrades}.
  25614. @item switch-generation
  25615. @cindex generations
  25616. Switch to an existing system generation. This action atomically
  25617. switches the system profile to the specified system generation. It
  25618. also rearranges the system's existing bootloader menu entries. It
  25619. makes the menu entry for the specified system generation the default,
  25620. and it moves the entries for the other generations to a submenu, if
  25621. supported by the bootloader being used. The next time the system
  25622. boots, it will use the specified system generation.
  25623. The bootloader itself is not being reinstalled when using this
  25624. command. Thus, the installed bootloader is used with an updated
  25625. configuration file.
  25626. The target generation can be specified explicitly by its generation
  25627. number. For example, the following invocation would switch to system
  25628. generation 7:
  25629. @example
  25630. guix system switch-generation 7
  25631. @end example
  25632. The target generation can also be specified relative to the current
  25633. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  25634. ``3 generations ahead of the current generation,'' and @code{-1} means
  25635. ``1 generation prior to the current generation.'' When specifying a
  25636. negative value such as @code{-1}, you must precede it with @code{--} to
  25637. prevent it from being parsed as an option. For example:
  25638. @example
  25639. guix system switch-generation -- -1
  25640. @end example
  25641. Currently, the effect of invoking this action is @emph{only} to switch
  25642. the system profile to an existing generation and rearrange the
  25643. bootloader menu entries. To actually start using the target system
  25644. generation, you must reboot after running this action. In the future,
  25645. it will be updated to do the same things as @command{reconfigure},
  25646. like activating and deactivating services.
  25647. This action will fail if the specified generation does not exist.
  25648. @item roll-back
  25649. @cindex rolling back
  25650. Switch to the preceding system generation. The next time the system
  25651. boots, it will use the preceding system generation. This is the inverse
  25652. of @command{reconfigure}, and it is exactly the same as invoking
  25653. @command{switch-generation} with an argument of @code{-1}.
  25654. Currently, as with @command{switch-generation}, you must reboot after
  25655. running this action to actually start using the preceding system
  25656. generation.
  25657. @item delete-generations
  25658. @cindex deleting system generations
  25659. @cindex saving space
  25660. Delete system generations, making them candidates for garbage collection
  25661. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  25662. collector'').
  25663. This works in the same way as @samp{guix package --delete-generations}
  25664. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  25665. arguments, all system generations but the current one are deleted:
  25666. @example
  25667. guix system delete-generations
  25668. @end example
  25669. You can also select the generations you want to delete. The example below
  25670. deletes all the system generations that are more than two month old:
  25671. @example
  25672. guix system delete-generations 2m
  25673. @end example
  25674. Running this command automatically reinstalls the bootloader with an updated
  25675. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  25676. longer lists the generations that have been deleted.
  25677. @item build
  25678. Build the derivation of the operating system, which includes all the
  25679. configuration files and programs needed to boot and run the system.
  25680. This action does not actually install anything.
  25681. @item init
  25682. Populate the given directory with all the files necessary to run the
  25683. operating system specified in @var{file}. This is useful for first-time
  25684. installations of Guix System. For instance:
  25685. @example
  25686. guix system init my-os-config.scm /mnt
  25687. @end example
  25688. copies to @file{/mnt} all the store items required by the configuration
  25689. specified in @file{my-os-config.scm}. This includes configuration
  25690. files, packages, and so on. It also creates other essential files
  25691. needed for the system to operate correctly---e.g., the @file{/etc},
  25692. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  25693. This command also installs bootloader on the target specified in
  25694. @file{my-os-config}, unless the @option{--no-bootloader} option was
  25695. passed.
  25696. @item vm
  25697. @cindex virtual machine
  25698. @cindex VM
  25699. @anchor{guix system vm}
  25700. Build a virtual machine that contains the operating system declared in
  25701. @var{file}, and return a script to run that virtual machine (VM).
  25702. @quotation Note
  25703. The @code{vm} action and others below
  25704. can use KVM support in the Linux-libre kernel. Specifically, if the
  25705. machine has hardware virtualization support, the corresponding
  25706. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  25707. must exist and be readable and writable by the user and by the
  25708. build users of the daemon (@pxref{Build Environment Setup}).
  25709. @end quotation
  25710. Arguments given to the script are passed to QEMU as in the example
  25711. below, which enables networking and requests 1@tie{}GiB of RAM for the
  25712. emulated machine:
  25713. @example
  25714. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -net user,model=virtio-net-pci
  25715. @end example
  25716. The VM shares its store with the host system.
  25717. Additional file systems can be shared between the host and the VM using
  25718. the @option{--share} and @option{--expose} command-line options: the former
  25719. specifies a directory to be shared with write access, while the latter
  25720. provides read-only access to the shared directory.
  25721. The example below creates a VM in which the user's home directory is
  25722. accessible read-only, and where the @file{/exchange} directory is a
  25723. read-write mapping of @file{$HOME/tmp} on the host:
  25724. @example
  25725. guix system vm my-config.scm \
  25726. --expose=$HOME --share=$HOME/tmp=/exchange
  25727. @end example
  25728. On GNU/Linux, the default is to boot directly to the kernel; this has
  25729. the advantage of requiring only a very tiny root disk image since the
  25730. store of the host can then be mounted.
  25731. The @option{--full-boot} option forces a complete boot sequence, starting
  25732. with the bootloader. This requires more disk space since a root image
  25733. containing at least the kernel, initrd, and bootloader data files must
  25734. be created. The @option{--image-size} option can be used to specify the
  25735. size of the image.
  25736. @cindex System images, creation in various formats
  25737. @cindex Creating system images in various formats
  25738. @item image
  25739. @itemx docker-image
  25740. Return a virtual machine, disk image, or Docker image of the operating
  25741. system declared in @var{file} that stands alone. By default,
  25742. @command{guix system} estimates the size of the image needed to store
  25743. the system, but you can use the @option{--image-size} option to specify
  25744. a value. Docker images are built to contain exactly what they need, so
  25745. the @option{--image-size} option is ignored in the case of
  25746. @code{docker-image}.
  25747. @cindex image, creating disk images
  25748. The @code{image} command can produce various image types. The
  25749. image type can be selected using the @option{--image-type} option. It
  25750. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  25751. @option{--label} option can be used to specify a volume ID with
  25752. @code{image}. By default, the root file system of a disk image is
  25753. mounted non-volatile; the @option{--volatile} option can be provided to
  25754. make it volatile instead. When using @code{image}, the bootloader
  25755. installed on the generated image is taken from the provided
  25756. @code{operating-system} definition. The following example demonstrates
  25757. how to generate an image that uses the @code{grub-efi-bootloader}
  25758. bootloader and boot it with QEMU:
  25759. @example
  25760. image=$(guix system image --image-type=qcow2 \
  25761. gnu/system/examples/lightweight-desktop.tmpl)
  25762. cp $image /tmp/my-image.qcow2
  25763. chmod +w /tmp/my-image.qcow2
  25764. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  25765. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  25766. @end example
  25767. When using the @code{efi-raw} image type, a raw disk image is produced;
  25768. it can be copied as is to a USB stick, for instance. Assuming
  25769. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  25770. the image to it using the following command:
  25771. @example
  25772. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  25773. @end example
  25774. The @code{--list-image-types} command lists all the available image
  25775. types.
  25776. @cindex creating virtual machine images
  25777. When using the @code{qcow2} image type, the returned image is in qcow2
  25778. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  25779. in a VM}, for more information on how to run the image in a virtual
  25780. machine. The @code{grub-bootloader} bootloader is always used
  25781. independently of what is declared in the @code{operating-system} file
  25782. passed as argument. This is to make it easier to work with QEMU, which
  25783. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  25784. in the Master Boot Record (MBR).
  25785. @cindex docker-image, creating docker images
  25786. When using @code{docker-image}, a Docker image is produced. Guix builds
  25787. the image from scratch, not from a pre-existing Docker base image. As a
  25788. result, it contains @emph{exactly} what you define in the operating
  25789. system configuration file. You can then load the image and launch a
  25790. Docker container using commands like the following:
  25791. @example
  25792. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  25793. container_id="$(docker create $image_id)"
  25794. docker start $container_id
  25795. @end example
  25796. This command starts a new Docker container from the specified image. It
  25797. will boot the Guix system in the usual manner, which means it will
  25798. start any services you have defined in the operating system
  25799. configuration. You can get an interactive shell running in the container
  25800. using @command{docker exec}:
  25801. @example
  25802. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  25803. @end example
  25804. Depending on what you run in the Docker container, it
  25805. may be necessary to give the container additional permissions. For
  25806. example, if you intend to build software using Guix inside of the Docker
  25807. container, you may need to pass the @option{--privileged} option to
  25808. @code{docker create}.
  25809. Last, the @option{--network} option applies to @command{guix system
  25810. docker-image}: it produces an image where network is supposedly shared
  25811. with the host, and thus without services like nscd or NetworkManager.
  25812. @item container
  25813. Return a script to run the operating system declared in @var{file}
  25814. within a container. Containers are a set of lightweight isolation
  25815. mechanisms provided by the kernel Linux-libre. Containers are
  25816. substantially less resource-demanding than full virtual machines since
  25817. the kernel, shared objects, and other resources can be shared with the
  25818. host system; this also means they provide thinner isolation.
  25819. Currently, the script must be run as root in order to support more than
  25820. a single user and group. The container shares its store with the host
  25821. system.
  25822. As with the @code{vm} action (@pxref{guix system vm}), additional file
  25823. systems to be shared between the host and container can be specified
  25824. using the @option{--share} and @option{--expose} options:
  25825. @example
  25826. guix system container my-config.scm \
  25827. --expose=$HOME --share=$HOME/tmp=/exchange
  25828. @end example
  25829. @quotation Note
  25830. This option requires Linux-libre 3.19 or newer.
  25831. @end quotation
  25832. @end table
  25833. @var{options} can contain any of the common build options (@pxref{Common
  25834. Build Options}). In addition, @var{options} can contain one of the
  25835. following:
  25836. @table @option
  25837. @item --expression=@var{expr}
  25838. @itemx -e @var{expr}
  25839. Consider the operating-system @var{expr} evaluates to.
  25840. This is an alternative to specifying a file which evaluates to an
  25841. operating system.
  25842. This is used to generate the Guix system installer @pxref{Building the
  25843. Installation Image}).
  25844. @item --system=@var{system}
  25845. @itemx -s @var{system}
  25846. Attempt to build for @var{system} instead of the host system type.
  25847. This works as per @command{guix build} (@pxref{Invoking guix build}).
  25848. @item --derivation
  25849. @itemx -d
  25850. Return the derivation file name of the given operating system without
  25851. building anything.
  25852. @cindex provenance tracking, of the operating system
  25853. @item --save-provenance
  25854. As discussed above, @command{guix system init} and @command{guix system
  25855. reconfigure} always save provenance information @i{via} a dedicated
  25856. service (@pxref{Service Reference, @code{provenance-service-type}}).
  25857. However, other commands don't do that by default. If you wish to, say,
  25858. create a virtual machine image that contains provenance information, you
  25859. can run:
  25860. @example
  25861. guix system image -t qcow2 --save-provenance config.scm
  25862. @end example
  25863. That way, the resulting image will effectively ``embed its own source''
  25864. in the form of meta-data in @file{/run/current-system}. With that
  25865. information, one can rebuild the image to make sure it really contains
  25866. what it pretends to contain; or they could use that to derive a variant
  25867. of the image.
  25868. @item --image-type=@var{type}
  25869. @itemx -t @var{type}
  25870. For the @code{image} action, create an image with given @var{type}.
  25871. When this option is omitted, @command{guix system} uses the
  25872. @code{efi-raw} image type.
  25873. @cindex ISO-9660 format
  25874. @cindex CD image format
  25875. @cindex DVD image format
  25876. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  25877. for burning on CDs and DVDs.
  25878. @item --image-size=@var{size}
  25879. For the @code{image} action, create an image of the given @var{size}.
  25880. @var{size} may be a number of bytes, or it may include a unit as a
  25881. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  25882. Coreutils}).
  25883. When this option is omitted, @command{guix system} computes an estimate
  25884. of the image size as a function of the size of the system declared in
  25885. @var{file}.
  25886. @item --network
  25887. @itemx -N
  25888. For the @code{container} action, allow containers to access the host network,
  25889. that is, do not create a network namespace.
  25890. @item --root=@var{file}
  25891. @itemx -r @var{file}
  25892. Make @var{file} a symlink to the result, and register it as a garbage
  25893. collector root.
  25894. @item --skip-checks
  25895. Skip pre-installation safety checks.
  25896. By default, @command{guix system init} and @command{guix system
  25897. reconfigure} perform safety checks: they make sure the file systems that
  25898. appear in the @code{operating-system} declaration actually exist
  25899. (@pxref{File Systems}), and that any Linux kernel modules that may be
  25900. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  25901. RAM Disk}). Passing this option skips these tests altogether.
  25902. @item --allow-downgrades
  25903. Instruct @command{guix system reconfigure} to allow system downgrades.
  25904. By default, @command{reconfigure} prevents you from downgrading your
  25905. system. It achieves that by comparing the provenance info of your
  25906. system (shown by @command{guix system describe}) with that of your
  25907. @command{guix} command (shown by @command{guix describe}). If the
  25908. commits for @command{guix} are not descendants of those used for your
  25909. system, @command{guix system reconfigure} errors out. Passing
  25910. @option{--allow-downgrades} allows you to bypass these checks.
  25911. @quotation Note
  25912. Make sure you understand its security implications before using
  25913. @option{--allow-downgrades}.
  25914. @end quotation
  25915. @cindex on-error
  25916. @cindex on-error strategy
  25917. @cindex error strategy
  25918. @item --on-error=@var{strategy}
  25919. Apply @var{strategy} when an error occurs when reading @var{file}.
  25920. @var{strategy} may be one of the following:
  25921. @table @code
  25922. @item nothing-special
  25923. Report the error concisely and exit. This is the default strategy.
  25924. @item backtrace
  25925. Likewise, but also display a backtrace.
  25926. @item debug
  25927. Report the error and enter Guile's debugger. From there, you can run
  25928. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  25929. display local variable values, and more generally inspect the state of the
  25930. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  25931. a list of available debugging commands.
  25932. @end table
  25933. @end table
  25934. Once you have built, configured, re-configured, and re-re-configured
  25935. your Guix installation, you may find it useful to list the operating
  25936. system generations available on disk---and that you can choose from the
  25937. bootloader boot menu:
  25938. @table @code
  25939. @item describe
  25940. Describe the current system generation: its file name, the kernel and
  25941. bootloader used, etc., as well as provenance information when available.
  25942. @item list-generations
  25943. List a summary of each generation of the operating system available on
  25944. disk, in a human-readable way. This is similar to the
  25945. @option{--list-generations} option of @command{guix package}
  25946. (@pxref{Invoking guix package}).
  25947. Optionally, one can specify a pattern, with the same syntax that is used
  25948. in @command{guix package --list-generations}, to restrict the list of
  25949. generations displayed. For instance, the following command displays
  25950. generations that are up to 10 days old:
  25951. @example
  25952. $ guix system list-generations 10d
  25953. @end example
  25954. @end table
  25955. The @command{guix system} command has even more to offer! The following
  25956. sub-commands allow you to visualize how your system services relate to
  25957. each other:
  25958. @anchor{system-extension-graph}
  25959. @table @code
  25960. @item extension-graph
  25961. Emit to standard output the @dfn{service
  25962. extension graph} of the operating system defined in @var{file}
  25963. (@pxref{Service Composition}, for more information on service
  25964. extensions). By default the output is in Dot/Graphviz format, but you
  25965. can choose a different format with @option{--graph-backend}, as with
  25966. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  25967. The command:
  25968. @example
  25969. $ guix system extension-graph @var{file} | xdot -
  25970. @end example
  25971. shows the extension relations among services.
  25972. @anchor{system-shepherd-graph}
  25973. @item shepherd-graph
  25974. Emit to standard output the @dfn{dependency
  25975. graph} of shepherd services of the operating system defined in
  25976. @var{file}. @xref{Shepherd Services}, for more information and for an
  25977. example graph.
  25978. Again, the default output format is Dot/Graphviz, but you can pass
  25979. @option{--graph-backend} to select a different one.
  25980. @end table
  25981. @node Invoking guix deploy
  25982. @section Invoking @code{guix deploy}
  25983. We've already seen @code{operating-system} declarations used to manage a
  25984. machine's configuration locally. Suppose you need to configure multiple
  25985. machines, though---perhaps you're managing a service on the web that's
  25986. comprised of several servers. @command{guix deploy} enables you to use those
  25987. same @code{operating-system} declarations to manage multiple remote hosts at
  25988. once as a logical ``deployment''.
  25989. @quotation Note
  25990. The functionality described in this section is still under development
  25991. and is subject to change. Get in touch with us on
  25992. @email{guix-devel@@gnu.org}!
  25993. @end quotation
  25994. @example
  25995. guix deploy @var{file}
  25996. @end example
  25997. Such an invocation will deploy the machines that the code within @var{file}
  25998. evaluates to. As an example, @var{file} might contain a definition like this:
  25999. @lisp
  26000. ;; This is a Guix deployment of a "bare bones" setup, with
  26001. ;; no X11 display server, to a machine with an SSH daemon
  26002. ;; listening on localhost:2222. A configuration such as this
  26003. ;; may be appropriate for virtual machine with ports
  26004. ;; forwarded to the host's loopback interface.
  26005. (use-service-modules networking ssh)
  26006. (use-package-modules bootloaders)
  26007. (define %system
  26008. (operating-system
  26009. (host-name "gnu-deployed")
  26010. (timezone "Etc/UTC")
  26011. (bootloader (bootloader-configuration
  26012. (bootloader grub-bootloader)
  26013. (target "/dev/vda")
  26014. (terminal-outputs '(console))))
  26015. (file-systems (cons (file-system
  26016. (mount-point "/")
  26017. (device "/dev/vda1")
  26018. (type "ext4"))
  26019. %base-file-systems))
  26020. (services
  26021. (append (list (service dhcp-client-service-type)
  26022. (service openssh-service-type
  26023. (openssh-configuration
  26024. (permit-root-login #t)
  26025. (allow-empty-passwords? #t))))
  26026. %base-services))))
  26027. (list (machine
  26028. (operating-system %system)
  26029. (environment managed-host-environment-type)
  26030. (configuration (machine-ssh-configuration
  26031. (host-name "localhost")
  26032. (system "x86_64-linux")
  26033. (user "alice")
  26034. (identity "./id_rsa")
  26035. (port 2222)))))
  26036. @end lisp
  26037. The file should evaluate to a list of @var{machine} objects. This example,
  26038. upon being deployed, will create a new generation on the remote system
  26039. realizing the @code{operating-system} declaration @code{%system}.
  26040. @code{environment} and @code{configuration} specify how the machine should be
  26041. provisioned---that is, how the computing resources should be created and
  26042. managed. The above example does not create any resources, as a
  26043. @code{'managed-host} is a machine that is already running the Guix system and
  26044. available over the network. This is a particularly simple case; a more
  26045. complex deployment may involve, for example, starting virtual machines through
  26046. a Virtual Private Server (VPS) provider. In such a case, a different
  26047. @var{environment} type would be used.
  26048. Do note that you first need to generate a key pair on the coordinator machine
  26049. to allow the daemon to export signed archives of files from the store
  26050. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  26051. System:
  26052. @example
  26053. # guix archive --generate-key
  26054. @end example
  26055. @noindent
  26056. Each target machine must authorize the key of the master machine so that it
  26057. accepts store items it receives from the coordinator:
  26058. @example
  26059. # guix archive --authorize < coordinator-public-key.txt
  26060. @end example
  26061. @code{user}, in this example, specifies the name of the user account to log in
  26062. as to perform the deployment. Its default value is @code{root}, but root
  26063. login over SSH may be forbidden in some cases. To work around this,
  26064. @command{guix deploy} can log in as an unprivileged user and employ
  26065. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  26066. currently installed on the remote and can be invoked non-interactively as
  26067. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  26068. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  26069. be accomplished with the following operating system configuration snippet:
  26070. @lisp
  26071. (use-modules ...
  26072. (gnu system)) ;for %sudoers-specification
  26073. (define %user "username")
  26074. (operating-system
  26075. ...
  26076. (sudoers-file
  26077. (plain-file "sudoers"
  26078. (string-append (plain-file-content %sudoers-specification)
  26079. (format #f "~a ALL = NOPASSWD: ALL~%"
  26080. %user)))))
  26081. @end lisp
  26082. For more information regarding the format of the @file{sudoers} file,
  26083. consult @command{man sudoers}.
  26084. @deftp {Data Type} machine
  26085. This is the data type representing a single machine in a heterogeneous Guix
  26086. deployment.
  26087. @table @asis
  26088. @item @code{operating-system}
  26089. The object of the operating system configuration to deploy.
  26090. @item @code{environment}
  26091. An @code{environment-type} describing how the machine should be provisioned.
  26092. @item @code{configuration} (default: @code{#f})
  26093. An object describing the configuration for the machine's @code{environment}.
  26094. If the @code{environment} has a default configuration, @code{#f} may be used.
  26095. If @code{#f} is used for an environment with no default configuration,
  26096. however, an error will be thrown.
  26097. @end table
  26098. @end deftp
  26099. @deftp {Data Type} machine-ssh-configuration
  26100. This is the data type representing the SSH client parameters for a machine
  26101. with an @code{environment} of @code{managed-host-environment-type}.
  26102. @table @asis
  26103. @item @code{host-name}
  26104. @item @code{build-locally?} (default: @code{#t})
  26105. If false, system derivations will be built on the machine being deployed to.
  26106. @item @code{system}
  26107. The system type describing the architecture of the machine being deployed
  26108. to---e.g., @code{"x86_64-linux"}.
  26109. @item @code{authorize?} (default: @code{#t})
  26110. If true, the coordinator's signing key will be added to the remote's ACL
  26111. keyring.
  26112. @item @code{port} (default: @code{22})
  26113. @item @code{user} (default: @code{"root"})
  26114. @item @code{identity} (default: @code{#f})
  26115. If specified, the path to the SSH private key to use to authenticate with the
  26116. remote host.
  26117. @item @code{host-key} (default: @code{#f})
  26118. This should be the SSH host key of the machine, which looks like this:
  26119. @example
  26120. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  26121. @end example
  26122. When @code{host-key} is @code{#f}, the server is authenticated against
  26123. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  26124. client does.
  26125. @item @code{allow-downgrades?} (default: @code{#f})
  26126. Whether to allow potential downgrades.
  26127. Like @command{guix system reconfigure}, @command{guix deploy} compares
  26128. the channel commits currently deployed on the remote host (as returned
  26129. by @command{guix system describe}) to those currently in use (as
  26130. returned by @command{guix describe}) to determine whether commits
  26131. currently in use are descendants of those deployed. When this is not
  26132. the case and @code{allow-downgrades?} is false, it raises an error.
  26133. This ensures you do not accidentally downgrade remote machines.
  26134. @end table
  26135. @end deftp
  26136. @deftp {Data Type} digital-ocean-configuration
  26137. This is the data type describing the Droplet that should be created for a
  26138. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  26139. @table @asis
  26140. @item @code{ssh-key}
  26141. The path to the SSH private key to use to authenticate with the remote
  26142. host. In the future, this field may not exist.
  26143. @item @code{tags}
  26144. A list of string ``tags'' that uniquely identify the machine. Must be given
  26145. such that no two machines in the deployment have the same set of tags.
  26146. @item @code{region}
  26147. A Digital Ocean region slug, such as @code{"nyc3"}.
  26148. @item @code{size}
  26149. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  26150. @item @code{enable-ipv6?}
  26151. Whether or not the droplet should be created with IPv6 networking.
  26152. @end table
  26153. @end deftp
  26154. @node Running Guix in a VM
  26155. @section Running Guix in a Virtual Machine
  26156. @cindex virtual machine
  26157. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
  26158. distributed at
  26159. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.xz}.
  26160. This image is a compressed image in QCOW format. You will first need to
  26161. decompress with @command{xz -d}, and then you can pass it to an emulator such
  26162. as QEMU (see below for details).
  26163. This image boots the Xfce graphical environment and it contains some
  26164. commonly used tools. You can install more software in the image by running
  26165. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  26166. also reconfigure the system based on its initial configuration file available
  26167. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  26168. Configuration System}).
  26169. Instead of using this pre-built image, one can also build their own virtual
  26170. machine image using @command{guix system vm-image} (@pxref{Invoking guix
  26171. system}). The returned image is in qcow2 format, which the
  26172. @uref{https://qemu.org/, QEMU emulator} can efficiently use.
  26173. @cindex QEMU
  26174. If you built your own image, you must copy it out of the store
  26175. (@pxref{The Store}) and give yourself permission to write to the copy
  26176. before you can use it. When invoking QEMU, you must choose a system
  26177. emulator that is suitable for your hardware platform. Here is a minimal
  26178. QEMU invocation that will boot the result of @command{guix system
  26179. image -t qcow2} on x86_64 hardware:
  26180. @example
  26181. $ qemu-system-x86_64 \
  26182. -nic user,model=virtio-net-pci \
  26183. -enable-kvm -m 1024 \
  26184. -device virtio-blk,drive=myhd \
  26185. -drive if=none,file=/tmp/qemu-image,id=myhd
  26186. @end example
  26187. Here is what each of these options means:
  26188. @table @code
  26189. @item qemu-system-x86_64
  26190. This specifies the hardware platform to emulate. This should match the
  26191. host.
  26192. @item -nic user,model=virtio-net-pci
  26193. Enable the unprivileged user-mode network stack. The guest OS can
  26194. access the host but not vice versa. This is the simplest way to get the
  26195. guest OS online. @code{model} specifies which network device to emulate:
  26196. @code{virtio-net-pci} is a special device made for virtualized operating
  26197. systems and recommended for most uses. Assuming your hardware platform is
  26198. x86_64, you can get a list of available NIC models by running
  26199. @command{qemu-system-x86_64 -nic model=help}.
  26200. @item -enable-kvm
  26201. If your system has hardware virtualization extensions, enabling the
  26202. virtual machine support (KVM) of the Linux kernel will make things run
  26203. faster.
  26204. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  26205. @item -m 1024
  26206. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  26207. which may be insufficient for some operations.
  26208. @item -device virtio-blk,drive=myhd
  26209. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  26210. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  26211. better performance than if it were emulating a complete disk drive. See the
  26212. QEMU and KVM documentation for more info.
  26213. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  26214. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  26215. store of the ``myhd'' drive.
  26216. @end table
  26217. The default @command{run-vm.sh} script that is returned by an invocation of
  26218. @command{guix system vm} does not add a @command{-nic user} flag by default.
  26219. To get network access from within the vm add the @code{(dhcp-client-service)}
  26220. to your system definition and start the VM using
  26221. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  26222. @command{-nic user} for networking is that @command{ping} will not work, because
  26223. it uses the ICMP protocol. You'll have to use a different command to check for
  26224. network connectivity, for example @command{guix download}.
  26225. @subsection Connecting Through SSH
  26226. @cindex SSH
  26227. @cindex SSH server
  26228. To enable SSH inside a VM you need to add an SSH server like
  26229. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  26230. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  26231. 22 by default, to the host. You can do this with
  26232. @example
  26233. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  26234. @end example
  26235. To connect to the VM you can run
  26236. @example
  26237. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
  26238. @end example
  26239. The @command{-p} tells @command{ssh} the port you want to connect to.
  26240. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  26241. every time you modify your @command{config.scm} file and the
  26242. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  26243. connection to an unknown host every time you connect.
  26244. @subsection Using @command{virt-viewer} with Spice
  26245. As an alternative to the default @command{qemu} graphical client you can
  26246. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  26247. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  26248. @command{qemu}. See previous section for further information on how to do this.
  26249. Spice also allows you to do some nice stuff like share your clipboard with your
  26250. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  26251. @example
  26252. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  26253. -chardev spicevmc,name=vdagent,id=vdagent
  26254. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  26255. name=com.redhat.spice.0
  26256. @end example
  26257. You'll also need to add the @code{(spice-vdagent-service)} to your
  26258. system definition (@pxref{Miscellaneous Services, Spice service}).
  26259. @node Defining Services
  26260. @section Defining Services
  26261. The previous sections show the available services and how one can combine
  26262. them in an @code{operating-system} declaration. But how do we define
  26263. them in the first place? And what is a service anyway?
  26264. @menu
  26265. * Service Composition:: The model for composing services.
  26266. * Service Types and Services:: Types and services.
  26267. * Service Reference:: API reference.
  26268. * Shepherd Services:: A particular type of service.
  26269. @end menu
  26270. @node Service Composition
  26271. @subsection Service Composition
  26272. @cindex services
  26273. @cindex daemons
  26274. Here we define a @dfn{service} as, broadly, something that extends the
  26275. functionality of the operating system. Often a service is a process---a
  26276. @dfn{daemon}---started when the system boots: a secure shell server, a
  26277. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  26278. whose execution can be triggered by another daemon---e.g., an FTP server
  26279. started by @command{inetd} or a D-Bus service activated by
  26280. @command{dbus-daemon}. Occasionally, a service does not map to a
  26281. daemon. For instance, the ``account'' service collects user accounts
  26282. and makes sure they exist when the system runs; the ``udev'' service
  26283. collects device management rules and makes them available to the eudev
  26284. daemon; the @file{/etc} service populates the @file{/etc} directory
  26285. of the system.
  26286. @cindex service extensions
  26287. Guix system services are connected by @dfn{extensions}. For instance, the
  26288. secure shell service @emph{extends} the Shepherd---the
  26289. initialization system, running as PID@tie{}1---by giving it the command
  26290. lines to start and stop the secure shell daemon (@pxref{Networking
  26291. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  26292. service by passing it its @file{.service} specification, and extends the
  26293. udev service by passing it device management rules (@pxref{Desktop
  26294. Services, @code{upower-service}}); the Guix daemon service extends the
  26295. Shepherd by passing it the command lines to start and stop the daemon,
  26296. and extends the account service by passing it a list of required build
  26297. user accounts (@pxref{Base Services}).
  26298. All in all, services and their ``extends'' relations form a directed
  26299. acyclic graph (DAG). If we represent services as boxes and extensions
  26300. as arrows, a typical system might provide something like this:
  26301. @image{images/service-graph,,5in,Typical service extension graph.}
  26302. @cindex system service
  26303. At the bottom, we see the @dfn{system service}, which produces the
  26304. directory containing everything to run and boot the system, as returned
  26305. by the @command{guix system build} command. @xref{Service Reference},
  26306. to learn about the other service types shown here.
  26307. @xref{system-extension-graph, the @command{guix system extension-graph}
  26308. command}, for information on how to generate this representation for a
  26309. particular operating system definition.
  26310. @cindex service types
  26311. Technically, developers can define @dfn{service types} to express these
  26312. relations. There can be any number of services of a given type on the
  26313. system---for instance, a system running two instances of the GNU secure
  26314. shell server (lsh) has two instances of @code{lsh-service-type}, with
  26315. different parameters.
  26316. The following section describes the programming interface for service
  26317. types and services.
  26318. @node Service Types and Services
  26319. @subsection Service Types and Services
  26320. A @dfn{service type} is a node in the DAG described above. Let us start
  26321. with a simple example, the service type for the Guix build daemon
  26322. (@pxref{Invoking guix-daemon}):
  26323. @lisp
  26324. (define guix-service-type
  26325. (service-type
  26326. (name 'guix)
  26327. (extensions
  26328. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  26329. (service-extension account-service-type guix-accounts)
  26330. (service-extension activation-service-type guix-activation)))
  26331. (default-value (guix-configuration))))
  26332. @end lisp
  26333. @noindent
  26334. It defines three things:
  26335. @enumerate
  26336. @item
  26337. A name, whose sole purpose is to make inspection and debugging easier.
  26338. @item
  26339. A list of @dfn{service extensions}, where each extension designates the
  26340. target service type and a procedure that, given the parameters of the
  26341. service, returns a list of objects to extend the service of that type.
  26342. Every service type has at least one service extension. The only
  26343. exception is the @dfn{boot service type}, which is the ultimate service.
  26344. @item
  26345. Optionally, a default value for instances of this type.
  26346. @end enumerate
  26347. In this example, @code{guix-service-type} extends three services:
  26348. @table @code
  26349. @item shepherd-root-service-type
  26350. The @code{guix-shepherd-service} procedure defines how the Shepherd
  26351. service is extended. Namely, it returns a @code{<shepherd-service>}
  26352. object that defines how @command{guix-daemon} is started and stopped
  26353. (@pxref{Shepherd Services}).
  26354. @item account-service-type
  26355. This extension for this service is computed by @code{guix-accounts},
  26356. which returns a list of @code{user-group} and @code{user-account}
  26357. objects representing the build user accounts (@pxref{Invoking
  26358. guix-daemon}).
  26359. @item activation-service-type
  26360. Here @code{guix-activation} is a procedure that returns a gexp, which is
  26361. a code snippet to run at ``activation time''---e.g., when the service is
  26362. booted.
  26363. @end table
  26364. A service of this type is instantiated like this:
  26365. @lisp
  26366. (service guix-service-type
  26367. (guix-configuration
  26368. (build-accounts 5)
  26369. (extra-options '("--gc-keep-derivations"))))
  26370. @end lisp
  26371. The second argument to the @code{service} form is a value representing
  26372. the parameters of this specific service instance.
  26373. @xref{guix-configuration-type, @code{guix-configuration}}, for
  26374. information about the @code{guix-configuration} data type. When the
  26375. value is omitted, the default value specified by
  26376. @code{guix-service-type} is used:
  26377. @lisp
  26378. (service guix-service-type)
  26379. @end lisp
  26380. @code{guix-service-type} is quite simple because it extends other
  26381. services but is not extensible itself.
  26382. @c @subsubsubsection Extensible Service Types
  26383. The service type for an @emph{extensible} service looks like this:
  26384. @lisp
  26385. (define udev-service-type
  26386. (service-type (name 'udev)
  26387. (extensions
  26388. (list (service-extension shepherd-root-service-type
  26389. udev-shepherd-service)))
  26390. (compose concatenate) ;concatenate the list of rules
  26391. (extend (lambda (config rules)
  26392. (match config
  26393. (($ <udev-configuration> udev initial-rules)
  26394. (udev-configuration
  26395. (udev udev) ;the udev package to use
  26396. (rules (append initial-rules rules)))))))))
  26397. @end lisp
  26398. This is the service type for the
  26399. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  26400. management daemon}. Compared to the previous example, in addition to an
  26401. extension of @code{shepherd-root-service-type}, we see two new fields:
  26402. @table @code
  26403. @item compose
  26404. This is the procedure to @dfn{compose} the list of extensions to
  26405. services of this type.
  26406. Services can extend the udev service by passing it lists of rules; we
  26407. compose those extensions simply by concatenating them.
  26408. @item extend
  26409. This procedure defines how the value of the service is @dfn{extended} with
  26410. the composition of the extensions.
  26411. Udev extensions are composed into a list of rules, but the udev service
  26412. value is itself a @code{<udev-configuration>} record. So here, we
  26413. extend that record by appending the list of rules it contains to the
  26414. list of contributed rules.
  26415. @item description
  26416. This is a string giving an overview of the service type. The string can
  26417. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  26418. @command{guix system search} command searches these strings and displays
  26419. them (@pxref{Invoking guix system}).
  26420. @end table
  26421. There can be only one instance of an extensible service type such as
  26422. @code{udev-service-type}. If there were more, the
  26423. @code{service-extension} specifications would be ambiguous.
  26424. Still here? The next section provides a reference of the programming
  26425. interface for services.
  26426. @node Service Reference
  26427. @subsection Service Reference
  26428. We have seen an overview of service types (@pxref{Service Types and
  26429. Services}). This section provides a reference on how to manipulate
  26430. services and service types. This interface is provided by the
  26431. @code{(gnu services)} module.
  26432. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  26433. Return a new service of @var{type}, a @code{<service-type>} object (see
  26434. below). @var{value} can be any object; it represents the parameters of
  26435. this particular service instance.
  26436. When @var{value} is omitted, the default value specified by @var{type}
  26437. is used; if @var{type} does not specify a default value, an error is
  26438. raised.
  26439. For instance, this:
  26440. @lisp
  26441. (service openssh-service-type)
  26442. @end lisp
  26443. @noindent
  26444. is equivalent to this:
  26445. @lisp
  26446. (service openssh-service-type
  26447. (openssh-configuration))
  26448. @end lisp
  26449. In both cases the result is an instance of @code{openssh-service-type}
  26450. with the default configuration.
  26451. @end deffn
  26452. @deffn {Scheme Procedure} service? @var{obj}
  26453. Return true if @var{obj} is a service.
  26454. @end deffn
  26455. @deffn {Scheme Procedure} service-kind @var{service}
  26456. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  26457. @end deffn
  26458. @deffn {Scheme Procedure} service-value @var{service}
  26459. Return the value associated with @var{service}. It represents its
  26460. parameters.
  26461. @end deffn
  26462. Here is an example of how a service is created and manipulated:
  26463. @lisp
  26464. (define s
  26465. (service nginx-service-type
  26466. (nginx-configuration
  26467. (nginx nginx)
  26468. (log-directory log-directory)
  26469. (run-directory run-directory)
  26470. (file config-file))))
  26471. (service? s)
  26472. @result{} #t
  26473. (eq? (service-kind s) nginx-service-type)
  26474. @result{} #t
  26475. @end lisp
  26476. The @code{modify-services} form provides a handy way to change the
  26477. parameters of some of the services of a list such as
  26478. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  26479. evaluates to a list of services. Of course, you could always use
  26480. standard list combinators such as @code{map} and @code{fold} to do that
  26481. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  26482. @code{modify-services} simply provides a more concise form for this
  26483. common pattern.
  26484. @deffn {Scheme Syntax} modify-services @var{services} @
  26485. (@var{type} @var{variable} => @var{body}) @dots{}
  26486. Modify the services listed in @var{services} according to the given
  26487. clauses. Each clause has the form:
  26488. @example
  26489. (@var{type} @var{variable} => @var{body})
  26490. @end example
  26491. where @var{type} is a service type---e.g.,
  26492. @code{guix-service-type}---and @var{variable} is an identifier that is
  26493. bound within the @var{body} to the service parameters---e.g., a
  26494. @code{guix-configuration} instance---of the original service of that
  26495. @var{type}.
  26496. The @var{body} should evaluate to the new service parameters, which will
  26497. be used to configure the new service. This new service will replace the
  26498. original in the resulting list. Because a service's service parameters
  26499. are created using @code{define-record-type*}, you can write a succinct
  26500. @var{body} that evaluates to the new service parameters by using the
  26501. @code{inherit} feature that @code{define-record-type*} provides.
  26502. @xref{Using the Configuration System}, for example usage.
  26503. @end deffn
  26504. Next comes the programming interface for service types. This is
  26505. something you want to know when writing new service definitions, but not
  26506. necessarily when simply looking for ways to customize your
  26507. @code{operating-system} declaration.
  26508. @deftp {Data Type} service-type
  26509. @cindex service type
  26510. This is the representation of a @dfn{service type} (@pxref{Service Types
  26511. and Services}).
  26512. @table @asis
  26513. @item @code{name}
  26514. This is a symbol, used only to simplify inspection and debugging.
  26515. @item @code{extensions}
  26516. A non-empty list of @code{<service-extension>} objects (see below).
  26517. @item @code{compose} (default: @code{#f})
  26518. If this is @code{#f}, then the service type denotes services that cannot
  26519. be extended---i.e., services that do not receive ``values'' from other
  26520. services.
  26521. Otherwise, it must be a one-argument procedure. The procedure is called
  26522. by @code{fold-services} and is passed a list of values collected from
  26523. extensions. It may return any single value.
  26524. @item @code{extend} (default: @code{#f})
  26525. If this is @code{#f}, services of this type cannot be extended.
  26526. Otherwise, it must be a two-argument procedure: @code{fold-services}
  26527. calls it, passing it the initial value of the service as the first
  26528. argument and the result of applying @code{compose} to the extension
  26529. values as the second argument. It must return a value that is a valid
  26530. parameter value for the service instance.
  26531. @item @code{description}
  26532. This is a string, possibly using Texinfo markup, describing in a couple
  26533. of sentences what the service is about. This string allows users to
  26534. find about the service through @command{guix system search}
  26535. (@pxref{Invoking guix system}).
  26536. @item @code{default-value} (default: @code{&no-default-value})
  26537. The default value associated for instances of this service type. This
  26538. allows users to use the @code{service} form without its second argument:
  26539. @lisp
  26540. (service @var{type})
  26541. @end lisp
  26542. The returned service in this case has the default value specified by
  26543. @var{type}.
  26544. @end table
  26545. @xref{Service Types and Services}, for examples.
  26546. @end deftp
  26547. @deffn {Scheme Procedure} service-extension @var{target-type} @
  26548. @var{compute}
  26549. Return a new extension for services of type @var{target-type}.
  26550. @var{compute} must be a one-argument procedure: @code{fold-services}
  26551. calls it, passing it the value associated with the service that provides
  26552. the extension; it must return a valid value for the target service.
  26553. @end deffn
  26554. @deffn {Scheme Procedure} service-extension? @var{obj}
  26555. Return true if @var{obj} is a service extension.
  26556. @end deffn
  26557. Occasionally, you might want to simply extend an existing service. This
  26558. involves creating a new service type and specifying the extension of
  26559. interest, which can be verbose; the @code{simple-service} procedure
  26560. provides a shorthand for this.
  26561. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  26562. Return a service that extends @var{target} with @var{value}. This works
  26563. by creating a singleton service type @var{name}, of which the returned
  26564. service is an instance.
  26565. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  26566. an additional job:
  26567. @lisp
  26568. (simple-service 'my-mcron-job mcron-service-type
  26569. #~(job '(next-hour (3)) "guix gc -F 2G"))
  26570. @end lisp
  26571. @end deffn
  26572. At the core of the service abstraction lies the @code{fold-services}
  26573. procedure, which is responsible for ``compiling'' a list of services
  26574. down to a single directory that contains everything needed to boot and
  26575. run the system---the directory shown by the @command{guix system build}
  26576. command (@pxref{Invoking guix system}). In essence, it propagates
  26577. service extensions down the service graph, updating each node parameters
  26578. on the way, until it reaches the root node.
  26579. @deffn {Scheme Procedure} fold-services @var{services} @
  26580. [#:target-type @var{system-service-type}]
  26581. Fold @var{services} by propagating their extensions down to the root of
  26582. type @var{target-type}; return the root service adjusted accordingly.
  26583. @end deffn
  26584. Lastly, the @code{(gnu services)} module also defines several essential
  26585. service types, some of which are listed below.
  26586. @defvr {Scheme Variable} system-service-type
  26587. This is the root of the service graph. It produces the system directory
  26588. as returned by the @command{guix system build} command.
  26589. @end defvr
  26590. @defvr {Scheme Variable} boot-service-type
  26591. The type of the ``boot service'', which produces the @dfn{boot script}.
  26592. The boot script is what the initial RAM disk runs when booting.
  26593. @end defvr
  26594. @defvr {Scheme Variable} etc-service-type
  26595. The type of the @file{/etc} service. This service is used to create
  26596. files under @file{/etc} and can be extended by
  26597. passing it name/file tuples such as:
  26598. @lisp
  26599. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  26600. @end lisp
  26601. In this example, the effect would be to add an @file{/etc/issue} file
  26602. pointing to the given file.
  26603. @end defvr
  26604. @defvr {Scheme Variable} setuid-program-service-type
  26605. Type for the ``setuid-program service''. This service collects lists of
  26606. executable file names, passed as gexps, and adds them to the set of
  26607. setuid-root programs on the system (@pxref{Setuid Programs}).
  26608. @end defvr
  26609. @defvr {Scheme Variable} profile-service-type
  26610. Type of the service that populates the @dfn{system profile}---i.e., the
  26611. programs under @file{/run/current-system/profile}. Other services can
  26612. extend it by passing it lists of packages to add to the system profile.
  26613. @end defvr
  26614. @cindex provenance tracking, of the operating system
  26615. @anchor{provenance-service-type}
  26616. @defvr {Scheme Variable} provenance-service-type
  26617. This is the type of the service that records @dfn{provenance meta-data}
  26618. in the system itself. It creates several files under
  26619. @file{/run/current-system}:
  26620. @table @file
  26621. @item channels.scm
  26622. This is a ``channel file'' that can be passed to @command{guix pull -C}
  26623. or @command{guix time-machine -C}, and which describes the channels used
  26624. to build the system, if that information was available
  26625. (@pxref{Channels}).
  26626. @item configuration.scm
  26627. This is the file that was passed as the value for this
  26628. @code{provenance-service-type} service. By default, @command{guix
  26629. system reconfigure} automatically passes the OS configuration file it
  26630. received on the command line.
  26631. @item provenance
  26632. This contains the same information as the two other files but in a
  26633. format that is more readily processable.
  26634. @end table
  26635. In general, these two pieces of information (channels and configuration
  26636. file) are enough to reproduce the operating system ``from source''.
  26637. @quotation Caveats
  26638. This information is necessary to rebuild your operating system, but it
  26639. is not always sufficient. In particular, @file{configuration.scm}
  26640. itself is insufficient if it is not self-contained---if it refers to
  26641. external Guile modules or to extra files. If you want
  26642. @file{configuration.scm} to be self-contained, we recommend that modules
  26643. or files it refers to be part of a channel.
  26644. Besides, provenance meta-data is ``silent'' in the sense that it does
  26645. not change the bits contained in your system, @emph{except for the
  26646. meta-data bits themselves}. Two different OS configurations or sets of
  26647. channels can lead to the same system, bit-for-bit; when
  26648. @code{provenance-service-type} is used, these two systems will have
  26649. different meta-data and thus different store file names, which makes
  26650. comparison less trivial.
  26651. @end quotation
  26652. This service is automatically added to your operating system
  26653. configuration when you use @command{guix system reconfigure},
  26654. @command{guix system init}, or @command{guix deploy}.
  26655. @end defvr
  26656. @node Shepherd Services
  26657. @subsection Shepherd Services
  26658. @cindex shepherd services
  26659. @cindex PID 1
  26660. @cindex init system
  26661. The @code{(gnu services shepherd)} module provides a way to define
  26662. services managed by the GNU@tie{}Shepherd, which is the
  26663. initialization system---the first process that is started when the
  26664. system boots, also known as PID@tie{}1
  26665. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  26666. Services in the Shepherd can depend on each other. For instance, the
  26667. SSH daemon may need to be started after the syslog daemon has been
  26668. started, which in turn can only happen once all the file systems have
  26669. been mounted. The simple operating system defined earlier (@pxref{Using
  26670. the Configuration System}) results in a service graph like this:
  26671. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  26672. You can actually generate such a graph for any operating system
  26673. definition using the @command{guix system shepherd-graph} command
  26674. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  26675. The @code{%shepherd-root-service} is a service object representing
  26676. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  26677. by passing it lists of @code{<shepherd-service>} objects.
  26678. @deftp {Data Type} shepherd-service
  26679. The data type representing a service managed by the Shepherd.
  26680. @table @asis
  26681. @item @code{provision}
  26682. This is a list of symbols denoting what the service provides.
  26683. These are the names that may be passed to @command{herd start},
  26684. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  26685. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  26686. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  26687. @item @code{requirement} (default: @code{'()})
  26688. List of symbols denoting the Shepherd services this one depends on.
  26689. @cindex one-shot services, for the Shepherd
  26690. @item @code{one-shot?} (default: @code{#f})
  26691. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  26692. after their @code{start} action has completed. @xref{Slots of services,,,
  26693. shepherd, The GNU Shepherd Manual}, for more info.
  26694. @item @code{respawn?} (default: @code{#t})
  26695. Whether to restart the service when it stops, for instance when the
  26696. underlying process dies.
  26697. @item @code{start}
  26698. @itemx @code{stop} (default: @code{#~(const #f)})
  26699. The @code{start} and @code{stop} fields refer to the Shepherd's
  26700. facilities to start and stop processes (@pxref{Service De- and
  26701. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  26702. G-expressions that get expanded in the Shepherd configuration file
  26703. (@pxref{G-Expressions}).
  26704. @item @code{actions} (default: @code{'()})
  26705. @cindex actions, of Shepherd services
  26706. This is a list of @code{shepherd-action} objects (see below) defining
  26707. @dfn{actions} supported by the service, in addition to the standard
  26708. @code{start} and @code{stop} actions. Actions listed here become available as
  26709. @command{herd} sub-commands:
  26710. @example
  26711. herd @var{action} @var{service} [@var{arguments}@dots{}]
  26712. @end example
  26713. @item @code{auto-start?} (default: @code{#t})
  26714. Whether this service should be started automatically by the Shepherd. If it
  26715. is @code{#f} the service has to be started manually with @code{herd start}.
  26716. @item @code{documentation}
  26717. A documentation string, as shown when running:
  26718. @example
  26719. herd doc @var{service-name}
  26720. @end example
  26721. where @var{service-name} is one of the symbols in @code{provision}
  26722. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  26723. @item @code{modules} (default: @code{%default-modules})
  26724. This is the list of modules that must be in scope when @code{start} and
  26725. @code{stop} are evaluated.
  26726. @end table
  26727. @end deftp
  26728. The example below defines a Shepherd service that spawns
  26729. @command{syslogd}, the system logger from the GNU Networking Utilities
  26730. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  26731. Inetutils}):
  26732. @example
  26733. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  26734. (shepherd-service
  26735. (documentation "Run the syslog daemon (syslogd).")
  26736. (provision '(syslogd))
  26737. (requirement '(user-processes))
  26738. (start #~(make-forkexec-constructor
  26739. (list #$(file-append inetutils "/libexec/syslogd")
  26740. "--rcfile" #$config)
  26741. #:pid-file "/var/run/syslog.pid"))
  26742. (stop #~(make-kill-destructor))))
  26743. @end example
  26744. Key elements in this example are the @code{start} and @code{stop}
  26745. fields: they are @dfn{staged} code snippets that use the
  26746. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  26747. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  26748. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  26749. field will have @command{shepherd} spawn @command{syslogd} with the
  26750. given option; note that we pass @code{config} after @option{--rcfile},
  26751. which is a configuration file declared above (contents of this file are
  26752. omitted). Likewise, the @code{stop} field tells how this service is to
  26753. be stopped; in this case, it is stopped by making the @code{kill} system
  26754. call on its PID@. Code staging is achieved using G-expressions:
  26755. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  26756. (@pxref{G-Expressions}).
  26757. @deftp {Data Type} shepherd-action
  26758. This is the data type that defines additional actions implemented by a
  26759. Shepherd service (see above).
  26760. @table @code
  26761. @item name
  26762. Symbol naming the action.
  26763. @item documentation
  26764. This is a documentation string for the action. It can be viewed by running:
  26765. @example
  26766. herd doc @var{service} action @var{action}
  26767. @end example
  26768. @item procedure
  26769. This should be a gexp that evaluates to a procedure of at least one argument,
  26770. which is the ``running value'' of the service (@pxref{Slots of services,,,
  26771. shepherd, The GNU Shepherd Manual}).
  26772. @end table
  26773. The following example defines an action called @code{say-hello} that kindly
  26774. greets the user:
  26775. @lisp
  26776. (shepherd-action
  26777. (name 'say-hello)
  26778. (documentation "Say hi!")
  26779. (procedure #~(lambda (running . args)
  26780. (format #t "Hello, friend! arguments: ~s\n"
  26781. args)
  26782. #t)))
  26783. @end lisp
  26784. Assuming this action is added to the @code{example} service, then you can do:
  26785. @example
  26786. # herd say-hello example
  26787. Hello, friend! arguments: ()
  26788. # herd say-hello example a b c
  26789. Hello, friend! arguments: ("a" "b" "c")
  26790. @end example
  26791. This, as you can see, is a fairly sophisticated way to say hello.
  26792. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  26793. info on actions.
  26794. @end deftp
  26795. @defvr {Scheme Variable} shepherd-root-service-type
  26796. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  26797. This is the service type that extensions target when they want to create
  26798. shepherd services (@pxref{Service Types and Services}, for an example).
  26799. Each extension must pass a list of @code{<shepherd-service>}. Its
  26800. value must be a @code{shepherd-configuration}, as described below.
  26801. @end defvr
  26802. @deftp {Data Type} shepherd-configuration
  26803. This data type represents the Shepherd's configuration.
  26804. @table @code
  26805. @item shepherd (default: @code{shepherd})
  26806. The Shepherd package to use.
  26807. @item services (default: @code{'()})
  26808. A list of @code{<shepherd-service>} to start.
  26809. You should probably use the service extension
  26810. mechanism instead (@pxref{Shepherd Services}).
  26811. @end table
  26812. @end deftp
  26813. The following example specifies the Shepherd package for the operating
  26814. system:
  26815. @lisp
  26816. (operating-system
  26817. ;; ...
  26818. (services (append (list openssh-service-type))
  26819. ;; ...
  26820. %desktop-services)
  26821. ;; ...
  26822. ;; Use own Shepherd package.
  26823. (essential-services
  26824. (modify-services (operating-system-default-essential-services
  26825. this-operating-system)
  26826. (shepherd-root-service-type config => (shepherd-configuration
  26827. (inherit config)
  26828. (shepherd my-shepherd))))))
  26829. @end lisp
  26830. @defvr {Scheme Variable} %shepherd-root-service
  26831. This service represents PID@tie{}1.
  26832. @end defvr
  26833. @node Documentation
  26834. @chapter Documentation
  26835. @cindex documentation, searching for
  26836. @cindex searching for documentation
  26837. @cindex Info, documentation format
  26838. @cindex man pages
  26839. @cindex manual pages
  26840. In most cases packages installed with Guix come with documentation.
  26841. There are two main documentation formats: ``Info'', a browsable
  26842. hypertext format used for GNU software, and ``manual pages'' (or ``man
  26843. pages''), the linear documentation format traditionally found on Unix.
  26844. Info manuals are accessed with the @command{info} command or with Emacs,
  26845. and man pages are accessed using @command{man}.
  26846. You can look for documentation of software installed on your system by
  26847. keyword. For example, the following command searches for information
  26848. about ``TLS'' in Info manuals:
  26849. @example
  26850. $ info -k TLS
  26851. "(emacs)Network Security" -- STARTTLS
  26852. "(emacs)Network Security" -- TLS
  26853. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  26854. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  26855. @dots{}
  26856. @end example
  26857. @noindent
  26858. The command below searches for the same keyword in man pages:
  26859. @example
  26860. $ man -k TLS
  26861. SSL (7) - OpenSSL SSL/TLS library
  26862. certtool (1) - GnuTLS certificate tool
  26863. @dots {}
  26864. @end example
  26865. These searches are purely local to your computer so you have the
  26866. guarantee that documentation you find corresponds to what you have
  26867. actually installed, you can access it off-line, and your privacy is
  26868. respected.
  26869. Once you have these results, you can view the relevant documentation by
  26870. running, say:
  26871. @example
  26872. $ info "(gnutls)Core TLS API"
  26873. @end example
  26874. @noindent
  26875. or:
  26876. @example
  26877. $ man certtool
  26878. @end example
  26879. Info manuals contain sections and indices as well as hyperlinks like
  26880. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  26881. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  26882. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  26883. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  26884. Introduction}, for an introduction to Info navigation.
  26885. @node Installing Debugging Files
  26886. @chapter Installing Debugging Files
  26887. @cindex debugging files
  26888. Program binaries, as produced by the GCC compilers for instance, are
  26889. typically written in the ELF format, with a section containing
  26890. @dfn{debugging information}. Debugging information is what allows the
  26891. debugger, GDB, to map binary code to source code; it is required to
  26892. debug a compiled program in good conditions.
  26893. This chapter explains how to use separate debug info when packages
  26894. provide it, and how to rebuild packages with debug info when it's
  26895. missing.
  26896. @menu
  26897. * Separate Debug Info:: Installing 'debug' outputs.
  26898. * Rebuilding Debug Info:: Building missing debug info.
  26899. @end menu
  26900. @node Separate Debug Info
  26901. @section Separate Debug Info
  26902. The problem with debugging information is that is takes up a fair amount
  26903. of disk space. For example, debugging information for the GNU C Library
  26904. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  26905. debugging info of all the installed programs is usually not an option.
  26906. Yet, space savings should not come at the cost of an impediment to
  26907. debugging---especially in the GNU system, which should make it easier
  26908. for users to exert their computing freedom (@pxref{GNU Distribution}).
  26909. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  26910. mechanism that allows users to get the best of both worlds: debugging
  26911. information can be stripped from the binaries and stored in separate
  26912. files. GDB is then able to load debugging information from those files,
  26913. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  26914. with GDB}).
  26915. The GNU distribution takes advantage of this by storing debugging
  26916. information in the @code{lib/debug} sub-directory of a separate package
  26917. output unimaginatively called @code{debug} (@pxref{Packages with
  26918. Multiple Outputs}). Users can choose to install the @code{debug} output
  26919. of a package when they need it. For instance, the following command
  26920. installs the debugging information for the GNU C Library and for GNU
  26921. Guile:
  26922. @example
  26923. guix install glibc:debug guile:debug
  26924. @end example
  26925. GDB must then be told to look for debug files in the user's profile, by
  26926. setting the @code{debug-file-directory} variable (consider setting it
  26927. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  26928. GDB}):
  26929. @example
  26930. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  26931. @end example
  26932. From there on, GDB will pick up debugging information from the
  26933. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  26934. Below is an alternative GDB script which is useful when working with
  26935. other profiles. It takes advantage of the optional Guile integration in
  26936. GDB. This snippet is included by default on Guix System in the
  26937. @file{~/.gdbinit} file.
  26938. @example
  26939. guile
  26940. (use-modules (gdb))
  26941. (execute (string-append "set debug-file-directory "
  26942. (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
  26943. "~/.guix-profile/lib/debug")))
  26944. end
  26945. @end example
  26946. In addition, you will most likely want GDB to be able to show the source
  26947. code being debugged. To do that, you will have to unpack the source
  26948. code of the package of interest (obtained with @code{guix build
  26949. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  26950. directory using the @code{directory} command (@pxref{Source Path,
  26951. @code{directory},, gdb, Debugging with GDB}).
  26952. @c XXX: keep me up-to-date
  26953. The @code{debug} output mechanism in Guix is implemented by the
  26954. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  26955. opt-in---debugging information is available only for the packages with
  26956. definitions explicitly declaring a @code{debug} output. To check
  26957. whether a package has a @code{debug} output, use @command{guix package
  26958. --list-available} (@pxref{Invoking guix package}).
  26959. Read on for how to deal with packages lacking a @code{debug} output.
  26960. @node Rebuilding Debug Info
  26961. @section Rebuilding Debug Info
  26962. @cindex debugging info, rebuilding
  26963. As we saw above, some packages, but not all, provide debugging info in a
  26964. @code{debug} output. What can you do when debugging info is missing?
  26965. The @option{--with-debug-info} option provides a solution to that: it
  26966. allows you to rebuild the package(s) for which debugging info is
  26967. missing---and only those---and to graft those onto the application
  26968. you're debugging. Thus, while it's not as fast as installing a
  26969. @code{debug} output, it is relatively inexpensive.
  26970. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  26971. and would like to see what's going on in GLib, a library that's deep
  26972. down in its dependency graph. As it turns out, GLib does not have a
  26973. @code{debug} output and the backtrace GDB shows is all sadness:
  26974. @example
  26975. (gdb) bt
  26976. #0 0x00007ffff5f92190 in g_getenv ()
  26977. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  26978. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  26979. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  26980. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  26981. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  26982. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  26983. at dl-init.c:118
  26984. @end example
  26985. To address that, you install Inkscape linked against a variant GLib that
  26986. contains debug info:
  26987. @example
  26988. guix install inkscape --with-debug-info=glib
  26989. @end example
  26990. This time, debugging will be a whole lot nicer:
  26991. @example
  26992. $ gdb --args sh -c 'exec inkscape'
  26993. @dots{}
  26994. (gdb) b g_getenv
  26995. Function "g_getenv" not defined.
  26996. Make breakpoint pending on future shared library load? (y or [n]) y
  26997. Breakpoint 1 (g_getenv) pending.
  26998. (gdb) r
  26999. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  27000. @dots{}
  27001. (gdb) bt
  27002. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  27003. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  27004. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  27005. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  27006. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  27007. @dots{}
  27008. @end example
  27009. Much better!
  27010. Note that there can be packages for which @option{--with-debug-info}
  27011. will not have the desired effect. @xref{Package Transformation Options,
  27012. @option{--with-debug-info}}, for more information.
  27013. @node Security Updates
  27014. @chapter Security Updates
  27015. @cindex security updates
  27016. @cindex security vulnerabilities
  27017. Occasionally, important security vulnerabilities are discovered in software
  27018. packages and must be patched. Guix developers try hard to keep track of
  27019. known vulnerabilities and to apply fixes as soon as possible in the
  27020. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  27021. containing only security updates). The @command{guix lint} tool helps
  27022. developers find out about vulnerable versions of software packages in the
  27023. distribution:
  27024. @smallexample
  27025. $ guix lint -c cve
  27026. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  27027. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  27028. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  27029. @dots{}
  27030. @end smallexample
  27031. @xref{Invoking guix lint}, for more information.
  27032. Guix follows a functional
  27033. package management discipline (@pxref{Introduction}), which implies
  27034. that, when a package is changed, @emph{every package that depends on it}
  27035. must be rebuilt. This can significantly slow down the deployment of
  27036. fixes in core packages such as libc or Bash, since basically the whole
  27037. distribution would need to be rebuilt. Using pre-built binaries helps
  27038. (@pxref{Substitutes}), but deployment may still take more time than
  27039. desired.
  27040. @cindex grafts
  27041. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  27042. for fast deployment of critical updates without the costs associated
  27043. with a whole-distribution rebuild. The idea is to rebuild only the
  27044. package that needs to be patched, and then to ``graft'' it onto packages
  27045. explicitly installed by the user and that were previously referring to
  27046. the original package. The cost of grafting is typically very low, and
  27047. order of magnitudes lower than a full rebuild of the dependency chain.
  27048. @cindex replacements of packages, for grafts
  27049. For instance, suppose a security update needs to be applied to Bash.
  27050. Guix developers will provide a package definition for the ``fixed''
  27051. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  27052. Packages}). Then, the original package definition is augmented with a
  27053. @code{replacement} field pointing to the package containing the bug fix:
  27054. @lisp
  27055. (define bash
  27056. (package
  27057. (name "bash")
  27058. ;; @dots{}
  27059. (replacement bash-fixed)))
  27060. @end lisp
  27061. From there on, any package depending directly or indirectly on Bash---as
  27062. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  27063. gc})---that is installed is automatically ``rewritten'' to refer to
  27064. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  27065. time proportional to the size of the package, usually less than a
  27066. minute for an ``average'' package on a recent machine. Grafting is
  27067. recursive: when an indirect dependency requires grafting, then grafting
  27068. ``propagates'' up to the package that the user is installing.
  27069. Currently, the length of the name and version of the graft and that of
  27070. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  27071. above) must be equal. This restriction mostly comes from the fact that
  27072. grafting works by patching files, including binary files, directly.
  27073. Other restrictions may apply: for instance, when adding a graft to a
  27074. package providing a shared library, the original shared library and its
  27075. replacement must have the same @code{SONAME} and be binary-compatible.
  27076. The @option{--no-grafts} command-line option allows you to forcefully
  27077. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  27078. Thus, the command:
  27079. @example
  27080. guix build bash --no-grafts
  27081. @end example
  27082. @noindent
  27083. returns the store file name of the original Bash, whereas:
  27084. @example
  27085. guix build bash
  27086. @end example
  27087. @noindent
  27088. returns the store file name of the ``fixed'', replacement Bash. This
  27089. allows you to distinguish between the two variants of Bash.
  27090. To verify which Bash your whole profile refers to, you can run
  27091. (@pxref{Invoking guix gc}):
  27092. @example
  27093. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  27094. @end example
  27095. @noindent
  27096. @dots{} and compare the store file names that you get with those above.
  27097. Likewise for a complete Guix system generation:
  27098. @example
  27099. guix gc -R $(guix system build my-config.scm) | grep bash
  27100. @end example
  27101. Lastly, to check which Bash running processes are using, you can use the
  27102. @command{lsof} command:
  27103. @example
  27104. lsof | grep /gnu/store/.*bash
  27105. @end example
  27106. @node Bootstrapping
  27107. @chapter Bootstrapping
  27108. @c Adapted from the ELS 2013 paper.
  27109. @cindex bootstrapping
  27110. Bootstrapping in our context refers to how the distribution gets built
  27111. ``from nothing''. Remember that the build environment of a derivation
  27112. contains nothing but its declared inputs (@pxref{Introduction}). So
  27113. there's an obvious chicken-and-egg problem: how does the first package
  27114. get built? How does the first compiler get compiled?
  27115. It is tempting to think of this question as one that only die-hard
  27116. hackers may care about. However, while the answer to that question is
  27117. technical in nature, its implications are wide-ranging. How the
  27118. distribution is bootstrapped defines the extent to which we, as
  27119. individuals and as a collective of users and hackers, can trust the
  27120. software we run. It is a central concern from the standpoint of
  27121. @emph{security} and from a @emph{user freedom} viewpoint.
  27122. @cindex bootstrap binaries
  27123. The GNU system is primarily made of C code, with libc at its core. The
  27124. GNU build system itself assumes the availability of a Bourne shell and
  27125. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  27126. `grep'. Furthermore, build programs---programs that run
  27127. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  27128. (@pxref{Derivations}). Consequently, to be able to build anything at
  27129. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  27130. Binutils, libc, and the other packages mentioned above---the
  27131. @dfn{bootstrap binaries}.
  27132. These bootstrap binaries are ``taken for granted'', though we can also
  27133. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  27134. Binaries}).
  27135. @menu
  27136. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  27137. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  27138. @end menu
  27139. @node Reduced Binary Seed Bootstrap
  27140. @section The Reduced Binary Seed Bootstrap
  27141. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  27142. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  27143. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  27144. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  27145. ``taken for granted.''
  27146. Taking the bootstrap binaries for granted means that we consider them to
  27147. be a correct and trustworthy ``seed'' for building the complete system.
  27148. Therein lies a problem: the combined size of these bootstrap binaries is
  27149. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  27150. or even inspecting these is next to impossible.
  27151. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  27152. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  27153. Source Bootstrap'' and while we are working towards that goal it would
  27154. be hyperbole to use that term for what we do now.}.
  27155. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  27156. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  27157. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  27158. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  27159. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  27160. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  27161. C Library are built from source. From here on the more traditional
  27162. bootstrap process resumes. This approach has reduced the bootstrap
  27163. binaries in size to about 145MB in Guix v1.1.
  27164. The next step that Guix has taken is to replace the shell and all its
  27165. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  27166. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  27167. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  27168. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  27169. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  27170. removed are now built from source.
  27171. Building the GNU System from source is currently only possible by adding
  27172. some historical GNU packages as intermediate steps@footnote{Packages
  27173. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  27174. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  27175. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  27176. and GNU packages become more bootstrappable again (e.g., new releases of
  27177. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  27178. hard to bootstrap @code{xz}-compression), this set of added packages can
  27179. hopefully be reduced again.
  27180. The graph below shows the resulting dependency graph for
  27181. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  27182. traditional bootstrap of the rest of the Guix System.
  27183. @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
  27184. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  27185. The only significant binary bootstrap seeds that remain@footnote{
  27186. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  27187. together with @code{mes}.} are a Scheme interpreter and a Scheme
  27188. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  27189. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  27190. to get Guile running.}.
  27191. This further reduction has brought down the size of the binary seed to
  27192. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  27193. Work is ongoing to remove all binary blobs from our free software
  27194. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  27195. is work to bring these bootstraps to the @code{arm-linux} and
  27196. @code{aarch64-linux} architectures and to the Hurd.
  27197. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  27198. IRC network or discuss on @email{bug-mes@@gnu.org} or
  27199. @email{gash-devel@@nongnu.org}.
  27200. @node Preparing to Use the Bootstrap Binaries
  27201. @section Preparing to Use the Bootstrap Binaries
  27202. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  27203. @c large image, it's hard to scroll. Oh well.
  27204. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  27205. The figure above shows the very beginning of the dependency graph of the
  27206. distribution, corresponding to the package definitions of the @code{(gnu
  27207. packages bootstrap)} module. A similar figure can be generated with
  27208. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  27209. @example
  27210. guix graph -t derivation \
  27211. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  27212. | dot -Tps > gcc.ps
  27213. @end example
  27214. or, for the further Reduced Binary Seed bootstrap
  27215. @example
  27216. guix graph -t derivation \
  27217. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  27218. | dot -Tps > mes.ps
  27219. @end example
  27220. At this level of detail, things are
  27221. slightly complex. First, Guile itself consists of an ELF executable,
  27222. along with many source and compiled Scheme files that are dynamically
  27223. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  27224. tarball shown in this graph. This tarball is part of Guix's ``source''
  27225. distribution, and gets inserted into the store with @code{add-to-store}
  27226. (@pxref{The Store}).
  27227. But how do we write a derivation that unpacks this tarball and adds it
  27228. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  27229. derivation---the first one that gets built---uses @code{bash} as its
  27230. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  27231. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  27232. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  27233. the Guix source distribution, whose sole purpose is to allow the Guile
  27234. tarball to be unpacked.
  27235. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  27236. Guile that can be used to run subsequent build programs. Its first task
  27237. is to download tarballs containing the other pre-built binaries---this
  27238. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  27239. @code{ftp-client.scm} are used for this purpose. The
  27240. @code{module-import.drv} derivations import those modules in a directory
  27241. in the store, using the original layout. The
  27242. @code{module-import-compiled.drv} derivations compile those modules, and
  27243. write them in an output directory with the right layout. This
  27244. corresponds to the @code{#:modules} argument of
  27245. @code{build-expression->derivation} (@pxref{Derivations}).
  27246. Finally, the various tarballs are unpacked by the derivations
  27247. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  27248. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  27249. point we have a working C tool chain.
  27250. @unnumberedsec Building the Build Tools
  27251. Bootstrapping is complete when we have a full tool chain that does not
  27252. depend on the pre-built bootstrap tools discussed above. This
  27253. no-dependency requirement is verified by checking whether the files of
  27254. the final tool chain contain references to the @file{/gnu/store}
  27255. directories of the bootstrap inputs. The process that leads to this
  27256. ``final'' tool chain is described by the package definitions found in
  27257. the @code{(gnu packages commencement)} module.
  27258. The @command{guix graph} command allows us to ``zoom out'' compared to
  27259. the graph above, by looking at the level of package objects instead of
  27260. individual derivations---remember that a package may translate to
  27261. several derivations, typically one derivation to download its source,
  27262. one to build the Guile modules it needs, and one to actually build the
  27263. package from source. The command:
  27264. @example
  27265. guix graph -t bag \
  27266. -e '(@@@@ (gnu packages commencement)
  27267. glibc-final-with-bootstrap-bash)' | xdot -
  27268. @end example
  27269. @noindent
  27270. displays the dependency graph leading to the ``final'' C
  27271. library@footnote{You may notice the @code{glibc-intermediate} label,
  27272. suggesting that it is not @emph{quite} final, but as a good
  27273. approximation, we will consider it final.}, depicted below.
  27274. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  27275. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  27276. The first tool that gets built with the bootstrap binaries is
  27277. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  27278. for all the following packages. From there Findutils and Diffutils get
  27279. built.
  27280. Then come the first-stage Binutils and GCC, built as pseudo cross
  27281. tools---i.e., with @option{--target} equal to @option{--host}. They are
  27282. used to build libc. Thanks to this cross-build trick, this libc is
  27283. guaranteed not to hold any reference to the initial tool chain.
  27284. From there the final Binutils and GCC (not shown above) are built. GCC
  27285. uses @command{ld} from the final Binutils, and links programs against
  27286. the just-built libc. This tool chain is used to build the other
  27287. packages used by Guix and by the GNU Build System: Guile, Bash,
  27288. Coreutils, etc.
  27289. And voilà! At this point we have the complete set of build tools that
  27290. the GNU Build System expects. These are in the @code{%final-inputs}
  27291. variable of the @code{(gnu packages commencement)} module, and are
  27292. implicitly used by any package that uses @code{gnu-build-system}
  27293. (@pxref{Build Systems, @code{gnu-build-system}}).
  27294. @unnumberedsec Building the Bootstrap Binaries
  27295. @cindex bootstrap binaries
  27296. Because the final tool chain does not depend on the bootstrap binaries,
  27297. those rarely need to be updated. Nevertheless, it is useful to have an
  27298. automated way to produce them, should an update occur, and this is what
  27299. the @code{(gnu packages make-bootstrap)} module provides.
  27300. The following command builds the tarballs containing the bootstrap binaries
  27301. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  27302. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  27303. and Guile, and a tarball containing a mixture of Coreutils and other basic
  27304. command-line tools):
  27305. @example
  27306. guix build bootstrap-tarballs
  27307. @end example
  27308. The generated tarballs are those that should be referred to in the
  27309. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  27310. this section.
  27311. Still here? Then perhaps by now you've started to wonder: when do we
  27312. reach a fixed point? That is an interesting question! The answer is
  27313. unknown, but if you would like to investigate further (and have
  27314. significant computational and storage resources to do so), then let us
  27315. know.
  27316. @unnumberedsec Reducing the Set of Bootstrap Binaries
  27317. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  27318. binary code! Why is that a problem? It's a problem because these big chunks
  27319. of binary code are practically non-auditable, which makes it hard to establish
  27320. what source code produced them. Every unauditable binary also leaves us
  27321. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  27322. paper @emph{Reflections on Trusting Trust}.
  27323. This is mitigated by the fact that our bootstrap binaries were generated
  27324. from an earlier Guix revision. Nevertheless it lacks the level of
  27325. transparency that we get in the rest of the package dependency graph,
  27326. where Guix always gives us a source-to-binary mapping. Thus, our goal
  27327. is to reduce the set of bootstrap binaries to the bare minimum.
  27328. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  27329. on-going projects to do that. One of these is about replacing the
  27330. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  27331. of increasing complexity, which could be built from source starting from
  27332. a simple and auditable assembler.
  27333. Our first major achievement is the replacement of of GCC, the GNU C Library
  27334. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  27335. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  27336. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  27337. bootstrapped yet and thus we inject them as binary seeds. We call this the
  27338. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  27339. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  27340. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  27341. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  27342. also looking at any other bootstrap binaries. Your help is welcome!
  27343. @node Porting
  27344. @chapter Porting to a New Platform
  27345. As discussed above, the GNU distribution is self-contained, and
  27346. self-containment is achieved by relying on pre-built ``bootstrap
  27347. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  27348. operating system kernel, CPU architecture, and application binary
  27349. interface (ABI). Thus, to port the distribution to a platform that is
  27350. not yet supported, one must build those bootstrap binaries, and update
  27351. the @code{(gnu packages bootstrap)} module to use them on that platform.
  27352. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  27353. When everything goes well, and assuming the GNU tool chain supports the
  27354. target platform, this can be as simple as running a command like this
  27355. one:
  27356. @example
  27357. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  27358. @end example
  27359. For this to work, the @code{glibc-dynamic-linker} procedure in
  27360. @code{(gnu packages bootstrap)} must be augmented to return the right
  27361. file name for libc's dynamic linker on that platform; likewise,
  27362. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  27363. taught about the new platform.
  27364. Once these are built, the @code{(gnu packages bootstrap)} module needs
  27365. to be updated to refer to these binaries on the target platform. That
  27366. is, the hashes and URLs of the bootstrap tarballs for the new platform
  27367. must be added alongside those of the currently supported platforms. The
  27368. bootstrap Guile tarball is treated specially: it is expected to be
  27369. available locally, and @file{gnu/local.mk} has rules to download it for
  27370. the supported architectures; a rule for the new platform must be added
  27371. as well.
  27372. In practice, there may be some complications. First, it may be that the
  27373. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  27374. above) is not recognized by all the GNU tools. Typically, glibc
  27375. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  27376. configure flag (see @code{gcc.scm} for examples of how to handle this).
  27377. Second, some of the required packages could fail to build for that
  27378. platform. Lastly, the generated binaries could be broken for some
  27379. reason.
  27380. @c *********************************************************************
  27381. @include contributing.texi
  27382. @c *********************************************************************
  27383. @node Acknowledgments
  27384. @chapter Acknowledgments
  27385. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  27386. which was designed and
  27387. implemented by Eelco Dolstra, with contributions from other people (see
  27388. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  27389. management, and promoted unprecedented features, such as transactional
  27390. package upgrades and rollbacks, per-user profiles, and referentially
  27391. transparent build processes. Without this work, Guix would not exist.
  27392. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  27393. an inspiration for Guix.
  27394. GNU@tie{}Guix itself is a collective work with contributions from a
  27395. number of people. See the @file{AUTHORS} file in Guix for more
  27396. information on these fine people. The @file{THANKS} file lists people
  27397. who have helped by reporting bugs, taking care of the infrastructure,
  27398. providing artwork and themes, making suggestions, and more---thank you!
  27399. @c *********************************************************************
  27400. @node GNU Free Documentation License
  27401. @appendix GNU Free Documentation License
  27402. @cindex license, GNU Free Documentation License
  27403. @include fdl-1.3.texi
  27404. @c *********************************************************************
  27405. @node Concept Index
  27406. @unnumbered Concept Index
  27407. @printindex cp
  27408. @node Programming Index
  27409. @unnumbered Programming Index
  27410. @syncodeindex tp fn
  27411. @syncodeindex vr fn
  27412. @printindex fn
  27413. @bye
  27414. @c Local Variables:
  27415. @c ispell-local-dictionary: "american";
  27416. @c End: