guix.texi 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459
  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 27D586A4F8900854329FF09F1260E46482E63562
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=127547
  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-1 ci.guix.gnu.org
  16. @set SUBSTITUTE-SERVER-2 bordeaux.guix.gnu.org
  17. @set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
  18. @copying
  19. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
  20. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  21. Copyright @copyright{} 2013 Nikita Karetnikov@*
  22. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  23. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  24. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  25. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  26. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 Leo Famulari@*
  27. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ricardo Wurmus@*
  28. Copyright @copyright{} 2016 Ben Woodcroft@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2021 Chris Marusich@*
  30. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Efraim Flashner@*
  31. Copyright @copyright{} 2016 John Darrington@*
  32. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
  34. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Julien Lepiller@*
  35. Copyright @copyright{} 2016 Alex ter Weele@*
  36. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@*
  37. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  38. Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
  39. Copyright @copyright{} 2017 Federico Beffa@*
  40. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  41. Copyright @copyright{} 2017 Thomas Danckaert@*
  42. Copyright @copyright{} 2017 humanitiesNerd@*
  43. Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@*
  44. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Marius Bakke@*
  45. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  46. Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
  47. Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@*
  48. Copyright @copyright{} 2017 George Clemmer@*
  49. Copyright @copyright{} 2017 Andy Wingo@*
  50. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  51. Copyright @copyright{} 2017 nee@*
  52. Copyright @copyright{} 2018 Rutger Helling@*
  53. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  54. Copyright @copyright{} 2018 Mike Gerwitz@*
  55. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  56. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  57. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  58. Copyright @copyright{} 2018 Laura Lazzati@*
  59. Copyright @copyright{} 2018 Alex Vong@*
  60. Copyright @copyright{} 2019 Josh Holland@*
  61. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  62. Copyright @copyright{} 2019 Ivan Petkov@*
  63. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  64. Copyright @copyright{} 2019 Kyle Andrews@*
  65. Copyright @copyright{} 2019 Alex Griffin@*
  66. Copyright @copyright{} 2019, 2020, 2021 Guillaume Le Vaillant@*
  67. Copyright @copyright{} 2020 Liliana Marie Prikler@*
  68. Copyright @copyright{} 2019, 2020, 2021 Simon Tournier@*
  69. Copyright @copyright{} 2020 Wiktor Żelazny@*
  70. Copyright @copyright{} 2020 Damien Cassou@*
  71. Copyright @copyright{} 2020 Jakub Kądziołka@*
  72. Copyright @copyright{} 2020 Jack Hill@*
  73. Copyright @copyright{} 2020 Naga Malleswari@*
  74. Copyright @copyright{} 2020, 2021 Brice Waegeneire@*
  75. Copyright @copyright{} 2020 R Veera Kumar@*
  76. Copyright @copyright{} 2020, 2021 Pierre Langlois@*
  77. Copyright @copyright{} 2020 pinoaffe@*
  78. Copyright @copyright{} 2020 André Batista@*
  79. Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
  80. Copyright @copyright{} 2020 raingloom@*
  81. Copyright @copyright{} 2020 Daniel Brooks@*
  82. Copyright @copyright{} 2020 John Soo@*
  83. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  84. Copyright @copyright{} 2020 Edgar Vincent@*
  85. Copyright @copyright{} 2021, 2022 Maxime Devos@*
  86. Copyright @copyright{} 2021 B. Wilson@*
  87. Copyright @copyright{} 2021 Xinglu Chen@*
  88. Copyright @copyright{} 2021 Raghav Gururajan@*
  89. Copyright @copyright{} 2021 Domagoj Stolfa@*
  90. Copyright @copyright{} 2021 Hui Lu@*
  91. Copyright @copyright{} 2021 pukkamustard@*
  92. Copyright @copyright{} 2021 Alice Brenon@*
  93. Copyright @copyright{} 2021 Josselin Poiret@*
  94. Copyright @copyright{} 2021 Andrew Tropin@*
  95. Copyright @copyright{} 2021 Sarah Morgensen@*
  96. Copyright @copyright{} 2021 Josselin Poiret@*
  97. Permission is granted to copy, distribute and/or modify this document
  98. under the terms of the GNU Free Documentation License, Version 1.3 or
  99. any later version published by the Free Software Foundation; with no
  100. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  101. copy of the license is included in the section entitled ``GNU Free
  102. Documentation License''.
  103. @end copying
  104. @dircategory System administration
  105. @direntry
  106. * Guix: (guix). Manage installed software and system configuration.
  107. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  108. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  109. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  110. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  111. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  112. @end direntry
  113. @dircategory Software development
  114. @direntry
  115. * guix shell: (guix)Invoking guix shell. Creating software environments.
  116. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  117. * guix build: (guix)Invoking guix build. Building packages.
  118. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  119. @end direntry
  120. @titlepage
  121. @title GNU Guix Reference Manual
  122. @subtitle Using the GNU Guix Functional Package Manager
  123. @author The GNU Guix Developers
  124. @page
  125. @vskip 0pt plus 1filll
  126. Edition @value{EDITION} @*
  127. @value{UPDATED} @*
  128. @insertcopying
  129. @end titlepage
  130. @contents
  131. @c *********************************************************************
  132. @node Top
  133. @top GNU Guix
  134. This document describes GNU Guix version @value{VERSION}, a functional
  135. package management tool written for the GNU system.
  136. @c TRANSLATORS: You can replace the following paragraph with information on
  137. @c how to join your own translation team and how to report issues with the
  138. @c translation.
  139. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  140. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  141. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  142. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  143. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  144. would like to translate it in your native language, consider joining
  145. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  146. Weblate} (@pxref{Translating Guix}).
  147. @menu
  148. * Introduction:: What is Guix about?
  149. * Installation:: Installing Guix.
  150. * System Installation:: Installing the whole operating system.
  151. * Getting Started:: Your first steps.
  152. * Package Management:: Package installation, upgrade, etc.
  153. * Channels:: Customizing the package collection.
  154. * Development:: Guix-aided software development.
  155. * Programming Interface:: Using Guix in Scheme.
  156. * Utilities:: Package management commands.
  157. * System Configuration:: Configuring the operating system.
  158. * Home Configuration:: Configuring the home environment.
  159. * Documentation:: Browsing software user manuals.
  160. * Installing Debugging Files:: Feeding the debugger.
  161. * Security Updates:: Deploying security fixes quickly.
  162. * Bootstrapping:: GNU/Linux built from scratch.
  163. * Porting:: Targeting another platform or kernel.
  164. * Contributing:: Your help needed!
  165. * Acknowledgments:: Thanks!
  166. * GNU Free Documentation License:: The license of this manual.
  167. * Concept Index:: Concepts.
  168. * Programming Index:: Data types, functions, and variables.
  169. @detailmenu
  170. --- The Detailed Node Listing ---
  171. Introduction
  172. * Managing Software the Guix Way:: What's special.
  173. * GNU Distribution:: The packages and tools.
  174. Installation
  175. * Binary Installation:: Getting Guix running in no time!
  176. * Requirements:: Software needed to build and run Guix.
  177. * Running the Test Suite:: Testing Guix.
  178. * Setting Up the Daemon:: Preparing the build daemon's environment.
  179. * Invoking guix-daemon:: Running the build daemon.
  180. * Application Setup:: Application-specific setup.
  181. * Upgrading Guix:: Upgrading Guix and its build daemon.
  182. Setting Up the Daemon
  183. * Build Environment Setup:: Preparing the isolated build environment.
  184. * Daemon Offload Setup:: Offloading builds to remote machines.
  185. * SELinux Support:: Using an SELinux policy for the daemon.
  186. System Installation
  187. * Limitations:: What you can expect.
  188. * Hardware Considerations:: Supported hardware.
  189. * USB Stick and DVD Installation:: Preparing the installation medium.
  190. * Preparing for Installation:: Networking, partitioning, etc.
  191. * Guided Graphical Installation:: Easy graphical installation.
  192. * Manual Installation:: Manual installation for wizards.
  193. * After System Installation:: When installation succeeded.
  194. * Installing Guix in a VM:: Guix System playground.
  195. * Building the Installation Image:: How this comes to be.
  196. Manual Installation
  197. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  198. * Proceeding with the Installation:: Installing.
  199. Package Management
  200. * Features:: How Guix will make your life brighter.
  201. * Invoking guix package:: Package installation, removal, etc.
  202. * Substitutes:: Downloading pre-built binaries.
  203. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  204. * Invoking guix gc:: Running the garbage collector.
  205. * Invoking guix pull:: Fetching the latest Guix and distribution.
  206. * Invoking guix time-machine:: Running an older revision of Guix.
  207. * Inferiors:: Interacting with another revision of Guix.
  208. * Invoking guix describe:: Display information about your Guix revision.
  209. * Invoking guix archive:: Exporting and importing store files.
  210. Substitutes
  211. * Official Substitute Servers:: One particular source of substitutes.
  212. * Substitute Server Authorization:: How to enable or disable substitutes.
  213. * Getting Substitutes from Other Servers:: Substitute diversity.
  214. * Substitute Authentication:: How Guix verifies substitutes.
  215. * Proxy Settings:: How to get substitutes via proxy.
  216. * Substitution Failure:: What happens when substitution fails.
  217. * On Trusting Binaries:: How can you trust that binary blob?
  218. Channels
  219. * Specifying Additional Channels:: Extending the package collection.
  220. * Using a Custom Guix Channel:: Using a customized Guix.
  221. * Replicating Guix:: Running the @emph{exact same} Guix.
  222. * Channel Authentication:: How Guix verifies what it fetches.
  223. * Channels with Substitutes:: Using channels with available substitutes.
  224. * Creating a Channel:: How to write your custom channel.
  225. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  226. * Declaring Channel Dependencies:: How to depend on other channels.
  227. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  228. * Primary URL:: Distinguishing mirror to original.
  229. * Writing Channel News:: Communicating information to channel's users.
  230. Development
  231. * Invoking guix shell:: Spawning one-off software environments.
  232. * Invoking guix environment:: Setting up development environments.
  233. * Invoking guix pack:: Creating software bundles.
  234. * The GCC toolchain:: Working with languages supported by GCC.
  235. * Invoking guix git authenticate:: Authenticating Git repositories.
  236. Programming Interface
  237. * Package Modules:: Packages from the programmer's viewpoint.
  238. * Defining Packages:: Defining new packages.
  239. * Defining Package Variants:: Customizing packages.
  240. * Build Systems:: Specifying how packages are built.
  241. * Build Phases:: Phases of the build process of a package.
  242. * Build Utilities:: Helpers for your package definitions and more.
  243. * The Store:: Manipulating the package store.
  244. * Derivations:: Low-level interface to package derivations.
  245. * The Store Monad:: Purely functional interface to the store.
  246. * G-Expressions:: Manipulating build expressions.
  247. * Invoking guix repl:: Programming Guix in Guile.
  248. Defining Packages
  249. * package Reference:: The package data type.
  250. * origin Reference:: The origin data type.
  251. Utilities
  252. * Invoking guix build:: Building packages from the command line.
  253. * Invoking guix edit:: Editing package definitions.
  254. * Invoking guix download:: Downloading a file and printing its hash.
  255. * Invoking guix hash:: Computing the cryptographic hash of a file.
  256. * Invoking guix import:: Importing package definitions.
  257. * Invoking guix refresh:: Updating package definitions.
  258. * Invoking guix style:: Styling package definitions.
  259. * Invoking guix lint:: Finding errors in package definitions.
  260. * Invoking guix size:: Profiling disk usage.
  261. * Invoking guix graph:: Visualizing the graph of packages.
  262. * Invoking guix publish:: Sharing substitutes.
  263. * Invoking guix challenge:: Challenging substitute servers.
  264. * Invoking guix copy:: Copying to and from a remote store.
  265. * Invoking guix container:: Process isolation.
  266. * Invoking guix weather:: Assessing substitute availability.
  267. * Invoking guix processes:: Listing client processes.
  268. Invoking @command{guix build}
  269. * Common Build Options:: Build options for most commands.
  270. * Package Transformation Options:: Creating variants of packages.
  271. * Additional Build Options:: Options specific to 'guix build'.
  272. * Debugging Build Failures:: Real life packaging experience.
  273. System Configuration
  274. * Using the Configuration System:: Customizing your GNU system.
  275. * operating-system Reference:: Detail of operating-system declarations.
  276. * File Systems:: Configuring file system mounts.
  277. * Mapped Devices:: Block device extra processing.
  278. * Swap Space:: Backing RAM with disk space.
  279. * User Accounts:: Specifying user accounts.
  280. * Keyboard Layout:: How the system interprets key strokes.
  281. * Locales:: Language and cultural convention settings.
  282. * Services:: Specifying system services.
  283. * Setuid Programs:: Programs running with root privileges.
  284. * X.509 Certificates:: Authenticating HTTPS servers.
  285. * Name Service Switch:: Configuring libc's name service switch.
  286. * Initial RAM Disk:: Linux-Libre bootstrapping.
  287. * Bootloader Configuration:: Configuring the boot loader.
  288. * Invoking guix system:: Instantiating a system configuration.
  289. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  290. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  291. * Defining Services:: Adding new service definitions.
  292. Home Environment Configuration
  293. * Invoking guix home:: Instantiating a home environment configuration.
  294. Services
  295. * Base Services:: Essential system services.
  296. * Scheduled Job Execution:: The mcron service.
  297. * Log Rotation:: The rottlog service.
  298. * Networking Setup:: Setting up network interfaces.
  299. * Networking Services:: Firewall, SSH daemon, etc.
  300. * Unattended Upgrades:: Automated system upgrades.
  301. * X Window:: Graphical display.
  302. * Printing Services:: Local and remote printer support.
  303. * Desktop Services:: D-Bus and desktop services.
  304. * Sound Services:: ALSA and Pulseaudio services.
  305. * Database Services:: SQL databases, key-value stores, etc.
  306. * Mail Services:: IMAP, POP3, SMTP, and all that.
  307. * Messaging Services:: Messaging services.
  308. * Telephony Services:: Telephony services.
  309. * Monitoring Services:: Monitoring services.
  310. * Kerberos Services:: Kerberos services.
  311. * LDAP Services:: LDAP services.
  312. * Web Services:: Web servers.
  313. * Certificate Services:: TLS certificates via Let's Encrypt.
  314. * DNS Services:: DNS daemons.
  315. * VPN Services:: VPN daemons.
  316. * Network File System:: NFS related services.
  317. * Continuous Integration:: Cuirass and Laminar services.
  318. * Power Management Services:: Extending battery life.
  319. * Audio Services:: The MPD.
  320. * Virtualization Services:: Virtualization services.
  321. * Version Control Services:: Providing remote access to Git repositories.
  322. * Game Services:: Game servers.
  323. * PAM Mount Service:: Service to mount volumes when logging in.
  324. * Guix Services:: Services relating specifically to Guix.
  325. * Linux Services:: Services tied to the Linux kernel.
  326. * Hurd Services:: Services specific for a Hurd System.
  327. * Miscellaneous Services:: Other services.
  328. Defining Services
  329. * Service Composition:: The model for composing services.
  330. * Service Types and Services:: Types and services.
  331. * Service Reference:: API reference.
  332. * Shepherd Services:: A particular type of service.
  333. * Complex Configurations:: Defining bindings for complex configurations.
  334. Installing Debugging Files
  335. * Separate Debug Info:: Installing 'debug' outputs.
  336. * Rebuilding Debug Info:: Building missing debug info.
  337. Bootstrapping
  338. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  339. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  340. @end detailmenu
  341. @end menu
  342. @c *********************************************************************
  343. @node Introduction
  344. @chapter Introduction
  345. @cindex purpose
  346. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  347. using the international phonetic alphabet (IPA).} is a package
  348. management tool for and distribution of the GNU system.
  349. Guix makes it easy for unprivileged
  350. users to install, upgrade, or remove software packages, to roll back to a
  351. previous package set, to build packages from source, and generally
  352. assists with the creation and maintenance of software environments.
  353. @cindex Guix System
  354. @cindex GuixSD, now Guix System
  355. @cindex Guix System Distribution, now Guix System
  356. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  357. complements the available tools without interference (@pxref{Installation}),
  358. or you can use it as a standalone operating system distribution,
  359. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  360. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  361. group everything under the ``Guix'' banner since, after all, Guix System is
  362. readily available through the @command{guix system} command, even if you're
  363. using a different distro underneath!}. @xref{GNU Distribution}.
  364. @menu
  365. * Managing Software the Guix Way:: What's special.
  366. * GNU Distribution:: The packages and tools.
  367. @end menu
  368. @node Managing Software the Guix Way
  369. @section Managing Software the Guix Way
  370. @cindex user interfaces
  371. Guix provides a command-line package management interface
  372. (@pxref{Package Management}), tools to help with software development
  373. (@pxref{Development}), command-line utilities for more advanced usage
  374. (@pxref{Utilities}), as well as Scheme programming interfaces
  375. (@pxref{Programming Interface}).
  376. @cindex build daemon
  377. Its @dfn{build daemon} is responsible for building packages on behalf of
  378. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  379. binaries from authorized sources (@pxref{Substitutes}).
  380. @cindex extensibility of the distribution
  381. @cindex customization, of packages
  382. Guix includes package definitions for many GNU and non-GNU packages, all
  383. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  384. user's computing freedom}. It is @emph{extensible}: users can write
  385. their own package definitions (@pxref{Defining Packages}) and make them
  386. available as independent package modules (@pxref{Package Modules}). It
  387. is also @emph{customizable}: users can @emph{derive} specialized package
  388. definitions from existing ones, including from the command line
  389. (@pxref{Package Transformation Options}).
  390. @cindex functional package management
  391. @cindex isolation
  392. Under the hood, Guix implements the @dfn{functional package management}
  393. discipline pioneered by Nix (@pxref{Acknowledgments}).
  394. In Guix, the package build and installation process is seen
  395. as a @emph{function}, in the mathematical sense. That function takes inputs,
  396. such as build scripts, a compiler, and libraries, and
  397. returns an installed package. As a pure function, its result depends
  398. solely on its inputs---for instance, it cannot refer to software or
  399. scripts that were not explicitly passed as inputs. A build function
  400. always produces the same result when passed a given set of inputs. It
  401. cannot alter the environment of the running system in
  402. any way; for instance, it cannot create, modify, or delete files outside
  403. of its build and installation directories. This is achieved by running
  404. build processes in isolated environments (or @dfn{containers}), where only their
  405. explicit inputs are visible.
  406. @cindex store
  407. The result of package build functions is @dfn{cached} in the file
  408. system, in a special directory called @dfn{the store} (@pxref{The
  409. Store}). Each package is installed in a directory of its own in the
  410. store---by default under @file{/gnu/store}. The directory name contains
  411. a hash of all the inputs used to build that package; thus, changing an
  412. input yields a different directory name.
  413. This approach is the foundation for the salient features of Guix: support
  414. for transactional package upgrade and rollback, per-user installation, and
  415. garbage collection of packages (@pxref{Features}).
  416. @node GNU Distribution
  417. @section GNU Distribution
  418. @cindex Guix System
  419. Guix comes with a distribution of the GNU system consisting entirely of
  420. free software@footnote{The term ``free'' here refers to the
  421. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  422. users of that software}.}. The
  423. distribution can be installed on its own (@pxref{System Installation}),
  424. but it is also possible to install Guix as a package manager on top of
  425. an installed GNU/Linux system (@pxref{Installation}). When we need to
  426. distinguish between the two, we refer to the standalone distribution as
  427. Guix@tie{}System.
  428. The distribution provides core GNU packages such as GNU libc, GCC, and
  429. Binutils, as well as many GNU and non-GNU applications. The complete
  430. list of available packages can be browsed
  431. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  432. running @command{guix package} (@pxref{Invoking guix package}):
  433. @example
  434. guix package --list-available
  435. @end example
  436. Our goal is to provide a practical 100% free software distribution of
  437. Linux-based and other variants of GNU, with a focus on the promotion and
  438. tight integration of GNU components, and an emphasis on programs and
  439. tools that help users exert that freedom.
  440. Packages are currently available on the following platforms:
  441. @table @code
  442. @item x86_64-linux
  443. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  444. @item i686-linux
  445. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  446. @item armhf-linux
  447. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  448. using the EABI hard-float application binary interface (ABI),
  449. and Linux-Libre kernel.
  450. @item aarch64-linux
  451. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  452. @item i586-gnu
  453. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  454. (IA32).
  455. This configuration is experimental and under development. The easiest
  456. way for you to give it a try is by setting up an instance of
  457. @code{hurd-vm-service-type} on your GNU/Linux machine
  458. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  459. @xref{Contributing}, on how to help!
  460. @item mips64el-linux (unsupported)
  461. little-endian 64-bit MIPS processors, specifically the Loongson series,
  462. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  463. supported; in particular, there is no ongoing work to ensure that this
  464. architecture still works. Should someone decide they wish to revive this
  465. architecture then the code is still available.
  466. @item powerpc-linux (unsupported)
  467. big-endian 32-bit PowerPC processors, specifically the PowerPC G4 with
  468. AltiVec support, and Linux-Libre kernel. This configuration is not
  469. fully supported and there is no ongoing work to ensure this architecture
  470. works.
  471. @item powerpc64le-linux
  472. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  473. includes POWER9 systems such as the
  474. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  475. RYF Talos II mainboard}. This platform is available as a "technology
  476. preview": although it is supported, substitutes are not yet available
  477. from the build farm (@pxref{Substitutes}), and some packages may fail to
  478. build (@pxref{Tracking Bugs and Patches}). That said, the Guix
  479. community is actively working on improving this support, and now is a
  480. great time to try it and get involved!
  481. @end table
  482. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  483. configuration and Guix takes care of instantiating the configuration in a
  484. transactional, reproducible, and stateless fashion (@pxref{System
  485. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  486. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  487. Manual}), the well-known GNU utilities and tool chain, as well as the
  488. graphical environment or system services of your choice.
  489. Guix System is available on all the above platforms except
  490. @code{mips64el-linux} and @code{powerpc64le-linux}.
  491. @noindent
  492. For information on porting to other architectures or kernels,
  493. @pxref{Porting}.
  494. Building this distribution is a cooperative effort, and you are invited
  495. to join! @xref{Contributing}, for information about how you can help.
  496. @c *********************************************************************
  497. @node Installation
  498. @chapter Installation
  499. @cindex installing Guix
  500. @quotation Note
  501. We recommend the use of this
  502. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  503. shell installer script} to install Guix on top of a running GNU/Linux system,
  504. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  505. with the installation of the package manager, which can be done on top of a
  506. running GNU/Linux system. If, instead, you want to install the complete GNU
  507. operating system, @pxref{System Installation}.} The script automates the
  508. download, installation, and initial configuration of Guix. It should be run
  509. as the root user.
  510. @end quotation
  511. @cindex foreign distro
  512. @cindex directories related to foreign distro
  513. When installed on a foreign distro, GNU@tie{}Guix complements the available
  514. tools without interference. Its data lives exclusively in two directories,
  515. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  516. such as @file{/etc}, are left untouched.
  517. Once installed, Guix can be updated by running @command{guix pull}
  518. (@pxref{Invoking guix pull}).
  519. If you prefer to perform the installation steps manually or want to tweak
  520. them, you may find the following subsections useful. They describe the
  521. software requirements of Guix, as well as how to install it manually and get
  522. ready to use it.
  523. @menu
  524. * Binary Installation:: Getting Guix running in no time!
  525. * Requirements:: Software needed to build and run Guix.
  526. * Running the Test Suite:: Testing Guix.
  527. * Setting Up the Daemon:: Preparing the build daemon's environment.
  528. * Invoking guix-daemon:: Running the build daemon.
  529. * Application Setup:: Application-specific setup.
  530. * Upgrading Guix:: Upgrading Guix and its build daemon.
  531. @end menu
  532. @node Binary Installation
  533. @section Binary Installation
  534. @cindex installing Guix from binaries
  535. @cindex installer script
  536. This section describes how to install Guix on an arbitrary system from a
  537. self-contained tarball providing binaries for Guix and for all its
  538. dependencies. This is often quicker than installing from source, which
  539. is described in the next sections. The only requirement is to have
  540. GNU@tie{}tar and Xz.
  541. @c Note duplicated from the ``Installation'' node.
  542. @quotation Note
  543. We recommend the use of this
  544. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  545. shell installer script}. The script automates the download, installation, and
  546. initial configuration steps described below. It should be run as the root
  547. user. As root, you can thus run this:
  548. @example
  549. cd /tmp
  550. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  551. chmod +x guix-install.sh
  552. ./guix-install.sh
  553. @end example
  554. When you're done, @pxref{Application Setup} for extra configuration you
  555. might need, and @ref{Getting Started} for your first steps!
  556. @end quotation
  557. Installing goes along these lines:
  558. @enumerate
  559. @item
  560. @cindex downloading Guix binary
  561. Download the binary tarball from
  562. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  563. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  564. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  565. (@pxref{GNU Distribution}).
  566. @c The following is somewhat duplicated in ``System Installation''.
  567. Make sure to download the associated @file{.sig} file and to verify the
  568. authenticity of the tarball against it, along these lines:
  569. @example
  570. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  571. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  572. @end example
  573. If that command fails because you do not have the required public key,
  574. then run this command to import it:
  575. @example
  576. $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
  577. -qO - | gpg --import -
  578. @end example
  579. @noindent
  580. and rerun the @code{gpg --verify} command.
  581. Take note that a warning like ``This key is not certified with a trusted
  582. signature!'' is normal.
  583. @c end authentication part
  584. @item
  585. Now, you need to become the @code{root} user. Depending on your distribution,
  586. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  587. @example
  588. # cd /tmp
  589. # tar --warning=no-timestamp -xf \
  590. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  591. # mv var/guix /var/ && mv gnu /
  592. @end example
  593. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  594. The latter contains a ready-to-use profile for @code{root} (see next
  595. step).
  596. Do @emph{not} unpack the tarball on a working Guix system since that
  597. would overwrite its own essential files.
  598. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  599. not emit warnings about ``implausibly old time stamps'' (such
  600. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  601. versions are fine).
  602. They stem from the fact that all the
  603. files in the archive have their modification time set to 1 (which
  604. means January 1st, 1970). This is done on purpose to make sure the
  605. archive content is independent of its creation time, thus making it
  606. reproducible.
  607. @item
  608. Make the profile available under @file{~root/.config/guix/current}, which is
  609. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  610. @example
  611. # mkdir -p ~root/.config/guix
  612. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  613. ~root/.config/guix/current
  614. @end example
  615. Source @file{etc/profile} to augment @env{PATH} and other relevant
  616. environment variables:
  617. @example
  618. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  619. source $GUIX_PROFILE/etc/profile
  620. @end example
  621. @item
  622. Create the group and user accounts for build users as explained below
  623. (@pxref{Build Environment Setup}).
  624. @item
  625. Run the daemon, and set it to automatically start on boot.
  626. If your host distro uses the systemd init system, this can be achieved
  627. with these commands:
  628. @c Versions of systemd that supported symlinked service files are not
  629. @c yet widely deployed, so we should suggest that users copy the service
  630. @c files into place.
  631. @c
  632. @c See this thread for more information:
  633. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  634. @example
  635. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  636. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  637. /etc/systemd/system/
  638. # systemctl enable --now gnu-store.mount guix-daemon
  639. @end example
  640. You may also want to arrange for @command{guix gc} to run periodically:
  641. @example
  642. # cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
  643. ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
  644. /etc/systemd/system/
  645. # systemctl enable --now guix-gc.timer
  646. @end example
  647. You may want to edit @file{guix-gc.service} to adjust the command line
  648. options to fit your needs (@pxref{Invoking guix gc}).
  649. If your host distro uses the Upstart init system:
  650. @example
  651. # initctl reload-configuration
  652. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  653. /etc/init/
  654. # start guix-daemon
  655. @end example
  656. Otherwise, you can still start the daemon manually with:
  657. @example
  658. # ~root/.config/guix/current/bin/guix-daemon \
  659. --build-users-group=guixbuild
  660. @end example
  661. @item
  662. Make the @command{guix} command available to other users on the machine,
  663. for instance with:
  664. @example
  665. # mkdir -p /usr/local/bin
  666. # cd /usr/local/bin
  667. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  668. @end example
  669. It is also a good idea to make the Info version of this manual available
  670. there:
  671. @example
  672. # mkdir -p /usr/local/share/info
  673. # cd /usr/local/share/info
  674. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  675. do ln -s $i ; done
  676. @end example
  677. That way, assuming @file{/usr/local/share/info} is in the search path,
  678. running @command{info guix} will open this manual (@pxref{Other Info
  679. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  680. Info search path).
  681. @item
  682. @cindex substitutes, authorization thereof
  683. To use substitutes from @code{@value{SUBSTITUTE-SERVER-1}},
  684. @code{@value{SUBSTITUTE-SERVER-2}} or a mirror (@pxref{Substitutes}),
  685. authorize them:
  686. @example
  687. # guix archive --authorize < \
  688. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  689. # guix archive --authorize < \
  690. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  691. @end example
  692. @quotation Note
  693. If you do not enable substitutes, Guix will end up building
  694. @emph{everything} from source on your machine, making each installation
  695. and upgrade very expensive. @xref{On Trusting Binaries}, for a
  696. discussion of reasons why one might want do disable substitutes.
  697. @end quotation
  698. @item
  699. Each user may need to perform a few additional steps to make their Guix
  700. environment ready for use, @pxref{Application Setup}.
  701. @end enumerate
  702. Voilà, the installation is complete!
  703. You can confirm that Guix is working by installing a sample package into
  704. the root profile:
  705. @example
  706. # guix install hello
  707. @end example
  708. The binary installation tarball can be (re)produced and verified simply
  709. by running the following command in the Guix source tree:
  710. @example
  711. make guix-binary.@var{system}.tar.xz
  712. @end example
  713. @noindent
  714. ...@: which, in turn, runs:
  715. @example
  716. guix pack -s @var{system} --localstatedir \
  717. --profile-name=current-guix guix
  718. @end example
  719. @xref{Invoking guix pack}, for more info on this handy tool.
  720. @node Requirements
  721. @section Requirements
  722. This section lists requirements when building Guix from source. The
  723. build procedure for Guix is the same as for other GNU software, and is
  724. not covered here. Please see the files @file{README} and @file{INSTALL}
  725. in the Guix source tree for additional details.
  726. @cindex official website
  727. GNU Guix is available for download from its website at
  728. @url{https://www.gnu.org/software/guix/}.
  729. GNU Guix depends on the following packages:
  730. @itemize
  731. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x;
  732. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  733. 0.1.0 or later;
  734. @item
  735. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  736. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  737. Guile,, gnutls-guile, GnuTLS-Guile});
  738. @item
  739. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  740. or later;
  741. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  742. version 0.1.0 or later;
  743. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  744. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  745. @item
  746. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.5.0
  747. or later;
  748. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  749. 4.3.0 or later;
  750. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  751. @end itemize
  752. The following dependencies are optional:
  753. @itemize
  754. @item
  755. @c Note: We need at least 0.13.0 for #:nodelay.
  756. Support for build offloading (@pxref{Daemon Offload Setup}) and
  757. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  758. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  759. version 0.13.0 or later.
  760. @item
  761. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  762. compression and decompression in @command{guix publish} and for
  763. substitutes (@pxref{Invoking guix publish}).
  764. @item
  765. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  766. the @code{crate} importer (@pxref{Invoking guix import}).
  767. @item
  768. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  769. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  770. the ``updaters'' (@pxref{Invoking guix refresh}).
  771. @item
  772. When @url{http://www.bzip.org, libbz2} is available,
  773. @command{guix-daemon} can use it to compress build logs.
  774. @end itemize
  775. Unless @option{--disable-daemon} was passed to @command{configure}, the
  776. following packages are also needed:
  777. @itemize
  778. @item @url{https://gnupg.org/, GNU libgcrypt};
  779. @item @url{https://sqlite.org, SQLite 3};
  780. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  781. C++11 standard.
  782. @end itemize
  783. @cindex state directory
  784. When configuring Guix on a system that already has a Guix installation,
  785. be sure to specify the same state directory as the existing installation
  786. using the @option{--localstatedir} option of the @command{configure}
  787. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  788. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  789. set to the value @file{/var}. The @command{configure} script protects
  790. against unintended misconfiguration of @var{localstatedir} so you do not
  791. inadvertently corrupt your store (@pxref{The Store}).
  792. @node Running the Test Suite
  793. @section Running the Test Suite
  794. @cindex test suite
  795. After a successful @command{configure} and @code{make} run, it is a good
  796. idea to run the test suite. It can help catch issues with the setup or
  797. environment, or bugs in Guix itself---and really, reporting test
  798. failures is a good way to help improve the software. To run the test
  799. suite, type:
  800. @example
  801. make check
  802. @end example
  803. Test cases can run in parallel: you can use the @code{-j} option of
  804. GNU@tie{}make to speed things up. The first run may take a few minutes
  805. on a recent machine; subsequent runs will be faster because the store
  806. that is created for test purposes will already have various things in
  807. cache.
  808. It is also possible to run a subset of the tests by defining the
  809. @code{TESTS} makefile variable as in this example:
  810. @example
  811. make check TESTS="tests/store.scm tests/cpio.scm"
  812. @end example
  813. By default, tests results are displayed at a file level. In order to
  814. see the details of every individual test cases, it is possible to define
  815. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  816. @example
  817. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  818. @end example
  819. The underlying SRFI 64 custom Automake test driver used for the 'check'
  820. test suite (located at @file{build-aux/test-driver.scm}) also allows
  821. selecting which test cases to run at a finer level, via its
  822. @option{--select} and @option{--exclude} options. Here's an example, to
  823. run all the test cases from the @file{tests/packages.scm} test file
  824. whose names start with ``transaction-upgrade-entry'':
  825. @example
  826. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  827. make check TESTS="tests/packages.scm"
  828. @end example
  829. Those wishing to inspect the results of failed tests directly from the
  830. command line can add the @option{--errors-only=yes} option to the
  831. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  832. Automake makefile variable, as in:
  833. @example
  834. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  835. @end example
  836. The @option{--show-duration=yes} option can be used to print the
  837. duration of the individual test cases, when used in combination with
  838. @option{--brief=no}:
  839. @example
  840. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  841. @end example
  842. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  843. information about the Automake Parallel Test Harness.
  844. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  845. @file{test-suite.log} file. Please specify the Guix version being used
  846. as well as version numbers of the dependencies (@pxref{Requirements}) in
  847. your message.
  848. Guix also comes with a whole-system test suite that tests complete
  849. Guix System instances. It can only run on systems where
  850. Guix is already installed, using:
  851. @example
  852. make check-system
  853. @end example
  854. @noindent
  855. or, again, by defining @code{TESTS} to select a subset of tests to run:
  856. @example
  857. make check-system TESTS="basic mcron"
  858. @end example
  859. These system tests are defined in the @code{(gnu tests @dots{})}
  860. modules. They work by running the operating systems under test with
  861. lightweight instrumentation in a virtual machine (VM). They can be
  862. computationally intensive or rather cheap, depending on whether
  863. substitutes are available for their dependencies (@pxref{Substitutes}).
  864. Some of them require a lot of storage space to hold VM images.
  865. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  866. all the details.
  867. @node Setting Up the Daemon
  868. @section Setting Up the Daemon
  869. @cindex daemon
  870. Operations such as building a package or running the garbage collector
  871. are all performed by a specialized process, the @dfn{build daemon}, on
  872. behalf of clients. Only the daemon may access the store and its
  873. associated database. Thus, any operation that manipulates the store
  874. goes through the daemon. For instance, command-line tools such as
  875. @command{guix package} and @command{guix build} communicate with the
  876. daemon (@i{via} remote procedure calls) to instruct it what to do.
  877. The following sections explain how to prepare the build daemon's
  878. environment. See also @ref{Substitutes}, for information on how to allow
  879. the daemon to download pre-built binaries.
  880. @menu
  881. * Build Environment Setup:: Preparing the isolated build environment.
  882. * Daemon Offload Setup:: Offloading builds to remote machines.
  883. * SELinux Support:: Using an SELinux policy for the daemon.
  884. @end menu
  885. @node Build Environment Setup
  886. @subsection Build Environment Setup
  887. @cindex build environment
  888. In a standard multi-user setup, Guix and its daemon---the
  889. @command{guix-daemon} program---are installed by the system
  890. administrator; @file{/gnu/store} is owned by @code{root} and
  891. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  892. Guix tools to build packages or otherwise access the store, and the
  893. daemon will do it on their behalf, ensuring that the store is kept in a
  894. consistent state, and allowing built packages to be shared among users.
  895. @cindex build users
  896. When @command{guix-daemon} runs as @code{root}, you may not want package
  897. build processes themselves to run as @code{root} too, for obvious
  898. security reasons. To avoid that, a special pool of @dfn{build users}
  899. should be created for use by build processes started by the daemon.
  900. These build users need not have a shell and a home directory: they will
  901. just be used when the daemon drops @code{root} privileges in build
  902. processes. Having several such users allows the daemon to launch
  903. distinct build processes under separate UIDs, which guarantees that they
  904. do not interfere with each other---an essential feature since builds are
  905. regarded as pure functions (@pxref{Introduction}).
  906. On a GNU/Linux system, a build user pool may be created like this (using
  907. Bash syntax and the @code{shadow} commands):
  908. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  909. @c for why `-G' is needed.
  910. @example
  911. # groupadd --system guixbuild
  912. # for i in $(seq -w 1 10);
  913. do
  914. useradd -g guixbuild -G guixbuild \
  915. -d /var/empty -s $(which nologin) \
  916. -c "Guix build user $i" --system \
  917. guixbuilder$i;
  918. done
  919. @end example
  920. @noindent
  921. The number of build users determines how many build jobs may run in
  922. parallel, as specified by the @option{--max-jobs} option
  923. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  924. @command{guix system vm} and related commands, you may need to add the
  925. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  926. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  927. (@pxref{Invoking guix system}).
  928. The @code{guix-daemon} program may then be run as @code{root} with the
  929. following command@footnote{If your machine uses the systemd init system,
  930. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  931. file in @file{/etc/systemd/system} will ensure that
  932. @command{guix-daemon} is automatically started. Similarly, if your
  933. machine uses the Upstart init system, drop the
  934. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  935. file in @file{/etc/init}.}:
  936. @example
  937. # guix-daemon --build-users-group=guixbuild
  938. @end example
  939. @cindex chroot
  940. @noindent
  941. This way, the daemon starts build processes in a chroot, under one of
  942. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  943. environment contains nothing but:
  944. @c Keep this list in sync with libstore/build.cc! -----------------------
  945. @itemize
  946. @item
  947. a minimal @code{/dev} directory, created mostly independently from the
  948. host @code{/dev}@footnote{``Mostly'', because while the set of files
  949. that appear in the chroot's @code{/dev} is fixed, most of these files
  950. can only be created if the host has them.};
  951. @item
  952. the @code{/proc} directory; it only shows the processes of the container
  953. since a separate PID name space is used;
  954. @item
  955. @file{/etc/passwd} with an entry for the current user and an entry for
  956. user @file{nobody};
  957. @item
  958. @file{/etc/group} with an entry for the user's group;
  959. @item
  960. @file{/etc/hosts} with an entry that maps @code{localhost} to
  961. @code{127.0.0.1};
  962. @item
  963. a writable @file{/tmp} directory.
  964. @end itemize
  965. You can influence the directory where the daemon stores build trees
  966. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  967. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  968. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  969. This way, the value of @env{TMPDIR} does not leak inside build
  970. environments, which avoids discrepancies in cases where build processes
  971. capture the name of their build tree.
  972. @vindex http_proxy
  973. @vindex https_proxy
  974. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  975. environment variables for HTTP and HTTPS downloads it performs, be it
  976. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  977. (@pxref{Substitutes}).
  978. If you are installing Guix as an unprivileged user, it is still possible
  979. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  980. However, build processes will not be isolated from one another, and not
  981. from the rest of the system. Thus, build processes may interfere with
  982. each other, and may access programs, libraries, and other files
  983. available on the system---making it much harder to view them as
  984. @emph{pure} functions.
  985. @node Daemon Offload Setup
  986. @subsection Using the Offload Facility
  987. @cindex offloading
  988. @cindex build hook
  989. When desired, the build daemon can @dfn{offload} derivation builds to
  990. other machines running Guix, using the @code{offload} @dfn{build
  991. hook}@footnote{This feature is available only when
  992. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  993. present.}. When that feature is enabled, a list of user-specified build
  994. machines is read from @file{/etc/guix/machines.scm}; every time a build
  995. is requested, for instance via @code{guix build}, the daemon attempts to
  996. offload it to one of the machines that satisfy the constraints of the
  997. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  998. A single machine can have multiple system types, either because its
  999. architecture natively supports it, via emulation
  1000. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  1001. or both. Missing prerequisites for the build are
  1002. copied over SSH to the target machine, which then proceeds with the
  1003. build; upon success the output(s) of the build are copied back to the
  1004. initial machine. The offload facility comes with a basic scheduler that
  1005. attempts to select the best machine. The best machine is chosen among
  1006. the available machines based on criteria such as:
  1007. @enumerate
  1008. @item
  1009. The availability of a build slot. A build machine can have as many
  1010. build slots (connections) as the value of the @code{parallel-builds}
  1011. field of its @code{build-machine} object.
  1012. @item
  1013. Its relative speed, as defined via the @code{speed} field of its
  1014. @code{build-machine} object.
  1015. @item
  1016. Its load. The normalized machine load must be lower than a threshold
  1017. value, configurable via the @code{overload-threshold} field of its
  1018. @code{build-machine} object.
  1019. @item
  1020. Disk space availability. More than a 100 MiB must be available.
  1021. @end enumerate
  1022. The @file{/etc/guix/machines.scm} file typically looks like this:
  1023. @lisp
  1024. (list (build-machine
  1025. (name "eightysix.example.org")
  1026. (systems (list "x86_64-linux" "i686-linux"))
  1027. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  1028. (user "bob")
  1029. (speed 2.)) ;incredibly fast!
  1030. (build-machine
  1031. (name "armeight.example.org")
  1032. (systems (list "aarch64-linux"))
  1033. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  1034. (user "alice")
  1035. ;; Remember 'guix offload' is spawned by
  1036. ;; 'guix-daemon' as root.
  1037. (private-key "/root/.ssh/identity-for-guix")))
  1038. @end lisp
  1039. @noindent
  1040. In the example above we specify a list of two build machines, one for
  1041. the @code{x86_64} and @code{i686} architectures and one for the
  1042. @code{aarch64} architecture.
  1043. In fact, this file is---not surprisingly!---a Scheme file that is
  1044. evaluated when the @code{offload} hook is started. Its return value
  1045. must be a list of @code{build-machine} objects. While this example
  1046. shows a fixed list of build machines, one could imagine, say, using
  1047. DNS-SD to return a list of potential build machines discovered in the
  1048. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1049. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1050. detailed below.
  1051. @deftp {Data Type} build-machine
  1052. This data type represents build machines to which the daemon may offload
  1053. builds. The important fields are:
  1054. @table @code
  1055. @item name
  1056. The host name of the remote machine.
  1057. @item systems
  1058. The system types the remote machine supports---e.g., @code{(list
  1059. "x86_64-linux" "i686-linux")}.
  1060. @item user
  1061. The user account to use when connecting to the remote machine over SSH.
  1062. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1063. allow non-interactive logins.
  1064. @item host-key
  1065. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1066. This is used to authenticate the machine when we connect to it. It is a
  1067. long string that looks like this:
  1068. @example
  1069. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1070. @end example
  1071. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1072. key can be found in a file such as
  1073. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1074. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1075. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1076. similar file. It can be converted to the OpenSSH format using
  1077. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1078. @example
  1079. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1080. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1081. @end example
  1082. @end table
  1083. A number of optional fields may be specified:
  1084. @table @asis
  1085. @item @code{port} (default: @code{22})
  1086. Port number of SSH server on the machine.
  1087. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1088. The SSH private key file to use when connecting to the machine, in
  1089. OpenSSH format. This key must not be protected with a passphrase.
  1090. Note that the default value is the private key @emph{of the root
  1091. account}. Make sure it exists if you use the default.
  1092. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1093. @itemx @code{compression-level} (default: @code{3})
  1094. The SSH-level compression methods and compression level requested.
  1095. Note that offloading relies on SSH compression to reduce bandwidth usage
  1096. when transferring files to and from build machines.
  1097. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1098. File name of the Unix-domain socket @command{guix-daemon} is listening
  1099. to on that machine.
  1100. @item @code{overload-threshold} (default: @code{0.6})
  1101. The load threshold above which a potential offload machine is
  1102. disregarded by the offload scheduler. The value roughly translates to
  1103. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1104. 1.0 (100%). It can also be disabled by setting
  1105. @code{overload-threshold} to @code{#f}.
  1106. @item @code{parallel-builds} (default: @code{1})
  1107. The number of builds that may run in parallel on the machine.
  1108. @item @code{speed} (default: @code{1.0})
  1109. A ``relative speed factor''. The offload scheduler will tend to prefer
  1110. machines with a higher speed factor.
  1111. @item @code{features} (default: @code{'()})
  1112. A list of strings denoting specific features supported by the machine.
  1113. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1114. and corresponding hardware support. Derivations can request features by
  1115. name, and they will be scheduled on matching build machines.
  1116. @end table
  1117. @end deftp
  1118. The @command{guix} command must be in the search path on the build
  1119. machines. You can check whether this is the case by running:
  1120. @example
  1121. ssh build-machine guix repl --version
  1122. @end example
  1123. There is one last thing to do once @file{machines.scm} is in place. As
  1124. explained above, when offloading, files are transferred back and forth
  1125. between the machine stores. For this to work, you first need to
  1126. generate a key pair on each machine to allow the daemon to export signed
  1127. archives of files from the store (@pxref{Invoking guix archive}):
  1128. @example
  1129. # guix archive --generate-key
  1130. @end example
  1131. @noindent
  1132. Each build machine must authorize the key of the master machine so that
  1133. it accepts store items it receives from the master:
  1134. @example
  1135. # guix archive --authorize < master-public-key.txt
  1136. @end example
  1137. @noindent
  1138. Likewise, the master machine must authorize the key of each build machine.
  1139. All the fuss with keys is here to express pairwise mutual trust
  1140. relations between the master and the build machines. Concretely, when
  1141. the master receives files from a build machine (and @i{vice versa}), its
  1142. build daemon can make sure they are genuine, have not been tampered
  1143. with, and that they are signed by an authorized key.
  1144. @cindex offload test
  1145. To test whether your setup is operational, run this command on the
  1146. master node:
  1147. @example
  1148. # guix offload test
  1149. @end example
  1150. This will attempt to connect to each of the build machines specified in
  1151. @file{/etc/guix/machines.scm}, make sure Guix is
  1152. available on each machine, attempt to export to the machine and import
  1153. from it, and report any error in the process.
  1154. If you want to test a different machine file, just specify it on the
  1155. command line:
  1156. @example
  1157. # guix offload test machines-qualif.scm
  1158. @end example
  1159. Last, you can test the subset of the machines whose name matches a
  1160. regular expression like this:
  1161. @example
  1162. # guix offload test machines.scm '\.gnu\.org$'
  1163. @end example
  1164. @cindex offload status
  1165. To display the current load of all build hosts, run this command on the
  1166. main node:
  1167. @example
  1168. # guix offload status
  1169. @end example
  1170. @node SELinux Support
  1171. @subsection SELinux Support
  1172. @cindex SELinux, daemon policy
  1173. @cindex mandatory access control, SELinux
  1174. @cindex security, guix-daemon
  1175. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1176. can be installed on a system where SELinux is enabled, in order to label
  1177. Guix files and to specify the expected behavior of the daemon. Since
  1178. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1179. be used on Guix System.
  1180. @subsubsection Installing the SELinux policy
  1181. @cindex SELinux, policy installation
  1182. To install the policy run this command as root:
  1183. @example
  1184. semodule -i etc/guix-daemon.cil
  1185. @end example
  1186. Then relabel the file system with @code{restorecon} or by a different
  1187. mechanism provided by your system.
  1188. Once the policy is installed, the file system has been relabeled, and
  1189. the daemon has been restarted, it should be running in the
  1190. @code{guix_daemon_t} context. You can confirm this with the following
  1191. command:
  1192. @example
  1193. ps -Zax | grep guix-daemon
  1194. @end example
  1195. Monitor the SELinux log files as you run a command like @code{guix build
  1196. hello} to convince yourself that SELinux permits all necessary
  1197. operations.
  1198. @subsubsection Limitations
  1199. @cindex SELinux, limitations
  1200. This policy is not perfect. Here is a list of limitations or quirks
  1201. that should be considered when deploying the provided SELinux policy for
  1202. the Guix daemon.
  1203. @enumerate
  1204. @item
  1205. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1206. operations involve contexts that have anything to do with
  1207. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1208. but it would be preferable to define socket rules for only this label.
  1209. @item
  1210. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1211. the file label of the destination of a symlink is independent of the
  1212. file label of the link itself. Although all profiles under
  1213. $localstatedir are labelled, the links to these profiles inherit the
  1214. label of the directory they are in. For links in the user’s home
  1215. directory this will be @code{user_home_t}. But for links from the root
  1216. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1217. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1218. reading and following these links.
  1219. @item
  1220. The daemon’s feature to listen for TCP connections might no longer work.
  1221. This might require extra rules, because SELinux treats network sockets
  1222. differently from files.
  1223. @item
  1224. Currently all files with a name matching the regular expression
  1225. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1226. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1227. that name in any profile would be permitted to run in the
  1228. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1229. build a package that provides this executable and convince a user to
  1230. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1231. At that point SELinux could not prevent it from accessing files that are
  1232. allowed for processes in that domain.
  1233. You will need to relabel the store directory after all upgrades to
  1234. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1235. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1236. or by other means provided by your operating system.
  1237. We could generate a much more restrictive policy at installation time,
  1238. so that only the @emph{exact} file name of the currently installed
  1239. @code{guix-daemon} executable would be labelled with
  1240. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1241. The downside is that root would have to install or upgrade the policy at
  1242. installation time whenever the Guix package that provides the
  1243. effectively running @code{guix-daemon} executable is upgraded.
  1244. @end enumerate
  1245. @node Invoking guix-daemon
  1246. @section Invoking @command{guix-daemon}
  1247. The @command{guix-daemon} program implements all the functionality to
  1248. access the store. This includes launching build processes, running the
  1249. garbage collector, querying the availability of a build result, etc. It
  1250. is normally run as @code{root} like this:
  1251. @example
  1252. # guix-daemon --build-users-group=guixbuild
  1253. @end example
  1254. @noindent
  1255. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1256. @cindex chroot
  1257. @cindex container, build environment
  1258. @cindex build environment
  1259. @cindex reproducible builds
  1260. By default, @command{guix-daemon} launches build processes under
  1261. different UIDs, taken from the build group specified with
  1262. @option{--build-users-group}. In addition, each build process is run in a
  1263. chroot environment that only contains the subset of the store that the
  1264. build process depends on, as specified by its derivation
  1265. (@pxref{Programming Interface, derivation}), plus a set of specific
  1266. system directories. By default, the latter contains @file{/dev} and
  1267. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1268. @dfn{container}: in addition to having its own file system tree, it has
  1269. a separate mount name space, its own PID name space, network name space,
  1270. etc. This helps achieve reproducible builds (@pxref{Features}).
  1271. When the daemon performs a build on behalf of the user, it creates a
  1272. build directory under @file{/tmp} or under the directory specified by
  1273. its @env{TMPDIR} environment variable. This directory is shared with
  1274. the container for the duration of the build, though within the container,
  1275. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1276. The build directory is automatically deleted upon completion, unless the
  1277. build failed and the client specified @option{--keep-failed}
  1278. (@pxref{Common Build Options, @option{--keep-failed}}).
  1279. The daemon listens for connections and spawns one sub-process for each session
  1280. started by a client (one of the @command{guix} sub-commands). The
  1281. @command{guix processes} command allows you to get an overview of the activity
  1282. on your system by viewing each of the active sessions and clients.
  1283. @xref{Invoking guix processes}, for more information.
  1284. The following command-line options are supported:
  1285. @table @code
  1286. @item --build-users-group=@var{group}
  1287. Take users from @var{group} to run build processes (@pxref{Setting Up
  1288. the Daemon, build users}).
  1289. @item --no-substitutes
  1290. @cindex substitutes
  1291. Do not use substitutes for build products. That is, always build things
  1292. locally instead of allowing downloads of pre-built binaries
  1293. (@pxref{Substitutes}).
  1294. When the daemon runs with @option{--no-substitutes}, clients can still
  1295. explicitly enable substitution @i{via} the @code{set-build-options}
  1296. remote procedure call (@pxref{The Store}).
  1297. @anchor{daemon-substitute-urls}
  1298. @item --substitute-urls=@var{urls}
  1299. Consider @var{urls} the default whitespace-separated list of substitute
  1300. source URLs. When this option is omitted,
  1301. @indicateurl{@value{SUBSTITUTE-URLS}} is used.
  1302. This means that substitutes may be downloaded from @var{urls}, as long
  1303. as they are signed by a trusted signature (@pxref{Substitutes}).
  1304. @xref{Getting Substitutes from Other Servers}, for more information on
  1305. how to configure the daemon to get substitutes from other servers.
  1306. @cindex offloading
  1307. @item --no-offload
  1308. Do not use offload builds to other machines (@pxref{Daemon Offload
  1309. Setup}). That is, always build things locally instead of offloading
  1310. builds to remote machines.
  1311. @item --cache-failures
  1312. Cache build failures. By default, only successful builds are cached.
  1313. When this option is used, @command{guix gc --list-failures} can be used
  1314. to query the set of store items marked as failed; @command{guix gc
  1315. --clear-failures} removes store items from the set of cached failures.
  1316. @xref{Invoking guix gc}.
  1317. @item --cores=@var{n}
  1318. @itemx -c @var{n}
  1319. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1320. as available.
  1321. The default value is @code{0}, but it may be overridden by clients, such
  1322. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1323. guix build}).
  1324. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1325. in the build process, which can then use it to exploit internal
  1326. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1327. @item --max-jobs=@var{n}
  1328. @itemx -M @var{n}
  1329. Allow at most @var{n} build jobs in parallel. The default value is
  1330. @code{1}. Setting it to @code{0} means that no builds will be performed
  1331. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1332. Setup}), or simply fail.
  1333. @item --max-silent-time=@var{seconds}
  1334. When the build or substitution process remains silent for more than
  1335. @var{seconds}, terminate it and report a build failure.
  1336. The default value is @code{0}, which disables the timeout.
  1337. The value specified here can be overridden by clients (@pxref{Common
  1338. Build Options, @option{--max-silent-time}}).
  1339. @item --timeout=@var{seconds}
  1340. Likewise, when the build or substitution process lasts for more than
  1341. @var{seconds}, terminate it and report a build failure.
  1342. The default value is @code{0}, which disables the timeout.
  1343. The value specified here can be overridden by clients (@pxref{Common
  1344. Build Options, @option{--timeout}}).
  1345. @item --rounds=@var{N}
  1346. Build each derivation @var{n} times in a row, and raise an error if
  1347. consecutive build results are not bit-for-bit identical. Note that this
  1348. setting can be overridden by clients such as @command{guix build}
  1349. (@pxref{Invoking guix build}).
  1350. When used in conjunction with @option{--keep-failed}, the differing
  1351. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1352. This makes it easy to look for differences between the two results.
  1353. @item --debug
  1354. Produce debugging output.
  1355. This is useful to debug daemon start-up issues, but then it may be
  1356. overridden by clients, for example the @option{--verbosity} option of
  1357. @command{guix build} (@pxref{Invoking guix build}).
  1358. @item --chroot-directory=@var{dir}
  1359. Add @var{dir} to the build chroot.
  1360. Doing this may change the result of build processes---for instance if
  1361. they use optional dependencies found in @var{dir} when it is available,
  1362. and not otherwise. For that reason, it is not recommended to do so.
  1363. Instead, make sure that each derivation declares all the inputs that it
  1364. needs.
  1365. @item --disable-chroot
  1366. Disable chroot builds.
  1367. Using this option is not recommended since, again, it would allow build
  1368. processes to gain access to undeclared dependencies. It is necessary,
  1369. though, when @command{guix-daemon} is running under an unprivileged user
  1370. account.
  1371. @item --log-compression=@var{type}
  1372. Compress build logs according to @var{type}, one of @code{gzip},
  1373. @code{bzip2}, or @code{none}.
  1374. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1375. @var{localstatedir}. To save space, the daemon automatically compresses
  1376. them with Bzip2 by default.
  1377. @item --discover[=yes|no]
  1378. Whether to discover substitute servers on the local network using mDNS
  1379. and DNS-SD.
  1380. This feature is still experimental. However, here are a few
  1381. considerations.
  1382. @enumerate
  1383. @item
  1384. It might be faster/less expensive than fetching from remote servers;
  1385. @item
  1386. There are no security risks, only genuine substitutes will be used
  1387. (@pxref{Substitute Authentication});
  1388. @item
  1389. An attacker advertising @command{guix publish} on your LAN cannot serve
  1390. you malicious binaries, but they can learn what software you’re
  1391. installing;
  1392. @item
  1393. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1394. LAN can see what software you’re installing.
  1395. @end enumerate
  1396. It is also possible to enable or disable substitute server discovery at
  1397. run-time by running:
  1398. @example
  1399. herd discover guix-daemon on
  1400. herd discover guix-daemon off
  1401. @end example
  1402. @item --disable-deduplication
  1403. @cindex deduplication
  1404. Disable automatic file ``deduplication'' in the store.
  1405. By default, files added to the store are automatically ``deduplicated'':
  1406. if a newly added file is identical to another one found in the store,
  1407. the daemon makes the new file a hard link to the other file. This can
  1408. noticeably reduce disk usage, at the expense of slightly increased
  1409. input/output load at the end of a build process. This option disables
  1410. this optimization.
  1411. @item --gc-keep-outputs[=yes|no]
  1412. Tell whether the garbage collector (GC) must keep outputs of live
  1413. derivations.
  1414. @cindex GC roots
  1415. @cindex garbage collector roots
  1416. When set to @code{yes}, the GC will keep the outputs of any live
  1417. derivation available in the store---the @file{.drv} files. The default
  1418. is @code{no}, meaning that derivation outputs are kept only if they are
  1419. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1420. roots.
  1421. @item --gc-keep-derivations[=yes|no]
  1422. Tell whether the garbage collector (GC) must keep derivations
  1423. corresponding to live outputs.
  1424. When set to @code{yes}, as is the case by default, the GC keeps
  1425. derivations---i.e., @file{.drv} files---as long as at least one of their
  1426. outputs is live. This allows users to keep track of the origins of
  1427. items in their store. Setting it to @code{no} saves a bit of disk
  1428. space.
  1429. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1430. liveness to flow from outputs to derivations, and setting
  1431. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1432. derivations to outputs. When both are set to @code{yes}, the effect is
  1433. to keep all the build prerequisites (the sources, compiler, libraries,
  1434. and other build-time tools) of live objects in the store, regardless of
  1435. whether these prerequisites are reachable from a GC root. This is
  1436. convenient for developers since it saves rebuilds or downloads.
  1437. @item --impersonate-linux-2.6
  1438. On Linux-based systems, impersonate Linux 2.6. This means that the
  1439. kernel's @command{uname} system call will report 2.6 as the release number.
  1440. This might be helpful to build programs that (usually wrongfully) depend
  1441. on the kernel version number.
  1442. @item --lose-logs
  1443. Do not keep build logs. By default they are kept under
  1444. @file{@var{localstatedir}/guix/log}.
  1445. @item --system=@var{system}
  1446. Assume @var{system} as the current system type. By default it is the
  1447. architecture/kernel pair found at configure time, such as
  1448. @code{x86_64-linux}.
  1449. @item --listen=@var{endpoint}
  1450. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1451. as the file name of a Unix-domain socket if it starts with
  1452. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1453. host name or host name and port to listen to. Here are a few examples:
  1454. @table @code
  1455. @item --listen=/gnu/var/daemon
  1456. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1457. creating it if needed.
  1458. @item --listen=localhost
  1459. @cindex daemon, remote access
  1460. @cindex remote access to the daemon
  1461. @cindex daemon, cluster setup
  1462. @cindex clusters, daemon setup
  1463. Listen for TCP connections on the network interface corresponding to
  1464. @code{localhost}, on port 44146.
  1465. @item --listen=128.0.0.42:1234
  1466. Listen for TCP connections on the network interface corresponding to
  1467. @code{128.0.0.42}, on port 1234.
  1468. @end table
  1469. This option can be repeated multiple times, in which case
  1470. @command{guix-daemon} accepts connections on all the specified
  1471. endpoints. Users can tell client commands what endpoint to connect to
  1472. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1473. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1474. @quotation Note
  1475. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1476. @option{--listen=@var{host}} is suitable on local networks, such as
  1477. clusters, where only trusted nodes may connect to the build daemon. In
  1478. other cases where remote access to the daemon is needed, we recommend
  1479. using Unix-domain sockets along with SSH.
  1480. @end quotation
  1481. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1482. connections on the Unix-domain socket located at
  1483. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1484. @end table
  1485. @node Application Setup
  1486. @section Application Setup
  1487. @cindex foreign distro
  1488. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1489. so-called @dfn{foreign distro}---a few additional steps are needed to
  1490. get everything in place. Here are some of them.
  1491. @subsection Locales
  1492. @anchor{locales-and-locpath}
  1493. @cindex locales, when not on Guix System
  1494. @vindex LOCPATH
  1495. @vindex GUIX_LOCPATH
  1496. Packages installed @i{via} Guix will not use the locale data of the
  1497. host system. Instead, you must first install one of the locale packages
  1498. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1499. variable:
  1500. @example
  1501. $ guix install glibc-locales
  1502. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1503. @end example
  1504. Note that the @code{glibc-locales} package contains data for all the
  1505. locales supported by the GNU@tie{}libc and weighs in at around
  1506. 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1507. limited to a few UTF-8 locales.
  1508. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1509. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1510. Manual}). There are two important differences though:
  1511. @enumerate
  1512. @item
  1513. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1514. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1515. to make sure the programs of the foreign distro will not end up loading
  1516. incompatible locale data.
  1517. @item
  1518. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1519. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1520. should your Guix profile contain a mixture of programs linked against
  1521. different libc version, each libc version will only try to load locale
  1522. data in the right format.
  1523. @end enumerate
  1524. This is important because the locale data format used by different libc
  1525. versions may be incompatible.
  1526. @subsection Name Service Switch
  1527. @cindex name service switch, glibc
  1528. @cindex NSS (name service switch), glibc
  1529. @cindex nscd (name service caching daemon)
  1530. @cindex name service caching daemon (nscd)
  1531. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1532. the system run the GNU C library's @dfn{name service cache daemon},
  1533. @command{nscd}, which should be listening on the
  1534. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1535. installed with Guix may fail to look up host names or user accounts, or
  1536. may even crash. The next paragraphs explain why.
  1537. @cindex @file{nsswitch.conf}
  1538. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1539. an extensible mechanism for ``name lookups'' in general: host name
  1540. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1541. The GNU C Library Reference Manual}).
  1542. @cindex Network information service (NIS)
  1543. @cindex NIS (Network information service)
  1544. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1545. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1546. resolution of @code{.local} host names, the @code{nis} plugin allows
  1547. user account lookup using the Network information service (NIS), and so
  1548. on. These extra ``lookup services'' are configured system-wide in
  1549. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1550. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1551. Reference Manual}).
  1552. When they perform a name lookup---for instance by calling the
  1553. @code{getaddrinfo} function in C---applications first try to connect to
  1554. the nscd; on success, nscd performs name lookups on their behalf. If
  1555. the nscd is not running, then they perform the name lookup by
  1556. themselves, by loading the name lookup services into their own address
  1557. space and running it. These name lookup services---the
  1558. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1559. the host system's C library, rather than from the C library the
  1560. application is linked against (the C library coming from Guix).
  1561. And this is where the problem is: if your application is linked against
  1562. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1563. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1564. likely crash or have its name lookups fail unexpectedly.
  1565. Running @command{nscd} on the system, among other advantages, eliminates
  1566. this binary incompatibility problem because those @code{libnss_*.so}
  1567. files are loaded in the @command{nscd} process, not in applications
  1568. themselves.
  1569. @subsection X11 Fonts
  1570. @cindex fonts
  1571. The majority of graphical applications use Fontconfig to locate and load
  1572. fonts and perform X11-client-side rendering. The @code{fontconfig}
  1573. package in Guix looks for fonts in @file{$HOME/.guix-profile} by
  1574. default. Thus, to allow graphical applications installed with Guix to
  1575. display fonts, you have to install fonts with Guix as well. Essential
  1576. font packages include @code{font-ghostscript}, @code{font-dejavu}, and
  1577. @code{font-gnu-freefont}.
  1578. @cindex @code{fc-cache}
  1579. @cindex font cache
  1580. Once you have installed or removed fonts, or when you notice an
  1581. application that does not find fonts, you may need to install Fontconfig
  1582. and to force an update of its font cache by running:
  1583. @example
  1584. guix install fontconfig
  1585. fc-cache -rv
  1586. @end example
  1587. To display text written in Chinese languages, Japanese, or Korean in
  1588. graphical applications, consider installing
  1589. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1590. has multiple outputs, one per language family (@pxref{Packages with
  1591. Multiple Outputs}). For instance, the following command installs fonts
  1592. for Chinese languages:
  1593. @example
  1594. guix install font-adobe-source-han-sans:cn
  1595. @end example
  1596. @cindex @code{xterm}
  1597. Older programs such as @command{xterm} do not use Fontconfig and instead
  1598. rely on server-side font rendering. Such programs require to specify a
  1599. full name of a font using XLFD (X Logical Font Description), like this:
  1600. @example
  1601. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1602. @end example
  1603. To be able to use such full names for the TrueType fonts installed in
  1604. your Guix profile, you need to extend the font path of the X server:
  1605. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1606. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1607. @example
  1608. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1609. @end example
  1610. @cindex @code{xlsfonts}
  1611. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1612. to make sure your TrueType fonts are listed there.
  1613. @subsection X.509 Certificates
  1614. @cindex @code{nss-certs}
  1615. The @code{nss-certs} package provides X.509 certificates, which allow
  1616. programs to authenticate Web servers accessed over HTTPS.
  1617. When using Guix on a foreign distro, you can install this package and
  1618. define the relevant environment variables so that packages know where to
  1619. look for certificates. @xref{X.509 Certificates}, for detailed
  1620. information.
  1621. @subsection Emacs Packages
  1622. @cindex @code{emacs}
  1623. When you install Emacs packages with Guix, the Elisp files are placed
  1624. under the @file{share/emacs/site-lisp/} directory of the profile in
  1625. which they are installed. The Elisp libraries are made available to
  1626. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1627. set when installing Emacs itself.
  1628. Additionally, autoload definitions are automatically evaluated at the
  1629. initialization of Emacs, by the Guix-specific
  1630. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1631. want to avoid auto-loading the Emacs packages installed with Guix, you
  1632. can do so by running Emacs with the @option{--no-site-file} option
  1633. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1634. @node Upgrading Guix
  1635. @section Upgrading Guix
  1636. @cindex Upgrading Guix, on a foreign distro
  1637. To upgrade Guix, run:
  1638. @example
  1639. guix pull
  1640. @end example
  1641. @xref{Invoking guix pull}, for more information.
  1642. @cindex upgrading Guix for the root user, on a foreign distro
  1643. @cindex upgrading the Guix daemon, on a foreign distro
  1644. @cindex @command{guix pull} for the root user, on a foreign distro
  1645. On a foreign distro, you can upgrade the build daemon by running:
  1646. @example
  1647. sudo -i guix pull
  1648. @end example
  1649. @noindent
  1650. followed by (assuming your distro uses the systemd service management
  1651. tool):
  1652. @example
  1653. systemctl restart guix-daemon.service
  1654. @end example
  1655. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1656. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1657. @c TODO What else?
  1658. @c *********************************************************************
  1659. @node System Installation
  1660. @chapter System Installation
  1661. @cindex installing Guix System
  1662. @cindex Guix System, installation
  1663. This section explains how to install Guix System
  1664. on a machine. Guix, as a package manager, can
  1665. also be installed on top of a running GNU/Linux system,
  1666. @pxref{Installation}.
  1667. @ifinfo
  1668. @quotation Note
  1669. @c This paragraph is for people reading this from tty2 of the
  1670. @c installation image.
  1671. You are reading this documentation with an Info reader. For details on
  1672. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1673. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1674. Info}. Hit @kbd{l} afterwards to come back here.
  1675. Alternatively, run @command{info info} in another tty to keep the manual
  1676. available.
  1677. @end quotation
  1678. @end ifinfo
  1679. @menu
  1680. * Limitations:: What you can expect.
  1681. * Hardware Considerations:: Supported hardware.
  1682. * USB Stick and DVD Installation:: Preparing the installation medium.
  1683. * Preparing for Installation:: Networking, partitioning, etc.
  1684. * Guided Graphical Installation:: Easy graphical installation.
  1685. * Manual Installation:: Manual installation for wizards.
  1686. * After System Installation:: When installation succeeded.
  1687. * Installing Guix in a VM:: Guix System playground.
  1688. * Building the Installation Image:: How this comes to be.
  1689. @end menu
  1690. @node Limitations
  1691. @section Limitations
  1692. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1693. use cases. The reliability guarantees it provides---transactional upgrades
  1694. and rollbacks, reproducibility---make it a solid foundation.
  1695. Nevertheless, before you proceed with the installation, be aware of the
  1696. following noteworthy limitations applicable to version @value{VERSION}:
  1697. @itemize
  1698. @item
  1699. More and more system services are provided (@pxref{Services}), but some
  1700. may be missing.
  1701. @item
  1702. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1703. as well as a number of X11 window managers. However, KDE is currently
  1704. missing.
  1705. @end itemize
  1706. More than a disclaimer, this is an invitation to report issues (and success
  1707. stories!), and to join us in improving it. @xref{Contributing}, for more
  1708. info.
  1709. @node Hardware Considerations
  1710. @section Hardware Considerations
  1711. @cindex hardware support on Guix System
  1712. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1713. builds around the kernel Linux-libre, which means that only hardware for
  1714. which free software drivers and firmware exist is supported. Nowadays,
  1715. a wide range of off-the-shelf hardware is supported on
  1716. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1717. Ethernet controllers. Unfortunately, there are still areas where
  1718. hardware vendors deny users control over their own computing, and such
  1719. hardware is not supported on Guix System.
  1720. @cindex WiFi, hardware support
  1721. One of the main areas where free drivers or firmware are lacking is WiFi
  1722. devices. WiFi devices known to work include those using Atheros chips
  1723. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1724. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1725. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1726. Linux-libre driver. Free firmware exists for both and is available
  1727. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1728. (@pxref{operating-system Reference, @code{firmware}}).
  1729. @cindex RYF, Respects Your Freedom
  1730. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1731. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1732. certification program for hardware products that respect your freedom
  1733. and your privacy and ensure that you have control over your device. We
  1734. encourage you to check the list of RYF-certified devices.
  1735. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1736. web site. It contains a catalog of hardware devices with information
  1737. about their support in GNU/Linux.
  1738. @node USB Stick and DVD Installation
  1739. @section USB Stick and DVD Installation
  1740. An ISO-9660 installation image that can be written to a USB stick or
  1741. burnt to a DVD can be downloaded from
  1742. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso},
  1743. where you can replace @code{x86_64-linux} with one of:
  1744. @table @code
  1745. @item x86_64-linux
  1746. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1747. @item i686-linux
  1748. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1749. @end table
  1750. @c start duplication of authentication part from ``Binary Installation''
  1751. Make sure to download the associated @file{.sig} file and to verify the
  1752. authenticity of the image against it, along these lines:
  1753. @example
  1754. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1755. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1756. @end example
  1757. If that command fails because you do not have the required public key,
  1758. then run this command to import it:
  1759. @example
  1760. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1761. -qO - | gpg --import -
  1762. @end example
  1763. @noindent
  1764. and rerun the @code{gpg --verify} command.
  1765. Take note that a warning like ``This key is not certified with a trusted
  1766. signature!'' is normal.
  1767. @c end duplication
  1768. This image contains the tools necessary for an installation.
  1769. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1770. @unnumberedsubsec Copying to a USB Stick
  1771. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1772. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1773. copy the image with:
  1774. @example
  1775. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1776. sync
  1777. @end example
  1778. Access to @file{/dev/sdX} usually requires root privileges.
  1779. @unnumberedsubsec Burning on a DVD
  1780. Insert a blank DVD into your machine, and determine
  1781. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1782. copy the image with:
  1783. @example
  1784. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1785. @end example
  1786. Access to @file{/dev/srX} usually requires root privileges.
  1787. @unnumberedsubsec Booting
  1788. Once this is done, you should be able to reboot the system and boot from
  1789. the USB stick or DVD@. The latter usually requires you to get in the
  1790. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1791. In order to boot from Libreboot, switch to the command mode by pressing
  1792. the @kbd{c} key and type @command{search_grub usb}.
  1793. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1794. Guix System in a virtual machine (VM).
  1795. @node Preparing for Installation
  1796. @section Preparing for Installation
  1797. Once you have booted, you can use the guided graphical installer, which makes
  1798. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1799. if you are already familiar with GNU/Linux and if you want more control than
  1800. what the graphical installer provides, you can choose the ``manual''
  1801. installation process (@pxref{Manual Installation}).
  1802. The graphical installer is available on TTY1. You can obtain root shells on
  1803. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1804. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1805. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1806. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1807. which allows you to select text with the left mouse button and to paste it
  1808. with the middle button.
  1809. @quotation Note
  1810. Installation requires access to the Internet so that any missing
  1811. dependencies of your system configuration can be downloaded. See the
  1812. ``Networking'' section below.
  1813. @end quotation
  1814. @node Guided Graphical Installation
  1815. @section Guided Graphical Installation
  1816. The graphical installer is a text-based user interface. It will guide you,
  1817. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1818. The first dialog boxes allow you to set up the system as you use it during the
  1819. installation: you can choose the language, keyboard layout, and set up
  1820. networking, which will be used during the installation. The image below shows
  1821. the networking dialog.
  1822. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1823. Later steps allow you to partition your hard disk, as shown in the image
  1824. below, to choose whether or not to use encrypted file systems, to enter the
  1825. host name and root password, and to create an additional account, among other
  1826. things.
  1827. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1828. Note that, at any time, the installer allows you to exit the current
  1829. installation step and resume at a previous step, as show in the image below.
  1830. @image{images/installer-resume,5in,, resuming the installation process}
  1831. Once you're done, the installer produces an operating system configuration and
  1832. displays it (@pxref{Using the Configuration System}). At that point you can
  1833. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1834. new system and enjoy. @xref{After System Installation}, for what's next!
  1835. @node Manual Installation
  1836. @section Manual Installation
  1837. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1838. on your machine. This option requires familiarity with GNU/Linux, with the
  1839. shell, and with common administration tools. If you think this is not for
  1840. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1841. Installation}).
  1842. The installation system provides root shells on TTYs 3 to 6; press
  1843. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1844. many common tools needed to install the system. But it is also a full-blown
  1845. Guix System, which means that you can install additional packages, should you
  1846. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1847. @menu
  1848. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1849. * Proceeding with the Installation:: Installing.
  1850. @end menu
  1851. @node Keyboard Layout and Networking and Partitioning
  1852. @subsection Keyboard Layout, Networking, and Partitioning
  1853. Before you can install the system, you may want to adjust the keyboard layout,
  1854. set up networking, and partition your target hard disk. This section will
  1855. guide you through this.
  1856. @subsubsection Keyboard Layout
  1857. @cindex keyboard layout
  1858. The installation image uses the US qwerty keyboard layout. If you want
  1859. to change it, you can use the @command{loadkeys} command. For example,
  1860. the following command selects the Dvorak keyboard layout:
  1861. @example
  1862. loadkeys dvorak
  1863. @end example
  1864. See the files under @file{/run/current-system/profile/share/keymaps} for
  1865. a list of available keyboard layouts. Run @command{man loadkeys} for
  1866. more information.
  1867. @subsubsection Networking
  1868. Run the following command to see what your network interfaces are called:
  1869. @example
  1870. ifconfig -a
  1871. @end example
  1872. @noindent
  1873. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1874. @example
  1875. ip address
  1876. @end example
  1877. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1878. Wired interfaces have a name starting with @samp{e}; for example, the
  1879. interface corresponding to the first on-board Ethernet controller is
  1880. called @samp{eno1}. Wireless interfaces have a name starting with
  1881. @samp{w}, like @samp{w1p2s0}.
  1882. @table @asis
  1883. @item Wired connection
  1884. To configure a wired network run the following command, substituting
  1885. @var{interface} with the name of the wired interface you want to use.
  1886. @example
  1887. ifconfig @var{interface} up
  1888. @end example
  1889. @noindent
  1890. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1891. @example
  1892. ip link set @var{interface} up
  1893. @end example
  1894. @item Wireless connection
  1895. @cindex wireless
  1896. @cindex WiFi
  1897. To configure wireless networking, you can create a configuration file
  1898. for the @command{wpa_supplicant} configuration tool (its location is not
  1899. important) using one of the available text editors such as
  1900. @command{nano}:
  1901. @example
  1902. nano wpa_supplicant.conf
  1903. @end example
  1904. As an example, the following stanza can go to this file and will work
  1905. for many wireless networks, provided you give the actual SSID and
  1906. passphrase for the network you are connecting to:
  1907. @example
  1908. network=@{
  1909. ssid="@var{my-ssid}"
  1910. key_mgmt=WPA-PSK
  1911. psk="the network's secret passphrase"
  1912. @}
  1913. @end example
  1914. Start the wireless service and run it in the background with the
  1915. following command (substitute @var{interface} with the name of the
  1916. network interface you want to use):
  1917. @example
  1918. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1919. @end example
  1920. Run @command{man wpa_supplicant} for more information.
  1921. @end table
  1922. @cindex DHCP
  1923. At this point, you need to acquire an IP address. On a network where IP
  1924. addresses are automatically assigned @i{via} DHCP, you can run:
  1925. @example
  1926. dhclient -v @var{interface}
  1927. @end example
  1928. Try to ping a server to see if networking is up and running:
  1929. @example
  1930. ping -c 3 gnu.org
  1931. @end example
  1932. Setting up network access is almost always a requirement because the
  1933. image does not contain all the software and tools that may be needed.
  1934. @cindex proxy, during system installation
  1935. If you need HTTP and HTTPS access to go through a proxy, run the
  1936. following command:
  1937. @example
  1938. herd set-http-proxy guix-daemon @var{URL}
  1939. @end example
  1940. @noindent
  1941. where @var{URL} is the proxy URL, for example
  1942. @code{http://example.org:8118}.
  1943. @cindex installing over SSH
  1944. If you want to, you can continue the installation remotely by starting
  1945. an SSH server:
  1946. @example
  1947. herd start ssh-daemon
  1948. @end example
  1949. Make sure to either set a password with @command{passwd}, or configure
  1950. OpenSSH public key authentication before logging in.
  1951. @subsubsection Disk Partitioning
  1952. Unless this has already been done, the next step is to partition, and
  1953. then format the target partition(s).
  1954. The installation image includes several partitioning tools, including
  1955. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1956. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1957. the partition layout you want:
  1958. @example
  1959. cfdisk
  1960. @end example
  1961. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1962. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1963. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1964. manual}).
  1965. @cindex EFI, installation
  1966. @cindex UEFI, installation
  1967. @cindex ESP, EFI system partition
  1968. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1969. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1970. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  1971. @example
  1972. parted /dev/sda set 1 esp on
  1973. @end example
  1974. @quotation Note
  1975. @vindex grub-bootloader
  1976. @vindex grub-efi-bootloader
  1977. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  1978. @file{/sys/firmware/efi} exists in the installation image, then you should
  1979. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  1980. Otherwise you should use the BIOS-based GRUB, known as
  1981. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  1982. bootloaders.
  1983. @end quotation
  1984. Once you are done partitioning the target hard disk drive, you have to
  1985. create a file system on the relevant partition(s)@footnote{Currently
  1986. Guix System only supports ext4, btrfs, JFS, F2FS, and XFS file systems. In
  1987. particular, code that reads file system UUIDs and labels only works for these
  1988. file system types.}. For the ESP, if you have one and assuming it is
  1989. @file{/dev/sda1}, run:
  1990. @example
  1991. mkfs.fat -F32 /dev/sda1
  1992. @end example
  1993. For the root file system, ext4 is the most widely used format. Other
  1994. file systems, such as Btrfs, support compression, which is reported to
  1995. nicely complement file deduplication that the daemon performs
  1996. independently of the file system (@pxref{Invoking guix-daemon,
  1997. deduplication}).
  1998. Preferably, assign file systems a label so that you can easily and
  1999. reliably refer to them in @code{file-system} declarations (@pxref{File
  2000. Systems}). This is typically done using the @code{-L} option of
  2001. @command{mkfs.ext4} and related commands. So, assuming the target root
  2002. partition lives at @file{/dev/sda2}, a file system with the label
  2003. @code{my-root} can be created with:
  2004. @example
  2005. mkfs.ext4 -L my-root /dev/sda2
  2006. @end example
  2007. @cindex encrypted disk
  2008. If you are instead planning to encrypt the root partition, you can use
  2009. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  2010. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  2011. @code{man cryptsetup}} for more information).
  2012. @quotation Warning
  2013. Note that GRUB can unlock LUKS2 devices since version 2.06, but only
  2014. supports the PBKDF2 key derivation function, which is not the default
  2015. for @command{cryptsetup luksFormat}. You can check which key derivation
  2016. function is being used by a device by running @command{cryptsetup
  2017. luksDump @var{device}}, and looking for the PBKDF field of your
  2018. keyslots.
  2019. @end quotation
  2020. Assuming you want to store the root partition on @file{/dev/sda2}, the
  2021. command sequence to format it as a LUKS2 partition would be along these
  2022. lines:
  2023. @example
  2024. cryptsetup luksFormat --type luks2 --pbkdf pbkdf2 /dev/sda2
  2025. cryptsetup open /dev/sda2 my-partition
  2026. mkfs.ext4 -L my-root /dev/mapper/my-partition
  2027. @end example
  2028. Once that is done, mount the target file system under @file{/mnt}
  2029. with a command like (again, assuming @code{my-root} is the label of the
  2030. root file system):
  2031. @example
  2032. mount LABEL=my-root /mnt
  2033. @end example
  2034. Also mount any other file systems you would like to use on the target
  2035. system relative to this path. If you have opted for @file{/boot/efi} as an
  2036. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  2037. found by @code{guix system init} afterwards.
  2038. Finally, if you plan to use one or more swap partitions (@pxref{Swap
  2039. Space}), make sure to initialize them with @command{mkswap}. Assuming
  2040. you have one swap partition on @file{/dev/sda3}, you would run:
  2041. @example
  2042. mkswap /dev/sda3
  2043. swapon /dev/sda3
  2044. @end example
  2045. Alternatively, you may use a swap file. For example, assuming that in
  2046. the new system you want to use the file @file{/swapfile} as a swap file,
  2047. you would run@footnote{This example will work for many types of file
  2048. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  2049. btrfs), the required steps may be different. For details, see the
  2050. manual pages for @command{mkswap} and @command{swapon}.}:
  2051. @example
  2052. # This is 10 GiB of swap space. Adjust "count" to change the size.
  2053. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  2054. # For security, make the file readable and writable only by root.
  2055. chmod 600 /mnt/swapfile
  2056. mkswap /mnt/swapfile
  2057. swapon /mnt/swapfile
  2058. @end example
  2059. Note that if you have encrypted the root partition and created a swap
  2060. file in its file system as described above, then the encryption also
  2061. protects the swap file, just like any other file in that file system.
  2062. @node Proceeding with the Installation
  2063. @subsection Proceeding with the Installation
  2064. With the target partitions ready and the target root mounted on
  2065. @file{/mnt}, we're ready to go. First, run:
  2066. @example
  2067. herd start cow-store /mnt
  2068. @end example
  2069. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  2070. during the installation phase are written to the target disk on @file{/mnt}
  2071. rather than kept in memory. This is necessary because the first phase of
  2072. the @command{guix system init} command (see below) entails downloads or
  2073. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  2074. Next, you have to edit a file and
  2075. provide the declaration of the operating system to be installed. To
  2076. that end, the installation system comes with three text editors. We
  2077. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2078. supports syntax highlighting and parentheses matching; other editors
  2079. include mg (an Emacs clone), and
  2080. nvi (a clone of the original BSD @command{vi} editor).
  2081. We strongly recommend storing that file on the target root file system, say,
  2082. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2083. configuration file once you have rebooted into the newly-installed system.
  2084. @xref{Using the Configuration System}, for an overview of the
  2085. configuration file. The example configurations discussed in that
  2086. section are available under @file{/etc/configuration} in the
  2087. installation image. Thus, to get started with a system configuration
  2088. providing a graphical display server (a ``desktop'' system), you can run
  2089. something along these lines:
  2090. @example
  2091. # mkdir /mnt/etc
  2092. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2093. # nano /mnt/etc/config.scm
  2094. @end example
  2095. You should pay attention to what your configuration file contains, and
  2096. in particular:
  2097. @itemize
  2098. @item
  2099. Make sure the @code{bootloader-configuration} form refers to the targets
  2100. you want to install GRUB on. It should mention @code{grub-bootloader}
  2101. if you are installing GRUB in the legacy way, or
  2102. @code{grub-efi-bootloader} for newer UEFI systems. For legacy systems,
  2103. the @code{targets} field contain the names of the devices, like
  2104. @code{(list "/dev/sda")}; for UEFI systems it names the paths to mounted
  2105. EFI partitions, like @code{(list "/boot/efi")}; do make sure the paths
  2106. are currently mounted and a @code{file-system} entry is specified in
  2107. your configuration.
  2108. @item
  2109. Be sure that your file system labels match the value of their respective
  2110. @code{device} fields in your @code{file-system} configuration, assuming
  2111. your @code{file-system} configuration uses the @code{file-system-label}
  2112. procedure in its @code{device} field.
  2113. @item
  2114. If there are encrypted or RAID partitions, make sure to add a
  2115. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2116. @end itemize
  2117. Once you are done preparing the configuration file, the new system must
  2118. be initialized (remember that the target root file system is mounted
  2119. under @file{/mnt}):
  2120. @example
  2121. guix system init /mnt/etc/config.scm /mnt
  2122. @end example
  2123. @noindent
  2124. This copies all the necessary files and installs GRUB on
  2125. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2126. more information, @pxref{Invoking guix system}. This command may trigger
  2127. downloads or builds of missing packages, which can take some time.
  2128. Once that command has completed---and hopefully succeeded!---you can run
  2129. @command{reboot} and boot into the new system. The @code{root} password
  2130. in the new system is initially empty; other users' passwords need to be
  2131. initialized by running the @command{passwd} command as @code{root},
  2132. unless your configuration specifies otherwise
  2133. (@pxref{user-account-password, user account passwords}).
  2134. @xref{After System Installation}, for what's next!
  2135. @node After System Installation
  2136. @section After System Installation
  2137. Success, you've now booted into Guix System! From then on, you can update the
  2138. system whenever you want by running, say:
  2139. @example
  2140. guix pull
  2141. sudo guix system reconfigure /etc/config.scm
  2142. @end example
  2143. @noindent
  2144. This builds a new system generation with the latest packages and services
  2145. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2146. your system includes the latest security updates (@pxref{Security Updates}).
  2147. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2148. @quotation Note
  2149. @cindex sudo vs. @command{guix pull}
  2150. Note that @command{sudo guix} runs your user's @command{guix} command and
  2151. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2152. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2153. The difference matters here, because @command{guix pull} updates
  2154. the @command{guix} command and package definitions only for the user it is run
  2155. as. This means that if you choose to use @command{guix system reconfigure} in
  2156. root's login shell, you'll need to @command{guix pull} separately.
  2157. @end quotation
  2158. Now, @pxref{Getting Started}, and
  2159. join us on @code{#guix} on the Libera Chat IRC network or on
  2160. @email{guix-devel@@gnu.org} to share your experience!
  2161. @node Installing Guix in a VM
  2162. @section Installing Guix in a Virtual Machine
  2163. @cindex virtual machine, Guix System installation
  2164. @cindex virtual private server (VPS)
  2165. @cindex VPS (virtual private server)
  2166. If you'd like to install Guix System in a virtual machine (VM) or on a
  2167. virtual private server (VPS) rather than on your beloved machine, this
  2168. section is for you.
  2169. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2170. disk image, follow these steps:
  2171. @enumerate
  2172. @item
  2173. First, retrieve and decompress the Guix system installation image as
  2174. described previously (@pxref{USB Stick and DVD Installation}).
  2175. @item
  2176. Create a disk image that will hold the installed system. To make a
  2177. qcow2-formatted disk image, use the @command{qemu-img} command:
  2178. @example
  2179. qemu-img create -f qcow2 guix-system.img 50G
  2180. @end example
  2181. The resulting file will be much smaller than 50 GB (typically less than
  2182. 1 MB), but it will grow as the virtualized storage device is filled up.
  2183. @item
  2184. Boot the USB installation image in an VM:
  2185. @example
  2186. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2187. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2188. -drive file=guix-system.img \
  2189. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2190. @end example
  2191. @code{-enable-kvm} is optional, but significantly improves performance,
  2192. @pxref{Running Guix in a VM}.
  2193. @item
  2194. You're now root in the VM, proceed with the installation process.
  2195. @xref{Preparing for Installation}, and follow the instructions.
  2196. @end enumerate
  2197. Once installation is complete, you can boot the system that's on your
  2198. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2199. that.
  2200. @node Building the Installation Image
  2201. @section Building the Installation Image
  2202. @cindex installation image
  2203. The installation image described above was built using the @command{guix
  2204. system} command, specifically:
  2205. @example
  2206. guix system image -t iso9660 gnu/system/install.scm
  2207. @end example
  2208. Have a look at @file{gnu/system/install.scm} in the source tree,
  2209. and see also @ref{Invoking guix system} for more information
  2210. about the installation image.
  2211. @section Building the Installation Image for ARM Boards
  2212. Many ARM boards require a specific variant of the
  2213. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2214. If you build a disk image and the bootloader is not available otherwise
  2215. (on another boot drive etc), it's advisable to build an image that
  2216. includes the bootloader, specifically:
  2217. @example
  2218. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2219. @end example
  2220. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2221. board, a list of possible boards will be printed.
  2222. @c *********************************************************************
  2223. @node Getting Started
  2224. @chapter Getting Started
  2225. Presumably, you've reached this section because either you have
  2226. installed Guix on top of another distribution (@pxref{Installation}), or
  2227. you've installed the standalone Guix System (@pxref{System
  2228. Installation}). It's time for you to get started using Guix and this
  2229. section aims to help you do that and give you a feel of what it's like.
  2230. Guix is about installing software, so probably the first thing you'll
  2231. want to do is to actually look for software. Let's say you're looking
  2232. for a text editor, you can run:
  2233. @example
  2234. guix search text editor
  2235. @end example
  2236. This command shows you a number of matching @dfn{packages}, each time
  2237. showing the package's name, version, a description, and additional info.
  2238. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2239. you can go ahead and install it (run this command as a regular user,
  2240. @emph{no need for root privileges}!):
  2241. @example
  2242. guix install emacs
  2243. @end example
  2244. @cindex profile
  2245. You've installed your first package, congrats! The package is now
  2246. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2247. profile is a directory containing installed packages.
  2248. In the process, you've
  2249. probably noticed that Guix downloaded pre-built binaries; or, if you
  2250. explicitly chose to @emph{not} use pre-built binaries, then probably
  2251. Guix is still building software (@pxref{Substitutes}, for more info).
  2252. Unless you're using Guix System, the @command{guix install} command must
  2253. have printed this hint:
  2254. @example
  2255. hint: Consider setting the necessary environment variables by running:
  2256. GUIX_PROFILE="$HOME/.guix-profile"
  2257. . "$GUIX_PROFILE/etc/profile"
  2258. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2259. @end example
  2260. Indeed, you must now tell your shell where @command{emacs} and other
  2261. programs installed with Guix are to be found. Pasting the two lines
  2262. above will do just that: it will add
  2263. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2264. is---to the @code{PATH} environment variable. You can paste these two
  2265. lines in your shell so they take effect right away, but more importantly
  2266. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2267. do not use Bash) so that environment variables are set next time you
  2268. spawn a shell. You only need to do this once and other search paths
  2269. environment variables will be taken care of similarly---e.g., if you
  2270. eventually install @code{python} and Python libraries,
  2271. @env{GUIX_PYTHONPATH} will be defined.
  2272. You can go on installing packages at your will. To list installed
  2273. packages, run:
  2274. @example
  2275. guix package --list-installed
  2276. @end example
  2277. To remove a package, you would unsurprisingly run @command{guix remove}.
  2278. A distinguishing feature is the ability to @dfn{roll back} any operation
  2279. you made---installation, removal, upgrade---by simply typing:
  2280. @example
  2281. guix package --roll-back
  2282. @end example
  2283. This is because each operation is in fact a @dfn{transaction} that
  2284. creates a new @dfn{generation}. These generations and the difference
  2285. between them can be displayed by running:
  2286. @example
  2287. guix package --list-generations
  2288. @end example
  2289. Now you know the basics of package management!
  2290. @quotation Going further
  2291. @xref{Package Management}, for more about package management. You may
  2292. like @dfn{declarative} package management with @command{guix package
  2293. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2294. deleting old generations, collecting garbage, and other nifty features
  2295. that will come in handy as you become more familiar with Guix. If you
  2296. are a developer, @pxref{Development} for additional tools. And if
  2297. you're curious, @pxref{Features}, to peek under the hood.
  2298. @end quotation
  2299. Once you've installed a set of packages, you will want to periodically
  2300. @emph{upgrade} them to the latest and greatest version. To do that, you
  2301. will first pull the latest revision of Guix and its package collection:
  2302. @example
  2303. guix pull
  2304. @end example
  2305. The end result is a new @command{guix} command, under
  2306. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2307. first time you run @command{guix pull}, be sure to follow the hint that
  2308. the command prints and, similar to what we saw above, paste these two
  2309. lines in your terminal and @file{.bash_profile}:
  2310. @example
  2311. GUIX_PROFILE="$HOME/.config/guix/current"
  2312. . "$GUIX_PROFILE/etc/profile"
  2313. @end example
  2314. @noindent
  2315. You must also instruct your shell to point to this new @command{guix}:
  2316. @example
  2317. hash guix
  2318. @end example
  2319. At this point, you're running a brand new Guix. You can thus go ahead
  2320. and actually upgrade all the packages you previously installed:
  2321. @example
  2322. guix upgrade
  2323. @end example
  2324. As you run this command, you will see that binaries are downloaded (or
  2325. perhaps some packages are built), and eventually you end up with the
  2326. upgraded packages. Should one of these upgraded packages not be to your
  2327. liking, remember you can always roll back!
  2328. You can display the exact revision of Guix you're currently using by
  2329. running:
  2330. @example
  2331. guix describe
  2332. @end example
  2333. The information it displays is @emph{all it takes to reproduce the exact
  2334. same Guix}, be it at a different point in time or on a different
  2335. machine.
  2336. @quotation Going further
  2337. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2338. how to specify additional @dfn{channels} to pull packages from, how to
  2339. replicate Guix, and more. You may also find @command{time-machine}
  2340. handy (@pxref{Invoking guix time-machine}).
  2341. @end quotation
  2342. If you installed Guix System, one of the first things you'll want to do
  2343. is to upgrade your system. Once you've run @command{guix pull} to get
  2344. the latest Guix, you can upgrade the system like this:
  2345. @example
  2346. sudo guix system reconfigure /etc/config.scm
  2347. @end example
  2348. Upon completion, the system runs the latest versions of its software
  2349. packages. When you eventually reboot, you'll notice a sub-menu in the
  2350. bootloader that reads ``Old system generations'': it's what allows you
  2351. to boot @emph{an older generation of your system}, should the latest
  2352. generation be ``broken'' or otherwise unsatisfying. Just like for
  2353. packages, you can always @emph{roll back} to a previous generation
  2354. @emph{of the whole system}:
  2355. @example
  2356. sudo guix system roll-back
  2357. @end example
  2358. There are many things you'll probably want to tweak on your system:
  2359. adding new user accounts, adding new system services, fiddling with the
  2360. configuration of those services, etc. The system configuration is
  2361. @emph{entirely} described in the @file{/etc/config.scm} file.
  2362. @xref{Using the Configuration System}, to learn how to change it.
  2363. Now you know enough to get started!
  2364. @quotation Resources
  2365. The rest of this manual provides a reference for all things Guix. Here
  2366. are some additional resources you may find useful:
  2367. @itemize
  2368. @item
  2369. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2370. ``how-to'' style of recipes for a variety of applications.
  2371. @item
  2372. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2373. Card} lists in two pages most of the commands and options you'll ever
  2374. need.
  2375. @item
  2376. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2377. instructional videos} covering topics such as everyday use of Guix, how
  2378. to get help, and how to become a contributor.
  2379. @item
  2380. @xref{Documentation}, to learn how to access documentation on your
  2381. computer.
  2382. @end itemize
  2383. We hope you will enjoy Guix as much as the community enjoys building it!
  2384. @end quotation
  2385. @c *********************************************************************
  2386. @node Package Management
  2387. @chapter Package Management
  2388. @cindex packages
  2389. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2390. remove software packages, without having to know about their build
  2391. procedures or dependencies. Guix also goes beyond this obvious set of
  2392. features.
  2393. This chapter describes the main features of Guix, as well as the
  2394. package management tools it provides. Along with the command-line
  2395. interface described below (@pxref{Invoking guix package, @code{guix
  2396. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2397. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2398. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2399. with it):
  2400. @example
  2401. guix install emacs-guix
  2402. @end example
  2403. @menu
  2404. * Features:: How Guix will make your life brighter.
  2405. * Invoking guix package:: Package installation, removal, etc.
  2406. * Substitutes:: Downloading pre-built binaries.
  2407. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2408. * Invoking guix gc:: Running the garbage collector.
  2409. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2410. * Invoking guix time-machine:: Running an older revision of Guix.
  2411. * Inferiors:: Interacting with another revision of Guix.
  2412. * Invoking guix describe:: Display information about your Guix revision.
  2413. * Invoking guix archive:: Exporting and importing store files.
  2414. @end menu
  2415. @node Features
  2416. @section Features
  2417. Here we assume you've already made your first steps with Guix
  2418. (@pxref{Getting Started}) and would like to get an overview about what's
  2419. going on under the hood.
  2420. When using Guix, each package ends up in the @dfn{package store}, in its
  2421. own directory---something that resembles
  2422. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2423. Instead of referring to these directories, users have their own
  2424. @dfn{profile}, which points to the packages that they actually want to
  2425. use. These profiles are stored within each user's home directory, at
  2426. @code{$HOME/.guix-profile}.
  2427. For example, @code{alice} installs GCC 4.7.2. As a result,
  2428. @file{/home/alice/.guix-profile/bin/gcc} points to
  2429. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2430. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2431. simply continues to point to
  2432. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2433. coexist on the same system without any interference.
  2434. The @command{guix package} command is the central tool to manage
  2435. packages (@pxref{Invoking guix package}). It operates on the per-user
  2436. profiles, and can be used @emph{with normal user privileges}.
  2437. @cindex transactions
  2438. The command provides the obvious install, remove, and upgrade
  2439. operations. Each invocation is actually a @emph{transaction}: either
  2440. the specified operation succeeds, or nothing happens. Thus, if the
  2441. @command{guix package} process is terminated during the transaction,
  2442. or if a power outage occurs during the transaction, then the user's
  2443. profile remains in its previous state, and remains usable.
  2444. In addition, any package transaction may be @emph{rolled back}. So, if,
  2445. for example, an upgrade installs a new version of a package that turns
  2446. out to have a serious bug, users may roll back to the previous instance
  2447. of their profile, which was known to work well. Similarly, the global
  2448. system configuration on Guix is subject to
  2449. transactional upgrades and roll-back
  2450. (@pxref{Using the Configuration System}).
  2451. All packages in the package store may be @emph{garbage-collected}.
  2452. Guix can determine which packages are still referenced by user
  2453. profiles, and remove those that are provably no longer referenced
  2454. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2455. generations of their profile so that the packages they refer to can be
  2456. collected.
  2457. @cindex reproducibility
  2458. @cindex reproducible builds
  2459. Guix takes a @dfn{purely functional} approach to package
  2460. management, as described in the introduction (@pxref{Introduction}).
  2461. Each @file{/gnu/store} package directory name contains a hash of all the
  2462. inputs that were used to build that package---compiler, libraries, build
  2463. scripts, etc. This direct correspondence allows users to make sure a
  2464. given package installation matches the current state of their
  2465. distribution. It also helps maximize @dfn{build reproducibility}:
  2466. thanks to the isolated build environments that are used, a given build
  2467. is likely to yield bit-identical files when performed on different
  2468. machines (@pxref{Invoking guix-daemon, container}).
  2469. @cindex substitutes
  2470. This foundation allows Guix to support @dfn{transparent binary/source
  2471. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2472. available from an external source---a @dfn{substitute}, Guix just
  2473. downloads it and unpacks it;
  2474. otherwise, it builds the package from source, locally
  2475. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2476. reproducible, users do not have to trust servers that provide
  2477. substitutes: they can force a local build and @emph{challenge} providers
  2478. (@pxref{Invoking guix challenge}).
  2479. Control over the build environment is a feature that is also useful for
  2480. developers. The @command{guix shell} command allows developers of
  2481. a package to quickly set up the right development environment for their
  2482. package, without having to manually install the dependencies of the
  2483. package into their profile (@pxref{Invoking guix shell}).
  2484. @cindex replication, of software environments
  2485. @cindex provenance tracking, of software artifacts
  2486. All of Guix and its package definitions is version-controlled, and
  2487. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2488. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2489. Guix instance on a different machine or at a later point in time, which in
  2490. turn allows you to @emph{replicate complete software environments}, while
  2491. retaining precise @dfn{provenance tracking} of the software.
  2492. @node Invoking guix package
  2493. @section Invoking @command{guix package}
  2494. @cindex installing packages
  2495. @cindex removing packages
  2496. @cindex package installation
  2497. @cindex package removal
  2498. @cindex profile
  2499. The @command{guix package} command is the tool that allows users to
  2500. install, upgrade, and remove packages, as well as rolling back to
  2501. previous configurations. These operations work on a user
  2502. @dfn{profile}---a directory of installed packages. Each user has a
  2503. default profile in @file{$HOME/.guix-profile}.
  2504. The command operates only on the user's own profile,
  2505. and works with normal user privileges (@pxref{Features}). Its syntax
  2506. is:
  2507. @example
  2508. guix package @var{options}
  2509. @end example
  2510. @cindex transactions
  2511. Primarily, @var{options} specifies the operations to be performed during
  2512. the transaction. Upon completion, a new profile is created, but
  2513. previous @dfn{generations} of the profile remain available, should the user
  2514. want to roll back.
  2515. For example, to remove @code{lua} and install @code{guile} and
  2516. @code{guile-cairo} in a single transaction:
  2517. @example
  2518. guix package -r lua -i guile guile-cairo
  2519. @end example
  2520. @cindex aliases, for @command{guix package}
  2521. For your convenience, we also provide the following aliases:
  2522. @itemize
  2523. @item
  2524. @command{guix search} is an alias for @command{guix package -s},
  2525. @item
  2526. @command{guix install} is an alias for @command{guix package -i},
  2527. @item
  2528. @command{guix remove} is an alias for @command{guix package -r},
  2529. @item
  2530. @command{guix upgrade} is an alias for @command{guix package -u},
  2531. @item
  2532. and @command{guix show} is an alias for @command{guix package --show=}.
  2533. @end itemize
  2534. These aliases are less expressive than @command{guix package} and provide
  2535. fewer options, so in some cases you'll probably want to use @command{guix
  2536. package} directly.
  2537. @command{guix package} also supports a @dfn{declarative approach}
  2538. whereby the user specifies the exact set of packages to be available and
  2539. passes it @i{via} the @option{--manifest} option
  2540. (@pxref{profile-manifest, @option{--manifest}}).
  2541. @cindex profile
  2542. For each user, a symlink to the user's default profile is automatically
  2543. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2544. current generation of the user's default profile. Thus, users can add
  2545. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2546. variable, and so on.
  2547. @cindex search paths
  2548. If you are not using Guix System, consider adding the
  2549. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2550. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2551. shells get all the right environment variable definitions:
  2552. @example
  2553. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2554. source "$GUIX_PROFILE/etc/profile"
  2555. @end example
  2556. In a multi-user setup, user profiles are stored in a place registered as
  2557. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2558. to (@pxref{Invoking guix gc}). That directory is normally
  2559. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2560. @var{localstatedir} is the value passed to @code{configure} as
  2561. @option{--localstatedir}, and @var{user} is the user name. The
  2562. @file{per-user} directory is created when @command{guix-daemon} is
  2563. started, and the @var{user} sub-directory is created by @command{guix
  2564. package}.
  2565. The @var{options} can be among the following:
  2566. @table @code
  2567. @item --install=@var{package} @dots{}
  2568. @itemx -i @var{package} @dots{}
  2569. Install the specified @var{package}s.
  2570. Each @var{package} may specify either a simple package name, such as
  2571. @code{guile}, or a package name followed by an at-sign and version number,
  2572. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2573. case, the newest version prefixed by @code{1.8} is selected).
  2574. If no version number is specified, the
  2575. newest available version will be selected. In addition, @var{package}
  2576. may contain a colon, followed by the name of one of the outputs of the
  2577. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2578. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2579. name (and optionally version) are searched for among the GNU
  2580. distribution modules (@pxref{Package Modules}).
  2581. @cindex propagated inputs
  2582. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2583. that automatically get installed along with the required package
  2584. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2585. @code{package} objects}, for information about propagated inputs in
  2586. package definitions).
  2587. @anchor{package-cmd-propagated-inputs}
  2588. An example is the GNU MPC library: its C header files refer to those of
  2589. the GNU MPFR library, which in turn refer to those of the GMP library.
  2590. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2591. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2592. also been explicitly installed by the user.
  2593. Besides, packages sometimes rely on the definition of environment
  2594. variables for their search paths (see explanation of
  2595. @option{--search-paths} below). Any missing or possibly incorrect
  2596. environment variable definitions are reported here.
  2597. @item --install-from-expression=@var{exp}
  2598. @itemx -e @var{exp}
  2599. Install the package @var{exp} evaluates to.
  2600. @var{exp} must be a Scheme expression that evaluates to a
  2601. @code{<package>} object. This option is notably useful to disambiguate
  2602. between same-named variants of a package, with expressions such as
  2603. @code{(@@ (gnu packages base) guile-final)}.
  2604. Note that this option installs the first output of the specified
  2605. package, which may be insufficient when needing a specific output of a
  2606. multiple-output package.
  2607. @item --install-from-file=@var{file}
  2608. @itemx -f @var{file}
  2609. Install the package that the code within @var{file} evaluates to.
  2610. As an example, @var{file} might contain a definition like this
  2611. (@pxref{Defining Packages}):
  2612. @lisp
  2613. @include package-hello.scm
  2614. @end lisp
  2615. Developers may find it useful to include such a @file{guix.scm} file
  2616. in the root of their project source tree that can be used to test
  2617. development snapshots and create reproducible development environments
  2618. (@pxref{Invoking guix shell}).
  2619. The @var{file} may also contain a JSON representation of one or more
  2620. package definitions. Running @code{guix package -f} on
  2621. @file{hello.json} with the following contents would result in installing
  2622. the package @code{greeter} after building @code{myhello}:
  2623. @example
  2624. @verbatiminclude package-hello.json
  2625. @end example
  2626. @item --remove=@var{package} @dots{}
  2627. @itemx -r @var{package} @dots{}
  2628. Remove the specified @var{package}s.
  2629. As for @option{--install}, each @var{package} may specify a version number
  2630. and/or output name in addition to the package name. For instance,
  2631. @samp{-r glibc:debug} would remove the @code{debug} output of
  2632. @code{glibc}.
  2633. @item --upgrade[=@var{regexp} @dots{}]
  2634. @itemx -u [@var{regexp} @dots{}]
  2635. @cindex upgrading packages
  2636. Upgrade all the installed packages. If one or more @var{regexp}s are
  2637. specified, upgrade only installed packages whose name matches a
  2638. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2639. Note that this upgrades package to the latest version of packages found
  2640. in the distribution currently installed. To update your distribution,
  2641. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2642. pull}).
  2643. @cindex package transformations, upgrades
  2644. When upgrading, package transformations that were originally applied
  2645. when creating the profile are automatically re-applied (@pxref{Package
  2646. Transformation Options}). For example, assume you first installed Emacs
  2647. from the tip of its development branch with:
  2648. @example
  2649. guix install emacs-next --with-branch=emacs-next=master
  2650. @end example
  2651. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2652. of the Emacs development branch and build @code{emacs-next} from that
  2653. checkout.
  2654. Note that transformation options such as @option{--with-branch} and
  2655. @option{--with-source} depend on external state; it is up to you to
  2656. ensure that they work as expected. You can also discard a
  2657. transformations that apply to a package by running:
  2658. @example
  2659. guix install @var{package}
  2660. @end example
  2661. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2662. When used together with the @option{--upgrade} option, do @emph{not}
  2663. upgrade any packages whose name matches a @var{regexp}. For example, to
  2664. upgrade all packages in the current profile except those containing the
  2665. substring ``emacs'':
  2666. @example
  2667. $ guix package --upgrade . --do-not-upgrade emacs
  2668. @end example
  2669. @item @anchor{profile-manifest}--manifest=@var{file}
  2670. @itemx -m @var{file}
  2671. @cindex profile declaration
  2672. @cindex profile manifest
  2673. Create a new generation of the profile from the manifest object
  2674. returned by the Scheme code in @var{file}. This option can be repeated
  2675. several times, in which case the manifests are concatenated.
  2676. This allows you to @emph{declare} the profile's contents rather than
  2677. constructing it through a sequence of @option{--install} and similar
  2678. commands. The advantage is that @var{file} can be put under version
  2679. control, copied to different machines to reproduce the same profile, and
  2680. so on.
  2681. @c FIXME: Add reference to (guix profile) documentation when available.
  2682. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2683. of packages:
  2684. @findex packages->manifest
  2685. @lisp
  2686. (use-package-modules guile emacs)
  2687. (packages->manifest
  2688. (list emacs
  2689. guile-2.0
  2690. ;; Use a specific package output.
  2691. (list guile-2.0 "debug")))
  2692. @end lisp
  2693. @findex specifications->manifest
  2694. In this example we have to know which modules define the @code{emacs}
  2695. and @code{guile-2.0} variables to provide the right
  2696. @code{use-package-modules} line, which can be cumbersome. We can
  2697. instead provide regular package specifications and let
  2698. @code{specifications->manifest} look up the corresponding package
  2699. objects, like this:
  2700. @lisp
  2701. (specifications->manifest
  2702. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2703. @end lisp
  2704. @findex package->development-manifest
  2705. You might also want to create a manifest for all the dependencies of a
  2706. package, rather than the package itself:
  2707. @lisp
  2708. (package->development-manifest (specification->package "emacs"))
  2709. @end lisp
  2710. The example above gives you all the software required to develop Emacs,
  2711. similar to what @command{guix environment emacs} provides.
  2712. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2713. obtain a manifest file from an existing profile.
  2714. @item --roll-back
  2715. @cindex rolling back
  2716. @cindex undoing transactions
  2717. @cindex transactions, undoing
  2718. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2719. the last transaction.
  2720. When combined with options such as @option{--install}, roll back occurs
  2721. before any other actions.
  2722. When rolling back from the first generation that actually contains
  2723. installed packages, the profile is made to point to the @dfn{zeroth
  2724. generation}, which contains no files apart from its own metadata.
  2725. After having rolled back, installing, removing, or upgrading packages
  2726. overwrites previous future generations. Thus, the history of the
  2727. generations in a profile is always linear.
  2728. @item --switch-generation=@var{pattern}
  2729. @itemx -S @var{pattern}
  2730. @cindex generations
  2731. Switch to a particular generation defined by @var{pattern}.
  2732. @var{pattern} may be either a generation number or a number prefixed
  2733. with ``+'' or ``-''. The latter means: move forward/backward by a
  2734. specified number of generations. For example, if you want to return to
  2735. the latest generation after @option{--roll-back}, use
  2736. @option{--switch-generation=+1}.
  2737. The difference between @option{--roll-back} and
  2738. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2739. not make a zeroth generation, so if a specified generation does not
  2740. exist, the current generation will not be changed.
  2741. @item --search-paths[=@var{kind}]
  2742. @cindex search paths
  2743. Report environment variable definitions, in Bash syntax, that may be
  2744. needed in order to use the set of installed packages. These environment
  2745. variables are used to specify @dfn{search paths} for files used by some
  2746. of the installed packages.
  2747. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2748. environment variables to be defined so it can look for headers and
  2749. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2750. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2751. library are installed in the profile, then @option{--search-paths} will
  2752. suggest setting these variables to @file{@var{profile}/include} and
  2753. @file{@var{profile}/lib}, respectively.
  2754. The typical use case is to define these environment variables in the
  2755. shell:
  2756. @example
  2757. $ eval `guix package --search-paths`
  2758. @end example
  2759. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2760. meaning that the returned environment variable definitions will either
  2761. be exact settings, or prefixes or suffixes of the current value of these
  2762. variables. When omitted, @var{kind} defaults to @code{exact}.
  2763. This option can also be used to compute the @emph{combined} search paths
  2764. of several profiles. Consider this example:
  2765. @example
  2766. $ guix package -p foo -i guile
  2767. $ guix package -p bar -i guile-json
  2768. $ guix package -p foo -p bar --search-paths
  2769. @end example
  2770. The last command above reports about the @env{GUILE_LOAD_PATH}
  2771. variable, even though, taken individually, neither @file{foo} nor
  2772. @file{bar} would lead to that recommendation.
  2773. @cindex profile, choosing
  2774. @item --profile=@var{profile}
  2775. @itemx -p @var{profile}
  2776. Use @var{profile} instead of the user's default profile.
  2777. @var{profile} must be the name of a file that will be created upon
  2778. completion. Concretely, @var{profile} will be a mere symbolic link
  2779. (``symlink'') pointing to the actual profile where packages are
  2780. installed:
  2781. @example
  2782. $ guix install hello -p ~/code/my-profile
  2783. @dots{}
  2784. $ ~/code/my-profile/bin/hello
  2785. Hello, world!
  2786. @end example
  2787. All it takes to get rid of the profile is to remove this symlink and its
  2788. siblings that point to specific generations:
  2789. @example
  2790. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2791. @end example
  2792. @item --list-profiles
  2793. List all the user's profiles:
  2794. @example
  2795. $ guix package --list-profiles
  2796. /home/charlie/.guix-profile
  2797. /home/charlie/code/my-profile
  2798. /home/charlie/code/devel-profile
  2799. /home/charlie/tmp/test
  2800. @end example
  2801. When running as root, list all the profiles of all the users.
  2802. @cindex collisions, in a profile
  2803. @cindex colliding packages in profiles
  2804. @cindex profile collisions
  2805. @item --allow-collisions
  2806. Allow colliding packages in the new profile. Use at your own risk!
  2807. By default, @command{guix package} reports as an error @dfn{collisions}
  2808. in the profile. Collisions happen when two or more different versions
  2809. or variants of a given package end up in the profile.
  2810. @item --bootstrap
  2811. Use the bootstrap Guile to build the profile. This option is only
  2812. useful to distribution developers.
  2813. @end table
  2814. In addition to these actions, @command{guix package} supports the
  2815. following options to query the current state of a profile, or the
  2816. availability of packages:
  2817. @table @option
  2818. @item --search=@var{regexp}
  2819. @itemx -s @var{regexp}
  2820. @anchor{guix-search}
  2821. @cindex searching for packages
  2822. List the available packages whose name, synopsis, or description matches
  2823. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2824. Print all the metadata of matching packages in
  2825. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2826. GNU recutils manual}).
  2827. This allows specific fields to be extracted using the @command{recsel}
  2828. command, for instance:
  2829. @example
  2830. $ guix package -s malloc | recsel -p name,version,relevance
  2831. name: jemalloc
  2832. version: 4.5.0
  2833. relevance: 6
  2834. name: glibc
  2835. version: 2.25
  2836. relevance: 1
  2837. name: libgc
  2838. version: 7.6.0
  2839. relevance: 1
  2840. @end example
  2841. Similarly, to show the name of all the packages available under the
  2842. terms of the GNU@tie{}LGPL version 3:
  2843. @example
  2844. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2845. name: elfutils
  2846. name: gmp
  2847. @dots{}
  2848. @end example
  2849. It is also possible to refine search results using several @code{-s} flags to
  2850. @command{guix package}, or several arguments to @command{guix search}. For
  2851. example, the following command returns a list of board games (this time using
  2852. the @command{guix search} alias):
  2853. @example
  2854. $ guix search '\<board\>' game | recsel -p name
  2855. name: gnubg
  2856. @dots{}
  2857. @end example
  2858. If we were to omit @code{-s game}, we would also get software packages
  2859. that deal with printed circuit boards; removing the angle brackets
  2860. around @code{board} would further add packages that have to do with
  2861. keyboards.
  2862. And now for a more elaborate example. The following command searches
  2863. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2864. libraries, and prints the name and synopsis of the matching packages:
  2865. @example
  2866. $ guix search crypto library | \
  2867. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2868. @end example
  2869. @noindent
  2870. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2871. information on @dfn{selection expressions} for @code{recsel -e}.
  2872. @item --show=@var{package}
  2873. Show details about @var{package}, taken from the list of available packages, in
  2874. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2875. recutils manual}).
  2876. @example
  2877. $ guix package --show=guile | recsel -p name,version
  2878. name: guile
  2879. version: 3.0.5
  2880. name: guile
  2881. version: 3.0.2
  2882. name: guile
  2883. version: 2.2.7
  2884. @dots{}
  2885. @end example
  2886. You may also specify the full name of a package to only get details about a
  2887. specific version of it (this time using the @command{guix show} alias):
  2888. @example
  2889. $ guix show guile@@3.0.5 | recsel -p name,version
  2890. name: guile
  2891. version: 3.0.5
  2892. @end example
  2893. @item --list-installed[=@var{regexp}]
  2894. @itemx -I [@var{regexp}]
  2895. List the currently installed packages in the specified profile, with the
  2896. most recently installed packages shown last. When @var{regexp} is
  2897. specified, list only installed packages whose name matches @var{regexp}.
  2898. For each installed package, print the following items, separated by
  2899. tabs: the package name, its version string, the part of the package that
  2900. is installed (for instance, @code{out} for the default output,
  2901. @code{include} for its headers, etc.), and the path of this package in
  2902. the store.
  2903. @item --list-available[=@var{regexp}]
  2904. @itemx -A [@var{regexp}]
  2905. List packages currently available in the distribution for this system
  2906. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2907. available packages whose name matches @var{regexp}.
  2908. For each package, print the following items separated by tabs: its name,
  2909. its version string, the parts of the package (@pxref{Packages with
  2910. Multiple Outputs}), and the source location of its definition.
  2911. @item --list-generations[=@var{pattern}]
  2912. @itemx -l [@var{pattern}]
  2913. @cindex generations
  2914. Return a list of generations along with their creation dates; for each
  2915. generation, show the installed packages, with the most recently
  2916. installed packages shown last. Note that the zeroth generation is never
  2917. shown.
  2918. For each installed package, print the following items, separated by
  2919. tabs: the name of a package, its version string, the part of the package
  2920. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2921. location of this package in the store.
  2922. When @var{pattern} is used, the command returns only matching
  2923. generations. Valid patterns include:
  2924. @itemize
  2925. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2926. generation numbers. For instance, @option{--list-generations=1} returns
  2927. the first one.
  2928. And @option{--list-generations=1,8,2} outputs three generations in the
  2929. specified order. Neither spaces nor trailing commas are allowed.
  2930. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2931. specified generations and everything in between. Note that the start of
  2932. a range must be smaller than its end.
  2933. It is also possible to omit the endpoint. For example,
  2934. @option{--list-generations=2..}, returns all generations starting from the
  2935. second one.
  2936. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2937. or months by passing an integer along with the first letter of the
  2938. duration. For example, @option{--list-generations=20d} lists generations
  2939. that are up to 20 days old.
  2940. @end itemize
  2941. @item --delete-generations[=@var{pattern}]
  2942. @itemx -d [@var{pattern}]
  2943. When @var{pattern} is omitted, delete all generations except the current
  2944. one.
  2945. This command accepts the same patterns as @option{--list-generations}.
  2946. When @var{pattern} is specified, delete the matching generations. When
  2947. @var{pattern} specifies a duration, generations @emph{older} than the
  2948. specified duration match. For instance, @option{--delete-generations=1m}
  2949. deletes generations that are more than one month old.
  2950. If the current generation matches, it is @emph{not} deleted. Also, the
  2951. zeroth generation is never deleted.
  2952. Note that deleting generations prevents rolling back to them.
  2953. Consequently, this command must be used with care.
  2954. @cindex manifest, exporting
  2955. @anchor{export-manifest}
  2956. @item --export-manifest
  2957. Write to standard output a manifest suitable for @option{--manifest}
  2958. corresponding to the chosen profile(s).
  2959. This option is meant to help you migrate from the ``imperative''
  2960. operating mode---running @command{guix install}, @command{guix upgrade},
  2961. etc.---to the declarative mode that @option{--manifest} offers.
  2962. Be aware that the resulting manifest @emph{approximates} what your
  2963. profile actually contains; for instance, depending on how your profile
  2964. was created, it can refer to packages or package versions that are not
  2965. exactly what you specified.
  2966. Keep in mind that a manifest is purely symbolic: it only contains
  2967. package names and possibly versions, and their meaning varies over time.
  2968. If you wish to ``pin'' channels to the revisions that were used to build
  2969. the profile(s), see @option{--export-channels} below.
  2970. @cindex pinning, channel revisions of a profile
  2971. @item --export-channels
  2972. Write to standard output the list of channels used by the chosen
  2973. profile(s), in a format suitable for @command{guix pull --channels} or
  2974. @command{guix time-machine --channels} (@pxref{Channels}).
  2975. Together with @option{--export-manifest}, this option provides
  2976. information allowing you to replicate the current profile
  2977. (@pxref{Replicating Guix}).
  2978. However, note that the output of this command @emph{approximates} what
  2979. was actually used to build this profile. In particular, a single
  2980. profile might have been built from several different revisions of the
  2981. same channel. In that case, @option{--export-manifest} chooses the last
  2982. one and writes the list of other revisions in a comment. If you really
  2983. need to pick packages from different channel revisions, you can use
  2984. inferiors in your manifest to do so (@pxref{Inferiors}).
  2985. Together with @option{--export-manifest}, this is a good starting point
  2986. if you are willing to migrate from the ``imperative'' model to the fully
  2987. declarative model consisting of a manifest file along with a channels
  2988. file pinning the exact channel revision(s) you want.
  2989. @end table
  2990. Finally, since @command{guix package} may actually start build
  2991. processes, it supports all the common build options (@pxref{Common Build
  2992. Options}). It also supports package transformation options, such as
  2993. @option{--with-source}, and preserves them across upgrades
  2994. (@pxref{Package Transformation Options}).
  2995. @node Substitutes
  2996. @section Substitutes
  2997. @cindex substitutes
  2998. @cindex pre-built binaries
  2999. Guix supports transparent source/binary deployment, which means that it
  3000. can either build things locally, or download pre-built items from a
  3001. server, or both. We call these pre-built items @dfn{substitutes}---they
  3002. are substitutes for local build results. In many cases, downloading a
  3003. substitute is much faster than building things locally.
  3004. Substitutes can be anything resulting from a derivation build
  3005. (@pxref{Derivations}). Of course, in the common case, they are
  3006. pre-built package binaries, but source tarballs, for instance, which
  3007. also result from derivation builds, can be available as substitutes.
  3008. @menu
  3009. * Official Substitute Servers:: One particular source of substitutes.
  3010. * Substitute Server Authorization:: How to enable or disable substitutes.
  3011. * Getting Substitutes from Other Servers:: Substitute diversity.
  3012. * Substitute Authentication:: How Guix verifies substitutes.
  3013. * Proxy Settings:: How to get substitutes via proxy.
  3014. * Substitution Failure:: What happens when substitution fails.
  3015. * On Trusting Binaries:: How can you trust that binary blob?
  3016. @end menu
  3017. @node Official Substitute Servers
  3018. @subsection Official Substitute Servers
  3019. @cindex build farm
  3020. @code{@value{SUBSTITUTE-SERVER-1}} and
  3021. @code{@value{SUBSTITUTE-SERVER-2}} are both front-ends to official build
  3022. farms that build packages from Guix continuously for some architectures,
  3023. and make them available as substitutes. These are the default source of
  3024. substitutes; which can be overridden by passing the
  3025. @option{--substitute-urls} option either to @command{guix-daemon}
  3026. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  3027. or to client tools such as @command{guix package}
  3028. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  3029. option}).
  3030. Substitute URLs can be either HTTP or HTTPS.
  3031. HTTPS is recommended because communications are encrypted; conversely,
  3032. using HTTP makes all communications visible to an eavesdropper, who
  3033. could use the information gathered to determine, for instance, whether
  3034. your system has unpatched security vulnerabilities.
  3035. Substitutes from the official build farms are enabled by default when
  3036. using Guix System (@pxref{GNU Distribution}). However,
  3037. they are disabled by default when using Guix on a foreign distribution,
  3038. unless you have explicitly enabled them via one of the recommended
  3039. installation steps (@pxref{Installation}). The following paragraphs
  3040. describe how to enable or disable substitutes for the official build
  3041. farm; the same procedure can also be used to enable substitutes for any
  3042. other substitute server.
  3043. @node Substitute Server Authorization
  3044. @subsection Substitute Server Authorization
  3045. @cindex security
  3046. @cindex substitutes, authorization thereof
  3047. @cindex access control list (ACL), for substitutes
  3048. @cindex ACL (access control list), for substitutes
  3049. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER-1}}, @code{@value{SUBSTITUTE-SERVER-2}} or a mirror, you
  3050. must add the relevant public key to the access control list (ACL) of archive
  3051. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3052. archive}). Doing so implies that you trust the substitute server to not
  3053. be compromised and to serve genuine substitutes.
  3054. @quotation Note
  3055. If you are using Guix System, you can skip this section: Guix System
  3056. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER-1}} and
  3057. @code{@value{SUBSTITUTE-SERVER-2}} by default.
  3058. @end quotation
  3059. The public keys for each of the project maintained substitute servers
  3060. are installed along with Guix, in @code{@var{prefix}/share/guix/}, where
  3061. @var{prefix} is the installation prefix of Guix. If you installed Guix
  3062. from source, make sure you checked the GPG signature of
  3063. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3064. Then, you can run something like this:
  3065. @example
  3066. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  3067. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  3068. @end example
  3069. Once this is in place, the output of a command like @code{guix build}
  3070. should change from something like:
  3071. @example
  3072. $ guix build emacs --dry-run
  3073. The following derivations would be built:
  3074. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3075. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3076. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3077. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3078. @dots{}
  3079. @end example
  3080. @noindent
  3081. to something like:
  3082. @example
  3083. $ guix build emacs --dry-run
  3084. 112.3 MB would be downloaded:
  3085. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3086. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3087. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3088. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3089. @dots{}
  3090. @end example
  3091. @noindent
  3092. The text changed from ``The following derivations would be built'' to
  3093. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3094. the configured substitute servers are usable and will be downloaded,
  3095. when possible, for future builds.
  3096. @cindex substitutes, how to disable
  3097. The substitute mechanism can be disabled globally by running
  3098. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3099. guix-daemon}). It can also be disabled temporarily by passing the
  3100. @option{--no-substitutes} option to @command{guix package},
  3101. @command{guix build}, and other command-line tools.
  3102. @node Getting Substitutes from Other Servers
  3103. @subsection Getting Substitutes from Other Servers
  3104. @cindex substitute servers, adding more
  3105. Guix can look up and fetch substitutes from several servers. This is
  3106. useful when you are using packages from additional channels for which
  3107. the official server does not have substitutes but another server
  3108. provides them. Another situation where this is useful is when you would
  3109. prefer to download from your organization's substitute server, resorting
  3110. to the official server only as a fallback or dismissing it altogether.
  3111. You can give Guix a list of substitute server URLs and it will check
  3112. them in the specified order. You also need to explicitly authorize the
  3113. public keys of substitute servers to instruct Guix to accept the
  3114. substitutes they sign.
  3115. On Guix System, this is achieved by modifying the configuration of the
  3116. @code{guix} service. Since the @code{guix} service is part of the
  3117. default lists of services, @code{%base-services} and
  3118. @code{%desktop-services}, you can use @code{modify-services} to change
  3119. its configuration and add the URLs and substitute keys that you want
  3120. (@pxref{Service Reference, @code{modify-services}}).
  3121. As an example, suppose you want to fetch substitutes from
  3122. @code{guix.example.org} and to authorize the signing key of that server,
  3123. in addition to the default @code{@value{SUBSTITUTE-SERVER-1}} and
  3124. @code{@value{SUBSTITUTE-SERVER-2}}. The resulting operating system
  3125. configuration will look something like:
  3126. @lisp
  3127. (operating-system
  3128. ;; @dots{}
  3129. (services
  3130. ;; Assume we're starting from '%desktop-services'. Replace it
  3131. ;; with the list of services you're actually using.
  3132. (modify-services %desktop-services
  3133. (guix-service-type config =>
  3134. (guix-configuration
  3135. (inherit config)
  3136. (substitute-urls
  3137. (append (list "https://guix.example.org")
  3138. %default-substitute-urls))
  3139. (authorized-keys
  3140. (append (list (local-file "./key.pub"))
  3141. %default-authorized-guix-keys)))))))
  3142. @end lisp
  3143. This assumes that the file @file{key.pub} contains the signing key of
  3144. @code{guix.example.org}. With this change in place in your operating
  3145. system configuration file (say @file{/etc/config.scm}), you can
  3146. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3147. changes take effect:
  3148. @example
  3149. $ sudo guix system reconfigure /etc/config.scm
  3150. $ sudo herd restart guix-daemon
  3151. @end example
  3152. If you're running Guix on a ``foreign distro'', you would instead take
  3153. the following steps to get substitutes from additional servers:
  3154. @enumerate
  3155. @item
  3156. Edit the service configuration file for @code{guix-daemon}; when using
  3157. systemd, this is normally
  3158. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3159. @option{--substitute-urls} option on the @command{guix-daemon} command
  3160. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3161. @code{guix-daemon --substitute-urls}}):
  3162. @example
  3163. @dots{} --substitute-urls='https://guix.example.org @value{SUBSTITUTE-URLS}'
  3164. @end example
  3165. @item
  3166. Restart the daemon. For systemd, it goes like this:
  3167. @example
  3168. systemctl daemon-reload
  3169. systemctl restart guix-daemon.service
  3170. @end example
  3171. @item
  3172. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3173. @example
  3174. guix archive --authorize < key.pub
  3175. @end example
  3176. Again this assumes @file{key.pub} contains the public key that
  3177. @code{guix.example.org} uses to sign substitutes.
  3178. @end enumerate
  3179. Now you're all set! Substitutes will be preferably taken from
  3180. @code{https://guix.example.org}, using
  3181. @code{@value{SUBSTITUTE-SERVER-1}} then
  3182. @code{@value{SUBSTITUTE-SERVER-2}} as fallback options. Of course you
  3183. can list as many substitute servers as you like, with the caveat that
  3184. substitute lookup can be slowed down if too many servers need to be
  3185. contacted.
  3186. Note that there are also situations where one may want to add the URL of
  3187. a substitute server @emph{without} authorizing its key.
  3188. @xref{Substitute Authentication}, to understand this fine point.
  3189. @node Substitute Authentication
  3190. @subsection Substitute Authentication
  3191. @cindex digital signatures
  3192. Guix detects and raises an error when attempting to use a substitute
  3193. that has been tampered with. Likewise, it ignores substitutes that are
  3194. not signed, or that are not signed by one of the keys listed in the ACL.
  3195. There is one exception though: if an unauthorized server provides
  3196. substitutes that are @emph{bit-for-bit identical} to those provided by
  3197. an authorized server, then the unauthorized server becomes eligible for
  3198. downloads. For example, assume we have chosen two substitute servers
  3199. with this option:
  3200. @example
  3201. --substitute-urls="https://a.example.org https://b.example.org"
  3202. @end example
  3203. @noindent
  3204. @cindex reproducible builds
  3205. If the ACL contains only the key for @samp{b.example.org}, and if
  3206. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3207. then Guix will download substitutes from @samp{a.example.org} because it
  3208. comes first in the list and can be considered a mirror of
  3209. @samp{b.example.org}. In practice, independent build machines usually
  3210. produce the same binaries, thanks to bit-reproducible builds (see
  3211. below).
  3212. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3213. (in other words, the server is not authenticated), contrary to what
  3214. HTTPS clients such as Web browsers usually do. This is because Guix
  3215. authenticates substitute information itself, as explained above, which
  3216. is what we care about (whereas X.509 certificates are about
  3217. authenticating bindings between domain names and public keys).
  3218. @node Proxy Settings
  3219. @subsection Proxy Settings
  3220. @vindex http_proxy
  3221. @vindex https_proxy
  3222. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3223. @env{https_proxy} environment variables can be set in the environment of
  3224. @command{guix-daemon} and are honored for downloads of substitutes.
  3225. Note that the value of those environment variables in the environment
  3226. where @command{guix build}, @command{guix package}, and other client
  3227. commands are run has @emph{absolutely no effect}.
  3228. @node Substitution Failure
  3229. @subsection Substitution Failure
  3230. Even when a substitute for a derivation is available, sometimes the
  3231. substitution attempt will fail. This can happen for a variety of
  3232. reasons: the substitute server might be offline, the substitute may
  3233. recently have been deleted, the connection might have been interrupted,
  3234. etc.
  3235. When substitutes are enabled and a substitute for a derivation is
  3236. available, but the substitution attempt fails, Guix will attempt to
  3237. build the derivation locally depending on whether or not
  3238. @option{--fallback} was given (@pxref{fallback-option,, common build
  3239. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3240. omitted, then no local build will be performed, and the derivation is
  3241. considered to have failed. However, if @option{--fallback} was given,
  3242. then Guix will attempt to build the derivation locally, and the success
  3243. or failure of the derivation depends on the success or failure of the
  3244. local build. Note that when substitutes are disabled or no substitute
  3245. is available for the derivation in question, a local build will
  3246. @emph{always} be performed, regardless of whether or not
  3247. @option{--fallback} was given.
  3248. To get an idea of how many substitutes are available right now, you can
  3249. try running the @command{guix weather} command (@pxref{Invoking guix
  3250. weather}). This command provides statistics on the substitutes provided
  3251. by a server.
  3252. @node On Trusting Binaries
  3253. @subsection On Trusting Binaries
  3254. @cindex trust, of pre-built binaries
  3255. Today, each individual's control over their own computing is at the
  3256. mercy of institutions, corporations, and groups with enough power and
  3257. determination to subvert the computing infrastructure and exploit its
  3258. weaknesses. While using substitutes can be convenient, we encourage
  3259. users to also build on their own, or even run their own build farm, such
  3260. that the project run substitute servers are less of an interesting
  3261. target. One way to help is by publishing the software you build using
  3262. @command{guix publish} so that others have one more choice of server to
  3263. download substitutes from (@pxref{Invoking guix publish}).
  3264. Guix has the foundations to maximize build reproducibility
  3265. (@pxref{Features}). In most cases, independent builds of a given
  3266. package or derivation should yield bit-identical results. Thus, through
  3267. a diverse set of independent package builds, we can strengthen the
  3268. integrity of our systems. The @command{guix challenge} command aims to
  3269. help users assess substitute servers, and to assist developers in
  3270. finding out about non-deterministic package builds (@pxref{Invoking guix
  3271. challenge}). Similarly, the @option{--check} option of @command{guix
  3272. build} allows users to check whether previously-installed substitutes
  3273. are genuine by rebuilding them locally (@pxref{build-check,
  3274. @command{guix build --check}}).
  3275. In the future, we want Guix to have support to publish and retrieve
  3276. binaries to/from other users, in a peer-to-peer fashion. If you would
  3277. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3278. @node Packages with Multiple Outputs
  3279. @section Packages with Multiple Outputs
  3280. @cindex multiple-output packages
  3281. @cindex package outputs
  3282. @cindex outputs
  3283. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3284. source package leads to exactly one directory in the store. When running
  3285. @command{guix install glibc}, one installs the default output of the
  3286. GNU libc package; the default output is called @code{out}, but its name
  3287. can be omitted as shown in this command. In this particular case, the
  3288. default output of @code{glibc} contains all the C header files, shared
  3289. libraries, static libraries, Info documentation, and other supporting
  3290. files.
  3291. Sometimes it is more appropriate to separate the various types of files
  3292. produced from a single source package into separate outputs. For
  3293. instance, the GLib C library (used by GTK+ and related packages)
  3294. installs more than 20 MiB of reference documentation as HTML pages.
  3295. To save space for users who do not need it, the documentation goes to a
  3296. separate output, called @code{doc}. To install the main GLib output,
  3297. which contains everything but the documentation, one would run:
  3298. @example
  3299. guix install glib
  3300. @end example
  3301. @cindex documentation
  3302. The command to install its documentation is:
  3303. @example
  3304. guix install glib:doc
  3305. @end example
  3306. Some packages install programs with different ``dependency footprints''.
  3307. For instance, the WordNet package installs both command-line tools and
  3308. graphical user interfaces (GUIs). The former depend solely on the C
  3309. library, whereas the latter depend on Tcl/Tk and the underlying X
  3310. libraries. In this case, we leave the command-line tools in the default
  3311. output, whereas the GUIs are in a separate output. This allows users
  3312. who do not need the GUIs to save space. The @command{guix size} command
  3313. can help find out about such situations (@pxref{Invoking guix size}).
  3314. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3315. There are several such multiple-output packages in the GNU distribution.
  3316. Other conventional output names include @code{lib} for libraries and
  3317. possibly header files, @code{bin} for stand-alone programs, and
  3318. @code{debug} for debugging information (@pxref{Installing Debugging
  3319. Files}). The outputs of a packages are listed in the third column of
  3320. the output of @command{guix package --list-available} (@pxref{Invoking
  3321. guix package}).
  3322. @node Invoking guix gc
  3323. @section Invoking @command{guix gc}
  3324. @cindex garbage collector
  3325. @cindex disk space
  3326. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3327. The @command{guix gc} command allows users to explicitly run the garbage
  3328. collector to reclaim space from the @file{/gnu/store} directory. It is
  3329. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3330. files or directories manually may break it beyond repair!
  3331. @cindex GC roots
  3332. @cindex garbage collector roots
  3333. The garbage collector has a set of known @dfn{roots}: any file under
  3334. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3335. cannot be deleted; any other file is considered @dfn{dead} and may be
  3336. deleted. The set of garbage collector roots (``GC roots'' for short)
  3337. includes default user profiles; by default, the symlinks under
  3338. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3339. added with @command{guix build --root}, for example (@pxref{Invoking
  3340. guix build}). The @command{guix gc --list-roots} command lists them.
  3341. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3342. often useful to remove old generations from user profiles; that way, old
  3343. package builds referenced by those generations can be reclaimed. This
  3344. is achieved by running @code{guix package --delete-generations}
  3345. (@pxref{Invoking guix package}).
  3346. Our recommendation is to run a garbage collection periodically, or when
  3347. you are short on disk space. For instance, to guarantee that at least
  3348. 5@tie{}GB are available on your disk, simply run:
  3349. @example
  3350. guix gc -F 5G
  3351. @end example
  3352. It is perfectly safe to run as a non-interactive periodic job
  3353. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3354. Running @command{guix gc} with no arguments will collect as
  3355. much garbage as it can, but that is often inconvenient: you may find
  3356. yourself having to rebuild or re-download software that is ``dead'' from
  3357. the GC viewpoint but that is necessary to build other pieces of
  3358. software---e.g., the compiler tool chain.
  3359. The @command{guix gc} command has three modes of operation: it can be
  3360. used to garbage-collect any dead files (the default), to delete specific
  3361. files (the @option{--delete} option), to print garbage-collector
  3362. information, or for more advanced queries. The garbage collection
  3363. options are as follows:
  3364. @table @code
  3365. @item --collect-garbage[=@var{min}]
  3366. @itemx -C [@var{min}]
  3367. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3368. sub-directories. This is the default operation when no option is
  3369. specified.
  3370. When @var{min} is given, stop once @var{min} bytes have been collected.
  3371. @var{min} may be a number of bytes, or it may include a unit as a
  3372. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3373. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3374. When @var{min} is omitted, collect all the garbage.
  3375. @item --free-space=@var{free}
  3376. @itemx -F @var{free}
  3377. Collect garbage until @var{free} space is available under
  3378. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3379. as @code{500MiB}, as described above.
  3380. When @var{free} or more is already available in @file{/gnu/store}, do
  3381. nothing and exit immediately.
  3382. @item --delete-generations[=@var{duration}]
  3383. @itemx -d [@var{duration}]
  3384. Before starting the garbage collection process, delete all the generations
  3385. older than @var{duration}, for all the user profiles; when run as root, this
  3386. applies to all the profiles @emph{of all the users}.
  3387. For example, this command deletes all the generations of all your profiles
  3388. that are older than 2 months (except generations that are current), and then
  3389. proceeds to free space until at least 10 GiB are available:
  3390. @example
  3391. guix gc -d 2m -F 10G
  3392. @end example
  3393. @item --delete
  3394. @itemx -D
  3395. Attempt to delete all the store files and directories specified as
  3396. arguments. This fails if some of the files are not in the store, or if
  3397. they are still live.
  3398. @item --list-failures
  3399. List store items corresponding to cached build failures.
  3400. This prints nothing unless the daemon was started with
  3401. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3402. @option{--cache-failures}}).
  3403. @item --list-roots
  3404. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3405. roots.
  3406. @item --list-busy
  3407. List store items in use by currently running processes. These store
  3408. items are effectively considered GC roots: they cannot be deleted.
  3409. @item --clear-failures
  3410. Remove the specified store items from the failed-build cache.
  3411. Again, this option only makes sense when the daemon is started with
  3412. @option{--cache-failures}. Otherwise, it does nothing.
  3413. @item --list-dead
  3414. Show the list of dead files and directories still present in the
  3415. store---i.e., files and directories no longer reachable from any root.
  3416. @item --list-live
  3417. Show the list of live store files and directories.
  3418. @end table
  3419. In addition, the references among existing store files can be queried:
  3420. @table @code
  3421. @item --references
  3422. @itemx --referrers
  3423. @cindex package dependencies
  3424. List the references (respectively, the referrers) of store files given
  3425. as arguments.
  3426. @item --requisites
  3427. @itemx -R
  3428. @cindex closure
  3429. List the requisites of the store files passed as arguments. Requisites
  3430. include the store files themselves, their references, and the references
  3431. of these, recursively. In other words, the returned list is the
  3432. @dfn{transitive closure} of the store files.
  3433. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3434. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3435. the graph of references.
  3436. @item --derivers
  3437. @cindex derivation
  3438. Return the derivation(s) leading to the given store items
  3439. (@pxref{Derivations}).
  3440. For example, this command:
  3441. @example
  3442. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3443. @end example
  3444. @noindent
  3445. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3446. installed in your profile.
  3447. Note that there may be zero matching @file{.drv} files, for instance
  3448. because these files have been garbage-collected. There can also be more
  3449. than one matching @file{.drv} due to fixed-output derivations.
  3450. @end table
  3451. Lastly, the following options allow you to check the integrity of the
  3452. store and to control disk usage.
  3453. @table @option
  3454. @item --verify[=@var{options}]
  3455. @cindex integrity, of the store
  3456. @cindex integrity checking
  3457. Verify the integrity of the store.
  3458. By default, make sure that all the store items marked as valid in the
  3459. database of the daemon actually exist in @file{/gnu/store}.
  3460. When provided, @var{options} must be a comma-separated list containing one
  3461. or more of @code{contents} and @code{repair}.
  3462. When passing @option{--verify=contents}, the daemon computes the
  3463. content hash of each store item and compares it against its hash in the
  3464. database. Hash mismatches are reported as data corruptions. Because it
  3465. traverses @emph{all the files in the store}, this command can take a
  3466. long time, especially on systems with a slow disk drive.
  3467. @cindex repairing the store
  3468. @cindex corruption, recovering from
  3469. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3470. causes the daemon to try to repair corrupt store items by fetching
  3471. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3472. atomic, and thus potentially dangerous, it is available only to the
  3473. system administrator. A lightweight alternative, when you know exactly
  3474. which items in the store are corrupt, is @command{guix build --repair}
  3475. (@pxref{Invoking guix build}).
  3476. @item --optimize
  3477. @cindex deduplication
  3478. Optimize the store by hard-linking identical files---this is
  3479. @dfn{deduplication}.
  3480. The daemon performs deduplication after each successful build or archive
  3481. import, unless it was started with @option{--disable-deduplication}
  3482. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3483. this option is primarily useful when the daemon was running with
  3484. @option{--disable-deduplication}.
  3485. @end table
  3486. @node Invoking guix pull
  3487. @section Invoking @command{guix pull}
  3488. @cindex upgrading Guix
  3489. @cindex updating Guix
  3490. @cindex @command{guix pull}
  3491. @cindex pull
  3492. @cindex security, @command{guix pull}
  3493. @cindex authenticity, of code obtained with @command{guix pull}
  3494. Packages are installed or upgraded to the latest version available in
  3495. the distribution currently available on your local machine. To update
  3496. that distribution, along with the Guix tools, you must run @command{guix
  3497. pull}: the command downloads the latest Guix source code and package
  3498. descriptions, and deploys it. Source code is downloaded from a
  3499. @uref{https://git-scm.com, Git} repository, by default the official
  3500. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3501. pull} ensures that the code it downloads is @emph{authentic} by
  3502. verifying that commits are signed by Guix developers.
  3503. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3504. (@pxref{Channels}) specified by one of the followings, in this order:
  3505. @enumerate
  3506. @item
  3507. the @option{--channels} option;
  3508. @item
  3509. the user's @file{~/.config/guix/channels.scm} file;
  3510. @item
  3511. the system-wide @file{/etc/guix/channels.scm} file;
  3512. @item
  3513. the built-in default channels specified in the @code{%default-channels}
  3514. variable.
  3515. @end enumerate
  3516. On completion, @command{guix package} will use packages and package
  3517. versions from this just-retrieved copy of Guix. Not only that, but all
  3518. the Guix commands and Scheme modules will also be taken from that latest
  3519. version. New @command{guix} sub-commands added by the update also
  3520. become available.
  3521. Any user can update their Guix copy using @command{guix pull}, and the
  3522. effect is limited to the user who ran @command{guix pull}. For
  3523. instance, when user @code{root} runs @command{guix pull}, this has no
  3524. effect on the version of Guix that user @code{alice} sees, and vice
  3525. versa.
  3526. The result of running @command{guix pull} is a @dfn{profile} available
  3527. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3528. make sure to add it to the beginning of your search path so that you use
  3529. the latest version, and similarly for the Info manual
  3530. (@pxref{Documentation}):
  3531. @example
  3532. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3533. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3534. @end example
  3535. The @option{--list-generations} or @option{-l} option lists past generations
  3536. produced by @command{guix pull}, along with details about their provenance:
  3537. @example
  3538. $ guix pull -l
  3539. Generation 1 Jun 10 2018 00:18:18
  3540. guix 65956ad
  3541. repository URL: https://git.savannah.gnu.org/git/guix.git
  3542. branch: origin/master
  3543. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3544. Generation 2 Jun 11 2018 11:02:49
  3545. guix e0cc7f6
  3546. repository URL: https://git.savannah.gnu.org/git/guix.git
  3547. branch: origin/master
  3548. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3549. 2 new packages: keepalived, libnfnetlink
  3550. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3551. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3552. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3553. Generation 3 Jun 13 2018 23:31:07 (current)
  3554. guix 844cc1c
  3555. repository URL: https://git.savannah.gnu.org/git/guix.git
  3556. branch: origin/master
  3557. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3558. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3559. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3560. @end example
  3561. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3562. describe the current status of Guix.
  3563. This @code{~/.config/guix/current} profile works exactly like the profiles
  3564. created by @command{guix package} (@pxref{Invoking guix package}). That
  3565. is, you can list generations, roll back to the previous
  3566. generation---i.e., the previous Guix---and so on:
  3567. @example
  3568. $ guix pull --roll-back
  3569. switched from generation 3 to 2
  3570. $ guix pull --delete-generations=1
  3571. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3572. @end example
  3573. You can also use @command{guix package} (@pxref{Invoking guix package})
  3574. to manage the profile by naming it explicitly:
  3575. @example
  3576. $ guix package -p ~/.config/guix/current --roll-back
  3577. switched from generation 3 to 2
  3578. $ guix package -p ~/.config/guix/current --delete-generations=1
  3579. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3580. @end example
  3581. The @command{guix pull} command is usually invoked with no arguments,
  3582. but it supports the following options:
  3583. @table @code
  3584. @item --url=@var{url}
  3585. @itemx --commit=@var{commit}
  3586. @itemx --branch=@var{branch}
  3587. Download code for the @code{guix} channel from the specified @var{url}, at the
  3588. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3589. string), or @var{branch}.
  3590. @cindex @file{channels.scm}, configuration file
  3591. @cindex configuration file for channels
  3592. These options are provided for convenience, but you can also specify your
  3593. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3594. @option{--channels} option (see below).
  3595. @item --channels=@var{file}
  3596. @itemx -C @var{file}
  3597. Read the list of channels from @var{file} instead of
  3598. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3599. @var{file} must contain Scheme code that
  3600. evaluates to a list of channel objects. @xref{Channels}, for more
  3601. information.
  3602. @cindex channel news
  3603. @item --news
  3604. @itemx -N
  3605. Display the list of packages added or upgraded since the previous
  3606. generation, as well as, occasionally, news written by channel authors
  3607. for their users (@pxref{Channels, Writing Channel News}).
  3608. The package information is the same as displayed upon @command{guix
  3609. pull} completion, but without ellipses; it is also similar to the output
  3610. of @command{guix pull -l} for the last generation (see below).
  3611. @item --list-generations[=@var{pattern}]
  3612. @itemx -l [@var{pattern}]
  3613. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3614. is provided, the subset of generations that match @var{pattern}.
  3615. The syntax of @var{pattern} is the same as with @code{guix package
  3616. --list-generations} (@pxref{Invoking guix package}).
  3617. @item --roll-back
  3618. @cindex rolling back
  3619. @cindex undoing transactions
  3620. @cindex transactions, undoing
  3621. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3622. undo the last transaction.
  3623. @item --switch-generation=@var{pattern}
  3624. @itemx -S @var{pattern}
  3625. @cindex generations
  3626. Switch to a particular generation defined by @var{pattern}.
  3627. @var{pattern} may be either a generation number or a number prefixed
  3628. with ``+'' or ``-''. The latter means: move forward/backward by a
  3629. specified number of generations. For example, if you want to return to
  3630. the latest generation after @option{--roll-back}, use
  3631. @option{--switch-generation=+1}.
  3632. @item --delete-generations[=@var{pattern}]
  3633. @itemx -d [@var{pattern}]
  3634. When @var{pattern} is omitted, delete all generations except the current
  3635. one.
  3636. This command accepts the same patterns as @option{--list-generations}.
  3637. When @var{pattern} is specified, delete the matching generations. When
  3638. @var{pattern} specifies a duration, generations @emph{older} than the
  3639. specified duration match. For instance, @option{--delete-generations=1m}
  3640. deletes generations that are more than one month old.
  3641. If the current generation matches, it is @emph{not} deleted.
  3642. Note that deleting generations prevents rolling back to them.
  3643. Consequently, this command must be used with care.
  3644. @xref{Invoking guix describe}, for a way to display information about the
  3645. current generation only.
  3646. @item --profile=@var{profile}
  3647. @itemx -p @var{profile}
  3648. Use @var{profile} instead of @file{~/.config/guix/current}.
  3649. @item --dry-run
  3650. @itemx -n
  3651. Show which channel commit(s) would be used and what would be built or
  3652. substituted but do not actually do it.
  3653. @item --allow-downgrades
  3654. Allow pulling older or unrelated revisions of channels than those
  3655. currently in use.
  3656. @cindex downgrade attacks, protection against
  3657. By default, @command{guix pull} protects against so-called ``downgrade
  3658. attacks'' whereby the Git repository of a channel would be reset to an
  3659. earlier or unrelated revision of itself, potentially leading you to
  3660. install older, known-vulnerable versions of software packages.
  3661. @quotation Note
  3662. Make sure you understand its security implications before using
  3663. @option{--allow-downgrades}.
  3664. @end quotation
  3665. @item --disable-authentication
  3666. Allow pulling channel code without authenticating it.
  3667. @cindex authentication, of channel code
  3668. By default, @command{guix pull} authenticates code downloaded from
  3669. channels by verifying that its commits are signed by authorized
  3670. developers, and raises an error if this is not the case. This option
  3671. instructs it to not perform any such verification.
  3672. @quotation Note
  3673. Make sure you understand its security implications before using
  3674. @option{--disable-authentication}.
  3675. @end quotation
  3676. @item --system=@var{system}
  3677. @itemx -s @var{system}
  3678. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3679. the system type of the build host.
  3680. @item --bootstrap
  3681. Use the bootstrap Guile to build the latest Guix. This option is only
  3682. useful to Guix developers.
  3683. @end table
  3684. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3685. repository and branch to pull from, as well as @emph{additional} repositories
  3686. containing package modules that should be deployed. @xref{Channels}, for more
  3687. information.
  3688. In addition, @command{guix pull} supports all the common build options
  3689. (@pxref{Common Build Options}).
  3690. @node Invoking guix time-machine
  3691. @section Invoking @command{guix time-machine}
  3692. @cindex @command{guix time-machine}
  3693. @cindex pinning, channels
  3694. @cindex replicating Guix
  3695. @cindex reproducibility, of Guix
  3696. The @command{guix time-machine} command provides access to other
  3697. revisions of Guix, for example to install older versions of packages,
  3698. or to reproduce a computation in an identical environment. The revision
  3699. of Guix to be used is defined by a commit or by a channel
  3700. description file created by @command{guix describe}
  3701. (@pxref{Invoking guix describe}).
  3702. The general syntax is:
  3703. @example
  3704. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3705. @end example
  3706. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3707. @command{guix} command of the specified revision. The @var{options} that define
  3708. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3709. @table @code
  3710. @item --url=@var{url}
  3711. @itemx --commit=@var{commit}
  3712. @itemx --branch=@var{branch}
  3713. Use the @code{guix} channel from the specified @var{url}, at the
  3714. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3715. string), or @var{branch}.
  3716. @item --channels=@var{file}
  3717. @itemx -C @var{file}
  3718. Read the list of channels from @var{file}. @var{file} must contain
  3719. Scheme code that evaluates to a list of channel objects.
  3720. @xref{Channels} for more information.
  3721. @end table
  3722. As for @command{guix pull}, the absence of any options means that the
  3723. latest commit on the master branch will be used. The command
  3724. @example
  3725. guix time-machine -- build hello
  3726. @end example
  3727. will thus build the package @code{hello} as defined in the master branch,
  3728. which is in general a newer revision of Guix than you have installed.
  3729. Time travel works in both directions!
  3730. Note that @command{guix time-machine} can trigger builds of channels and
  3731. their dependencies, and these are controlled by the standard build
  3732. options (@pxref{Common Build Options}).
  3733. @node Inferiors
  3734. @section Inferiors
  3735. @c TODO: Remove this once we're more confident about API stability.
  3736. @quotation Note
  3737. The functionality described here is a ``technology preview'' as of version
  3738. @value{VERSION}. As such, the interface is subject to change.
  3739. @end quotation
  3740. @cindex inferiors
  3741. @cindex composition of Guix revisions
  3742. Sometimes you might need to mix packages from the revision of Guix you're
  3743. currently running with packages available in a different revision of Guix.
  3744. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3745. revisions in arbitrary ways.
  3746. @cindex inferior packages
  3747. Technically, an ``inferior'' is essentially a separate Guix process connected
  3748. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3749. @code{(guix inferior)} module allows you to create inferiors and to
  3750. communicate with them. It also provides a high-level interface to browse and
  3751. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3752. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3753. to interact with a separate revision of Guix. For example, let's assume you
  3754. want to install in your profile the current @code{guile} package, along with
  3755. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3756. because the newer @code{guile-json} has an incompatible API and you want to
  3757. run your code against the old API@. To do that, you could write a manifest for
  3758. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3759. manifest, you would create an inferior for that old Guix revision you care
  3760. about, and you would look up the @code{guile-json} package in the inferior:
  3761. @lisp
  3762. (use-modules (guix inferior) (guix channels)
  3763. (srfi srfi-1)) ;for 'first'
  3764. (define channels
  3765. ;; This is the old revision from which we want to
  3766. ;; extract guile-json.
  3767. (list (channel
  3768. (name 'guix)
  3769. (url "https://git.savannah.gnu.org/git/guix.git")
  3770. (commit
  3771. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3772. (define inferior
  3773. ;; An inferior representing the above revision.
  3774. (inferior-for-channels channels))
  3775. ;; Now create a manifest with the current "guile" package
  3776. ;; and the old "guile-json" package.
  3777. (packages->manifest
  3778. (list (first (lookup-inferior-packages inferior "guile-json"))
  3779. (specification->package "guile")))
  3780. @end lisp
  3781. On its first run, @command{guix package --manifest} might have to build the
  3782. channel you specified before it can create the inferior; subsequent runs will
  3783. be much faster because the Guix revision will be cached.
  3784. The @code{(guix inferior)} module provides the following procedures to open an
  3785. inferior:
  3786. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3787. [#:cache-directory] [#:ttl]
  3788. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3789. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3790. This procedure opens a new connection to the build daemon.
  3791. As a side effect, this procedure may build or substitute binaries for
  3792. @var{channels}, which can take time.
  3793. @end deffn
  3794. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3795. [#:command "bin/guix"]
  3796. Open the inferior Guix in @var{directory}, running
  3797. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3798. the inferior could not be launched.
  3799. @end deffn
  3800. @cindex inferior packages
  3801. The procedures listed below allow you to obtain and manipulate inferior
  3802. packages.
  3803. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3804. Return the list of packages known to @var{inferior}.
  3805. @end deffn
  3806. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3807. [@var{version}]
  3808. Return the sorted list of inferior packages matching @var{name} in
  3809. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3810. return only packages with a version number prefixed by @var{version}.
  3811. @end deffn
  3812. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3813. Return true if @var{obj} is an inferior package.
  3814. @end deffn
  3815. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3816. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3817. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3818. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3819. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3820. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3821. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3822. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3823. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3824. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3825. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3826. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3827. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3828. These procedures are the counterpart of package record accessors
  3829. (@pxref{package Reference}). Most of them work by querying the inferior
  3830. @var{package} comes from, so the inferior must still be live when you call
  3831. these procedures.
  3832. @end deffn
  3833. Inferior packages can be used transparently like any other package or
  3834. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3835. transparently handled by the @code{packages->manifest} procedure, which is
  3836. commonly used in manifests (@pxref{Invoking guix package, the
  3837. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3838. an inferior package pretty much anywhere you would insert a regular package:
  3839. in manifests, in the @code{packages} field of your @code{operating-system}
  3840. declaration, and so on.
  3841. @node Invoking guix describe
  3842. @section Invoking @command{guix describe}
  3843. @cindex reproducibility
  3844. @cindex replicating Guix
  3845. Often you may want to answer questions like: ``Which revision of Guix am I
  3846. using?'' or ``Which channels am I using?'' This is useful information in many
  3847. situations: if you want to @emph{replicate} an environment on a different
  3848. machine or user account, if you want to report a bug or to determine what
  3849. change in the channels you are using caused it, or if you want to record your
  3850. system state for reproducibility purposes. The @command{guix describe}
  3851. command answers these questions.
  3852. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3853. displays the channel(s) that it was built from, including their repository URL
  3854. and commit IDs (@pxref{Channels}):
  3855. @example
  3856. $ guix describe
  3857. Generation 10 Sep 03 2018 17:32:44 (current)
  3858. guix e0fa68c
  3859. repository URL: https://git.savannah.gnu.org/git/guix.git
  3860. branch: master
  3861. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3862. @end example
  3863. If you're familiar with the Git version control system, this is similar in
  3864. spirit to @command{git describe}; the output is also similar to that of
  3865. @command{guix pull --list-generations}, but limited to the current generation
  3866. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3867. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3868. information is all it takes to describe the revision of Guix you're using, and
  3869. also to replicate it.
  3870. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3871. to return a list of channels instead of the human-readable description above:
  3872. @example
  3873. $ guix describe -f channels
  3874. (list (channel
  3875. (name 'guix)
  3876. (url "https://git.savannah.gnu.org/git/guix.git")
  3877. (commit
  3878. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3879. (introduction
  3880. (make-channel-introduction
  3881. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3882. (openpgp-fingerprint
  3883. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3884. @end example
  3885. @noindent
  3886. You can save this to a file and feed it to @command{guix pull -C} on some
  3887. other machine or at a later point in time, which will instantiate @emph{this
  3888. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3889. From there on, since you're able to deploy the same revision of Guix, you can
  3890. just as well @emph{replicate a complete software environment}. We humbly
  3891. think that this is @emph{awesome}, and we hope you'll like it too!
  3892. The details of the options supported by @command{guix describe} are as
  3893. follows:
  3894. @table @code
  3895. @item --format=@var{format}
  3896. @itemx -f @var{format}
  3897. Produce output in the specified @var{format}, one of:
  3898. @table @code
  3899. @item human
  3900. produce human-readable output;
  3901. @item channels
  3902. produce a list of channel specifications that can be passed to @command{guix
  3903. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3904. guix pull});
  3905. @item channels-sans-intro
  3906. like @code{channels}, but omit the @code{introduction} field; use it to
  3907. produce a channel specification suitable for Guix version 1.1.0 or
  3908. earlier---the @code{introduction} field has to do with channel
  3909. authentication (@pxref{Channels, Channel Authentication}) and is not
  3910. supported by these older versions;
  3911. @item json
  3912. @cindex JSON
  3913. produce a list of channel specifications in JSON format;
  3914. @item recutils
  3915. produce a list of channel specifications in Recutils format.
  3916. @end table
  3917. @item --list-formats
  3918. Display available formats for @option{--format} option.
  3919. @item --profile=@var{profile}
  3920. @itemx -p @var{profile}
  3921. Display information about @var{profile}.
  3922. @end table
  3923. @node Invoking guix archive
  3924. @section Invoking @command{guix archive}
  3925. @cindex @command{guix archive}
  3926. @cindex archive
  3927. The @command{guix archive} command allows users to @dfn{export} files
  3928. from the store into a single archive, and to later @dfn{import} them on
  3929. a machine that runs Guix.
  3930. In particular, it allows store files to be transferred from one machine
  3931. to the store on another machine.
  3932. @quotation Note
  3933. If you're looking for a way to produce archives in a format suitable for
  3934. tools other than Guix, @pxref{Invoking guix pack}.
  3935. @end quotation
  3936. @cindex exporting store items
  3937. To export store files as an archive to standard output, run:
  3938. @example
  3939. guix archive --export @var{options} @var{specifications}...
  3940. @end example
  3941. @var{specifications} may be either store file names or package
  3942. specifications, as for @command{guix package} (@pxref{Invoking guix
  3943. package}). For instance, the following command creates an archive
  3944. containing the @code{gui} output of the @code{git} package and the main
  3945. output of @code{emacs}:
  3946. @example
  3947. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3948. @end example
  3949. If the specified packages are not built yet, @command{guix archive}
  3950. automatically builds them. The build process may be controlled with the
  3951. common build options (@pxref{Common Build Options}).
  3952. To transfer the @code{emacs} package to a machine connected over SSH,
  3953. one would run:
  3954. @example
  3955. guix archive --export -r emacs | ssh the-machine guix archive --import
  3956. @end example
  3957. @noindent
  3958. Similarly, a complete user profile may be transferred from one machine
  3959. to another like this:
  3960. @example
  3961. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3962. ssh the-machine guix archive --import
  3963. @end example
  3964. @noindent
  3965. However, note that, in both examples, all of @code{emacs} and the
  3966. profile as well as all of their dependencies are transferred (due to
  3967. @option{-r}), regardless of what is already available in the store on
  3968. the target machine. The @option{--missing} option can help figure out
  3969. which items are missing from the target store. The @command{guix copy}
  3970. command simplifies and optimizes this whole process, so this is probably
  3971. what you should use in this case (@pxref{Invoking guix copy}).
  3972. @cindex nar, archive format
  3973. @cindex normalized archive (nar)
  3974. @cindex nar bundle, archive format
  3975. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3976. format (described below), and the output of @command{guix archive
  3977. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3978. bundle}.
  3979. The nar format is
  3980. comparable in spirit to `tar', but with differences
  3981. that make it more appropriate for our purposes. First, rather than
  3982. recording all Unix metadata for each file, the nar format only mentions
  3983. the file type (regular, directory, or symbolic link); Unix permissions
  3984. and owner/group are dismissed. Second, the order in which directory
  3985. entries are stored always follows the order of file names according to
  3986. the C locale collation order. This makes archive production fully
  3987. deterministic.
  3988. That nar bundle format is essentially the concatenation of zero or more
  3989. nars along with metadata for each store item it contains: its file name,
  3990. references, corresponding derivation, and a digital signature.
  3991. When exporting, the daemon digitally signs the contents of the archive,
  3992. and that digital signature is appended. When importing, the daemon
  3993. verifies the signature and rejects the import in case of an invalid
  3994. signature or if the signing key is not authorized.
  3995. @c FIXME: Add xref to daemon doc about signatures.
  3996. The main options are:
  3997. @table @code
  3998. @item --export
  3999. Export the specified store files or packages (see below). Write the
  4000. resulting archive to the standard output.
  4001. Dependencies are @emph{not} included in the output, unless
  4002. @option{--recursive} is passed.
  4003. @item -r
  4004. @itemx --recursive
  4005. When combined with @option{--export}, this instructs @command{guix archive}
  4006. to include dependencies of the given items in the archive. Thus, the
  4007. resulting archive is self-contained: it contains the closure of the
  4008. exported store items.
  4009. @item --import
  4010. Read an archive from the standard input, and import the files listed
  4011. therein into the store. Abort if the archive has an invalid digital
  4012. signature, or if it is signed by a public key not among the authorized
  4013. keys (see @option{--authorize} below).
  4014. @item --missing
  4015. Read a list of store file names from the standard input, one per line,
  4016. and write on the standard output the subset of these files missing from
  4017. the store.
  4018. @item --generate-key[=@var{parameters}]
  4019. @cindex signing, archives
  4020. Generate a new key pair for the daemon. This is a prerequisite before
  4021. archives can be exported with @option{--export}. This
  4022. operation is usually instantaneous but it can take time if the system's
  4023. entropy pool needs to be refilled. On Guix System,
  4024. @code{guix-service-type} takes care of generating this key pair the
  4025. first boot.
  4026. The generated key pair is typically stored under @file{/etc/guix}, in
  4027. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  4028. key, which must be kept secret). When @var{parameters} is omitted,
  4029. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  4030. versions before 1.6.0, it is a 4096-bit RSA key.
  4031. Alternatively, @var{parameters} can specify
  4032. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  4033. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  4034. Libgcrypt Reference Manual}).
  4035. @item --authorize
  4036. @cindex authorizing, archives
  4037. Authorize imports signed by the public key passed on standard input.
  4038. The public key must be in ``s-expression advanced format''---i.e., the
  4039. same format as the @file{signing-key.pub} file.
  4040. The list of authorized keys is kept in the human-editable file
  4041. @file{/etc/guix/acl}. The file contains
  4042. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  4043. s-expressions''} and is structured as an access-control list in the
  4044. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  4045. (SPKI)}.
  4046. @item --extract=@var{directory}
  4047. @itemx -x @var{directory}
  4048. Read a single-item archive as served by substitute servers
  4049. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4050. low-level operation needed in only very narrow use cases; see below.
  4051. For example, the following command extracts the substitute for Emacs
  4052. served by @code{@value{SUBSTITUTE-SERVER-1}} to @file{/tmp/emacs}:
  4053. @example
  4054. $ wget -O - \
  4055. https://@value{SUBSTITUTE-SERVER-1}/nar/gzip/@dots{}-emacs-24.5 \
  4056. | gunzip | guix archive -x /tmp/emacs
  4057. @end example
  4058. Single-item archives are different from multiple-item archives produced
  4059. by @command{guix archive --export}; they contain a single store item,
  4060. and they do @emph{not} embed a signature. Thus this operation does
  4061. @emph{no} signature verification and its output should be considered
  4062. unsafe.
  4063. The primary purpose of this operation is to facilitate inspection of
  4064. archive contents coming from possibly untrusted substitute servers
  4065. (@pxref{Invoking guix challenge}).
  4066. @item --list
  4067. @itemx -t
  4068. Read a single-item archive as served by substitute servers
  4069. (@pxref{Substitutes}) and print the list of files it contains, as in
  4070. this example:
  4071. @example
  4072. $ wget -O - \
  4073. https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-emacs-26.3 \
  4074. | lzip -d | guix archive -t
  4075. @end example
  4076. @end table
  4077. @c *********************************************************************
  4078. @node Channels
  4079. @chapter Channels
  4080. @cindex channels
  4081. @cindex @file{channels.scm}, configuration file
  4082. @cindex configuration file for channels
  4083. @cindex @command{guix pull}, configuration file
  4084. @cindex configuration of @command{guix pull}
  4085. Guix and its package collection are updated by running @command{guix pull}
  4086. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4087. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4088. customized by defining @dfn{channels} in the
  4089. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4090. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4091. to pull from one or more channels. In other words, channels can be used
  4092. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4093. Guix is able to take into account security concerns and deal with authenticated
  4094. updates.
  4095. @menu
  4096. * Specifying Additional Channels:: Extending the package collection.
  4097. * Using a Custom Guix Channel:: Using a customized Guix.
  4098. * Replicating Guix:: Running the @emph{exact same} Guix.
  4099. * Channel Authentication:: How Guix verifies what it fetches.
  4100. * Channels with Substitutes:: Using channels with available substitutes.
  4101. * Creating a Channel:: How to write your custom channel.
  4102. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4103. * Declaring Channel Dependencies:: How to depend on other channels.
  4104. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4105. * Primary URL:: Distinguishing mirror to original.
  4106. * Writing Channel News:: Communicating information to channel's users.
  4107. @end menu
  4108. @node Specifying Additional Channels
  4109. @section Specifying Additional Channels
  4110. @cindex extending the package collection (channels)
  4111. @cindex variant packages (channels)
  4112. You can specify @emph{additional channels} to pull from. To use a channel, write
  4113. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4114. @emph{in addition} to the default Guix channel(s):
  4115. @vindex %default-channels
  4116. @lisp
  4117. ;; Add variant packages to those Guix provides.
  4118. (cons (channel
  4119. (name 'variant-packages)
  4120. (url "https://example.org/variant-packages.git"))
  4121. %default-channels)
  4122. @end lisp
  4123. @noindent
  4124. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4125. add a channel the list of channels that the variable @code{%default-channels}
  4126. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4127. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4128. but also the package modules from your own repository. The result in
  4129. @file{~/.config/guix/current} is the union of Guix with your own package
  4130. modules:
  4131. @example
  4132. $ guix pull --list-generations
  4133. @dots{}
  4134. Generation 19 Aug 27 2018 16:20:48
  4135. guix d894ab8
  4136. repository URL: https://git.savannah.gnu.org/git/guix.git
  4137. branch: master
  4138. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4139. variant-packages dd3df5e
  4140. repository URL: https://example.org/variant-packages.git
  4141. branch: master
  4142. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4143. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4144. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4145. @end example
  4146. @noindent
  4147. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4148. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4149. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4150. @code{variant-emacs-with-cool-features} might come from
  4151. @code{variant-packages}, while others come from the Guix default channel.
  4152. @node Using a Custom Guix Channel
  4153. @section Using a Custom Guix Channel
  4154. The channel called @code{guix} specifies where Guix itself---its command-line
  4155. tools as well as its package collection---should be downloaded. For instance,
  4156. suppose you want to update from another copy of the Guix repository at
  4157. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4158. write in @code{~/.config/guix/channels.scm} this specification:
  4159. @lisp
  4160. ;; Tell 'guix pull' to use another repo.
  4161. (list (channel
  4162. (name 'guix)
  4163. (url "https://example.org/another-guix.git")
  4164. (branch "super-hacks")))
  4165. @end lisp
  4166. @noindent
  4167. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4168. branch of the repository at @code{example.org}. The authentication concern is
  4169. addressed below ((@pxref{Channel Authentication}).
  4170. @node Replicating Guix
  4171. @section Replicating Guix
  4172. @cindex pinning, channels
  4173. @cindex replicating Guix
  4174. @cindex reproducibility, of Guix
  4175. The @command{guix pull --list-generations} output above shows precisely which
  4176. commits were used to build this instance of Guix. We can thus replicate it,
  4177. say, on another machine, by providing a channel specification in
  4178. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4179. @lisp
  4180. ;; Deploy specific commits of my channels of interest.
  4181. (list (channel
  4182. (name 'guix)
  4183. (url "https://git.savannah.gnu.org/git/guix.git")
  4184. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4185. (channel
  4186. (name 'variant-packages)
  4187. (url "https://example.org/variant-packages.git")
  4188. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4189. @end lisp
  4190. The @command{guix describe --format=channels} command can even generate this
  4191. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4192. file can be used with the -C options of @command{guix pull}
  4193. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4194. (@pxref{Invoking guix time-machine}).
  4195. At this point the two machines run the @emph{exact same Guix}, with access to
  4196. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4197. one machine will be exactly the same, bit for bit, as the output of the same
  4198. command on the other machine. It also means both machines have access to all
  4199. the source code of Guix and, transitively, to all the source code of every
  4200. package it defines.
  4201. This gives you super powers, allowing you to track the provenance of binary
  4202. artifacts with very fine grain, and to reproduce software environments at
  4203. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4204. @xref{Inferiors}, for another way to take advantage of these super powers.
  4205. @node Channel Authentication
  4206. @section Channel Authentication
  4207. @anchor{channel-authentication}
  4208. @cindex authentication, of channel code
  4209. The @command{guix pull} and @command{guix time-machine} commands
  4210. @dfn{authenticate} the code retrieved from channels: they make sure each
  4211. commit that is fetched is signed by an authorized developer. The goal
  4212. is to protect from unauthorized modifications to the channel that would
  4213. lead users to run malicious code.
  4214. As a user, you must provide a @dfn{channel introduction} in your
  4215. channels file so that Guix knows how to authenticate its first commit.
  4216. A channel specification, including its introduction, looks something
  4217. along these lines:
  4218. @lisp
  4219. (channel
  4220. (name 'some-channel)
  4221. (url "https://example.org/some-channel.git")
  4222. (introduction
  4223. (make-channel-introduction
  4224. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4225. (openpgp-fingerprint
  4226. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4227. @end lisp
  4228. The specification above shows the name and URL of the channel. The call
  4229. to @code{make-channel-introduction} above specifies that authentication
  4230. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4231. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4232. For the main channel, called @code{guix}, you automatically get that
  4233. information from your Guix installation. For other channels, include
  4234. the channel introduction provided by the channel authors in your
  4235. @file{channels.scm} file. Make sure you retrieve the channel
  4236. introduction from a trusted source since that is the root of your trust.
  4237. If you're curious about the authentication mechanics, read on!
  4238. @node Channels with Substitutes
  4239. @section Channels with Substitutes
  4240. When running @command{guix pull}, Guix will first compile the
  4241. definitions of every available package. This is an expensive operation
  4242. for which substitutes (@pxref{Substitutes}) may be available. The
  4243. following snippet in @file{channels.scm} will ensure that @command{guix
  4244. pull} uses the latest commit with available substitutes for the package
  4245. definitions: this is done by querying the continuous integration
  4246. server at @url{https://ci.guix.gnu.org}.
  4247. @lisp
  4248. (use-modules (guix ci))
  4249. (list (channel-with-substitutes-available
  4250. %default-guix-channel
  4251. "https://ci.guix.gnu.org"))
  4252. @end lisp
  4253. Note that this does not mean that all the packages that you will
  4254. install after running @command{guix pull} will have available
  4255. substitutes. It only ensures that @command{guix pull} will not try to
  4256. compile package definitions. This is particularly useful when using
  4257. machines with limited resources.
  4258. @node Creating a Channel
  4259. @section Creating a Channel
  4260. @cindex personal packages (channels)
  4261. @cindex channels, for personal packages
  4262. Let's say you have a bunch of custom package variants or personal packages
  4263. that you think would make little sense to contribute to the Guix project, but
  4264. would like to have these packages transparently available to you at the
  4265. command line. You would first write modules containing those package
  4266. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4267. then you and anyone else can use it as an additional channel to get packages
  4268. from. Neat, no?
  4269. @c What follows stems from discussions at
  4270. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4271. @c earlier discussions on guix-devel@gnu.org.
  4272. @quotation Warning
  4273. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4274. publish your personal channel to the world, we would like to share a few words
  4275. of caution:
  4276. @itemize
  4277. @item
  4278. Before publishing a channel, please consider contributing your package
  4279. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4280. to free software of all sorts, and packages in Guix proper are readily
  4281. available to all Guix users and benefit from the project's quality assurance
  4282. process.
  4283. @item
  4284. When you maintain package definitions outside Guix, we, Guix developers,
  4285. consider that @emph{the compatibility burden is on you}. Remember that
  4286. package modules and package definitions are just Scheme code that uses various
  4287. programming interfaces (APIs). We want to remain free to change these APIs to
  4288. keep improving Guix, possibly in ways that break your channel. We never
  4289. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4290. either.
  4291. @item
  4292. Corollary: if you're using an external channel and that channel breaks, please
  4293. @emph{report the issue to the channel authors}, not to the Guix project.
  4294. @end itemize
  4295. You've been warned! Having said this, we believe external channels are a
  4296. practical way to exert your freedom to augment Guix' package collection and to
  4297. share your improvements, which are basic tenets of
  4298. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4299. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4300. @end quotation
  4301. To create a channel, create a Git repository containing your own package
  4302. modules and make it available. The repository can contain anything, but a
  4303. useful channel will contain Guile modules that export packages. Once you
  4304. start using a channel, Guix will behave as if the root directory of that
  4305. channel's Git repository has been added to the Guile load path (@pxref{Load
  4306. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4307. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4308. module, then the module will be available under the name @code{(my-packages
  4309. my-tools)}, and you will be able to use it like any other module
  4310. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4311. As a channel author, consider bundling authentication material with your
  4312. channel so that users can authenticate it. @xref{Channel
  4313. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4314. on how to do it.
  4315. @node Package Modules in a Sub-directory
  4316. @section Package Modules in a Sub-directory
  4317. @cindex subdirectory, channels
  4318. As a channel author, you may want to keep your channel modules in a
  4319. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4320. add a meta-data file @file{.guix-channel} that contains:
  4321. @lisp
  4322. (channel
  4323. (version 0)
  4324. (directory "guix"))
  4325. @end lisp
  4326. @node Declaring Channel Dependencies
  4327. @section Declaring Channel Dependencies
  4328. @cindex dependencies, channels
  4329. @cindex meta-data, channels
  4330. Channel authors may decide to augment a package collection provided by other
  4331. channels. They can declare their channel to be dependent on other channels in
  4332. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4333. the channel repository.
  4334. The meta-data file should contain a simple S-expression like this:
  4335. @lisp
  4336. (channel
  4337. (version 0)
  4338. (dependencies
  4339. (channel
  4340. (name some-collection)
  4341. (url "https://example.org/first-collection.git")
  4342. ;; The 'introduction' bit below is optional: you would
  4343. ;; provide it for dependencies that can be authenticated.
  4344. (introduction
  4345. (channel-introduction
  4346. (version 0)
  4347. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4348. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4349. (channel
  4350. (name some-other-collection)
  4351. (url "https://example.org/second-collection.git")
  4352. (branch "testing"))))
  4353. @end lisp
  4354. In the above example this channel is declared to depend on two other channels,
  4355. which will both be fetched automatically. The modules provided by the channel
  4356. will be compiled in an environment where the modules of all these declared
  4357. channels are available.
  4358. For the sake of reliability and maintainability, you should avoid dependencies
  4359. on channels that you don't control, and you should aim to keep the number of
  4360. dependencies to a minimum.
  4361. @node Specifying Channel Authorizations
  4362. @section Specifying Channel Authorizations
  4363. @cindex channel authorizations
  4364. @anchor{channel-authorizations}
  4365. As we saw above, Guix ensures the source code it pulls from channels
  4366. comes from authorized developers. As a channel author, you need to
  4367. specify the list of authorized developers in the
  4368. @file{.guix-authorizations} file in the channel's Git repository. The
  4369. authentication rule is simple: each commit must be signed by a key
  4370. listed in the @file{.guix-authorizations} file of its parent
  4371. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4372. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4373. have one parent and merge commits have two parent commits. Read
  4374. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4375. for Computer Scientists}} for a great overview.} The
  4376. @file{.guix-authorizations} file looks like this:
  4377. @lisp
  4378. ;; Example '.guix-authorizations' file.
  4379. (authorizations
  4380. (version 0) ;current file format version
  4381. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4382. (name "alice"))
  4383. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4384. (name "bob"))
  4385. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4386. (name "charlie"))))
  4387. @end lisp
  4388. Each fingerprint is followed by optional key/value pairs, as in the
  4389. example above. Currently these key/value pairs are ignored.
  4390. This authentication rule creates a chicken-and-egg issue: how do we
  4391. authenticate the first commit? Related to that: how do we deal with
  4392. channels whose repository history contains unsigned commits and lack
  4393. @file{.guix-authorizations}? And how do we fork existing channels?
  4394. @cindex channel introduction
  4395. Channel introductions answer these questions by describing the first
  4396. commit of a channel that should be authenticated. The first time a
  4397. channel is fetched with @command{guix pull} or @command{guix
  4398. time-machine}, the command looks up the introductory commit and verifies
  4399. that it is signed by the specified OpenPGP key. From then on, it
  4400. authenticates commits according to the rule above.
  4401. Additionally, your channel must provide all the OpenPGP keys that were
  4402. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4403. files, which can be either binary or ``ASCII-armored''. By default,
  4404. those @file{.key} files are searched for in the branch named
  4405. @code{keyring} but you can specify a different branch name in
  4406. @code{.guix-channel} like so:
  4407. @lisp
  4408. (channel
  4409. (version 0)
  4410. (keyring-reference "my-keyring-branch"))
  4411. @end lisp
  4412. To summarize, as the author of a channel, there are three things you have
  4413. to do to allow users to authenticate your code:
  4414. @enumerate
  4415. @item
  4416. Export the OpenPGP keys of past and present committers with @command{gpg
  4417. --export} and store them in @file{.key} files, by default in a branch
  4418. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4419. @item
  4420. Introduce an initial @file{.guix-authorizations} in the channel's
  4421. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4422. information on how to sign Git commits.)
  4423. @item
  4424. Advertise the channel introduction, for instance on your channel's web
  4425. page. The channel introduction, as we saw above, is the commit/key
  4426. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4427. the fingerprint of the OpenPGP used to sign it.
  4428. @end enumerate
  4429. Before pushing to your public Git repository, you can run @command{guix
  4430. git-authenticate} to verify that you did sign all the commits you are
  4431. about to push with an authorized key:
  4432. @example
  4433. guix git authenticate @var{commit} @var{signer}
  4434. @end example
  4435. @noindent
  4436. where @var{commit} and @var{signer} are your channel introduction.
  4437. @xref{Invoking guix git authenticate}, for details.
  4438. Publishing a signed channel requires discipline: any mistake, such as an
  4439. unsigned commit or a commit signed by an unauthorized key, will prevent
  4440. users from pulling from your channel---well, that's the whole point of
  4441. authentication! Pay attention to merges in particular: merge commits
  4442. are considered authentic if and only if they are signed by a key present
  4443. in the @file{.guix-authorizations} file of @emph{both} branches.
  4444. @node Primary URL
  4445. @section Primary URL
  4446. @cindex primary URL, channels
  4447. Channel authors can indicate the primary URL of their channel's Git
  4448. repository in the @file{.guix-channel} file, like so:
  4449. @lisp
  4450. (channel
  4451. (version 0)
  4452. (url "https://example.org/guix.git"))
  4453. @end lisp
  4454. This allows @command{guix pull} to determine whether it is pulling code
  4455. from a mirror of the channel; when that is the case, it warns the user
  4456. that the mirror might be stale and displays the primary URL@. That way,
  4457. users cannot be tricked into fetching code from a stale mirror that does
  4458. not receive security updates.
  4459. This feature only makes sense for authenticated repositories, such as
  4460. the official @code{guix} channel, for which @command{guix pull} ensures
  4461. the code it fetches is authentic.
  4462. @node Writing Channel News
  4463. @section Writing Channel News
  4464. @cindex news, for channels
  4465. Channel authors may occasionally want to communicate to their users
  4466. information about important changes in the channel. You'd send them all
  4467. an email, but that's not convenient.
  4468. Instead, channels can provide a @dfn{news file}; when the channel users
  4469. run @command{guix pull}, that news file is automatically read and
  4470. @command{guix pull --news} can display the announcements that correspond
  4471. to the new commits that have been pulled, if any.
  4472. To do that, channel authors must first declare the name of the news file
  4473. in their @file{.guix-channel} file:
  4474. @lisp
  4475. (channel
  4476. (version 0)
  4477. (news-file "etc/news.txt"))
  4478. @end lisp
  4479. The news file itself, @file{etc/news.txt} in this example, must look
  4480. something like this:
  4481. @lisp
  4482. (channel-news
  4483. (version 0)
  4484. (entry (tag "the-bug-fix")
  4485. (title (en "Fixed terrible bug")
  4486. (fr "Oh la la"))
  4487. (body (en "@@emph@{Good news@}! It's fixed!")
  4488. (eo "Certe ĝi pli bone funkcias nun!")))
  4489. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4490. (title (en "Added a great package")
  4491. (ca "Què vol dir guix?"))
  4492. (body (en "Don't miss the @@code@{hello@} package!"))))
  4493. @end lisp
  4494. While the news file is using the Scheme syntax, avoid naming it with a
  4495. @file{.scm} extension or else it will get picked up when building the
  4496. channel and yield an error since it is not a valid module.
  4497. Alternatively, you can move the channel module to a subdirectory and
  4498. store the news file in another directory.
  4499. The file consists of a list of @dfn{news entries}. Each entry is
  4500. associated with a commit or tag: it describes changes made in this
  4501. commit, possibly in preceding commits as well. Users see entries only
  4502. the first time they obtain the commit the entry refers to.
  4503. The @code{title} field should be a one-line summary while @code{body}
  4504. can be arbitrarily long, and both can contain Texinfo markup
  4505. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4506. a list of language tag/message tuples, which allows @command{guix pull}
  4507. to display news in the language that corresponds to the user's locale.
  4508. If you want to translate news using a gettext-based workflow, you can
  4509. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4510. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4511. you write news entries in English first, the command below creates a PO
  4512. file containing the strings to translate:
  4513. @example
  4514. xgettext -o news.po -l scheme -ken etc/news.txt
  4515. @end example
  4516. To sum up, yes, you could use your channel as a blog. But beware, this
  4517. is @emph{not quite} what your users might expect.
  4518. @c *********************************************************************
  4519. @node Development
  4520. @chapter Development
  4521. @cindex software development
  4522. If you are a software developer, Guix provides tools that you should find
  4523. helpful---independently of the language you're developing in. This is what
  4524. this chapter is about.
  4525. The @command{guix shell} command provides a convenient way to set up
  4526. one-off software environments, be it for development purposes or to run
  4527. a command without installing it in your profile. The @command{guix
  4528. pack} command allows you to create @dfn{application bundles} that can be
  4529. easily distributed to users who do not run Guix.
  4530. @menu
  4531. * Invoking guix shell:: Spawning one-off software environments.
  4532. * Invoking guix environment:: Setting up development environments.
  4533. * Invoking guix pack:: Creating software bundles.
  4534. * The GCC toolchain:: Working with languages supported by GCC.
  4535. * Invoking guix git authenticate:: Authenticating Git repositories.
  4536. @end menu
  4537. @node Invoking guix shell
  4538. @section Invoking @command{guix shell}
  4539. @cindex reproducible build environments
  4540. @cindex development environments
  4541. @cindex @command{guix environment}
  4542. @cindex environment, package build environment
  4543. The purpose of @command{guix shell} is to make it easy to create one-off
  4544. software environments, without changing one's profile. It is typically
  4545. used to create development environments; it is also a convenient way to
  4546. run applications without ``polluting'' your profile.
  4547. @quotation Note
  4548. The @command{guix shell} command was recently introduced to supersede
  4549. @command{guix environment} (@pxref{Invoking guix environment}). If you
  4550. are familiar with @command{guix environment}, you will notice that it is
  4551. similar but also---we hope!---more convenient.
  4552. @end quotation
  4553. The general syntax is:
  4554. @example
  4555. guix shell [@var{options}] [@var{package}@dots{}]
  4556. @end example
  4557. The following example creates an environment containing Python and NumPy,
  4558. building or downloading any missing package, and runs the
  4559. @command{python3} command in that environment:
  4560. @example
  4561. guix shell python python-numpy -- python3
  4562. @end example
  4563. Development environments can be created as in the example below, which
  4564. spawns an interactive shell containing all the dependencies and
  4565. environment variables needed to work on Inkscape:
  4566. @example
  4567. guix shell --development inkscape
  4568. @end example
  4569. Exiting the shell places the user back in the original environment
  4570. before @command{guix shell} was invoked. The next garbage collection
  4571. (@pxref{Invoking guix gc}) may clean up packages that were installed in
  4572. the environment and that are no longer used outside of it.
  4573. As an added convenience, when running from a directory that contains a
  4574. @file{manifest.scm} or a @file{guix.scm} file (in this order), possibly
  4575. in a parent directory, @command{guix shell} automatically loads the
  4576. file---provided the directory is listed in
  4577. @file{~/.config/guix/shell-authorized-directories}, and only for
  4578. interactive use:
  4579. @example
  4580. guix shell
  4581. @end example
  4582. This provides an easy way to define, share, and enter development
  4583. environments.
  4584. By default, the shell session or command runs in an @emph{augmented}
  4585. environment, where the new packages are added to search path environment
  4586. variables such as @code{PATH}. You can, instead, choose to create an
  4587. @emph{isolated} environment containing nothing but the packages you
  4588. asked for. Passing the @option{--pure} option clears environment
  4589. variable definitions found in the parent environment@footnote{Be sure to
  4590. use the @option{--check} option the first time you use @command{guix
  4591. shell} interactively to make sure the shell does not undo the effect of
  4592. @option{--pure}.}; passing @option{--container} goes one step further by
  4593. spawning a @dfn{container} isolated from the rest of the system:
  4594. @example
  4595. guix shell --container emacs gcc-toolchain
  4596. @end example
  4597. The command above spawns an interactive shell in a container where
  4598. nothing but @code{emacs}, @code{gcc-toolchain}, and their dependencies
  4599. is available. The container lacks network access and shares no files
  4600. other than the current working directory with the surrounding
  4601. environment. This is useful to prevent access to system-wide resources
  4602. such as @file{/usr/bin} on foreign distros.
  4603. This @option{--container} option can also prove useful if you wish to
  4604. run a security-sensitive application, such as a web browser, in an
  4605. isolated environment. For example, the command below launches
  4606. Ungoogled-Chromium in an isolated environment, this time sharing network
  4607. access with the host and preserving its @code{DISPLAY} environment
  4608. variable, but without even sharing the current directory:
  4609. @example
  4610. guix shell --container --network --no-cwd ungoogled-chromium \
  4611. --preserve='^DISPLAY$' -- chromium
  4612. @end example
  4613. @vindex GUIX_ENVIRONMENT
  4614. @command{guix shell} defines the @env{GUIX_ENVIRONMENT}
  4615. variable in the shell it spawns; its value is the file name of the
  4616. profile of this environment. This allows users to, say, define a
  4617. specific prompt for development environments in their @file{.bashrc}
  4618. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4619. @example
  4620. if [ -n "$GUIX_ENVIRONMENT" ]
  4621. then
  4622. export PS1="\u@@\h \w [dev]\$ "
  4623. fi
  4624. @end example
  4625. @noindent
  4626. ...@: or to browse the profile:
  4627. @example
  4628. $ ls "$GUIX_ENVIRONMENT/bin"
  4629. @end example
  4630. The available options are summarized below.
  4631. @table @code
  4632. @item --check
  4633. Set up the environment and check whether the shell would clobber
  4634. environment variables. It's a good idea to use this option the first
  4635. time you run @command{guix shell} for an interactive session to make
  4636. sure your setup is correct.
  4637. For example, if the shell modifies the @env{PATH} environment variable,
  4638. report it since you would get a different environment than what you
  4639. asked for.
  4640. Such problems usually indicate that the shell startup files are
  4641. unexpectedly modifying those environment variables. For example, if you
  4642. are using Bash, make sure that environment variables are set or modified
  4643. in @file{~/.bash_profile} and @emph{not} in @file{~/.bashrc}---the
  4644. former is sourced only by log-in shells. @xref{Bash Startup Files,,,
  4645. bash, The GNU Bash Reference Manual}, for details on Bash start-up
  4646. files.
  4647. @item --development
  4648. @itemx -D
  4649. Cause @command{guix shell} to include in the environment the
  4650. dependencies of the following package rather than the package itself.
  4651. This can be combined with other packages. For instance, the command
  4652. below starts an interactive shell containing the build-time dependencies
  4653. of GNU@tie{}Guile, plus Autoconf, Automake, and Libtool:
  4654. @example
  4655. guix shell -D guile autoconf automake libtool
  4656. @end example
  4657. @item --expression=@var{expr}
  4658. @itemx -e @var{expr}
  4659. Create an environment for the package or list of packages that
  4660. @var{expr} evaluates to.
  4661. For example, running:
  4662. @example
  4663. guix shell -D -e '(@@ (gnu packages maths) petsc-openmpi)'
  4664. @end example
  4665. starts a shell with the environment for this specific variant of the
  4666. PETSc package.
  4667. Running:
  4668. @example
  4669. guix shell -e '(@@ (gnu) %base-packages)'
  4670. @end example
  4671. starts a shell with all the base system packages available.
  4672. The above commands only use the default output of the given packages.
  4673. To select other outputs, two element tuples can be specified:
  4674. @example
  4675. guix shell -e '(list (@@ (gnu packages bash) bash) "include")'
  4676. @end example
  4677. @item --file=@var{file}
  4678. @itemx -f @var{file}
  4679. Create an environment containing the package or list of packages that
  4680. the code within @var{file} evaluates to.
  4681. As an example, @var{file} might contain a definition like this
  4682. (@pxref{Defining Packages}):
  4683. @lisp
  4684. @verbatiminclude environment-gdb.scm
  4685. @end lisp
  4686. With the file above, you can enter a development environment for GDB by
  4687. running:
  4688. @example
  4689. guix shell -D -f gdb-devel.scm
  4690. @end example
  4691. @item --manifest=@var{file}
  4692. @itemx -m @var{file}
  4693. Create an environment for the packages contained in the manifest object
  4694. returned by the Scheme code in @var{file}. This option can be repeated
  4695. several times, in which case the manifests are concatenated.
  4696. This is similar to the same-named option in @command{guix package}
  4697. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4698. manifest files.
  4699. @item --rebuild-cache
  4700. When using @option{--manifest}, @option{--file}, or when invoked without
  4701. arguments, @command{guix shell} caches the environment so that
  4702. subsequent uses are instantaneous. The cache is invalidated anytime the
  4703. file is modified.
  4704. The @option{--rebuild-cache} forces the cached environment to be
  4705. refreshed even if the file has not changed. This is useful if the
  4706. @command{guix.scm} or @command{manifest.scm} has external dependencies,
  4707. or if its behavior depends, say, on environment variables.
  4708. @item --pure
  4709. Unset existing environment variables when building the new environment, except
  4710. those specified with @option{--preserve} (see below). This has the effect of
  4711. creating an environment in which search paths only contain package inputs.
  4712. @item --preserve=@var{regexp}
  4713. @itemx -E @var{regexp}
  4714. When used alongside @option{--pure}, preserve the environment variables
  4715. matching @var{regexp}---in other words, put them on a ``white list'' of
  4716. environment variables that must be preserved. This option can be repeated
  4717. several times.
  4718. @example
  4719. guix shell --pure --preserve=^SLURM openmpi @dots{} \
  4720. -- mpirun @dots{}
  4721. @end example
  4722. This example runs @command{mpirun} in a context where the only environment
  4723. variables defined are @env{PATH}, environment variables whose name starts
  4724. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4725. @env{USER}, etc.).
  4726. @item --search-paths
  4727. Display the environment variable definitions that make up the
  4728. environment.
  4729. @item --system=@var{system}
  4730. @itemx -s @var{system}
  4731. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4732. @item --container
  4733. @itemx -C
  4734. @cindex container
  4735. Run @var{command} within an isolated container. The current working
  4736. directory outside the container is mapped inside the container.
  4737. Additionally, unless overridden with @option{--user}, a dummy home
  4738. directory is created that matches the current user's home directory, and
  4739. @file{/etc/passwd} is configured accordingly.
  4740. The spawned process runs as the current user outside the container. Inside
  4741. the container, it has the same UID and GID as the current user, unless
  4742. @option{--user} is passed (see below).
  4743. @item --network
  4744. @itemx -N
  4745. For containers, share the network namespace with the host system.
  4746. Containers created without this flag only have access to the loopback
  4747. device.
  4748. @item --link-profile
  4749. @itemx -P
  4750. For containers, link the environment profile to @file{~/.guix-profile}
  4751. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4752. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4753. actual profile within the container.
  4754. Linking will fail and abort the environment if the directory already
  4755. exists, which will certainly be the case if @command{guix shell}
  4756. was invoked in the user's home directory.
  4757. Certain packages are configured to look in @file{~/.guix-profile} for
  4758. configuration files and data;@footnote{For example, the
  4759. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4760. for additional fonts.} @option{--link-profile} allows these programs to
  4761. behave as expected within the environment.
  4762. @item --user=@var{user}
  4763. @itemx -u @var{user}
  4764. For containers, use the username @var{user} in place of the current
  4765. user. The generated @file{/etc/passwd} entry within the container will
  4766. contain the name @var{user}, the home directory will be
  4767. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4768. the UID and GID inside the container are 1000. @var{user}
  4769. need not exist on the system.
  4770. Additionally, any shared or exposed path (see @option{--share} and
  4771. @option{--expose} respectively) whose target is within the current user's
  4772. home directory will be remapped relative to @file{/home/USER}; this
  4773. includes the automatic mapping of the current working directory.
  4774. @example
  4775. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4776. cd $HOME/wd
  4777. guix shell --container --user=foo \
  4778. --expose=$HOME/test \
  4779. --expose=/tmp/target=$HOME/target
  4780. @end example
  4781. While this will limit the leaking of user identity through home paths
  4782. and each of the user fields, this is only one useful component of a
  4783. broader privacy/anonymity solution---not one in and of itself.
  4784. @item --no-cwd
  4785. For containers, the default behavior is to share the current working
  4786. directory with the isolated container and immediately change to that
  4787. directory within the container. If this is undesirable,
  4788. @option{--no-cwd} will cause the current working directory to @emph{not}
  4789. be automatically shared and will change to the user's home directory
  4790. within the container instead. See also @option{--user}.
  4791. @item --expose=@var{source}[=@var{target}]
  4792. @itemx --share=@var{source}[=@var{target}]
  4793. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4794. file system @var{source} from the host system as the read-only
  4795. (resp. writable) file system @var{target} within the container. If
  4796. @var{target} is not specified, @var{source} is used as the target mount
  4797. point in the container.
  4798. The example below spawns a Guile REPL in a container in which the user's
  4799. home directory is accessible read-only via the @file{/exchange}
  4800. directory:
  4801. @example
  4802. guix shell --container --expose=$HOME=/exchange guile -- guile
  4803. @end example
  4804. @item --root=@var{file}
  4805. @itemx -r @var{file}
  4806. @cindex persistent environment
  4807. @cindex garbage collector root, for environments
  4808. Make @var{file} a symlink to the profile for this environment, and
  4809. register it as a garbage collector root.
  4810. This is useful if you want to protect your environment from garbage
  4811. collection, to make it ``persistent''.
  4812. When this option is omitted, the environment is protected from garbage
  4813. collection only for the duration of the @command{guix shell}
  4814. session. This means that next time you recreate the same environment,
  4815. you could have to rebuild or re-download packages. @xref{Invoking guix
  4816. gc}, for more on GC roots.
  4817. @end table
  4818. @command{guix shell} also supports all of the common build options that
  4819. @command{guix build} supports (@pxref{Common Build Options}) as well as
  4820. package transformation options (@pxref{Package Transformation Options}).
  4821. @node Invoking guix environment
  4822. @section Invoking @command{guix environment}
  4823. The purpose of @command{guix environment} is to assist in creating
  4824. development environments.
  4825. @quotation Deprecation warning
  4826. The @command{guix environment} command is deprecated in favor of
  4827. @command{guix shell}, which performs similar functions but is more
  4828. convenient to use. @xref{Invoking guix shell}.
  4829. Being deprecated, @command{guix environment} is slated for eventual
  4830. removal, but the Guix project is committed to keeping it until May 1st,
  4831. 2023. Please get in touch with us at @email{guix-devel@@gnu.org} if you
  4832. would like to discuss it.
  4833. @end quotation
  4834. The general syntax is:
  4835. @example
  4836. guix environment @var{options} @var{package}@dots{}
  4837. @end example
  4838. The following example spawns a new shell set up for the development of
  4839. GNU@tie{}Guile:
  4840. @example
  4841. guix environment guile
  4842. @end example
  4843. If the needed dependencies are not built yet, @command{guix environment}
  4844. automatically builds them. The environment of the new shell is an
  4845. augmented version of the environment that @command{guix environment} was
  4846. run in. It contains the necessary search paths for building the given
  4847. package added to the existing environment variables. To create
  4848. a ``pure'' environment, in which the original environment variables have
  4849. been unset, use the @option{--pure} option@footnote{Users sometimes
  4850. wrongfully augment environment variables such as @env{PATH} in their
  4851. @file{~/.bashrc} file. As a consequence, when @command{guix
  4852. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4853. introducing ``impurities'' in these environment variables. It is an
  4854. error to define such environment variables in @file{.bashrc}; instead,
  4855. they should be defined in @file{.bash_profile}, which is sourced only by
  4856. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4857. Manual}, for details on Bash start-up files.}.
  4858. Exiting from a Guix environment is the same as exiting from the shell,
  4859. and will place the user back in the old environment before @command{guix
  4860. environment} was invoked. The next garbage collection (@pxref{Invoking
  4861. guix gc}) will clean up packages that were installed from within the
  4862. environment and are no longer used outside of it.
  4863. @vindex GUIX_ENVIRONMENT
  4864. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4865. variable in the shell it spawns; its value is the file name of the
  4866. profile of this environment. This allows users to, say, define a
  4867. specific prompt for development environments in their @file{.bashrc}
  4868. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4869. @example
  4870. if [ -n "$GUIX_ENVIRONMENT" ]
  4871. then
  4872. export PS1="\u@@\h \w [dev]\$ "
  4873. fi
  4874. @end example
  4875. @noindent
  4876. ...@: or to browse the profile:
  4877. @example
  4878. $ ls "$GUIX_ENVIRONMENT/bin"
  4879. @end example
  4880. Additionally, more than one package may be specified, in which case the
  4881. union of the inputs for the given packages are used. For example, the
  4882. command below spawns a shell where all of the dependencies of both Guile
  4883. and Emacs are available:
  4884. @example
  4885. guix environment guile emacs
  4886. @end example
  4887. Sometimes an interactive shell session is not desired. An arbitrary
  4888. command may be invoked by placing the @code{--} token to separate the
  4889. command from the rest of the arguments:
  4890. @example
  4891. guix environment guile -- make -j4
  4892. @end example
  4893. In other situations, it is more convenient to specify the list of
  4894. packages needed in the environment. For example, the following command
  4895. runs @command{python} from an environment containing Python@tie{}3 and
  4896. NumPy:
  4897. @example
  4898. guix environment --ad-hoc python-numpy python -- python3
  4899. @end example
  4900. Furthermore, one might want the dependencies of a package and also some
  4901. additional packages that are not build-time or runtime dependencies, but
  4902. are useful when developing nonetheless. Because of this, the
  4903. @option{--ad-hoc} flag is positional. Packages appearing before
  4904. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4905. added to the environment. Packages appearing after are interpreted as
  4906. packages that will be added to the environment directly. For example,
  4907. the following command creates a Guix development environment that
  4908. additionally includes Git and strace:
  4909. @example
  4910. guix environment --pure guix --ad-hoc git strace
  4911. @end example
  4912. @cindex container
  4913. Sometimes it is desirable to isolate the environment as much as
  4914. possible, for maximal purity and reproducibility. In particular, when
  4915. using Guix on a host distro that is not Guix System, it is desirable to
  4916. prevent access to @file{/usr/bin} and other system-wide resources from
  4917. the development environment. For example, the following command spawns
  4918. a Guile REPL in a ``container'' where only the store and the current
  4919. working directory are mounted:
  4920. @example
  4921. guix environment --ad-hoc --container guile -- guile
  4922. @end example
  4923. @quotation Note
  4924. The @option{--container} option requires Linux-libre 3.19 or newer.
  4925. @end quotation
  4926. @cindex certificates
  4927. Another typical use case for containers is to run security-sensitive
  4928. applications such as a web browser. To run Eolie, we must expose and
  4929. share some files and directories; we include @code{nss-certs} and expose
  4930. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4931. @env{DISPLAY} environment variable since containerized graphical
  4932. applications won't display without it.
  4933. @example
  4934. guix environment --preserve='^DISPLAY$' --container --network \
  4935. --expose=/etc/machine-id \
  4936. --expose=/etc/ssl/certs/ \
  4937. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4938. --ad-hoc eolie nss-certs dbus -- eolie
  4939. @end example
  4940. The available options are summarized below.
  4941. @table @code
  4942. @item --check
  4943. Set up the environment and check whether the shell would clobber
  4944. environment variables. @xref{Invoking guix shell, @option{--check}},
  4945. for more info.
  4946. @item --root=@var{file}
  4947. @itemx -r @var{file}
  4948. @cindex persistent environment
  4949. @cindex garbage collector root, for environments
  4950. Make @var{file} a symlink to the profile for this environment, and
  4951. register it as a garbage collector root.
  4952. This is useful if you want to protect your environment from garbage
  4953. collection, to make it ``persistent''.
  4954. When this option is omitted, the environment is protected from garbage
  4955. collection only for the duration of the @command{guix environment}
  4956. session. This means that next time you recreate the same environment,
  4957. you could have to rebuild or re-download packages. @xref{Invoking guix
  4958. gc}, for more on GC roots.
  4959. @item --expression=@var{expr}
  4960. @itemx -e @var{expr}
  4961. Create an environment for the package or list of packages that
  4962. @var{expr} evaluates to.
  4963. For example, running:
  4964. @example
  4965. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4966. @end example
  4967. starts a shell with the environment for this specific variant of the
  4968. PETSc package.
  4969. Running:
  4970. @example
  4971. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4972. @end example
  4973. starts a shell with all the base system packages available.
  4974. The above commands only use the default output of the given packages.
  4975. To select other outputs, two element tuples can be specified:
  4976. @example
  4977. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4978. @end example
  4979. @item --load=@var{file}
  4980. @itemx -l @var{file}
  4981. Create an environment for the package or list of packages that the code
  4982. within @var{file} evaluates to.
  4983. As an example, @var{file} might contain a definition like this
  4984. (@pxref{Defining Packages}):
  4985. @lisp
  4986. @verbatiminclude environment-gdb.scm
  4987. @end lisp
  4988. @item --manifest=@var{file}
  4989. @itemx -m @var{file}
  4990. Create an environment for the packages contained in the manifest object
  4991. returned by the Scheme code in @var{file}. This option can be repeated
  4992. several times, in which case the manifests are concatenated.
  4993. This is similar to the same-named option in @command{guix package}
  4994. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4995. manifest files.
  4996. @item --ad-hoc
  4997. Include all specified packages in the resulting environment, as if an
  4998. @i{ad hoc} package were defined with them as inputs. This option is
  4999. useful for quickly creating an environment without having to write a
  5000. package expression to contain the desired inputs.
  5001. For instance, the command:
  5002. @example
  5003. guix environment --ad-hoc guile guile-sdl -- guile
  5004. @end example
  5005. runs @command{guile} in an environment where Guile and Guile-SDL are
  5006. available.
  5007. Note that this example implicitly asks for the default output of
  5008. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  5009. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  5010. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  5011. This option may be composed with the default behavior of @command{guix
  5012. environment}. Packages appearing before @option{--ad-hoc} are
  5013. interpreted as packages whose dependencies will be added to the
  5014. environment, the default behavior. Packages appearing after are
  5015. interpreted as packages that will be added to the environment directly.
  5016. @item --pure
  5017. Unset existing environment variables when building the new environment, except
  5018. those specified with @option{--preserve} (see below). This has the effect of
  5019. creating an environment in which search paths only contain package inputs.
  5020. @item --preserve=@var{regexp}
  5021. @itemx -E @var{regexp}
  5022. When used alongside @option{--pure}, preserve the environment variables
  5023. matching @var{regexp}---in other words, put them on a ``white list'' of
  5024. environment variables that must be preserved. This option can be repeated
  5025. several times.
  5026. @example
  5027. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  5028. -- mpirun @dots{}
  5029. @end example
  5030. This example runs @command{mpirun} in a context where the only environment
  5031. variables defined are @env{PATH}, environment variables whose name starts
  5032. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  5033. @env{USER}, etc.).
  5034. @item --search-paths
  5035. Display the environment variable definitions that make up the
  5036. environment.
  5037. @item --system=@var{system}
  5038. @itemx -s @var{system}
  5039. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5040. @item --container
  5041. @itemx -C
  5042. @cindex container
  5043. Run @var{command} within an isolated container. The current working
  5044. directory outside the container is mapped inside the container.
  5045. Additionally, unless overridden with @option{--user}, a dummy home
  5046. directory is created that matches the current user's home directory, and
  5047. @file{/etc/passwd} is configured accordingly.
  5048. The spawned process runs as the current user outside the container. Inside
  5049. the container, it has the same UID and GID as the current user, unless
  5050. @option{--user} is passed (see below).
  5051. @item --network
  5052. @itemx -N
  5053. For containers, share the network namespace with the host system.
  5054. Containers created without this flag only have access to the loopback
  5055. device.
  5056. @item --link-profile
  5057. @itemx -P
  5058. For containers, link the environment profile to @file{~/.guix-profile}
  5059. within the container and set @code{GUIX_ENVIRONMENT} to that.
  5060. This is equivalent to making @file{~/.guix-profile} a symlink to the
  5061. actual profile within the container.
  5062. Linking will fail and abort the environment if the directory already
  5063. exists, which will certainly be the case if @command{guix environment}
  5064. was invoked in the user's home directory.
  5065. Certain packages are configured to look in @file{~/.guix-profile} for
  5066. configuration files and data;@footnote{For example, the
  5067. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  5068. for additional fonts.} @option{--link-profile} allows these programs to
  5069. behave as expected within the environment.
  5070. @item --user=@var{user}
  5071. @itemx -u @var{user}
  5072. For containers, use the username @var{user} in place of the current
  5073. user. The generated @file{/etc/passwd} entry within the container will
  5074. contain the name @var{user}, the home directory will be
  5075. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  5076. the UID and GID inside the container are 1000. @var{user}
  5077. need not exist on the system.
  5078. Additionally, any shared or exposed path (see @option{--share} and
  5079. @option{--expose} respectively) whose target is within the current user's
  5080. home directory will be remapped relative to @file{/home/USER}; this
  5081. includes the automatic mapping of the current working directory.
  5082. @example
  5083. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  5084. cd $HOME/wd
  5085. guix environment --container --user=foo \
  5086. --expose=$HOME/test \
  5087. --expose=/tmp/target=$HOME/target
  5088. @end example
  5089. While this will limit the leaking of user identity through home paths
  5090. and each of the user fields, this is only one useful component of a
  5091. broader privacy/anonymity solution---not one in and of itself.
  5092. @item --no-cwd
  5093. For containers, the default behavior is to share the current working
  5094. directory with the isolated container and immediately change to that
  5095. directory within the container. If this is undesirable,
  5096. @option{--no-cwd} will cause the current working directory to @emph{not}
  5097. be automatically shared and will change to the user's home directory
  5098. within the container instead. See also @option{--user}.
  5099. @item --expose=@var{source}[=@var{target}]
  5100. @itemx --share=@var{source}[=@var{target}]
  5101. For containers, @option{--expose} (resp. @option{--share}) exposes the
  5102. file system @var{source} from the host system as the read-only
  5103. (resp. writable) file system @var{target} within the container. If
  5104. @var{target} is not specified, @var{source} is used as the target mount
  5105. point in the container.
  5106. The example below spawns a Guile REPL in a container in which the user's
  5107. home directory is accessible read-only via the @file{/exchange}
  5108. directory:
  5109. @example
  5110. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  5111. @end example
  5112. @end table
  5113. @command{guix environment}
  5114. also supports all of the common build options that @command{guix
  5115. build} supports (@pxref{Common Build Options}) as well as package
  5116. transformation options (@pxref{Package Transformation Options}).
  5117. @node Invoking guix pack
  5118. @section Invoking @command{guix pack}
  5119. Occasionally you want to pass software to people who are not (yet!)
  5120. lucky enough to be using Guix. You'd tell them to run @command{guix
  5121. package -i @var{something}}, but that's not possible in this case. This
  5122. is where @command{guix pack} comes in.
  5123. @quotation Note
  5124. If you are looking for ways to exchange binaries among machines that
  5125. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  5126. publish}, and @ref{Invoking guix archive}.
  5127. @end quotation
  5128. @cindex pack
  5129. @cindex bundle
  5130. @cindex application bundle
  5131. @cindex software bundle
  5132. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  5133. @dfn{software bundle}: it creates a tarball or some other archive
  5134. containing the binaries of the software you're interested in, and all
  5135. its dependencies. The resulting archive can be used on any machine that
  5136. does not have Guix, and people can run the exact same binaries as those
  5137. you have with Guix. The pack itself is created in a bit-reproducible
  5138. fashion, so anyone can verify that it really contains the build results
  5139. that you pretend to be shipping.
  5140. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  5141. their dependencies, you can run:
  5142. @example
  5143. $ guix pack guile emacs emacs-geiser
  5144. @dots{}
  5145. /gnu/store/@dots{}-pack.tar.gz
  5146. @end example
  5147. The result here is a tarball containing a @file{/gnu/store} directory
  5148. with all the relevant packages. The resulting tarball contains a
  5149. @dfn{profile} with the three packages of interest; the profile is the
  5150. same as would be created by @command{guix package -i}. It is this
  5151. mechanism that is used to create Guix's own standalone binary tarball
  5152. (@pxref{Binary Installation}).
  5153. Users of this pack would have to run
  5154. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  5155. find inconvenient. To work around it, you can create, say, a
  5156. @file{/opt/gnu/bin} symlink to the profile:
  5157. @example
  5158. guix pack -S /opt/gnu/bin=bin guile emacs emacs-geiser
  5159. @end example
  5160. @noindent
  5161. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  5162. @cindex relocatable binaries, with @command{guix pack}
  5163. What if the recipient of your pack does not have root privileges on
  5164. their machine, and thus cannot unpack it in the root file system? In
  5165. that case, you will want to use the @option{--relocatable} option (see
  5166. below). This option produces @dfn{relocatable binaries}, meaning they
  5167. they can be placed anywhere in the file system hierarchy: in the example
  5168. above, users can unpack your tarball in their home directory and
  5169. directly run @file{./opt/gnu/bin/guile}.
  5170. @cindex Docker, build an image with guix pack
  5171. Alternatively, you can produce a pack in the Docker image format using
  5172. the following command:
  5173. @example
  5174. guix pack -f docker -S /bin=bin guile guile-readline
  5175. @end example
  5176. @noindent
  5177. The result is a tarball that can be passed to the @command{docker load}
  5178. command, followed by @code{docker run}:
  5179. @example
  5180. docker load < @var{file}
  5181. docker run -ti guile-guile-readline /bin/guile
  5182. @end example
  5183. @noindent
  5184. where @var{file} is the image returned by @var{guix pack}, and
  5185. @code{guile-guile-readline} is its ``image tag''. See the
  5186. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  5187. documentation} for more information.
  5188. @cindex Singularity, build an image with guix pack
  5189. @cindex SquashFS, build an image with guix pack
  5190. Yet another option is to produce a SquashFS image with the following
  5191. command:
  5192. @example
  5193. guix pack -f squashfs bash guile emacs emacs-geiser
  5194. @end example
  5195. @noindent
  5196. The result is a SquashFS file system image that can either be mounted or
  5197. directly be used as a file system container image with the
  5198. @uref{https://www.sylabs.io/docs/, Singularity container execution
  5199. environment}, using commands like @command{singularity shell} or
  5200. @command{singularity exec}.
  5201. Several command-line options allow you to customize your pack:
  5202. @table @code
  5203. @item --format=@var{format}
  5204. @itemx -f @var{format}
  5205. Produce a pack in the given @var{format}.
  5206. The available formats are:
  5207. @table @code
  5208. @item tarball
  5209. This is the default format. It produces a tarball containing all the
  5210. specified binaries and symlinks.
  5211. @item docker
  5212. This produces a tarball that follows the
  5213. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  5214. Docker Image Specification}. The ``repository name'' as it appears in
  5215. the output of the @command{docker images} command is computed from
  5216. package names passed on the command line or in the manifest file.
  5217. @item squashfs
  5218. This produces a SquashFS image containing all the specified binaries and
  5219. symlinks, as well as empty mount points for virtual file systems like
  5220. procfs.
  5221. @quotation Note
  5222. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  5223. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  5224. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  5225. with something like:
  5226. @example
  5227. guix pack -f squashfs bash @dots{}
  5228. @end example
  5229. If you forget the @code{bash} (or similar) package, @command{singularity
  5230. run} and @command{singularity exec} will fail with an unhelpful ``no
  5231. such file or directory'' message.
  5232. @end quotation
  5233. @item deb
  5234. This produces a Debian archive (a package with the @samp{.deb} file
  5235. extension) containing all the specified binaries and symbolic links,
  5236. that can be installed on top of any dpkg-based GNU(/Linux) distribution.
  5237. Advanced options can be revealed via the @option{--help-deb-format}
  5238. option. They allow embedding control files for more fine-grained
  5239. control, such as activating specific triggers or providing a maintainer
  5240. configure script to run arbitrary setup code upon installation.
  5241. @example
  5242. guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello
  5243. @end example
  5244. @quotation Note
  5245. Because archives produced with @command{guix pack} contain a collection
  5246. of store items and because each @command{dpkg} package must not have
  5247. conflicting files, in practice that means you likely won't be able to
  5248. install more than one such archive on a given system.
  5249. @end quotation
  5250. @quotation Warning
  5251. @command{dpkg} will assume ownership of any files contained in the pack
  5252. that it does @emph{not} know about. It is unwise to install
  5253. Guix-produced @samp{.deb} files on a system where @file{/gnu/store} is
  5254. shared by other software, such as a Guix installation or other, non-deb
  5255. packs.
  5256. @end quotation
  5257. @end table
  5258. @cindex relocatable binaries
  5259. @item --relocatable
  5260. @itemx -R
  5261. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  5262. anywhere in the file system hierarchy and run from there.
  5263. When this option is passed once, the resulting binaries require support for
  5264. @dfn{user namespaces} in the kernel Linux; when passed
  5265. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  5266. PRoot support, can be thought of as the abbreviation of ``Really
  5267. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  5268. other techniques if user namespaces are unavailable, and essentially
  5269. work anywhere---see below for the implications.
  5270. For example, if you create a pack containing Bash with:
  5271. @example
  5272. guix pack -RR -S /mybin=bin bash
  5273. @end example
  5274. @noindent
  5275. ...@: you can copy that pack to a machine that lacks Guix, and from your
  5276. home directory as a normal user, run:
  5277. @example
  5278. tar xf pack.tar.gz
  5279. ./mybin/sh
  5280. @end example
  5281. @noindent
  5282. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  5283. @file{/gnu/store} shows up and contains all the dependencies of
  5284. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  5285. altogether! That is probably the simplest way to deploy Guix-built
  5286. software on a non-Guix machine.
  5287. @quotation Note
  5288. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  5289. the kernel Linux, which allows unprivileged users to mount or change root.
  5290. Old versions of Linux did not support it, and some GNU/Linux distributions
  5291. turn it off.
  5292. To produce relocatable binaries that work even in the absence of user
  5293. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  5294. case, binaries will try user namespace support and fall back to another
  5295. @dfn{execution engine} if user namespaces are not supported. The
  5296. following execution engines are supported:
  5297. @table @code
  5298. @item default
  5299. Try user namespaces and fall back to PRoot if user namespaces are not
  5300. supported (see below).
  5301. @item performance
  5302. Try user namespaces and fall back to Fakechroot if user namespaces are
  5303. not supported (see below).
  5304. @item userns
  5305. Run the program through user namespaces and abort if they are not
  5306. supported.
  5307. @item proot
  5308. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  5309. provides the necessary
  5310. support for file system virtualization. It achieves that by using the
  5311. @code{ptrace} system call on the running program. This approach has the
  5312. advantage to work without requiring special kernel support, but it incurs
  5313. run-time overhead every time a system call is made.
  5314. @item fakechroot
  5315. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  5316. Fakechroot} virtualizes file system accesses by intercepting calls to C
  5317. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  5318. on. Unlike PRoot, it incurs very little overhead. However, it does not
  5319. always work: for example, some file system accesses made from within the
  5320. C library are not intercepted, and file system accesses made @i{via}
  5321. direct syscalls are not intercepted either, leading to erratic behavior.
  5322. @end table
  5323. @vindex GUIX_EXECUTION_ENGINE
  5324. When running a wrapped program, you can explicitly request one of the
  5325. execution engines listed above by setting the
  5326. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  5327. @end quotation
  5328. @cindex entry point, for Docker images
  5329. @item --entry-point=@var{command}
  5330. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  5331. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  5332. support it. @var{command} must be relative to the profile contained in the
  5333. pack.
  5334. The entry point specifies the command that tools like @code{docker run} or
  5335. @code{singularity run} automatically start by default. For example, you can
  5336. do:
  5337. @example
  5338. guix pack -f docker --entry-point=bin/guile guile
  5339. @end example
  5340. The resulting pack can easily be loaded and @code{docker run} with no extra
  5341. arguments will spawn @code{bin/guile}:
  5342. @example
  5343. docker load -i pack.tar.gz
  5344. docker run @var{image-id}
  5345. @end example
  5346. @item --expression=@var{expr}
  5347. @itemx -e @var{expr}
  5348. Consider the package @var{expr} evaluates to.
  5349. This has the same purpose as the same-named option in @command{guix
  5350. build} (@pxref{Additional Build Options, @option{--expression} in
  5351. @command{guix build}}).
  5352. @item --manifest=@var{file}
  5353. @itemx -m @var{file}
  5354. Use the packages contained in the manifest object returned by the Scheme
  5355. code in @var{file}. This option can be repeated several times, in which
  5356. case the manifests are concatenated.
  5357. This has a similar purpose as the same-named option in @command{guix
  5358. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  5359. same manifest files. It allows you to define a collection of packages
  5360. once and use it both for creating profiles and for creating archives
  5361. for use on machines that do not have Guix installed. Note that you can
  5362. specify @emph{either} a manifest file @emph{or} a list of packages,
  5363. but not both.
  5364. @item --system=@var{system}
  5365. @itemx -s @var{system}
  5366. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5367. the system type of the build host.
  5368. @item --target=@var{triplet}
  5369. @cindex cross-compilation
  5370. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5371. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5372. configuration triplets,, autoconf, Autoconf}).
  5373. @item --compression=@var{tool}
  5374. @itemx -C @var{tool}
  5375. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  5376. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  5377. compression.
  5378. @item --symlink=@var{spec}
  5379. @itemx -S @var{spec}
  5380. Add the symlinks specified by @var{spec} to the pack. This option can
  5381. appear several times.
  5382. @var{spec} has the form @code{@var{source}=@var{target}}, where
  5383. @var{source} is the symlink that will be created and @var{target} is the
  5384. symlink target.
  5385. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  5386. symlink pointing to the @file{bin} sub-directory of the profile.
  5387. @item --save-provenance
  5388. Save provenance information for the packages passed on the command line.
  5389. Provenance information includes the URL and commit of the channels in use
  5390. (@pxref{Channels}).
  5391. Provenance information is saved in the
  5392. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  5393. usual package metadata---the name and version of each package, their
  5394. propagated inputs, and so on. It is useful information to the recipient of
  5395. the pack, who then knows how the pack was (supposedly) obtained.
  5396. This option is not enabled by default because, like timestamps, provenance
  5397. information contributes nothing to the build process. In other words, there
  5398. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  5399. Recording such ``silent'' metadata in the output thus potentially breaks the
  5400. source-to-binary bitwise reproducibility property.
  5401. @item --root=@var{file}
  5402. @itemx -r @var{file}
  5403. @cindex garbage collector root, for packs
  5404. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  5405. collector root.
  5406. @item --localstatedir
  5407. @itemx --profile-name=@var{name}
  5408. Include the ``local state directory'', @file{/var/guix}, in the resulting
  5409. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  5410. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  5411. @file{~root/.guix-profile}.
  5412. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  5413. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  5414. the pack means that the store is ``complete'' and manageable by Guix;
  5415. not providing it pack means that the store is ``dead'': items cannot be
  5416. added to it or removed from it after extraction of the pack.
  5417. One use case for this is the Guix self-contained binary tarball
  5418. (@pxref{Binary Installation}).
  5419. @item --derivation
  5420. @itemx -d
  5421. Print the name of the derivation that builds the pack.
  5422. @item --bootstrap
  5423. Use the bootstrap binaries to build the pack. This option is only
  5424. useful to Guix developers.
  5425. @end table
  5426. In addition, @command{guix pack} supports all the common build options
  5427. (@pxref{Common Build Options}) and all the package transformation
  5428. options (@pxref{Package Transformation Options}).
  5429. @node The GCC toolchain
  5430. @section The GCC toolchain
  5431. @cindex GCC
  5432. @cindex ld-wrapper
  5433. @cindex linker wrapper
  5434. @cindex toolchain, for C development
  5435. @cindex toolchain, for Fortran development
  5436. If you need a complete toolchain for compiling and linking C or C++
  5437. source code, use the @code{gcc-toolchain} package. This package
  5438. provides a complete GCC toolchain for C/C++ development, including GCC
  5439. itself, the GNU C Library (headers and binaries, plus debugging symbols
  5440. in the @code{debug} output), Binutils, and a linker wrapper.
  5441. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  5442. passed to the linker, add corresponding @code{-rpath} arguments, and
  5443. invoke the actual linker with this new set of arguments. You can instruct the
  5444. wrapper to refuse to link against libraries not in the store by setting the
  5445. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  5446. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  5447. for Fortran development. For other languages, please use
  5448. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  5449. @node Invoking guix git authenticate
  5450. @section Invoking @command{guix git authenticate}
  5451. The @command{guix git authenticate} command authenticates a Git checkout
  5452. following the same rule as for channels (@pxref{channel-authentication,
  5453. channel authentication}). That is, starting from a given commit, it
  5454. ensures that all subsequent commits are signed by an OpenPGP key whose
  5455. fingerprint appears in the @file{.guix-authorizations} file of its
  5456. parent commit(s).
  5457. You will find this command useful if you maintain a channel. But in
  5458. fact, this authentication mechanism is useful in a broader context, so
  5459. you might want to use it for Git repositories that have nothing to do
  5460. with Guix.
  5461. The general syntax is:
  5462. @example
  5463. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  5464. @end example
  5465. By default, this command authenticates the Git checkout in the current
  5466. directory; it outputs nothing and exits with exit code zero on success
  5467. and non-zero on failure. @var{commit} above denotes the first commit
  5468. where authentication takes place, and @var{signer} is the OpenPGP
  5469. fingerprint of public key used to sign @var{commit}. Together, they
  5470. form a ``channel introduction'' (@pxref{channel-authentication, channel
  5471. introduction}). The options below allow you to fine-tune the process.
  5472. @table @code
  5473. @item --repository=@var{directory}
  5474. @itemx -r @var{directory}
  5475. Open the Git repository in @var{directory} instead of the current
  5476. directory.
  5477. @item --keyring=@var{reference}
  5478. @itemx -k @var{reference}
  5479. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5480. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5481. contain OpenPGP public keys in @file{.key} files, either in binary form
  5482. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5483. named @code{keyring}.
  5484. @item --stats
  5485. Display commit signing statistics upon completion.
  5486. @item --cache-key=@var{key}
  5487. Previously-authenticated commits are cached in a file under
  5488. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5489. stored in file @var{key} in that directory.
  5490. @item --historical-authorizations=@var{file}
  5491. By default, any commit whose parent commit(s) lack the
  5492. @file{.guix-authorizations} file is considered inauthentic. In
  5493. contrast, this option considers the authorizations in @var{file} for any
  5494. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5495. is the same as that of @file{.guix-authorizations}
  5496. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5497. @end table
  5498. @c *********************************************************************
  5499. @node Programming Interface
  5500. @chapter Programming Interface
  5501. GNU Guix provides several Scheme programming interfaces (APIs) to
  5502. define, build, and query packages. The first interface allows users to
  5503. write high-level package definitions. These definitions refer to
  5504. familiar packaging concepts, such as the name and version of a package,
  5505. its build system, and its dependencies. These definitions can then be
  5506. turned into concrete build actions.
  5507. Build actions are performed by the Guix daemon, on behalf of users. In a
  5508. standard setup, the daemon has write access to the store---the
  5509. @file{/gnu/store} directory---whereas users do not. The recommended
  5510. setup also has the daemon perform builds in chroots, under specific
  5511. build users, to minimize interference with the rest of the system.
  5512. @cindex derivation
  5513. Lower-level APIs are available to interact with the daemon and the
  5514. store. To instruct the daemon to perform a build action, users actually
  5515. provide it with a @dfn{derivation}. A derivation is a low-level
  5516. representation of the build actions to be taken, and the environment in
  5517. which they should occur---derivations are to package definitions what
  5518. assembly is to C programs. The term ``derivation'' comes from the fact
  5519. that build results @emph{derive} from them.
  5520. This chapter describes all these APIs in turn, starting from high-level
  5521. package definitions.
  5522. @menu
  5523. * Package Modules:: Packages from the programmer's viewpoint.
  5524. * Defining Packages:: Defining new packages.
  5525. * Defining Package Variants:: Customizing packages.
  5526. * Build Systems:: Specifying how packages are built.
  5527. * Build Phases:: Phases of the build process of a package.
  5528. * Build Utilities:: Helpers for your package definitions and more.
  5529. * The Store:: Manipulating the package store.
  5530. * Derivations:: Low-level interface to package derivations.
  5531. * The Store Monad:: Purely functional interface to the store.
  5532. * G-Expressions:: Manipulating build expressions.
  5533. * Invoking guix repl:: Programming Guix in Guile
  5534. @end menu
  5535. @node Package Modules
  5536. @section Package Modules
  5537. From a programming viewpoint, the package definitions of the
  5538. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5539. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5540. packages @dots{})} module name space are not necessarily ``GNU
  5541. packages''. This module naming scheme follows the usual Guile module
  5542. naming convention: @code{gnu} means that these modules are distributed
  5543. as part of the GNU system, and @code{packages} identifies modules that
  5544. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5545. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5546. module exports a variable named @code{emacs}, which is bound to a
  5547. @code{<package>} object (@pxref{Defining Packages}).
  5548. The @code{(gnu packages @dots{})} module name space is
  5549. automatically scanned for packages by the command-line tools. For
  5550. instance, when running @code{guix install emacs}, all the @code{(gnu
  5551. packages @dots{})} modules are scanned until one that exports a package
  5552. object whose name is @code{emacs} is found. This package search
  5553. facility is implemented in the @code{(gnu packages)} module.
  5554. @cindex customization, of packages
  5555. @cindex package module search path
  5556. Users can store package definitions in modules with different
  5557. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5558. name and module name must match. For instance, the @code{(my-packages
  5559. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5560. relative to the load path specified with @option{--load-path} or
  5561. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5562. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5563. these package definitions visible to the user interfaces:
  5564. @enumerate
  5565. @item
  5566. By adding the directory containing your package modules to the search path
  5567. with the @code{-L} flag of @command{guix package} and other commands
  5568. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5569. environment variable described below.
  5570. @item
  5571. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5572. pulls from it. A channel is essentially a Git repository containing package
  5573. modules. @xref{Channels}, for more information on how to define and use
  5574. channels.
  5575. @end enumerate
  5576. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5577. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5578. This is a colon-separated list of directories to search for additional
  5579. package modules. Directories listed in this variable take precedence
  5580. over the own modules of the distribution.
  5581. @end defvr
  5582. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5583. each package is built based solely on other packages in the
  5584. distribution. The root of this dependency graph is a small set of
  5585. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5586. bootstrap)} module. For more information on bootstrapping,
  5587. @pxref{Bootstrapping}.
  5588. @node Defining Packages
  5589. @section Defining Packages
  5590. The high-level interface to package definitions is implemented in the
  5591. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5592. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5593. package looks like this:
  5594. @lisp
  5595. (define-module (gnu packages hello)
  5596. #:use-module (guix packages)
  5597. #:use-module (guix download)
  5598. #:use-module (guix build-system gnu)
  5599. #:use-module (guix licenses)
  5600. #:use-module (gnu packages gawk))
  5601. (define-public hello
  5602. (package
  5603. (name "hello")
  5604. (version "2.10")
  5605. (source (origin
  5606. (method url-fetch)
  5607. (uri (string-append "mirror://gnu/hello/hello-" version
  5608. ".tar.gz"))
  5609. (sha256
  5610. (base32
  5611. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5612. (build-system gnu-build-system)
  5613. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5614. (inputs (list gawk))
  5615. (synopsis "Hello, GNU world: An example GNU package")
  5616. (description "Guess what GNU Hello prints!")
  5617. (home-page "https://www.gnu.org/software/hello/")
  5618. (license gpl3+)))
  5619. @end lisp
  5620. @noindent
  5621. Without being a Scheme expert, the reader may have guessed the meaning
  5622. of the various fields here. This expression binds the variable
  5623. @code{hello} to a @code{<package>} object, which is essentially a record
  5624. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5625. This package object can be inspected using procedures found in the
  5626. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5627. returns---surprise!---@code{"hello"}.
  5628. With luck, you may be able to import part or all of the definition of
  5629. the package you are interested in from another repository, using the
  5630. @code{guix import} command (@pxref{Invoking guix import}).
  5631. In the example above, @code{hello} is defined in a module of its own,
  5632. @code{(gnu packages hello)}. Technically, this is not strictly
  5633. necessary, but it is convenient to do so: all the packages defined in
  5634. modules under @code{(gnu packages @dots{})} are automatically known to
  5635. the command-line tools (@pxref{Package Modules}).
  5636. There are a few points worth noting in the above package definition:
  5637. @itemize
  5638. @item
  5639. The @code{source} field of the package is an @code{<origin>} object
  5640. (@pxref{origin Reference}, for the complete reference).
  5641. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5642. meaning that the source is a file to be downloaded over FTP or HTTP.
  5643. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5644. the GNU mirrors defined in @code{(guix download)}.
  5645. The @code{sha256} field specifies the expected SHA256 hash of the file
  5646. being downloaded. It is mandatory, and allows Guix to check the
  5647. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5648. base32 representation of the hash. You can obtain this information with
  5649. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5650. hash} (@pxref{Invoking guix hash}).
  5651. @cindex patches
  5652. When needed, the @code{origin} form can also have a @code{patches} field
  5653. listing patches to be applied, and a @code{snippet} field giving a
  5654. Scheme expression to modify the source code.
  5655. @item
  5656. @cindex GNU Build System
  5657. The @code{build-system} field specifies the procedure to build the
  5658. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5659. represents the familiar GNU Build System, where packages may be
  5660. configured, built, and installed with the usual @code{./configure &&
  5661. make && make check && make install} command sequence.
  5662. When you start packaging non-trivial software, you may need tools to
  5663. manipulate those build phases, manipulate files, and so on. @xref{Build
  5664. Utilities}, for more on this.
  5665. @item
  5666. The @code{arguments} field specifies options for the build system
  5667. (@pxref{Build Systems}). Here it is interpreted by
  5668. @code{gnu-build-system} as a request run @file{configure} with the
  5669. @option{--enable-silent-rules} flag.
  5670. @cindex quote
  5671. @cindex quoting
  5672. @findex '
  5673. @findex quote
  5674. @cindex backquote (quasiquote)
  5675. @findex `
  5676. @findex quasiquote
  5677. @cindex comma (unquote)
  5678. @findex ,
  5679. @findex unquote
  5680. What about these quote (@code{'}) characters? They are Scheme syntax to
  5681. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5682. Sometimes you'll also see @code{`} (a backquote, synonymous with
  5683. @code{quasiquote}) and @code{,} (a comma, synonymous with @code{unquote}).
  5684. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5685. for details. Here the value of the @code{arguments} field is a list of
  5686. arguments passed to the build system down the road, as with @code{apply}
  5687. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5688. Manual}).
  5689. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5690. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5691. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5692. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5693. Reference Manual}).
  5694. @item
  5695. The @code{inputs} field specifies inputs to the build process---i.e.,
  5696. build-time or run-time dependencies of the package. Here, we add
  5697. an input, a reference to the @code{gawk}
  5698. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5699. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5700. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5701. of ensuring that they are present (@pxref{Build Systems}).
  5702. However, any other dependencies need to be specified in the
  5703. @code{inputs} field. Any dependency not specified here will simply be
  5704. unavailable to the build process, possibly leading to a build failure.
  5705. @end itemize
  5706. @xref{package Reference}, for a full description of possible fields.
  5707. Once a package definition is in place, the
  5708. package may actually be built using the @code{guix build} command-line
  5709. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5710. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5711. package definition using the @command{guix edit} command
  5712. (@pxref{Invoking guix edit}).
  5713. @xref{Packaging Guidelines}, for
  5714. more information on how to test package definitions, and
  5715. @ref{Invoking guix lint}, for information on how to check a definition
  5716. for style conformance.
  5717. @vindex GUIX_PACKAGE_PATH
  5718. Lastly, @pxref{Channels}, for information
  5719. on how to extend the distribution by adding your own package definitions
  5720. in a ``channel''.
  5721. Finally, updating the package definition to a new upstream version
  5722. can be partly automated by the @command{guix refresh} command
  5723. (@pxref{Invoking guix refresh}).
  5724. Behind the scenes, a derivation corresponding to the @code{<package>}
  5725. object is first computed by the @code{package-derivation} procedure.
  5726. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5727. The build actions it prescribes may then be realized by using the
  5728. @code{build-derivations} procedure (@pxref{The Store}).
  5729. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5730. Return the @code{<derivation>} object of @var{package} for @var{system}
  5731. (@pxref{Derivations}).
  5732. @var{package} must be a valid @code{<package>} object, and @var{system}
  5733. must be a string denoting the target system type---e.g.,
  5734. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5735. must be a connection to the daemon, which operates on the store
  5736. (@pxref{The Store}).
  5737. @end deffn
  5738. @noindent
  5739. @cindex cross-compilation
  5740. Similarly, it is possible to compute a derivation that cross-builds a
  5741. package for some other system:
  5742. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5743. @var{package} @var{target} [@var{system}]
  5744. Return the @code{<derivation>} object of @var{package} cross-built from
  5745. @var{system} to @var{target}.
  5746. @var{target} must be a valid GNU triplet denoting the target hardware
  5747. and operating system, such as @code{"aarch64-linux-gnu"}
  5748. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5749. @end deffn
  5750. Once you have package definitions, you can easily define @emph{variants}
  5751. of those packages. @xref{Defining Package Variants}, for more on that.
  5752. @menu
  5753. * package Reference:: The package data type.
  5754. * origin Reference:: The origin data type.
  5755. @end menu
  5756. @node package Reference
  5757. @subsection @code{package} Reference
  5758. This section summarizes all the options available in @code{package}
  5759. declarations (@pxref{Defining Packages}).
  5760. @deftp {Data Type} package
  5761. This is the data type representing a package recipe.
  5762. @table @asis
  5763. @item @code{name}
  5764. The name of the package, as a string.
  5765. @item @code{version}
  5766. The version of the package, as a string. @xref{Version Numbers}, for
  5767. guidelines.
  5768. @item @code{source}
  5769. An object telling how the source code for the package should be
  5770. acquired. Most of the time, this is an @code{origin} object, which
  5771. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5772. can also be any other ``file-like'' object such as a @code{local-file},
  5773. which denotes a file from the local file system (@pxref{G-Expressions,
  5774. @code{local-file}}).
  5775. @item @code{build-system}
  5776. The build system that should be used to build the package (@pxref{Build
  5777. Systems}).
  5778. @item @code{arguments} (default: @code{'()})
  5779. The arguments that should be passed to the build system. This is a
  5780. list, typically containing sequential keyword-value pairs.
  5781. @item @code{inputs} (default: @code{'()})
  5782. @itemx @code{native-inputs} (default: @code{'()})
  5783. @itemx @code{propagated-inputs} (default: @code{'()})
  5784. @cindex inputs, of packages
  5785. These fields list dependencies of the package. Each element of these
  5786. lists is either a package, origin, or other ``file-like object''
  5787. (@pxref{G-Expressions}); to specify the output of that file-like object
  5788. that should be used, pass a two-element list where the second element is
  5789. the output (@pxref{Packages with Multiple Outputs}, for more on package
  5790. outputs). For example, the list below specifies three inputs:
  5791. @lisp
  5792. (list libffi libunistring
  5793. `(,glib "bin")) ;the "bin" output of GLib
  5794. @end lisp
  5795. In the example above, the @code{"out"} output of @code{libffi} and
  5796. @code{libunistring} is used.
  5797. @quotation Compatibility Note
  5798. Until version 1.3.0, input lists were a list of tuples,
  5799. where each tuple has a label for the input (a string) as its
  5800. first element, a package, origin, or derivation as its second element,
  5801. and optionally the name of the output thereof that should be used, which
  5802. defaults to @code{"out"}. For example, the list below is equivalent to
  5803. the one above, but using the @dfn{old input style}:
  5804. @lisp
  5805. ;; Old input style (deprecated).
  5806. `(("libffi" ,libffi)
  5807. ("libunistring" ,libunistring)
  5808. ("glib:bin" ,glib "bin")) ;the "bin" output of GLib
  5809. @end lisp
  5810. This style is now deprecated; it is still supported but support will be
  5811. removed in a future version. It should not be used for new package
  5812. definitions. @xref{Invoking guix style}, on how to migrate to the new
  5813. style.
  5814. @end quotation
  5815. @cindex cross compilation, package dependencies
  5816. The distinction between @code{native-inputs} and @code{inputs} is
  5817. necessary when considering cross-compilation. When cross-compiling,
  5818. dependencies listed in @code{inputs} are built for the @emph{target}
  5819. architecture; conversely, dependencies listed in @code{native-inputs}
  5820. are built for the architecture of the @emph{build} machine.
  5821. @code{native-inputs} is typically used to list tools needed at
  5822. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5823. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5824. this area (@pxref{Invoking guix lint}).
  5825. @anchor{package-propagated-inputs}
  5826. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5827. specified packages will be automatically installed to profiles
  5828. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5829. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5830. package}}, for information on how @command{guix package} deals with
  5831. propagated inputs).
  5832. For example this is necessary when packaging a C/C++ library that needs
  5833. headers of another library to compile, or when a pkg-config file refers
  5834. to another one @i{via} its @code{Requires} field.
  5835. Another example where @code{propagated-inputs} is useful is for languages
  5836. that lack a facility to record the run-time search path akin to the
  5837. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5838. more. When packaging libraries written in those languages, ensure they
  5839. can find library code they depend on at run time by listing run-time
  5840. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5841. @item @code{outputs} (default: @code{'("out")})
  5842. The list of output names of the package. @xref{Packages with Multiple
  5843. Outputs}, for typical uses of additional outputs.
  5844. @item @code{native-search-paths} (default: @code{'()})
  5845. @itemx @code{search-paths} (default: @code{'()})
  5846. A list of @code{search-path-specification} objects describing
  5847. search-path environment variables honored by the package.
  5848. @item @code{replacement} (default: @code{#f})
  5849. This must be either @code{#f} or a package object that will be used as a
  5850. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5851. for details.
  5852. @item @code{synopsis}
  5853. A one-line description of the package.
  5854. @item @code{description}
  5855. A more elaborate description of the package.
  5856. @item @code{license}
  5857. @cindex license, of packages
  5858. The license of the package; a value from @code{(guix licenses)},
  5859. or a list of such values.
  5860. @item @code{home-page}
  5861. The URL to the home-page of the package, as a string.
  5862. @item @code{supported-systems} (default: @code{%supported-systems})
  5863. The list of systems supported by the package, as strings of the form
  5864. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5865. @item @code{location} (default: source location of the @code{package} form)
  5866. The source location of the package. It is useful to override this when
  5867. inheriting from another package, in which case this field is not
  5868. automatically corrected.
  5869. @end table
  5870. @end deftp
  5871. @deffn {Scheme Syntax} this-package
  5872. When used in the @emph{lexical scope} of a package field definition, this
  5873. identifier resolves to the package being defined.
  5874. The example below shows how to add a package as a native input of itself when
  5875. cross-compiling:
  5876. @lisp
  5877. (package
  5878. (name "guile")
  5879. ;; ...
  5880. ;; When cross-compiled, Guile, for example, depends on
  5881. ;; a native version of itself. Add it here.
  5882. (native-inputs (if (%current-target-system)
  5883. (list this-package)
  5884. '())))
  5885. @end lisp
  5886. It is an error to refer to @code{this-package} outside a package definition.
  5887. @end deffn
  5888. The following helper procedures are provided to help deal with package
  5889. inputs.
  5890. @deffn {Scheme Procedure} lookup-package-input @var{package} @var{name}
  5891. @deffnx {Scheme Procedure} lookup-package-native-input @var{package} @var{name}
  5892. @deffnx {Scheme Procedure} lookup-package-propagated-input @var{package} @var{name}
  5893. @deffnx {Scheme Procedure} lookup-package-direct-input @var{package} @var{name}
  5894. Look up @var{name} among @var{package}'s inputs (or native, propagated,
  5895. or direct inputs). Return it if found, @code{#f} otherwise.
  5896. @var{name} is the name of a package depended on. Here's how you might
  5897. use it:
  5898. @lisp
  5899. (use-modules (guix packages) (gnu packages base))
  5900. (lookup-package-direct-input coreutils "gmp")
  5901. @result{} #<package gmp@@6.2.1 @dots{}>
  5902. @end lisp
  5903. In this example we obtain the @code{gmp} package that is among the
  5904. direct inputs of @code{coreutils}.
  5905. @end deffn
  5906. @cindex development inputs, of a package
  5907. @cindex implicit inputs, of a package
  5908. Sometimes you will want to obtain the list of inputs needed to
  5909. @emph{develop} a package---all the inputs that are visible when the
  5910. package is compiled. This is what the @code{package-development-inputs}
  5911. procedure returns.
  5912. @deffn {Scheme Procedure} package-development-inputs @var{package} @
  5913. [@var{system}] [#:target #f]
  5914. Return the list of inputs required by @var{package} for development
  5915. purposes on @var{system}. When @var{target} is true, return the inputs
  5916. needed to cross-compile @var{package} from @var{system} to
  5917. @var{triplet}, where @var{triplet} is a triplet such as
  5918. @code{"aarch64-linux-gnu"}.
  5919. Note that the result includes both explicit inputs and implicit
  5920. inputs---inputs automatically added by the build system (@pxref{Build
  5921. Systems}). Let us take the @code{hello} package to illustrate that:
  5922. @lisp
  5923. (use-modules (gnu packages base) (guix packages))
  5924. hello
  5925. @result{} #<package hello@@2.10 gnu/packages/base.scm:79 7f585d4f6790>
  5926. (package-direct-inputs hello)
  5927. @result{} ()
  5928. (package-development-inputs hello)
  5929. @result{} (("source" @dots{}) ("tar" #<package tar@@1.32 @dots{}>) @dots{})
  5930. @end lisp
  5931. In this example, @code{package-direct-inputs} returns the empty list,
  5932. because @code{hello} has zero explicit dependencies. Conversely,
  5933. @code{package-development-inputs} includes inputs implicitly added by
  5934. @code{gnu-build-system} that are required to build @code{hello}: tar,
  5935. gzip, GCC, libc, Bash, and more. To visualize it, @command{guix graph
  5936. hello} would show you explicit inputs, whereas @command{guix graph -t
  5937. bag hello} would include implicit inputs (@pxref{Invoking guix graph}).
  5938. @end deffn
  5939. Because packages are regular Scheme objects that capture a complete
  5940. dependency graph and associated build procedures, it is often useful to
  5941. write procedures that take a package and return a modified version
  5942. thereof according to some parameters. Below are a few examples.
  5943. @cindex tool chain, choosing a package's tool chain
  5944. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  5945. Return a variant of @var{package} that uses @var{toolchain} instead of
  5946. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  5947. inputs (label/package tuples) providing equivalent functionality, such
  5948. as the @code{gcc-toolchain} package.
  5949. The example below returns a variant of the @code{hello} package built
  5950. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  5951. GNU C Library) instead of the default tool chain:
  5952. @lisp
  5953. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  5954. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  5955. @end lisp
  5956. The build tool chain is part of the @dfn{implicit inputs} of
  5957. packages---it's usually not listed as part of the various ``inputs''
  5958. fields and is instead pulled in by the build system. Consequently, this
  5959. procedure works by changing the build system of @var{package} so that it
  5960. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  5961. for more on build systems.
  5962. @end deffn
  5963. @node origin Reference
  5964. @subsection @code{origin} Reference
  5965. This section documents @dfn{origins}. An @code{origin} declaration
  5966. specifies data that must be ``produced''---downloaded, usually---and
  5967. whose content hash is known in advance. Origins are primarily used to
  5968. represent the source code of packages (@pxref{Defining Packages}). For
  5969. that reason, the @code{origin} form allows you to declare patches to
  5970. apply to the original source code as well as code snippets to modify it.
  5971. @deftp {Data Type} origin
  5972. This is the data type representing a source code origin.
  5973. @table @asis
  5974. @item @code{uri}
  5975. An object containing the URI of the source. The object type depends on
  5976. the @code{method} (see below). For example, when using the
  5977. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5978. values are: a URL represented as a string, or a list thereof.
  5979. @cindex fixed-output derivations, for download
  5980. @item @code{method}
  5981. A monadic procedure that handles the given URI@. The procedure must
  5982. accept at least three arguments: the value of the @code{uri} field and
  5983. the hash algorithm and hash value specified by the @code{hash} field.
  5984. It must return a store item or a derivation in the store monad
  5985. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  5986. (@pxref{Derivations}).
  5987. Commonly used methods include @code{url-fetch}, which fetches data from
  5988. a URL, and @code{git-fetch}, which fetches data from a Git repository
  5989. (see below).
  5990. @item @code{sha256}
  5991. A bytevector containing the SHA-256 hash of the source. This is
  5992. equivalent to providing a @code{content-hash} SHA256 object in the
  5993. @code{hash} field described below.
  5994. @item @code{hash}
  5995. The @code{content-hash} object of the source---see below for how to use
  5996. @code{content-hash}.
  5997. You can obtain this information using @code{guix download}
  5998. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5999. guix hash}).
  6000. @item @code{file-name} (default: @code{#f})
  6001. The file name under which the source code should be saved. When this is
  6002. @code{#f}, a sensible default value will be used in most cases. In case
  6003. the source is fetched from a URL, the file name from the URL will be
  6004. used. For version control checkouts, it is recommended to provide the
  6005. file name explicitly because the default is not very descriptive.
  6006. @item @code{patches} (default: @code{'()})
  6007. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  6008. file-like objects}) pointing to patches to be applied to the source.
  6009. This list of patches must be unconditional. In particular, it cannot
  6010. depend on the value of @code{%current-system} or
  6011. @code{%current-target-system}.
  6012. @item @code{snippet} (default: @code{#f})
  6013. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  6014. in the source directory. This is a convenient way to modify the source,
  6015. sometimes more convenient than a patch.
  6016. @item @code{patch-flags} (default: @code{'("-p1")})
  6017. A list of command-line flags that should be passed to the @code{patch}
  6018. command.
  6019. @item @code{patch-inputs} (default: @code{#f})
  6020. Input packages or derivations to the patching process. When this is
  6021. @code{#f}, the usual set of inputs necessary for patching are provided,
  6022. such as GNU@tie{}Patch.
  6023. @item @code{modules} (default: @code{'()})
  6024. A list of Guile modules that should be loaded during the patching
  6025. process and while running the code in the @code{snippet} field.
  6026. @item @code{patch-guile} (default: @code{#f})
  6027. The Guile package that should be used in the patching process. When
  6028. this is @code{#f}, a sensible default is used.
  6029. @end table
  6030. @end deftp
  6031. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  6032. Construct a content hash object for the given @var{algorithm}, and with
  6033. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  6034. it is @code{sha256}.
  6035. @var{value} can be a literal string, in which case it is base32-decoded,
  6036. or it can be a bytevector.
  6037. The following forms are all equivalent:
  6038. @lisp
  6039. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  6040. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  6041. sha256)
  6042. (content-hash (base32
  6043. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  6044. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  6045. sha256)
  6046. @end lisp
  6047. Technically, @code{content-hash} is currently implemented as a macro.
  6048. It performs sanity checks at macro-expansion time, when possible, such
  6049. as ensuring that @var{value} has the right size for @var{algorithm}.
  6050. @end deftp
  6051. As we have seen above, how exactly the data an origin refers to is
  6052. retrieved is determined by its @code{method} field. The @code{(guix
  6053. download)} module provides the most common method, @code{url-fetch},
  6054. described below.
  6055. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  6056. [name] [#:executable? #f]
  6057. Return a fixed-output derivation that fetches data from @var{url} (a
  6058. string, or a list of strings denoting alternate URLs), which is expected
  6059. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  6060. the file name is the base name of URL; optionally, @var{name} can
  6061. specify a different file name. When @var{executable?} is true, make the
  6062. downloaded file executable.
  6063. When one of the URL starts with @code{mirror://}, then its host part is
  6064. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  6065. Alternatively, when URL starts with @code{file://}, return the
  6066. corresponding file name in the store.
  6067. @end deffn
  6068. Likewise, the @code{(guix git-download)} module defines the
  6069. @code{git-fetch} origin method, which fetches data from a Git version
  6070. control repository, and the @code{git-reference} data type to describe
  6071. the repository and revision to fetch.
  6072. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  6073. Return a fixed-output derivation that fetches @var{ref}, a
  6074. @code{<git-reference>} object. The output is expected to have recursive
  6075. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6076. the file name, or a generic name if @code{#f}.
  6077. @end deffn
  6078. @deftp {Data Type} git-reference
  6079. This data type represents a Git reference for @code{git-fetch} to
  6080. retrieve.
  6081. @table @asis
  6082. @item @code{url}
  6083. The URL of the Git repository to clone.
  6084. @item @code{commit}
  6085. This string denotes either the commit to fetch (a hexadecimal string),
  6086. or the tag to fetch. You can also use a ``short'' commit ID or a
  6087. @command{git describe} style identifier such as
  6088. @code{v1.0.1-10-g58d7909c97}.
  6089. @item @code{recursive?} (default: @code{#f})
  6090. This Boolean indicates whether to recursively fetch Git sub-modules.
  6091. @end table
  6092. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  6093. repository:
  6094. @lisp
  6095. (git-reference
  6096. (url "https://git.savannah.gnu.org/git/hello.git")
  6097. (commit "v2.10"))
  6098. @end lisp
  6099. This is equivalent to the reference below, which explicitly names the
  6100. commit:
  6101. @lisp
  6102. (git-reference
  6103. (url "https://git.savannah.gnu.org/git/hello.git")
  6104. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  6105. @end lisp
  6106. @end deftp
  6107. For Mercurial repositories, the module @code{(guix hg-download)} defines
  6108. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  6109. support of the Mercurial version control system.
  6110. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  6111. [name]
  6112. Return a fixed-output derivation that fetches @var{ref}, a
  6113. @code{<hg-reference>} object. The output is expected to have recursive
  6114. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6115. the file name, or a generic name if @code{#false}.
  6116. @end deffn
  6117. @node Defining Package Variants
  6118. @section Defining Package Variants
  6119. @cindex customizing packages
  6120. @cindex variants, of packages
  6121. One of the nice things with Guix is that, given a package definition,
  6122. you can easily @emph{derive} variants of that package---for a different
  6123. upstream version, with different dependencies, different compilation
  6124. options, and so on. Some of these custom packages can be defined
  6125. straight from the command line (@pxref{Package Transformation Options}).
  6126. This section describes how to define package variants in code. This can
  6127. be useful in ``manifests'' (@pxref{profile-manifest,
  6128. @option{--manifest}}) and in your own package collection
  6129. (@pxref{Creating a Channel}), among others!
  6130. @cindex inherit, for package definitions
  6131. As discussed earlier, packages are first-class objects in the Scheme
  6132. language. The @code{(guix packages)} module provides the @code{package}
  6133. construct to define new package objects (@pxref{package Reference}).
  6134. The easiest way to define a package variant is using the @code{inherit}
  6135. keyword together with @code{package}. This allows you to inherit from a
  6136. package definition while overriding the fields you want.
  6137. For example, given the @code{hello} variable, which contains a
  6138. definition for the current version of GNU@tie{}Hello, here's how you
  6139. would define a variant for version 2.2 (released in 2006, it's
  6140. vintage!):
  6141. @lisp
  6142. (use-modules (gnu packages base)) ;for 'hello'
  6143. (define hello-2.2
  6144. (package
  6145. (inherit hello)
  6146. (version "2.2")
  6147. (source (origin
  6148. (method url-fetch)
  6149. (uri (string-append "mirror://gnu/hello/hello-" version
  6150. ".tar.gz"))
  6151. (sha256
  6152. (base32
  6153. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  6154. @end lisp
  6155. The example above corresponds to what the @option{--with-source} package
  6156. transformation option does. Essentially @code{hello-2.2} preserves all
  6157. the fields of @code{hello}, except @code{version} and @code{source},
  6158. which it overrides. Note that the original @code{hello} variable is
  6159. still there, in the @code{(gnu packages base)} module, unchanged. When
  6160. you define a custom package like this, you are really @emph{adding} a
  6161. new package definition; the original one remains available.
  6162. You can just as well define variants with a different set of
  6163. dependencies than the original package. For example, the default
  6164. @code{gdb} package depends on @code{guile}, but since that is an
  6165. optional dependency, you can define a variant that removes that
  6166. dependency like so:
  6167. @lisp
  6168. (use-modules (gnu packages gdb)) ;for 'gdb'
  6169. (define gdb-sans-guile
  6170. (package
  6171. (inherit gdb)
  6172. (inputs (modify-inputs (package-inputs gdb)
  6173. (delete "guile")))))
  6174. @end lisp
  6175. The @code{modify-inputs} form above removes the @code{"guile"} package
  6176. from the @code{inputs} field of @code{gdb}. The @code{modify-inputs}
  6177. macro is a helper that can prove useful anytime you want to remove, add,
  6178. or replace package inputs.
  6179. @deffn {Scheme Syntax} modify-inputs @var{inputs} @var{clauses}
  6180. Modify the given package inputs, as returned by @code{package-inputs} & co.,
  6181. according to the given clauses. Each clause must have one of the
  6182. following forms:
  6183. @table @code
  6184. @item (delete @var{name}@dots{})
  6185. Delete from the inputs packages with the given @var{name}s (strings).
  6186. @item (append @var{package}@dots{})
  6187. Add @var{package}s to the end of the input list.
  6188. @item (prepend @var{package}@dots{})
  6189. Add @var{package}s to the front of the input list.
  6190. @end table
  6191. The example below removes the GMP and ACL inputs of Coreutils and adds
  6192. libcap to the back of the input list:
  6193. @lisp
  6194. (modify-inputs (package-inputs coreutils)
  6195. (delete "gmp" "acl")
  6196. (append libcap))
  6197. @end lisp
  6198. The example below replaces the @code{guile} package from the inputs of
  6199. @code{guile-redis} with @code{guile-2.2}:
  6200. @lisp
  6201. (modify-inputs (package-inputs guile-redis)
  6202. (replace "guile" guile-2.2))
  6203. @end lisp
  6204. The last type of clause is @code{prepend}, to add inputs to the front of
  6205. the list.
  6206. @end deffn
  6207. In some cases, you may find it useful to write functions
  6208. (``procedures'', in Scheme parlance) that return a package based on some
  6209. parameters. For example, consider the @code{luasocket} library for the
  6210. Lua programming language. We want to create @code{luasocket} packages
  6211. for major versions of Lua. One way to do that is to define a procedure
  6212. that takes a Lua package and returns a @code{luasocket} package that
  6213. depends on it:
  6214. @lisp
  6215. (define (make-lua-socket name lua)
  6216. ;; Return a luasocket package built with LUA.
  6217. (package
  6218. (name name)
  6219. (version "3.0")
  6220. ;; several fields omitted
  6221. (inputs (list lua))
  6222. (synopsis "Socket library for Lua")))
  6223. (define-public lua5.1-socket
  6224. (make-lua-socket "lua5.1-socket" lua-5.1))
  6225. (define-public lua5.2-socket
  6226. (make-lua-socket "lua5.2-socket" lua-5.2))
  6227. @end lisp
  6228. Here we have defined packages @code{lua5.1-socket} and
  6229. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  6230. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  6231. more info on procedures. Having top-level public definitions for these
  6232. two packages means that they can be referred to from the command line
  6233. (@pxref{Package Modules}).
  6234. @cindex package transformations
  6235. These are pretty simple package variants. As a convenience, the
  6236. @code{(guix transformations)} module provides a high-level interface
  6237. that directly maps to the more sophisticated package transformation
  6238. options (@pxref{Package Transformation Options}):
  6239. @deffn {Scheme Procedure} options->transformation @var{opts}
  6240. Return a procedure that, when passed an object to build (package,
  6241. derivation, etc.), applies the transformations specified by @var{opts} and returns
  6242. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  6243. @lisp
  6244. ((with-branch . "guile-gcrypt=master")
  6245. (without-tests . "libgcrypt"))
  6246. @end lisp
  6247. Each symbol names a transformation and the corresponding string is an argument
  6248. to that transformation.
  6249. @end deffn
  6250. For instance, a manifest equivalent to this command:
  6251. @example
  6252. guix build guix \
  6253. --with-branch=guile-gcrypt=master \
  6254. --with-debug-info=zlib
  6255. @end example
  6256. @noindent
  6257. ... would look like this:
  6258. @lisp
  6259. (use-modules (guix transformations))
  6260. (define transform
  6261. ;; The package transformation procedure.
  6262. (options->transformation
  6263. '((with-branch . "guile-gcrypt=master")
  6264. (with-debug-info . "zlib"))))
  6265. (packages->manifest
  6266. (list (transform (specification->package "guix"))))
  6267. @end lisp
  6268. @cindex input rewriting
  6269. @cindex dependency graph rewriting
  6270. The @code{options->transformation} procedure is convenient, but it's
  6271. perhaps also not as flexible as you may like. How is it implemented?
  6272. The astute reader probably noticed that most package transformation
  6273. options go beyond the superficial changes shown in the first examples of
  6274. this section: they involve @dfn{input rewriting}, whereby the dependency
  6275. graph of a package is rewritten by replacing specific inputs by others.
  6276. Dependency graph rewriting, for the purposes of swapping packages in the
  6277. graph, is what the @code{package-input-rewriting} procedure in
  6278. @code{(guix packages)} implements.
  6279. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  6280. [@var{rewrite-name}] [#:deep? #t]
  6281. Return a procedure that, when passed a package, replaces its direct and
  6282. indirect dependencies, including implicit inputs when @var{deep?} is
  6283. true, according to @var{replacements}. @var{replacements} is a list of
  6284. package pairs; the first element of each pair is the package to replace,
  6285. and the second one is the replacement.
  6286. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  6287. the name of a package and returns its new name after rewrite.
  6288. @end deffn
  6289. @noindent
  6290. Consider this example:
  6291. @lisp
  6292. (define libressl-instead-of-openssl
  6293. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  6294. ;; recursively.
  6295. (package-input-rewriting `((,openssl . ,libressl))))
  6296. (define git-with-libressl
  6297. (libressl-instead-of-openssl git))
  6298. @end lisp
  6299. @noindent
  6300. Here we first define a rewriting procedure that replaces @var{openssl}
  6301. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  6302. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  6303. This is exactly what the @option{--with-input} command-line option does
  6304. (@pxref{Package Transformation Options, @option{--with-input}}).
  6305. The following variant of @code{package-input-rewriting} can match packages to
  6306. be replaced by name rather than by identity.
  6307. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  6308. Return a procedure that, given a package, applies the given
  6309. @var{replacements} to all the package graph, including implicit inputs
  6310. unless @var{deep?} is false. @var{replacements} is a list of
  6311. spec/procedures pair; each spec is a package specification such as
  6312. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  6313. package and returns a replacement for that package.
  6314. @end deffn
  6315. The example above could be rewritten this way:
  6316. @lisp
  6317. (define libressl-instead-of-openssl
  6318. ;; Replace all the packages called "openssl" with LibreSSL.
  6319. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  6320. @end lisp
  6321. The key difference here is that, this time, packages are matched by spec and
  6322. not by identity. In other words, any package in the graph that is called
  6323. @code{openssl} will be replaced.
  6324. A more generic procedure to rewrite a package dependency graph is
  6325. @code{package-mapping}: it supports arbitrary changes to nodes in the
  6326. graph.
  6327. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  6328. Return a procedure that, given a package, applies @var{proc} to all the packages
  6329. depended on and returns the resulting package. The procedure stops recursion
  6330. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  6331. applied to implicit inputs as well.
  6332. @end deffn
  6333. @node Build Systems
  6334. @section Build Systems
  6335. @cindex build system
  6336. Each package definition specifies a @dfn{build system} and arguments for
  6337. that build system (@pxref{Defining Packages}). This @code{build-system}
  6338. field represents the build procedure of the package, as well as implicit
  6339. dependencies of that build procedure.
  6340. Build systems are @code{<build-system>} objects. The interface to
  6341. create and manipulate them is provided by the @code{(guix build-system)}
  6342. module, and actual build systems are exported by specific modules.
  6343. @cindex bag (low-level package representation)
  6344. Under the hood, build systems first compile package objects to
  6345. @dfn{bags}. A @dfn{bag} is like a package, but with less
  6346. ornamentation---in other words, a bag is a lower-level representation of
  6347. a package, which includes all the inputs of that package, including some
  6348. that were implicitly added by the build system. This intermediate
  6349. representation is then compiled to a derivation (@pxref{Derivations}).
  6350. The @code{package-with-c-toolchain} is an example of a way to change the
  6351. implicit inputs that a package's build system pulls in (@pxref{package
  6352. Reference, @code{package-with-c-toolchain}}).
  6353. Build systems accept an optional list of @dfn{arguments}. In package
  6354. definitions, these are passed @i{via} the @code{arguments} field
  6355. (@pxref{Defining Packages}). They are typically keyword arguments
  6356. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  6357. Guile Reference Manual}). The value of these arguments is usually
  6358. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  6359. by the daemon (@pxref{Derivations}).
  6360. The main build system is @code{gnu-build-system}, which implements the
  6361. standard build procedure for GNU and many other packages. It
  6362. is provided by the @code{(guix build-system gnu)} module.
  6363. @defvr {Scheme Variable} gnu-build-system
  6364. @code{gnu-build-system} represents the GNU Build System, and variants
  6365. thereof (@pxref{Configuration, configuration and makefile conventions,,
  6366. standards, GNU Coding Standards}).
  6367. @cindex build phases
  6368. In a nutshell, packages using it are configured, built, and installed with
  6369. the usual @code{./configure && make && make check && make install}
  6370. command sequence. In practice, a few additional steps are often needed.
  6371. All these steps are split up in separate @dfn{phases}.
  6372. @xref{Build Phases}, for more info on build phases and ways to customize
  6373. them.
  6374. In addition, this build system ensures that the ``standard'' environment
  6375. for GNU packages is available. This includes tools such as GCC, libc,
  6376. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  6377. build-system gnu)} module for a complete list). We call these the
  6378. @dfn{implicit inputs} of a package, because package definitions do not
  6379. have to mention them.
  6380. This build system supports a number of keyword arguments, which can be
  6381. passed @i{via} the @code{arguments} field of a package. Here are some
  6382. of the main parameters:
  6383. @table @code
  6384. @item #:phases
  6385. This argument specifies build-side code that evaluates to an alist of
  6386. build phases. @xref{Build Phases}, for more information.
  6387. @item #:configure-flags
  6388. This is a list of flags (strings) passed to the @command{configure}
  6389. script. @xref{Defining Packages}, for an example.
  6390. @item #:make-flags
  6391. This list of strings contains flags passed as arguments to
  6392. @command{make} invocations in the @code{build}, @code{check}, and
  6393. @code{install} phases.
  6394. @item #:out-of-source?
  6395. This Boolean, @code{#f} by default, indicates whether to run builds in a
  6396. build directory separate from the source tree.
  6397. When it is true, the @code{configure} phase creates a separate build
  6398. directory, changes to that directory, and runs the @code{configure}
  6399. script from there. This is useful for packages that require it, such as
  6400. @code{glibc}.
  6401. @item #:tests?
  6402. This Boolean, @code{#t} by default, indicates whether the @code{check}
  6403. phase should run the package's test suite.
  6404. @item #:test-target
  6405. This string, @code{"check"} by default, gives the name of the makefile
  6406. target used by the @code{check} phase.
  6407. @item #:parallel-build?
  6408. @itemx #:parallel-tests?
  6409. These Boolean values specify whether to build, respectively run the test
  6410. suite, in parallel, with the @code{-j} flag of @command{make}. When
  6411. they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
  6412. the number specified as the @option{--cores} option of
  6413. @command{guix-daemon} or that of the @command{guix} client command
  6414. (@pxref{Common Build Options, @option{--cores}}).
  6415. @cindex RUNPATH, validation
  6416. @item #:validate-runpath?
  6417. This Boolean, @code{#t} by default, determines whether to ``validate''
  6418. the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
  6419. as executables) previously installed by the @code{install} phase.
  6420. This validation step consists in making sure that all the shared
  6421. libraries needed by an ELF binary, which are listed as
  6422. @code{DT_NEEDED} entries in its @code{PT_DYNAMIC} segment, appear in the
  6423. @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
  6424. running or using those binaries will not result in a ``file not found''
  6425. error at run time. @xref{Options, @option{-rpath},, ld, The GNU
  6426. Linker}, for more information on @code{RUNPATH}.
  6427. @item #:substitutable?
  6428. This Boolean, @code{#t} by default, tells whether the package outputs
  6429. should be substitutable---i.e., whether users should be able to obtain
  6430. substitutes for them instead of building locally (@pxref{Substitutes}).
  6431. @item #:allowed-references
  6432. @itemx #:disallowed-references
  6433. When true, these arguments must be a list of dependencies that must not
  6434. appear among the references of the build results. If, upon build
  6435. completion, some of these references are retained, the build process
  6436. fails.
  6437. This is useful to ensure that a package does not erroneously keep a
  6438. reference to some of it build-time inputs, in cases where doing so
  6439. would, for example, unnecessarily increase its size (@pxref{Invoking
  6440. guix size}).
  6441. @end table
  6442. Most other build systems support these keyword arguments.
  6443. @end defvr
  6444. Other @code{<build-system>} objects are defined to support other
  6445. conventions and tools used by free software packages. They inherit most
  6446. of @code{gnu-build-system}, and differ mainly in the set of inputs
  6447. implicitly added to the build process, and in the list of phases
  6448. executed. Some of these build systems are listed below.
  6449. @defvr {Scheme Variable} ant-build-system
  6450. This variable is exported by @code{(guix build-system ant)}. It
  6451. implements the build procedure for Java packages that can be built with
  6452. @url{https://ant.apache.org/, Ant build tool}.
  6453. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  6454. provided by the @code{icedtea} package to the set of inputs. Different
  6455. packages can be specified with the @code{#:ant} and @code{#:jdk}
  6456. parameters, respectively.
  6457. When the original package does not provide a suitable Ant build file,
  6458. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  6459. build file @file{build.xml} with tasks to build the specified jar
  6460. archive. In this case the parameter @code{#:source-dir} can be used to
  6461. specify the source sub-directory, defaulting to ``src''.
  6462. The @code{#:main-class} parameter can be used with the minimal ant
  6463. buildfile to specify the main class of the resulting jar. This makes the
  6464. jar file executable. The @code{#:test-include} parameter can be used to
  6465. specify the list of junit tests to run. It defaults to
  6466. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  6467. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  6468. because abstract classes cannot be run as tests.
  6469. The parameter @code{#:build-target} can be used to specify the Ant task
  6470. that should be run during the @code{build} phase. By default the
  6471. ``jar'' task will be run.
  6472. @end defvr
  6473. @defvr {Scheme Variable} android-ndk-build-system
  6474. @cindex Android distribution
  6475. @cindex Android NDK build system
  6476. This variable is exported by @code{(guix build-system android-ndk)}. It
  6477. implements a build procedure for Android NDK (native development kit)
  6478. packages using a Guix-specific build process.
  6479. The build system assumes that packages install their public interface
  6480. (header) files to the subdirectory @file{include} of the @code{out} output and
  6481. their libraries to the subdirectory @file{lib} the @code{out} output.
  6482. It's also assumed that the union of all the dependencies of a package
  6483. has no conflicting files.
  6484. For the time being, cross-compilation is not supported - so right now
  6485. the libraries and header files are assumed to be host tools.
  6486. @end defvr
  6487. @defvr {Scheme Variable} asdf-build-system/source
  6488. @defvrx {Scheme Variable} asdf-build-system/sbcl
  6489. @defvrx {Scheme Variable} asdf-build-system/ecl
  6490. These variables, exported by @code{(guix build-system asdf)}, implement
  6491. build procedures for Common Lisp packages using
  6492. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  6493. definition facility for Common Lisp programs and libraries.
  6494. The @code{asdf-build-system/source} system installs the packages in
  6495. source form, and can be loaded using any common lisp implementation, via
  6496. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  6497. systems in the format which a particular implementation understands.
  6498. These build systems can also be used to produce executable programs, or
  6499. lisp images which contain a set of packages pre-loaded.
  6500. The build system uses naming conventions. For binary packages, the
  6501. package name should be prefixed with the lisp implementation, such as
  6502. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  6503. Additionally, the corresponding source package should be labeled using
  6504. the same convention as python packages (see @ref{Python Modules}), using
  6505. the @code{cl-} prefix.
  6506. In order to create executable programs and images, the build-side
  6507. procedures @code{build-program} and @code{build-image} can be used.
  6508. They should be called in a build phase after the
  6509. @code{create-asdf-configuration} phase, so that the system which was
  6510. just built can be used within the resulting image. @code{build-program}
  6511. requires a list of Common Lisp expressions to be passed as the
  6512. @code{#:entry-program} argument.
  6513. By default, all the @file{.asd} files present in the sources are read to
  6514. find system definitions. The @code{#:asd-files} parameter can be used
  6515. to specify the list of @file{.asd} files to read. Furthermore, if the
  6516. package defines a system for its tests in a separate file, it will be
  6517. loaded before the tests are run if it is specified by the
  6518. @code{#:test-asd-file} parameter. If it is not set, the files
  6519. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  6520. and @code{test.asd} will be tried if they exist.
  6521. If for some reason the package must be named in a different way than the
  6522. naming conventions suggest, or if several systems must be compiled, the
  6523. @code{#:asd-systems} parameter can be used to specify the list of system
  6524. names.
  6525. @end defvr
  6526. @defvr {Scheme Variable} cargo-build-system
  6527. @cindex Rust programming language
  6528. @cindex Cargo (Rust build system)
  6529. This variable is exported by @code{(guix build-system cargo)}. It
  6530. supports builds of packages using Cargo, the build tool of the
  6531. @uref{https://www.rust-lang.org, Rust programming language}.
  6532. It adds @code{rustc} and @code{cargo} to the set of inputs.
  6533. A different Rust package can be specified with the @code{#:rust} parameter.
  6534. Regular cargo dependencies should be added to the package definition similarly
  6535. to other packages; those needed only at build time to native-inputs, others to
  6536. inputs. If you need to add source-only crates then you should add them to via
  6537. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  6538. spec can be a package or a source definition. Note that the spec must
  6539. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  6540. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  6541. should be added to the package definition via the
  6542. @code{#:cargo-development-inputs} parameter.
  6543. In its @code{configure} phase, this build system will make any source inputs
  6544. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  6545. parameters available to cargo. It will also remove an included
  6546. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  6547. @code{build} phase. The @code{package} phase will run @code{cargo package}
  6548. to create a source crate for future use. The @code{install} phase installs
  6549. the binaries defined by the crate. Unless @code{install-source? #f} is
  6550. defined it will also install a source crate repository of itself and unpacked
  6551. sources, to ease in future hacking on rust packages.
  6552. @end defvr
  6553. @defvr {Scheme Variable} chicken-build-system
  6554. This variable is exported by @code{(guix build-system chicken)}. It
  6555. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  6556. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  6557. gets compiled by a C compiler, in this case GCC.
  6558. This build system adds @code{chicken} to the package inputs, as well as
  6559. the packages of @code{gnu-build-system}.
  6560. The build system can't (yet) deduce the egg's name automatically, so just like
  6561. with @code{go-build-system} and its @code{#:import-path}, you should define
  6562. @code{#:egg-name} in the package's @code{arguments} field.
  6563. For example, if you are packaging the @code{srfi-1} egg:
  6564. @lisp
  6565. (arguments '(#:egg-name "srfi-1"))
  6566. @end lisp
  6567. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  6568. because CHICKEN doesn't embed absolute references in compiled eggs.
  6569. Test dependencies should go to @code{native-inputs}, as usual.
  6570. @end defvr
  6571. @defvr {Scheme Variable} copy-build-system
  6572. This variable is exported by @code{(guix build-system copy)}. It
  6573. supports builds of simple packages that don't require much compiling,
  6574. mostly just moving files around.
  6575. It adds much of the @code{gnu-build-system} packages to the set of
  6576. inputs. Because of this, the @code{copy-build-system} does not require
  6577. all the boilerplate code often needed for the
  6578. @code{trivial-build-system}.
  6579. To further simplify the file installation process, an
  6580. @code{#:install-plan} argument is exposed to let the packager specify
  6581. which files go where. The install plan is a list of @code{(@var{source}
  6582. @var{target} [@var{filters}])}. @var{filters} are optional.
  6583. @itemize
  6584. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  6585. @itemize
  6586. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  6587. @item Otherwise install @var{source} as @var{target}.
  6588. @end itemize
  6589. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  6590. the trailing slash of @var{target} is implied with the same meaning
  6591. as above.
  6592. @itemize
  6593. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  6594. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  6595. @code{#:exclude-regexp}, only select files are installed depending on
  6596. the filters. Each filters is specified by a list of strings.
  6597. @itemize
  6598. @item With @code{#:include}, install all the files which the path suffix matches
  6599. at least one of the elements in the given list.
  6600. @item With @code{#:include-regexp}, install all the files which the
  6601. subpaths match at least one of the regular expressions in the given
  6602. list.
  6603. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6604. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6605. install all files but those matching the exclusion filters.
  6606. If both inclusions and exclusions are specified, the exclusions are done
  6607. on top of the inclusions.
  6608. @end itemize
  6609. @end itemize
  6610. In all cases, the paths relative to @var{source} are preserved within
  6611. @var{target}.
  6612. @end itemize
  6613. Examples:
  6614. @itemize
  6615. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6616. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6617. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6618. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6619. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6620. @file{share/my-app/sub/file}.
  6621. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6622. @file{share/my-app/file}.
  6623. @end itemize
  6624. @end defvr
  6625. @cindex Clojure (programming language)
  6626. @cindex simple Clojure build system
  6627. @defvr {Scheme Variable} clojure-build-system
  6628. This variable is exported by @code{(guix build-system clojure)}. It implements
  6629. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6630. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6631. yet.
  6632. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6633. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6634. @code{#:zip} parameters, respectively.
  6635. A list of source directories, test directories and jar names can be specified
  6636. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6637. parameters, respectively. Compile directory and main class can be specified
  6638. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6639. Other parameters are documented below.
  6640. This build system is an extension of @code{ant-build-system}, but with the
  6641. following phases changed:
  6642. @table @code
  6643. @item build
  6644. This phase calls @code{compile} in Clojure to compile source files and runs
  6645. @command{jar} to create jars from both source files and compiled files
  6646. according to the include list and exclude list specified in
  6647. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6648. has priority over the include list. These lists consist of symbols
  6649. representing Clojure libraries or the special keyword @code{#:all} representing
  6650. all Clojure libraries found under the source directories. The parameter
  6651. @code{#:omit-source?} decides if source should be included into the jars.
  6652. @item check
  6653. This phase runs tests according to the include list and exclude list specified
  6654. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6655. meanings are analogous to that of @code{#:aot-include} and
  6656. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6657. stands for all Clojure libraries found under the test directories. The
  6658. parameter @code{#:tests?} decides if tests should be run.
  6659. @item install
  6660. This phase installs all jars built previously.
  6661. @end table
  6662. Apart from the above, this build system also contains an additional phase:
  6663. @table @code
  6664. @item install-doc
  6665. This phase installs all top-level files with base name matching
  6666. @code{%doc-regex}. A different regex can be specified with the
  6667. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6668. directories specified in @code{#:doc-dirs} are installed as well.
  6669. @end table
  6670. @end defvr
  6671. @defvr {Scheme Variable} cmake-build-system
  6672. This variable is exported by @code{(guix build-system cmake)}. It
  6673. implements the build procedure for packages using the
  6674. @url{https://www.cmake.org, CMake build tool}.
  6675. It automatically adds the @code{cmake} package to the set of inputs.
  6676. Which package is used can be specified with the @code{#:cmake}
  6677. parameter.
  6678. The @code{#:configure-flags} parameter is taken as a list of flags
  6679. passed to the @command{cmake} command. The @code{#:build-type}
  6680. parameter specifies in abstract terms the flags passed to the compiler;
  6681. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6682. debugging information''), which roughly means that code is compiled with
  6683. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6684. @end defvr
  6685. @defvr {Scheme Variable} dune-build-system
  6686. This variable is exported by @code{(guix build-system dune)}. It
  6687. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6688. tool for the OCaml programming language. It is implemented as an extension
  6689. of the @code{ocaml-build-system} which is described below. As such, the
  6690. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6691. system.
  6692. It automatically adds the @code{dune} package to the set of inputs.
  6693. Which package is used can be specified with the @code{#:dune}
  6694. parameter.
  6695. There is no @code{configure} phase because dune packages typically don't
  6696. need to be configured. The @code{#:build-flags} parameter is taken as a
  6697. list of flags passed to the @code{dune} command during the build.
  6698. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6699. command instead of the more recent @code{dune} command while building
  6700. a package. Its default value is @code{#f}.
  6701. The @code{#:package} parameter can be passed to specify a package name, which
  6702. is useful when a package contains multiple packages and you want to build
  6703. only one of them. This is equivalent to passing the @code{-p} argument to
  6704. @code{dune}.
  6705. @end defvr
  6706. @defvr {Scheme Variable} go-build-system
  6707. This variable is exported by @code{(guix build-system go)}. It
  6708. implements a build procedure for Go packages using the standard
  6709. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6710. Go build mechanisms}.
  6711. The user is expected to provide a value for the key @code{#:import-path}
  6712. and, in some cases, @code{#:unpack-path}. The
  6713. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6714. corresponds to the file system path expected by the package's build
  6715. scripts and any referring packages, and provides a unique way to
  6716. refer to a Go package. It is typically based on a combination of the
  6717. package source code's remote URI and file system hierarchy structure. In
  6718. some cases, you will need to unpack the package's source code to a
  6719. different directory structure than the one indicated by the import path,
  6720. and @code{#:unpack-path} should be used in such cases.
  6721. Packages that provide Go libraries should install their source code into
  6722. the built output. The key @code{#:install-source?}, which defaults to
  6723. @code{#t}, controls whether or not the source code is installed. It can
  6724. be set to @code{#f} for packages that only provide executable files.
  6725. Packages can be cross-built, and if a specific architecture or operating
  6726. system is desired then the keywords @code{#:goarch} and @code{#:goos}
  6727. can be used to force the package to be built for that architecture and
  6728. operating system. The combinations known to Go can be found
  6729. @url{"https://golang.org/doc/install/source#environment", in their
  6730. documentation}.
  6731. @end defvr
  6732. @defvr {Scheme Variable} glib-or-gtk-build-system
  6733. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6734. is intended for use with packages making use of GLib or GTK+.
  6735. This build system adds the following two phases to the ones defined by
  6736. @code{gnu-build-system}:
  6737. @table @code
  6738. @item glib-or-gtk-wrap
  6739. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6740. @file{bin/} are able to find GLib ``schemas'' and
  6741. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6742. modules}. This is achieved by wrapping the programs in launch scripts
  6743. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6744. environment variables.
  6745. It is possible to exclude specific package outputs from that wrapping
  6746. process by listing their names in the
  6747. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6748. when an output is known not to contain any GLib or GTK+ binaries, and
  6749. where wrapping would gratuitously add a dependency of that output on
  6750. GLib and GTK+.
  6751. @item glib-or-gtk-compile-schemas
  6752. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6753. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6754. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6755. @command{glib-compile-schemas} program. It is provided by the package
  6756. @code{glib:bin} which is automatically imported by the build system.
  6757. The @code{glib} package providing @command{glib-compile-schemas} can be
  6758. specified with the @code{#:glib} parameter.
  6759. @end table
  6760. Both phases are executed after the @code{install} phase.
  6761. @end defvr
  6762. @defvr {Scheme Variable} guile-build-system
  6763. This build system is for Guile packages that consist exclusively of Scheme
  6764. code and that are so lean that they don't even have a makefile, let alone a
  6765. @file{configure} script. It compiles Scheme code using @command{guild
  6766. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6767. installs the @file{.scm} and @file{.go} files in the right place. It also
  6768. installs documentation.
  6769. This build system supports cross-compilation by using the
  6770. @option{--target} option of @samp{guild compile}.
  6771. Packages built with @code{guile-build-system} must provide a Guile package in
  6772. their @code{native-inputs} field.
  6773. @end defvr
  6774. @defvr {Scheme Variable} julia-build-system
  6775. This variable is exported by @code{(guix build-system julia)}. It
  6776. implements the build procedure used by @uref{https://julialang.org/,
  6777. julia} packages, which essentially is similar to running @samp{julia -e
  6778. 'using Pkg; Pkg.add(package)'} in an environment where
  6779. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6780. Tests are run by calling @code{/test/runtests.jl}.
  6781. The Julia package name is read from the file @file{Project.toml}. This
  6782. value can be overridden by passing the argument @code{#:julia-package-name}
  6783. (which must be correctly capitalized).
  6784. Julia packages usually manage their binary dependencies via
  6785. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  6786. after the wrapped library followed by @code{_jll.jl}.
  6787. To add the binary path @code{_jll.jl} packages, you need to patch the
  6788. files under @file{src/wrappers/}, replacing the call to the macro
  6789. @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
  6790. argument containing the store path the binary.
  6791. As an example, in the MbedTLS Julia package, we add a build phase
  6792. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  6793. MbedTLS package:
  6794. @lisp
  6795. (add-after 'unpack 'override-binary-path
  6796. (lambda* (#:key inputs #:allow-other-keys)
  6797. (for-each (lambda (wrapper)
  6798. (substitute* wrapper
  6799. (("generate_wrapper_header.*")
  6800. (string-append
  6801. "generate_wrapper_header(\"MbedTLS\", \""
  6802. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  6803. ;; There's a Julia file for each platform, override them all.
  6804. (find-files "src/wrappers/" "\\.jl$"))))
  6805. @end lisp
  6806. Some older packages that aren't using @file{Package.toml} yet, will require
  6807. this file to be created, too. The function @code{julia-create-package-toml}
  6808. helps creating the file. You need to pass the outputs and the source of the
  6809. package, its name (the same as the @code{file-name} parameter), the package
  6810. uuid, the package version, and a list of dependencies specified by their name
  6811. and their uuid.
  6812. @end defvr
  6813. @defvr {Scheme Variable} maven-build-system
  6814. This variable is exported by @code{(guix build-system maven)}. It implements
  6815. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6816. is a dependency and lifecycle management tool for Java. A user of Maven
  6817. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6818. When Maven does not have one of the dependencies or plugins in its repository,
  6819. it will download them and use them to build the package.
  6820. The maven build system ensures that maven will not try to download any
  6821. dependency by running in offline mode. Maven will fail if a dependency is
  6822. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6823. modified to specify the version of dependencies and plugins that match the
  6824. versions available in the guix build environment. Dependencies and plugins
  6825. must be installed in the fake maven repository at @file{lib/m2}, and are
  6826. symlinked into a proper repository before maven is run. Maven is instructed
  6827. to use that repository for the build and installs built artifacts there.
  6828. Changed files are copied to the @file{lib/m2} directory of the package output.
  6829. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6830. or let the build system use the default @file{pom.xml} file in the sources.
  6831. In case you need to specify a dependency's version manually, you can use the
  6832. @code{#:local-packages} argument. It takes an association list where the key
  6833. is the groupId of the package and its value is an association list where the
  6834. key is the artifactId of the package and its value is the version you want to
  6835. override in the @file{pom.xml}.
  6836. Some packages use dependencies or plugins that are not useful at runtime nor
  6837. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6838. using the @code{#:exclude} argument. Its value is an association list where
  6839. the key is the groupId of the plugin or dependency you want to remove, and
  6840. the value is a list of artifactId you want to remove.
  6841. You can override the default @code{jdk} and @code{maven} packages with the
  6842. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6843. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6844. the build, with the same format as the @code{inputs} fields of the package
  6845. declaration. Its default value is @code{(default-maven-plugins)} which is
  6846. also exported.
  6847. @end defvr
  6848. @defvr {Scheme Variable} minetest-mod-build-system
  6849. This variable is exported by @code{(guix build-system minetest)}. It
  6850. implements a build procedure for @uref{https://www.minetest.net, Minetest}
  6851. mods, which consists of copying Lua code, images and other resources to
  6852. the location Minetest searches for mods. The build system also minimises
  6853. PNG images and verifies that Minetest can load the mod without errors.
  6854. @end defvr
  6855. @defvr {Scheme Variable} minify-build-system
  6856. This variable is exported by @code{(guix build-system minify)}. It
  6857. implements a minification procedure for simple JavaScript packages.
  6858. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6859. all JavaScript files in the @file{src} directory. A different minifier
  6860. package can be specified with the @code{#:uglify-js} parameter, but it
  6861. is expected that the package writes the minified code to the standard
  6862. output.
  6863. When the input JavaScript files are not all located in the @file{src}
  6864. directory, the parameter @code{#:javascript-files} can be used to
  6865. specify a list of file names to feed to the minifier.
  6866. @end defvr
  6867. @defvr {Scheme Variable} ocaml-build-system
  6868. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6869. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6870. of choosing the correct set of commands to run for each package. OCaml
  6871. packages can expect many different commands to be run. This build system will
  6872. try some of them.
  6873. When the package has a @file{setup.ml} file present at the top-level, it will
  6874. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6875. @code{ocaml setup.ml -install}. The build system will assume that this file
  6876. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6877. care of setting the prefix and enabling tests if they are not disabled. You
  6878. can pass configure and build flags with the @code{#:configure-flags} and
  6879. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6880. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6881. bypass this system in the build and install phases.
  6882. When the package has a @file{configure} file, it is assumed that it is a
  6883. hand-made configure script that requires a different argument format than
  6884. in the @code{gnu-build-system}. You can add more flags with the
  6885. @code{#:configure-flags} key.
  6886. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6887. @code{#t}), it will be used and more flags can be passed to the build and
  6888. install phases with the @code{#:make-flags} key.
  6889. Finally, some packages do not have these files and use a somewhat standard
  6890. location for its build system. In that case, the build system will run
  6891. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6892. providing the path to the required findlib module. Additional flags can
  6893. be passed via the @code{#:build-flags} key. Install is taken care of by
  6894. @command{opam-installer}. In this case, the @code{opam} package must
  6895. be added to the @code{native-inputs} field of the package definition.
  6896. Note that most OCaml packages assume they will be installed in the same
  6897. directory as OCaml, which is not what we want in guix. In particular, they
  6898. will install @file{.so} files in their module's directory, which is usually
  6899. fine because it is in the OCaml compiler directory. In guix though, these
  6900. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6901. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6902. @file{.so} libraries should be installed.
  6903. @end defvr
  6904. @defvr {Scheme Variable} python-build-system
  6905. This variable is exported by @code{(guix build-system python)}. It
  6906. implements the more or less standard build procedure used by Python
  6907. packages, which consists in running @code{python setup.py build} and
  6908. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6909. For packages that install stand-alone Python programs under @code{bin/},
  6910. it takes care of wrapping these programs so that their
  6911. @env{GUIX_PYTHONPATH} environment variable points to all the Python
  6912. libraries they depend on.
  6913. Which Python package is used to perform the build can be specified with
  6914. the @code{#:python} parameter. This is a useful way to force a package
  6915. to be built for a specific version of the Python interpreter, which
  6916. might be necessary if the package is only compatible with a single
  6917. interpreter version.
  6918. By default guix calls @code{setup.py} under control of
  6919. @code{setuptools}, much like @command{pip} does. Some packages are not
  6920. compatible with setuptools (and pip), thus you can disable this by
  6921. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6922. If a @code{"python"} output is available, the package is installed into it
  6923. instead of the default @code{"out"} output. This is useful for packages that
  6924. include a Python package as only a part of the software, and thus want to
  6925. combine the phases of @code{python-build-system} with another build system.
  6926. Python bindings are a common usecase.
  6927. @end defvr
  6928. @defvr {Scheme Variable} perl-build-system
  6929. This variable is exported by @code{(guix build-system perl)}. It
  6930. implements the standard build procedure for Perl packages, which either
  6931. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6932. followed by @code{Build} and @code{Build install}; or in running
  6933. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  6934. @code{make} and @code{make install}, depending on which of
  6935. @code{Build.PL} or @code{Makefile.PL} is present in the package
  6936. distribution. Preference is given to the former if both @code{Build.PL}
  6937. and @code{Makefile.PL} exist in the package distribution. This
  6938. preference can be reversed by specifying @code{#t} for the
  6939. @code{#:make-maker?} parameter.
  6940. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  6941. passes flags specified by the @code{#:make-maker-flags} or
  6942. @code{#:module-build-flags} parameter, respectively.
  6943. Which Perl package is used can be specified with @code{#:perl}.
  6944. @end defvr
  6945. @defvr {Scheme Variable} renpy-build-system
  6946. This variable is exported by @code{(guix build-system renpy)}. It implements
  6947. the more or less standard build procedure used by Ren'py games, which consists
  6948. of loading @code{#:game} once, thereby creating bytecode for it.
  6949. It further creates a wrapper script in @code{bin/} and a desktop entry in
  6950. @code{share/applications}, both of which can be used to launch the game.
  6951. Which Ren'py package is used can be specified with @code{#:renpy}.
  6952. Games can also be installed in outputs other than ``out'' by using
  6953. @code{#:output}.
  6954. @end defvr
  6955. @defvr {Scheme Variable} qt-build-system
  6956. This variable is exported by @code{(guix build-system qt)}. It
  6957. is intended for use with applications using Qt or KDE.
  6958. This build system adds the following two phases to the ones defined by
  6959. @code{cmake-build-system}:
  6960. @table @code
  6961. @item check-setup
  6962. The phase @code{check-setup} prepares the environment for running
  6963. the checks as commonly used by Qt test programs.
  6964. For now this only sets some environment variables:
  6965. @code{QT_QPA_PLATFORM=offscreen},
  6966. @code{DBUS_FATAL_WARNINGS=0} and
  6967. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  6968. This phase is added before the @code{check} phase.
  6969. It's a separate phase to ease adjusting if necessary.
  6970. @item qt-wrap
  6971. The phase @code{qt-wrap}
  6972. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  6973. and output. In case some path is found, all programs in the output's
  6974. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  6975. are wrapped in scripts defining the necessary environment variables.
  6976. It is possible to exclude specific package outputs from that wrapping process
  6977. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  6978. This is useful when an output is known not to contain any Qt binaries, and
  6979. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  6980. or such.
  6981. This phase is added after the @code{install} phase.
  6982. @end table
  6983. @end defvr
  6984. @defvr {Scheme Variable} r-build-system
  6985. This variable is exported by @code{(guix build-system r)}. It
  6986. implements the build procedure used by @uref{https://r-project.org, R}
  6987. packages, which essentially is little more than running @samp{R CMD
  6988. INSTALL --library=/gnu/store/@dots{}} in an environment where
  6989. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  6990. run after installation using the R function
  6991. @code{tools::testInstalledPackage}.
  6992. @end defvr
  6993. @defvr {Scheme Variable} rakudo-build-system
  6994. This variable is exported by @code{(guix build-system rakudo)}. It
  6995. implements the build procedure used by @uref{https://rakudo.org/,
  6996. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  6997. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  6998. installs the binaries, library files and the resources, as well as wrap
  6999. the files under the @code{bin/} directory. Tests can be skipped by
  7000. passing @code{#f} to the @code{tests?} parameter.
  7001. Which rakudo package is used can be specified with @code{rakudo}.
  7002. Which perl6-tap-harness package used for the tests can be specified with
  7003. @code{#:prove6} or removed by passing @code{#f} to the
  7004. @code{with-prove6?} parameter.
  7005. Which perl6-zef package used for tests and installing can be specified
  7006. with @code{#:zef} or removed by passing @code{#f} to the
  7007. @code{with-zef?} parameter.
  7008. @end defvr
  7009. @defvr {Scheme Variable} texlive-build-system
  7010. This variable is exported by @code{(guix build-system texlive)}. It is
  7011. used to build TeX packages in batch mode with a specified engine. The
  7012. build system sets the @env{TEXINPUTS} variable to find all TeX source
  7013. files in the inputs.
  7014. By default it runs @code{luatex} on all files ending on @code{ins}. A
  7015. different engine and format can be specified with the
  7016. @code{#:tex-format} argument. Different build targets can be specified
  7017. with the @code{#:build-targets} argument, which expects a list of file
  7018. names. The build system adds only @code{texlive-bin} and
  7019. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  7020. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  7021. and @code{#:texlive-latex-base}, respectively.
  7022. The @code{#:tex-directory} parameter tells the build system where to
  7023. install the built files under the texmf tree.
  7024. @end defvr
  7025. @defvr {Scheme Variable} ruby-build-system
  7026. This variable is exported by @code{(guix build-system ruby)}. It
  7027. implements the RubyGems build procedure used by Ruby packages, which
  7028. involves running @code{gem build} followed by @code{gem install}.
  7029. The @code{source} field of a package that uses this build system
  7030. typically references a gem archive, since this is the format that Ruby
  7031. developers use when releasing their software. The build system unpacks
  7032. the gem archive, potentially patches the source, runs the test suite,
  7033. repackages the gem, and installs it. Additionally, directories and
  7034. tarballs may be referenced to allow building unreleased gems from Git or
  7035. a traditional source release tarball.
  7036. Which Ruby package is used can be specified with the @code{#:ruby}
  7037. parameter. A list of additional flags to be passed to the @command{gem}
  7038. command can be specified with the @code{#:gem-flags} parameter.
  7039. @end defvr
  7040. @defvr {Scheme Variable} waf-build-system
  7041. This variable is exported by @code{(guix build-system waf)}. It
  7042. implements a build procedure around the @code{waf} script. The common
  7043. phases---@code{configure}, @code{build}, and @code{install}---are
  7044. implemented by passing their names as arguments to the @code{waf}
  7045. script.
  7046. The @code{waf} script is executed by the Python interpreter. Which
  7047. Python package is used to run the script can be specified with the
  7048. @code{#:python} parameter.
  7049. @end defvr
  7050. @defvr {Scheme Variable} scons-build-system
  7051. This variable is exported by @code{(guix build-system scons)}. It
  7052. implements the build procedure used by the SCons software construction
  7053. tool. This build system runs @code{scons} to build the package,
  7054. @code{scons test} to run tests, and then @code{scons install} to install
  7055. the package.
  7056. Additional flags to be passed to @code{scons} can be specified with the
  7057. @code{#:scons-flags} parameter. The default build and install targets
  7058. can be overridden with @code{#:build-targets} and
  7059. @code{#:install-targets} respectively. The version of Python used to
  7060. run SCons can be specified by selecting the appropriate SCons package
  7061. with the @code{#:scons} parameter.
  7062. @end defvr
  7063. @defvr {Scheme Variable} haskell-build-system
  7064. This variable is exported by @code{(guix build-system haskell)}. It
  7065. implements the Cabal build procedure used by Haskell packages, which
  7066. involves running @code{runhaskell Setup.hs configure
  7067. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  7068. Instead of installing the package by running @code{runhaskell Setup.hs
  7069. install}, to avoid trying to register libraries in the read-only
  7070. compiler store directory, the build system uses @code{runhaskell
  7071. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  7072. addition, the build system generates the package documentation by
  7073. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  7074. is passed. Optional Haddock parameters can be passed with the help of
  7075. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  7076. not found, the build system looks for @code{Setup.lhs} instead.
  7077. Which Haskell compiler is used can be specified with the @code{#:haskell}
  7078. parameter which defaults to @code{ghc}.
  7079. @end defvr
  7080. @defvr {Scheme Variable} dub-build-system
  7081. This variable is exported by @code{(guix build-system dub)}. It
  7082. implements the Dub build procedure used by D packages, which
  7083. involves running @code{dub build} and @code{dub run}.
  7084. Installation is done by copying the files manually.
  7085. Which D compiler is used can be specified with the @code{#:ldc}
  7086. parameter which defaults to @code{ldc}.
  7087. @end defvr
  7088. @anchor{emacs-build-system}
  7089. @defvr {Scheme Variable} emacs-build-system
  7090. This variable is exported by @code{(guix build-system emacs)}. It
  7091. implements an installation procedure similar to the packaging system
  7092. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  7093. It first creates the @code{@code{package}-autoloads.el} file, then it
  7094. byte compiles all Emacs Lisp files. Differently from the Emacs
  7095. packaging system, the Info documentation files are moved to the standard
  7096. documentation directory and the @file{dir} file is deleted. The Elisp
  7097. package files are installed directly under @file{share/emacs/site-lisp}.
  7098. @end defvr
  7099. @defvr {Scheme Variable} font-build-system
  7100. This variable is exported by @code{(guix build-system font)}. It
  7101. implements an installation procedure for font packages where upstream
  7102. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  7103. need to be copied into place. It copies font files to standard
  7104. locations in the output directory.
  7105. @end defvr
  7106. @defvr {Scheme Variable} meson-build-system
  7107. This variable is exported by @code{(guix build-system meson)}. It
  7108. implements the build procedure for packages that use
  7109. @url{https://mesonbuild.com, Meson} as their build system.
  7110. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  7111. of inputs, and they can be changed with the parameters @code{#:meson}
  7112. and @code{#:ninja} if needed.
  7113. This build system is an extension of @code{gnu-build-system}, but with the
  7114. following phases changed to some specific for Meson:
  7115. @table @code
  7116. @item configure
  7117. The phase runs @code{meson} with the flags specified in
  7118. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  7119. @code{debugoptimized} unless something else is specified in
  7120. @code{#:build-type}.
  7121. @item build
  7122. The phase runs @code{ninja} to build the package in parallel by default, but
  7123. this can be changed with @code{#:parallel-build?}.
  7124. @item check
  7125. The phase runs @samp{meson test} with a base set of options that cannot
  7126. be overridden. This base set of options can be extended via the
  7127. @code{#:test-options} argument, for example to select or skip a specific
  7128. test suite.
  7129. @item install
  7130. The phase runs @code{ninja install} and can not be changed.
  7131. @end table
  7132. Apart from that, the build system also adds the following phases:
  7133. @table @code
  7134. @item fix-runpath
  7135. This phase ensures that all binaries can find the libraries they need.
  7136. It searches for required libraries in subdirectories of the package
  7137. being built, and adds those to @code{RUNPATH} where needed. It also
  7138. removes references to libraries left over from the build phase by
  7139. @code{meson}, such as test dependencies, that aren't actually required
  7140. for the program to run.
  7141. @item glib-or-gtk-wrap
  7142. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  7143. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  7144. @item glib-or-gtk-compile-schemas
  7145. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  7146. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  7147. @end table
  7148. @end defvr
  7149. @defvr {Scheme Variable} linux-module-build-system
  7150. @code{linux-module-build-system} allows building Linux kernel modules.
  7151. @cindex build phases
  7152. This build system is an extension of @code{gnu-build-system}, but with the
  7153. following phases changed:
  7154. @table @code
  7155. @item configure
  7156. This phase configures the environment so that the Linux kernel's Makefile
  7157. can be used to build the external kernel module.
  7158. @item build
  7159. This phase uses the Linux kernel's Makefile in order to build the external
  7160. kernel module.
  7161. @item install
  7162. This phase uses the Linux kernel's Makefile in order to install the external
  7163. kernel module.
  7164. @end table
  7165. It is possible and useful to specify the Linux kernel to use for building
  7166. the module (in the @code{arguments} form of a package using the
  7167. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  7168. @end defvr
  7169. @defvr {Scheme Variable} node-build-system
  7170. This variable is exported by @code{(guix build-system node)}. It
  7171. implements the build procedure used by @uref{https://nodejs.org,
  7172. Node.js}, which implements an approximation of the @code{npm install}
  7173. command, followed by an @code{npm test} command.
  7174. Which Node.js package is used to interpret the @code{npm} commands can
  7175. be specified with the @code{#:node} parameter which defaults to
  7176. @code{node}.
  7177. @end defvr
  7178. Lastly, for packages that do not need anything as sophisticated, a
  7179. ``trivial'' build system is provided. It is trivial in the sense that
  7180. it provides basically no support: it does not pull any implicit inputs,
  7181. and does not have a notion of build phases.
  7182. @defvr {Scheme Variable} trivial-build-system
  7183. This variable is exported by @code{(guix build-system trivial)}.
  7184. This build system requires a @code{#:builder} argument. This argument
  7185. must be a Scheme expression that builds the package output(s)---as
  7186. with @code{build-expression->derivation} (@pxref{Derivations,
  7187. @code{build-expression->derivation}}).
  7188. @end defvr
  7189. @node Build Phases
  7190. @section Build Phases
  7191. @cindex build phases, for packages
  7192. Almost all package build systems implement a notion @dfn{build phases}:
  7193. a sequence of actions that the build system executes, when you build the
  7194. package, leading to the installed byproducts in the store. A notable
  7195. exception is the ``bare-bones'' @code{trivial-build-system}
  7196. (@pxref{Build Systems}).
  7197. As discussed in the previous section, those build systems provide a
  7198. standard list of phases. For @code{gnu-build-system}, the main build
  7199. phases are the following:
  7200. @table @code
  7201. @item unpack
  7202. Unpack the source tarball, and change the current directory to the
  7203. extracted source tree. If the source is actually a directory, copy it
  7204. to the build tree, and enter that directory.
  7205. @item patch-source-shebangs
  7206. Patch shebangs encountered in source files so they refer to the right
  7207. store file names. For instance, this changes @code{#!/bin/sh} to
  7208. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  7209. @item configure
  7210. Run the @file{configure} script with a number of default options, such
  7211. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  7212. by the @code{#:configure-flags} argument.
  7213. @item build
  7214. Run @code{make} with the list of flags specified with
  7215. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  7216. (the default), build with @code{make -j}.
  7217. @item check
  7218. Run @code{make check}, or some other target specified with
  7219. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  7220. @code{#:parallel-tests?} argument is true (the default), run @code{make
  7221. check -j}.
  7222. @item install
  7223. Run @code{make install} with the flags listed in @code{#:make-flags}.
  7224. @item patch-shebangs
  7225. Patch shebangs on the installed executable files.
  7226. @item strip
  7227. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  7228. is false), copying them to the @code{debug} output when available
  7229. (@pxref{Installing Debugging Files}).
  7230. @end table
  7231. Other build systems have similar phases, with some variations. For
  7232. example, @code{cmake-build-system} has same-named phases but its
  7233. @code{configure} phases runs @code{cmake} instead of @code{./configure}.
  7234. Others, such as @code{python-build-system}, have a wholly different list
  7235. of standard phases. All this code runs on the @dfn{build side}: it is
  7236. evaluated when you actually build the package, in a dedicated build
  7237. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  7238. Build phases are represented as association lists or ``alists''
  7239. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  7240. each key is a symbol for the name of the phase and the associated value
  7241. is a procedure that accepts an arbitrary number of arguments. By
  7242. convention, those procedures receive information about the build in the
  7243. form of @dfn{keyword parameters}, which they can use or ignore.
  7244. @vindex %standard-phases
  7245. For example, here is how @code{(guix build gnu-build-system)} defines
  7246. @code{%standard-phases}, the variable holding its alist of build
  7247. phases@footnote{We present a simplified view of those build phases, but
  7248. do take a look at @code{(guix build gnu-build-system)} to see all the
  7249. details!}:
  7250. @lisp
  7251. ;; The build phases of 'gnu-build-system'.
  7252. (define* (unpack #:key source #:allow-other-keys)
  7253. ;; Extract the source tarball.
  7254. (invoke "tar" "xvf" source))
  7255. (define* (configure #:key outputs #:allow-other-keys)
  7256. ;; Run the 'configure' script. Install to output "out".
  7257. (let ((out (assoc-ref outputs "out")))
  7258. (invoke "./configure"
  7259. (string-append "--prefix=" out))))
  7260. (define* (build #:allow-other-keys)
  7261. ;; Compile.
  7262. (invoke "make"))
  7263. (define* (check #:key (test-target "check") (tests? #true)
  7264. #:allow-other-keys)
  7265. ;; Run the test suite.
  7266. (if tests?
  7267. (invoke "make" test-target)
  7268. (display "test suite not run\n")))
  7269. (define* (install #:allow-other-keys)
  7270. ;; Install files to the prefix 'configure' specified.
  7271. (invoke "make" "install"))
  7272. (define %standard-phases
  7273. ;; The list of standard phases (quite a few are omitted
  7274. ;; for brevity). Each element is a symbol/procedure pair.
  7275. (list (cons 'unpack unpack)
  7276. (cons 'configure configure)
  7277. (cons 'build build)
  7278. (cons 'check check)
  7279. (cons 'install install)))
  7280. @end lisp
  7281. This shows how @code{%standard-phases} is defined as a list of
  7282. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  7283. Manual}). The first pair associates the @code{unpack} procedure with
  7284. the @code{unpack} symbol---a name; the second pair defines the
  7285. @code{configure} phase similarly, and so on. When building a package
  7286. that uses @code{gnu-build-system} with its default list of phases, those
  7287. phases are executed sequentially. You can see the name of each phase
  7288. started and completed in the build log of packages that you build.
  7289. Let's now look at the procedures themselves. Each one is defined with
  7290. @code{define*}: @code{#:key} lists keyword parameters the procedure
  7291. accepts, possibly with a default value, and @code{#:allow-other-keys}
  7292. specifies that other keyword parameters are ignored (@pxref{Optional
  7293. Arguments,,, guile, GNU Guile Reference Manual}).
  7294. The @code{unpack} procedure honors the @code{source} parameter, which
  7295. the build system uses to pass the file name of the source tarball (or
  7296. version control checkout), and it ignores other parameters. The
  7297. @code{configure} phase only cares about the @code{outputs} parameter, an
  7298. alist mapping package output names to their store file name
  7299. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  7300. for @code{out}, the default output, and passes it to
  7301. @command{./configure} as the installation prefix, meaning that
  7302. @command{make install} will eventually copy all the files in that
  7303. directory (@pxref{Configuration, configuration and makefile
  7304. conventions,, standards, GNU Coding Standards}). @code{build} and
  7305. @code{install} ignore all their arguments. @code{check} honors the
  7306. @code{test-target} argument, which specifies the name of the Makefile
  7307. target to run tests; it prints a message and skips tests when
  7308. @code{tests?} is false.
  7309. @cindex build phases, customizing
  7310. The list of phases used for a particular package can be changed with the
  7311. @code{#:phases} parameter of the build system. Changing the set of
  7312. build phases boils down to building a new alist of phases based on the
  7313. @code{%standard-phases} alist described above. This can be done with
  7314. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  7315. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  7316. more convenient to do so with @code{modify-phases} (@pxref{Build
  7317. Utilities, @code{modify-phases}}).
  7318. Here is an example of a package definition that removes the
  7319. @code{configure} phase of @code{%standard-phases} and inserts a new
  7320. phase before the @code{build} phase, called
  7321. @code{set-prefix-in-makefile}:
  7322. @lisp
  7323. (define-public example
  7324. (package
  7325. (name "example")
  7326. ;; other fields omitted
  7327. (build-system gnu-build-system)
  7328. (arguments
  7329. '(#:phases (modify-phases %standard-phases
  7330. (delete 'configure)
  7331. (add-before 'build 'set-prefix-in-makefile
  7332. (lambda* (#:key outputs #:allow-other-keys)
  7333. ;; Modify the makefile so that its
  7334. ;; 'PREFIX' variable points to "out".
  7335. (let ((out (assoc-ref outputs "out")))
  7336. (substitute* "Makefile"
  7337. (("PREFIX =.*")
  7338. (string-append "PREFIX = "
  7339. out "\n")))
  7340. #true))))))))
  7341. @end lisp
  7342. The new phase that is inserted is written as an anonymous procedure,
  7343. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  7344. we have seen before. @xref{Build Utilities}, for more about the helpers
  7345. used by this phase, and for more examples of @code{modify-phases}.
  7346. @cindex code staging
  7347. @cindex staging, of code
  7348. Keep in mind that build phases are code evaluated at the time the
  7349. package is actually built. This explains why the whole
  7350. @code{modify-phases} expression above is quoted (it comes after the
  7351. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  7352. @xref{G-Expressions}, for an explanation of code staging and the
  7353. @dfn{code strata} involved.
  7354. @node Build Utilities
  7355. @section Build Utilities
  7356. As soon as you start writing non-trivial package definitions
  7357. (@pxref{Defining Packages}) or other build actions
  7358. (@pxref{G-Expressions}), you will likely start looking for helpers for
  7359. ``shell-like'' actions---creating directories, copying and deleting
  7360. files recursively, manipulating build phases, and so on. The
  7361. @code{(guix build utils)} module provides such utility procedures.
  7362. Most build systems load @code{(guix build utils)} (@pxref{Build
  7363. Systems}). Thus, when writing custom build phases for your package
  7364. definitions, you can usually assume those procedures are in scope.
  7365. When writing G-expressions, you can import @code{(guix build utils)} on
  7366. the ``build side'' using @code{with-imported-modules} and then put it in
  7367. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  7368. guile, GNU Guile Reference Manual}):
  7369. @lisp
  7370. (with-imported-modules '((guix build utils)) ;import it
  7371. (computed-file "empty-tree"
  7372. #~(begin
  7373. ;; Put it in scope.
  7374. (use-modules (guix build utils))
  7375. ;; Happily use its 'mkdir-p' procedure.
  7376. (mkdir-p (string-append #$output "/a/b/c")))))
  7377. @end lisp
  7378. The remainder of this section is the reference for most of the utility
  7379. procedures provided by @code{(guix build utils)}.
  7380. @c TODO Document what's missing.
  7381. @subsection Dealing with Store File Names
  7382. This section documents procedures that deal with store file names.
  7383. @deffn {Scheme Procedure} %store-directory
  7384. Return the directory name of the store.
  7385. @end deffn
  7386. @deffn {Scheme Procedure} store-file-name? @var{file}
  7387. Return true if @var{file} is in the store.
  7388. @end deffn
  7389. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  7390. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  7391. The result is typically a @code{"@var{package}-@var{version}"} string.
  7392. @end deffn
  7393. @deffn {Scheme Procedure} package-name->name+version @var{name}
  7394. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  7395. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  7396. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  7397. followed by a digit is considered to introduce the version part.
  7398. @end deffn
  7399. @subsection File Types
  7400. The procedures below deal with files and file types.
  7401. @deffn {Scheme Procedure} directory-exists? @var{dir}
  7402. Return @code{#t} if @var{dir} exists and is a directory.
  7403. @end deffn
  7404. @deffn {Scheme Procedure} executable-file? @var{file}
  7405. Return @code{#t} if @var{file} exists and is executable.
  7406. @end deffn
  7407. @deffn {Scheme Procedure} symbolic-link? @var{file}
  7408. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  7409. @end deffn
  7410. @deffn {Scheme Procedure} elf-file? @var{file}
  7411. @deffnx {Scheme Procedure} ar-file? @var{file}
  7412. @deffnx {Scheme Procedure} gzip-file? @var{file}
  7413. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  7414. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  7415. @end deffn
  7416. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  7417. If @var{file} is a gzip file, reset its embedded timestamp (as with
  7418. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  7419. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  7420. @end deffn
  7421. @subsection File Manipulation
  7422. The following procedures and macros help create, modify, and delete
  7423. files. They provide functionality comparable to common shell utilities
  7424. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  7425. @command{sed}. They complement Guile's extensive, but low-level, file
  7426. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  7427. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  7428. Run @var{body} with @var{directory} as the process's current directory.
  7429. Essentially, this macro changes the current directory to @var{directory}
  7430. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  7431. guile, GNU Guile Reference Manual}). It changes back to the initial
  7432. directory when the dynamic extent of @var{body} is left, be it @i{via}
  7433. normal procedure return or @i{via} a non-local exit such as an
  7434. exception.
  7435. @end deffn
  7436. @deffn {Scheme Procedure} mkdir-p @var{dir}
  7437. Create directory @var{dir} and all its ancestors.
  7438. @end deffn
  7439. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  7440. Create @var{directory} if it does not exist and copy @var{file} in there
  7441. under the same name.
  7442. @end deffn
  7443. @deffn {Scheme Procedure} make-file-writable @var{file}
  7444. Make @var{file} writable for its owner.
  7445. @end deffn
  7446. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  7447. [#:log (current-output-port)] [#:follow-symlinks? #f] @
  7448. [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
  7449. Copy @var{source} directory to @var{destination}. Follow symlinks if
  7450. @var{follow-symlinks?} is true; otherwise, just preserve them. Call
  7451. @var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
  7452. keep the modification time of the files in @var{source} on those of
  7453. @var{destination}. When @var{keep-permissions?} is true, preserve file
  7454. permissions. Write verbose output to the @var{log} port.
  7455. @end deffn
  7456. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  7457. [#:follow-mounts? #f]
  7458. Delete @var{dir} recursively, like @command{rm -rf}, without following
  7459. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  7460. is true. Report but ignore errors.
  7461. @end deffn
  7462. @deffn {Scheme Syntax} substitute* @var{file} @
  7463. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  7464. Substitute @var{regexp} in @var{file} by the string returned by
  7465. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  7466. the corresponding positional regexp sub-expression. For example:
  7467. @lisp
  7468. (substitute* file
  7469. (("hello")
  7470. "good morning\n")
  7471. (("foo([a-z]+)bar(.*)$" all letters end)
  7472. (string-append "baz" letters end)))
  7473. @end lisp
  7474. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  7475. by @code{good morning}. Anytime a line of @var{file} matches the second
  7476. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  7477. to the first sub-expression, and @code{end} is bound to the last one.
  7478. When one of the @var{match-var} is @code{_}, no variable is bound to the
  7479. corresponding match substring.
  7480. Alternatively, @var{file} may be a list of file names, in which case
  7481. they are all subject to the substitutions.
  7482. Be careful about using @code{$} to match the end of a line; by itself it
  7483. won't match the terminating newline of a line.
  7484. @end deffn
  7485. @subsection File Search
  7486. @cindex file, searching
  7487. This section documents procedures to search and filter files.
  7488. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  7489. Return a predicate that returns true when passed a file name whose base
  7490. name matches @var{regexp}.
  7491. @end deffn
  7492. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  7493. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  7494. Return the lexicographically sorted list of files under @var{dir} for
  7495. which @var{pred} returns true. @var{pred} is passed two arguments: the
  7496. absolute file name, and its stat buffer; the default predicate always
  7497. returns true. @var{pred} can also be a regular expression, in which
  7498. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  7499. @var{stat} is used to obtain file information; using @code{lstat} means
  7500. that symlinks are not followed. If @var{directories?} is true, then
  7501. directories will also be included. If @var{fail-on-error?} is true,
  7502. raise an exception upon error.
  7503. @end deffn
  7504. Here are a few examples where we assume that the current directory is
  7505. the root of the Guix source tree:
  7506. @lisp
  7507. ;; List all the regular files in the current directory.
  7508. (find-files ".")
  7509. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  7510. ;; List all the .scm files under gnu/services.
  7511. (find-files "gnu/services" "\\.scm$")
  7512. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  7513. ;; List ar files in the current directory.
  7514. (find-files "." (lambda (file stat) (ar-file? file)))
  7515. @result{} ("./libformat.a" "./libstore.a" @dots{})
  7516. @end lisp
  7517. @deffn {Scheme Procedure} which @var{program}
  7518. Return the complete file name for @var{program} as found in
  7519. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  7520. @end deffn
  7521. @deffn {Scheme Procedure} search-input-file @var{inputs} @var{name}
  7522. @deffnx {Scheme Procedure} search-input-directory @var{inputs} @var{name}
  7523. Return the complete file name for @var{name} as found in @var{inputs};
  7524. @code{search-input-file} searches for a regular file and
  7525. @code{search-input-directory} searches for a directory. If @var{name}
  7526. could not be found, an exception is raised.
  7527. Here, @var{inputs} must be an association list like @code{inputs} and
  7528. @code{native-inputs} as available to build phases (@pxref{Build
  7529. Phases}).
  7530. @end deffn
  7531. Here is a (simplified) example of how @code{search-input-file} is used
  7532. in a build phase of the @code{wireguard-tools} package:
  7533. @lisp
  7534. (add-after 'install 'wrap-wg-quick
  7535. (lambda* (#:key inputs outputs #:allow-other-keys)
  7536. (let ((coreutils (string-append (assoc-ref inputs "coreutils")
  7537. "/bin")))
  7538. (wrap-program (search-input-file outputs "bin/wg-quick")
  7539. #:sh (search-input-file inputs "bin/bash")
  7540. `("PATH" ":" prefix ,(list coreutils))))))
  7541. @end lisp
  7542. @subsection Build Phases
  7543. @cindex build phases
  7544. The @code{(guix build utils)} also contains tools to manipulate build
  7545. phases as used by build systems (@pxref{Build Systems}). Build phases
  7546. are represented as association lists or ``alists'' (@pxref{Association
  7547. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  7548. naming the phase and the associated value is a procedure (@pxref{Build
  7549. Phases}).
  7550. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  7551. manipulate alists. The @code{(guix build utils)} module complements
  7552. those with tools written with build phases in mind.
  7553. @cindex build phases, modifying
  7554. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  7555. Modify @var{phases} sequentially as per each @var{clause}, which may
  7556. have one of the following forms:
  7557. @lisp
  7558. (delete @var{old-phase-name})
  7559. (replace @var{old-phase-name} @var{new-phase})
  7560. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7561. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7562. @end lisp
  7563. Where every @var{phase-name} above is an expression evaluating to a
  7564. symbol, and @var{new-phase} an expression evaluating to a procedure.
  7565. @end deffn
  7566. The example below is taken from the definition of the @code{grep}
  7567. package. It adds a phase to run after the @code{install} phase, called
  7568. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  7569. is for anonymous procedures) that takes a @code{#:outputs} keyword
  7570. argument and ignores extra keyword arguments (@pxref{Optional
  7571. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  7572. @code{lambda*} and optional and keyword arguments.) The phase uses
  7573. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  7574. scripts so that they refer to @code{grep} by its absolute file name:
  7575. @lisp
  7576. (modify-phases %standard-phases
  7577. (add-after 'install 'fix-egrep-and-fgrep
  7578. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  7579. ;; absolute file name instead of searching for it in $PATH.
  7580. (lambda* (#:key outputs #:allow-other-keys)
  7581. (let* ((out (assoc-ref outputs "out"))
  7582. (bin (string-append out "/bin")))
  7583. (substitute* (list (string-append bin "/egrep")
  7584. (string-append bin "/fgrep"))
  7585. (("^exec grep")
  7586. (string-append "exec " bin "/grep")))
  7587. #t))))
  7588. @end lisp
  7589. In the example below, phases are modified in two ways: the standard
  7590. @code{configure} phase is deleted, presumably because the package does
  7591. not have a @file{configure} script or anything similar, and the default
  7592. @code{install} phase is replaced by one that manually copies the
  7593. executable files to be installed:
  7594. @lisp
  7595. (modify-phases %standard-phases
  7596. (delete 'configure) ;no 'configure' script
  7597. (replace 'install
  7598. (lambda* (#:key outputs #:allow-other-keys)
  7599. ;; The package's Makefile doesn't provide an "install"
  7600. ;; rule so do it by ourselves.
  7601. (let ((bin (string-append (assoc-ref outputs "out")
  7602. "/bin")))
  7603. (install-file "footswitch" bin)
  7604. (install-file "scythe" bin)
  7605. #t))))
  7606. @end lisp
  7607. @c TODO: Add more examples.
  7608. @node The Store
  7609. @section The Store
  7610. @cindex store
  7611. @cindex store items
  7612. @cindex store paths
  7613. Conceptually, the @dfn{store} is the place where derivations that have
  7614. been built successfully are stored---by default, @file{/gnu/store}.
  7615. Sub-directories in the store are referred to as @dfn{store items} or
  7616. sometimes @dfn{store paths}. The store has an associated database that
  7617. contains information such as the store paths referred to by each store
  7618. path, and the list of @emph{valid} store items---results of successful
  7619. builds. This database resides in @file{@var{localstatedir}/guix/db},
  7620. where @var{localstatedir} is the state directory specified @i{via}
  7621. @option{--localstatedir} at configure time, usually @file{/var}.
  7622. The store is @emph{always} accessed by the daemon on behalf of its clients
  7623. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  7624. connect to the daemon over a Unix-domain socket, send requests to it,
  7625. and read the result---these are remote procedure calls, or RPCs.
  7626. @quotation Note
  7627. Users must @emph{never} modify files under @file{/gnu/store} directly.
  7628. This would lead to inconsistencies and break the immutability
  7629. assumptions of Guix's functional model (@pxref{Introduction}).
  7630. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  7631. how to check the integrity of the store and attempt recovery from
  7632. accidental modifications.
  7633. @end quotation
  7634. The @code{(guix store)} module provides procedures to connect to the
  7635. daemon, and to perform RPCs. These are described below. By default,
  7636. @code{open-connection}, and thus all the @command{guix} commands,
  7637. connect to the local daemon or to the URI specified by the
  7638. @env{GUIX_DAEMON_SOCKET} environment variable.
  7639. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  7640. When set, the value of this variable should be a file name or a URI
  7641. designating the daemon endpoint. When it is a file name, it denotes a
  7642. Unix-domain socket to connect to. In addition to file names, the
  7643. supported URI schemes are:
  7644. @table @code
  7645. @item file
  7646. @itemx unix
  7647. These are for Unix-domain sockets.
  7648. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  7649. @file{/var/guix/daemon-socket/socket}.
  7650. @item guix
  7651. @cindex daemon, remote access
  7652. @cindex remote access to the daemon
  7653. @cindex daemon, cluster setup
  7654. @cindex clusters, daemon setup
  7655. These URIs denote connections over TCP/IP, without encryption nor
  7656. authentication of the remote host. The URI must specify the host name
  7657. and optionally a port number (by default port 44146 is used):
  7658. @example
  7659. guix://master.guix.example.org:1234
  7660. @end example
  7661. This setup is suitable on local networks, such as clusters, where only
  7662. trusted nodes may connect to the build daemon at
  7663. @code{master.guix.example.org}.
  7664. The @option{--listen} option of @command{guix-daemon} can be used to
  7665. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  7666. @option{--listen}}).
  7667. @item ssh
  7668. @cindex SSH access to build daemons
  7669. These URIs allow you to connect to a remote daemon over SSH@. This
  7670. feature requires Guile-SSH (@pxref{Requirements}) and a working
  7671. @command{guile} binary in @env{PATH} on the destination machine. It
  7672. supports public key and GSSAPI authentication. A typical URL might look
  7673. like this:
  7674. @example
  7675. ssh://charlie@@guix.example.org:22
  7676. @end example
  7677. As for @command{guix copy}, the usual OpenSSH client configuration files
  7678. are honored (@pxref{Invoking guix copy}).
  7679. @end table
  7680. Additional URI schemes may be supported in the future.
  7681. @c XXX: Remove this note when the protocol incurs fewer round trips
  7682. @c and when (guix derivations) no longer relies on file system access.
  7683. @quotation Note
  7684. The ability to connect to remote build daemons is considered
  7685. experimental as of @value{VERSION}. Please get in touch with us to
  7686. share any problems or suggestions you may have (@pxref{Contributing}).
  7687. @end quotation
  7688. @end defvr
  7689. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  7690. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  7691. @var{reserve-space?} is true, instruct it to reserve a little bit of
  7692. extra space on the file system so that the garbage collector can still
  7693. operate should the disk become full. Return a server object.
  7694. @var{file} defaults to @code{%default-socket-path}, which is the normal
  7695. location given the options that were passed to @command{configure}.
  7696. @end deffn
  7697. @deffn {Scheme Procedure} close-connection @var{server}
  7698. Close the connection to @var{server}.
  7699. @end deffn
  7700. @defvr {Scheme Variable} current-build-output-port
  7701. This variable is bound to a SRFI-39 parameter, which refers to the port
  7702. where build and error logs sent by the daemon should be written.
  7703. @end defvr
  7704. Procedures that make RPCs all take a server object as their first
  7705. argument.
  7706. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  7707. @cindex invalid store items
  7708. Return @code{#t} when @var{path} designates a valid store item and
  7709. @code{#f} otherwise (an invalid item may exist on disk but still be
  7710. invalid, for instance because it is the result of an aborted or failed
  7711. build).
  7712. A @code{&store-protocol-error} condition is raised if @var{path} is not
  7713. prefixed by the store directory (@file{/gnu/store}).
  7714. @end deffn
  7715. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  7716. Add @var{text} under file @var{name} in the store, and return its store
  7717. path. @var{references} is the list of store paths referred to by the
  7718. resulting store path.
  7719. @end deffn
  7720. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  7721. [@var{mode}]
  7722. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  7723. file names, or derivation/output pairs, using the specified
  7724. @var{mode}---@code{(build-mode normal)} by default.
  7725. @end deffn
  7726. Note that the @code{(guix monads)} module provides a monad as well as
  7727. monadic versions of the above procedures, with the goal of making it
  7728. more convenient to work with code that accesses the store (@pxref{The
  7729. Store Monad}).
  7730. @c FIXME
  7731. @i{This section is currently incomplete.}
  7732. @node Derivations
  7733. @section Derivations
  7734. @cindex derivations
  7735. Low-level build actions and the environment in which they are performed
  7736. are represented by @dfn{derivations}. A derivation contains the
  7737. following pieces of information:
  7738. @itemize
  7739. @item
  7740. The outputs of the derivation---derivations produce at least one file or
  7741. directory in the store, but may produce more.
  7742. @item
  7743. @cindex build-time dependencies
  7744. @cindex dependencies, build-time
  7745. The inputs of the derivations---i.e., its build-time dependencies---which may
  7746. be other derivations or plain files in the store (patches, build scripts,
  7747. etc.).
  7748. @item
  7749. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  7750. @item
  7751. The file name of a build script in the store, along with the arguments
  7752. to be passed.
  7753. @item
  7754. A list of environment variables to be defined.
  7755. @end itemize
  7756. @cindex derivation path
  7757. Derivations allow clients of the daemon to communicate build actions to
  7758. the store. They exist in two forms: as an in-memory representation,
  7759. both on the client- and daemon-side, and as files in the store whose
  7760. name end in @file{.drv}---these files are referred to as @dfn{derivation
  7761. paths}. Derivations paths can be passed to the @code{build-derivations}
  7762. procedure to perform the build actions they prescribe (@pxref{The
  7763. Store}).
  7764. @cindex fixed-output derivations
  7765. Operations such as file downloads and version-control checkouts for
  7766. which the expected content hash is known in advance are modeled as
  7767. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  7768. of a fixed-output derivation are independent of its inputs---e.g., a
  7769. source code download produces the same result regardless of the download
  7770. method and tools being used.
  7771. @cindex references
  7772. @cindex run-time dependencies
  7773. @cindex dependencies, run-time
  7774. The outputs of derivations---i.e., the build results---have a set of
  7775. @dfn{references}, as reported by the @code{references} RPC or the
  7776. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  7777. are the set of run-time dependencies of the build results. References are a
  7778. subset of the inputs of the derivation; this subset is automatically computed
  7779. by the build daemon by scanning all the files in the outputs.
  7780. The @code{(guix derivations)} module provides a representation of
  7781. derivations as Scheme objects, along with procedures to create and
  7782. otherwise manipulate derivations. The lowest-level primitive to create
  7783. a derivation is the @code{derivation} procedure:
  7784. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  7785. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7786. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  7787. [#:system (%current-system)] [#:references-graphs #f] @
  7788. [#:allowed-references #f] [#:disallowed-references #f] @
  7789. [#:leaked-env-vars #f] [#:local-build? #f] @
  7790. [#:substitutable? #t] [#:properties '()]
  7791. Build a derivation with the given arguments, and return the resulting
  7792. @code{<derivation>} object.
  7793. When @var{hash} and @var{hash-algo} are given, a
  7794. @dfn{fixed-output derivation} is created---i.e., one whose result is
  7795. known in advance, such as a file download. If, in addition,
  7796. @var{recursive?} is true, then that fixed output may be an executable
  7797. file or a directory and @var{hash} must be the hash of an archive
  7798. containing this output.
  7799. When @var{references-graphs} is true, it must be a list of file
  7800. name/store path pairs. In that case, the reference graph of each store
  7801. path is exported in the build environment in the corresponding file, in
  7802. a simple text format.
  7803. When @var{allowed-references} is true, it must be a list of store items
  7804. or outputs that the derivation's output may refer to. Likewise,
  7805. @var{disallowed-references}, if true, must be a list of things the
  7806. outputs may @emph{not} refer to.
  7807. When @var{leaked-env-vars} is true, it must be a list of strings
  7808. denoting environment variables that are allowed to ``leak'' from the
  7809. daemon's environment to the build environment. This is only applicable
  7810. to fixed-output derivations---i.e., when @var{hash} is true. The main
  7811. use is to allow variables such as @code{http_proxy} to be passed to
  7812. derivations that download files.
  7813. When @var{local-build?} is true, declare that the derivation is not a
  7814. good candidate for offloading and should rather be built locally
  7815. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  7816. where the costs of data transfers would outweigh the benefits.
  7817. When @var{substitutable?} is false, declare that substitutes of the
  7818. derivation's output should not be used (@pxref{Substitutes}). This is
  7819. useful, for instance, when building packages that capture details of the
  7820. host CPU instruction set.
  7821. @var{properties} must be an association list describing ``properties'' of the
  7822. derivation. It is kept as-is, uninterpreted, in the derivation.
  7823. @end deffn
  7824. @noindent
  7825. Here's an example with a shell script as its builder, assuming
  7826. @var{store} is an open connection to the daemon, and @var{bash} points
  7827. to a Bash executable in the store:
  7828. @lisp
  7829. (use-modules (guix utils)
  7830. (guix store)
  7831. (guix derivations))
  7832. (let ((builder ; add the Bash script to the store
  7833. (add-text-to-store store "my-builder.sh"
  7834. "echo hello world > $out\n" '())))
  7835. (derivation store "foo"
  7836. bash `("-e" ,builder)
  7837. #:inputs `((,bash) (,builder))
  7838. #:env-vars '(("HOME" . "/homeless"))))
  7839. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  7840. @end lisp
  7841. As can be guessed, this primitive is cumbersome to use directly. A
  7842. better approach is to write build scripts in Scheme, of course! The
  7843. best course of action for that is to write the build code as a
  7844. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  7845. information, @pxref{G-Expressions}.
  7846. Once upon a time, @code{gexp->derivation} did not exist and constructing
  7847. derivations with build code written in Scheme was achieved with
  7848. @code{build-expression->derivation}, documented below. This procedure
  7849. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  7850. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  7851. @var{name} @var{exp} @
  7852. [#:system (%current-system)] [#:inputs '()] @
  7853. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7854. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7855. [#:references-graphs #f] [#:allowed-references #f] @
  7856. [#:disallowed-references #f] @
  7857. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  7858. Return a derivation that executes Scheme expression @var{exp} as a
  7859. builder for derivation @var{name}. @var{inputs} must be a list of
  7860. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  7861. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  7862. modules from the current search path to be copied in the store,
  7863. compiled, and made available in the load path during the execution of
  7864. @var{exp}---e.g., @code{((guix build utils) (guix build
  7865. gnu-build-system))}.
  7866. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  7867. to a list of output/path pairs, and where @code{%build-inputs} is bound
  7868. to a list of string/output-path pairs made from @var{inputs}.
  7869. Optionally, @var{env-vars} is a list of string pairs specifying the name
  7870. and value of environment variables visible to the builder. The builder
  7871. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  7872. @var{exp} returns @code{#f}, the build is considered to have failed.
  7873. @var{exp} is built using @var{guile-for-build} (a derivation). When
  7874. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  7875. @code{%guile-for-build} fluid is used instead.
  7876. See the @code{derivation} procedure for the meaning of
  7877. @var{references-graphs}, @var{allowed-references},
  7878. @var{disallowed-references}, @var{local-build?}, and
  7879. @var{substitutable?}.
  7880. @end deffn
  7881. @noindent
  7882. Here's an example of a single-output derivation that creates a directory
  7883. containing one file:
  7884. @lisp
  7885. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  7886. (mkdir out) ; create /gnu/store/@dots{}-goo
  7887. (call-with-output-file (string-append out "/test")
  7888. (lambda (p)
  7889. (display '(hello guix) p))))))
  7890. (build-expression->derivation store "goo" builder))
  7891. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  7892. @end lisp
  7893. @node The Store Monad
  7894. @section The Store Monad
  7895. @cindex monad
  7896. The procedures that operate on the store described in the previous
  7897. sections all take an open connection to the build daemon as their first
  7898. argument. Although the underlying model is functional, they either have
  7899. side effects or depend on the current state of the store.
  7900. The former is inconvenient: the connection to the build daemon has to be
  7901. carried around in all those functions, making it impossible to compose
  7902. functions that do not take that parameter with functions that do. The
  7903. latter can be problematic: since store operations have side effects
  7904. and/or depend on external state, they have to be properly sequenced.
  7905. @cindex monadic values
  7906. @cindex monadic functions
  7907. This is where the @code{(guix monads)} module comes in. This module
  7908. provides a framework for working with @dfn{monads}, and a particularly
  7909. useful monad for our uses, the @dfn{store monad}. Monads are a
  7910. construct that allows two things: associating ``context'' with values
  7911. (in our case, the context is the store), and building sequences of
  7912. computations (here computations include accesses to the store). Values
  7913. in a monad---values that carry this additional context---are called
  7914. @dfn{monadic values}; procedures that return such values are called
  7915. @dfn{monadic procedures}.
  7916. Consider this ``normal'' procedure:
  7917. @lisp
  7918. (define (sh-symlink store)
  7919. ;; Return a derivation that symlinks the 'bash' executable.
  7920. (let* ((drv (package-derivation store bash))
  7921. (out (derivation->output-path drv))
  7922. (sh (string-append out "/bin/bash")))
  7923. (build-expression->derivation store "sh"
  7924. `(symlink ,sh %output))))
  7925. @end lisp
  7926. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  7927. as a monadic function:
  7928. @lisp
  7929. (define (sh-symlink)
  7930. ;; Same, but return a monadic value.
  7931. (mlet %store-monad ((drv (package->derivation bash)))
  7932. (gexp->derivation "sh"
  7933. #~(symlink (string-append #$drv "/bin/bash")
  7934. #$output))))
  7935. @end lisp
  7936. There are several things to note in the second version: the @code{store}
  7937. parameter is now implicit and is ``threaded'' in the calls to the
  7938. @code{package->derivation} and @code{gexp->derivation} monadic
  7939. procedures, and the monadic value returned by @code{package->derivation}
  7940. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  7941. As it turns out, the call to @code{package->derivation} can even be
  7942. omitted since it will take place implicitly, as we will see later
  7943. (@pxref{G-Expressions}):
  7944. @lisp
  7945. (define (sh-symlink)
  7946. (gexp->derivation "sh"
  7947. #~(symlink (string-append #$bash "/bin/bash")
  7948. #$output)))
  7949. @end lisp
  7950. @c See
  7951. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  7952. @c for the funny quote.
  7953. Calling the monadic @code{sh-symlink} has no effect. As someone once
  7954. said, ``you exit a monad like you exit a building on fire: by running''.
  7955. So, to exit the monad and get the desired effect, one must use
  7956. @code{run-with-store}:
  7957. @lisp
  7958. (run-with-store (open-connection) (sh-symlink))
  7959. @result{} /gnu/store/...-sh-symlink
  7960. @end lisp
  7961. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  7962. new ``meta-commands'' to make it easier to deal with monadic procedures:
  7963. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  7964. to ``run'' a single monadic value through the store:
  7965. @example
  7966. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  7967. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7968. @end example
  7969. The latter enters a recursive REPL, where all the return values are
  7970. automatically run through the store:
  7971. @example
  7972. scheme@@(guile-user)> ,enter-store-monad
  7973. store-monad@@(guile-user) [1]> (package->derivation hello)
  7974. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7975. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  7976. $3 = "/gnu/store/@dots{}-foo"
  7977. store-monad@@(guile-user) [1]> ,q
  7978. scheme@@(guile-user)>
  7979. @end example
  7980. @noindent
  7981. Note that non-monadic values cannot be returned in the
  7982. @code{store-monad} REPL.
  7983. The main syntactic forms to deal with monads in general are provided by
  7984. the @code{(guix monads)} module and are described below.
  7985. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  7986. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  7987. in @var{monad}.
  7988. @end deffn
  7989. @deffn {Scheme Syntax} return @var{val}
  7990. Return a monadic value that encapsulates @var{val}.
  7991. @end deffn
  7992. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  7993. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  7994. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  7995. referred to as ``bind'', but that name denotes an unrelated procedure in
  7996. Guile. Thus we use this somewhat cryptic symbol inherited from the
  7997. Haskell language.}. There can be one @var{mproc} or several of them, as
  7998. in this example:
  7999. @lisp
  8000. (run-with-state
  8001. (with-monad %state-monad
  8002. (>>= (return 1)
  8003. (lambda (x) (return (+ 1 x)))
  8004. (lambda (x) (return (* 2 x)))))
  8005. 'some-state)
  8006. @result{} 4
  8007. @result{} some-state
  8008. @end lisp
  8009. @end deffn
  8010. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  8011. @var{body} ...
  8012. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  8013. @var{body} ...
  8014. Bind the variables @var{var} to the monadic values @var{mval} in
  8015. @var{body}, which is a sequence of expressions. As with the bind
  8016. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  8017. value ``contained'' in @var{mval} and making @var{var} refer to that
  8018. raw, non-monadic value within the scope of the @var{body}. The form
  8019. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  8020. @var{val}, as per @code{let}. The binding operations occur in sequence
  8021. from left to right. The last expression of @var{body} must be a monadic
  8022. expression, and its result will become the result of the @code{mlet} or
  8023. @code{mlet*} when run in the @var{monad}.
  8024. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  8025. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  8026. @end deffn
  8027. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  8028. Bind @var{mexp} and the following monadic expressions in sequence,
  8029. returning the result of the last expression. Every expression in the
  8030. sequence must be a monadic expression.
  8031. This is akin to @code{mlet}, except that the return values of the
  8032. monadic expressions are ignored. In that sense, it is analogous to
  8033. @code{begin}, but applied to monadic expressions.
  8034. @end deffn
  8035. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  8036. When @var{condition} is true, evaluate the sequence of monadic
  8037. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  8038. @var{condition} is false, return @code{*unspecified*} in the current
  8039. monad. Every expression in the sequence must be a monadic expression.
  8040. @end deffn
  8041. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  8042. When @var{condition} is false, evaluate the sequence of monadic
  8043. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  8044. @var{condition} is true, return @code{*unspecified*} in the current
  8045. monad. Every expression in the sequence must be a monadic expression.
  8046. @end deffn
  8047. @cindex state monad
  8048. The @code{(guix monads)} module provides the @dfn{state monad}, which
  8049. allows an additional value---the state---to be @emph{threaded} through
  8050. monadic procedure calls.
  8051. @defvr {Scheme Variable} %state-monad
  8052. The state monad. Procedures in the state monad can access and change
  8053. the state that is threaded.
  8054. Consider the example below. The @code{square} procedure returns a value
  8055. in the state monad. It returns the square of its argument, but also
  8056. increments the current state value:
  8057. @lisp
  8058. (define (square x)
  8059. (mlet %state-monad ((count (current-state)))
  8060. (mbegin %state-monad
  8061. (set-current-state (+ 1 count))
  8062. (return (* x x)))))
  8063. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  8064. @result{} (0 1 4)
  8065. @result{} 3
  8066. @end lisp
  8067. When ``run'' through @code{%state-monad}, we obtain that additional state
  8068. value, which is the number of @code{square} calls.
  8069. @end defvr
  8070. @deffn {Monadic Procedure} current-state
  8071. Return the current state as a monadic value.
  8072. @end deffn
  8073. @deffn {Monadic Procedure} set-current-state @var{value}
  8074. Set the current state to @var{value} and return the previous state as a
  8075. monadic value.
  8076. @end deffn
  8077. @deffn {Monadic Procedure} state-push @var{value}
  8078. Push @var{value} to the current state, which is assumed to be a list,
  8079. and return the previous state as a monadic value.
  8080. @end deffn
  8081. @deffn {Monadic Procedure} state-pop
  8082. Pop a value from the current state and return it as a monadic value.
  8083. The state is assumed to be a list.
  8084. @end deffn
  8085. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  8086. Run monadic value @var{mval} starting with @var{state} as the initial
  8087. state. Return two values: the resulting value, and the resulting state.
  8088. @end deffn
  8089. The main interface to the store monad, provided by the @code{(guix
  8090. store)} module, is as follows.
  8091. @defvr {Scheme Variable} %store-monad
  8092. The store monad---an alias for @code{%state-monad}.
  8093. Values in the store monad encapsulate accesses to the store. When its
  8094. effect is needed, a value of the store monad must be ``evaluated'' by
  8095. passing it to the @code{run-with-store} procedure (see below).
  8096. @end defvr
  8097. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  8098. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  8099. open store connection.
  8100. @end deffn
  8101. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  8102. Return as a monadic value the absolute file name in the store of the file
  8103. containing @var{text}, a string. @var{references} is a list of store items that the
  8104. resulting text file refers to; it defaults to the empty list.
  8105. @end deffn
  8106. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  8107. Return as a monadic value the absolute file name in the store of the file
  8108. containing @var{data}, a bytevector. @var{references} is a list of store
  8109. items that the resulting binary file refers to; it defaults to the empty list.
  8110. @end deffn
  8111. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  8112. [#:recursive? #t] [#:select? (const #t)]
  8113. Return the name of @var{file} once interned in the store. Use
  8114. @var{name} as its store name, or the basename of @var{file} if
  8115. @var{name} is omitted.
  8116. When @var{recursive?} is true, the contents of @var{file} are added
  8117. recursively; if @var{file} designates a flat file and @var{recursive?}
  8118. is true, its contents are added, and its permission bits are kept.
  8119. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8120. @var{stat})} for each directory entry, where @var{file} is the entry's
  8121. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8122. entries for which @var{select?} does not return true.
  8123. The example below adds a file to the store, under two different names:
  8124. @lisp
  8125. (run-with-store (open-connection)
  8126. (mlet %store-monad ((a (interned-file "README"))
  8127. (b (interned-file "README" "LEGU-MIN")))
  8128. (return (list a b))))
  8129. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  8130. @end lisp
  8131. @end deffn
  8132. The @code{(guix packages)} module exports the following package-related
  8133. monadic procedures:
  8134. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  8135. [#:system (%current-system)] [#:target #f] @
  8136. [#:output "out"]
  8137. Return as a monadic
  8138. value in the absolute file name of @var{file} within the @var{output}
  8139. directory of @var{package}. When @var{file} is omitted, return the name
  8140. of the @var{output} directory of @var{package}. When @var{target} is
  8141. true, use it as a cross-compilation target triplet.
  8142. Note that this procedure does @emph{not} build @var{package}. Thus, the
  8143. result might or might not designate an existing file. We recommend not
  8144. using this procedure unless you know what you are doing.
  8145. @end deffn
  8146. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  8147. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  8148. @var{target} [@var{system}]
  8149. Monadic version of @code{package-derivation} and
  8150. @code{package-cross-derivation} (@pxref{Defining Packages}).
  8151. @end deffn
  8152. @node G-Expressions
  8153. @section G-Expressions
  8154. @cindex G-expression
  8155. @cindex build code quoting
  8156. So we have ``derivations'', which represent a sequence of build actions
  8157. to be performed to produce an item in the store (@pxref{Derivations}).
  8158. These build actions are performed when asking the daemon to actually
  8159. build the derivations; they are run by the daemon in a container
  8160. (@pxref{Invoking guix-daemon}).
  8161. @cindex code staging
  8162. @cindex staging, of code
  8163. @cindex strata of code
  8164. It should come as no surprise that we like to write these build actions
  8165. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  8166. code@footnote{The term @dfn{stratum} in this context was coined by
  8167. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  8168. Kiselyov, who has written insightful
  8169. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  8170. on this topic}, refers to this kind of code generation as
  8171. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  8172. to the daemon, etc.---and the ``build code''---code that actually
  8173. performs build actions, such as making directories, invoking
  8174. @command{make}, and so on (@pxref{Build Phases}).
  8175. To describe a derivation and its build actions, one typically needs to
  8176. embed build code inside host code. It boils down to manipulating build
  8177. code as data, and the homoiconicity of Scheme---code has a direct
  8178. representation as data---comes in handy for that. But we need more than
  8179. the normal @code{quasiquote} mechanism in Scheme to construct build
  8180. expressions.
  8181. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  8182. S-expressions adapted to build expressions. G-expressions, or
  8183. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  8184. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  8185. @code{#$}, and @code{#$@@}), which are comparable to
  8186. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  8187. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  8188. GNU Guile Reference Manual}). However, there are major differences:
  8189. @itemize
  8190. @item
  8191. Gexps are meant to be written to a file and run or manipulated by other
  8192. processes.
  8193. @item
  8194. When a high-level object such as a package or derivation is unquoted
  8195. inside a gexp, the result is as if its output file name had been
  8196. introduced.
  8197. @item
  8198. Gexps carry information about the packages or derivations they refer to,
  8199. and these dependencies are automatically added as inputs to the build
  8200. processes that use them.
  8201. @end itemize
  8202. @cindex lowering, of high-level objects in gexps
  8203. This mechanism is not limited to package and derivation
  8204. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  8205. derivations or files in the store can be defined,
  8206. such that these objects can also be inserted
  8207. into gexps. For example, a useful type of high-level objects that can be
  8208. inserted in a gexp is ``file-like objects'', which make it easy to
  8209. add files to the store and to refer to them in
  8210. derivations and such (see @code{local-file} and @code{plain-file}
  8211. below).
  8212. To illustrate the idea, here is an example of a gexp:
  8213. @lisp
  8214. (define build-exp
  8215. #~(begin
  8216. (mkdir #$output)
  8217. (chdir #$output)
  8218. (symlink (string-append #$coreutils "/bin/ls")
  8219. "list-files")))
  8220. @end lisp
  8221. This gexp can be passed to @code{gexp->derivation}; we obtain a
  8222. derivation that builds a directory containing exactly one symlink to
  8223. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  8224. @lisp
  8225. (gexp->derivation "the-thing" build-exp)
  8226. @end lisp
  8227. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  8228. substituted to the reference to the @var{coreutils} package in the
  8229. actual build code, and @var{coreutils} is automatically made an input to
  8230. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  8231. output)}) is replaced by a string containing the directory name of the
  8232. output of the derivation.
  8233. @cindex cross compilation
  8234. In a cross-compilation context, it is useful to distinguish between
  8235. references to the @emph{native} build of a package---that can run on the
  8236. host---versus references to cross builds of a package. To that end, the
  8237. @code{#+} plays the same role as @code{#$}, but is a reference to a
  8238. native package build:
  8239. @lisp
  8240. (gexp->derivation "vi"
  8241. #~(begin
  8242. (mkdir #$output)
  8243. (mkdir (string-append #$output "/bin"))
  8244. (system* (string-append #+coreutils "/bin/ln")
  8245. "-s"
  8246. (string-append #$emacs "/bin/emacs")
  8247. (string-append #$output "/bin/vi")))
  8248. #:target "aarch64-linux-gnu")
  8249. @end lisp
  8250. @noindent
  8251. In the example above, the native build of @var{coreutils} is used, so
  8252. that @command{ln} can actually run on the host; but then the
  8253. cross-compiled build of @var{emacs} is referenced.
  8254. @cindex imported modules, for gexps
  8255. @findex with-imported-modules
  8256. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  8257. able to use certain Guile modules from the ``host environment'' in the
  8258. gexp, so those modules should be imported in the ``build environment''.
  8259. The @code{with-imported-modules} form allows you to express that:
  8260. @lisp
  8261. (let ((build (with-imported-modules '((guix build utils))
  8262. #~(begin
  8263. (use-modules (guix build utils))
  8264. (mkdir-p (string-append #$output "/bin"))))))
  8265. (gexp->derivation "empty-dir"
  8266. #~(begin
  8267. #$build
  8268. (display "success!\n")
  8269. #t)))
  8270. @end lisp
  8271. @noindent
  8272. In this example, the @code{(guix build utils)} module is automatically
  8273. pulled into the isolated build environment of our gexp, such that
  8274. @code{(use-modules (guix build utils))} works as expected.
  8275. @cindex module closure
  8276. @findex source-module-closure
  8277. Usually you want the @emph{closure} of the module to be imported---i.e.,
  8278. the module itself and all the modules it depends on---rather than just
  8279. the module; failing to do that, attempts to use the module will fail
  8280. because of missing dependent modules. The @code{source-module-closure}
  8281. procedure computes the closure of a module by looking at its source file
  8282. headers, which comes in handy in this case:
  8283. @lisp
  8284. (use-modules (guix modules)) ;for 'source-module-closure'
  8285. (with-imported-modules (source-module-closure
  8286. '((guix build utils)
  8287. (gnu build image)))
  8288. (gexp->derivation "something-with-vms"
  8289. #~(begin
  8290. (use-modules (guix build utils)
  8291. (gnu build image))
  8292. @dots{})))
  8293. @end lisp
  8294. @cindex extensions, for gexps
  8295. @findex with-extensions
  8296. In the same vein, sometimes you want to import not just pure-Scheme
  8297. modules, but also ``extensions'' such as Guile bindings to C libraries
  8298. or other ``full-blown'' packages. Say you need the @code{guile-json}
  8299. package available on the build side, here's how you would do it:
  8300. @lisp
  8301. (use-modules (gnu packages guile)) ;for 'guile-json'
  8302. (with-extensions (list guile-json)
  8303. (gexp->derivation "something-with-json"
  8304. #~(begin
  8305. (use-modules (json))
  8306. @dots{})))
  8307. @end lisp
  8308. The syntactic form to construct gexps is summarized below.
  8309. @deffn {Scheme Syntax} #~@var{exp}
  8310. @deffnx {Scheme Syntax} (gexp @var{exp})
  8311. Return a G-expression containing @var{exp}. @var{exp} may contain one
  8312. or more of the following forms:
  8313. @table @code
  8314. @item #$@var{obj}
  8315. @itemx (ungexp @var{obj})
  8316. Introduce a reference to @var{obj}. @var{obj} may have one of the
  8317. supported types, for example a package or a
  8318. derivation, in which case the @code{ungexp} form is replaced by its
  8319. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  8320. If @var{obj} is a list, it is traversed and references to supported
  8321. objects are substituted similarly.
  8322. If @var{obj} is another gexp, its contents are inserted and its
  8323. dependencies are added to those of the containing gexp.
  8324. If @var{obj} is another kind of object, it is inserted as is.
  8325. @item #$@var{obj}:@var{output}
  8326. @itemx (ungexp @var{obj} @var{output})
  8327. This is like the form above, but referring explicitly to the
  8328. @var{output} of @var{obj}---this is useful when @var{obj} produces
  8329. multiple outputs (@pxref{Packages with Multiple Outputs}).
  8330. @item #+@var{obj}
  8331. @itemx #+@var{obj}:output
  8332. @itemx (ungexp-native @var{obj})
  8333. @itemx (ungexp-native @var{obj} @var{output})
  8334. Same as @code{ungexp}, but produces a reference to the @emph{native}
  8335. build of @var{obj} when used in a cross compilation context.
  8336. @item #$output[:@var{output}]
  8337. @itemx (ungexp output [@var{output}])
  8338. Insert a reference to derivation output @var{output}, or to the main
  8339. output when @var{output} is omitted.
  8340. This only makes sense for gexps passed to @code{gexp->derivation}.
  8341. @item #$@@@var{lst}
  8342. @itemx (ungexp-splicing @var{lst})
  8343. Like the above, but splices the contents of @var{lst} inside the
  8344. containing list.
  8345. @item #+@@@var{lst}
  8346. @itemx (ungexp-native-splicing @var{lst})
  8347. Like the above, but refers to native builds of the objects listed in
  8348. @var{lst}.
  8349. @end table
  8350. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  8351. of the @code{gexp?} type (see below).
  8352. @end deffn
  8353. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  8354. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  8355. in their execution environment.
  8356. Each item in @var{modules} can be the name of a module, such as
  8357. @code{(guix build utils)}, or it can be a module name, followed by an
  8358. arrow, followed by a file-like object:
  8359. @lisp
  8360. `((guix build utils)
  8361. (guix gcrypt)
  8362. ((guix config) => ,(scheme-file "config.scm"
  8363. #~(define-module @dots{}))))
  8364. @end lisp
  8365. @noindent
  8366. In the example above, the first two modules are taken from the search
  8367. path, and the last one is created from the given file-like object.
  8368. This form has @emph{lexical} scope: it has an effect on the gexps
  8369. directly defined in @var{body}@dots{}, but not on those defined, say, in
  8370. procedures called from @var{body}@dots{}.
  8371. @end deffn
  8372. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  8373. Mark the gexps defined in @var{body}@dots{} as requiring
  8374. @var{extensions} in their build and execution environment.
  8375. @var{extensions} is typically a list of package objects such as those
  8376. defined in the @code{(gnu packages guile)} module.
  8377. Concretely, the packages listed in @var{extensions} are added to the
  8378. load path while compiling imported modules in @var{body}@dots{}; they
  8379. are also added to the load path of the gexp returned by
  8380. @var{body}@dots{}.
  8381. @end deffn
  8382. @deffn {Scheme Procedure} gexp? @var{obj}
  8383. Return @code{#t} if @var{obj} is a G-expression.
  8384. @end deffn
  8385. G-expressions are meant to be written to disk, either as code building
  8386. some derivation, or as plain files in the store. The monadic procedures
  8387. below allow you to do that (@pxref{The Store Monad}, for more
  8388. information about monads).
  8389. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  8390. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  8391. [#:hash #f] [#:hash-algo #f] @
  8392. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  8393. [#:module-path @code{%load-path}] @
  8394. [#:effective-version "2.2"] @
  8395. [#:references-graphs #f] [#:allowed-references #f] @
  8396. [#:disallowed-references #f] @
  8397. [#:leaked-env-vars #f] @
  8398. [#:script-name (string-append @var{name} "-builder")] @
  8399. [#:deprecation-warnings #f] @
  8400. [#:local-build? #f] [#:substitutable? #t] @
  8401. [#:properties '()] [#:guile-for-build #f]
  8402. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  8403. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  8404. stored in a file called @var{script-name}. When @var{target} is true,
  8405. it is used as the cross-compilation target triplet for packages referred
  8406. to by @var{exp}.
  8407. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  8408. Its meaning is to
  8409. make @var{modules} available in the evaluation context of @var{exp};
  8410. @var{modules} is a list of names of Guile modules searched in
  8411. @var{module-path} to be copied in the store, compiled, and made available in
  8412. the load path during the execution of @var{exp}---e.g., @code{((guix
  8413. build utils) (guix build gnu-build-system))}.
  8414. @var{effective-version} determines the string to use when adding extensions of
  8415. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  8416. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  8417. applicable.
  8418. When @var{references-graphs} is true, it must be a list of tuples of one of the
  8419. following forms:
  8420. @example
  8421. (@var{file-name} @var{package})
  8422. (@var{file-name} @var{package} @var{output})
  8423. (@var{file-name} @var{derivation})
  8424. (@var{file-name} @var{derivation} @var{output})
  8425. (@var{file-name} @var{store-item})
  8426. @end example
  8427. The right-hand-side of each element of @var{references-graphs} is automatically made
  8428. an input of the build process of @var{exp}. In the build environment, each
  8429. @var{file-name} contains the reference graph of the corresponding item, in a simple
  8430. text format.
  8431. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  8432. In the latter case, the list denotes store items that the result is allowed to
  8433. refer to. Any reference to another store item will lead to a build error.
  8434. Similarly for @var{disallowed-references}, which can list items that must not be
  8435. referenced by the outputs.
  8436. @var{deprecation-warnings} determines whether to show deprecation warnings while
  8437. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  8438. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  8439. @end deffn
  8440. @cindex file-like objects
  8441. The @code{local-file}, @code{plain-file}, @code{computed-file},
  8442. @code{program-file}, and @code{scheme-file} procedures below return
  8443. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  8444. these objects lead to a file in the store. Consider this G-expression:
  8445. @lisp
  8446. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  8447. #$(local-file "/tmp/my-nscd.conf"))
  8448. @end lisp
  8449. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  8450. to the store. Once expanded, for instance @i{via}
  8451. @code{gexp->derivation}, the G-expression refers to that copy under
  8452. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  8453. does not have any effect on what the G-expression does.
  8454. @code{plain-file} can be used similarly; it differs in that the file
  8455. content is directly passed as a string.
  8456. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  8457. [#:recursive? #f] [#:select? (const #t)]
  8458. Return an object representing local file @var{file} to add to the store;
  8459. this object can be used in a gexp. If @var{file} is a literal string
  8460. denoting a relative file name, it is looked up relative to the source
  8461. file where it appears; if @var{file} is not a literal string, it is
  8462. looked up relative to the current working directory at run time.
  8463. @var{file} will be added to the store under @var{name}--by default the
  8464. base name of @var{file}.
  8465. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  8466. designates a flat file and @var{recursive?} is true, its contents are added, and its
  8467. permission bits are kept.
  8468. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8469. @var{stat})} for each directory entry, where @var{file} is the entry's
  8470. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8471. entries for which @var{select?} does not return true.
  8472. This is the declarative counterpart of the @code{interned-file} monadic
  8473. procedure (@pxref{The Store Monad, @code{interned-file}}).
  8474. @end deffn
  8475. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  8476. Return an object representing a text file called @var{name} with the given
  8477. @var{content} (a string or a bytevector) to be added to the store.
  8478. This is the declarative counterpart of @code{text-file}.
  8479. @end deffn
  8480. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  8481. [#:local-build? #t]
  8482. [#:options '()]
  8483. Return an object representing the store item @var{name}, a file or
  8484. directory computed by @var{gexp}. When @var{local-build?} is true (the
  8485. default), the derivation is built locally. @var{options} is a list of
  8486. additional arguments to pass to @code{gexp->derivation}.
  8487. This is the declarative counterpart of @code{gexp->derivation}.
  8488. @end deffn
  8489. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  8490. [#:guile (default-guile)] [#:module-path %load-path] @
  8491. [#:system (%current-system)] [#:target #f]
  8492. Return an executable script @var{name} that runs @var{exp} using
  8493. @var{guile}, with @var{exp}'s imported modules in its search path.
  8494. Look up @var{exp}'s modules in @var{module-path}.
  8495. The example below builds a script that simply invokes the @command{ls}
  8496. command:
  8497. @lisp
  8498. (use-modules (guix gexp) (gnu packages base))
  8499. (gexp->script "list-files"
  8500. #~(execl #$(file-append coreutils "/bin/ls")
  8501. "ls"))
  8502. @end lisp
  8503. When ``running'' it through the store (@pxref{The Store Monad,
  8504. @code{run-with-store}}), we obtain a derivation that produces an
  8505. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  8506. @example
  8507. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  8508. !#
  8509. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  8510. @end example
  8511. @end deffn
  8512. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  8513. [#:guile #f] [#:module-path %load-path]
  8514. Return an object representing the executable store item @var{name} that
  8515. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  8516. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  8517. This is the declarative counterpart of @code{gexp->script}.
  8518. @end deffn
  8519. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  8520. [#:set-load-path? #t] [#:module-path %load-path] @
  8521. [#:splice? #f] @
  8522. [#:guile (default-guile)]
  8523. Return a derivation that builds a file @var{name} containing @var{exp}.
  8524. When @var{splice?} is true, @var{exp} is considered to be a list of
  8525. expressions that will be spliced in the resulting file.
  8526. When @var{set-load-path?} is true, emit code in the resulting file to
  8527. set @code{%load-path} and @code{%load-compiled-path} to honor
  8528. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  8529. @var{module-path}.
  8530. The resulting file holds references to all the dependencies of @var{exp}
  8531. or a subset thereof.
  8532. @end deffn
  8533. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  8534. [#:splice? #f] [#:set-load-path? #t]
  8535. Return an object representing the Scheme file @var{name} that contains
  8536. @var{exp}.
  8537. This is the declarative counterpart of @code{gexp->file}.
  8538. @end deffn
  8539. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  8540. Return as a monadic value a derivation that builds a text file
  8541. containing all of @var{text}. @var{text} may list, in addition to
  8542. strings, objects of any type that can be used in a gexp: packages,
  8543. derivations, local file objects, etc. The resulting store file holds
  8544. references to all these.
  8545. This variant should be preferred over @code{text-file} anytime the file
  8546. to create will reference items from the store. This is typically the
  8547. case when building a configuration file that embeds store file names,
  8548. like this:
  8549. @lisp
  8550. (define (profile.sh)
  8551. ;; Return the name of a shell script in the store that
  8552. ;; initializes the 'PATH' environment variable.
  8553. (text-file* "profile.sh"
  8554. "export PATH=" coreutils "/bin:"
  8555. grep "/bin:" sed "/bin\n"))
  8556. @end lisp
  8557. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  8558. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  8559. preventing them from being garbage-collected during its lifetime.
  8560. @end deffn
  8561. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  8562. Return an object representing store file @var{name} containing
  8563. @var{text}. @var{text} is a sequence of strings and file-like objects,
  8564. as in:
  8565. @lisp
  8566. (mixed-text-file "profile"
  8567. "export PATH=" coreutils "/bin:" grep "/bin")
  8568. @end lisp
  8569. This is the declarative counterpart of @code{text-file*}.
  8570. @end deffn
  8571. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  8572. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  8573. Each item in @var{files} must be a two-element list where the first element is the
  8574. file name to use in the new directory, and the second element is a gexp
  8575. denoting the target file. Here's an example:
  8576. @lisp
  8577. (file-union "etc"
  8578. `(("hosts" ,(plain-file "hosts"
  8579. "127.0.0.1 localhost"))
  8580. ("bashrc" ,(plain-file "bashrc"
  8581. "alias ls='ls --color=auto'"))))
  8582. @end lisp
  8583. This yields an @code{etc} directory containing these two files.
  8584. @end deffn
  8585. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  8586. Return a directory that is the union of @var{things}, where @var{things} is a list of
  8587. file-like objects denoting directories. For example:
  8588. @lisp
  8589. (directory-union "guile+emacs" (list guile emacs))
  8590. @end lisp
  8591. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  8592. @end deffn
  8593. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  8594. Return a file-like object that expands to the concatenation of @var{obj}
  8595. and @var{suffix}, where @var{obj} is a lowerable object and each
  8596. @var{suffix} is a string.
  8597. As an example, consider this gexp:
  8598. @lisp
  8599. (gexp->script "run-uname"
  8600. #~(system* #$(file-append coreutils
  8601. "/bin/uname")))
  8602. @end lisp
  8603. The same effect could be achieved with:
  8604. @lisp
  8605. (gexp->script "run-uname"
  8606. #~(system* (string-append #$coreutils
  8607. "/bin/uname")))
  8608. @end lisp
  8609. There is one difference though: in the @code{file-append} case, the
  8610. resulting script contains the absolute file name as a string, whereas in
  8611. the second case, the resulting script contains a @code{(string-append
  8612. @dots{})} expression to construct the file name @emph{at run time}.
  8613. @end deffn
  8614. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  8615. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  8616. Bind @var{system} to the currently targeted system---e.g.,
  8617. @code{"x86_64-linux"}---within @var{body}.
  8618. In the second case, additionally bind @var{target} to the current
  8619. cross-compilation target---a GNU triplet such as
  8620. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  8621. cross-compiling.
  8622. @code{let-system} is useful in the occasional case where the object
  8623. spliced into the gexp depends on the target system, as in this example:
  8624. @lisp
  8625. #~(system*
  8626. #+(let-system system
  8627. (cond ((string-prefix? "armhf-" system)
  8628. (file-append qemu "/bin/qemu-system-arm"))
  8629. ((string-prefix? "x86_64-" system)
  8630. (file-append qemu "/bin/qemu-system-x86_64"))
  8631. (else
  8632. (error "dunno!"))))
  8633. "-net" "user" #$image)
  8634. @end lisp
  8635. @end deffn
  8636. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  8637. This macro is similar to the @code{parameterize} form for
  8638. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  8639. Guile Reference Manual}). The key difference is that it takes effect
  8640. when the file-like object returned by @var{exp} is lowered to a
  8641. derivation or store item.
  8642. A typical use of @code{with-parameters} is to force the system in effect
  8643. for a given object:
  8644. @lisp
  8645. (with-parameters ((%current-system "i686-linux"))
  8646. coreutils)
  8647. @end lisp
  8648. The example above returns an object that corresponds to the i686 build
  8649. of Coreutils, regardless of the current value of @code{%current-system}.
  8650. @end deffn
  8651. Of course, in addition to gexps embedded in ``host'' code, there are
  8652. also modules containing build tools. To make it clear that they are
  8653. meant to be used in the build stratum, these modules are kept in the
  8654. @code{(guix build @dots{})} name space.
  8655. @cindex lowering, of high-level objects in gexps
  8656. Internally, high-level objects are @dfn{lowered}, using their compiler,
  8657. to either derivations or store items. For instance, lowering a package
  8658. yields a derivation, and lowering a @code{plain-file} yields a store
  8659. item. This is achieved using the @code{lower-object} monadic procedure.
  8660. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  8661. [#:target #f]
  8662. Return as a value in @code{%store-monad} the derivation or store item
  8663. corresponding to @var{obj} for @var{system}, cross-compiling for
  8664. @var{target} if @var{target} is true. @var{obj} must be an object that
  8665. has an associated gexp compiler, such as a @code{<package>}.
  8666. @end deffn
  8667. @deffn {Procedure} gexp->approximate-sexp @var{gexp}
  8668. Sometimes, it may be useful to convert a G-exp into a S-exp. For
  8669. example, some linters (@pxref{Invoking guix lint}) peek into the build
  8670. phases of a package to detect potential problems. This conversion can
  8671. be achieved with this procedure. However, some information can be lost
  8672. in the process. More specifically, lowerable objects will be silently
  8673. replaced with some arbitrary object -- currently the list
  8674. @code{(*approximate*)}, but this may change.
  8675. @end deffn
  8676. @node Invoking guix repl
  8677. @section Invoking @command{guix repl}
  8678. @cindex REPL, read-eval-print loop, script
  8679. The @command{guix repl} command makes it easier to program Guix in Guile
  8680. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  8681. programming (@pxref{Using Guile Interactively,,, guile,
  8682. GNU Guile Reference Manual}), or by running Guile scripts
  8683. (@pxref{Running Guile Scripts,,, guile,
  8684. GNU Guile Reference Manual}).
  8685. Compared to just launching the @command{guile}
  8686. command, @command{guix repl} guarantees that all the Guix modules and all its
  8687. dependencies are available in the search path.
  8688. The general syntax is:
  8689. @example
  8690. guix repl @var{options} [@var{file} @var{args}]
  8691. @end example
  8692. When a @var{file} argument is provided, @var{file} is
  8693. executed as a Guile scripts:
  8694. @example
  8695. guix repl my-script.scm
  8696. @end example
  8697. To pass arguments to the script, use @code{--} to prevent them from
  8698. being interpreted as arguments to @command{guix repl} itself:
  8699. @example
  8700. guix repl -- my-script.scm --input=foo.txt
  8701. @end example
  8702. To make a script executable directly from the shell, using the guix
  8703. executable that is on the user's search path, add the following two
  8704. lines at the top of the script:
  8705. @example
  8706. @code{#!/usr/bin/env -S guix repl --}
  8707. @code{!#}
  8708. @end example
  8709. Without a file name argument, a Guile REPL is started:
  8710. @example
  8711. $ guix repl
  8712. scheme@@(guile-user)> ,use (gnu packages base)
  8713. scheme@@(guile-user)> coreutils
  8714. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  8715. @end example
  8716. @cindex inferiors
  8717. In addition, @command{guix repl} implements a simple machine-readable REPL
  8718. protocol for use by @code{(guix inferior)}, a facility to interact with
  8719. @dfn{inferiors}, separate processes running a potentially different revision
  8720. of Guix.
  8721. The available options are as follows:
  8722. @table @code
  8723. @item --type=@var{type}
  8724. @itemx -t @var{type}
  8725. Start a REPL of the given @var{TYPE}, which can be one of the following:
  8726. @table @code
  8727. @item guile
  8728. This is default, and it spawns a standard full-featured Guile REPL.
  8729. @item machine
  8730. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  8731. that the @code{(guix inferior)} module speaks.
  8732. @end table
  8733. @item --listen=@var{endpoint}
  8734. By default, @command{guix repl} reads from standard input and writes to
  8735. standard output. When this option is passed, it will instead listen for
  8736. connections on @var{endpoint}. Here are examples of valid options:
  8737. @table @code
  8738. @item --listen=tcp:37146
  8739. Accept connections on localhost on port 37146.
  8740. @item --listen=unix:/tmp/socket
  8741. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  8742. @end table
  8743. @item --load-path=@var{directory}
  8744. @itemx -L @var{directory}
  8745. Add @var{directory} to the front of the package module search path
  8746. (@pxref{Package Modules}).
  8747. This allows users to define their own packages and make them visible to
  8748. the script or REPL.
  8749. @item -q
  8750. Inhibit loading of the @file{~/.guile} file. By default, that
  8751. configuration file is loaded when spawning a @code{guile} REPL.
  8752. @end table
  8753. @c *********************************************************************
  8754. @node Utilities
  8755. @chapter Utilities
  8756. This section describes Guix command-line utilities. Some of them are
  8757. primarily targeted at developers and users who write new package
  8758. definitions, while others are more generally useful. They complement
  8759. the Scheme programming interface of Guix in a convenient way.
  8760. @menu
  8761. * Invoking guix build:: Building packages from the command line.
  8762. * Invoking guix edit:: Editing package definitions.
  8763. * Invoking guix download:: Downloading a file and printing its hash.
  8764. * Invoking guix hash:: Computing the cryptographic hash of a file.
  8765. * Invoking guix import:: Importing package definitions.
  8766. * Invoking guix refresh:: Updating package definitions.
  8767. * Invoking guix style:: Styling package definitions.
  8768. * Invoking guix lint:: Finding errors in package definitions.
  8769. * Invoking guix size:: Profiling disk usage.
  8770. * Invoking guix graph:: Visualizing the graph of packages.
  8771. * Invoking guix publish:: Sharing substitutes.
  8772. * Invoking guix challenge:: Challenging substitute servers.
  8773. * Invoking guix copy:: Copying to and from a remote store.
  8774. * Invoking guix container:: Process isolation.
  8775. * Invoking guix weather:: Assessing substitute availability.
  8776. * Invoking guix processes:: Listing client processes.
  8777. @end menu
  8778. @node Invoking guix build
  8779. @section Invoking @command{guix build}
  8780. @cindex package building
  8781. @cindex @command{guix build}
  8782. The @command{guix build} command builds packages or derivations and
  8783. their dependencies, and prints the resulting store paths. Note that it
  8784. does not modify the user's profile---this is the job of the
  8785. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  8786. it is mainly useful for distribution developers.
  8787. The general syntax is:
  8788. @example
  8789. guix build @var{options} @var{package-or-derivation}@dots{}
  8790. @end example
  8791. As an example, the following command builds the latest versions of Emacs
  8792. and of Guile, displays their build logs, and finally displays the
  8793. resulting directories:
  8794. @example
  8795. guix build emacs guile
  8796. @end example
  8797. Similarly, the following command builds all the available packages:
  8798. @example
  8799. guix build --quiet --keep-going \
  8800. $(guix package -A | awk '@{ print $1 "@@" $2 @}')
  8801. @end example
  8802. @var{package-or-derivation} may be either the name of a package found in
  8803. the software distribution such as @code{coreutils} or
  8804. @code{coreutils@@8.20}, or a derivation such as
  8805. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  8806. package with the corresponding name (and optionally version) is searched
  8807. for among the GNU distribution modules (@pxref{Package Modules}).
  8808. Alternatively, the @option{--expression} option may be used to specify a
  8809. Scheme expression that evaluates to a package; this is useful when
  8810. disambiguating among several same-named packages or package variants is
  8811. needed.
  8812. There may be zero or more @var{options}. The available options are
  8813. described in the subsections below.
  8814. @menu
  8815. * Common Build Options:: Build options for most commands.
  8816. * Package Transformation Options:: Creating variants of packages.
  8817. * Additional Build Options:: Options specific to 'guix build'.
  8818. * Debugging Build Failures:: Real life packaging experience.
  8819. @end menu
  8820. @node Common Build Options
  8821. @subsection Common Build Options
  8822. A number of options that control the build process are common to
  8823. @command{guix build} and other commands that can spawn builds, such as
  8824. @command{guix package} or @command{guix archive}. These are the
  8825. following:
  8826. @table @code
  8827. @item --load-path=@var{directory}
  8828. @itemx -L @var{directory}
  8829. Add @var{directory} to the front of the package module search path
  8830. (@pxref{Package Modules}).
  8831. This allows users to define their own packages and make them visible to
  8832. the command-line tools.
  8833. @item --keep-failed
  8834. @itemx -K
  8835. Keep the build tree of failed builds. Thus, if a build fails, its build
  8836. tree is kept under @file{/tmp}, in a directory whose name is shown at
  8837. the end of the build log. This is useful when debugging build issues.
  8838. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  8839. build issues.
  8840. This option implies @option{--no-offload}, and it has no effect when
  8841. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  8842. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  8843. @item --keep-going
  8844. @itemx -k
  8845. Keep going when some of the derivations fail to build; return only once
  8846. all the builds have either completed or failed.
  8847. The default behavior is to stop as soon as one of the specified
  8848. derivations has failed.
  8849. @item --dry-run
  8850. @itemx -n
  8851. Do not build the derivations.
  8852. @anchor{fallback-option}
  8853. @item --fallback
  8854. When substituting a pre-built binary fails, fall back to building
  8855. packages locally (@pxref{Substitution Failure}).
  8856. @item --substitute-urls=@var{urls}
  8857. @anchor{client-substitute-urls}
  8858. Consider @var{urls} the whitespace-separated list of substitute source
  8859. URLs, overriding the default list of URLs of @command{guix-daemon}
  8860. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  8861. This means that substitutes may be downloaded from @var{urls}, provided
  8862. they are signed by a key authorized by the system administrator
  8863. (@pxref{Substitutes}).
  8864. When @var{urls} is the empty string, substitutes are effectively
  8865. disabled.
  8866. @item --no-substitutes
  8867. Do not use substitutes for build products. That is, always build things
  8868. locally instead of allowing downloads of pre-built binaries
  8869. (@pxref{Substitutes}).
  8870. @item --no-grafts
  8871. Do not ``graft'' packages. In practice, this means that package updates
  8872. available as grafts are not applied. @xref{Security Updates}, for more
  8873. information on grafts.
  8874. @item --rounds=@var{n}
  8875. Build each derivation @var{n} times in a row, and raise an error if
  8876. consecutive build results are not bit-for-bit identical.
  8877. This is a useful way to detect non-deterministic builds processes.
  8878. Non-deterministic build processes are a problem because they make it
  8879. practically impossible for users to @emph{verify} whether third-party
  8880. binaries are genuine. @xref{Invoking guix challenge}, for more.
  8881. When used in conjunction with @option{--keep-failed}, the differing
  8882. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8883. This makes it easy to look for differences between the two results.
  8884. @item --no-offload
  8885. Do not use offload builds to other machines (@pxref{Daemon Offload
  8886. Setup}). That is, always build things locally instead of offloading
  8887. builds to remote machines.
  8888. @item --max-silent-time=@var{seconds}
  8889. When the build or substitution process remains silent for more than
  8890. @var{seconds}, terminate it and report a build failure.
  8891. By default, the daemon's setting is honored (@pxref{Invoking
  8892. guix-daemon, @option{--max-silent-time}}).
  8893. @item --timeout=@var{seconds}
  8894. Likewise, when the build or substitution process lasts for more than
  8895. @var{seconds}, terminate it and report a build failure.
  8896. By default, the daemon's setting is honored (@pxref{Invoking
  8897. guix-daemon, @option{--timeout}}).
  8898. @c Note: This option is actually not part of %standard-build-options but
  8899. @c most programs honor it.
  8900. @cindex verbosity, of the command-line tools
  8901. @cindex build logs, verbosity
  8902. @item -v @var{level}
  8903. @itemx --verbosity=@var{level}
  8904. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  8905. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  8906. additionally displays download URLs; 3 shows all the build log output on
  8907. standard error.
  8908. @item --cores=@var{n}
  8909. @itemx -c @var{n}
  8910. Allow the use of up to @var{n} CPU cores for the build. The special
  8911. value @code{0} means to use as many CPU cores as available.
  8912. @item --max-jobs=@var{n}
  8913. @itemx -M @var{n}
  8914. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  8915. guix-daemon, @option{--max-jobs}}, for details about this option and the
  8916. equivalent @command{guix-daemon} option.
  8917. @item --debug=@var{level}
  8918. Produce debugging output coming from the build daemon. @var{level} must be an
  8919. integer between 0 and 5; higher means more verbose output. Setting a level of
  8920. 4 or more may be helpful when debugging setup issues with the build daemon.
  8921. @end table
  8922. Behind the scenes, @command{guix build} is essentially an interface to
  8923. the @code{package-derivation} procedure of the @code{(guix packages)}
  8924. module, and to the @code{build-derivations} procedure of the @code{(guix
  8925. derivations)} module.
  8926. In addition to options explicitly passed on the command line,
  8927. @command{guix build} and other @command{guix} commands that support
  8928. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  8929. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  8930. Users can define this variable to a list of command line options that
  8931. will automatically be used by @command{guix build} and other
  8932. @command{guix} commands that can perform builds, as in the example
  8933. below:
  8934. @example
  8935. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  8936. @end example
  8937. These options are parsed independently, and the result is appended to
  8938. the parsed command-line options.
  8939. @end defvr
  8940. @node Package Transformation Options
  8941. @subsection Package Transformation Options
  8942. @cindex package variants
  8943. Another set of command-line options supported by @command{guix build}
  8944. and also @command{guix package} are @dfn{package transformation
  8945. options}. These are options that make it possible to define @dfn{package
  8946. variants}---for instance, packages built from different source code.
  8947. This is a convenient way to create customized packages on the fly
  8948. without having to type in the definitions of package variants
  8949. (@pxref{Defining Packages}).
  8950. Package transformation options are preserved across upgrades:
  8951. @command{guix upgrade} attempts to apply transformation options
  8952. initially used when creating the profile to the upgraded packages.
  8953. The available options are listed below. Most commands support them and
  8954. also support a @option{--help-transform} option that lists all the
  8955. available options and a synopsis (these options are not shown in the
  8956. @option{--help} output for brevity).
  8957. @table @code
  8958. @cindex performance, tuning code
  8959. @cindex optimization, of package code
  8960. @cindex tuning, of package code
  8961. @cindex SIMD support
  8962. @cindex tunable packages
  8963. @cindex package multi-versioning
  8964. @item --tune[=@var{cpu}]
  8965. Use versions of the packages marked as ``tunable'' optimized for
  8966. @var{cpu}. When @var{cpu} is @code{native}, or when it is omitted, tune
  8967. for the CPU on which the @command{guix} command is running.
  8968. Valid @var{cpu} names are those recognized by the underlying compiler,
  8969. by default the GNU Compiler Collection. On x86_64 processors, this
  8970. includes CPU names such as @code{nehalem}, @code{haswell}, and
  8971. @code{skylake} (@pxref{x86 Options, @code{-march},, gcc, Using the GNU
  8972. Compiler Collection (GCC)}).
  8973. As new generations of CPUs come out, they augment the standard
  8974. instruction set architecture (ISA) with additional instructions, in
  8975. particular instructions for single-instruction/multiple-data (SIMD)
  8976. parallel processing. For example, while Core2 and Skylake CPUs both
  8977. implement the x86_64 ISA, only the latter supports AVX2 SIMD
  8978. instructions.
  8979. The primary gain one can expect from @option{--tune} is for programs
  8980. that can make use of those SIMD capabilities @emph{and} that do not
  8981. already have a mechanism to select the right optimized code at run time.
  8982. Packages that have the @code{tunable?} property set are considered
  8983. @dfn{tunable packages} by the @option{--tune} option; a package
  8984. definition with the property set looks like this:
  8985. @lisp
  8986. (package
  8987. (name "hello-simd")
  8988. ;; ...
  8989. ;; This package may benefit from SIMD extensions so
  8990. ;; mark it as "tunable".
  8991. (properties '((tunable? . #t))))
  8992. @end lisp
  8993. Other packages are not considered tunable. This allows Guix to use
  8994. generic binaries in the cases where tuning for a specific CPU is
  8995. unlikely to provide any gain.
  8996. Tuned packages are built with @code{-march=@var{CPU}}; under the hood,
  8997. the @option{-march} option is passed to the actual wrapper by a compiler
  8998. wrapper. Since the build machine may not be able to run code for the
  8999. target CPU micro-architecture, the test suite is not run when building a
  9000. tuned package.
  9001. To reduce rebuilds to the minimum, tuned packages are @emph{grafted}
  9002. onto packages that depend on them (@pxref{Security Updates, grafts}).
  9003. Thus, using @option{--no-grafts} cancels the effect of @option{--tune}.
  9004. We call this technique @dfn{package multi-versioning}: several variants
  9005. of tunable packages may be built, one for each CPU variant. It is the
  9006. coarse-grain counterpart of @dfn{function multi-versioning} as
  9007. implemented by the GNU tool chain (@pxref{Function Multiversioning,,,
  9008. gcc, Using the GNU Compiler Collection (GCC)}).
  9009. @item --with-source=@var{source}
  9010. @itemx --with-source=@var{package}=@var{source}
  9011. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  9012. Use @var{source} as the source of @var{package}, and @var{version} as
  9013. its version number.
  9014. @var{source} must be a file name or a URL, as for @command{guix
  9015. download} (@pxref{Invoking guix download}).
  9016. When @var{package} is omitted,
  9017. it is taken to be the package name specified on the
  9018. command line that matches the base of @var{source}---e.g.,
  9019. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  9020. package is @code{guile}.
  9021. Likewise, when @var{version} is omitted, the version string is inferred from
  9022. @var{source}; in the previous example, it is @code{2.0.10}.
  9023. This option allows users to try out versions of packages other than the
  9024. one provided by the distribution. The example below downloads
  9025. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  9026. the @code{ed} package:
  9027. @example
  9028. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  9029. @end example
  9030. As a developer, @option{--with-source} makes it easy to test release
  9031. candidates:
  9032. @example
  9033. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  9034. @end example
  9035. @dots{} or to build from a checkout in a pristine environment:
  9036. @example
  9037. $ git clone git://git.sv.gnu.org/guix.git
  9038. $ guix build guix --with-source=guix@@1.0=./guix
  9039. @end example
  9040. @item --with-input=@var{package}=@var{replacement}
  9041. Replace dependency on @var{package} by a dependency on
  9042. @var{replacement}. @var{package} must be a package name, and
  9043. @var{replacement} must be a package specification such as @code{guile}
  9044. or @code{guile@@1.8}.
  9045. For instance, the following command builds Guix, but replaces its
  9046. dependency on the current stable version of Guile with a dependency on
  9047. the legacy version of Guile, @code{guile@@2.0}:
  9048. @example
  9049. guix build --with-input=guile=guile@@2.0 guix
  9050. @end example
  9051. This is a recursive, deep replacement. So in this example, both
  9052. @code{guix} and its dependency @code{guile-json} (which also depends on
  9053. @code{guile}) get rebuilt against @code{guile@@2.0}.
  9054. This is implemented using the @code{package-input-rewriting} Scheme
  9055. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  9056. @item --with-graft=@var{package}=@var{replacement}
  9057. This is similar to @option{--with-input} but with an important difference:
  9058. instead of rebuilding the whole dependency chain, @var{replacement} is
  9059. built and then @dfn{grafted} onto the binaries that were initially
  9060. referring to @var{package}. @xref{Security Updates}, for more
  9061. information on grafts.
  9062. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  9063. and all its dependencies, replacing references to the version of GnuTLS
  9064. they currently refer to:
  9065. @example
  9066. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  9067. @end example
  9068. This has the advantage of being much faster than rebuilding everything.
  9069. But there is a caveat: it works if and only if @var{package} and
  9070. @var{replacement} are strictly compatible---for example, if they provide
  9071. a library, the application binary interface (ABI) of those libraries
  9072. must be compatible. If @var{replacement} is somehow incompatible with
  9073. @var{package}, then the resulting package may be unusable. Use with
  9074. care!
  9075. @cindex debugging info, rebuilding
  9076. @item --with-debug-info=@var{package}
  9077. Build @var{package} in a way that preserves its debugging info and graft
  9078. it onto packages that depend on it. This is useful if @var{package}
  9079. does not already provide debugging info as a @code{debug} output
  9080. (@pxref{Installing Debugging Files}).
  9081. For example, suppose you're experiencing a crash in Inkscape and would
  9082. like to see what's up in GLib, a library deep down in Inkscape's
  9083. dependency graph. GLib lacks a @code{debug} output, so debugging is
  9084. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  9085. Inkscape:
  9086. @example
  9087. guix install inkscape --with-debug-info=glib
  9088. @end example
  9089. Only GLib needs to be recompiled so this takes a reasonable amount of
  9090. time. @xref{Installing Debugging Files}, for more info.
  9091. @quotation Note
  9092. Under the hood, this option works by passing the @samp{#:strip-binaries?
  9093. #f} to the build system of the package of interest (@pxref{Build
  9094. Systems}). Most build systems support that option but some do not. In
  9095. that case, an error is raised.
  9096. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  9097. the case), debugging info will remain unavailable even when
  9098. @code{#:strip-binaries?} is false.
  9099. @end quotation
  9100. @cindex tool chain, changing the build tool chain of a package
  9101. @item --with-c-toolchain=@var{package}=@var{toolchain}
  9102. This option changes the compilation of @var{package} and everything that
  9103. depends on it so that they get built with @var{toolchain} instead of the
  9104. default GNU tool chain for C/C++.
  9105. Consider this example:
  9106. @example
  9107. guix build octave-cli \
  9108. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  9109. --with-c-toolchain=fftwf=gcc-toolchain@@10
  9110. @end example
  9111. The command above builds a variant of the @code{fftw} and @code{fftwf}
  9112. packages using version 10 of @code{gcc-toolchain} instead of the default
  9113. tool chain, and then builds a variant of the GNU@tie{}Octave
  9114. command-line interface using them. GNU@tie{}Octave itself is also built
  9115. with @code{gcc-toolchain@@10}.
  9116. This other example builds the Hardware Locality (@code{hwloc}) library
  9117. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  9118. compiler:
  9119. @example
  9120. guix build --with-c-toolchain=hwloc=clang-toolchain \
  9121. intel-mpi-benchmarks
  9122. @end example
  9123. @quotation Note
  9124. There can be application binary interface (ABI) incompatibilities among
  9125. tool chains. This is particularly true of the C++ standard library and
  9126. run-time support libraries such as that of OpenMP@. By rebuilding all
  9127. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  9128. the risks of incompatibility but cannot entirely eliminate them. Choose
  9129. @var{package} wisely.
  9130. @end quotation
  9131. @item --with-git-url=@var{package}=@var{url}
  9132. @cindex Git, using the latest commit
  9133. @cindex latest commit, building
  9134. Build @var{package} from the latest commit of the @code{master} branch of the
  9135. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  9136. recursively.
  9137. For example, the following command builds the NumPy Python library against the
  9138. latest commit of the master branch of Python itself:
  9139. @example
  9140. guix build python-numpy \
  9141. --with-git-url=python=https://github.com/python/cpython
  9142. @end example
  9143. This option can also be combined with @option{--with-branch} or
  9144. @option{--with-commit} (see below).
  9145. @cindex continuous integration
  9146. Obviously, since it uses the latest commit of the given branch, the result of
  9147. such a command varies over time. Nevertheless it is a convenient way to
  9148. rebuild entire software stacks against the latest commit of one or more
  9149. packages. This is particularly useful in the context of continuous
  9150. integration (CI).
  9151. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  9152. consecutive accesses to the same repository. You may want to clean it up once
  9153. in a while to save disk space.
  9154. @item --with-branch=@var{package}=@var{branch}
  9155. Build @var{package} from the latest commit of @var{branch}. If the
  9156. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  9157. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  9158. repository URL is taken from that @code{source}. Otherwise you have to use
  9159. @option{--with-git-url} to specify the URL of the Git repository.
  9160. For instance, the following command builds @code{guile-sqlite3} from the
  9161. latest commit of its @code{master} branch, and then builds @code{guix} (which
  9162. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  9163. specific @code{guile-sqlite3} build:
  9164. @example
  9165. guix build --with-branch=guile-sqlite3=master cuirass
  9166. @end example
  9167. @item --with-commit=@var{package}=@var{commit}
  9168. This is similar to @option{--with-branch}, except that it builds from
  9169. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  9170. Git commit SHA1 identifier, a tag, or a @command{git describe} style
  9171. identifier such as @code{1.0-3-gabc123}.
  9172. @item --with-patch=@var{package}=@var{file}
  9173. Add @var{file} to the list of patches applied to @var{package}, where
  9174. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  9175. @var{file} must contain a patch; it is applied with the flags specified
  9176. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  9177. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  9178. Comparing and Merging Files}).
  9179. As an example, the command below rebuilds Coreutils with the GNU C
  9180. Library (glibc) patched with the given patch:
  9181. @example
  9182. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  9183. @end example
  9184. In this example, glibc itself as well as everything that leads to
  9185. Coreutils in the dependency graph is rebuilt.
  9186. @cindex upstream, latest version
  9187. @item --with-latest=@var{package}
  9188. So you like living on the bleeding edge? This option is for you! It
  9189. replaces occurrences of @var{package} in the dependency graph with its
  9190. latest upstream version, as reported by @command{guix refresh}
  9191. (@pxref{Invoking guix refresh}).
  9192. It does so by determining the latest upstream release of @var{package}
  9193. (if possible), downloading it, and authenticating it @emph{if} it comes
  9194. with an OpenPGP signature.
  9195. As an example, the command below builds Guix against the latest version
  9196. of Guile-JSON:
  9197. @example
  9198. guix build guix --with-latest=guile-json
  9199. @end example
  9200. There are limitations. First, in cases where the tool cannot or does
  9201. not know how to authenticate source code, you are at risk of running
  9202. malicious code; a warning is emitted in this case. Second, this option
  9203. simply changes the source used in the existing package definitions,
  9204. which is not always sufficient: there might be additional dependencies
  9205. that need to be added, patches to apply, and more generally the quality
  9206. assurance work that Guix developers normally do will be missing.
  9207. You've been warned! In all the other cases, it's a snappy way to stay
  9208. on top. We encourage you to submit patches updating the actual package
  9209. definitions once you have successfully tested an upgrade
  9210. (@pxref{Contributing}).
  9211. @cindex test suite, skipping
  9212. @item --without-tests=@var{package}
  9213. Build @var{package} without running its tests. This can be useful in
  9214. situations where you want to skip the lengthy test suite of a
  9215. intermediate package, or if a package's test suite fails in a
  9216. non-deterministic fashion. It should be used with care because running
  9217. the test suite is a good way to ensure a package is working as intended.
  9218. Turning off tests leads to a different store item. Consequently, when
  9219. using this option, anything that depends on @var{package} must be
  9220. rebuilt, as in this example:
  9221. @example
  9222. guix install --without-tests=python python-notebook
  9223. @end example
  9224. The command above installs @code{python-notebook} on top of
  9225. @code{python} built without running its test suite. To do so, it also
  9226. rebuilds everything that depends on @code{python}, including
  9227. @code{python-notebook} itself.
  9228. Internally, @option{--without-tests} relies on changing the
  9229. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  9230. Systems}). Note that some packages use a customized @code{check} phase
  9231. that does not respect a @code{#:tests? #f} setting. Therefore,
  9232. @option{--without-tests} has no effect on these packages.
  9233. @end table
  9234. Wondering how to achieve the same effect using Scheme code, for example
  9235. in your manifest, or how to write your own package transformation?
  9236. @xref{Defining Package Variants}, for an overview of the programming
  9237. interfaces available.
  9238. @node Additional Build Options
  9239. @subsection Additional Build Options
  9240. The command-line options presented below are specific to @command{guix
  9241. build}.
  9242. @table @code
  9243. @item --quiet
  9244. @itemx -q
  9245. Build quietly, without displaying the build log; this is equivalent to
  9246. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  9247. (or similar) and can always be retrieved using the @option{--log-file} option.
  9248. @item --file=@var{file}
  9249. @itemx -f @var{file}
  9250. Build the package, derivation, or other file-like object that the code within
  9251. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  9252. As an example, @var{file} might contain a package definition like this
  9253. (@pxref{Defining Packages}):
  9254. @lisp
  9255. @include package-hello.scm
  9256. @end lisp
  9257. The @var{file} may also contain a JSON representation of one or more
  9258. package definitions. Running @code{guix build -f} on @file{hello.json}
  9259. with the following contents would result in building the packages
  9260. @code{myhello} and @code{greeter}:
  9261. @example
  9262. @verbatiminclude package-hello.json
  9263. @end example
  9264. @item --manifest=@var{manifest}
  9265. @itemx -m @var{manifest}
  9266. Build all packages listed in the given @var{manifest}
  9267. (@pxref{profile-manifest, @option{--manifest}}).
  9268. @item --expression=@var{expr}
  9269. @itemx -e @var{expr}
  9270. Build the package or derivation @var{expr} evaluates to.
  9271. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  9272. guile-1.8)}, which unambiguously designates this specific variant of
  9273. version 1.8 of Guile.
  9274. Alternatively, @var{expr} may be a G-expression, in which case it is used
  9275. as a build program passed to @code{gexp->derivation}
  9276. (@pxref{G-Expressions}).
  9277. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  9278. (@pxref{The Store Monad}). The procedure must return a derivation as a
  9279. monadic value, which is then passed through @code{run-with-store}.
  9280. @item --source
  9281. @itemx -S
  9282. Build the source derivations of the packages, rather than the packages
  9283. themselves.
  9284. For instance, @code{guix build -S gcc} returns something like
  9285. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  9286. source tarball.
  9287. The returned source tarball is the result of applying any patches and
  9288. code snippets specified in the package @code{origin} (@pxref{Defining
  9289. Packages}).
  9290. @cindex source, verification
  9291. As with other derivations, the result of building a source derivation
  9292. can be verified using the @option{--check} option (@pxref{build-check}).
  9293. This is useful to validate that a (potentially already built or
  9294. substituted, thus cached) package source matches against its declared
  9295. hash.
  9296. Note that @command{guix build -S} compiles the sources only of the
  9297. specified packages. They do not include the sources of statically
  9298. linked dependencies and by themselves are insufficient for reproducing
  9299. the packages.
  9300. @item --sources
  9301. Fetch and return the source of @var{package-or-derivation} and all their
  9302. dependencies, recursively. This is a handy way to obtain a local copy
  9303. of all the source code needed to build @var{packages}, allowing you to
  9304. eventually build them even without network access. It is an extension
  9305. of the @option{--source} option and can accept one of the following
  9306. optional argument values:
  9307. @table @code
  9308. @item package
  9309. This value causes the @option{--sources} option to behave in the same way
  9310. as the @option{--source} option.
  9311. @item all
  9312. Build the source derivations of all packages, including any source that
  9313. might be listed as @code{inputs}. This is the default value.
  9314. @example
  9315. $ guix build --sources tzdata
  9316. The following derivations will be built:
  9317. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  9318. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  9319. @end example
  9320. @item transitive
  9321. Build the source derivations of all packages, as well of all transitive
  9322. inputs to the packages. This can be used e.g.@: to
  9323. prefetch package source for later offline building.
  9324. @example
  9325. $ guix build --sources=transitive tzdata
  9326. The following derivations will be built:
  9327. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  9328. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  9329. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  9330. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  9331. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  9332. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  9333. @dots{}
  9334. @end example
  9335. @end table
  9336. @item --system=@var{system}
  9337. @itemx -s @var{system}
  9338. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  9339. the system type of the build host. The @command{guix build} command allows
  9340. you to repeat this option several times, in which case it builds for all the
  9341. specified systems; other commands ignore extraneous @option{-s} options.
  9342. @quotation Note
  9343. The @option{--system} flag is for @emph{native} compilation and must not
  9344. be confused with cross-compilation. See @option{--target} below for
  9345. information on cross-compilation.
  9346. @end quotation
  9347. An example use of this is on Linux-based systems, which can emulate
  9348. different personalities. For instance, passing
  9349. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  9350. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  9351. you to build packages in a complete 32-bit environment.
  9352. @quotation Note
  9353. Building for an @code{armhf-linux} system is unconditionally enabled on
  9354. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  9355. allow for this functionality, notably the ThunderX.
  9356. @end quotation
  9357. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  9358. is enabled (@pxref{Virtualization Services,
  9359. @code{qemu-binfmt-service-type}}), you can build for any system for
  9360. which a QEMU @code{binfmt_misc} handler is installed.
  9361. Builds for a system other than that of the machine you are using can
  9362. also be offloaded to a remote machine of the right architecture.
  9363. @xref{Daemon Offload Setup}, for more information on offloading.
  9364. @item --target=@var{triplet}
  9365. @cindex cross-compilation
  9366. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  9367. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  9368. configuration triplets,, autoconf, Autoconf}).
  9369. @anchor{build-check}
  9370. @item --check
  9371. @cindex determinism, checking
  9372. @cindex reproducibility, checking
  9373. Rebuild @var{package-or-derivation}, which are already available in the
  9374. store, and raise an error if the build results are not bit-for-bit
  9375. identical.
  9376. This mechanism allows you to check whether previously installed
  9377. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  9378. of a package is deterministic. @xref{Invoking guix challenge}, for more
  9379. background information and tools.
  9380. When used in conjunction with @option{--keep-failed}, the differing
  9381. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  9382. This makes it easy to look for differences between the two results.
  9383. @item --repair
  9384. @cindex repairing store items
  9385. @cindex corruption, recovering from
  9386. Attempt to repair the specified store items, if they are corrupt, by
  9387. re-downloading or rebuilding them.
  9388. This operation is not atomic and thus restricted to @code{root}.
  9389. @item --derivations
  9390. @itemx -d
  9391. Return the derivation paths, not the output paths, of the given
  9392. packages.
  9393. @item --root=@var{file}
  9394. @itemx -r @var{file}
  9395. @cindex GC roots, adding
  9396. @cindex garbage collector roots, adding
  9397. Make @var{file} a symlink to the result, and register it as a garbage
  9398. collector root.
  9399. Consequently, the results of this @command{guix build} invocation are
  9400. protected from garbage collection until @var{file} is removed. When
  9401. that option is omitted, build results are eligible for garbage
  9402. collection as soon as the build completes. @xref{Invoking guix gc}, for
  9403. more on GC roots.
  9404. @item --log-file
  9405. @cindex build logs, access
  9406. Return the build log file names or URLs for the given
  9407. @var{package-or-derivation}, or raise an error if build logs are
  9408. missing.
  9409. This works regardless of how packages or derivations are specified. For
  9410. instance, the following invocations are equivalent:
  9411. @example
  9412. guix build --log-file $(guix build -d guile)
  9413. guix build --log-file $(guix build guile)
  9414. guix build --log-file guile
  9415. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  9416. @end example
  9417. If a log is unavailable locally, and unless @option{--no-substitutes} is
  9418. passed, the command looks for a corresponding log on one of the
  9419. substitute servers (as specified with @option{--substitute-urls}).
  9420. So for instance, imagine you want to see the build log of GDB on MIPS,
  9421. but you are actually on an @code{x86_64} machine:
  9422. @example
  9423. $ guix build --log-file gdb -s aarch64-linux
  9424. https://@value{SUBSTITUTE-SERVER-1}/log/@dots{}-gdb-7.10
  9425. @end example
  9426. You can freely access a huge library of build logs!
  9427. @end table
  9428. @node Debugging Build Failures
  9429. @subsection Debugging Build Failures
  9430. @cindex build failures, debugging
  9431. When defining a new package (@pxref{Defining Packages}), you will
  9432. probably find yourself spending some time debugging and tweaking the
  9433. build until it succeeds. To do that, you need to operate the build
  9434. commands yourself in an environment as close as possible to the one the
  9435. build daemon uses.
  9436. To that end, the first thing to do is to use the @option{--keep-failed}
  9437. or @option{-K} option of @command{guix build}, which will keep the
  9438. failed build tree in @file{/tmp} or whatever directory you specified as
  9439. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  9440. From there on, you can @command{cd} to the failed build tree and source
  9441. the @file{environment-variables} file, which contains all the
  9442. environment variable definitions that were in place when the build
  9443. failed. So let's say you're debugging a build failure in package
  9444. @code{foo}; a typical session would look like this:
  9445. @example
  9446. $ guix build foo -K
  9447. @dots{} @i{build fails}
  9448. $ cd /tmp/guix-build-foo.drv-0
  9449. $ source ./environment-variables
  9450. $ cd foo-1.2
  9451. @end example
  9452. Now, you can invoke commands as if you were the daemon (almost) and
  9453. troubleshoot your build process.
  9454. Sometimes it happens that, for example, a package's tests pass when you
  9455. run them manually but they fail when the daemon runs them. This can
  9456. happen because the daemon runs builds in containers where, unlike in our
  9457. environment above, network access is missing, @file{/bin/sh} does not
  9458. exist, etc. (@pxref{Build Environment Setup}).
  9459. In such cases, you may need to run inspect the build process from within
  9460. a container similar to the one the build daemon creates:
  9461. @example
  9462. $ guix build -K foo
  9463. @dots{}
  9464. $ cd /tmp/guix-build-foo.drv-0
  9465. $ guix shell --no-grafts -C -D foo strace gdb
  9466. [env]# source ./environment-variables
  9467. [env]# cd foo-1.2
  9468. @end example
  9469. Here, @command{guix shell -C} creates a container and spawns a new
  9470. shell in it (@pxref{Invoking guix shell}). The @command{strace gdb}
  9471. part adds the @command{strace} and @command{gdb} commands to
  9472. the container, which you may find handy while debugging. The
  9473. @option{--no-grafts} option makes sure we get the exact same
  9474. environment, with ungrafted packages (@pxref{Security Updates}, for more
  9475. info on grafts).
  9476. To get closer to a container like that used by the build daemon, we can
  9477. remove @file{/bin/sh}:
  9478. @example
  9479. [env]# rm /bin/sh
  9480. @end example
  9481. (Don't worry, this is harmless: this is all happening in the throw-away
  9482. container created by @command{guix shell}.)
  9483. The @command{strace} command is probably not in the search path, but we
  9484. can run:
  9485. @example
  9486. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  9487. @end example
  9488. In this way, not only you will have reproduced the environment variables
  9489. the daemon uses, you will also be running the build process in a container
  9490. similar to the one the daemon uses.
  9491. @node Invoking guix edit
  9492. @section Invoking @command{guix edit}
  9493. @cindex @command{guix edit}
  9494. @cindex package definition, editing
  9495. So many packages, so many source files! The @command{guix edit} command
  9496. facilitates the life of users and packagers by pointing their editor at
  9497. the source file containing the definition of the specified packages.
  9498. For instance:
  9499. @example
  9500. guix edit gcc@@4.9 vim
  9501. @end example
  9502. @noindent
  9503. launches the program specified in the @env{VISUAL} or in the
  9504. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  9505. and that of Vim.
  9506. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  9507. have created your own packages on @env{GUIX_PACKAGE_PATH}
  9508. (@pxref{Package Modules}), you will be able to edit the package
  9509. recipes. In other cases, you will be able to examine the read-only recipes
  9510. for packages currently in the store.
  9511. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  9512. @option{--load-path=@var{directory}} (or in short @option{-L
  9513. @var{directory}}) allows you to add @var{directory} to the front of the
  9514. package module search path and so make your own packages visible.
  9515. @node Invoking guix download
  9516. @section Invoking @command{guix download}
  9517. @cindex @command{guix download}
  9518. @cindex downloading package sources
  9519. When writing a package definition, developers typically need to download
  9520. a source tarball, compute its SHA256 hash, and write that
  9521. hash in the package definition (@pxref{Defining Packages}). The
  9522. @command{guix download} tool helps with this task: it downloads a file
  9523. from the given URI, adds it to the store, and prints both its file name
  9524. in the store and its SHA256 hash.
  9525. The fact that the downloaded file is added to the store saves bandwidth:
  9526. when the developer eventually tries to build the newly defined package
  9527. with @command{guix build}, the source tarball will not have to be
  9528. downloaded again because it is already in the store. It is also a
  9529. convenient way to temporarily stash files, which may be deleted
  9530. eventually (@pxref{Invoking guix gc}).
  9531. The @command{guix download} command supports the same URIs as used in
  9532. package definitions. In particular, it supports @code{mirror://} URIs.
  9533. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  9534. Guile bindings for GnuTLS are available in the user's environment; when
  9535. they are not available, an error is raised. @xref{Guile Preparations,
  9536. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  9537. GnuTLS-Guile}, for more information.
  9538. @command{guix download} verifies HTTPS server certificates by loading
  9539. the certificates of X.509 authorities from the directory pointed to by
  9540. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  9541. Certificates}), unless @option{--no-check-certificate} is used.
  9542. The following options are available:
  9543. @table @code
  9544. @item --hash=@var{algorithm}
  9545. @itemx -H @var{algorithm}
  9546. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  9547. hash}, for more information.
  9548. @item --format=@var{fmt}
  9549. @itemx -f @var{fmt}
  9550. Write the hash in the format specified by @var{fmt}. For more
  9551. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  9552. @item --no-check-certificate
  9553. Do not validate the X.509 certificates of HTTPS servers.
  9554. When using this option, you have @emph{absolutely no guarantee} that you
  9555. are communicating with the authentic server responsible for the given
  9556. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  9557. @item --output=@var{file}
  9558. @itemx -o @var{file}
  9559. Save the downloaded file to @var{file} instead of adding it to the
  9560. store.
  9561. @end table
  9562. @node Invoking guix hash
  9563. @section Invoking @command{guix hash}
  9564. @cindex @command{guix hash}
  9565. The @command{guix hash} command computes the hash of a file.
  9566. It is primarily a convenience tool for anyone contributing to the
  9567. distribution: it computes the cryptographic hash of one or more files, which can be
  9568. used in the definition of a package (@pxref{Defining Packages}).
  9569. The general syntax is:
  9570. @example
  9571. guix hash @var{option} @var{file} ...
  9572. @end example
  9573. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  9574. hash of data read from standard input. @command{guix hash} has the
  9575. following options:
  9576. @table @code
  9577. @item --hash=@var{algorithm}
  9578. @itemx -H @var{algorithm}
  9579. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  9580. default.
  9581. @var{algorithm} must the name of a cryptographic hash algorithm
  9582. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  9583. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  9584. Reference Manual}).
  9585. @item --format=@var{fmt}
  9586. @itemx -f @var{fmt}
  9587. Write the hash in the format specified by @var{fmt}.
  9588. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  9589. (@code{hex} and @code{hexadecimal} can be used as well).
  9590. If the @option{--format} option is not specified, @command{guix hash}
  9591. will output the hash in @code{nix-base32}. This representation is used
  9592. in the definitions of packages.
  9593. @item --recursive
  9594. @itemx -r
  9595. This option is deprecated in favor of @option{--serializer}. It is a
  9596. legacy alias for @var{type} sets to @code{nar}.
  9597. @item --serializer=@var{type}
  9598. @itemx -S
  9599. Compute the hash on @var{file} using @var{type} serialization.
  9600. @var{type} may be one of the following:
  9601. @table @code
  9602. @item none
  9603. This is the default: it computes the hash of a file's contents.
  9604. @item nar
  9605. Compute the hash of a ``normalized archive'' (or ``nar'') containing
  9606. @var{file}, including its children if it is a directory. Some of the
  9607. metadata of @var{file} is part of the archive; for instance, when
  9608. @var{file} is a regular file, the hash is different depending on whether
  9609. @var{file} is executable or not. Metadata such as time stamps has no
  9610. impact on the hash (@pxref{Invoking guix archive}, for more info on the
  9611. nar format).
  9612. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  9613. @c it exists.
  9614. @item git
  9615. Compute the has of the file or directory as a Git ``tree'', following
  9616. the same method as the Git version control system.
  9617. @end table
  9618. @item --exclude-vcs
  9619. @itemx -x
  9620. When combined with @option{--recursive}, exclude version control system
  9621. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  9622. @vindex git-fetch
  9623. As an example, here is how you would compute the hash of a Git checkout,
  9624. which is useful when using the @code{git-fetch} method (@pxref{origin
  9625. Reference}):
  9626. @example
  9627. $ git clone http://example.org/foo.git
  9628. $ cd foo
  9629. $ guix hash -rx .
  9630. @end example
  9631. @end table
  9632. @node Invoking guix import
  9633. @section Invoking @command{guix import}
  9634. @cindex importing packages
  9635. @cindex package import
  9636. @cindex package conversion
  9637. @cindex Invoking @command{guix import}
  9638. The @command{guix import} command is useful for people who would like to
  9639. add a package to the distribution with as little work as
  9640. possible---a legitimate demand. The command knows of a few
  9641. repositories from which it can ``import'' package metadata. The result
  9642. is a package definition, or a template thereof, in the format we know
  9643. (@pxref{Defining Packages}).
  9644. The general syntax is:
  9645. @example
  9646. guix import @var{importer} @var{options}@dots{}
  9647. @end example
  9648. @var{importer} specifies the source from which to import package
  9649. metadata, and @var{options} specifies a package identifier and other
  9650. options specific to @var{importer}.
  9651. Some of the importers rely on the ability to run the @command{gpgv} command.
  9652. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  9653. gnupg} if needed.
  9654. Currently, the available ``importers'' are:
  9655. @table @code
  9656. @item gnu
  9657. Import metadata for the given GNU package. This provides a template
  9658. for the latest version of that GNU package, including the hash of its
  9659. source tarball, and its canonical synopsis and description.
  9660. Additional information such as the package dependencies and its
  9661. license needs to be figured out manually.
  9662. For example, the following command returns a package definition for
  9663. GNU@tie{}Hello:
  9664. @example
  9665. guix import gnu hello
  9666. @end example
  9667. Specific command-line options are:
  9668. @table @code
  9669. @item --key-download=@var{policy}
  9670. As for @command{guix refresh}, specify the policy to handle missing
  9671. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  9672. refresh, @option{--key-download}}.
  9673. @end table
  9674. @item pypi
  9675. @cindex pypi
  9676. Import metadata from the @uref{https://pypi.python.org/, Python Package
  9677. Index}. Information is taken from the JSON-formatted description
  9678. available at @code{pypi.python.org} and usually includes all the relevant
  9679. information, including package dependencies. For maximum efficiency, it
  9680. is recommended to install the @command{unzip} utility, so that the
  9681. importer can unzip Python wheels and gather data from them.
  9682. The command below imports metadata for the latest version of the
  9683. @code{itsdangerous} Python package:
  9684. @example
  9685. guix import pypi itsdangerous
  9686. @end example
  9687. You can also ask for a specific version:
  9688. @example
  9689. guix import pypi itsdangerous@@1.1.0
  9690. @end example
  9691. @table @code
  9692. @item --recursive
  9693. @itemx -r
  9694. Traverse the dependency graph of the given upstream package recursively
  9695. and generate package expressions for all those packages that are not yet
  9696. in Guix.
  9697. @end table
  9698. @item gem
  9699. @cindex gem
  9700. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  9701. is taken from the JSON-formatted description available at
  9702. @code{rubygems.org} and includes most relevant information, including
  9703. runtime dependencies. There are some caveats, however. The metadata
  9704. doesn't distinguish between synopses and descriptions, so the same string
  9705. is used for both fields. Additionally, the details of non-Ruby
  9706. dependencies required to build native extensions is unavailable and left
  9707. as an exercise to the packager.
  9708. The command below imports metadata for the @code{rails} Ruby package:
  9709. @example
  9710. guix import gem rails
  9711. @end example
  9712. @table @code
  9713. @item --recursive
  9714. @itemx -r
  9715. Traverse the dependency graph of the given upstream package recursively
  9716. and generate package expressions for all those packages that are not yet
  9717. in Guix.
  9718. @end table
  9719. @item minetest
  9720. @cindex minetest
  9721. @cindex ContentDB
  9722. Import metadata from @uref{https://content.minetest.net, ContentDB}.
  9723. Information is taken from the JSON-formatted metadata provided through
  9724. @uref{https://content.minetest.net/help/api/, ContentDB's API} and
  9725. includes most relevant information, including dependencies. There are
  9726. some caveats, however. The license information is often incomplete.
  9727. The commit hash is sometimes missing. The descriptions are in the
  9728. Markdown format, but Guix uses Texinfo instead. Texture packs and
  9729. subgames are unsupported.
  9730. The command below imports metadata for the Mesecons mod by Jeija:
  9731. @example
  9732. guix import minetest Jeija/mesecons
  9733. @end example
  9734. The author name can also be left out:
  9735. @example
  9736. guix import minetest mesecons
  9737. @end example
  9738. @table @code
  9739. @item --recursive
  9740. @itemx -r
  9741. Traverse the dependency graph of the given upstream package recursively
  9742. and generate package expressions for all those packages that are not yet
  9743. in Guix.
  9744. @end table
  9745. @item cpan
  9746. @cindex CPAN
  9747. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  9748. Information is taken from the JSON-formatted metadata provided through
  9749. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  9750. relevant information, such as module dependencies. License information
  9751. should be checked closely. If Perl is available in the store, then the
  9752. @code{corelist} utility will be used to filter core modules out of the
  9753. list of dependencies.
  9754. The command command below imports metadata for the Acme::Boolean Perl
  9755. module:
  9756. @example
  9757. guix import cpan Acme::Boolean
  9758. @end example
  9759. @item cran
  9760. @cindex CRAN
  9761. @cindex Bioconductor
  9762. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  9763. central repository for the @uref{https://r-project.org, GNU@tie{}R
  9764. statistical and graphical environment}.
  9765. Information is extracted from the @file{DESCRIPTION} file of the package.
  9766. The command command below imports metadata for the Cairo R package:
  9767. @example
  9768. guix import cran Cairo
  9769. @end example
  9770. You can also ask for a specific version:
  9771. @example
  9772. guix import cran rasterVis@@0.50.3
  9773. @end example
  9774. When @option{--recursive} is added, the importer will traverse the
  9775. dependency graph of the given upstream package recursively and generate
  9776. package expressions for all those packages that are not yet in Guix.
  9777. When @option{--style=specification} is added, the importer will generate
  9778. package definitions whose inputs are package specifications instead of
  9779. references to package variables. This is useful when generated package
  9780. definitions are to be appended to existing user modules, as the list of
  9781. used package modules need not be changed. The default is
  9782. @option{--style=variable}.
  9783. When @option{--archive=bioconductor} is added, metadata is imported from
  9784. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  9785. packages for the analysis and comprehension of high-throughput
  9786. genomic data in bioinformatics.
  9787. Information is extracted from the @file{DESCRIPTION} file contained in the
  9788. package archive.
  9789. The command below imports metadata for the GenomicRanges R package:
  9790. @example
  9791. guix import cran --archive=bioconductor GenomicRanges
  9792. @end example
  9793. Finally, you can also import R packages that have not yet been published on
  9794. CRAN or Bioconductor as long as they are in a git repository. Use
  9795. @option{--archive=git} followed by the URL of the git repository:
  9796. @example
  9797. guix import cran --archive=git https://github.com/immunogenomics/harmony
  9798. @end example
  9799. @item texlive
  9800. @cindex TeX Live
  9801. @cindex CTAN
  9802. Import TeX package information from the TeX Live package database for
  9803. TeX packages that are part of the @uref{https://www.tug.org/texlive/,
  9804. TeX Live distribution}.
  9805. Information about the package is obtained from the TeX Live package
  9806. database, a plain text file that is included in the @code{texlive-bin}
  9807. package. The source code is downloaded from possibly multiple locations
  9808. in the SVN repository of the Tex Live project.
  9809. The command command below imports metadata for the @code{fontspec}
  9810. TeX package:
  9811. @example
  9812. guix import texlive fontspec
  9813. @end example
  9814. @item json
  9815. @cindex JSON, import
  9816. Import package metadata from a local JSON file. Consider the following
  9817. example package definition in JSON format:
  9818. @example
  9819. @{
  9820. "name": "hello",
  9821. "version": "2.10",
  9822. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  9823. "build-system": "gnu",
  9824. "home-page": "https://www.gnu.org/software/hello/",
  9825. "synopsis": "Hello, GNU world: An example GNU package",
  9826. "description": "GNU Hello prints a greeting.",
  9827. "license": "GPL-3.0+",
  9828. "native-inputs": ["gettext"]
  9829. @}
  9830. @end example
  9831. The field names are the same as for the @code{<package>} record
  9832. (@xref{Defining Packages}). References to other packages are provided
  9833. as JSON lists of quoted package specification strings such as
  9834. @code{guile} or @code{guile@@2.0}.
  9835. The importer also supports a more explicit source definition using the
  9836. common fields for @code{<origin>} records:
  9837. @example
  9838. @{
  9839. @dots{}
  9840. "source": @{
  9841. "method": "url-fetch",
  9842. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  9843. "sha256": @{
  9844. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  9845. @}
  9846. @}
  9847. @dots{}
  9848. @}
  9849. @end example
  9850. The command below reads metadata from the JSON file @code{hello.json}
  9851. and outputs a package expression:
  9852. @example
  9853. guix import json hello.json
  9854. @end example
  9855. @item hackage
  9856. @cindex hackage
  9857. Import metadata from the Haskell community's central package archive
  9858. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  9859. Cabal files and includes all the relevant information, including package
  9860. dependencies.
  9861. Specific command-line options are:
  9862. @table @code
  9863. @item --stdin
  9864. @itemx -s
  9865. Read a Cabal file from standard input.
  9866. @item --no-test-dependencies
  9867. @itemx -t
  9868. Do not include dependencies required only by the test suites.
  9869. @item --cabal-environment=@var{alist}
  9870. @itemx -e @var{alist}
  9871. @var{alist} is a Scheme alist defining the environment in which the
  9872. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  9873. @code{arch}, @code{impl} and a string representing the name of a flag.
  9874. The value associated with a flag has to be either the symbol
  9875. @code{true} or @code{false}. The value associated with other keys
  9876. has to conform to the Cabal file format definition. The default value
  9877. associated with the keys @code{os}, @code{arch} and @code{impl} is
  9878. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  9879. @item --recursive
  9880. @itemx -r
  9881. Traverse the dependency graph of the given upstream package recursively
  9882. and generate package expressions for all those packages that are not yet
  9883. in Guix.
  9884. @end table
  9885. The command below imports metadata for the latest version of the
  9886. HTTP Haskell package without including test dependencies and
  9887. specifying the value of the flag @samp{network-uri} as @code{false}:
  9888. @example
  9889. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  9890. @end example
  9891. A specific package version may optionally be specified by following the
  9892. package name by an at-sign and a version number as in the following example:
  9893. @example
  9894. guix import hackage mtl@@2.1.3.1
  9895. @end example
  9896. @item stackage
  9897. @cindex stackage
  9898. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  9899. It takes a package name, looks up the package version included in a
  9900. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  9901. release and uses the @code{hackage} importer to retrieve its metadata.
  9902. Note that it is up to you to select an LTS release compatible with the
  9903. GHC compiler used by Guix.
  9904. Specific command-line options are:
  9905. @table @code
  9906. @item --no-test-dependencies
  9907. @itemx -t
  9908. Do not include dependencies required only by the test suites.
  9909. @item --lts-version=@var{version}
  9910. @itemx -l @var{version}
  9911. @var{version} is the desired LTS release version. If omitted the latest
  9912. release is used.
  9913. @item --recursive
  9914. @itemx -r
  9915. Traverse the dependency graph of the given upstream package recursively
  9916. and generate package expressions for all those packages that are not yet
  9917. in Guix.
  9918. @end table
  9919. The command below imports metadata for the HTTP Haskell package
  9920. included in the LTS Stackage release version 7.18:
  9921. @example
  9922. guix import stackage --lts-version=7.18 HTTP
  9923. @end example
  9924. @item elpa
  9925. @cindex elpa
  9926. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  9927. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  9928. Specific command-line options are:
  9929. @table @code
  9930. @item --archive=@var{repo}
  9931. @itemx -a @var{repo}
  9932. @var{repo} identifies the archive repository from which to retrieve the
  9933. information. Currently the supported repositories and their identifiers
  9934. are:
  9935. @itemize -
  9936. @item
  9937. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  9938. identifier. This is the default.
  9939. Packages from @code{elpa.gnu.org} are signed with one of the keys
  9940. contained in the GnuPG keyring at
  9941. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  9942. @code{emacs} package (@pxref{Package Installation, ELPA package
  9943. signatures,, emacs, The GNU Emacs Manual}).
  9944. @item
  9945. @uref{https://elpa.nongnu.org/nongnu/, NonGNU}, selected by the
  9946. @code{nongnu} identifier.
  9947. @item
  9948. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  9949. @code{melpa-stable} identifier.
  9950. @item
  9951. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  9952. identifier.
  9953. @end itemize
  9954. @item --recursive
  9955. @itemx -r
  9956. Traverse the dependency graph of the given upstream package recursively
  9957. and generate package expressions for all those packages that are not yet
  9958. in Guix.
  9959. @end table
  9960. @item crate
  9961. @cindex crate
  9962. Import metadata from the crates.io Rust package repository
  9963. @uref{https://crates.io, crates.io}, as in this example:
  9964. @example
  9965. guix import crate blake2-rfc
  9966. @end example
  9967. The crate importer also allows you to specify a version string:
  9968. @example
  9969. guix import crate constant-time-eq@@0.1.0
  9970. @end example
  9971. Additional options include:
  9972. @table @code
  9973. @item --recursive
  9974. @itemx -r
  9975. Traverse the dependency graph of the given upstream package recursively
  9976. and generate package expressions for all those packages that are not yet
  9977. in Guix.
  9978. @end table
  9979. @item opam
  9980. @cindex OPAM
  9981. @cindex OCaml
  9982. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  9983. repository used by the OCaml community.
  9984. Additional options include:
  9985. @table @code
  9986. @item --recursive
  9987. @itemx -r
  9988. Traverse the dependency graph of the given upstream package recursively
  9989. and generate package expressions for all those packages that are not yet
  9990. in Guix.
  9991. @item --repo
  9992. By default, packages are searched in the official OPAM repository. This
  9993. option, which can be used more than once, lets you add other repositories
  9994. which will be searched for packages. It accepts as valid arguments:
  9995. @itemize
  9996. @item the name of a known repository - can be one of @code{opam},
  9997. @code{coq} (equivalent to @code{coq-released}),
  9998. @code{coq-core-dev}, @code{coq-extra-dev} or @code{grew}.
  9999. @item the URL of a repository as expected by the
  10000. @code{opam repository add} command (for instance, the URL equivalent
  10001. of the above @code{opam} name would be
  10002. @uref{https://opam.ocaml.org}).
  10003. @item the path to a local copy of a repository (a directory containing a
  10004. @file{packages/} sub-directory).
  10005. @end itemize
  10006. Repositories are assumed to be passed to this option by order of
  10007. preference. The additional repositories will not replace the default
  10008. @code{opam} repository, which is always kept as a fallback.
  10009. Also, please note that versions are not compared across repositories.
  10010. The first repository (from left to right) that has at least one version
  10011. of a given package will prevail over any others, and the version
  10012. imported will be the latest one found @emph{in this repository only}.
  10013. @end table
  10014. @item go
  10015. @cindex go
  10016. Import metadata for a Go module using
  10017. @uref{https://proxy.golang.org, proxy.golang.org}.
  10018. @example
  10019. guix import go gopkg.in/yaml.v2
  10020. @end example
  10021. It is possible to use a package specification with a @code{@@VERSION}
  10022. suffix to import a specific version.
  10023. Additional options include:
  10024. @table @code
  10025. @item --recursive
  10026. @itemx -r
  10027. Traverse the dependency graph of the given upstream package recursively
  10028. and generate package expressions for all those packages that are not yet
  10029. in Guix.
  10030. @item --pin-versions
  10031. When using this option, the importer preserves the exact versions of the
  10032. Go modules dependencies instead of using their latest available
  10033. versions. This can be useful when attempting to import packages that
  10034. recursively depend on former versions of themselves to build. When
  10035. using this mode, the symbol of the package is made by appending the
  10036. version to its name, so that multiple versions of the same package can
  10037. coexist.
  10038. @end table
  10039. @item egg
  10040. @cindex egg
  10041. Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}.
  10042. The information is taken from @file{PACKAGE.egg} files found in the
  10043. @uref{git://code.call-cc.org/eggs-5-all, eggs-5-all} Git
  10044. repository. However, it does not provide all the information that we
  10045. need, there is no ``description'' field, and the licenses used are not
  10046. always precise (BSD is often used instead of BSD-N).
  10047. @example
  10048. guix import egg sourcehut
  10049. @end example
  10050. You can also ask for a specific version:
  10051. @example
  10052. guix import egg arrays@@1.0
  10053. @end example
  10054. Additional options include:
  10055. @table @code
  10056. @item --recursive
  10057. @itemx -r
  10058. Traverse the dependency graph of the given upstream package recursively
  10059. and generate package expressions for all those packages that are not yet
  10060. in Guix.
  10061. @end table
  10062. @end table
  10063. The structure of the @command{guix import} code is modular. It would be
  10064. useful to have more importers for other package formats, and your help
  10065. is welcome here (@pxref{Contributing}).
  10066. @node Invoking guix refresh
  10067. @section Invoking @command{guix refresh}
  10068. @cindex @command {guix refresh}
  10069. The primary audience of the @command{guix refresh} command is packagers.
  10070. As a user, you may be interested in the @option{--with-latest} option,
  10071. which can bring you package update superpowers built upon @command{guix
  10072. refresh} (@pxref{Package Transformation Options,
  10073. @option{--with-latest}}). By default, @command{guix refresh} reports
  10074. any packages provided by the distribution that are outdated compared to
  10075. the latest upstream version, like this:
  10076. @example
  10077. $ guix refresh
  10078. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  10079. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  10080. @end example
  10081. Alternatively, one can specify packages to consider, in which case a
  10082. warning is emitted for packages that lack an updater:
  10083. @example
  10084. $ guix refresh coreutils guile guile-ssh
  10085. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  10086. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  10087. @end example
  10088. @command{guix refresh} browses the upstream repository of each package and determines
  10089. the highest version number of the releases therein. The command
  10090. knows how to update specific types of packages: GNU packages, ELPA
  10091. packages, etc.---see the documentation for @option{--type} below. There
  10092. are many packages, though, for which it lacks a method to determine
  10093. whether a new upstream release is available. However, the mechanism is
  10094. extensible, so feel free to get in touch with us to add a new method!
  10095. @table @code
  10096. @item --recursive
  10097. Consider the packages specified, and all the packages upon which they depend.
  10098. @example
  10099. $ guix refresh --recursive coreutils
  10100. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  10101. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  10102. gnu/packages/xml.scm:68:2: warning: no updater for expat
  10103. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  10104. @dots{}
  10105. @end example
  10106. @end table
  10107. Sometimes the upstream name differs from the package name used in Guix,
  10108. and @command{guix refresh} needs a little help. Most updaters honor the
  10109. @code{upstream-name} property in package definitions, which can be used
  10110. to that effect:
  10111. @lisp
  10112. (define-public network-manager
  10113. (package
  10114. (name "network-manager")
  10115. ;; @dots{}
  10116. (properties '((upstream-name . "NetworkManager")))))
  10117. @end lisp
  10118. When passed @option{--update}, it modifies distribution source files to
  10119. update the version numbers and source tarball hashes of those package
  10120. recipes (@pxref{Defining Packages}). This is achieved by downloading
  10121. each package's latest source tarball and its associated OpenPGP
  10122. signature, authenticating the downloaded tarball against its signature
  10123. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  10124. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  10125. When the public
  10126. key used to sign the tarball is missing from the user's keyring, an
  10127. attempt is made to automatically retrieve it from a public key server;
  10128. when this is successful, the key is added to the user's keyring; otherwise,
  10129. @command{guix refresh} reports an error.
  10130. The following options are supported:
  10131. @table @code
  10132. @item --expression=@var{expr}
  10133. @itemx -e @var{expr}
  10134. Consider the package @var{expr} evaluates to.
  10135. This is useful to precisely refer to a package, as in this example:
  10136. @example
  10137. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  10138. @end example
  10139. This command lists the dependents of the ``final'' libc (essentially all
  10140. the packages).
  10141. @item --update
  10142. @itemx -u
  10143. Update distribution source files (package recipes) in place. This is
  10144. usually run from a checkout of the Guix source tree (@pxref{Running
  10145. Guix Before It Is Installed}):
  10146. @example
  10147. $ ./pre-inst-env guix refresh -s non-core -u
  10148. @end example
  10149. @xref{Defining Packages}, for more information on package definitions.
  10150. @item --select=[@var{subset}]
  10151. @itemx -s @var{subset}
  10152. Select all the packages in @var{subset}, one of @code{core} or
  10153. @code{non-core}.
  10154. The @code{core} subset refers to all the packages at the core of the
  10155. distribution---i.e., packages that are used to build ``everything
  10156. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  10157. changing one of these packages in the distribution entails a rebuild of
  10158. all the others. Thus, such updates are an inconvenience to users in
  10159. terms of build time or bandwidth used to achieve the upgrade.
  10160. The @code{non-core} subset refers to the remaining packages. It is
  10161. typically useful in cases where an update of the core packages would be
  10162. inconvenient.
  10163. @item --manifest=@var{file}
  10164. @itemx -m @var{file}
  10165. Select all the packages from the manifest in @var{file}. This is useful to
  10166. check if any packages of the user manifest can be updated.
  10167. @item --type=@var{updater}
  10168. @itemx -t @var{updater}
  10169. Select only packages handled by @var{updater} (may be a comma-separated
  10170. list of updaters). Currently, @var{updater} may be one of:
  10171. @table @code
  10172. @item gnu
  10173. the updater for GNU packages;
  10174. @item savannah
  10175. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  10176. @item sourceforge
  10177. the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
  10178. @item gnome
  10179. the updater for GNOME packages;
  10180. @item kde
  10181. the updater for KDE packages;
  10182. @item xorg
  10183. the updater for X.org packages;
  10184. @item kernel.org
  10185. the updater for packages hosted on kernel.org;
  10186. @item egg
  10187. the updater for @uref{https://wiki.call-cc.org/eggs/, Egg} packages;
  10188. @item elpa
  10189. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  10190. @item cran
  10191. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  10192. @item bioconductor
  10193. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  10194. @item cpan
  10195. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  10196. @item pypi
  10197. the updater for @uref{https://pypi.python.org, PyPI} packages.
  10198. @item gem
  10199. the updater for @uref{https://rubygems.org, RubyGems} packages.
  10200. @item github
  10201. the updater for @uref{https://github.com, GitHub} packages.
  10202. @item hackage
  10203. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  10204. @item minetest
  10205. the updater for @uref{https://content.minetest.net, ContentDB} packages.
  10206. @item stackage
  10207. the updater for @uref{https://www.stackage.org, Stackage} packages.
  10208. @item crate
  10209. the updater for @uref{https://crates.io, Crates} packages.
  10210. @item launchpad
  10211. the updater for @uref{https://launchpad.net, Launchpad} packages.
  10212. @item generic-html
  10213. a generic updater that crawls the HTML page where the source tarball of
  10214. the package is hosted, when applicable.
  10215. @item generic-git
  10216. a generic updater for packages hosted on Git repositories. It tries to
  10217. be smart about parsing Git tag names, but if it is not able to parse the
  10218. tag name and compare tags correctly, users can define the following
  10219. properties for a package.
  10220. @itemize
  10221. @item @code{release-tag-prefix}: a regular expression for matching a prefix of
  10222. the tag name.
  10223. @item @code{release-tag-suffix}: a regular expression for matching a suffix of
  10224. the tag name.
  10225. @item @code{release-tag-version-delimiter}: a string used as the delimiter in
  10226. the tag name for separating the numbers of the version.
  10227. @item @code{accept-pre-releases}: by default, the updater will ignore
  10228. pre-releases; to make it also look for pre-releases, set the this
  10229. property to @code{#t}.
  10230. @end itemize
  10231. @lisp
  10232. (package
  10233. (name "foo")
  10234. ;; ...
  10235. (properties
  10236. '((release-tag-prefix . "^release0-")
  10237. (release-tag-suffix . "[a-z]?$")
  10238. (release-tag-version-delimiter . ":"))))
  10239. @end lisp
  10240. @item latest-git
  10241. @cindex latest-git
  10242. @cindex with-latest-git-commit
  10243. another updater for packages hosted on Git repositories. The difference
  10244. with @code{generic-git} is that it always choses the latest commit, even
  10245. when it does not have a version tag. As this practice should remain
  10246. exceptional (@pxref{Version Numbers}), packages have to opt-in this
  10247. updater, by using @code{git-version} to construct the version number and
  10248. setting the @code{with-latest-git-commit} package property.
  10249. Usually, it can be simply be set to @code{#true} to use the latest Git
  10250. commit on the default branch---i.e., HEAD in Git parlance. If this is
  10251. not desired, for example if upstream has a branch that is considered
  10252. ‘stable’, it can be set to the name of a reference to take commits from.
  10253. For example, to take commits from a branch named @code{stable}, the
  10254. property @code{with-latest-git-commit} needs to be set to
  10255. @code{refs/heads/stable}.
  10256. @end table
  10257. For instance, the following command only checks for updates of Emacs
  10258. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  10259. @example
  10260. $ guix refresh --type=elpa,cran
  10261. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  10262. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  10263. @end example
  10264. @item --list-updaters
  10265. @itemx -L
  10266. List available updaters and exit (see @option{--type} above).
  10267. For each updater, display the fraction of packages it covers; at the
  10268. end, display the fraction of packages covered by all these updaters.
  10269. @end table
  10270. In addition, @command{guix refresh} can be passed one or more package
  10271. names, as in this example:
  10272. @example
  10273. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  10274. @end example
  10275. @noindent
  10276. The command above specifically updates the @code{emacs} and
  10277. @code{idutils} packages. The @option{--select} option would have no
  10278. effect in this case. You might also want to update definitions that
  10279. correspond to the packages installed in your profile:
  10280. @example
  10281. $ ./pre-inst-env guix refresh -u \
  10282. $(guix package --list-installed | cut -f1)
  10283. @end example
  10284. When considering whether to upgrade a package, it is sometimes
  10285. convenient to know which packages would be affected by the upgrade and
  10286. should be checked for compatibility. For this the following option may
  10287. be used when passing @command{guix refresh} one or more package names:
  10288. @table @code
  10289. @item --list-dependent
  10290. @itemx -l
  10291. List top-level dependent packages that would need to be rebuilt as a
  10292. result of upgrading one or more packages.
  10293. @xref{Invoking guix graph, the @code{reverse-package} type of
  10294. @command{guix graph}}, for information on how to visualize the list of
  10295. dependents of a package.
  10296. @end table
  10297. Be aware that the @option{--list-dependent} option only
  10298. @emph{approximates} the rebuilds that would be required as a result of
  10299. an upgrade. More rebuilds might be required under some circumstances.
  10300. @example
  10301. $ guix refresh --list-dependent flex
  10302. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  10303. hop@@2.4.0 emacs-geiser@@0.13 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  10304. @end example
  10305. The command above lists a set of packages that could be built to check
  10306. for compatibility with an upgraded @code{flex} package.
  10307. @table @code
  10308. @item --list-transitive
  10309. List all the packages which one or more packages depend upon.
  10310. @example
  10311. $ guix refresh --list-transitive flex
  10312. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  10313. 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{}
  10314. @end example
  10315. @end table
  10316. The command above lists a set of packages which, when changed, would cause
  10317. @code{flex} to be rebuilt.
  10318. The following options can be used to customize GnuPG operation:
  10319. @table @code
  10320. @item --gpg=@var{command}
  10321. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  10322. for in @code{$PATH}.
  10323. @item --keyring=@var{file}
  10324. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  10325. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  10326. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  10327. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  10328. information on a tool to manipulate keybox files).
  10329. When this option is omitted, @command{guix refresh} uses
  10330. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  10331. signing keys. OpenPGP signatures are checked against keys from this keyring;
  10332. missing keys are downloaded to this keyring as well (see
  10333. @option{--key-download} below).
  10334. You can export keys from your default GPG keyring into a keybox file using
  10335. commands like this one:
  10336. @example
  10337. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  10338. @end example
  10339. Likewise, you can fetch keys to a specific keybox file like this:
  10340. @example
  10341. gpg --no-default-keyring --keyring mykeyring.kbx \
  10342. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  10343. @end example
  10344. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  10345. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  10346. @item --key-download=@var{policy}
  10347. Handle missing OpenPGP keys according to @var{policy}, which may be one
  10348. of:
  10349. @table @code
  10350. @item always
  10351. Always download missing OpenPGP keys from the key server, and add them
  10352. to the user's GnuPG keyring.
  10353. @item never
  10354. Never try to download missing OpenPGP keys. Instead just bail out.
  10355. @item interactive
  10356. When a package signed with an unknown OpenPGP key is encountered, ask
  10357. the user whether to download it or not. This is the default behavior.
  10358. @end table
  10359. @item --key-server=@var{host}
  10360. Use @var{host} as the OpenPGP key server when importing a public key.
  10361. @item --load-path=@var{directory}
  10362. Add @var{directory} to the front of the package module search path
  10363. (@pxref{Package Modules}).
  10364. This allows users to define their own packages and make them visible to
  10365. the command-line tools.
  10366. @end table
  10367. The @code{github} updater uses the
  10368. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  10369. releases. When used repeatedly e.g.@: when refreshing all packages,
  10370. GitHub will eventually refuse to answer any further API requests. By
  10371. default 60 API requests per hour are allowed, and a full refresh on all
  10372. GitHub packages in Guix requires more than this. Authentication with
  10373. GitHub through the use of an API token alleviates these limits. To use
  10374. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  10375. token procured from @uref{https://github.com/settings/tokens} or
  10376. otherwise.
  10377. @node Invoking guix style
  10378. @section Invoking @command{guix style}
  10379. The @command{guix style} command helps packagers style their package
  10380. definitions according to the latest fashionable trends. The command
  10381. currently focuses on one aspect: the style of package inputs. It may
  10382. eventually be extended to handle other stylistic matters.
  10383. The way package inputs are written is going through a transition
  10384. (@pxref{package Reference}, for more on package inputs). Until version
  10385. 1.3.0, package inputs were written using the ``old style'', where each
  10386. input was given an explicit label, most of the time the package name:
  10387. @lisp
  10388. (package
  10389. ;; @dots{}
  10390. ;; The "old style" (deprecated).
  10391. (inputs `(("libunistring" ,libunistring)
  10392. ("libffi" ,libffi))))
  10393. @end lisp
  10394. Today, the old style is deprecated and the preferred style looks like
  10395. this:
  10396. @lisp
  10397. (package
  10398. ;; @dots{}
  10399. ;; The "new style".
  10400. (inputs (list libunistring libffi)))
  10401. @end lisp
  10402. Likewise, uses of @code{alist-delete} and friends to manipulate inputs
  10403. is now deprecated in favor of @code{modify-inputs} (@pxref{Defining
  10404. Package Variants}, for more info on @code{modify-inputs}).
  10405. In the vast majority of cases, this is a purely mechanical change on the
  10406. surface syntax that does not even incur a package rebuild. Running
  10407. @command{guix style} can do that for you, whether you're working on
  10408. packages in Guix proper or in an external channel.
  10409. The general syntax is:
  10410. @example
  10411. guix style [@var{options}] @var{package}@dots{}
  10412. @end example
  10413. This causes @command{guix style} to analyze and rewrite the definition
  10414. of @var{package}@dots{}. It does so in a conservative way: preserving
  10415. comments and bailing out if it cannot make sense of the code that
  10416. appears in an inputs field. The available options are listed below.
  10417. @table @code
  10418. @item --dry-run
  10419. @itemx -n
  10420. Show source file locations that would be edited but do not modify them.
  10421. @item --load-path=@var{directory}
  10422. @itemx -L @var{directory}
  10423. Add @var{directory} to the front of the package module search path
  10424. (@pxref{Package Modules}).
  10425. @item --expression=@var{expr}
  10426. @itemx -e @var{expr}
  10427. Style the package @var{expr} evaluates to.
  10428. For example, running:
  10429. @example
  10430. guix style -e '(@@ (gnu packages gcc) gcc-5)'
  10431. @end example
  10432. styles the @code{gcc-5} package definition.
  10433. @item --input-simplification=@var{policy}
  10434. Specify the package input simplification policy for cases where an input
  10435. label does not match the corresponding package name. @var{policy} may
  10436. be one of the following:
  10437. @table @code
  10438. @item silent
  10439. Simplify inputs only when the change is ``silent'', meaning that the
  10440. package does not need to be rebuilt (its derivation is unchanged).
  10441. @item safe
  10442. Simplify inputs only when that is ``safe'' to do: the package might need
  10443. to be rebuilt, but the change is known to have no observable effect.
  10444. @item always
  10445. Simplify inputs even when input labels do not match package names, and
  10446. even if that might have an observable effect.
  10447. @end table
  10448. The default is @code{silent}, meaning that input simplifications do not
  10449. trigger any package rebuild.
  10450. @end table
  10451. @node Invoking guix lint
  10452. @section Invoking @command{guix lint}
  10453. @cindex @command{guix lint}
  10454. @cindex package, checking for errors
  10455. The @command{guix lint} command is meant to help package developers avoid
  10456. common errors and use a consistent style. It runs a number of checks on
  10457. a given set of packages in order to find common mistakes in their
  10458. definitions. Available @dfn{checkers} include (see
  10459. @option{--list-checkers} for a complete list):
  10460. @table @code
  10461. @item synopsis
  10462. @itemx description
  10463. Validate certain typographical and stylistic rules about package
  10464. descriptions and synopses.
  10465. @item inputs-should-be-native
  10466. Identify inputs that should most likely be native inputs.
  10467. @item source
  10468. @itemx home-page
  10469. @itemx mirror-url
  10470. @itemx github-url
  10471. @itemx source-file-name
  10472. Probe @code{home-page} and @code{source} URLs and report those that are
  10473. invalid. Suggest a @code{mirror://} URL when applicable. If the
  10474. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  10475. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  10476. version number or ``git-checkout'', without a declared @code{file-name}
  10477. (@pxref{origin Reference}).
  10478. @item source-unstable-tarball
  10479. Parse the @code{source} URL to determine if a tarball from GitHub is
  10480. autogenerated or if it is a release tarball. Unfortunately GitHub's
  10481. autogenerated tarballs are sometimes regenerated.
  10482. @item derivation
  10483. Check that the derivation of the given packages can be successfully
  10484. computed for all the supported systems (@pxref{Derivations}).
  10485. @item profile-collisions
  10486. Check whether installing the given packages in a profile would lead to
  10487. collisions. Collisions occur when several packages with the same name
  10488. but a different version or a different store file name are propagated.
  10489. @xref{package Reference, @code{propagated-inputs}}, for more information
  10490. on propagated inputs.
  10491. @item archival
  10492. @cindex Software Heritage, source code archive
  10493. @cindex archival of source code, Software Heritage
  10494. Checks whether the package's source code is archived at
  10495. @uref{https://www.softwareheritage.org, Software Heritage}.
  10496. When the source code that is not archived comes from a version-control system
  10497. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  10498. ``save'' request so that it eventually archives it. This ensures that the
  10499. source will remain available in the long term, and that Guix can fall back to
  10500. Software Heritage should the source code disappear from its original host.
  10501. The status of recent ``save'' requests can be
  10502. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  10503. When source code is a tarball obtained with @code{url-fetch}, simply print a
  10504. message when it is not archived. As of this writing, Software Heritage does
  10505. not allow requests to save arbitrary tarballs; we are working on ways to
  10506. ensure that non-VCS source code is also archived.
  10507. Software Heritage
  10508. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  10509. request rate per IP address}. When the limit is reached, @command{guix lint}
  10510. prints a message and the @code{archival} checker stops doing anything until
  10511. that limit has been reset.
  10512. @item cve
  10513. @cindex security vulnerabilities
  10514. @cindex CVE, Common Vulnerabilities and Exposures
  10515. Report known vulnerabilities found in the Common Vulnerabilities and
  10516. Exposures (CVE) databases of the current and past year
  10517. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  10518. NIST}.
  10519. To view information about a particular vulnerability, visit pages such as:
  10520. @itemize
  10521. @item
  10522. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  10523. @item
  10524. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  10525. @end itemize
  10526. @noindent
  10527. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  10528. @code{CVE-2015-7554}.
  10529. Package developers can specify in package recipes the
  10530. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  10531. name and version of the package when they differ from the name or version
  10532. that Guix uses, as in this example:
  10533. @lisp
  10534. (package
  10535. (name "grub")
  10536. ;; @dots{}
  10537. ;; CPE calls this package "grub2".
  10538. (properties '((cpe-name . "grub2")
  10539. (cpe-version . "2.3"))))
  10540. @end lisp
  10541. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  10542. Some entries in the CVE database do not specify which version of a
  10543. package they apply to, and would thus ``stick around'' forever. Package
  10544. developers who found CVE alerts and verified they can be ignored can
  10545. declare them as in this example:
  10546. @lisp
  10547. (package
  10548. (name "t1lib")
  10549. ;; @dots{}
  10550. ;; These CVEs no longer apply and can be safely ignored.
  10551. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  10552. "CVE-2011-1553"
  10553. "CVE-2011-1554"
  10554. "CVE-2011-5244")))))
  10555. @end lisp
  10556. @item formatting
  10557. Warn about obvious source code formatting issues: trailing white space,
  10558. use of tabulations, etc.
  10559. @item input-labels
  10560. Report old-style input labels that do not match the name of the
  10561. corresponding package. This aims to help migrate from the ``old input
  10562. style''. @xref{package Reference}, for more information on package
  10563. inputs and input styles. @xref{Invoking guix style}, on how to migrate
  10564. to the new style.
  10565. @end table
  10566. The general syntax is:
  10567. @example
  10568. guix lint @var{options} @var{package}@dots{}
  10569. @end example
  10570. If no package is given on the command line, then all packages are checked.
  10571. The @var{options} may be zero or more of the following:
  10572. @table @code
  10573. @item --list-checkers
  10574. @itemx -l
  10575. List and describe all the available checkers that will be run on packages
  10576. and exit.
  10577. @item --checkers
  10578. @itemx -c
  10579. Only enable the checkers specified in a comma-separated list using the
  10580. names returned by @option{--list-checkers}.
  10581. @item --exclude
  10582. @itemx -x
  10583. Only disable the checkers specified in a comma-separated list using the
  10584. names returned by @option{--list-checkers}.
  10585. @item --no-network
  10586. @itemx -n
  10587. Only enable the checkers that do not depend on Internet access.
  10588. @item --load-path=@var{directory}
  10589. @itemx -L @var{directory}
  10590. Add @var{directory} to the front of the package module search path
  10591. (@pxref{Package Modules}).
  10592. This allows users to define their own packages and make them visible to
  10593. the command-line tools.
  10594. @end table
  10595. @node Invoking guix size
  10596. @section Invoking @command{guix size}
  10597. @cindex size
  10598. @cindex package size
  10599. @cindex closure
  10600. @cindex @command{guix size}
  10601. The @command{guix size} command helps package developers profile the
  10602. disk usage of packages. It is easy to overlook the impact of an
  10603. additional dependency added to a package, or the impact of using a
  10604. single output for a package that could easily be split (@pxref{Packages
  10605. with Multiple Outputs}). Such are the typical issues that
  10606. @command{guix size} can highlight.
  10607. The command can be passed one or more package specifications
  10608. such as @code{gcc@@4.8}
  10609. or @code{guile:debug}, or a file name in the store. Consider this
  10610. example:
  10611. @example
  10612. $ guix size coreutils
  10613. store item total self
  10614. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  10615. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  10616. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  10617. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  10618. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  10619. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  10620. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  10621. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  10622. total: 78.9 MiB
  10623. @end example
  10624. @cindex closure
  10625. The store items listed here constitute the @dfn{transitive closure} of
  10626. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  10627. would be returned by:
  10628. @example
  10629. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  10630. @end example
  10631. Here the output shows three columns next to store items. The first column,
  10632. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  10633. the store item---that is, its own size plus the size of all its
  10634. dependencies. The next column, labeled ``self'', shows the size of the
  10635. item itself. The last column shows the ratio of the size of the item
  10636. itself to the space occupied by all the items listed here.
  10637. In this example, we see that the closure of Coreutils weighs in at
  10638. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  10639. libraries. (That libc and GCC's libraries represent a large fraction of
  10640. the closure is not a problem @i{per se} because they are always available
  10641. on the system anyway.)
  10642. Since the command also accepts store file names, assessing the size of
  10643. a build result is straightforward:
  10644. @example
  10645. guix size $(guix system build config.scm)
  10646. @end example
  10647. When the package(s) passed to @command{guix size} are available in the
  10648. store@footnote{More precisely, @command{guix size} looks for the
  10649. @emph{ungrafted} variant of the given package(s), as returned by
  10650. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  10651. for information on grafts.}, @command{guix size} queries the daemon to determine its
  10652. dependencies, and measures its size in the store, similar to @command{du
  10653. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  10654. Coreutils}).
  10655. When the given packages are @emph{not} in the store, @command{guix size}
  10656. reports information based on the available substitutes
  10657. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  10658. store items that are not even on disk, only available remotely.
  10659. You can also specify several package names:
  10660. @example
  10661. $ guix size coreutils grep sed bash
  10662. store item total self
  10663. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  10664. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  10665. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  10666. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  10667. @dots{}
  10668. total: 102.3 MiB
  10669. @end example
  10670. @noindent
  10671. In this example we see that the combination of the four packages takes
  10672. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  10673. since they have a lot of dependencies in common.
  10674. When looking at the profile returned by @command{guix size}, you may
  10675. find yourself wondering why a given package shows up in the profile at
  10676. all. To understand it, you can use @command{guix graph --path -t
  10677. references} to display the shortest path between the two packages
  10678. (@pxref{Invoking guix graph}).
  10679. The available options are:
  10680. @table @option
  10681. @item --substitute-urls=@var{urls}
  10682. Use substitute information from @var{urls}.
  10683. @xref{client-substitute-urls, the same option for @code{guix build}}.
  10684. @item --sort=@var{key}
  10685. Sort lines according to @var{key}, one of the following options:
  10686. @table @code
  10687. @item self
  10688. the size of each item (the default);
  10689. @item closure
  10690. the total size of the item's closure.
  10691. @end table
  10692. @item --map-file=@var{file}
  10693. Write a graphical map of disk usage in PNG format to @var{file}.
  10694. For the example above, the map looks like this:
  10695. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  10696. produced by @command{guix size}}
  10697. This option requires that
  10698. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  10699. installed and visible in Guile's module search path. When that is not
  10700. the case, @command{guix size} fails as it tries to load it.
  10701. @item --system=@var{system}
  10702. @itemx -s @var{system}
  10703. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  10704. @item --load-path=@var{directory}
  10705. @itemx -L @var{directory}
  10706. Add @var{directory} to the front of the package module search path
  10707. (@pxref{Package Modules}).
  10708. This allows users to define their own packages and make them visible to
  10709. the command-line tools.
  10710. @end table
  10711. @node Invoking guix graph
  10712. @section Invoking @command{guix graph}
  10713. @cindex DAG
  10714. @cindex @command{guix graph}
  10715. @cindex package dependencies
  10716. Packages and their dependencies form a @dfn{graph}, specifically a
  10717. directed acyclic graph (DAG). It can quickly become difficult to have a
  10718. mental model of the package DAG, so the @command{guix graph} command
  10719. provides a visual representation of the DAG@. By default,
  10720. @command{guix graph} emits a DAG representation in the input format of
  10721. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  10722. directly to the @command{dot} command of Graphviz. It can also emit an
  10723. HTML page with embedded JavaScript code to display a ``chord diagram''
  10724. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  10725. emit Cypher queries to construct a graph in a graph database supporting
  10726. the @uref{https://www.opencypher.org/, openCypher} query language. With
  10727. @option{--path}, it simply displays the shortest path between two
  10728. packages. The general syntax is:
  10729. @example
  10730. guix graph @var{options} @var{package}@dots{}
  10731. @end example
  10732. For example, the following command generates a PDF file representing the
  10733. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  10734. dependencies:
  10735. @example
  10736. guix graph coreutils | dot -Tpdf > dag.pdf
  10737. @end example
  10738. The output looks like this:
  10739. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  10740. Nice little graph, no?
  10741. You may find it more pleasant to navigate the graph interactively with
  10742. @command{xdot} (from the @code{xdot} package):
  10743. @example
  10744. guix graph coreutils | xdot -
  10745. @end example
  10746. But there is more than one graph! The one above is concise: it is the
  10747. graph of package objects, omitting implicit inputs such as GCC, libc,
  10748. grep, etc. It is often useful to have such a concise graph, but
  10749. sometimes one may want to see more details. @command{guix graph} supports
  10750. several types of graphs, allowing you to choose the level of detail:
  10751. @table @code
  10752. @item package
  10753. This is the default type used in the example above. It shows the DAG of
  10754. package objects, excluding implicit dependencies. It is concise, but
  10755. filters out many details.
  10756. @item reverse-package
  10757. This shows the @emph{reverse} DAG of packages. For example:
  10758. @example
  10759. guix graph --type=reverse-package ocaml
  10760. @end example
  10761. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  10762. you are also interested in cases where OCaml is an implicit dependency, see
  10763. @code{reverse-bag} below).
  10764. Note that for core packages this can yield huge graphs. If all you want
  10765. is to know the number of packages that depend on a given package, use
  10766. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  10767. @option{--list-dependent}}).
  10768. @item bag-emerged
  10769. This is the package DAG, @emph{including} implicit inputs.
  10770. For instance, the following command:
  10771. @example
  10772. guix graph --type=bag-emerged coreutils
  10773. @end example
  10774. ...@: yields this bigger graph:
  10775. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  10776. At the bottom of the graph, we see all the implicit inputs of
  10777. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  10778. Now, note that the dependencies of these implicit inputs---that is, the
  10779. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  10780. here, for conciseness.
  10781. @item bag
  10782. Similar to @code{bag-emerged}, but this time including all the bootstrap
  10783. dependencies.
  10784. @item bag-with-origins
  10785. Similar to @code{bag}, but also showing origins and their dependencies.
  10786. @item reverse-bag
  10787. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  10788. it also takes implicit dependencies into account. For example:
  10789. @example
  10790. guix graph -t reverse-bag dune
  10791. @end example
  10792. @noindent
  10793. ...@: yields the graph of all packages that depend on Dune, directly or
  10794. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  10795. @i{via} @code{dune-build-system}, this shows a large number of packages,
  10796. whereas @code{reverse-package} would show very few if any.
  10797. @item derivation
  10798. This is the most detailed representation: It shows the DAG of
  10799. derivations (@pxref{Derivations}) and plain store items. Compared to
  10800. the above representation, many additional nodes are visible, including
  10801. build scripts, patches, Guile modules, etc.
  10802. For this type of graph, it is also possible to pass a @file{.drv} file
  10803. name instead of a package name, as in:
  10804. @example
  10805. guix graph -t derivation $(guix system build -d my-config.scm)
  10806. @end example
  10807. @item module
  10808. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  10809. For example, the following command shows the graph for the package
  10810. module that defines the @code{guile} package:
  10811. @example
  10812. guix graph -t module guile | xdot -
  10813. @end example
  10814. @end table
  10815. All the types above correspond to @emph{build-time dependencies}. The
  10816. following graph type represents the @emph{run-time dependencies}:
  10817. @table @code
  10818. @item references
  10819. This is the graph of @dfn{references} of a package output, as returned
  10820. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  10821. If the given package output is not available in the store, @command{guix
  10822. graph} attempts to obtain dependency information from substitutes.
  10823. Here you can also pass a store file name instead of a package name. For
  10824. example, the command below produces the reference graph of your profile
  10825. (which can be big!):
  10826. @example
  10827. guix graph -t references $(readlink -f ~/.guix-profile)
  10828. @end example
  10829. @item referrers
  10830. This is the graph of the @dfn{referrers} of a store item, as returned by
  10831. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  10832. This relies exclusively on local information from your store. For
  10833. instance, let us suppose that the current Inkscape is available in 10
  10834. profiles on your machine; @command{guix graph -t referrers inkscape}
  10835. will show a graph rooted at Inkscape and with those 10 profiles linked
  10836. to it.
  10837. It can help determine what is preventing a store item from being garbage
  10838. collected.
  10839. @end table
  10840. @cindex shortest path, between packages
  10841. Often, the graph of the package you are interested in does not fit on
  10842. your screen, and anyway all you want to know is @emph{why} that package
  10843. actually depends on some seemingly unrelated package. The
  10844. @option{--path} option instructs @command{guix graph} to display the
  10845. shortest path between two packages (or derivations, or store items,
  10846. etc.):
  10847. @example
  10848. $ guix graph --path emacs libunistring
  10849. emacs@@26.3
  10850. mailutils@@3.9
  10851. libunistring@@0.9.10
  10852. $ guix graph --path -t derivation emacs libunistring
  10853. /gnu/store/@dots{}-emacs-26.3.drv
  10854. /gnu/store/@dots{}-mailutils-3.9.drv
  10855. /gnu/store/@dots{}-libunistring-0.9.10.drv
  10856. $ guix graph --path -t references emacs libunistring
  10857. /gnu/store/@dots{}-emacs-26.3
  10858. /gnu/store/@dots{}-libidn2-2.2.0
  10859. /gnu/store/@dots{}-libunistring-0.9.10
  10860. @end example
  10861. Sometimes you still want to visualize the graph but would like to trim
  10862. it so it can actually be displayed. One way to do it is via the
  10863. @option{--max-depth} (or @option{-M}) option, which lets you specify the
  10864. maximum depth of the graph. In the example below, we visualize only
  10865. @code{libreoffice} and the nodes whose distance to @code{libreoffice} is
  10866. at most 2:
  10867. @example
  10868. guix graph -M 2 libreoffice | xdot -f fdp -
  10869. @end example
  10870. Mind you, that's still a big ball of spaghetti, but at least
  10871. @command{dot} can render it quickly and it can be browsed somewhat.
  10872. The available options are the following:
  10873. @table @option
  10874. @item --type=@var{type}
  10875. @itemx -t @var{type}
  10876. Produce a graph output of @var{type}, where @var{type} must be one of
  10877. the values listed above.
  10878. @item --list-types
  10879. List the supported graph types.
  10880. @item --backend=@var{backend}
  10881. @itemx -b @var{backend}
  10882. Produce a graph using the selected @var{backend}.
  10883. @item --list-backends
  10884. List the supported graph backends.
  10885. Currently, the available backends are Graphviz and d3.js.
  10886. @item --path
  10887. Display the shortest path between two nodes of the type specified by
  10888. @option{--type}. The example below shows the shortest path between
  10889. @code{libreoffice} and @code{llvm} according to the references of
  10890. @code{libreoffice}:
  10891. @example
  10892. $ guix graph --path -t references libreoffice llvm
  10893. /gnu/store/@dots{}-libreoffice-6.4.2.2
  10894. /gnu/store/@dots{}-libepoxy-1.5.4
  10895. /gnu/store/@dots{}-mesa-19.3.4
  10896. /gnu/store/@dots{}-llvm-9.0.1
  10897. @end example
  10898. @item --expression=@var{expr}
  10899. @itemx -e @var{expr}
  10900. Consider the package @var{expr} evaluates to.
  10901. This is useful to precisely refer to a package, as in this example:
  10902. @example
  10903. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  10904. @end example
  10905. @item --system=@var{system}
  10906. @itemx -s @var{system}
  10907. Display the graph for @var{system}---e.g., @code{i686-linux}.
  10908. The package dependency graph is largely architecture-independent, but there
  10909. are some architecture-dependent bits that this option allows you to visualize.
  10910. @item --load-path=@var{directory}
  10911. @itemx -L @var{directory}
  10912. Add @var{directory} to the front of the package module search path
  10913. (@pxref{Package Modules}).
  10914. This allows users to define their own packages and make them visible to
  10915. the command-line tools.
  10916. @end table
  10917. On top of that, @command{guix graph} supports all the usual package
  10918. transformation options (@pxref{Package Transformation Options}). This
  10919. makes it easy to view the effect of a graph-rewriting transformation
  10920. such as @option{--with-input}. For example, the command below outputs
  10921. the graph of @code{git} once @code{openssl} has been replaced by
  10922. @code{libressl} everywhere in the graph:
  10923. @example
  10924. guix graph git --with-input=openssl=libressl
  10925. @end example
  10926. So many possibilities, so much fun!
  10927. @node Invoking guix publish
  10928. @section Invoking @command{guix publish}
  10929. @cindex @command{guix publish}
  10930. The purpose of @command{guix publish} is to enable users to easily share
  10931. their store with others, who can then use it as a substitute server
  10932. (@pxref{Substitutes}).
  10933. When @command{guix publish} runs, it spawns an HTTP server which allows
  10934. anyone with network access to obtain substitutes from it. This means
  10935. that any machine running Guix can also act as if it were a build farm,
  10936. since the HTTP interface is compatible with Cuirass, the software behind
  10937. the @code{@value{SUBSTITUTE-SERVER-1}} build farm.
  10938. For security, each substitute is signed, allowing recipients to check
  10939. their authenticity and integrity (@pxref{Substitutes}). Because
  10940. @command{guix publish} uses the signing key of the system, which is only
  10941. readable by the system administrator, it must be started as root; the
  10942. @option{--user} option makes it drop root privileges early on.
  10943. The signing key pair must be generated before @command{guix publish} is
  10944. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  10945. guix archive}).
  10946. When the @option{--advertise} option is passed, the server advertises
  10947. its availability on the local network using multicast DNS (mDNS) and DNS
  10948. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  10949. guile-avahi, Using Avahi in Guile Scheme Programs}).
  10950. The general syntax is:
  10951. @example
  10952. guix publish @var{options}@dots{}
  10953. @end example
  10954. Running @command{guix publish} without any additional arguments will
  10955. spawn an HTTP server on port 8080:
  10956. @example
  10957. guix publish
  10958. @end example
  10959. Once a publishing server has been authorized, the daemon may download
  10960. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  10961. By default, @command{guix publish} compresses archives on the fly as it
  10962. serves them. This ``on-the-fly'' mode is convenient in that it requires
  10963. no setup and is immediately available. However, when serving lots of
  10964. clients, we recommend using the @option{--cache} option, which enables
  10965. caching of the archives before they are sent to clients---see below for
  10966. details. The @command{guix weather} command provides a handy way to
  10967. check what a server provides (@pxref{Invoking guix weather}).
  10968. As a bonus, @command{guix publish} also serves as a content-addressed
  10969. mirror for source files referenced in @code{origin} records
  10970. (@pxref{origin Reference}). For instance, assuming @command{guix
  10971. publish} is running on @code{example.org}, the following URL returns the
  10972. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  10973. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  10974. @example
  10975. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  10976. @end example
  10977. Obviously, these URLs only work for files that are in the store; in
  10978. other cases, they return 404 (``Not Found'').
  10979. @cindex build logs, publication
  10980. Build logs are available from @code{/log} URLs like:
  10981. @example
  10982. http://example.org/log/gwspk@dots{}-guile-2.2.3
  10983. @end example
  10984. @noindent
  10985. When @command{guix-daemon} is configured to save compressed build logs,
  10986. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  10987. URLs return the compressed log as-is, with an appropriate
  10988. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  10989. running @command{guix-daemon} with @option{--log-compression=gzip} since
  10990. Web browsers can automatically decompress it, which is not the case with
  10991. Bzip2 compression.
  10992. The following options are available:
  10993. @table @code
  10994. @item --port=@var{port}
  10995. @itemx -p @var{port}
  10996. Listen for HTTP requests on @var{port}.
  10997. @item --listen=@var{host}
  10998. Listen on the network interface for @var{host}. The default is to
  10999. accept connections from any interface.
  11000. @item --user=@var{user}
  11001. @itemx -u @var{user}
  11002. Change privileges to @var{user} as soon as possible---i.e., once the
  11003. server socket is open and the signing key has been read.
  11004. @item --compression[=@var{method}[:@var{level}]]
  11005. @itemx -C [@var{method}[:@var{level}]]
  11006. Compress data using the given @var{method} and @var{level}. @var{method} is
  11007. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  11008. omitted, @code{gzip} is used.
  11009. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  11010. to different compression levels: 1 is the fastest, and 9 is the best
  11011. (CPU-intensive). The default is 3.
  11012. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  11013. small increase in CPU usage; see
  11014. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  11015. Web page}. However, @code{lzip} achieves low decompression throughput
  11016. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  11017. bottleneck for someone who downloads over a fast network connection.
  11018. The compression ratio of @code{zstd} is between that of @code{lzip} and
  11019. that of @code{gzip}; its main advantage is a
  11020. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  11021. Unless @option{--cache} is used, compression occurs on the fly and
  11022. the compressed streams are not
  11023. cached. Thus, to reduce load on the machine that runs @command{guix
  11024. publish}, it may be a good idea to choose a low compression level, to
  11025. run @command{guix publish} behind a caching proxy, or to use
  11026. @option{--cache}. Using @option{--cache} has the advantage that it
  11027. allows @command{guix publish} to add @code{Content-Length} HTTP header
  11028. to its responses.
  11029. This option can be repeated, in which case every substitute gets compressed
  11030. using all the selected methods, and all of them are advertised. This is
  11031. useful when users may not support all the compression methods: they can select
  11032. the one they support.
  11033. @item --cache=@var{directory}
  11034. @itemx -c @var{directory}
  11035. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  11036. and only serve archives that are in cache.
  11037. When this option is omitted, archives and meta-data are created
  11038. on-the-fly. This can reduce the available bandwidth, especially when
  11039. compression is enabled, since this may become CPU-bound. Another
  11040. drawback of the default mode is that the length of archives is not known
  11041. in advance, so @command{guix publish} does not add a
  11042. @code{Content-Length} HTTP header to its responses, which in turn
  11043. prevents clients from knowing the amount of data being downloaded.
  11044. Conversely, when @option{--cache} is used, the first request for a store
  11045. item (@i{via} a @code{.narinfo} URL) triggers a
  11046. background process to @dfn{bake} the archive---computing its
  11047. @code{.narinfo} and compressing the archive, if needed. Once the
  11048. archive is cached in @var{directory}, subsequent requests succeed and
  11049. are served directly from the cache, which guarantees that clients get
  11050. the best possible bandwidth.
  11051. That first @code{.narinfo} request nonetheless returns 200, provided the
  11052. requested store item is ``small enough'', below the cache bypass
  11053. threshold---see @option{--cache-bypass-threshold} below. That way,
  11054. clients do not have to wait until the archive is baked. For larger
  11055. store items, the first @code{.narinfo} request returns 404, meaning that
  11056. clients have to wait until the archive is baked.
  11057. The ``baking'' process is performed by worker threads. By default, one
  11058. thread per CPU core is created, but this can be customized. See
  11059. @option{--workers} below.
  11060. When @option{--ttl} is used, cached entries are automatically deleted
  11061. when they have expired.
  11062. @item --workers=@var{N}
  11063. When @option{--cache} is used, request the allocation of @var{N} worker
  11064. threads to ``bake'' archives.
  11065. @item --ttl=@var{ttl}
  11066. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  11067. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  11068. days, @code{1m} means 1 month, and so on.
  11069. This allows the user's Guix to keep substitute information in cache for
  11070. @var{ttl}. However, note that @code{guix publish} does not itself
  11071. guarantee that the store items it provides will indeed remain available
  11072. for as long as @var{ttl}.
  11073. Additionally, when @option{--cache} is used, cached entries that have
  11074. not been accessed for @var{ttl} and that no longer have a corresponding
  11075. item in the store, may be deleted.
  11076. @item --negative-ttl=@var{ttl}
  11077. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  11078. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  11079. which the HTTP 404 code is returned. By default, no negative TTL is
  11080. advertised.
  11081. This parameter can help adjust server load and substitute latency by
  11082. instructing cooperating clients to be more or less patient when a store
  11083. item is missing.
  11084. @item --cache-bypass-threshold=@var{size}
  11085. When used in conjunction with @option{--cache}, store items smaller than
  11086. @var{size} are immediately available, even when they are not yet in
  11087. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  11088. for megabytes and so on. The default is @code{10M}.
  11089. ``Cache bypass'' allows you to reduce the publication delay for clients
  11090. at the expense of possibly additional I/O and CPU use on the server
  11091. side: depending on the client access patterns, those store items can end
  11092. up being baked several times until a copy is available in cache.
  11093. Increasing the threshold may be useful for sites that have few users, or
  11094. to guarantee that users get substitutes even for store items that are
  11095. not popular.
  11096. @item --nar-path=@var{path}
  11097. Use @var{path} as the prefix for the URLs of ``nar'' files
  11098. (@pxref{Invoking guix archive, normalized archives}).
  11099. By default, nars are served at a URL such as
  11100. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  11101. change the @code{/nar} part to @var{path}.
  11102. @item --public-key=@var{file}
  11103. @itemx --private-key=@var{file}
  11104. Use the specific @var{file}s as the public/private key pair used to sign
  11105. the store items being published.
  11106. The files must correspond to the same key pair (the private key is used
  11107. for signing and the public key is merely advertised in the signature
  11108. metadata). They must contain keys in the canonical s-expression format
  11109. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  11110. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  11111. @file{/etc/guix/signing-key.sec} are used.
  11112. @item --repl[=@var{port}]
  11113. @itemx -r [@var{port}]
  11114. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  11115. Reference Manual}) on @var{port} (37146 by default). This is used
  11116. primarily for debugging a running @command{guix publish} server.
  11117. @end table
  11118. Enabling @command{guix publish} on Guix System is a one-liner: just
  11119. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  11120. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  11121. @code{guix-publish-service-type}}).
  11122. If you are instead running Guix on a ``foreign distro'', follow these
  11123. instructions:
  11124. @itemize
  11125. @item
  11126. If your host distro uses the systemd init system:
  11127. @example
  11128. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  11129. /etc/systemd/system/
  11130. # systemctl start guix-publish && systemctl enable guix-publish
  11131. @end example
  11132. @item
  11133. If your host distro uses the Upstart init system:
  11134. @example
  11135. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  11136. # start guix-publish
  11137. @end example
  11138. @item
  11139. Otherwise, proceed similarly with your distro's init system.
  11140. @end itemize
  11141. @node Invoking guix challenge
  11142. @section Invoking @command{guix challenge}
  11143. @cindex reproducible builds
  11144. @cindex verifiable builds
  11145. @cindex @command{guix challenge}
  11146. @cindex challenge
  11147. Do the binaries provided by this server really correspond to the source
  11148. code it claims to build? Is a package build process deterministic?
  11149. These are the questions the @command{guix challenge} command attempts to
  11150. answer.
  11151. The former is obviously an important question: Before using a substitute
  11152. server (@pxref{Substitutes}), one had better @emph{verify} that it
  11153. provides the right binaries, and thus @emph{challenge} it. The latter
  11154. is what enables the former: If package builds are deterministic, then
  11155. independent builds of the package should yield the exact same result,
  11156. bit for bit; if a server provides a binary different from the one
  11157. obtained locally, it may be either corrupt or malicious.
  11158. We know that the hash that shows up in @file{/gnu/store} file names is
  11159. the hash of all the inputs of the process that built the file or
  11160. directory---compilers, libraries, build scripts,
  11161. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  11162. one store file name should map to exactly one build output.
  11163. @command{guix challenge} checks whether there is, indeed, a single
  11164. mapping by comparing the build outputs of several independent builds of
  11165. any given store item.
  11166. The command output looks like this:
  11167. @smallexample
  11168. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  11169. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER-1}'... 100.0%
  11170. updating list of substitutes from 'https://guix.example.org'... 100.0%
  11171. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  11172. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  11173. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  11174. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  11175. differing files:
  11176. /lib/libcrypto.so.1.1
  11177. /lib/libssl.so.1.1
  11178. /gnu/store/@dots{}-git-2.5.0 contents differ:
  11179. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  11180. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  11181. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  11182. differing file:
  11183. /libexec/git-core/git-fsck
  11184. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  11185. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  11186. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  11187. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  11188. differing file:
  11189. /share/man/man1/pius.1.gz
  11190. @dots{}
  11191. 6,406 store items were analyzed:
  11192. - 4,749 (74.1%) were identical
  11193. - 525 (8.2%) differed
  11194. - 1,132 (17.7%) were inconclusive
  11195. @end smallexample
  11196. @noindent
  11197. In this example, @command{guix challenge} first scans the store to
  11198. determine the set of locally-built derivations---as opposed to store
  11199. items that were downloaded from a substitute server---and then queries
  11200. all the substitute servers. It then reports those store items for which
  11201. the servers obtained a result different from the local build.
  11202. @cindex non-determinism, in package builds
  11203. As an example, @code{guix.example.org} always gets a different answer.
  11204. Conversely, @code{@value{SUBSTITUTE-SERVER-1}} agrees with local builds, except in the
  11205. case of Git. This might indicate that the build process of Git is
  11206. non-deterministic, meaning that its output varies as a function of
  11207. various things that Guix does not fully control, in spite of building
  11208. packages in isolated environments (@pxref{Features}). Most common
  11209. sources of non-determinism include the addition of timestamps in build
  11210. results, the inclusion of random numbers, and directory listings sorted
  11211. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  11212. more information.
  11213. To find out what is wrong with this Git binary, the easiest approach is
  11214. to run:
  11215. @example
  11216. guix challenge git \
  11217. --diff=diffoscope \
  11218. --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  11219. @end example
  11220. This automatically invokes @command{diffoscope}, which displays detailed
  11221. information about files that differ.
  11222. Alternatively, we can do something along these lines (@pxref{Invoking guix
  11223. archive}):
  11224. @example
  11225. $ wget -q -O - https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-git-2.5.0 \
  11226. | lzip -d | guix archive -x /tmp/git
  11227. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  11228. @end example
  11229. This command shows the difference between the files resulting from the
  11230. local build, and the files resulting from the build on
  11231. @code{@value{SUBSTITUTE-SERVER-1}} (@pxref{Overview, Comparing and Merging Files,,
  11232. diffutils, Comparing and Merging Files}). The @command{diff} command
  11233. works great for text files. When binary files differ, a better option
  11234. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  11235. visualize differences for all kinds of files.
  11236. Once you have done that work, you can tell whether the differences are due
  11237. to a non-deterministic build process or to a malicious server. We try
  11238. hard to remove sources of non-determinism in packages to make it easier
  11239. to verify substitutes, but of course, this is a process that
  11240. involves not just Guix, but a large part of the free software community.
  11241. In the meantime, @command{guix challenge} is one tool to help address
  11242. the problem.
  11243. If you are writing packages for Guix, you are encouraged to check
  11244. whether @code{@value{SUBSTITUTE-SERVER-1}} and other substitute servers obtain the
  11245. same build result as you did with:
  11246. @example
  11247. $ guix challenge @var{package}
  11248. @end example
  11249. @noindent
  11250. where @var{package} is a package specification such as
  11251. @code{guile@@2.0} or @code{glibc:debug}.
  11252. The general syntax is:
  11253. @example
  11254. guix challenge @var{options} [@var{packages}@dots{}]
  11255. @end example
  11256. When a difference is found between the hash of a locally-built item and
  11257. that of a server-provided substitute, or among substitutes provided by
  11258. different servers, the command displays it as in the example above and
  11259. its exit code is 2 (other non-zero exit codes denote other kinds of
  11260. errors).
  11261. The one option that matters is:
  11262. @table @code
  11263. @item --substitute-urls=@var{urls}
  11264. Consider @var{urls} the whitespace-separated list of substitute source
  11265. URLs to compare to.
  11266. @item --diff=@var{mode}
  11267. Upon mismatches, show differences according to @var{mode}, one of:
  11268. @table @asis
  11269. @item @code{simple} (the default)
  11270. Show the list of files that differ.
  11271. @item @code{diffoscope}
  11272. @itemx @var{command}
  11273. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  11274. two directories whose contents do not match.
  11275. When @var{command} is an absolute file name, run @var{command} instead
  11276. of Diffoscope.
  11277. @item @code{none}
  11278. Do not show further details about the differences.
  11279. @end table
  11280. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  11281. downloads the store items from the given substitute servers so that it
  11282. can compare them.
  11283. @item --verbose
  11284. @itemx -v
  11285. Show details about matches (identical contents) in addition to
  11286. information about mismatches.
  11287. @end table
  11288. @node Invoking guix copy
  11289. @section Invoking @command{guix copy}
  11290. @cindex copy, of store items, over SSH
  11291. @cindex SSH, copy of store items
  11292. @cindex sharing store items across machines
  11293. @cindex transferring store items across machines
  11294. The @command{guix copy} command copies items from the store of one
  11295. machine to that of another machine over a secure shell (SSH)
  11296. connection@footnote{This command is available only when Guile-SSH was
  11297. found. @xref{Requirements}, for details.}. For example, the following
  11298. command copies the @code{coreutils} package, the user's profile, and all
  11299. their dependencies over to @var{host}, logged in as @var{user}:
  11300. @example
  11301. guix copy --to=@var{user}@@@var{host} \
  11302. coreutils $(readlink -f ~/.guix-profile)
  11303. @end example
  11304. If some of the items to be copied are already present on @var{host},
  11305. they are not actually sent.
  11306. The command below retrieves @code{libreoffice} and @code{gimp} from
  11307. @var{host}, assuming they are available there:
  11308. @example
  11309. guix copy --from=@var{host} libreoffice gimp
  11310. @end example
  11311. The SSH connection is established using the Guile-SSH client, which is
  11312. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  11313. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  11314. The key used to sign items that are sent must be accepted by the remote
  11315. machine. Likewise, the key used by the remote machine to sign items you
  11316. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  11317. own daemon. @xref{Invoking guix archive}, for more information about
  11318. store item authentication.
  11319. The general syntax is:
  11320. @example
  11321. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  11322. @end example
  11323. You must always specify one of the following options:
  11324. @table @code
  11325. @item --to=@var{spec}
  11326. @itemx --from=@var{spec}
  11327. Specify the host to send to or receive from. @var{spec} must be an SSH
  11328. spec such as @code{example.org}, @code{charlie@@example.org}, or
  11329. @code{charlie@@example.org:2222}.
  11330. @end table
  11331. The @var{items} can be either package names, such as @code{gimp}, or
  11332. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  11333. When specifying the name of a package to send, it is first built if
  11334. needed, unless @option{--dry-run} was specified. Common build options
  11335. are supported (@pxref{Common Build Options}).
  11336. @node Invoking guix container
  11337. @section Invoking @command{guix container}
  11338. @cindex container
  11339. @cindex @command{guix container}
  11340. @quotation Note
  11341. As of version @value{VERSION}, this tool is experimental. The interface
  11342. is subject to radical change in the future.
  11343. @end quotation
  11344. The purpose of @command{guix container} is to manipulate processes
  11345. running within an isolated environment, commonly known as a
  11346. ``container'', typically created by the @command{guix shell}
  11347. (@pxref{Invoking guix shell}) and @command{guix system container}
  11348. (@pxref{Invoking guix system}) commands.
  11349. The general syntax is:
  11350. @example
  11351. guix container @var{action} @var{options}@dots{}
  11352. @end example
  11353. @var{action} specifies the operation to perform with a container, and
  11354. @var{options} specifies the context-specific arguments for the action.
  11355. The following actions are available:
  11356. @table @code
  11357. @item exec
  11358. Execute a command within the context of a running container.
  11359. The syntax is:
  11360. @example
  11361. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  11362. @end example
  11363. @var{pid} specifies the process ID of the running container.
  11364. @var{program} specifies an executable file name within the root file
  11365. system of the container. @var{arguments} are the additional options that
  11366. will be passed to @var{program}.
  11367. The following command launches an interactive login shell inside a
  11368. Guix system container, started by @command{guix system container}, and whose
  11369. process ID is 9001:
  11370. @example
  11371. guix container exec 9001 /run/current-system/profile/bin/bash --login
  11372. @end example
  11373. Note that the @var{pid} cannot be the parent process of a container. It
  11374. must be PID 1 of the container or one of its child processes.
  11375. @end table
  11376. @node Invoking guix weather
  11377. @section Invoking @command{guix weather}
  11378. Occasionally you're grumpy because substitutes are lacking and you end
  11379. up building packages by yourself (@pxref{Substitutes}). The
  11380. @command{guix weather} command reports on substitute availability on the
  11381. specified servers so you can have an idea of whether you'll be grumpy
  11382. today. It can sometimes be useful info as a user, but it is primarily
  11383. useful to people running @command{guix publish} (@pxref{Invoking guix
  11384. publish}).
  11385. @cindex statistics, for substitutes
  11386. @cindex availability of substitutes
  11387. @cindex substitute availability
  11388. @cindex weather, substitute availability
  11389. Here's a sample run:
  11390. @example
  11391. $ guix weather --substitute-urls=https://guix.example.org
  11392. computing 5,872 package derivations for x86_64-linux...
  11393. looking for 6,128 store items on https://guix.example.org..
  11394. updating list of substitutes from 'https://guix.example.org'... 100.0%
  11395. https://guix.example.org
  11396. 43.4% substitutes available (2,658 out of 6,128)
  11397. 7,032.5 MiB of nars (compressed)
  11398. 19,824.2 MiB on disk (uncompressed)
  11399. 0.030 seconds per request (182.9 seconds in total)
  11400. 33.5 requests per second
  11401. 9.8% (342 out of 3,470) of the missing items are queued
  11402. 867 queued builds
  11403. x86_64-linux: 518 (59.7%)
  11404. i686-linux: 221 (25.5%)
  11405. aarch64-linux: 128 (14.8%)
  11406. build rate: 23.41 builds per hour
  11407. x86_64-linux: 11.16 builds per hour
  11408. i686-linux: 6.03 builds per hour
  11409. aarch64-linux: 6.41 builds per hour
  11410. @end example
  11411. @cindex continuous integration, statistics
  11412. As you can see, it reports the fraction of all the packages for which
  11413. substitutes are available on the server---regardless of whether
  11414. substitutes are enabled, and regardless of whether this server's signing
  11415. key is authorized. It also reports the size of the compressed archives
  11416. (``nars'') provided by the server, the size the corresponding store
  11417. items occupy in the store (assuming deduplication is turned off), and
  11418. the server's throughput. The second part gives continuous integration
  11419. (CI) statistics, if the server supports it. In addition, using the
  11420. @option{--coverage} option, @command{guix weather} can list ``important''
  11421. package substitutes missing on the server (see below).
  11422. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  11423. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  11424. challenge}, it ignores signatures on those substitutes, which is
  11425. innocuous since the command only gathers statistics and cannot install
  11426. those substitutes.
  11427. The general syntax is:
  11428. @example
  11429. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  11430. @end example
  11431. When @var{packages} is omitted, @command{guix weather} checks the availability
  11432. of substitutes for @emph{all} the packages, or for those specified with
  11433. @option{--manifest}; otherwise it only considers the specified packages. It
  11434. is also possible to query specific system types with @option{--system}.
  11435. @command{guix weather} exits with a non-zero code when the fraction of
  11436. available substitutes is below 100%.
  11437. The available options are listed below.
  11438. @table @code
  11439. @item --substitute-urls=@var{urls}
  11440. @var{urls} is the space-separated list of substitute server URLs to
  11441. query. When this option is omitted, the default set of substitute
  11442. servers is queried.
  11443. @item --system=@var{system}
  11444. @itemx -s @var{system}
  11445. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  11446. option can be repeated, in which case @command{guix weather} will query
  11447. substitutes for several system types.
  11448. @item --manifest=@var{file}
  11449. Instead of querying substitutes for all the packages, only ask for those
  11450. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  11451. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  11452. guix package}).
  11453. This option can be repeated several times, in which case the manifests
  11454. are concatenated.
  11455. @item --coverage[=@var{count}]
  11456. @itemx -c [@var{count}]
  11457. Report on substitute coverage for packages: list packages with at least
  11458. @var{count} dependents (zero by default) for which substitutes are
  11459. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  11460. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  11461. @var{b} usually lacks substitutes as well. The result looks like this:
  11462. @example
  11463. $ guix weather --substitute-urls=@value{SUBSTITUTE-URLS} -c 10
  11464. computing 8,983 package derivations for x86_64-linux...
  11465. looking for 9,343 store items on @value{SUBSTITUTE-URLS}...
  11466. updating substitutes from '@value{SUBSTITUTE-URLS}'... 100.0%
  11467. @value{SUBSTITUTE-URLS}
  11468. 64.7% substitutes available (6,047 out of 9,343)
  11469. @dots{}
  11470. 2502 packages are missing from '@value{SUBSTITUTE-URLS}' for 'x86_64-linux', among which:
  11471. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  11472. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  11473. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  11474. @dots{}
  11475. @end example
  11476. What this example shows is that @code{kcoreaddons} and presumably the 58
  11477. packages that depend on it have no substitutes at
  11478. @code{@value{SUBSTITUTE-SERVER-1}}; likewise for @code{qgpgme} and the 46
  11479. packages that depend on it.
  11480. If you are a Guix developer, or if you are taking care of this build farm,
  11481. you'll probably want to have a closer look at these packages: they may simply
  11482. fail to build.
  11483. @item --display-missing
  11484. Display the list of store items for which substitutes are missing.
  11485. @end table
  11486. @node Invoking guix processes
  11487. @section Invoking @command{guix processes}
  11488. The @command{guix processes} command can be useful to developers and system
  11489. administrators, especially on multi-user machines and on build farms: it lists
  11490. the current sessions (connections to the daemon), as well as information about
  11491. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  11492. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  11493. listed.}. Here's an example of the information it returns:
  11494. @example
  11495. $ sudo guix processes
  11496. SessionPID: 19002
  11497. ClientPID: 19090
  11498. ClientCommand: guix shell python
  11499. SessionPID: 19402
  11500. ClientPID: 19367
  11501. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  11502. SessionPID: 19444
  11503. ClientPID: 19419
  11504. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11505. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  11506. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  11507. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  11508. ChildPID: 20495
  11509. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11510. ChildPID: 27733
  11511. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11512. ChildPID: 27793
  11513. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11514. @end example
  11515. In this example we see that @command{guix-daemon} has three clients:
  11516. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  11517. integration tool; their process identifier (PID) is given by the
  11518. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  11519. @command{guix-daemon} sub-process of this particular session.
  11520. The @code{LockHeld} fields show which store items are currently locked
  11521. by this session, which corresponds to store items being built or
  11522. substituted (the @code{LockHeld} field is not displayed when
  11523. @command{guix processes} is not running as root). Last, by looking at
  11524. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  11525. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  11526. The output is in Recutils format so we can use the handy @command{recsel}
  11527. command to select sessions of interest (@pxref{Selection Expressions,,,
  11528. recutils, GNU recutils manual}). As an example, the command shows the command
  11529. line and PID of the client that triggered the build of a Perl package:
  11530. @example
  11531. $ sudo guix processes | \
  11532. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  11533. ClientPID: 19419
  11534. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11535. @end example
  11536. Additional options are listed below.
  11537. @table @code
  11538. @item --format=@var{format}
  11539. @itemx -f @var{format}
  11540. Produce output in the specified @var{format}, one of:
  11541. @table @code
  11542. @item recutils
  11543. The default option. It outputs a set of Session recutils records
  11544. that include each @code{ChildProcess} as a field.
  11545. @item normalized
  11546. Normalize the output records into record sets (@pxref{Record Sets,,,
  11547. recutils, GNU recutils manual}). Normalizing into record sets allows
  11548. joins across record types. The example below lists the PID of each
  11549. @code{ChildProcess} and the associated PID for @code{Session} that
  11550. spawned the @code{ChildProcess} where the @code{Session} was started
  11551. using @command{guix build}.
  11552. @example
  11553. $ guix processes --format=normalized | \
  11554. recsel \
  11555. -j Session \
  11556. -t ChildProcess \
  11557. -p Session.PID,PID \
  11558. -e 'Session.ClientCommand ~ "guix build"'
  11559. PID: 4435
  11560. Session_PID: 4278
  11561. PID: 4554
  11562. Session_PID: 4278
  11563. PID: 4646
  11564. Session_PID: 4278
  11565. @end example
  11566. @end table
  11567. @end table
  11568. @node System Configuration
  11569. @chapter System Configuration
  11570. @cindex system configuration
  11571. Guix System supports a consistent whole-system configuration
  11572. mechanism. By that we mean that all aspects of the global system
  11573. configuration---such as the available system services, timezone and
  11574. locale settings, user accounts---are declared in a single place. Such
  11575. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  11576. One of the advantages of putting all the system configuration under the
  11577. control of Guix is that it supports transactional system upgrades, and
  11578. makes it possible to roll back to a previous system instantiation,
  11579. should something go wrong with the new one (@pxref{Features}). Another
  11580. advantage is that it makes it easy to replicate the exact same configuration
  11581. across different machines, or at different points in time, without
  11582. having to resort to additional administration tools layered on top of
  11583. the own tools of the system.
  11584. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  11585. This section describes this mechanism. First we focus on the system
  11586. administrator's viewpoint---explaining how the system is configured and
  11587. instantiated. Then we show how this mechanism can be extended, for
  11588. instance to support new system services.
  11589. @menu
  11590. * Using the Configuration System:: Customizing your GNU system.
  11591. * operating-system Reference:: Detail of operating-system declarations.
  11592. * File Systems:: Configuring file system mounts.
  11593. * Mapped Devices:: Block device extra processing.
  11594. * Swap Space:: Backing RAM with disk space.
  11595. * User Accounts:: Specifying user accounts.
  11596. * Keyboard Layout:: How the system interprets key strokes.
  11597. * Locales:: Language and cultural convention settings.
  11598. * Services:: Specifying system services.
  11599. * Setuid Programs:: Programs running with root privileges.
  11600. * X.509 Certificates:: Authenticating HTTPS servers.
  11601. * Name Service Switch:: Configuring libc's name service switch.
  11602. * Initial RAM Disk:: Linux-Libre bootstrapping.
  11603. * Bootloader Configuration:: Configuring the boot loader.
  11604. * Invoking guix system:: Instantiating a system configuration.
  11605. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  11606. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  11607. * Defining Services:: Adding new service definitions.
  11608. @end menu
  11609. @node Using the Configuration System
  11610. @section Using the Configuration System
  11611. The operating system is configured by providing an
  11612. @code{operating-system} declaration in a file that can then be passed to
  11613. the @command{guix system} command (@pxref{Invoking guix system}). A
  11614. simple setup, with the default system services, the default Linux-Libre
  11615. kernel, initial RAM disk, and boot loader looks like this:
  11616. @findex operating-system
  11617. @lisp
  11618. @include os-config-bare-bones.texi
  11619. @end lisp
  11620. This example should be self-describing. Some of the fields defined
  11621. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  11622. Others, such as @code{packages} and @code{services}, can be omitted, in
  11623. which case they get a default value.
  11624. Below we discuss the effect of some of the most important fields
  11625. (@pxref{operating-system Reference}, for details about all the available
  11626. fields), and how to @dfn{instantiate} the operating system using
  11627. @command{guix system}.
  11628. @unnumberedsubsec Bootloader
  11629. @cindex legacy boot, on Intel machines
  11630. @cindex BIOS boot, on Intel machines
  11631. @cindex UEFI boot
  11632. @cindex EFI boot
  11633. The @code{bootloader} field describes the method that will be used to boot
  11634. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  11635. mode, as in the example above. However, more recent machines rely instead on
  11636. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  11637. the @code{bootloader} field should contain something along these lines:
  11638. @lisp
  11639. (bootloader-configuration
  11640. (bootloader grub-efi-bootloader)
  11641. (targets '("/boot/efi")))
  11642. @end lisp
  11643. @xref{Bootloader Configuration}, for more information on the available
  11644. configuration options.
  11645. @unnumberedsubsec Globally-Visible Packages
  11646. @vindex %base-packages
  11647. The @code{packages} field lists packages that will be globally visible
  11648. on the system, for all user accounts---i.e., in every user's @env{PATH}
  11649. environment variable---in addition to the per-user profiles
  11650. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  11651. provides all the tools one would expect for basic user and administrator
  11652. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  11653. the @command{mg} lightweight text editor, @command{find}, @command{grep},
  11654. etc. The example above adds GNU@tie{}Screen to those,
  11655. taken from the @code{(gnu packages screen)}
  11656. module (@pxref{Package Modules}). The
  11657. @code{(list package output)} syntax can be used to add a specific output
  11658. of a package:
  11659. @lisp
  11660. (use-modules (gnu packages))
  11661. (use-modules (gnu packages dns))
  11662. (operating-system
  11663. ;; ...
  11664. (packages (cons (list isc-bind "utils")
  11665. %base-packages)))
  11666. @end lisp
  11667. @findex specification->package
  11668. Referring to packages by variable name, like @code{isc-bind} above, has
  11669. the advantage of being unambiguous; it also allows typos and such to be
  11670. diagnosed right away as ``unbound variables''. The downside is that one
  11671. needs to know which module defines which package, and to augment the
  11672. @code{use-package-modules} line accordingly. To avoid that, one can use
  11673. the @code{specification->package} procedure of the @code{(gnu packages)}
  11674. module, which returns the best package for a given name or name and
  11675. version:
  11676. @lisp
  11677. (use-modules (gnu packages))
  11678. (operating-system
  11679. ;; ...
  11680. (packages (append (map specification->package
  11681. '("tcpdump" "htop" "gnupg@@2.0"))
  11682. %base-packages)))
  11683. @end lisp
  11684. @unnumberedsubsec System Services
  11685. @cindex services
  11686. @vindex %base-services
  11687. The @code{services} field lists @dfn{system services} to be made
  11688. available when the system starts (@pxref{Services}).
  11689. The @code{operating-system} declaration above specifies that, in
  11690. addition to the basic services, we want the OpenSSH secure shell
  11691. daemon listening on port 2222 (@pxref{Networking Services,
  11692. @code{openssh-service-type}}). Under the hood,
  11693. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  11694. right command-line options, possibly with supporting configuration files
  11695. generated as needed (@pxref{Defining Services}).
  11696. @cindex customization, of services
  11697. @findex modify-services
  11698. Occasionally, instead of using the base services as is, you will want to
  11699. customize them. To do this, use @code{modify-services} (@pxref{Service
  11700. Reference, @code{modify-services}}) to modify the list.
  11701. @anchor{auto-login to TTY} For example, suppose you want to modify
  11702. @code{guix-daemon} and Mingetty (the console log-in) in the
  11703. @code{%base-services} list (@pxref{Base Services,
  11704. @code{%base-services}}). To do that, you can write the following in
  11705. your operating system declaration:
  11706. @lisp
  11707. (define %my-services
  11708. ;; My very own list of services.
  11709. (modify-services %base-services
  11710. (guix-service-type config =>
  11711. (guix-configuration
  11712. (inherit config)
  11713. ;; Fetch substitutes from example.org.
  11714. (substitute-urls
  11715. (list "https://example.org/guix"
  11716. "https://ci.guix.gnu.org"))))
  11717. (mingetty-service-type config =>
  11718. (mingetty-configuration
  11719. (inherit config)
  11720. ;; Automatially log in as "guest".
  11721. (auto-login "guest")))))
  11722. (operating-system
  11723. ;; @dots{}
  11724. (services %my-services))
  11725. @end lisp
  11726. This changes the configuration---i.e., the service parameters---of the
  11727. @code{guix-service-type} instance, and that of all the
  11728. @code{mingetty-service-type} instances in the @code{%base-services} list
  11729. (@pxref{Auto-Login to a Specific TTY, see the cookbook for how to
  11730. auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})).
  11731. Observe how this is accomplished: first, we arrange for the original
  11732. configuration to be bound to the identifier @code{config} in the
  11733. @var{body}, and then we write the @var{body} so that it evaluates to the
  11734. desired configuration. In particular, notice how we use @code{inherit}
  11735. to create a new configuration which has the same values as the old
  11736. configuration, but with a few modifications.
  11737. @cindex encrypted disk
  11738. The configuration for a typical ``desktop'' usage, with an encrypted
  11739. root partition, a swap file on the root partition, the X11 display
  11740. server, GNOME and Xfce (users can choose which of these desktop
  11741. environments to use at the log-in screen by pressing @kbd{F1}), network
  11742. management, power management, and more, would look like this:
  11743. @lisp
  11744. @include os-config-desktop.texi
  11745. @end lisp
  11746. A graphical system with a choice of lightweight window managers
  11747. instead of full-blown desktop environments would look like this:
  11748. @lisp
  11749. @include os-config-lightweight-desktop.texi
  11750. @end lisp
  11751. This example refers to the @file{/boot/efi} file system by its UUID,
  11752. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  11753. as returned by the @command{blkid} command.
  11754. @xref{Desktop Services}, for the exact list of services provided by
  11755. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  11756. information about the @code{nss-certs} package that is used here.
  11757. Again, @code{%desktop-services} is just a list of service objects. If
  11758. you want to remove services from there, you can do so using the
  11759. procedures for list filtering (@pxref{SRFI-1 Filtering and
  11760. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  11761. following expression returns a list that contains all the services in
  11762. @code{%desktop-services} minus the Avahi service:
  11763. @lisp
  11764. (remove (lambda (service)
  11765. (eq? (service-kind service) avahi-service-type))
  11766. %desktop-services)
  11767. @end lisp
  11768. Alternatively, the @code{modify-services} macro can be used:
  11769. @lisp
  11770. (modify-services %desktop-services
  11771. (delete avahi-service-type))
  11772. @end lisp
  11773. @unnumberedsubsec Instantiating the System
  11774. Assuming the @code{operating-system} declaration
  11775. is stored in the @file{my-system-config.scm}
  11776. file, the @command{guix system reconfigure my-system-config.scm} command
  11777. instantiates that configuration, and makes it the default GRUB boot
  11778. entry (@pxref{Invoking guix system}).
  11779. The normal way to change the system configuration is by updating this
  11780. file and re-running @command{guix system reconfigure}. One should never
  11781. have to touch files in @file{/etc} or to run commands that modify the
  11782. system state such as @command{useradd} or @command{grub-install}. In
  11783. fact, you must avoid that since that would not only void your warranty
  11784. but also prevent you from rolling back to previous versions of your
  11785. system, should you ever need to.
  11786. @cindex roll-back, of the operating system
  11787. Speaking of roll-back, each time you run @command{guix system
  11788. reconfigure}, a new @dfn{generation} of the system is created---without
  11789. modifying or deleting previous generations. Old system generations get
  11790. an entry in the bootloader boot menu, allowing you to boot them in case
  11791. something went wrong with the latest generation. Reassuring, no? The
  11792. @command{guix system list-generations} command lists the system
  11793. generations available on disk. It is also possible to roll back the
  11794. system via the commands @command{guix system roll-back} and
  11795. @command{guix system switch-generation}.
  11796. Although the @command{guix system reconfigure} command will not modify
  11797. previous generations, you must take care when the current generation is not
  11798. the latest (e.g., after invoking @command{guix system roll-back}), since
  11799. the operation might overwrite a later generation (@pxref{Invoking guix
  11800. system}).
  11801. @unnumberedsubsec The Programming Interface
  11802. At the Scheme level, the bulk of an @code{operating-system} declaration
  11803. is instantiated with the following monadic procedure (@pxref{The Store
  11804. Monad}):
  11805. @deffn {Monadic Procedure} operating-system-derivation os
  11806. Return a derivation that builds @var{os}, an @code{operating-system}
  11807. object (@pxref{Derivations}).
  11808. The output of the derivation is a single directory that refers to all
  11809. the packages, configuration files, and other supporting files needed to
  11810. instantiate @var{os}.
  11811. @end deffn
  11812. This procedure is provided by the @code{(gnu system)} module. Along
  11813. with @code{(gnu services)} (@pxref{Services}), this module contains the
  11814. guts of Guix System. Make sure to visit it!
  11815. @node operating-system Reference
  11816. @section @code{operating-system} Reference
  11817. This section summarizes all the options available in
  11818. @code{operating-system} declarations (@pxref{Using the Configuration
  11819. System}).
  11820. @deftp {Data Type} operating-system
  11821. This is the data type representing an operating system configuration.
  11822. By that, we mean all the global system configuration, not per-user
  11823. configuration (@pxref{Using the Configuration System}).
  11824. @table @asis
  11825. @item @code{kernel} (default: @code{linux-libre})
  11826. The package object of the operating system kernel to
  11827. use@footnote{Currently only the Linux-libre kernel is fully supported.
  11828. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  11829. available when building a virtual machine disk image.}.
  11830. @cindex hurd
  11831. @item @code{hurd} (default: @code{#f})
  11832. The package object of the Hurd to be started by the kernel. When this
  11833. field is set, produce a GNU/Hurd operating system. In that case,
  11834. @code{kernel} must also be set to the @code{gnumach} package---the
  11835. microkernel the Hurd runs on.
  11836. @quotation Warning
  11837. This feature is experimental and only supported for disk images.
  11838. @end quotation
  11839. @item @code{kernel-loadable-modules} (default: '())
  11840. A list of objects (usually packages) to collect loadable kernel modules
  11841. from--e.g. @code{(list ddcci-driver-linux)}.
  11842. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  11843. List of strings or gexps representing additional arguments to pass on
  11844. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  11845. @item @code{bootloader}
  11846. The system bootloader configuration object. @xref{Bootloader Configuration}.
  11847. @item @code{label}
  11848. This is the label (a string) as it appears in the bootloader's menu entry.
  11849. The default label includes the kernel name and version.
  11850. @item @code{keyboard-layout} (default: @code{#f})
  11851. This field specifies the keyboard layout to use in the console. It can be
  11852. either @code{#f}, in which case the default keyboard layout is used (usually
  11853. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  11854. for more information.
  11855. This keyboard layout is in effect as soon as the kernel has booted. For
  11856. instance, it is the keyboard layout in effect when you type a passphrase if
  11857. your root file system is on a @code{luks-device-mapping} mapped device
  11858. (@pxref{Mapped Devices}).
  11859. @quotation Note
  11860. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  11861. that used by the graphical display server. @xref{Bootloader Configuration},
  11862. for information on how to specify the bootloader's keyboard layout. @xref{X
  11863. Window}, for information on how to specify the keyboard layout used by the X
  11864. Window System.
  11865. @end quotation
  11866. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  11867. @cindex initrd
  11868. @cindex initial RAM disk
  11869. The list of Linux kernel modules that need to be available in the
  11870. initial RAM disk. @xref{Initial RAM Disk}.
  11871. @item @code{initrd} (default: @code{base-initrd})
  11872. A procedure that returns an initial RAM disk for the Linux
  11873. kernel. This field is provided to support low-level customization and
  11874. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  11875. @item @code{firmware} (default: @code{%base-firmware})
  11876. @cindex firmware
  11877. List of firmware packages loadable by the operating system kernel.
  11878. The default includes firmware needed for Atheros- and Broadcom-based
  11879. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  11880. respectively). @xref{Hardware Considerations}, for more info on
  11881. supported hardware.
  11882. @item @code{host-name}
  11883. The host name.
  11884. @item @code{hosts-file}
  11885. @cindex hosts file
  11886. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  11887. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  11888. Reference Manual}). The default is a file with entries for
  11889. @code{localhost} and @var{host-name}.
  11890. @item @code{mapped-devices} (default: @code{'()})
  11891. A list of mapped devices. @xref{Mapped Devices}.
  11892. @item @code{file-systems}
  11893. A list of file systems. @xref{File Systems}.
  11894. @item @code{swap-devices} (default: @code{'()})
  11895. @cindex swap devices
  11896. A list of swap spaces. @xref{Swap Space}.
  11897. @item @code{users} (default: @code{%base-user-accounts})
  11898. @itemx @code{groups} (default: @code{%base-groups})
  11899. List of user accounts and groups. @xref{User Accounts}.
  11900. If the @code{users} list lacks a user account with UID@tie{}0, a
  11901. ``root'' account with UID@tie{}0 is automatically added.
  11902. @item @code{skeletons} (default: @code{(default-skeletons)})
  11903. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  11904. file-like objects}). These are the skeleton files that will be added to
  11905. the home directory of newly-created user accounts.
  11906. For instance, a valid value may look like this:
  11907. @lisp
  11908. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  11909. (".guile" ,(plain-file "guile"
  11910. "(use-modules (ice-9 readline))
  11911. (activate-readline)")))
  11912. @end lisp
  11913. @item @code{issue} (default: @code{%default-issue})
  11914. A string denoting the contents of the @file{/etc/issue} file, which is
  11915. displayed when users log in on a text console.
  11916. @item @code{packages} (default: @code{%base-packages})
  11917. A list of packages to be installed in the global profile, which is accessible
  11918. at @file{/run/current-system/profile}. Each element is either a package
  11919. variable or a package/output tuple. Here's a simple example of both:
  11920. @lisp
  11921. (cons* git ; the default "out" output
  11922. (list git "send-email") ; another output of git
  11923. %base-packages) ; the default set
  11924. @end lisp
  11925. The default set includes core utilities and it is good practice to
  11926. install non-core utilities in user profiles (@pxref{Invoking guix
  11927. package}).
  11928. @item @code{timezone}
  11929. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  11930. You can run the @command{tzselect} command to find out which timezone
  11931. string corresponds to your region. Choosing an invalid timezone name
  11932. causes @command{guix system} to fail.
  11933. @item @code{locale} (default: @code{"en_US.utf8"})
  11934. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  11935. Library Reference Manual}). @xref{Locales}, for more information.
  11936. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  11937. The list of locale definitions to be compiled and that may be used at
  11938. run time. @xref{Locales}.
  11939. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  11940. The list of GNU@tie{}libc packages whose locale data and tools are used
  11941. to build the locale definitions. @xref{Locales}, for compatibility
  11942. considerations that justify this option.
  11943. @item @code{name-service-switch} (default: @code{%default-nss})
  11944. Configuration of the libc name service switch (NSS)---a
  11945. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  11946. details.
  11947. @item @code{services} (default: @code{%base-services})
  11948. A list of service objects denoting system services. @xref{Services}.
  11949. @cindex essential services
  11950. @item @code{essential-services} (default: ...)
  11951. The list of ``essential services''---i.e., things like instances of
  11952. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  11953. Reference}), which are derived from the operating system definition itself.
  11954. As a user you should @emph{never} need to touch this field.
  11955. @item @code{pam-services} (default: @code{(base-pam-services)})
  11956. @cindex PAM
  11957. @cindex pluggable authentication modules
  11958. Linux @dfn{pluggable authentication module} (PAM) services.
  11959. @c FIXME: Add xref to PAM services section.
  11960. @item @code{setuid-programs} (default: @code{%setuid-programs})
  11961. List of @code{<setuid-program>}. @xref{Setuid Programs}, for more
  11962. information.
  11963. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  11964. @cindex sudoers file
  11965. The contents of the @file{/etc/sudoers} file as a file-like object
  11966. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  11967. This file specifies which users can use the @command{sudo} command, what
  11968. they are allowed to do, and what privileges they may gain. The default
  11969. is that only @code{root} and members of the @code{wheel} group may use
  11970. @code{sudo}.
  11971. @end table
  11972. @deffn {Scheme Syntax} this-operating-system
  11973. When used in the @emph{lexical scope} of an operating system field definition,
  11974. this identifier resolves to the operating system being defined.
  11975. The example below shows how to refer to the operating system being defined in
  11976. the definition of the @code{label} field:
  11977. @lisp
  11978. (use-modules (gnu) (guix))
  11979. (operating-system
  11980. ;; ...
  11981. (label (package-full-name
  11982. (operating-system-kernel this-operating-system))))
  11983. @end lisp
  11984. It is an error to refer to @code{this-operating-system} outside an operating
  11985. system definition.
  11986. @end deffn
  11987. @end deftp
  11988. @node File Systems
  11989. @section File Systems
  11990. The list of file systems to be mounted is specified in the
  11991. @code{file-systems} field of the operating system declaration
  11992. (@pxref{Using the Configuration System}). Each file system is declared
  11993. using the @code{file-system} form, like this:
  11994. @lisp
  11995. (file-system
  11996. (mount-point "/home")
  11997. (device "/dev/sda3")
  11998. (type "ext4"))
  11999. @end lisp
  12000. As usual, some of the fields are mandatory---those shown in the example
  12001. above---while others can be omitted. These are described below.
  12002. @deftp {Data Type} file-system
  12003. Objects of this type represent file systems to be mounted. They
  12004. contain the following members:
  12005. @table @asis
  12006. @item @code{type}
  12007. This is a string specifying the type of the file system---e.g.,
  12008. @code{"ext4"}.
  12009. @item @code{mount-point}
  12010. This designates the place where the file system is to be mounted.
  12011. @item @code{device}
  12012. This names the ``source'' of the file system. It can be one of three
  12013. things: a file system label, a file system UUID, or the name of a
  12014. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  12015. systems without having to hard-code their actual device
  12016. name@footnote{Note that, while it is tempting to use
  12017. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  12018. result, this is not recommended: These special device nodes are created
  12019. by the udev daemon and may be unavailable at the time the device is
  12020. mounted.}.
  12021. @findex file-system-label
  12022. File system labels are created using the @code{file-system-label}
  12023. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  12024. plain strings. Here's an example of a file system referred to by its
  12025. label, as shown by the @command{e2label} command:
  12026. @lisp
  12027. (file-system
  12028. (mount-point "/home")
  12029. (type "ext4")
  12030. (device (file-system-label "my-home")))
  12031. @end lisp
  12032. @findex uuid
  12033. UUIDs are converted from their string representation (as shown by the
  12034. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  12035. @code{uuid} form expects 16-byte UUIDs as defined in
  12036. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  12037. form of UUID used by the ext2 family of file systems and others, but it
  12038. is different from ``UUIDs'' found in FAT file systems, for instance.},
  12039. like this:
  12040. @lisp
  12041. (file-system
  12042. (mount-point "/home")
  12043. (type "ext4")
  12044. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  12045. @end lisp
  12046. When the source of a file system is a mapped device (@pxref{Mapped
  12047. Devices}), its @code{device} field @emph{must} refer to the mapped
  12048. device name---e.g., @file{"/dev/mapper/root-partition"}.
  12049. This is required so that
  12050. the system knows that mounting the file system depends on having the
  12051. corresponding device mapping established.
  12052. @item @code{flags} (default: @code{'()})
  12053. This is a list of symbols denoting mount flags. Recognized flags
  12054. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  12055. access to special files), @code{no-suid} (ignore setuid and setgid
  12056. bits), @code{no-atime} (do not update file access times),
  12057. @code{strict-atime} (update file access time), @code{lazy-time} (only
  12058. update time on the in-memory version of the file inode), and
  12059. @code{no-exec} (disallow program execution).
  12060. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  12061. Manual}, for more information on these flags.
  12062. @item @code{options} (default: @code{#f})
  12063. This is either @code{#f}, or a string denoting mount options passed to
  12064. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  12065. Library Reference Manual}, for details and run @command{man 8 mount} for
  12066. options for various file systems. Note that the
  12067. @code{file-system-options->alist} and @code{alist->file-system-options}
  12068. procedures from @code{(gnu system file-systems)} can be used to convert
  12069. file system options given as an association list to the string
  12070. representation, and vice-versa.
  12071. @item @code{mount?} (default: @code{#t})
  12072. This value indicates whether to automatically mount the file system when
  12073. the system is brought up. When set to @code{#f}, the file system gets
  12074. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  12075. is not automatically mounted.
  12076. @item @code{needed-for-boot?} (default: @code{#f})
  12077. This Boolean value indicates whether the file system is needed when
  12078. booting. If that is true, then the file system is mounted when the
  12079. initial RAM disk (initrd) is loaded. This is always the case, for
  12080. instance, for the root file system.
  12081. @item @code{check?} (default: @code{#t})
  12082. This Boolean indicates whether the file system should be checked for
  12083. errors before being mounted. How and when this happens can be further
  12084. adjusted with the following options.
  12085. @item @code{skip-check-if-clean?} (default: @code{#t})
  12086. When true, this Boolean indicates that a file system check triggered
  12087. by @code{check?} may exit early if the file system is marked as
  12088. ``clean'', meaning that it was previously correctly unmounted and
  12089. should not contain errors.
  12090. Setting this to false will always force a full consistency check when
  12091. @code{check?} is true. This may take a very long time and is not
  12092. recommended on healthy systems---in fact, it may reduce reliability!
  12093. Conversely, some primitive file systems like @code{fat} do not keep
  12094. track of clean shutdowns and will perform a full scan regardless of the
  12095. value of this option.
  12096. @item @code{repair} (default: @code{'preen})
  12097. When @code{check?} finds errors, it can (try to) repair them and
  12098. continue booting. This option controls when and how to do so.
  12099. If false, try not to modify the file system at all. Checking certain
  12100. file systems like @code{jfs} may still write to the device to replay
  12101. the journal. No repairs will be attempted.
  12102. If @code{#t}, try to repair any errors found and assume ``yes'' to
  12103. all questions. This will fix the most errors, but may be risky.
  12104. If @code{'preen}, repair only errors that are safe to fix without
  12105. human interaction. What that means is left up to the developers of
  12106. each file system and may be equivalent to ``none'' or ``all''.
  12107. @item @code{create-mount-point?} (default: @code{#f})
  12108. When true, the mount point is created if it does not exist yet.
  12109. @item @code{mount-may-fail?} (default: @code{#f})
  12110. When true, this indicates that mounting this file system can fail but
  12111. that should not be considered an error. This is useful in unusual
  12112. cases; an example of this is @code{efivarfs}, a file system that can
  12113. only be mounted on EFI/UEFI systems.
  12114. @item @code{dependencies} (default: @code{'()})
  12115. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  12116. representing file systems that must be mounted or mapped devices that
  12117. must be opened before (and unmounted or closed after) this one.
  12118. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  12119. a dependency of @file{/sys/fs/cgroup/cpu} and
  12120. @file{/sys/fs/cgroup/memory}.
  12121. Another example is a file system that depends on a mapped device, for
  12122. example for an encrypted partition (@pxref{Mapped Devices}).
  12123. @end table
  12124. @end deftp
  12125. @deffn {Scheme Procedure} file-system-label @var{str}
  12126. This procedure returns an opaque file system label from @var{str}, a
  12127. string:
  12128. @lisp
  12129. (file-system-label "home")
  12130. @result{} #<file-system-label "home">
  12131. @end lisp
  12132. File system labels are used to refer to file systems by label rather
  12133. than by device name. See above for examples.
  12134. @end deffn
  12135. The @code{(gnu system file-systems)} exports the following useful
  12136. variables.
  12137. @defvr {Scheme Variable} %base-file-systems
  12138. These are essential file systems that are required on normal systems,
  12139. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  12140. below). Operating system declarations should always contain at least
  12141. these.
  12142. @end defvr
  12143. @defvr {Scheme Variable} %pseudo-terminal-file-system
  12144. This is the file system to be mounted as @file{/dev/pts}. It supports
  12145. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  12146. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  12147. Manual}). Pseudo-terminals are used by terminal emulators such as
  12148. @command{xterm}.
  12149. @end defvr
  12150. @defvr {Scheme Variable} %shared-memory-file-system
  12151. This file system is mounted as @file{/dev/shm} and is used to support
  12152. memory sharing across processes (@pxref{Memory-mapped I/O,
  12153. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  12154. @end defvr
  12155. @defvr {Scheme Variable} %immutable-store
  12156. This file system performs a read-only ``bind mount'' of
  12157. @file{/gnu/store}, making it read-only for all the users including
  12158. @code{root}. This prevents against accidental modification by software
  12159. running as @code{root} or by system administrators.
  12160. The daemon itself is still able to write to the store: it remounts it
  12161. read-write in its own ``name space.''
  12162. @end defvr
  12163. @defvr {Scheme Variable} %binary-format-file-system
  12164. The @code{binfmt_misc} file system, which allows handling of arbitrary
  12165. executable file types to be delegated to user space. This requires the
  12166. @code{binfmt.ko} kernel module to be loaded.
  12167. @end defvr
  12168. @defvr {Scheme Variable} %fuse-control-file-system
  12169. The @code{fusectl} file system, which allows unprivileged users to mount
  12170. and unmount user-space FUSE file systems. This requires the
  12171. @code{fuse.ko} kernel module to be loaded.
  12172. @end defvr
  12173. The @code{(gnu system uuid)} module provides tools to deal with file
  12174. system ``unique identifiers'' (UUIDs).
  12175. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  12176. Return an opaque UUID (unique identifier) object of the given @var{type}
  12177. (a symbol) by parsing @var{str} (a string):
  12178. @lisp
  12179. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  12180. @result{} #<<uuid> type: dce bv: @dots{}>
  12181. (uuid "1234-ABCD" 'fat)
  12182. @result{} #<<uuid> type: fat bv: @dots{}>
  12183. @end lisp
  12184. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  12185. @code{ntfs}, or one of the commonly found synonyms for these.
  12186. UUIDs are another way to unambiguously refer to file systems in
  12187. operating system configuration. See the examples above.
  12188. @end deffn
  12189. @node Btrfs file system
  12190. @subsection Btrfs file system
  12191. The Btrfs has special features, such as subvolumes, that merit being
  12192. explained in more details. The following section attempts to cover
  12193. basic as well as complex uses of a Btrfs file system with the Guix
  12194. System.
  12195. In its simplest usage, a Btrfs file system can be described, for
  12196. example, by:
  12197. @lisp
  12198. (file-system
  12199. (mount-point "/home")
  12200. (type "btrfs")
  12201. (device (file-system-label "my-home")))
  12202. @end lisp
  12203. The example below is more complex, as it makes use of a Btrfs
  12204. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  12205. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  12206. dependency on @code{mapped-devices}):
  12207. @lisp
  12208. (file-system
  12209. (device (file-system-label "my-btrfs-pool"))
  12210. (mount-point "/")
  12211. (type "btrfs")
  12212. (options "subvol=rootfs")
  12213. (dependencies mapped-devices))
  12214. @end lisp
  12215. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  12216. top level during the early boot, and rely on their configuration to
  12217. refer to the correct subvolume path within that top level. The
  12218. bootloaders operating in this way typically produce their configuration
  12219. on a running system where the Btrfs partitions are already mounted and
  12220. where the subvolume information is readily available. As an example,
  12221. @command{grub-mkconfig}, the configuration generator command shipped
  12222. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  12223. path of a subvolume.
  12224. The Guix System produces a bootloader configuration using the operating
  12225. system configuration as its sole input; it is therefore necessary to
  12226. extract the subvolume name on which @file{/gnu/store} lives (if any)
  12227. from that operating system configuration. To better illustrate,
  12228. consider a subvolume named 'rootfs' which contains the root file system
  12229. data. In such situation, the GRUB bootloader would only see the top
  12230. level of the root Btrfs partition, e.g.:
  12231. @example
  12232. / (top level)
  12233. ├── rootfs (subvolume directory)
  12234. ├── gnu (normal directory)
  12235. ├── store (normal directory)
  12236. [...]
  12237. @end example
  12238. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  12239. of the kernel, initrd binaries and any other files referred to in the
  12240. GRUB configuration that must be found during the early boot.
  12241. The next example shows a nested hierarchy of subvolumes and
  12242. directories:
  12243. @example
  12244. / (top level)
  12245. ├── rootfs (subvolume)
  12246. ├── gnu (normal directory)
  12247. ├── store (subvolume)
  12248. [...]
  12249. @end example
  12250. This scenario would work without mounting the 'store' subvolume.
  12251. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  12252. intended mount point in the file system hierarchy. Alternatively, the
  12253. 'store' subvolume could be referred to by setting the @code{subvol}
  12254. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  12255. Finally, a more contrived example of nested subvolumes:
  12256. @example
  12257. / (top level)
  12258. ├── root-snapshots (subvolume)
  12259. ├── root-current (subvolume)
  12260. ├── guix-store (subvolume)
  12261. [...]
  12262. @end example
  12263. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  12264. so it is necessary to mount it. The subvolume must be fully specified,
  12265. by passing its file name to the @code{subvol} option. To illustrate,
  12266. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  12267. a file system declaration such as:
  12268. @lisp
  12269. (file-system
  12270. (device (file-system-label "btrfs-pool-1"))
  12271. (mount-point "/gnu/store")
  12272. (type "btrfs")
  12273. (options "subvol=root-snapshots/root-current/guix-store,\
  12274. compress-force=zstd,space_cache=v2"))
  12275. @end lisp
  12276. @node Mapped Devices
  12277. @section Mapped Devices
  12278. @cindex device mapping
  12279. @cindex mapped devices
  12280. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  12281. such as a hard disk partition, can be @dfn{mapped} into another device,
  12282. usually in @code{/dev/mapper/},
  12283. with additional processing over the data that flows through
  12284. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  12285. concept of a ``mapped device'' and that of a file system: both boil down
  12286. to @emph{translating} input/output operations made on a file to
  12287. operations on its backing store. Thus, the Hurd implements mapped
  12288. devices, like file systems, using the generic @dfn{translator} mechanism
  12289. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  12290. typical example is encryption device mapping: all writes to the mapped
  12291. device are encrypted, and all reads are deciphered, transparently.
  12292. Guix extends this notion by considering any device or set of devices that
  12293. are @dfn{transformed} in some way to create a new device; for instance,
  12294. RAID devices are obtained by @dfn{assembling} several other devices, such
  12295. as hard disks or partitions, into a new one that behaves as one partition.
  12296. Mapped devices are declared using the @code{mapped-device} form,
  12297. defined as follows; for examples, see below.
  12298. @deftp {Data Type} mapped-device
  12299. Objects of this type represent device mappings that will be made when
  12300. the system boots up.
  12301. @table @code
  12302. @item source
  12303. This is either a string specifying the name of the block device to be mapped,
  12304. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  12305. need to be assembled for creating a new one. In case of LVM this is a
  12306. string specifying name of the volume group to be mapped.
  12307. @item target
  12308. This string specifies the name of the resulting mapped device. For
  12309. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  12310. specifying @code{"my-partition"} leads to the creation of
  12311. the @code{"/dev/mapper/my-partition"} device.
  12312. For RAID devices of type @code{raid-device-mapping}, the full device name
  12313. such as @code{"/dev/md0"} needs to be given.
  12314. LVM logical volumes of type @code{lvm-device-mapping} need to
  12315. be specified as @code{"VGNAME-LVNAME"}.
  12316. @item targets
  12317. This list of strings specifies names of the resulting mapped devices in case
  12318. there are several. The format is identical to @var{target}.
  12319. @item type
  12320. This must be a @code{mapped-device-kind} object, which specifies how
  12321. @var{source} is mapped to @var{target}.
  12322. @end table
  12323. @end deftp
  12324. @defvr {Scheme Variable} luks-device-mapping
  12325. This defines LUKS block device encryption using the @command{cryptsetup}
  12326. command from the package with the same name. It relies on the
  12327. @code{dm-crypt} Linux kernel module.
  12328. @end defvr
  12329. @defvr {Scheme Variable} raid-device-mapping
  12330. This defines a RAID device, which is assembled using the @code{mdadm}
  12331. command from the package with the same name. It requires a Linux kernel
  12332. module for the appropriate RAID level to be loaded, such as @code{raid456}
  12333. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  12334. @end defvr
  12335. @cindex LVM, logical volume manager
  12336. @defvr {Scheme Variable} lvm-device-mapping
  12337. This defines one or more logical volumes for the Linux
  12338. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  12339. The volume group is activated by the @command{vgchange} command from the
  12340. @code{lvm2} package.
  12341. @end defvr
  12342. @cindex disk encryption
  12343. @cindex LUKS
  12344. The following example specifies a mapping from @file{/dev/sda3} to
  12345. @file{/dev/mapper/home} using LUKS---the
  12346. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  12347. standard mechanism for disk encryption.
  12348. The @file{/dev/mapper/home}
  12349. device can then be used as the @code{device} of a @code{file-system}
  12350. declaration (@pxref{File Systems}).
  12351. @lisp
  12352. (mapped-device
  12353. (source "/dev/sda3")
  12354. (target "home")
  12355. (type luks-device-mapping))
  12356. @end lisp
  12357. Alternatively, to become independent of device numbering, one may obtain
  12358. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  12359. command like:
  12360. @example
  12361. cryptsetup luksUUID /dev/sda3
  12362. @end example
  12363. and use it as follows:
  12364. @lisp
  12365. (mapped-device
  12366. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  12367. (target "home")
  12368. (type luks-device-mapping))
  12369. @end lisp
  12370. @cindex swap encryption
  12371. It is also desirable to encrypt swap space, since swap space may contain
  12372. sensitive data. One way to accomplish that is to use a swap file in a
  12373. file system on a device mapped via LUKS encryption. In this way, the
  12374. swap file is encrypted because the entire device is encrypted.
  12375. @xref{Swap Space}, or @xref{Preparing for Installation,,Disk
  12376. Partitioning}, for an example.
  12377. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  12378. may be declared as follows:
  12379. @lisp
  12380. (mapped-device
  12381. (source (list "/dev/sda1" "/dev/sdb1"))
  12382. (target "/dev/md0")
  12383. (type raid-device-mapping))
  12384. @end lisp
  12385. The @file{/dev/md0} device can then be used as the @code{device} of a
  12386. @code{file-system} declaration (@pxref{File Systems}).
  12387. Note that the RAID level need not be given; it is chosen during the
  12388. initial creation and formatting of the RAID device and is determined
  12389. automatically later.
  12390. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  12391. be declared as follows:
  12392. @lisp
  12393. (mapped-device
  12394. (source "vg0")
  12395. (targets (list "vg0-alpha" "vg0-beta"))
  12396. (type lvm-device-mapping))
  12397. @end lisp
  12398. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  12399. then be used as the @code{device} of a @code{file-system} declaration
  12400. (@pxref{File Systems}).
  12401. @node Swap Space
  12402. @section Swap Space
  12403. @cindex swap space
  12404. Swap space, as it is commonly called, is a disk area specifically
  12405. designated for paging: the process in charge of memory management
  12406. (the Linux kernel or Hurd's default pager) can decide that some memory
  12407. pages stored in RAM which belong to a running program but are unused
  12408. should be stored on disk instead. It unloads those from the RAM,
  12409. freeing up precious fast memory, and writes them to the swap space. If
  12410. the program tries to access that very page, the memory management
  12411. process loads it back into memory for the program to use.
  12412. A common misconception about swap is that it is only useful when small
  12413. amounts of RAM are available to the system. However, it should be noted
  12414. that kernels often use all available RAM for disk access caching to make
  12415. I/O faster, and thus paging out unused portions of program memory will
  12416. expand the RAM available for such caching.
  12417. For a more detailed description of how memory is managed from the
  12418. viewpoint of a monolithic kernel, @xref{Memory
  12419. Concepts,,, libc, The GNU C Library Reference Manual}.
  12420. The Linux kernel has support for swap partitions and swap files: the
  12421. former uses a whole disk partition for paging, whereas the second uses a
  12422. file on a file system for that (the file system driver needs to support
  12423. it). On a comparable setup, both have the same performance, so one
  12424. should consider ease of use when deciding between them. Partitions are
  12425. ``simpler'' and do not need file system support, but need to be
  12426. allocated at disk formatting time (logical volumes notwithstanding),
  12427. whereas files can be allocated and deallocated at any time.
  12428. Note that swap space is not zeroed on shutdown, so sensitive data (such
  12429. as passwords) may linger on it if it was paged out. As such, you should
  12430. consider having your swap reside on an encrypted device (@pxref{Mapped
  12431. Devices}).
  12432. @deftp {Data Type} swap-space
  12433. Objects of this type represent swap spaces. They contain the following
  12434. members:
  12435. @table @asis
  12436. @item @code{target}
  12437. The device or file to use, either a UUID, a @code{file-system-label} or
  12438. a string, as in the definition of a @code{file-system} (@pxref{File
  12439. Systems}).
  12440. @item @code{dependencies} (default: @code{'()})
  12441. A list of @code{file-system} or @code{mapped-device} objects, upon which
  12442. the availability of the space depends. Note that just like for
  12443. @code{file-system} objects, dependencies which are needed for boot and
  12444. mounted in early userspace are not managed by the Shepherd, and so
  12445. automatically filtered out for you.
  12446. @item @code{priority} (default: @code{#f})
  12447. Only supported by the Linux kernel. Either @code{#f} to disable swap
  12448. priority, or an integer between 0 and 32767. The kernel will first use
  12449. swap spaces of higher priority when paging, and use same priority spaces
  12450. on a round-robin basis. The kernel will use swap spaces without a set
  12451. priority after prioritized spaces, and in the order that they appeared in
  12452. (not round-robin).
  12453. @item @code{discard?} (default: @code{#f})
  12454. Only supported by the Linux kernel. When true, the kernel will notify
  12455. the disk controller of discarded pages, for example with the TRIM
  12456. operation on Solid State Drives.
  12457. @end table
  12458. @end deftp
  12459. Here are some examples:
  12460. @lisp
  12461. (swap-space (target (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  12462. @end lisp
  12463. Use the swap partition with the given UUID@. You can learn the UUID of a
  12464. Linux swap partition by running @command{swaplabel @var{device}}, where
  12465. @var{device} is the @file{/dev} file name of that partition.
  12466. @lisp
  12467. (swap-space
  12468. (target (file-system-label "swap"))
  12469. (dependencies (list lvm-device)))
  12470. @end lisp
  12471. Use the partition with label @code{swap}, which can be found after the
  12472. @var{lvm-device} mapped device has been opened. Again, the
  12473. @command{swaplabel} command allows you to view and change the label of a
  12474. Linux swap partition.
  12475. @lisp
  12476. (swap-space
  12477. (target "/btrfs/swapfile")
  12478. (dependencies (list btrfs-fs)))
  12479. @end lisp
  12480. Use the file @file{/btrfs/swapfile} as swap space, which is present on the
  12481. @var{btrfs-fs} filesystem.
  12482. @node User Accounts
  12483. @section User Accounts
  12484. @cindex users
  12485. @cindex accounts
  12486. @cindex user accounts
  12487. User accounts and groups are entirely managed through the
  12488. @code{operating-system} declaration. They are specified with the
  12489. @code{user-account} and @code{user-group} forms:
  12490. @lisp
  12491. (user-account
  12492. (name "alice")
  12493. (group "users")
  12494. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  12495. "audio" ;sound card
  12496. "video" ;video devices such as webcams
  12497. "cdrom")) ;the good ol' CD-ROM
  12498. (comment "Bob's sister"))
  12499. @end lisp
  12500. Here's a user account that uses a different shell and a custom home
  12501. directory (the default would be @file{"/home/bob"}):
  12502. @lisp
  12503. (user-account
  12504. (name "bob")
  12505. (group "users")
  12506. (comment "Alice's bro")
  12507. (shell (file-append zsh "/bin/zsh"))
  12508. (home-directory "/home/robert"))
  12509. @end lisp
  12510. When booting or upon completion of @command{guix system reconfigure},
  12511. the system ensures that only the user accounts and groups specified in
  12512. the @code{operating-system} declaration exist, and with the specified
  12513. properties. Thus, account or group creations or modifications made by
  12514. directly invoking commands such as @command{useradd} are lost upon
  12515. reconfiguration or reboot. This ensures that the system remains exactly
  12516. as declared.
  12517. @deftp {Data Type} user-account
  12518. Objects of this type represent user accounts. The following members may
  12519. be specified:
  12520. @table @asis
  12521. @item @code{name}
  12522. The name of the user account.
  12523. @item @code{group}
  12524. @cindex groups
  12525. This is the name (a string) or identifier (a number) of the user group
  12526. this account belongs to.
  12527. @item @code{supplementary-groups} (default: @code{'()})
  12528. Optionally, this can be defined as a list of group names that this
  12529. account belongs to.
  12530. @item @code{uid} (default: @code{#f})
  12531. This is the user ID for this account (a number), or @code{#f}. In the
  12532. latter case, a number is automatically chosen by the system when the
  12533. account is created.
  12534. @item @code{comment} (default: @code{""})
  12535. A comment about the account, such as the account owner's full name.
  12536. Note that, for non-system accounts, users are free to change their real
  12537. name as it appears in @file{/etc/passwd} using the @command{chfn}
  12538. command. When they do, their choice prevails over the system
  12539. administrator's choice; reconfiguring does @emph{not} change their name.
  12540. @item @code{home-directory}
  12541. This is the name of the home directory for the account.
  12542. @item @code{create-home-directory?} (default: @code{#t})
  12543. Indicates whether the home directory of this account should be created
  12544. if it does not exist yet.
  12545. @item @code{shell} (default: Bash)
  12546. This is a G-expression denoting the file name of a program to be used as
  12547. the shell (@pxref{G-Expressions}). For example, you would refer to the
  12548. Bash executable like this:
  12549. @lisp
  12550. (file-append bash "/bin/bash")
  12551. @end lisp
  12552. @noindent
  12553. ... and to the Zsh executable like that:
  12554. @lisp
  12555. (file-append zsh "/bin/zsh")
  12556. @end lisp
  12557. @item @code{system?} (default: @code{#f})
  12558. This Boolean value indicates whether the account is a ``system''
  12559. account. System accounts are sometimes treated specially; for instance,
  12560. graphical login managers do not list them.
  12561. @anchor{user-account-password}
  12562. @cindex password, for user accounts
  12563. @item @code{password} (default: @code{#f})
  12564. You would normally leave this field to @code{#f}, initialize user
  12565. passwords as @code{root} with the @command{passwd} command, and then let
  12566. users change it with @command{passwd}. Passwords set with
  12567. @command{passwd} are of course preserved across reboot and
  12568. reconfiguration.
  12569. If you @emph{do} want to set an initial password for an account, then
  12570. this field must contain the encrypted password, as a string. You can use the
  12571. @code{crypt} procedure for this purpose:
  12572. @lisp
  12573. (user-account
  12574. (name "charlie")
  12575. (group "users")
  12576. ;; Specify a SHA-512-hashed initial password.
  12577. (password (crypt "InitialPassword!" "$6$abc")))
  12578. @end lisp
  12579. @quotation Note
  12580. The hash of this initial password will be available in a file in
  12581. @file{/gnu/store}, readable by all the users, so this method must be used with
  12582. care.
  12583. @end quotation
  12584. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  12585. more information on password encryption, and @ref{Encryption,,, guile, GNU
  12586. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  12587. @end table
  12588. @end deftp
  12589. @cindex groups
  12590. User group declarations are even simpler:
  12591. @lisp
  12592. (user-group (name "students"))
  12593. @end lisp
  12594. @deftp {Data Type} user-group
  12595. This type is for, well, user groups. There are just a few fields:
  12596. @table @asis
  12597. @item @code{name}
  12598. The name of the group.
  12599. @item @code{id} (default: @code{#f})
  12600. The group identifier (a number). If @code{#f}, a new number is
  12601. automatically allocated when the group is created.
  12602. @item @code{system?} (default: @code{#f})
  12603. This Boolean value indicates whether the group is a ``system'' group.
  12604. System groups have low numerical IDs.
  12605. @item @code{password} (default: @code{#f})
  12606. What, user groups can have a password? Well, apparently yes. Unless
  12607. @code{#f}, this field specifies the password of the group.
  12608. @end table
  12609. @end deftp
  12610. For convenience, a variable lists all the basic user groups one may
  12611. expect:
  12612. @defvr {Scheme Variable} %base-groups
  12613. This is the list of basic user groups that users and/or packages expect
  12614. to be present on the system. This includes groups such as ``root'',
  12615. ``wheel'', and ``users'', as well as groups used to control access to
  12616. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  12617. @end defvr
  12618. @defvr {Scheme Variable} %base-user-accounts
  12619. This is the list of basic system accounts that programs may expect to
  12620. find on a GNU/Linux system, such as the ``nobody'' account.
  12621. Note that the ``root'' account is not included here. It is a
  12622. special-case and is automatically added whether or not it is specified.
  12623. @end defvr
  12624. @node Keyboard Layout
  12625. @section Keyboard Layout
  12626. @cindex keyboard layout
  12627. @cindex keymap
  12628. To specify what each key of your keyboard does, you need to tell the operating
  12629. system what @dfn{keyboard layout} you want to use. The default, when nothing
  12630. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  12631. However, German speakers will usually prefer the German QWERTZ layout, French
  12632. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  12633. or bépo, and they might even want to further customize the effect of some of
  12634. the keys. This section explains how to get that done.
  12635. @cindex keyboard layout, definition
  12636. There are three components that will want to know about your keyboard layout:
  12637. @itemize
  12638. @item
  12639. The @emph{bootloader} may want to know what keyboard layout you want to use
  12640. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  12641. you want, for instance, to make sure that you can type the passphrase of your
  12642. encrypted root partition using the right layout.
  12643. @item
  12644. The @emph{operating system kernel}, Linux, will need that so that the console
  12645. is properly configured (@pxref{operating-system Reference,
  12646. @code{keyboard-layout}}).
  12647. @item
  12648. The @emph{graphical display server}, usually Xorg, also has its own idea of
  12649. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  12650. @end itemize
  12651. Guix allows you to configure all three separately but, fortunately, it allows
  12652. you to share the same keyboard layout for all three components.
  12653. @cindex XKB, keyboard layouts
  12654. Keyboard layouts are represented by records created by the
  12655. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  12656. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  12657. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  12658. optional variant name, an optional keyboard model name, and a possibly empty
  12659. list of additional options. In most cases the layout name is all you care
  12660. about.
  12661. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  12662. [#:model] [#:options '()]
  12663. Return a new keyboard layout with the given @var{name} and @var{variant}.
  12664. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  12665. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  12666. @code{xkeyboard-config} package for valid options.
  12667. @end deffn
  12668. Here are a few examples:
  12669. @lisp
  12670. ;; The German QWERTZ layout. Here we assume a standard
  12671. ;; "pc105" keyboard model.
  12672. (keyboard-layout "de")
  12673. ;; The bépo variant of the French layout.
  12674. (keyboard-layout "fr" "bepo")
  12675. ;; The Catalan layout.
  12676. (keyboard-layout "es" "cat")
  12677. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  12678. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  12679. ;; The Latin American Spanish layout. In addition, the
  12680. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  12681. ;; and the "Menu" key is used as a "Compose" key to enter
  12682. ;; accented letters.
  12683. (keyboard-layout "latam"
  12684. #:options '("ctrl:nocaps" "compose:menu"))
  12685. ;; The Russian layout for a ThinkPad keyboard.
  12686. (keyboard-layout "ru" #:model "thinkpad")
  12687. ;; The "US international" layout, which is the US layout plus
  12688. ;; dead keys to enter accented characters. This is for an
  12689. ;; Apple MacBook keyboard.
  12690. (keyboard-layout "us" "intl" #:model "macbook78")
  12691. @end lisp
  12692. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  12693. for a complete list of supported layouts, variants, and models.
  12694. @cindex keyboard layout, configuration
  12695. Let's say you want your system to use the Turkish keyboard layout throughout
  12696. your system---bootloader, console, and Xorg. Here's what your system
  12697. configuration would look like:
  12698. @findex set-xorg-configuration
  12699. @lisp
  12700. ;; Using the Turkish layout for the bootloader, the console,
  12701. ;; and for Xorg.
  12702. (operating-system
  12703. ;; ...
  12704. (keyboard-layout (keyboard-layout "tr")) ;for the console
  12705. (bootloader (bootloader-configuration
  12706. (bootloader grub-efi-bootloader)
  12707. (targets '("/boot/efi"))
  12708. (keyboard-layout keyboard-layout))) ;for GRUB
  12709. (services (cons (set-xorg-configuration
  12710. (xorg-configuration ;for Xorg
  12711. (keyboard-layout keyboard-layout)))
  12712. %desktop-services)))
  12713. @end lisp
  12714. In the example above, for GRUB and for Xorg, we just refer to the
  12715. @code{keyboard-layout} field defined above, but we could just as well refer to
  12716. a different layout. The @code{set-xorg-configuration} procedure communicates
  12717. the desired Xorg configuration to the graphical log-in manager, by default
  12718. GDM.
  12719. We've discussed how to specify the @emph{default} keyboard layout of your
  12720. system when it starts, but you can also adjust it at run time:
  12721. @itemize
  12722. @item
  12723. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  12724. where you can select one or more keyboard layouts.
  12725. @item
  12726. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  12727. allows you to change the current layout. For example, this is how you would
  12728. change the layout to US Dvorak:
  12729. @example
  12730. setxkbmap us dvorak
  12731. @end example
  12732. @item
  12733. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  12734. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  12735. keyboard layout categorization described above. The command below loads the
  12736. French bépo layout:
  12737. @example
  12738. loadkeys fr-bepo
  12739. @end example
  12740. @end itemize
  12741. @node Locales
  12742. @section Locales
  12743. @cindex locale
  12744. A @dfn{locale} defines cultural conventions for a particular language
  12745. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  12746. Reference Manual}). Each locale has a name that typically has the form
  12747. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  12748. @code{fr_LU.utf8} designates the locale for the French language, with
  12749. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  12750. @cindex locale definition
  12751. Usually, you will want to specify the default locale for the machine
  12752. using the @code{locale} field of the @code{operating-system} declaration
  12753. (@pxref{operating-system Reference, @code{locale}}).
  12754. The selected locale is automatically added to the @dfn{locale
  12755. definitions} known to the system if needed, with its codeset inferred
  12756. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  12757. @code{UTF-8} codeset. Additional locale definitions can be specified in
  12758. the @code{locale-definitions} slot of @code{operating-system}---this is
  12759. useful, for instance, if the codeset could not be inferred from the
  12760. locale name. The default set of locale definitions includes some widely
  12761. used locales, but not all the available locales, in order to save space.
  12762. For instance, to add the North Frisian locale for Germany, the value of
  12763. that field may be:
  12764. @lisp
  12765. (cons (locale-definition
  12766. (name "fy_DE.utf8") (source "fy_DE"))
  12767. %default-locale-definitions)
  12768. @end lisp
  12769. Likewise, to save space, one might want @code{locale-definitions} to
  12770. list only the locales that are actually used, as in:
  12771. @lisp
  12772. (list (locale-definition
  12773. (name "ja_JP.eucjp") (source "ja_JP")
  12774. (charset "EUC-JP")))
  12775. @end lisp
  12776. @vindex LOCPATH
  12777. The compiled locale definitions are available at
  12778. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  12779. version, which is the default location where the GNU@tie{}libc provided
  12780. by Guix looks for locale data. This can be overridden using the
  12781. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  12782. @env{LOCPATH} and locale packages}).
  12783. The @code{locale-definition} form is provided by the @code{(gnu system
  12784. locale)} module. Details are given below.
  12785. @deftp {Data Type} locale-definition
  12786. This is the data type of a locale definition.
  12787. @table @asis
  12788. @item @code{name}
  12789. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  12790. Reference Manual}, for more information on locale names.
  12791. @item @code{source}
  12792. The name of the source for that locale. This is typically the
  12793. @code{@var{language}_@var{territory}} part of the locale name.
  12794. @item @code{charset} (default: @code{"UTF-8"})
  12795. The ``character set'' or ``code set'' for that locale,
  12796. @uref{https://www.iana.org/assignments/character-sets, as defined by
  12797. IANA}.
  12798. @end table
  12799. @end deftp
  12800. @defvr {Scheme Variable} %default-locale-definitions
  12801. A list of commonly used UTF-8 locales, used as the default
  12802. value of the @code{locale-definitions} field of @code{operating-system}
  12803. declarations.
  12804. @cindex locale name
  12805. @cindex normalized codeset in locale names
  12806. These locale definitions use the @dfn{normalized codeset} for the part
  12807. that follows the dot in the name (@pxref{Using gettextized software,
  12808. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  12809. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  12810. @code{uk_UA.UTF-8}.
  12811. @end defvr
  12812. @subsection Locale Data Compatibility Considerations
  12813. @cindex incompatibility, of locale data
  12814. @code{operating-system} declarations provide a @code{locale-libcs} field
  12815. to specify the GNU@tie{}libc packages that are used to compile locale
  12816. declarations (@pxref{operating-system Reference}). ``Why would I
  12817. care?'', you may ask. Well, it turns out that the binary format of
  12818. locale data is occasionally incompatible from one libc version to
  12819. another.
  12820. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  12821. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  12822. For instance, a program linked against libc version 2.21 is unable to
  12823. read locale data produced with libc 2.22; worse, that program
  12824. @emph{aborts} instead of simply ignoring the incompatible locale
  12825. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  12826. the incompatible locale data, which is already an improvement.}.
  12827. Similarly, a program linked against libc 2.22 can read most, but not
  12828. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  12829. data is incompatible); thus calls to @code{setlocale} may fail, but
  12830. programs will not abort.
  12831. The ``problem'' with Guix is that users have a lot of freedom: They can
  12832. choose whether and when to upgrade software in their profiles, and might
  12833. be using a libc version different from the one the system administrator
  12834. used to build the system-wide locale data.
  12835. Fortunately, unprivileged users can also install their own locale data
  12836. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  12837. @env{GUIX_LOCPATH} and locale packages}).
  12838. Still, it is best if the system-wide locale data at
  12839. @file{/run/current-system/locale} is built for all the libc versions
  12840. actually in use on the system, so that all the programs can access
  12841. it---this is especially crucial on a multi-user system. To do that, the
  12842. administrator can specify several libc packages in the
  12843. @code{locale-libcs} field of @code{operating-system}:
  12844. @lisp
  12845. (use-package-modules base)
  12846. (operating-system
  12847. ;; @dots{}
  12848. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  12849. @end lisp
  12850. This example would lead to a system containing locale definitions for
  12851. both libc 2.21 and the current version of libc in
  12852. @file{/run/current-system/locale}.
  12853. @node Services
  12854. @section Services
  12855. @cindex system services
  12856. An important part of preparing an @code{operating-system} declaration is
  12857. listing @dfn{system services} and their configuration (@pxref{Using the
  12858. Configuration System}). System services are typically daemons launched
  12859. when the system boots, or other actions needed at that time---e.g.,
  12860. configuring network access.
  12861. Guix has a broad definition of ``service'' (@pxref{Service
  12862. Composition}), but many services are managed by the GNU@tie{}Shepherd
  12863. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  12864. command allows you to list the available services, show their status,
  12865. start and stop them, or do other specific operations (@pxref{Jump
  12866. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  12867. @example
  12868. # herd status
  12869. @end example
  12870. The above command, run as @code{root}, lists the currently defined
  12871. services. The @command{herd doc} command shows a synopsis of the given
  12872. service and its associated actions:
  12873. @example
  12874. # herd doc nscd
  12875. Run libc's name service cache daemon (nscd).
  12876. # herd doc nscd action invalidate
  12877. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  12878. @end example
  12879. The @command{start}, @command{stop}, and @command{restart} sub-commands
  12880. have the effect you would expect. For instance, the commands below stop
  12881. the nscd service and restart the Xorg display server:
  12882. @example
  12883. # herd stop nscd
  12884. Service nscd has been stopped.
  12885. # herd restart xorg-server
  12886. Service xorg-server has been stopped.
  12887. Service xorg-server has been started.
  12888. @end example
  12889. The following sections document the available services, starting with
  12890. the core services, that may be used in an @code{operating-system}
  12891. declaration.
  12892. @menu
  12893. * Base Services:: Essential system services.
  12894. * Scheduled Job Execution:: The mcron service.
  12895. * Log Rotation:: The rottlog service.
  12896. * Networking Setup:: Setting up network interfaces.
  12897. * Networking Services:: Firewall, SSH daemon, etc.
  12898. * Unattended Upgrades:: Automated system upgrades.
  12899. * X Window:: Graphical display.
  12900. * Printing Services:: Local and remote printer support.
  12901. * Desktop Services:: D-Bus and desktop services.
  12902. * Sound Services:: ALSA and Pulseaudio services.
  12903. * Database Services:: SQL databases, key-value stores, etc.
  12904. * Mail Services:: IMAP, POP3, SMTP, and all that.
  12905. * Messaging Services:: Messaging services.
  12906. * Telephony Services:: Telephony services.
  12907. * File-Sharing Services:: File-sharing services.
  12908. * Monitoring Services:: Monitoring services.
  12909. * Kerberos Services:: Kerberos services.
  12910. * LDAP Services:: LDAP services.
  12911. * Web Services:: Web servers.
  12912. * Certificate Services:: TLS certificates via Let's Encrypt.
  12913. * DNS Services:: DNS daemons.
  12914. * VPN Services:: VPN daemons.
  12915. * Network File System:: NFS related services.
  12916. * Continuous Integration:: Cuirass and Laminar services.
  12917. * Power Management Services:: Extending battery life.
  12918. * Audio Services:: The MPD.
  12919. * Virtualization Services:: Virtualization services.
  12920. * Version Control Services:: Providing remote access to Git repositories.
  12921. * Game Services:: Game servers.
  12922. * PAM Mount Service:: Service to mount volumes when logging in.
  12923. * Guix Services:: Services relating specifically to Guix.
  12924. * Linux Services:: Services tied to the Linux kernel.
  12925. * Hurd Services:: Services specific for a Hurd System.
  12926. * Miscellaneous Services:: Other services.
  12927. @end menu
  12928. @node Base Services
  12929. @subsection Base Services
  12930. The @code{(gnu services base)} module provides definitions for the basic
  12931. services that one expects from the system. The services exported by
  12932. this module are listed below.
  12933. @defvr {Scheme Variable} %base-services
  12934. This variable contains a list of basic services (@pxref{Service Types
  12935. and Services}, for more information on service objects) one would
  12936. expect from the system: a login service (mingetty) on each tty, syslogd,
  12937. the libc name service cache daemon (nscd), the udev device manager, and
  12938. more.
  12939. This is the default value of the @code{services} field of
  12940. @code{operating-system} declarations. Usually, when customizing a
  12941. system, you will want to append services to @code{%base-services}, like
  12942. this:
  12943. @lisp
  12944. (append (list (service avahi-service-type)
  12945. (service openssh-service-type))
  12946. %base-services)
  12947. @end lisp
  12948. @end defvr
  12949. @defvr {Scheme Variable} special-files-service-type
  12950. This is the service that sets up ``special files'' such as
  12951. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  12952. The value associated with @code{special-files-service-type} services
  12953. must be a list of tuples where the first element is the ``special file''
  12954. and the second element is its target. By default it is:
  12955. @cindex @file{/bin/sh}
  12956. @cindex @file{sh}, in @file{/bin}
  12957. @lisp
  12958. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  12959. @end lisp
  12960. @cindex @file{/usr/bin/env}
  12961. @cindex @file{env}, in @file{/usr/bin}
  12962. If you want to add, say, @code{/usr/bin/env} to your system, you can
  12963. change it to:
  12964. @lisp
  12965. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  12966. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  12967. @end lisp
  12968. Since this is part of @code{%base-services}, you can use
  12969. @code{modify-services} to customize the set of special files
  12970. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  12971. to add a special file is @i{via} the @code{extra-special-file} procedure
  12972. (see below).
  12973. @end defvr
  12974. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  12975. Use @var{target} as the ``special file'' @var{file}.
  12976. For example, adding the following lines to the @code{services} field of
  12977. your operating system declaration leads to a @file{/usr/bin/env}
  12978. symlink:
  12979. @lisp
  12980. (extra-special-file "/usr/bin/env"
  12981. (file-append coreutils "/bin/env"))
  12982. @end lisp
  12983. @end deffn
  12984. @deffn {Scheme Procedure} host-name-service @var{name}
  12985. Return a service that sets the host name to @var{name}.
  12986. @end deffn
  12987. @defvr {Scheme Variable} console-font-service-type
  12988. Install the given fonts on the specified ttys (fonts are per
  12989. virtual console on the kernel Linux). The value of this service is a list of
  12990. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  12991. package or any valid argument to @command{setfont}, as in this example:
  12992. @lisp
  12993. `(("tty1" . "LatGrkCyr-8x16")
  12994. ("tty2" . ,(file-append
  12995. font-tamzen
  12996. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  12997. ("tty3" . ,(file-append
  12998. font-terminus
  12999. "/share/consolefonts/ter-132n"))) ; for HDPI
  13000. @end lisp
  13001. @end defvr
  13002. @deffn {Scheme Procedure} login-service @var{config}
  13003. Return a service to run login according to @var{config}, a
  13004. @code{<login-configuration>} object, which specifies the message of the day,
  13005. among other things.
  13006. @end deffn
  13007. @deftp {Data Type} login-configuration
  13008. This is the data type representing the configuration of login.
  13009. @table @asis
  13010. @item @code{motd}
  13011. @cindex message of the day
  13012. A file-like object containing the ``message of the day''.
  13013. @item @code{allow-empty-passwords?} (default: @code{#t})
  13014. Allow empty passwords by default so that first-time users can log in when
  13015. the 'root' account has just been created.
  13016. @end table
  13017. @end deftp
  13018. @deffn {Scheme Procedure} mingetty-service @var{config}
  13019. Return a service to run mingetty according to @var{config}, a
  13020. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  13021. other things.
  13022. @end deffn
  13023. @deftp {Data Type} mingetty-configuration
  13024. This is the data type representing the configuration of Mingetty, which
  13025. provides the default implementation of virtual console log-in.
  13026. @table @asis
  13027. @item @code{tty}
  13028. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  13029. @item @code{auto-login} (default: @code{#f})
  13030. When true, this field must be a string denoting the user name under
  13031. which the system automatically logs in. When it is @code{#f}, a
  13032. user name and password must be entered to log in.
  13033. @item @code{login-program} (default: @code{#f})
  13034. This must be either @code{#f}, in which case the default log-in program
  13035. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  13036. the name of the log-in program.
  13037. @item @code{login-pause?} (default: @code{#f})
  13038. When set to @code{#t} in conjunction with @var{auto-login}, the user
  13039. will have to press a key before the log-in shell is launched.
  13040. @item @code{clear-on-logout?} (default: @code{#t})
  13041. When set to @code{#t}, the screen will be cleared after logout.
  13042. @item @code{mingetty} (default: @var{mingetty})
  13043. The Mingetty package to use.
  13044. @end table
  13045. @end deftp
  13046. @deffn {Scheme Procedure} agetty-service @var{config}
  13047. Return a service to run agetty according to @var{config}, an
  13048. @code{<agetty-configuration>} object, which specifies the tty to run,
  13049. among other things.
  13050. @end deffn
  13051. @deftp {Data Type} agetty-configuration
  13052. This is the data type representing the configuration of agetty, which
  13053. implements virtual and serial console log-in. See the @code{agetty(8)}
  13054. man page for more information.
  13055. @table @asis
  13056. @item @code{tty}
  13057. The name of the console this agetty runs on, as a string---e.g.,
  13058. @code{"ttyS0"}. This argument is optional, it will default to
  13059. a reasonable default serial port used by the kernel Linux.
  13060. For this, if there is a value for an option @code{agetty.tty} in the kernel
  13061. command line, agetty will extract the device name of the serial port
  13062. from it and use that.
  13063. If not and if there is a value for an option @code{console} with a tty in
  13064. the Linux command line, agetty will extract the device name of the
  13065. serial port from it and use that.
  13066. In both cases, agetty will leave the other serial device settings
  13067. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  13068. correct values.
  13069. @item @code{baud-rate} (default: @code{#f})
  13070. A string containing a comma-separated list of one or more baud rates, in
  13071. descending order.
  13072. @item @code{term} (default: @code{#f})
  13073. A string containing the value used for the @env{TERM} environment
  13074. variable.
  13075. @item @code{eight-bits?} (default: @code{#f})
  13076. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  13077. disabled.
  13078. @item @code{auto-login} (default: @code{#f})
  13079. When passed a login name, as a string, the specified user will be logged
  13080. in automatically without prompting for their login name or password.
  13081. @item @code{no-reset?} (default: @code{#f})
  13082. When @code{#t}, don't reset terminal cflags (control modes).
  13083. @item @code{host} (default: @code{#f})
  13084. This accepts a string containing the ``login_host'', which will be written
  13085. into the @file{/var/run/utmpx} file.
  13086. @item @code{remote?} (default: @code{#f})
  13087. When set to @code{#t} in conjunction with @var{host}, this will add an
  13088. @code{-r} fakehost option to the command line of the login program
  13089. specified in @var{login-program}.
  13090. @item @code{flow-control?} (default: @code{#f})
  13091. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  13092. @item @code{no-issue?} (default: @code{#f})
  13093. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  13094. not be displayed before presenting the login prompt.
  13095. @item @code{init-string} (default: @code{#f})
  13096. This accepts a string that will be sent to the tty or modem before
  13097. sending anything else. It can be used to initialize a modem.
  13098. @item @code{no-clear?} (default: @code{#f})
  13099. When set to @code{#t}, agetty will not clear the screen before showing
  13100. the login prompt.
  13101. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  13102. This must be either a gexp denoting the name of a log-in program, or
  13103. unset, in which case the default value is the @command{login} from the
  13104. Shadow tool suite.
  13105. @item @code{local-line} (default: @code{#f})
  13106. Control the CLOCAL line flag. This accepts one of three symbols as
  13107. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  13108. the default value chosen by agetty is @code{'auto}.
  13109. @item @code{extract-baud?} (default: @code{#f})
  13110. When set to @code{#t}, instruct agetty to try to extract the baud rate
  13111. from the status messages produced by certain types of modems.
  13112. @item @code{skip-login?} (default: @code{#f})
  13113. When set to @code{#t}, do not prompt the user for a login name. This
  13114. can be used with @var{login-program} field to use non-standard login
  13115. systems.
  13116. @item @code{no-newline?} (default: @code{#f})
  13117. When set to @code{#t}, do not print a newline before printing the
  13118. @file{/etc/issue} file.
  13119. @c Is this dangerous only when used with login-program, or always?
  13120. @item @code{login-options} (default: @code{#f})
  13121. This option accepts a string containing options that are passed to the
  13122. login program. When used with the @var{login-program}, be aware that a
  13123. malicious user could try to enter a login name containing embedded
  13124. options that could be parsed by the login program.
  13125. @item @code{login-pause} (default: @code{#f})
  13126. When set to @code{#t}, wait for any key before showing the login prompt.
  13127. This can be used in conjunction with @var{auto-login} to save memory by
  13128. lazily spawning shells.
  13129. @item @code{chroot} (default: @code{#f})
  13130. Change root to the specified directory. This option accepts a directory
  13131. path as a string.
  13132. @item @code{hangup?} (default: @code{#f})
  13133. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  13134. specified terminal.
  13135. @item @code{keep-baud?} (default: @code{#f})
  13136. When set to @code{#t}, try to keep the existing baud rate. The baud
  13137. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  13138. character.
  13139. @item @code{timeout} (default: @code{#f})
  13140. When set to an integer value, terminate if no user name could be read
  13141. within @var{timeout} seconds.
  13142. @item @code{detect-case?} (default: @code{#f})
  13143. When set to @code{#t}, turn on support for detecting an uppercase-only
  13144. terminal. This setting will detect a login name containing only
  13145. uppercase letters as indicating an uppercase-only terminal and turn on
  13146. some upper-to-lower case conversions. Note that this will not support
  13147. Unicode characters.
  13148. @item @code{wait-cr?} (default: @code{#f})
  13149. When set to @code{#t}, wait for the user or modem to send a
  13150. carriage-return or linefeed character before displaying
  13151. @file{/etc/issue} or login prompt. This is typically used with the
  13152. @var{init-string} option.
  13153. @item @code{no-hints?} (default: @code{#f})
  13154. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  13155. locks.
  13156. @item @code{no-hostname?} (default: @code{#f})
  13157. By default, the hostname is printed. When this option is set to
  13158. @code{#t}, no hostname will be shown at all.
  13159. @item @code{long-hostname?} (default: @code{#f})
  13160. By default, the hostname is only printed until the first dot. When this
  13161. option is set to @code{#t}, the fully qualified hostname by
  13162. @code{gethostname} or @code{getaddrinfo} is shown.
  13163. @item @code{erase-characters} (default: @code{#f})
  13164. This option accepts a string of additional characters that should be
  13165. interpreted as backspace when the user types their login name.
  13166. @item @code{kill-characters} (default: @code{#f})
  13167. This option accepts a string that should be interpreted to mean ``ignore
  13168. all previous characters'' (also called a ``kill'' character) when the user
  13169. types their login name.
  13170. @item @code{chdir} (default: @code{#f})
  13171. This option accepts, as a string, a directory path that will be changed
  13172. to before login.
  13173. @item @code{delay} (default: @code{#f})
  13174. This options accepts, as an integer, the number of seconds to sleep
  13175. before opening the tty and displaying the login prompt.
  13176. @item @code{nice} (default: @code{#f})
  13177. This option accepts, as an integer, the nice value with which to run the
  13178. @command{login} program.
  13179. @item @code{extra-options} (default: @code{'()})
  13180. This option provides an ``escape hatch'' for the user to provide arbitrary
  13181. command-line arguments to @command{agetty} as a list of strings.
  13182. @end table
  13183. @end deftp
  13184. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  13185. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  13186. according to @var{config}, a @code{<kmscon-configuration>} object, which
  13187. specifies the tty to run, among other things.
  13188. @end deffn
  13189. @deftp {Data Type} kmscon-configuration
  13190. This is the data type representing the configuration of Kmscon, which
  13191. implements virtual console log-in.
  13192. @table @asis
  13193. @item @code{virtual-terminal}
  13194. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  13195. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  13196. A gexp denoting the name of the log-in program. The default log-in program is
  13197. @command{login} from the Shadow tool suite.
  13198. @item @code{login-arguments} (default: @code{'("-p")})
  13199. A list of arguments to pass to @command{login}.
  13200. @item @code{auto-login} (default: @code{#f})
  13201. When passed a login name, as a string, the specified user will be logged
  13202. in automatically without prompting for their login name or password.
  13203. @item @code{hardware-acceleration?} (default: #f)
  13204. Whether to use hardware acceleration.
  13205. @item @code{font-engine} (default: @code{"pango"})
  13206. Font engine used in Kmscon.
  13207. @item @code{font-size} (default: @code{12})
  13208. Font size used in Kmscon.
  13209. @item @code{keyboard-layout} (default: @code{#f})
  13210. If this is @code{#f}, Kmscon uses the default keyboard layout---usually US
  13211. English (``qwerty'') for a 105-key PC keyboard.
  13212. Otherwise this must be a @code{keyboard-layout} object specifying the
  13213. keyboard layout. @xref{Keyboard Layout}, for more information on how to
  13214. specify the keyboard layout.
  13215. @item @code{kmscon} (default: @var{kmscon})
  13216. The Kmscon package to use.
  13217. @end table
  13218. @end deftp
  13219. @cindex name service cache daemon
  13220. @cindex nscd
  13221. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  13222. [#:name-services '()]
  13223. Return a service that runs the libc name service cache daemon (nscd) with the
  13224. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  13225. Service Switch}, for an example.
  13226. For convenience, the Shepherd service for nscd provides the following actions:
  13227. @table @code
  13228. @item invalidate
  13229. @cindex cache invalidation, nscd
  13230. @cindex nscd, cache invalidation
  13231. This invalidate the given cache. For instance, running:
  13232. @example
  13233. herd invalidate nscd hosts
  13234. @end example
  13235. @noindent
  13236. invalidates the host name lookup cache of nscd.
  13237. @item statistics
  13238. Running @command{herd statistics nscd} displays information about nscd usage
  13239. and caches.
  13240. @end table
  13241. @end deffn
  13242. @defvr {Scheme Variable} %nscd-default-configuration
  13243. This is the default @code{<nscd-configuration>} value (see below) used
  13244. by @code{nscd-service}. It uses the caches defined by
  13245. @code{%nscd-default-caches}; see below.
  13246. @end defvr
  13247. @deftp {Data Type} nscd-configuration
  13248. This is the data type representing the name service cache daemon (nscd)
  13249. configuration.
  13250. @table @asis
  13251. @item @code{name-services} (default: @code{'()})
  13252. List of packages denoting @dfn{name services} that must be visible to
  13253. the nscd---e.g., @code{(list @var{nss-mdns})}.
  13254. @item @code{glibc} (default: @var{glibc})
  13255. Package object denoting the GNU C Library providing the @command{nscd}
  13256. command.
  13257. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  13258. Name of the nscd log file. This is where debugging output goes when
  13259. @code{debug-level} is strictly positive.
  13260. @item @code{debug-level} (default: @code{0})
  13261. Integer denoting the debugging levels. Higher numbers mean that more
  13262. debugging output is logged.
  13263. @item @code{caches} (default: @code{%nscd-default-caches})
  13264. List of @code{<nscd-cache>} objects denoting things to be cached; see
  13265. below.
  13266. @end table
  13267. @end deftp
  13268. @deftp {Data Type} nscd-cache
  13269. Data type representing a cache database of nscd and its parameters.
  13270. @table @asis
  13271. @item @code{database}
  13272. This is a symbol representing the name of the database to be cached.
  13273. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  13274. @code{services}, which designate the corresponding NSS database
  13275. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  13276. @item @code{positive-time-to-live}
  13277. @itemx @code{negative-time-to-live} (default: @code{20})
  13278. A number representing the number of seconds during which a positive or
  13279. negative lookup result remains in cache.
  13280. @item @code{check-files?} (default: @code{#t})
  13281. Whether to check for updates of the files corresponding to
  13282. @var{database}.
  13283. For instance, when @var{database} is @code{hosts}, setting this flag
  13284. instructs nscd to check for updates in @file{/etc/hosts} and to take
  13285. them into account.
  13286. @item @code{persistent?} (default: @code{#t})
  13287. Whether the cache should be stored persistently on disk.
  13288. @item @code{shared?} (default: @code{#t})
  13289. Whether the cache should be shared among users.
  13290. @item @code{max-database-size} (default: 32@tie{}MiB)
  13291. Maximum size in bytes of the database cache.
  13292. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  13293. @c settings, so leave them out.
  13294. @end table
  13295. @end deftp
  13296. @defvr {Scheme Variable} %nscd-default-caches
  13297. List of @code{<nscd-cache>} objects used by default by
  13298. @code{nscd-configuration} (see above).
  13299. It enables persistent and aggressive caching of service and host name
  13300. lookups. The latter provides better host name lookup performance,
  13301. resilience in the face of unreliable name servers, and also better
  13302. privacy---often the result of host name lookups is in local cache, so
  13303. external name servers do not even need to be queried.
  13304. @end defvr
  13305. @anchor{syslog-configuration-type}
  13306. @cindex syslog
  13307. @cindex logging
  13308. @deftp {Data Type} syslog-configuration
  13309. This data type represents the configuration of the syslog daemon.
  13310. @table @asis
  13311. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  13312. The syslog daemon to use.
  13313. @item @code{config-file} (default: @code{%default-syslog.conf})
  13314. The syslog configuration file to use.
  13315. @end table
  13316. @end deftp
  13317. @anchor{syslog-service}
  13318. @cindex syslog
  13319. @deffn {Scheme Procedure} syslog-service @var{config}
  13320. Return a service that runs a syslog daemon according to @var{config}.
  13321. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  13322. information on the configuration file syntax.
  13323. @end deffn
  13324. @defvr {Scheme Variable} guix-service-type
  13325. This is the type of the service that runs the build daemon,
  13326. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  13327. @code{guix-configuration} record as described below.
  13328. @end defvr
  13329. @anchor{guix-configuration-type}
  13330. @deftp {Data Type} guix-configuration
  13331. This data type represents the configuration of the Guix build daemon.
  13332. @xref{Invoking guix-daemon}, for more information.
  13333. @table @asis
  13334. @item @code{guix} (default: @var{guix})
  13335. The Guix package to use.
  13336. @item @code{build-group} (default: @code{"guixbuild"})
  13337. Name of the group for build user accounts.
  13338. @item @code{build-accounts} (default: @code{10})
  13339. Number of build user accounts to create.
  13340. @item @code{authorize-key?} (default: @code{#t})
  13341. @cindex substitutes, authorization thereof
  13342. Whether to authorize the substitute keys listed in
  13343. @code{authorized-keys}---by default that of
  13344. @code{@value{SUBSTITUTE-SERVER-1}} and
  13345. @code{@value{SUBSTITUTE-SERVER-2}}
  13346. (@pxref{Substitutes}).
  13347. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  13348. changed by invoking @command{guix archive --authorize}. You must
  13349. instead adjust @code{guix-configuration} as you wish and reconfigure the
  13350. system. This ensures that your operating system configuration file is
  13351. self-contained.
  13352. @quotation Note
  13353. When booting or reconfiguring to a system where @code{authorize-key?}
  13354. is true, the existing @file{/etc/guix/acl} file is backed up as
  13355. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  13356. file. This is to facilitate migration from earlier versions, which
  13357. allowed for in-place modifications to @file{/etc/guix/acl}.
  13358. @end quotation
  13359. @vindex %default-authorized-guix-keys
  13360. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  13361. The list of authorized key files for archive imports, as a list of
  13362. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  13363. contains that of @code{@value{SUBSTITUTE-SERVER-1}} and
  13364. @code{@value{SUBSTITUTE-SERVER-2}} (@pxref{Substitutes}). See
  13365. @code{substitute-urls} below for an example on how to change it.
  13366. @item @code{use-substitutes?} (default: @code{#t})
  13367. Whether to use substitutes.
  13368. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  13369. The list of URLs where to look for substitutes by default.
  13370. Suppose you would like to fetch substitutes from @code{guix.example.org}
  13371. in addition to @code{@value{SUBSTITUTE-SERVER-1}}. You will need to do
  13372. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  13373. and (2) authorize its signing key, having done appropriate checks
  13374. (@pxref{Substitute Server Authorization}). The configuration below does
  13375. exactly that:
  13376. @lisp
  13377. (guix-configuration
  13378. (substitute-urls
  13379. (append (list "https://guix.example.org")
  13380. %default-substitute-urls))
  13381. (authorized-keys
  13382. (append (list (local-file "./guix.example.org-key.pub"))
  13383. %default-authorized-guix-keys)))
  13384. @end lisp
  13385. This example assumes that the file @file{./guix.example.org-key.pub}
  13386. contains the public key that @code{guix.example.org} uses to sign
  13387. substitutes.
  13388. @item @code{max-silent-time} (default: @code{0})
  13389. @itemx @code{timeout} (default: @code{0})
  13390. The number of seconds of silence and the number of seconds of activity,
  13391. respectively, after which a build process times out. A value of zero
  13392. disables the timeout.
  13393. @item @code{log-compression} (default: @code{'bzip2})
  13394. The type of compression used for build logs---one of @code{gzip},
  13395. @code{bzip2}, or @code{none}.
  13396. @item @code{discover?} (default: @code{#f})
  13397. Whether to discover substitute servers on the local network using mDNS
  13398. and DNS-SD.
  13399. @item @code{extra-options} (default: @code{'()})
  13400. List of extra command-line options for @command{guix-daemon}.
  13401. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  13402. File where @command{guix-daemon}'s standard output and standard error
  13403. are written.
  13404. @cindex HTTP proxy, for @code{guix-daemon}
  13405. @cindex proxy, for @code{guix-daemon} HTTP access
  13406. @item @code{http-proxy} (default: @code{#f})
  13407. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  13408. derivations and substitutes.
  13409. It is also possible to change the daemon's proxy at run time through the
  13410. @code{set-http-proxy} action, which restarts it:
  13411. @example
  13412. herd set-http-proxy guix-daemon http://localhost:8118
  13413. @end example
  13414. To clear the proxy settings, run:
  13415. @example
  13416. herd set-http-proxy guix-daemon
  13417. @end example
  13418. @item @code{tmpdir} (default: @code{#f})
  13419. A directory path where the @command{guix-daemon} will perform builds.
  13420. @end table
  13421. @end deftp
  13422. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  13423. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  13424. udev rules can be provided as a list of files through the @var{rules}
  13425. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  13426. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  13427. creation of such rule files.
  13428. The @command{herd rules udev} command, as root, returns the name of the
  13429. directory containing all the active udev rules.
  13430. @end deffn
  13431. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  13432. Return a udev-rule file named @var{file-name} containing the rules
  13433. defined by the @var{contents} literal.
  13434. In the following example, a rule for a USB device is defined to be
  13435. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  13436. upon detecting a USB device with a given product identifier.
  13437. @lisp
  13438. (define %example-udev-rule
  13439. (udev-rule
  13440. "90-usb-thing.rules"
  13441. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  13442. "ATTR@{product@}==\"Example\", "
  13443. "RUN+=\"/path/to/script\"")))
  13444. @end lisp
  13445. @end deffn
  13446. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  13447. [#:groups @var{groups}]
  13448. Return a service that extends @code{udev-service-type } with @var{rules}
  13449. and @code{account-service-type} with @var{groups} as system groups.
  13450. This works by creating a singleton service type
  13451. @code{@var{name}-udev-rules}, of which the returned service is an
  13452. instance.
  13453. Here we show how it can be used to extend @code{udev-service-type} with the
  13454. previously defined rule @code{%example-udev-rule}.
  13455. @lisp
  13456. (operating-system
  13457. ;; @dots{}
  13458. (services
  13459. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  13460. %desktop-services)))
  13461. @end lisp
  13462. @end deffn
  13463. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  13464. Return a udev file named @var{file-name} containing the rules defined
  13465. within @var{file}, a file-like object.
  13466. The following example showcases how we can use an existing rule file.
  13467. @lisp
  13468. (use-modules (guix download) ;for url-fetch
  13469. (guix packages) ;for origin
  13470. @dots{})
  13471. (define %android-udev-rules
  13472. (file->udev-rule
  13473. "51-android-udev.rules"
  13474. (let ((version "20170910"))
  13475. (origin
  13476. (method url-fetch)
  13477. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  13478. "android-udev-rules/" version "/51-android.rules"))
  13479. (sha256
  13480. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  13481. @end lisp
  13482. @end deffn
  13483. Additionally, Guix package definitions can be included in @var{rules} in
  13484. order to extend the udev rules with the definitions found under their
  13485. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  13486. @var{file->udev-rule} example, we could have used the
  13487. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  13488. packages android)} module.
  13489. The following example shows how to use the @var{android-udev-rules}
  13490. package so that the Android tool @command{adb} can detect devices
  13491. without root privileges. It also details how to create the
  13492. @code{adbusers} group, which is required for the proper functioning of
  13493. the rules defined within the @code{android-udev-rules} package. To
  13494. create such a group, we must define it both as part of the
  13495. @code{supplementary-groups} of our @code{user-account} declaration, as
  13496. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  13497. @lisp
  13498. (use-modules (gnu packages android) ;for android-udev-rules
  13499. (gnu system shadow) ;for user-group
  13500. @dots{})
  13501. (operating-system
  13502. ;; @dots{}
  13503. (users (cons (user-account
  13504. ;; @dots{}
  13505. (supplementary-groups
  13506. '("adbusers" ;for adb
  13507. "wheel" "netdev" "audio" "video")))))
  13508. ;; @dots{}
  13509. (services
  13510. (cons (udev-rules-service 'android android-udev-rules
  13511. #:groups '("adbusers"))
  13512. %desktop-services)))
  13513. @end lisp
  13514. @defvr {Scheme Variable} urandom-seed-service-type
  13515. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  13516. when rebooting. It also tries to seed @file{/dev/urandom} from
  13517. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  13518. readable.
  13519. @end defvr
  13520. @defvr {Scheme Variable} %random-seed-file
  13521. This is the name of the file where some random bytes are saved by
  13522. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  13523. It defaults to @file{/var/lib/random-seed}.
  13524. @end defvr
  13525. @cindex mouse
  13526. @cindex gpm
  13527. @defvr {Scheme Variable} gpm-service-type
  13528. This is the type of the service that runs GPM, the @dfn{general-purpose
  13529. mouse daemon}, which provides mouse support to the Linux console. GPM
  13530. allows users to use the mouse in the console, notably to select, copy,
  13531. and paste text.
  13532. The value for services of this type must be a @code{gpm-configuration}
  13533. (see below). This service is not part of @code{%base-services}.
  13534. @end defvr
  13535. @deftp {Data Type} gpm-configuration
  13536. Data type representing the configuration of GPM.
  13537. @table @asis
  13538. @item @code{options} (default: @code{%default-gpm-options})
  13539. Command-line options passed to @command{gpm}. The default set of
  13540. options instruct @command{gpm} to listen to mouse events on
  13541. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  13542. more information.
  13543. @item @code{gpm} (default: @code{gpm})
  13544. The GPM package to use.
  13545. @end table
  13546. @end deftp
  13547. @anchor{guix-publish-service-type}
  13548. @deffn {Scheme Variable} guix-publish-service-type
  13549. This is the service type for @command{guix publish} (@pxref{Invoking
  13550. guix publish}). Its value must be a @code{guix-publish-configuration}
  13551. object, as described below.
  13552. This assumes that @file{/etc/guix} already contains a signing key pair as
  13553. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  13554. archive}). If that is not the case, the service will fail to start.
  13555. @end deffn
  13556. @deftp {Data Type} guix-publish-configuration
  13557. Data type representing the configuration of the @code{guix publish}
  13558. service.
  13559. @table @asis
  13560. @item @code{guix} (default: @code{guix})
  13561. The Guix package to use.
  13562. @item @code{port} (default: @code{80})
  13563. The TCP port to listen for connections.
  13564. @item @code{host} (default: @code{"localhost"})
  13565. The host (and thus, network interface) to listen to. Use
  13566. @code{"0.0.0.0"} to listen on all the network interfaces.
  13567. @item @code{advertise?} (default: @code{#f})
  13568. When true, advertise the service on the local network @i{via} the DNS-SD
  13569. protocol, using Avahi.
  13570. This allows neighboring Guix devices with discovery on (see
  13571. @code{guix-configuration} above) to discover this @command{guix publish}
  13572. instance and to automatically download substitutes from it.
  13573. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  13574. This is a list of compression method/level tuple used when compressing
  13575. substitutes. For example, to compress all substitutes with @emph{both} lzip
  13576. at level 7 and gzip at level 9, write:
  13577. @lisp
  13578. '(("lzip" 7) ("gzip" 9))
  13579. @end lisp
  13580. Level 9 achieves the best compression ratio at the expense of increased CPU
  13581. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  13582. publish}, for more information on the available compression methods and
  13583. the tradeoffs involved.
  13584. An empty list disables compression altogether.
  13585. @item @code{nar-path} (default: @code{"nar"})
  13586. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  13587. publish, @option{--nar-path}}, for details.
  13588. @item @code{cache} (default: @code{#f})
  13589. When it is @code{#f}, disable caching and instead generate archives on
  13590. demand. Otherwise, this should be the name of a directory---e.g.,
  13591. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  13592. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  13593. @option{--cache}}, for more information on the tradeoffs involved.
  13594. @item @code{workers} (default: @code{#f})
  13595. When it is an integer, this is the number of worker threads used for
  13596. caching; when @code{#f}, the number of processors is used.
  13597. @xref{Invoking guix publish, @option{--workers}}, for more information.
  13598. @item @code{cache-bypass-threshold} (default: 10 MiB)
  13599. When @code{cache} is true, this is the maximum size in bytes of a store
  13600. item for which @command{guix publish} may bypass its cache in case of a
  13601. cache miss. @xref{Invoking guix publish,
  13602. @option{--cache-bypass-threshold}}, for more information.
  13603. @item @code{ttl} (default: @code{#f})
  13604. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  13605. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  13606. for more information.
  13607. @end table
  13608. @end deftp
  13609. @anchor{rngd-service}
  13610. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  13611. [#:device "/dev/hwrng"]
  13612. Return a service that runs the @command{rngd} program from @var{rng-tools}
  13613. to add @var{device} to the kernel's entropy pool. The service will fail if
  13614. @var{device} does not exist.
  13615. @end deffn
  13616. @anchor{pam-limits-service}
  13617. @cindex session limits
  13618. @cindex ulimit
  13619. @cindex priority
  13620. @cindex realtime
  13621. @cindex jackd
  13622. @cindex nofile
  13623. @cindex open file descriptors
  13624. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  13625. Return a service that installs a configuration file for the
  13626. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  13627. @code{pam_limits} module}. The procedure optionally takes a list of
  13628. @code{pam-limits-entry} values, which can be used to specify
  13629. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  13630. The following limits definition sets two hard and soft limits for all
  13631. login sessions of users in the @code{realtime} group:
  13632. @lisp
  13633. (pam-limits-service
  13634. (list
  13635. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  13636. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  13637. @end lisp
  13638. The first entry increases the maximum realtime priority for
  13639. non-privileged processes; the second entry lifts any restriction of the
  13640. maximum address space that can be locked in memory. These settings are
  13641. commonly used for real-time audio systems.
  13642. Another useful example is raising the maximum number of open file
  13643. descriptors that can be used:
  13644. @lisp
  13645. (pam-limits-service
  13646. (list
  13647. (pam-limits-entry "*" 'both 'nofile 100000)))
  13648. @end lisp
  13649. In the above example, the asterisk means the limit should apply to any
  13650. user. It is important to ensure the chosen value doesn't exceed the
  13651. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  13652. else the users would be prevented from login in. For more information
  13653. about the Pluggable Authentication Module (PAM) limits, refer to the
  13654. @samp{pam_limits} man page from the @code{linux-pam} package.
  13655. @end deffn
  13656. @node Scheduled Job Execution
  13657. @subsection Scheduled Job Execution
  13658. @cindex cron
  13659. @cindex mcron
  13660. @cindex scheduling jobs
  13661. The @code{(gnu services mcron)} module provides an interface to
  13662. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  13663. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  13664. Unix @command{cron} daemon; the main difference is that it is
  13665. implemented in Guile Scheme, which provides a lot of flexibility when
  13666. specifying the scheduling of jobs and their actions.
  13667. The example below defines an operating system that runs the
  13668. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  13669. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  13670. well as the @command{mkid} command on behalf of an unprivileged user
  13671. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  13672. gexps to introduce job definitions that are passed to mcron
  13673. (@pxref{G-Expressions}).
  13674. @lisp
  13675. (use-modules (guix) (gnu) (gnu services mcron))
  13676. (use-package-modules base idutils)
  13677. (define updatedb-job
  13678. ;; Run 'updatedb' at 3AM every day. Here we write the
  13679. ;; job's action as a Scheme procedure.
  13680. #~(job '(next-hour '(3))
  13681. (lambda ()
  13682. (execl (string-append #$findutils "/bin/updatedb")
  13683. "updatedb"
  13684. "--prunepaths=/tmp /var/tmp /gnu/store"))
  13685. "updatedb"))
  13686. (define garbage-collector-job
  13687. ;; Collect garbage 5 minutes after midnight every day.
  13688. ;; The job's action is a shell command.
  13689. #~(job "5 0 * * *" ;Vixie cron syntax
  13690. "guix gc -F 1G"))
  13691. (define idutils-job
  13692. ;; Update the index database as user "charlie" at 12:15PM
  13693. ;; and 19:15PM. This runs from the user's home directory.
  13694. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  13695. (string-append #$idutils "/bin/mkid src")
  13696. #:user "charlie"))
  13697. (operating-system
  13698. ;; @dots{}
  13699. ;; %BASE-SERVICES already includes an instance of
  13700. ;; 'mcron-service-type', which we extend with additional
  13701. ;; jobs using 'simple-service'.
  13702. (services (cons (simple-service 'my-cron-jobs
  13703. mcron-service-type
  13704. (list garbage-collector-job
  13705. updatedb-job
  13706. idutils-job))
  13707. %base-services)))
  13708. @end lisp
  13709. @quotation Tip
  13710. When providing the action of a job specification as a procedure, you
  13711. should provide an explicit name for the job via the optional 3rd
  13712. argument as done in the @code{updatedb-job} example above. Otherwise,
  13713. the job would appear as ``Lambda function'' in the output of
  13714. @command{herd schedule mcron}, which is not nearly descriptive enough!
  13715. @end quotation
  13716. For more complex jobs defined in Scheme where you need control over the top
  13717. level, for instance to introduce a @code{use-modules} form, you can move your
  13718. code to a separate program using the @code{program-file} procedure of the
  13719. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  13720. illustrates that.
  13721. @lisp
  13722. (define %battery-alert-job
  13723. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  13724. #~(job
  13725. '(next-minute (range 0 60 1))
  13726. #$(program-file
  13727. "battery-alert.scm"
  13728. (with-imported-modules (source-module-closure
  13729. '((guix build utils)))
  13730. #~(begin
  13731. (use-modules (guix build utils)
  13732. (ice-9 popen)
  13733. (ice-9 regex)
  13734. (ice-9 textual-ports)
  13735. (srfi srfi-2))
  13736. (define %min-level 20)
  13737. (setenv "LC_ALL" "C") ;ensure English output
  13738. (and-let* ((input-pipe (open-pipe*
  13739. OPEN_READ
  13740. #$(file-append acpi "/bin/acpi")))
  13741. (output (get-string-all input-pipe))
  13742. (m (string-match "Discharging, ([0-9]+)%" output))
  13743. (level (string->number (match:substring m 1)))
  13744. ((< level %min-level)))
  13745. (format #t "warning: Battery level is low (~a%)~%" level)
  13746. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  13747. @end lisp
  13748. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  13749. for more information on mcron job specifications. Below is the
  13750. reference of the mcron service.
  13751. On a running system, you can use the @code{schedule} action of the service to
  13752. visualize the mcron jobs that will be executed next:
  13753. @example
  13754. # herd schedule mcron
  13755. @end example
  13756. @noindent
  13757. The example above lists the next five tasks that will be executed, but you can
  13758. also specify the number of tasks to display:
  13759. @example
  13760. # herd schedule mcron 10
  13761. @end example
  13762. @defvr {Scheme Variable} mcron-service-type
  13763. This is the type of the @code{mcron} service, whose value is an
  13764. @code{mcron-configuration} object.
  13765. This service type can be the target of a service extension that provides
  13766. additional job specifications (@pxref{Service Composition}). In other
  13767. words, it is possible to define services that provide additional mcron
  13768. jobs to run.
  13769. @end defvr
  13770. @deftp {Data Type} mcron-configuration
  13771. Data type representing the configuration of mcron.
  13772. @table @asis
  13773. @item @code{mcron} (default: @var{mcron})
  13774. The mcron package to use.
  13775. @item @code{jobs}
  13776. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  13777. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  13778. specifications,, mcron, GNU@tie{}mcron}).
  13779. @end table
  13780. @end deftp
  13781. @node Log Rotation
  13782. @subsection Log Rotation
  13783. @cindex rottlog
  13784. @cindex log rotation
  13785. @cindex logging
  13786. Log files such as those found in @file{/var/log} tend to grow endlessly,
  13787. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  13788. their contents in separate files, possibly compressed. The @code{(gnu
  13789. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  13790. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  13791. This service is part of @code{%base-services}, and thus enabled by
  13792. default, with the default settings, for commonly encountered log files.
  13793. The example below shows how to extend it with an additional
  13794. @dfn{rotation}, should you need to do that (usually, services that
  13795. produce log files already take care of that):
  13796. @lisp
  13797. (use-modules (guix) (gnu))
  13798. (use-service-modules admin)
  13799. (define my-log-files
  13800. ;; Log files that I want to rotate.
  13801. '("/var/log/something.log" "/var/log/another.log"))
  13802. (operating-system
  13803. ;; @dots{}
  13804. (services (cons (simple-service 'rotate-my-stuff
  13805. rottlog-service-type
  13806. (list (log-rotation
  13807. (frequency 'daily)
  13808. (files my-log-files))))
  13809. %base-services)))
  13810. @end lisp
  13811. @defvr {Scheme Variable} rottlog-service-type
  13812. This is the type of the Rottlog service, whose value is a
  13813. @code{rottlog-configuration} object.
  13814. Other services can extend this one with new @code{log-rotation} objects
  13815. (see below), thereby augmenting the set of files to be rotated.
  13816. This service type can define mcron jobs (@pxref{Scheduled Job
  13817. Execution}) to run the rottlog service.
  13818. @end defvr
  13819. @deftp {Data Type} rottlog-configuration
  13820. Data type representing the configuration of rottlog.
  13821. @table @asis
  13822. @item @code{rottlog} (default: @code{rottlog})
  13823. The Rottlog package to use.
  13824. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  13825. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  13826. rottlog, GNU Rot[t]log Manual}).
  13827. @item @code{rotations} (default: @code{%default-rotations})
  13828. A list of @code{log-rotation} objects as defined below.
  13829. @item @code{jobs}
  13830. This is a list of gexps where each gexp corresponds to an mcron job
  13831. specification (@pxref{Scheduled Job Execution}).
  13832. @end table
  13833. @end deftp
  13834. @deftp {Data Type} log-rotation
  13835. Data type representing the rotation of a group of log files.
  13836. Taking an example from the Rottlog manual (@pxref{Period Related File
  13837. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  13838. defined like this:
  13839. @lisp
  13840. (log-rotation
  13841. (frequency 'daily)
  13842. (files '("/var/log/apache/*"))
  13843. (options '("storedir apache-archives"
  13844. "rotate 6"
  13845. "notifempty"
  13846. "nocompress")))
  13847. @end lisp
  13848. The list of fields is as follows:
  13849. @table @asis
  13850. @item @code{frequency} (default: @code{'weekly})
  13851. The log rotation frequency, a symbol.
  13852. @item @code{files}
  13853. The list of files or file glob patterns to rotate.
  13854. @item @code{options} (default: @code{'()})
  13855. The list of rottlog options for this rotation (@pxref{Configuration
  13856. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  13857. @item @code{post-rotate} (default: @code{#f})
  13858. Either @code{#f} or a gexp to execute once the rotation has completed.
  13859. @end table
  13860. @end deftp
  13861. @defvr {Scheme Variable} %default-rotations
  13862. Specifies weekly rotation of @code{%rotated-files} and of
  13863. @file{/var/log/guix-daemon.log}.
  13864. @end defvr
  13865. @defvr {Scheme Variable} %rotated-files
  13866. The list of syslog-controlled files to be rotated. By default it is:
  13867. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  13868. "/var/log/maillog")}.
  13869. @end defvr
  13870. @node Networking Setup
  13871. @subsection Networking Setup
  13872. The @code{(gnu services networking)} module provides services to
  13873. configure network interfaces and set up networking on your machine.
  13874. Those services provide different ways for you to set up your machine: by
  13875. declaring a static network configuration, by running a Dynamic Host
  13876. Configuration Protocol (DHCP) client, or by running daemons such as
  13877. NetworkManager and Connman that automate the whole process,
  13878. automatically adapt to connectivity changes, and provide a high-level
  13879. user interface.
  13880. On a laptop, NetworkManager and Connman are by far the most convenient
  13881. options, which is why the default desktop services include
  13882. NetworkManager (@pxref{Desktop Services, @code{%desktop-services}}).
  13883. For a server, or for a virtual machine or a container, static network
  13884. configuration or a simple DHCP client are often more appropriate.
  13885. This section describes the various network setup services available,
  13886. starting with static network configuration.
  13887. @defvr {Scheme Variable} static-networking-service-type
  13888. This is the type for statically-configured network interfaces. Its
  13889. value must be a list of @code{static-networking} records. Each of them
  13890. declares a set of @dfn{addresses}, @dfn{routes}, and @dfn{links}, as
  13891. show below.
  13892. @cindex network interface controller (NIC)
  13893. @cindex NIC, networking interface controller
  13894. Here is the simplest configuration, with only one network interface
  13895. controller (NIC) and only IPv4 connectivity:
  13896. @lisp
  13897. ;; Static networking for one NIC, IPv4-only.
  13898. (service static-networking-service-type
  13899. (list (static-networking
  13900. (addresses
  13901. (list (network-address
  13902. (device "eno1")
  13903. (value "10.0.2.15/24"))))
  13904. (routes
  13905. (list (network-route
  13906. (destination "default")
  13907. (gateway "10.0.2.2"))))
  13908. (name-servers '("10.0.2.3")))))
  13909. @end lisp
  13910. The snippet above can be added to the @code{services} field of your
  13911. operating system configuration (@pxref{Using the Configuration System}).
  13912. It will configure your machine to have 10.0.2.15 as its IP address, with
  13913. a 24-bit netmask for the local network---meaning that any 10.0.2.@var{x}
  13914. address is on the local area network (LAN). Traffic to addresses
  13915. outside the local network is routed @i{via} 10.0.2.2. Host names are
  13916. resolved by sending domain name system (DNS) queries to 10.0.2.3.
  13917. @end defvr
  13918. @deftp {Data Type} static-networking
  13919. This is the data type representing a static network configuration.
  13920. As an example, here is how you would declare the configuration of a
  13921. machine with a single network interface controller (NIC) available as
  13922. @code{eno1}, and with one IPv4 and one IPv6 address:
  13923. @lisp
  13924. ;; Network configuration for one NIC, IPv4 + IPv6.
  13925. (static-networking
  13926. (addresses (list (network-address
  13927. (device "eno1")
  13928. (value "10.0.2.15/24"))
  13929. (network-address
  13930. (device "eno1")
  13931. (value "2001:123:4567:101::1/64"))))
  13932. (routes (list (network-route
  13933. (destination "default")
  13934. (gateway "10.0.2.2"))
  13935. (network-route
  13936. (destination "default")
  13937. (gateway "2020:321:4567:42::1"))))
  13938. (name-servers '("10.0.2.3")))
  13939. @end lisp
  13940. If you are familiar with the @command{ip} command of the
  13941. @uref{https://wiki.linuxfoundation.org/networking/iproute2,
  13942. @code{iproute2} package} found on Linux-based systems, the declaration
  13943. above is equivalent to typing:
  13944. @example
  13945. ip address add 10.0.2.15/24 dev eno1
  13946. ip address add 2001:123:4567:101::1/64 dev eno1
  13947. ip route add default via inet 10.0.2.2
  13948. ip route add default via inet6 2020:321:4567:42::1
  13949. @end example
  13950. Run @command{man 8 ip} for more info. Venerable GNU/Linux users will
  13951. certainly know how to do it with @command{ifconfig} and @command{route},
  13952. but we'll spare you that.
  13953. The available fields of this data type are as follows:
  13954. @table @asis
  13955. @item @code{addresses}
  13956. @itemx @code{links} (default: @code{'()})
  13957. @itemx @code{routes} (default: @code{'()})
  13958. The list of @code{network-address}, @code{network-link}, and
  13959. @code{network-route} records for this network (see below).
  13960. @item @code{name-servers} (default: @code{'()})
  13961. The list of IP addresses (strings) of domain name servers. These IP
  13962. addresses go to @file{/etc/resolv.conf}.
  13963. @item @code{provision} (default: @code{'(networking)})
  13964. If true, this should be a list of symbols for the Shepherd service
  13965. corresponding to this network configuration.
  13966. @item @code{requirement} (default @code{'()})
  13967. The list of Shepherd services depended on.
  13968. @end table
  13969. @end deftp
  13970. @deftp {Data Type} network-address
  13971. This is the data type representing the IP address of a network
  13972. interface.
  13973. @table @code
  13974. @item device
  13975. The name of the network interface for this address---e.g.,
  13976. @code{"eno1"}.
  13977. @item value
  13978. The actual IP address and network mask, in
  13979. @uref{https://en.wikipedia.org/wiki/CIDR#CIDR_notation, @acronym{CIDR,
  13980. Classless Inter-Domain Routing} notation}, as a string.
  13981. For example, @code{"10.0.2.15/24"} denotes IPv4 address 10.0.2.15 on a
  13982. 24-bit sub-network---all 10.0.2.@var{x} addresses are on the same local
  13983. network.
  13984. @item ipv6?
  13985. Whether @code{value} denotes an IPv6 address. By default this is
  13986. automatically determined.
  13987. @end table
  13988. @end deftp
  13989. @deftp {Data Type} network-route
  13990. This is the data type representing a network route.
  13991. @table @asis
  13992. @item @code{destination}
  13993. The route destination (a string), either an IP address or
  13994. @code{"default"} to denote the default route.
  13995. @item @code{source} (default: @code{#f})
  13996. The route source.
  13997. @item @code{device} (default: @code{#f})
  13998. The device used for this route---e.g., @code{"eno2"}.
  13999. @item @code{ipv6?} (default: auto)
  14000. Whether this is an IPv6 route. By default this is automatically
  14001. determined based on @code{destination} or @code{gateway}.
  14002. @item @code{gateway} (default: @code{#f})
  14003. IP address (a string) through which traffic is routed.
  14004. @end table
  14005. @end deftp
  14006. @deftp {Data Type} network-link
  14007. Data type for a network link (@pxref{Link,,, guile-netlink,
  14008. Guile-Netlink Manual}).
  14009. @table @code
  14010. @item name
  14011. The name of the link---e.g., @code{"v0p0"}.
  14012. @item type
  14013. A symbol denoting the type of the link---e.g., @code{'veth}.
  14014. @item arguments
  14015. List of arguments for this type of link.
  14016. @end table
  14017. @end deftp
  14018. @cindex loopback device
  14019. @defvr {Scheme Variable} %loopback-static-networking
  14020. This is the @code{static-networking} record representing the ``loopback
  14021. device'', @code{lo}, for IP addresses 127.0.0.1 and ::1, and providing
  14022. the @code{loopback} Shepherd service.
  14023. @end defvr
  14024. @cindex networking, with QEMU
  14025. @cindex QEMU, networking
  14026. @defvr {Scheme Variable} %qemu-static-networking
  14027. This is the @code{static-networking} record representing network setup
  14028. when using QEMU's user-mode network stack on @code{eth0} (@pxref{Using
  14029. the user mode network stack,,, QEMU, QEMU Documentation}).
  14030. @end defvr
  14031. @cindex DHCP, networking service
  14032. @defvr {Scheme Variable} dhcp-client-service-type
  14033. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  14034. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  14035. is the DHCP client package to use, @code{isc-dhcp} by default.
  14036. @end defvr
  14037. @cindex NetworkManager
  14038. @defvr {Scheme Variable} network-manager-service-type
  14039. This is the service type for the
  14040. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  14041. service. The value for this service type is a
  14042. @code{network-manager-configuration} record.
  14043. This service is part of @code{%desktop-services} (@pxref{Desktop
  14044. Services}).
  14045. @end defvr
  14046. @deftp {Data Type} network-manager-configuration
  14047. Data type representing the configuration of NetworkManager.
  14048. @table @asis
  14049. @item @code{network-manager} (default: @code{network-manager})
  14050. The NetworkManager package to use.
  14051. @item @code{dns} (default: @code{"default"})
  14052. Processing mode for DNS, which affects how NetworkManager uses the
  14053. @code{resolv.conf} configuration file.
  14054. @table @samp
  14055. @item default
  14056. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  14057. provided by currently active connections.
  14058. @item dnsmasq
  14059. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  14060. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  14061. then update @code{resolv.conf} to point to the local nameserver.
  14062. With this setting, you can share your network connection. For example when
  14063. you want to share your network connection to another laptop @i{via} an
  14064. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  14065. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  14066. and reestablish the connection (or reboot).
  14067. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  14068. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  14069. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  14070. browser on your host system, or connect to the VM @i{via} SSH
  14071. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  14072. host-to-guest connection, run this command once:
  14073. @example
  14074. nmcli connection add type tun \
  14075. connection.interface-name tap0 \
  14076. tun.mode tap tun.owner $(id -u) \
  14077. ipv4.method shared \
  14078. ipv4.addresses 172.28.112.1/24
  14079. @end example
  14080. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  14081. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  14082. @command{qemu-system-...}.
  14083. @item none
  14084. NetworkManager will not modify @code{resolv.conf}.
  14085. @end table
  14086. @item @code{vpn-plugins} (default: @code{'()})
  14087. This is the list of available plugins for virtual private networks
  14088. (VPNs). An example of this is the @code{network-manager-openvpn}
  14089. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  14090. @end table
  14091. @end deftp
  14092. @cindex Connman
  14093. @deffn {Scheme Variable} connman-service-type
  14094. This is the service type to run @url{https://01.org/connman,Connman},
  14095. a network connection manager.
  14096. Its value must be an
  14097. @code{connman-configuration} record as in this example:
  14098. @lisp
  14099. (service connman-service-type
  14100. (connman-configuration
  14101. (disable-vpn? #t)))
  14102. @end lisp
  14103. See below for details about @code{connman-configuration}.
  14104. @end deffn
  14105. @deftp {Data Type} connman-configuration
  14106. Data Type representing the configuration of connman.
  14107. @table @asis
  14108. @item @code{connman} (default: @var{connman})
  14109. The connman package to use.
  14110. @item @code{disable-vpn?} (default: @code{#f})
  14111. When true, disable connman's vpn plugin.
  14112. @end table
  14113. @end deftp
  14114. @cindex WPA Supplicant
  14115. @defvr {Scheme Variable} wpa-supplicant-service-type
  14116. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  14117. supplicant}, an authentication daemon required to authenticate against
  14118. encrypted WiFi or ethernet networks.
  14119. @end defvr
  14120. @deftp {Data Type} wpa-supplicant-configuration
  14121. Data type representing the configuration of WPA Supplicant.
  14122. It takes the following parameters:
  14123. @table @asis
  14124. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  14125. The WPA Supplicant package to use.
  14126. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  14127. List of services that should be started before WPA Supplicant starts.
  14128. @item @code{dbus?} (default: @code{#t})
  14129. Whether to listen for requests on D-Bus.
  14130. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  14131. Where to store the PID file.
  14132. @item @code{interface} (default: @code{#f})
  14133. If this is set, it must specify the name of a network interface that
  14134. WPA supplicant will control.
  14135. @item @code{config-file} (default: @code{#f})
  14136. Optional configuration file to use.
  14137. @item @code{extra-options} (default: @code{'()})
  14138. List of additional command-line arguments to pass to the daemon.
  14139. @end table
  14140. @end deftp
  14141. @cindex wicd
  14142. @cindex wireless
  14143. @cindex WiFi
  14144. @cindex network management
  14145. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  14146. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  14147. management daemon that aims to simplify wired and wireless networking.
  14148. This service adds the @var{wicd} package to the global profile, providing
  14149. several commands to interact with the daemon and configure networking:
  14150. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  14151. and @command{wicd-curses} user interfaces.
  14152. @end deffn
  14153. @cindex ModemManager
  14154. Some networking devices such as modems require special care, and this is
  14155. what the services below focus on.
  14156. @defvr {Scheme Variable} modem-manager-service-type
  14157. This is the service type for the
  14158. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  14159. service. The value for this service type is a
  14160. @code{modem-manager-configuration} record.
  14161. This service is part of @code{%desktop-services} (@pxref{Desktop
  14162. Services}).
  14163. @end defvr
  14164. @deftp {Data Type} modem-manager-configuration
  14165. Data type representing the configuration of ModemManager.
  14166. @table @asis
  14167. @item @code{modem-manager} (default: @code{modem-manager})
  14168. The ModemManager package to use.
  14169. @end table
  14170. @end deftp
  14171. @cindex USB_ModeSwitch
  14172. @cindex Modeswitching
  14173. @defvr {Scheme Variable} usb-modeswitch-service-type
  14174. This is the service type for the
  14175. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  14176. service. The value for this service type is
  14177. a @code{usb-modeswitch-configuration} record.
  14178. When plugged in, some USB modems (and other USB devices) initially present
  14179. themselves as a read-only storage medium and not as a modem. They need to be
  14180. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  14181. installs udev rules to automatically modeswitch these devices when they are
  14182. plugged in.
  14183. This service is part of @code{%desktop-services} (@pxref{Desktop
  14184. Services}).
  14185. @end defvr
  14186. @deftp {Data Type} usb-modeswitch-configuration
  14187. Data type representing the configuration of USB_ModeSwitch.
  14188. @table @asis
  14189. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  14190. The USB_ModeSwitch package providing the binaries for modeswitching.
  14191. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  14192. The package providing the device data and udev rules file used by
  14193. USB_ModeSwitch.
  14194. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  14195. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  14196. config file shipped with USB_ModeSwitch is used which disables logging to
  14197. @file{/var/log} among other default settings. If set to @code{#f}, no config
  14198. file is used.
  14199. @end table
  14200. @end deftp
  14201. @node Networking Services
  14202. @subsection Networking Services
  14203. The @code{(gnu services networking)} module discussed in the previous
  14204. section provides services for more advanced setups: providing a DHCP
  14205. service for others to use, filtering packets with iptables or nftables,
  14206. running a WiFi access point with @command{hostapd}, running the
  14207. @command{inetd} ``superdaemon'', and more. This section describes
  14208. those.
  14209. @deffn {Scheme Procedure} dhcpd-service-type
  14210. This type defines a service that runs a DHCP daemon. To create a
  14211. service of this type, you must supply a @code{<dhcpd-configuration>}.
  14212. For example:
  14213. @lisp
  14214. (service dhcpd-service-type
  14215. (dhcpd-configuration
  14216. (config-file (local-file "my-dhcpd.conf"))
  14217. (interfaces '("enp0s25"))))
  14218. @end lisp
  14219. @end deffn
  14220. @deftp {Data Type} dhcpd-configuration
  14221. @table @asis
  14222. @item @code{package} (default: @code{isc-dhcp})
  14223. The package that provides the DHCP daemon. This package is expected to
  14224. provide the daemon at @file{sbin/dhcpd} relative to its output
  14225. directory. The default package is the
  14226. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  14227. @item @code{config-file} (default: @code{#f})
  14228. The configuration file to use. This is required. It will be passed to
  14229. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  14230. object (@pxref{G-Expressions, file-like objects}). See @code{man
  14231. dhcpd.conf} for details on the configuration file syntax.
  14232. @item @code{version} (default: @code{"4"})
  14233. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  14234. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  14235. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  14236. details.
  14237. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  14238. The run directory to use. At service activation time, this directory
  14239. will be created if it does not exist.
  14240. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  14241. The PID file to use. This corresponds to the @code{-pf} option of
  14242. @code{dhcpd}. See @code{man dhcpd} for details.
  14243. @item @code{interfaces} (default: @code{'()})
  14244. The names of the network interfaces on which dhcpd should listen for
  14245. broadcasts. If this list is not empty, then its elements (which must be
  14246. strings) will be appended to the @code{dhcpd} invocation when starting
  14247. the daemon. It may not be necessary to explicitly specify any
  14248. interfaces here; see @code{man dhcpd} for details.
  14249. @end table
  14250. @end deftp
  14251. @cindex hostapd service, for Wi-Fi access points
  14252. @cindex Wi-Fi access points, hostapd service
  14253. @defvr {Scheme Variable} hostapd-service-type
  14254. This is the service type to run the @uref{https://w1.fi/hostapd/,
  14255. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  14256. authentication servers. Its associated value must be a
  14257. @code{hostapd-configuration} as shown below:
  14258. @lisp
  14259. ;; Use wlan1 to run the access point for "My Network".
  14260. (service hostapd-service-type
  14261. (hostapd-configuration
  14262. (interface "wlan1")
  14263. (ssid "My Network")
  14264. (channel 12)))
  14265. @end lisp
  14266. @end defvr
  14267. @deftp {Data Type} hostapd-configuration
  14268. This data type represents the configuration of the hostapd service, with
  14269. the following fields:
  14270. @table @asis
  14271. @item @code{package} (default: @code{hostapd})
  14272. The hostapd package to use.
  14273. @item @code{interface} (default: @code{"wlan0"})
  14274. The network interface to run the WiFi access point.
  14275. @item @code{ssid}
  14276. The SSID (@dfn{service set identifier}), a string that identifies this
  14277. network.
  14278. @item @code{broadcast-ssid?} (default: @code{#t})
  14279. Whether to broadcast this SSID.
  14280. @item @code{channel} (default: @code{1})
  14281. The WiFi channel to use.
  14282. @item @code{driver} (default: @code{"nl80211"})
  14283. The driver interface type. @code{"nl80211"} is used with all Linux
  14284. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  14285. RADIUS server that does # not control any wireless/wired driver.
  14286. @item @code{extra-settings} (default: @code{""})
  14287. Extra settings to append as-is to the hostapd configuration file. See
  14288. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  14289. configuration file reference.
  14290. @end table
  14291. @end deftp
  14292. @defvr {Scheme Variable} simulated-wifi-service-type
  14293. This is the type of a service to simulate WiFi networking, which can be
  14294. useful in virtual machines for testing purposes. The service loads the
  14295. Linux kernel
  14296. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  14297. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  14298. network that can be seen on @code{wlan0}, by default.
  14299. The service's value is a @code{hostapd-configuration} record.
  14300. @end defvr
  14301. @cindex iptables
  14302. @defvr {Scheme Variable} iptables-service-type
  14303. This is the service type to set up an iptables configuration. iptables is a
  14304. packet filtering framework supported by the Linux kernel. This service
  14305. supports configuring iptables for both IPv4 and IPv6. A simple example
  14306. configuration rejecting all incoming connections except those to the ssh port
  14307. 22 is shown below.
  14308. @lisp
  14309. (service iptables-service-type
  14310. (iptables-configuration
  14311. (ipv4-rules (plain-file "iptables.rules" "*filter
  14312. :INPUT ACCEPT
  14313. :FORWARD ACCEPT
  14314. :OUTPUT ACCEPT
  14315. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  14316. -A INPUT -p tcp --dport 22 -j ACCEPT
  14317. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  14318. COMMIT
  14319. "))
  14320. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  14321. :INPUT ACCEPT
  14322. :FORWARD ACCEPT
  14323. :OUTPUT ACCEPT
  14324. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  14325. -A INPUT -p tcp --dport 22 -j ACCEPT
  14326. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  14327. COMMIT
  14328. "))))
  14329. @end lisp
  14330. @end defvr
  14331. @deftp {Data Type} iptables-configuration
  14332. The data type representing the configuration of iptables.
  14333. @table @asis
  14334. @item @code{iptables} (default: @code{iptables})
  14335. The iptables package that provides @code{iptables-restore} and
  14336. @code{ip6tables-restore}.
  14337. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  14338. The iptables rules to use. It will be passed to @code{iptables-restore}.
  14339. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  14340. objects}).
  14341. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  14342. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  14343. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  14344. objects}).
  14345. @end table
  14346. @end deftp
  14347. @cindex nftables
  14348. @defvr {Scheme Variable} nftables-service-type
  14349. This is the service type to set up a nftables configuration. nftables is a
  14350. netfilter project that aims to replace the existing iptables, ip6tables,
  14351. arptables and ebtables framework. It provides a new packet filtering
  14352. framework, a new user-space utility @command{nft}, and a compatibility layer
  14353. for iptables. This service comes with a default ruleset
  14354. @code{%default-nftables-ruleset} that rejecting all incoming connections
  14355. except those to the ssh port 22. To use it, simply write:
  14356. @lisp
  14357. (service nftables-service-type)
  14358. @end lisp
  14359. @end defvr
  14360. @deftp {Data Type} nftables-configuration
  14361. The data type representing the configuration of nftables.
  14362. @table @asis
  14363. @item @code{package} (default: @code{nftables})
  14364. The nftables package that provides @command{nft}.
  14365. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  14366. The nftables ruleset to use. This may be any ``file-like'' object
  14367. (@pxref{G-Expressions, file-like objects}).
  14368. @end table
  14369. @end deftp
  14370. @cindex NTP (Network Time Protocol), service
  14371. @cindex ntpd, service for the Network Time Protocol daemon
  14372. @cindex real time clock
  14373. @defvr {Scheme Variable} ntp-service-type
  14374. This is the type of the service running the @uref{https://www.ntp.org,
  14375. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  14376. system clock synchronized with that of the specified NTP servers.
  14377. The value of this service is an @code{ntpd-configuration} object, as described
  14378. below.
  14379. @end defvr
  14380. @deftp {Data Type} ntp-configuration
  14381. This is the data type for the NTP service configuration.
  14382. @table @asis
  14383. @item @code{servers} (default: @code{%ntp-servers})
  14384. This is the list of servers (@code{<ntp-server>} records) with which
  14385. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  14386. definition below.
  14387. @item @code{allow-large-adjustment?} (default: @code{#t})
  14388. This determines whether @command{ntpd} is allowed to make an initial
  14389. adjustment of more than 1,000 seconds.
  14390. @item @code{ntp} (default: @code{ntp})
  14391. The NTP package to use.
  14392. @end table
  14393. @end deftp
  14394. @defvr {Scheme Variable} %ntp-servers
  14395. List of host names used as the default NTP servers. These are servers of the
  14396. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  14397. @end defvr
  14398. @deftp {Data Type} ntp-server
  14399. The data type representing the configuration of a NTP server.
  14400. @table @asis
  14401. @item @code{type} (default: @code{'server})
  14402. The type of the NTP server, given as a symbol. One of @code{'pool},
  14403. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  14404. @item @code{address}
  14405. The address of the server, as a string.
  14406. @item @code{options}
  14407. NTPD options to use with that specific server, given as a list of option names
  14408. and/or of option names and values tuples. The following example define a server
  14409. to use with the options @option{iburst} and @option{prefer}, as well as
  14410. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  14411. @example
  14412. (ntp-server
  14413. (type 'server)
  14414. (address "some.ntp.server.org")
  14415. (options `(iburst (version 3) (maxpoll 16) prefer))))
  14416. @end example
  14417. @end table
  14418. @end deftp
  14419. @cindex OpenNTPD
  14420. @deffn {Scheme Procedure} openntpd-service-type
  14421. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  14422. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  14423. clock synchronized with that of the given servers.
  14424. @lisp
  14425. (service
  14426. openntpd-service-type
  14427. (openntpd-configuration
  14428. (listen-on '("127.0.0.1" "::1"))
  14429. (sensor '("udcf0 correction 70000"))
  14430. (constraint-from '("www.gnu.org"))
  14431. (constraints-from '("https://www.google.com/"))))
  14432. @end lisp
  14433. @end deffn
  14434. @defvr {Scheme Variable} %openntpd-servers
  14435. This variable is a list of the server addresses defined in
  14436. @code{%ntp-servers}.
  14437. @end defvr
  14438. @deftp {Data Type} openntpd-configuration
  14439. @table @asis
  14440. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  14441. The openntpd executable to use.
  14442. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  14443. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  14444. @item @code{query-from} (default: @code{'()})
  14445. A list of local IP address the ntpd daemon should use for outgoing queries.
  14446. @item @code{sensor} (default: @code{'()})
  14447. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  14448. will listen to each sensor that actually exists and ignore non-existent ones.
  14449. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  14450. information.
  14451. @item @code{server} (default: @code{'()})
  14452. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  14453. @item @code{servers} (default: @code{%openntp-servers})
  14454. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  14455. @item @code{constraint-from} (default: @code{'()})
  14456. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  14457. This time information is not used for precision but acts as an authenticated
  14458. constraint, thereby reducing the impact of unauthenticated NTP
  14459. man-in-the-middle attacks.
  14460. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  14461. a constraint.
  14462. @item @code{constraints-from} (default: @code{'()})
  14463. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  14464. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  14465. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  14466. @end table
  14467. @end deftp
  14468. @cindex inetd
  14469. @deffn {Scheme variable} inetd-service-type
  14470. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  14471. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  14472. connections on internet sockets, and lazily starts the specified server
  14473. program when a connection is made on one of these sockets.
  14474. The value of this service is an @code{inetd-configuration} object. The
  14475. following example configures the @command{inetd} daemon to provide the
  14476. built-in @command{echo} service, as well as an smtp service which
  14477. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  14478. gateway @code{hostname}:
  14479. @lisp
  14480. (service
  14481. inetd-service-type
  14482. (inetd-configuration
  14483. (entries (list
  14484. (inetd-entry
  14485. (name "echo")
  14486. (socket-type 'stream)
  14487. (protocol "tcp")
  14488. (wait? #f)
  14489. (user "root"))
  14490. (inetd-entry
  14491. (node "127.0.0.1")
  14492. (name "smtp")
  14493. (socket-type 'stream)
  14494. (protocol "tcp")
  14495. (wait? #f)
  14496. (user "root")
  14497. (program (file-append openssh "/bin/ssh"))
  14498. (arguments
  14499. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  14500. "-W" "smtp-server:25" "user@@hostname")))))))
  14501. @end lisp
  14502. See below for more details about @code{inetd-configuration}.
  14503. @end deffn
  14504. @deftp {Data Type} inetd-configuration
  14505. Data type representing the configuration of @command{inetd}.
  14506. @table @asis
  14507. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  14508. The @command{inetd} executable to use.
  14509. @item @code{entries} (default: @code{'()})
  14510. A list of @command{inetd} service entries. Each entry should be created
  14511. by the @code{inetd-entry} constructor.
  14512. @end table
  14513. @end deftp
  14514. @deftp {Data Type} inetd-entry
  14515. Data type representing an entry in the @command{inetd} configuration.
  14516. Each entry corresponds to a socket where @command{inetd} will listen for
  14517. requests.
  14518. @table @asis
  14519. @item @code{node} (default: @code{#f})
  14520. Optional string, a comma-separated list of local addresses
  14521. @command{inetd} should use when listening for this service.
  14522. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  14523. description of all options.
  14524. @item @code{name}
  14525. A string, the name must correspond to an entry in @code{/etc/services}.
  14526. @item @code{socket-type}
  14527. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  14528. @code{'seqpacket}.
  14529. @item @code{protocol}
  14530. A string, must correspond to an entry in @code{/etc/protocols}.
  14531. @item @code{wait?} (default: @code{#t})
  14532. Whether @command{inetd} should wait for the server to exit before
  14533. listening to new service requests.
  14534. @item @code{user}
  14535. A string containing the user (and, optionally, group) name of the user
  14536. as whom the server should run. The group name can be specified in a
  14537. suffix, separated by a colon or period, i.e.@: @code{"user"},
  14538. @code{"user:group"} or @code{"user.group"}.
  14539. @item @code{program} (default: @code{"internal"})
  14540. The server program which will serve the requests, or @code{"internal"}
  14541. if @command{inetd} should use a built-in service.
  14542. @item @code{arguments} (default: @code{'()})
  14543. A list strings or file-like objects, which are the server program's
  14544. arguments, starting with the zeroth argument, i.e.@: the name of the
  14545. program itself. For @command{inetd}'s internal services, this entry
  14546. must be @code{'()} or @code{'("internal")}.
  14547. @end table
  14548. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  14549. detailed discussion of each configuration field.
  14550. @end deftp
  14551. @cindex opendht, distributed hash table network service
  14552. @cindex dhtproxy, for use with jami
  14553. @defvr {Scheme Variable} opendht-service-type
  14554. This is the type of the service running a @uref{https://opendht.net,
  14555. OpenDHT} node, @command{dhtnode}. The daemon can be used to host your
  14556. own proxy service to the distributed hash table (DHT), for example to
  14557. connect to with Jami, among other applications.
  14558. @quotation Important
  14559. When using the OpenDHT proxy server, the IP addresses it ``sees'' from
  14560. the clients should be addresses reachable from other peers. In practice
  14561. this means that a publicly reachable address is best suited for a proxy
  14562. server, outside of your private network. For example, hosting the proxy
  14563. server on a IPv4 private local network and exposing it via port
  14564. forwarding could work for external peers, but peers local to the proxy
  14565. would have their private addresses shared with the external peers,
  14566. leading to connectivity problems.
  14567. @end quotation
  14568. The value of this service is a @code{opendht-configuration} object, as
  14569. described below.
  14570. @end defvr
  14571. @deftp {Data Type} opendht-configuration
  14572. This is the data type for the OpenDHT service configuration.
  14573. @c The fields documentation has been auto-generated using the
  14574. @c configuration->documentation procedure from
  14575. @c (gnu services configuration).
  14576. Available @code{opendht-configuration} fields are:
  14577. @deftypevr {@code{opendht-configuration} parameter} package opendht
  14578. The @code{opendht} package to use.
  14579. @end deftypevr
  14580. @deftypevr {@code{opendht-configuration} parameter} boolean peer-discovery?
  14581. Whether to enable the multicast local peer discovery mechanism.
  14582. Defaults to @samp{#f}.
  14583. @end deftypevr
  14584. @deftypevr {@code{opendht-configuration} parameter} boolean enable-logging?
  14585. Whether to enable logging messages to syslog. It is disabled by default
  14586. as it is rather verbose.
  14587. Defaults to @samp{#f}.
  14588. @end deftypevr
  14589. @deftypevr {@code{opendht-configuration} parameter} boolean debug?
  14590. Whether to enable debug-level logging messages. This has no effect if
  14591. logging is disabled.
  14592. Defaults to @samp{#f}.
  14593. @end deftypevr
  14594. @deftypevr {@code{opendht-configuration} parameter} maybe-string bootstrap-host
  14595. The node host name that is used to make the first connection to the
  14596. network. A specific port value can be provided by appending the
  14597. @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but
  14598. any host can be specified here. It's also possible to disable
  14599. bootsrapping by setting this to the @code{'disabled} symbol.
  14600. Defaults to @samp{"bootstrap.jami.net:4222"}.
  14601. @end deftypevr
  14602. @deftypevr {@code{opendht-configuration} parameter} maybe-number port
  14603. The UDP port to bind to. When set to @code{'disabled}, an available
  14604. port is automatically selected.
  14605. Defaults to @samp{4222}.
  14606. @end deftypevr
  14607. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port
  14608. Spawn a proxy server listening on the specified port.
  14609. Defaults to @samp{disabled}.
  14610. @end deftypevr
  14611. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port-tls
  14612. Spawn a proxy server listening to TLS connections on the specified port.
  14613. Defaults to @samp{disabled}.
  14614. @end deftypevr
  14615. @end deftp
  14616. @cindex Tor
  14617. @defvr {Scheme Variable} tor-service-type
  14618. This is the type for a service that runs the @uref{https://torproject.org,
  14619. Tor} anonymous networking daemon. The service is configured using a
  14620. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  14621. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  14622. @end defvr
  14623. @deftp {Data Type} tor-configuration
  14624. @table @asis
  14625. @item @code{tor} (default: @code{tor})
  14626. The package that provides the Tor daemon. This package is expected to provide
  14627. the daemon at @file{bin/tor} relative to its output directory. The default
  14628. package is the @uref{https://www.torproject.org, Tor Project's}
  14629. implementation.
  14630. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  14631. The configuration file to use. It will be appended to a default configuration
  14632. file, and the final configuration file will be passed to @code{tor} via its
  14633. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  14634. file-like objects}). See @code{man tor} for details on the configuration file
  14635. syntax.
  14636. @item @code{hidden-services} (default: @code{'()})
  14637. The list of @code{<hidden-service>} records to use. For any hidden service
  14638. you include in this list, appropriate configuration to enable the hidden
  14639. service will be automatically added to the default configuration file. You
  14640. may conveniently create @code{<hidden-service>} records using the
  14641. @code{tor-hidden-service} procedure described below.
  14642. @item @code{socks-socket-type} (default: @code{'tcp})
  14643. The default socket type that Tor should use for its SOCKS socket. This must
  14644. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  14645. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  14646. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  14647. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  14648. @code{tor} group.
  14649. If you want to customize the SOCKS socket in more detail, leave
  14650. @code{socks-socket-type} at its default value of @code{'tcp} and use
  14651. @code{config-file} to override the default by providing your own
  14652. @code{SocksPort} option.
  14653. @item @code{control-socket?} (default: @code{#f})
  14654. Whether or not to provide a ``control socket'' by which Tor can be
  14655. controlled to, for instance, dynamically instantiate tor onion services.
  14656. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  14657. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  14658. @code{tor} group.
  14659. @end table
  14660. @end deftp
  14661. @cindex hidden service
  14662. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  14663. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  14664. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  14665. @example
  14666. '((22 "127.0.0.1:22")
  14667. (80 "127.0.0.1:8080"))
  14668. @end example
  14669. In this example, port 22 of the hidden service is mapped to local port 22, and
  14670. port 80 is mapped to local port 8080.
  14671. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  14672. the @file{hostname} file contains the @code{.onion} host name for the hidden
  14673. service.
  14674. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  14675. project's documentation} for more information.
  14676. @end deffn
  14677. The @code{(gnu services rsync)} module provides the following services:
  14678. You might want an rsync daemon if you have files that you want available
  14679. so anyone (or just yourself) can download existing files or upload new
  14680. files.
  14681. @deffn {Scheme Variable} rsync-service-type
  14682. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  14683. The value for this service type is a
  14684. @command{rsync-configuration} record as in this example:
  14685. @lisp
  14686. ;; Export two directories over rsync. By default rsync listens on
  14687. ;; all the network interfaces.
  14688. (service rsync-service-type
  14689. (rsync-configuration
  14690. (modules (list (rsync-module
  14691. (name "music")
  14692. (file-name "/srv/zik")
  14693. (read-only? #f))
  14694. (rsync-module
  14695. (name "movies")
  14696. (file-name "/home/charlie/movies"))))))
  14697. @end lisp
  14698. See below for details about @code{rsync-configuration}.
  14699. @end deffn
  14700. @deftp {Data Type} rsync-configuration
  14701. Data type representing the configuration for @code{rsync-service}.
  14702. @table @asis
  14703. @item @code{package} (default: @var{rsync})
  14704. @code{rsync} package to use.
  14705. @item @code{address} (default: @code{#f})
  14706. IP address on which @command{rsync} listens for incoming connections.
  14707. If unspecified, it defaults to listening on all available addresses.
  14708. @item @code{port-number} (default: @code{873})
  14709. TCP port on which @command{rsync} listens for incoming connections. If port
  14710. is less than @code{1024} @command{rsync} needs to be started as the
  14711. @code{root} user and group.
  14712. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  14713. Name of the file where @command{rsync} writes its PID.
  14714. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  14715. Name of the file where @command{rsync} writes its lock file.
  14716. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  14717. Name of the file where @command{rsync} writes its log file.
  14718. @item @code{user} (default: @code{"root"})
  14719. Owner of the @code{rsync} process.
  14720. @item @code{group} (default: @code{"root"})
  14721. Group of the @code{rsync} process.
  14722. @item @code{uid} (default: @code{"rsyncd"})
  14723. User name or user ID that file transfers to and from that module should take
  14724. place as when the daemon was run as @code{root}.
  14725. @item @code{gid} (default: @code{"rsyncd"})
  14726. Group name or group ID that will be used when accessing the module.
  14727. @item @code{modules} (default: @code{%default-modules})
  14728. List of ``modules''---i.e., directories exported over rsync. Each
  14729. element must be a @code{rsync-module} record, as described below.
  14730. @end table
  14731. @end deftp
  14732. @deftp {Data Type} rsync-module
  14733. This is the data type for rsync ``modules''. A module is a directory
  14734. exported over the rsync protocol. The available fields are as follows:
  14735. @table @asis
  14736. @item @code{name}
  14737. The module name. This is the name that shows up in URLs. For example,
  14738. if the module is called @code{music}, the corresponding URL will be
  14739. @code{rsync://host.example.org/music}.
  14740. @item @code{file-name}
  14741. Name of the directory being exported.
  14742. @item @code{comment} (default: @code{""})
  14743. Comment associated with the module. Client user interfaces may display
  14744. it when they obtain the list of available modules.
  14745. @item @code{read-only?} (default: @code{#t})
  14746. Whether or not client will be able to upload files. If this is false,
  14747. the uploads will be authorized if permissions on the daemon side permit
  14748. it.
  14749. @item @code{chroot?} (default: @code{#t})
  14750. When this is true, the rsync daemon changes root to the module's
  14751. directory before starting file transfers with the client. This improves
  14752. security, but requires rsync to run as root.
  14753. @item @code{timeout} (default: @code{300})
  14754. Idle time in seconds after which the daemon closes a connection with the
  14755. client.
  14756. @end table
  14757. @end deftp
  14758. The @code{(gnu services syncthing)} module provides the following services:
  14759. @cindex syncthing
  14760. You might want a syncthing daemon if you have files between two or more
  14761. computers and want to sync them in real time, safely protected from
  14762. prying eyes.
  14763. @deffn {Scheme Variable} syncthing-service-type
  14764. This is the service type for the @uref{https://syncthing.net/,
  14765. syncthing} daemon, The value for this service type is a
  14766. @command{syncthing-configuration} record as in this example:
  14767. @lisp
  14768. (service syncthing-service-type
  14769. (syncthing-configuration (user "alice")))
  14770. @end lisp
  14771. See below for details about @code{syncthing-configuration}.
  14772. @deftp {Data Type} syncthing-configuration
  14773. Data type representing the configuration for @code{syncthing-service-type}.
  14774. @table @asis
  14775. @item @code{syncthing} (default: @var{syncthing})
  14776. @code{syncthing} package to use.
  14777. @item @code{arguments} (default: @var{'()})
  14778. List of command-line arguments passing to @code{syncthing} binary.
  14779. @item @code{logflags} (default: @var{0})
  14780. Sum of logging flags, see
  14781. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  14782. @item @code{user} (default: @var{#f})
  14783. The user as which the Syncthing service is to be run.
  14784. This assumes that the specified user exists.
  14785. @item @code{group} (default: @var{"users"})
  14786. The group as which the Syncthing service is to be run.
  14787. This assumes that the specified group exists.
  14788. @item @code{home} (default: @var{#f})
  14789. Common configuration and data directory. The default configuration
  14790. directory is @file{$HOME} of the specified Syncthing @code{user}.
  14791. @end table
  14792. @end deftp
  14793. @end deffn
  14794. Furthermore, @code{(gnu services ssh)} provides the following services.
  14795. @cindex SSH
  14796. @cindex SSH server
  14797. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  14798. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  14799. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  14800. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  14801. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  14802. [#:public-key-authentication? #t] [#:initialize? #t]
  14803. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  14804. @var{host-key} must designate a file containing the host key, and readable
  14805. only by root.
  14806. When @var{daemonic?} is true, @command{lshd} will detach from the
  14807. controlling terminal and log its output to syslogd, unless one sets
  14808. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  14809. depend on existence of syslogd service. When @var{pid-file?} is true,
  14810. @command{lshd} writes its PID to the file called @var{pid-file}.
  14811. When @var{initialize?} is true, automatically create the seed and host key
  14812. upon service activation if they do not exist yet. This may take long and
  14813. require interaction.
  14814. When @var{initialize?} is false, it is up to the user to initialize the
  14815. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  14816. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  14817. basics,,, lsh, LSH Manual}).
  14818. When @var{interfaces} is empty, lshd listens for connections on all the
  14819. network interfaces; otherwise, @var{interfaces} must be a list of host names
  14820. or addresses.
  14821. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  14822. passwords, and @var{root-login?} specifies whether to accept log-ins as
  14823. root.
  14824. The other options should be self-descriptive.
  14825. @end deffn
  14826. @cindex SSH
  14827. @cindex SSH server
  14828. @deffn {Scheme Variable} openssh-service-type
  14829. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  14830. shell daemon, @command{sshd}. Its value must be an
  14831. @code{openssh-configuration} record as in this example:
  14832. @lisp
  14833. (service openssh-service-type
  14834. (openssh-configuration
  14835. (x11-forwarding? #t)
  14836. (permit-root-login 'prohibit-password)
  14837. (authorized-keys
  14838. `(("alice" ,(local-file "alice.pub"))
  14839. ("bob" ,(local-file "bob.pub"))))))
  14840. @end lisp
  14841. See below for details about @code{openssh-configuration}.
  14842. This service can be extended with extra authorized keys, as in this
  14843. example:
  14844. @lisp
  14845. (service-extension openssh-service-type
  14846. (const `(("charlie"
  14847. ,(local-file "charlie.pub")))))
  14848. @end lisp
  14849. @end deffn
  14850. @deftp {Data Type} openssh-configuration
  14851. This is the configuration record for OpenSSH's @command{sshd}.
  14852. @table @asis
  14853. @item @code{openssh} (default @var{openssh})
  14854. The Openssh package to use.
  14855. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  14856. Name of the file where @command{sshd} writes its PID.
  14857. @item @code{port-number} (default: @code{22})
  14858. TCP port on which @command{sshd} listens for incoming connections.
  14859. @item @code{permit-root-login} (default: @code{#f})
  14860. This field determines whether and when to allow logins as root. If
  14861. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  14862. If it's the symbol @code{'prohibit-password}, then root logins are
  14863. permitted but not with password-based authentication.
  14864. @item @code{allow-empty-passwords?} (default: @code{#f})
  14865. When true, users with empty passwords may log in. When false, they may
  14866. not.
  14867. @item @code{password-authentication?} (default: @code{#t})
  14868. When true, users may log in with their password. When false, they have
  14869. other authentication methods.
  14870. @item @code{public-key-authentication?} (default: @code{#t})
  14871. When true, users may log in using public key authentication. When
  14872. false, users have to use other authentication method.
  14873. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  14874. This is used only by protocol version 2.
  14875. @item @code{x11-forwarding?} (default: @code{#f})
  14876. When true, forwarding of X11 graphical client connections is
  14877. enabled---in other words, @command{ssh} options @option{-X} and
  14878. @option{-Y} will work.
  14879. @item @code{allow-agent-forwarding?} (default: @code{#t})
  14880. Whether to allow agent forwarding.
  14881. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  14882. Whether to allow TCP forwarding.
  14883. @item @code{gateway-ports?} (default: @code{#f})
  14884. Whether to allow gateway ports.
  14885. @item @code{challenge-response-authentication?} (default: @code{#f})
  14886. Specifies whether challenge response authentication is allowed (e.g.@: via
  14887. PAM).
  14888. @item @code{use-pam?} (default: @code{#t})
  14889. Enables the Pluggable Authentication Module interface. If set to
  14890. @code{#t}, this will enable PAM authentication using
  14891. @code{challenge-response-authentication?} and
  14892. @code{password-authentication?}, in addition to PAM account and session
  14893. module processing for all authentication types.
  14894. Because PAM challenge response authentication usually serves an
  14895. equivalent role to password authentication, you should disable either
  14896. @code{challenge-response-authentication?} or
  14897. @code{password-authentication?}.
  14898. @item @code{print-last-log?} (default: @code{#t})
  14899. Specifies whether @command{sshd} should print the date and time of the
  14900. last user login when a user logs in interactively.
  14901. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  14902. Configures external subsystems (e.g.@: file transfer daemon).
  14903. This is a list of two-element lists, each of which containing the
  14904. subsystem name and a command (with optional arguments) to execute upon
  14905. subsystem request.
  14906. The command @command{internal-sftp} implements an in-process SFTP
  14907. server. Alternatively, one can specify the @command{sftp-server} command:
  14908. @lisp
  14909. (service openssh-service-type
  14910. (openssh-configuration
  14911. (subsystems
  14912. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  14913. @end lisp
  14914. @item @code{accepted-environment} (default: @code{'()})
  14915. List of strings describing which environment variables may be exported.
  14916. Each string gets on its own line. See the @code{AcceptEnv} option in
  14917. @code{man sshd_config}.
  14918. This example allows ssh-clients to export the @env{COLORTERM} variable.
  14919. It is set by terminal emulators, which support colors. You can use it in
  14920. your shell's resource file to enable colors for the prompt and commands
  14921. if this variable is set.
  14922. @lisp
  14923. (service openssh-service-type
  14924. (openssh-configuration
  14925. (accepted-environment '("COLORTERM"))))
  14926. @end lisp
  14927. @item @code{authorized-keys} (default: @code{'()})
  14928. @cindex authorized keys, SSH
  14929. @cindex SSH authorized keys
  14930. This is the list of authorized keys. Each element of the list is a user
  14931. name followed by one or more file-like objects that represent SSH public
  14932. keys. For example:
  14933. @lisp
  14934. (openssh-configuration
  14935. (authorized-keys
  14936. `(("rekado" ,(local-file "rekado.pub"))
  14937. ("chris" ,(local-file "chris.pub"))
  14938. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  14939. @end lisp
  14940. @noindent
  14941. registers the specified public keys for user accounts @code{rekado},
  14942. @code{chris}, and @code{root}.
  14943. Additional authorized keys can be specified @i{via}
  14944. @code{service-extension}.
  14945. Note that this does @emph{not} interfere with the use of
  14946. @file{~/.ssh/authorized_keys}.
  14947. @item @code{log-level} (default: @code{'info})
  14948. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  14949. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  14950. page for @file{sshd_config} for the full list of level names.
  14951. @item @code{extra-content} (default: @code{""})
  14952. This field can be used to append arbitrary text to the configuration file. It
  14953. is especially useful for elaborate configurations that cannot be expressed
  14954. otherwise. This configuration, for example, would generally disable root
  14955. logins, but permit them from one specific IP address:
  14956. @lisp
  14957. (openssh-configuration
  14958. (extra-content "\
  14959. Match Address 192.168.0.1
  14960. PermitRootLogin yes"))
  14961. @end lisp
  14962. @end table
  14963. @end deftp
  14964. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  14965. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  14966. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  14967. object.
  14968. For example, to specify a Dropbear service listening on port 1234, add
  14969. this call to the operating system's @code{services} field:
  14970. @lisp
  14971. (dropbear-service (dropbear-configuration
  14972. (port-number 1234)))
  14973. @end lisp
  14974. @end deffn
  14975. @deftp {Data Type} dropbear-configuration
  14976. This data type represents the configuration of a Dropbear SSH daemon.
  14977. @table @asis
  14978. @item @code{dropbear} (default: @var{dropbear})
  14979. The Dropbear package to use.
  14980. @item @code{port-number} (default: 22)
  14981. The TCP port where the daemon waits for incoming connections.
  14982. @item @code{syslog-output?} (default: @code{#t})
  14983. Whether to enable syslog output.
  14984. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  14985. File name of the daemon's PID file.
  14986. @item @code{root-login?} (default: @code{#f})
  14987. Whether to allow @code{root} logins.
  14988. @item @code{allow-empty-passwords?} (default: @code{#f})
  14989. Whether to allow empty passwords.
  14990. @item @code{password-authentication?} (default: @code{#t})
  14991. Whether to enable password-based authentication.
  14992. @end table
  14993. @end deftp
  14994. @cindex AutoSSH
  14995. @deffn {Scheme Variable} autossh-service-type
  14996. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  14997. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  14998. restarting it as necessary should it die or stop passing traffic.
  14999. AutoSSH can be run manually from the command-line by passing arguments
  15000. to the binary @command{autossh} from the package @code{autossh}, but it
  15001. can also be run as a Guix service. This latter use case is documented
  15002. here.
  15003. AutoSSH can be used to forward local traffic to a remote machine using
  15004. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  15005. is run as.
  15006. For example, to specify a service running autossh as the user
  15007. @code{pino} and forwarding all local connections to port @code{8081} to
  15008. @code{remote:8081} using an SSH tunnel, add this call to the operating
  15009. system's @code{services} field:
  15010. @lisp
  15011. (service autossh-service-type
  15012. (autossh-configuration
  15013. (user "pino")
  15014. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  15015. @end lisp
  15016. @end deffn
  15017. @deftp {Data Type} autossh-configuration
  15018. This data type represents the configuration of an AutoSSH service.
  15019. @table @asis
  15020. @item @code{user} (default @code{"autossh"})
  15021. The user as which the AutoSSH service is to be run.
  15022. This assumes that the specified user exists.
  15023. @item @code{poll} (default @code{600})
  15024. Specifies the connection poll time in seconds.
  15025. @item @code{first-poll} (default @code{#f})
  15026. Specifies how many seconds AutoSSH waits before the first connection
  15027. test. After this first test, polling is resumed at the pace defined in
  15028. @code{poll}. When set to @code{#f}, the first poll is not treated
  15029. specially and will also use the connection poll specified in
  15030. @code{poll}.
  15031. @item @code{gate-time} (default @code{30})
  15032. Specifies how many seconds an SSH connection must be active before it is
  15033. considered successful.
  15034. @item @code{log-level} (default @code{1})
  15035. The log level, corresponding to the levels used by syslog---so @code{0}
  15036. is the most silent while @code{7} is the chattiest.
  15037. @item @code{max-start} (default @code{#f})
  15038. The maximum number of times SSH may be (re)started before AutoSSH exits.
  15039. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  15040. @item @code{message} (default @code{""})
  15041. The message to append to the echo message sent when testing connections.
  15042. @item @code{port} (default @code{"0"})
  15043. The ports used for monitoring the connection. When set to @code{"0"},
  15044. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  15045. a positive integer, ports @var{n} and @var{n}+1 are used for
  15046. monitoring the connection, such that port @var{n} is the base
  15047. monitoring port and @code{n+1} is the echo port. When set to
  15048. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  15049. integers, the ports @var{n} and @var{m} are used for monitoring the
  15050. connection, such that port @var{n} is the base monitoring port and
  15051. @var{m} is the echo port.
  15052. @item @code{ssh-options} (default @code{'()})
  15053. The list of command-line arguments to pass to @command{ssh} when it is
  15054. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  15055. may cause undefined behaviour.
  15056. @end table
  15057. @end deftp
  15058. @cindex WebSSH
  15059. @deffn {Scheme Variable} webssh-service-type
  15060. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  15061. program that runs a web SSH client. WebSSH can be run manually from the
  15062. command-line by passing arguments to the binary @command{wssh} from the
  15063. package @code{webssh}, but it can also be run as a Guix service. This
  15064. latter use case is documented here.
  15065. For example, to specify a service running WebSSH on loopback interface
  15066. on port @code{8888} with reject policy with a list of allowed to
  15067. connection hosts, and NGINX as a reverse-proxy to this service listening
  15068. for HTTPS connection, add this call to the operating system's
  15069. @code{services} field:
  15070. @lisp
  15071. (service webssh-service-type
  15072. (webssh-configuration (address "127.0.0.1")
  15073. (port 8888)
  15074. (policy 'reject)
  15075. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  15076. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  15077. (service nginx-service-type
  15078. (nginx-configuration
  15079. (server-blocks
  15080. (list
  15081. (nginx-server-configuration
  15082. (inherit %webssh-configuration-nginx)
  15083. (server-name '("webssh.example.com"))
  15084. (listen '("443 ssl"))
  15085. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  15086. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  15087. (locations
  15088. (cons (nginx-location-configuration
  15089. (uri "/.well-known")
  15090. (body '("root /var/www;")))
  15091. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  15092. @end lisp
  15093. @end deffn
  15094. @deftp {Data Type} webssh-configuration
  15095. Data type representing the configuration for @code{webssh-service}.
  15096. @table @asis
  15097. @item @code{package} (default: @var{webssh})
  15098. @code{webssh} package to use.
  15099. @item @code{user-name} (default: @var{"webssh"})
  15100. User name or user ID that file transfers to and from that module should take
  15101. place.
  15102. @item @code{group-name} (default: @var{"webssh"})
  15103. Group name or group ID that will be used when accessing the module.
  15104. @item @code{address} (default: @var{#f})
  15105. IP address on which @command{webssh} listens for incoming connections.
  15106. @item @code{port} (default: @var{8888})
  15107. TCP port on which @command{webssh} listens for incoming connections.
  15108. @item @code{policy} (default: @var{#f})
  15109. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  15110. @item @code{known-hosts} (default: @var{'()})
  15111. List of hosts which allowed for SSH connection from @command{webssh}.
  15112. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  15113. Name of the file where @command{webssh} writes its log file.
  15114. @item @code{log-level} (default: @var{#f})
  15115. Logging level.
  15116. @end table
  15117. @end deftp
  15118. @defvr {Scheme Variable} %facebook-host-aliases
  15119. This variable contains a string for use in @file{/etc/hosts}
  15120. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  15121. line contains a entry that maps a known server name of the Facebook
  15122. on-line service---e.g., @code{www.facebook.com}---to the local
  15123. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  15124. This variable is typically used in the @code{hosts-file} field of an
  15125. @code{operating-system} declaration (@pxref{operating-system Reference,
  15126. @file{/etc/hosts}}):
  15127. @lisp
  15128. (use-modules (gnu) (guix))
  15129. (operating-system
  15130. (host-name "mymachine")
  15131. ;; ...
  15132. (hosts-file
  15133. ;; Create a /etc/hosts file with aliases for "localhost"
  15134. ;; and "mymachine", as well as for Facebook servers.
  15135. (plain-file "hosts"
  15136. (string-append (local-host-aliases host-name)
  15137. %facebook-host-aliases))))
  15138. @end lisp
  15139. This mechanism can prevent programs running locally, such as Web
  15140. browsers, from accessing Facebook.
  15141. @end defvr
  15142. The @code{(gnu services avahi)} provides the following definition.
  15143. @defvr {Scheme Variable} avahi-service-type
  15144. This is the service that runs @command{avahi-daemon}, a system-wide
  15145. mDNS/DNS-SD responder that allows for service discovery and
  15146. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  15147. Its value must be an @code{avahi-configuration} record---see below.
  15148. This service extends the name service cache daemon (nscd) so that it can
  15149. resolve @code{.local} host names using
  15150. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  15151. Service Switch}, for information on host name resolution.
  15152. Additionally, add the @var{avahi} package to the system profile so that
  15153. commands such as @command{avahi-browse} are directly usable.
  15154. @end defvr
  15155. @deftp {Data Type} avahi-configuration
  15156. Data type representation the configuration for Avahi.
  15157. @table @asis
  15158. @item @code{host-name} (default: @code{#f})
  15159. If different from @code{#f}, use that as the host name to
  15160. publish for this machine; otherwise, use the machine's actual host name.
  15161. @item @code{publish?} (default: @code{#t})
  15162. When true, allow host names and services to be published (broadcast) over the
  15163. network.
  15164. @item @code{publish-workstation?} (default: @code{#t})
  15165. When true, @command{avahi-daemon} publishes the machine's host name and IP
  15166. address via mDNS on the local network. To view the host names published on
  15167. your local network, you can run:
  15168. @example
  15169. avahi-browse _workstation._tcp
  15170. @end example
  15171. @item @code{wide-area?} (default: @code{#f})
  15172. When true, DNS-SD over unicast DNS is enabled.
  15173. @item @code{ipv4?} (default: @code{#t})
  15174. @itemx @code{ipv6?} (default: @code{#t})
  15175. These fields determine whether to use IPv4/IPv6 sockets.
  15176. @item @code{domains-to-browse} (default: @code{'()})
  15177. This is a list of domains to browse.
  15178. @end table
  15179. @end deftp
  15180. @deffn {Scheme Variable} openvswitch-service-type
  15181. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  15182. service, whose value should be an @code{openvswitch-configuration}
  15183. object.
  15184. @end deffn
  15185. @deftp {Data Type} openvswitch-configuration
  15186. Data type representing the configuration of Open vSwitch, a multilayer
  15187. virtual switch which is designed to enable massive network automation
  15188. through programmatic extension.
  15189. @table @asis
  15190. @item @code{package} (default: @var{openvswitch})
  15191. Package object of the Open vSwitch.
  15192. @end table
  15193. @end deftp
  15194. @defvr {Scheme Variable} pagekite-service-type
  15195. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  15196. a tunneling solution for making localhost servers publicly visible, even from
  15197. behind restrictive firewalls or NAT without forwarded ports. The value for
  15198. this service type is a @code{pagekite-configuration} record.
  15199. Here's an example exposing the local HTTP and SSH daemons:
  15200. @lisp
  15201. (service pagekite-service-type
  15202. (pagekite-configuration
  15203. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  15204. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  15205. (extra-file "/etc/pagekite.rc")))
  15206. @end lisp
  15207. @end defvr
  15208. @deftp {Data Type} pagekite-configuration
  15209. Data type representing the configuration of PageKite.
  15210. @table @asis
  15211. @item @code{package} (default: @var{pagekite})
  15212. Package object of PageKite.
  15213. @item @code{kitename} (default: @code{#f})
  15214. PageKite name for authenticating to the frontend server.
  15215. @item @code{kitesecret} (default: @code{#f})
  15216. Shared secret for authenticating to the frontend server. You should probably
  15217. put this inside @code{extra-file} instead.
  15218. @item @code{frontend} (default: @code{#f})
  15219. Connect to the named PageKite frontend server instead of the
  15220. @uref{https://pagekite.net,,pagekite.net} service.
  15221. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  15222. List of service kites to use. Exposes HTTP on port 80 by default. The format
  15223. is @code{proto:kitename:host:port:secret}.
  15224. @item @code{extra-file} (default: @code{#f})
  15225. Extra configuration file to read, which you are expected to create manually.
  15226. Use this to add additional options and manage shared secrets out-of-band.
  15227. @end table
  15228. @end deftp
  15229. @defvr {Scheme Variable} yggdrasil-service-type
  15230. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  15231. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  15232. encrypted IPv6 network.
  15233. @quotation
  15234. Yggdrasil provides name-independent routing with cryptographically generated
  15235. addresses. Static addressing means you can keep the same address as long as
  15236. you want, even if you move to a new location, or generate a new address (by
  15237. generating new keys) whenever you want.
  15238. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  15239. @end quotation
  15240. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  15241. peers and/or local peers.
  15242. Here is an example using public peers and a static address. The static
  15243. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  15244. (the default value for @code{config-file}).
  15245. @lisp
  15246. ;; part of the operating-system declaration
  15247. (service yggdrasil-service-type
  15248. (yggdrasil-configuration
  15249. (autoconf? #f) ;; use only the public peers
  15250. (json-config
  15251. ;; choose one from
  15252. ;; https://github.com/yggdrasil-network/public-peers
  15253. '((peers . #("tcp://1.2.3.4:1337"))))
  15254. ;; /etc/yggdrasil-private.conf is the default value for config-file
  15255. ))
  15256. @end lisp
  15257. @example
  15258. # sample content for /etc/yggdrasil-private.conf
  15259. @{
  15260. # Your public encryption key. Your peers may ask you for this to put
  15261. # into their AllowedEncryptionPublicKeys configuration.
  15262. EncryptionPublicKey: 378dc5...
  15263. # Your private encryption key. DO NOT share this with anyone!
  15264. EncryptionPrivateKey: 0777...
  15265. # Your public signing key. You should not ordinarily need to share
  15266. # this with anyone.
  15267. SigningPublicKey: e1664...
  15268. # Your private signing key. DO NOT share this with anyone!
  15269. SigningPrivateKey: 0589d...
  15270. @}
  15271. @end example
  15272. @end defvr
  15273. @deftp {Data Type} yggdrasil-configuration
  15274. Data type representing the configuration of Yggdrasil.
  15275. @table @asis
  15276. @item @code{package} (default: @code{yggdrasil})
  15277. Package object of Yggdrasil.
  15278. @item @code{json-config} (default: @code{'()})
  15279. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  15280. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  15281. the Guix store, which is readable to all users. @strong{Do not store your
  15282. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  15283. quick overview of valid keys and their default values.
  15284. @item @code{autoconf?} (default: @code{#f})
  15285. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  15286. and peer with IPv6 neighbors.
  15287. @item @code{log-level} (default: @code{'info})
  15288. How much detail to include in logs. Use @code{'debug} for more detail.
  15289. @item @code{log-to} (default: @code{'stdout})
  15290. Where to send logs. By default, the service logs standard output to
  15291. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  15292. sends output to the running syslog service.
  15293. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  15294. What HJSON file to load sensitive data from. This is where private keys
  15295. should be stored, which are necessary to specify if you don't want a
  15296. randomized address after each restart. Use @code{#f} to disable. Options
  15297. defined in this file take precedence over @code{json-config}. Use the output
  15298. of @code{yggdrasil -genconf} as a starting point. To configure a static
  15299. address, delete everything except these options:
  15300. @itemize
  15301. @item @code{EncryptionPublicKey}
  15302. @item @code{EncryptionPrivateKey}
  15303. @item @code{SigningPublicKey}
  15304. @item @code{SigningPrivateKey}
  15305. @end itemize
  15306. @end table
  15307. @end deftp
  15308. @cindex IPFS
  15309. @defvr {Scheme Variable} ipfs-service-type
  15310. The service type for connecting to the @uref{https://ipfs.io,IPFS network},
  15311. a global, versioned, peer-to-peer file system. Pass it a
  15312. @code{ipfs-configuration} to change the ports used for the gateway and API.
  15313. Here's an example configuration, using some non-standard ports:
  15314. @lisp
  15315. (service ipfs-service-type
  15316. (ipfs-configuration
  15317. (gateway "/ip4/127.0.0.1/tcp/8880")
  15318. (api "/ip4/127.0.0.1/tcp/8881")))
  15319. @end lisp
  15320. @end defvr
  15321. @deftp {Data Type} ipfs-configuration
  15322. Data type representing the configuration of IPFS.
  15323. @table @asis
  15324. @item @code{package} (default: @code{go-ipfs})
  15325. Package object of IPFS.
  15326. @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
  15327. Address of the gateway, in ‘multiaddress’ format.
  15328. @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
  15329. Address of the API endpoint, in ‘multiaddress’ format.
  15330. @end table
  15331. @end deftp
  15332. @cindex keepalived
  15333. @deffn {Scheme Variable} keepalived-service-type
  15334. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  15335. routing software, @command{keepalived}. Its value must be an
  15336. @code{keepalived-configuration} record as in this example for master
  15337. machine:
  15338. @lisp
  15339. (service keepalived-service-type
  15340. (keepalived-configuration
  15341. (config-file (local-file "keepalived-master.conf"))))
  15342. @end lisp
  15343. where @file{keepalived-master.conf}:
  15344. @example
  15345. vrrp_instance my-group @{
  15346. state MASTER
  15347. interface enp9s0
  15348. virtual_router_id 100
  15349. priority 100
  15350. unicast_peer @{ 10.0.0.2 @}
  15351. virtual_ipaddress @{
  15352. 10.0.0.4/24
  15353. @}
  15354. @}
  15355. @end example
  15356. and for backup machine:
  15357. @lisp
  15358. (service keepalived-service-type
  15359. (keepalived-configuration
  15360. (config-file (local-file "keepalived-backup.conf"))))
  15361. @end lisp
  15362. where @file{keepalived-backup.conf}:
  15363. @example
  15364. vrrp_instance my-group @{
  15365. state BACKUP
  15366. interface enp9s0
  15367. virtual_router_id 100
  15368. priority 99
  15369. unicast_peer @{ 10.0.0.3 @}
  15370. virtual_ipaddress @{
  15371. 10.0.0.4/24
  15372. @}
  15373. @}
  15374. @end example
  15375. @end deffn
  15376. @node Unattended Upgrades
  15377. @subsection Unattended Upgrades
  15378. @cindex unattended upgrades
  15379. @cindex upgrades, unattended
  15380. Guix provides a service to perform @emph{unattended upgrades}:
  15381. periodically, the system automatically reconfigures itself from the
  15382. latest Guix. Guix System has several properties that make unattended
  15383. upgrades safe:
  15384. @itemize
  15385. @item
  15386. upgrades are transactional (either the upgrade succeeds or it fails, but
  15387. you cannot end up with an ``in-between'' system state);
  15388. @item
  15389. the upgrade log is kept---you can view it with @command{guix system
  15390. list-generations}---and you can roll back to any previous generation,
  15391. should the upgraded system fail to behave as intended;
  15392. @item
  15393. channel code is authenticated so you know you can only run genuine code
  15394. (@pxref{Channels});
  15395. @item
  15396. @command{guix system reconfigure} prevents downgrades, which makes it
  15397. immune to @dfn{downgrade attacks}.
  15398. @end itemize
  15399. To set up unattended upgrades, add an instance of
  15400. @code{unattended-upgrade-service-type} like the one below to the list of
  15401. your operating system services:
  15402. @lisp
  15403. (service unattended-upgrade-service-type)
  15404. @end lisp
  15405. The defaults above set up weekly upgrades: every Sunday at midnight.
  15406. You do not need to provide the operating system configuration file: it
  15407. uses @file{/run/current-system/configuration.scm}, which ensures it
  15408. always uses your latest configuration---@pxref{provenance-service-type},
  15409. for more information about this file.
  15410. There are several things that can be configured, in particular the
  15411. periodicity and services (daemons) to be restarted upon completion.
  15412. When the upgrade is successful, the service takes care of deleting
  15413. system generations older that some threshold, as per @command{guix
  15414. system delete-generations}. See the reference below for details.
  15415. To ensure that upgrades are actually happening, you can run
  15416. @command{guix system describe}. To investigate upgrade failures, visit
  15417. the unattended upgrade log file (see below).
  15418. @defvr {Scheme Variable} unattended-upgrade-service-type
  15419. This is the service type for unattended upgrades. It sets up an mcron
  15420. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  15421. reconfigure} from the latest version of the specified channels.
  15422. Its value must be a @code{unattended-upgrade-configuration} record (see
  15423. below).
  15424. @end defvr
  15425. @deftp {Data Type} unattended-upgrade-configuration
  15426. This data type represents the configuration of the unattended upgrade
  15427. service. The following fields are available:
  15428. @table @asis
  15429. @item @code{schedule} (default: @code{"30 01 * * 0"})
  15430. This is the schedule of upgrades, expressed as a gexp containing an
  15431. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  15432. mcron, GNU@tie{}mcron}).
  15433. @item @code{channels} (default: @code{#~%default-channels})
  15434. This gexp specifies the channels to use for the upgrade
  15435. (@pxref{Channels}). By default, the tip of the official @code{guix}
  15436. channel is used.
  15437. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  15438. This field specifies the operating system configuration file to use.
  15439. The default is to reuse the config file of the current configuration.
  15440. There are cases, though, where referring to
  15441. @file{/run/current-system/configuration.scm} is not enough, for instance
  15442. because that file refers to extra files (SSH public keys, extra
  15443. configuration files, etc.) @i{via} @code{local-file} and similar
  15444. constructs. For those cases, we recommend something along these lines:
  15445. @lisp
  15446. (unattended-upgrade-configuration
  15447. (operating-system-file
  15448. (file-append (local-file "." "config-dir" #:recursive? #t)
  15449. "/config.scm")))
  15450. @end lisp
  15451. The effect here is to import all of the current directory into the
  15452. store, and to refer to @file{config.scm} within that directory.
  15453. Therefore, uses of @code{local-file} within @file{config.scm} will work
  15454. as expected. @xref{G-Expressions}, for information about
  15455. @code{local-file} and @code{file-append}.
  15456. @item @code{services-to-restart} (default: @code{'(mcron)})
  15457. This field specifies the Shepherd services to restart when the upgrade
  15458. completes.
  15459. Those services are restarted right away upon completion, as with
  15460. @command{herd restart}, which ensures that the latest version is
  15461. running---remember that by default @command{guix system reconfigure}
  15462. only restarts services that are not currently running, which is
  15463. conservative: it minimizes disruption but leaves outdated services
  15464. running.
  15465. Use @command{herd status} to find out candidates for restarting.
  15466. @xref{Services}, for general information about services. Common
  15467. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  15468. By default, the @code{mcron} service is restarted. This ensures that
  15469. the latest version of the unattended upgrade job will be used next time.
  15470. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  15471. This is the expiration time in seconds for system generations. System
  15472. generations older that this amount of time are deleted with
  15473. @command{guix system delete-generations} when an upgrade completes.
  15474. @quotation Note
  15475. The unattended upgrade service does not run the garbage collector. You
  15476. will probably want to set up your own mcron job to run @command{guix gc}
  15477. periodically.
  15478. @end quotation
  15479. @item @code{maximum-duration} (default: @code{3600})
  15480. Maximum duration in seconds for the upgrade; past that time, the upgrade
  15481. aborts.
  15482. This is primarily useful to ensure the upgrade does not end up
  15483. rebuilding or re-downloading ``the world''.
  15484. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  15485. File where unattended upgrades are logged.
  15486. @end table
  15487. @end deftp
  15488. @node X Window
  15489. @subsection X Window
  15490. @cindex X11
  15491. @cindex X Window System
  15492. @cindex login manager
  15493. Support for the X Window graphical display system---specifically
  15494. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  15495. there is no @code{xorg-service} procedure. Instead, the X server is
  15496. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  15497. @cindex GDM
  15498. @cindex GNOME, login manager
  15499. GDM of course allows users to log in into window managers and desktop
  15500. environments other than GNOME; for those using GNOME, GDM is required for
  15501. features such as automatic screen locking.
  15502. @cindex window manager
  15503. To use X11, you must install at least one @dfn{window manager}---for
  15504. example the @code{windowmaker} or @code{openbox} packages---preferably
  15505. by adding it to the @code{packages} field of your operating system
  15506. definition (@pxref{operating-system Reference, system-wide packages}).
  15507. @anchor{wayland-gdm}
  15508. GDM also supports Wayland: it can itself use Wayland instead of X11 for
  15509. its user interface, and it can also start Wayland sessions. The former is
  15510. required for the latter, to enable, set @code{wayland?} to @code{#t} in
  15511. @code{gdm-configuration}.
  15512. @defvr {Scheme Variable} gdm-service-type
  15513. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  15514. Desktop Manager} (GDM), a program that manages graphical display servers and
  15515. handles graphical user logins. Its value must be a @code{gdm-configuration}
  15516. (see below).
  15517. @cindex session types
  15518. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  15519. @file{/run/current-system/profile/share/xsessions} (for X11 sessions) and
  15520. @file{/run/current-system/profile/share/wayland-sessions} (for Wayland
  15521. sessions) and allows users to choose a session from the log-in screen.
  15522. Packages such as @code{gnome}, @code{xfce}, @code{i3} and @code{sway} provide
  15523. @file{.desktop} files; adding them to the system-wide set of packages
  15524. automatically makes them available at the log-in screen.
  15525. In addition, @file{~/.xsession} files are honored. When available,
  15526. @file{~/.xsession} must be an executable that starts a window manager
  15527. and/or other X clients.
  15528. @end defvr
  15529. @deftp {Data Type} gdm-configuration
  15530. @table @asis
  15531. @item @code{auto-login?} (default: @code{#f})
  15532. @itemx @code{default-user} (default: @code{#f})
  15533. When @code{auto-login?} is false, GDM presents a log-in screen.
  15534. When @code{auto-login?} is true, GDM logs in directly as
  15535. @code{default-user}.
  15536. @item @code{debug?} (default: @code{#f})
  15537. When true, GDM writes debug messages to its log.
  15538. @item @code{gnome-shell-assets} (default: ...)
  15539. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  15540. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  15541. Configuration of the Xorg graphical server.
  15542. @item @code{xsession} (default: @code{(xinitrc)})
  15543. Script to run before starting a X session.
  15544. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  15545. File name of the @code{dbus-daemon} executable.
  15546. @item @code{gdm} (default: @code{gdm})
  15547. The GDM package to use.
  15548. @item @code{wayland?} (default: @code{#f})
  15549. When true, enables Wayland in GDM, necessary to use Wayland sessions.
  15550. @item @code{wayland-session} (default: @code{gdm-wayland-session-wrapper})
  15551. The Wayland session wrapper to use, needed to setup the
  15552. environment.
  15553. @end table
  15554. @end deftp
  15555. @defvr {Scheme Variable} slim-service-type
  15556. This is the type for the SLiM graphical login manager for X11.
  15557. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  15558. allows users to choose a session from the log-in screen using @kbd{F1}. It
  15559. also honors @file{~/.xsession} files.
  15560. Unlike GDM, SLiM does not spawn the user session on a different VT after
  15561. logging in, which means that you can only start one graphical session. If you
  15562. want to be able to run multiple graphical sessions at the same time you have
  15563. to add multiple SLiM services to your system services. The following example
  15564. shows how to replace the default GDM service with two SLiM services on tty7
  15565. and tty8.
  15566. @lisp
  15567. (use-modules (gnu services)
  15568. (gnu services desktop)
  15569. (gnu services xorg))
  15570. (operating-system
  15571. ;; ...
  15572. (services (cons* (service slim-service-type (slim-configuration
  15573. (display ":0")
  15574. (vt "vt7")))
  15575. (service slim-service-type (slim-configuration
  15576. (display ":1")
  15577. (vt "vt8")))
  15578. (modify-services %desktop-services
  15579. (delete gdm-service-type)))))
  15580. @end lisp
  15581. @end defvr
  15582. @deftp {Data Type} slim-configuration
  15583. Data type representing the configuration of @code{slim-service-type}.
  15584. @table @asis
  15585. @item @code{allow-empty-passwords?} (default: @code{#t})
  15586. Whether to allow logins with empty passwords.
  15587. @item @code{gnupg?} (default: @code{#f})
  15588. If enabled, @code{pam-gnupg} will attempt to automatically unlock the
  15589. user's GPG keys with the login password via @code{gpg-agent}. The
  15590. keygrips of all keys to be unlocked should be written to
  15591. @file{~/.pam-gnupg}, and can be queried with @code{gpg -K
  15592. --with-keygrip}. Presetting passphrases must be enabled by adding
  15593. @code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}.
  15594. @item @code{auto-login?} (default: @code{#f})
  15595. @itemx @code{default-user} (default: @code{""})
  15596. When @code{auto-login?} is false, SLiM presents a log-in screen.
  15597. When @code{auto-login?} is true, SLiM logs in directly as
  15598. @code{default-user}.
  15599. @item @code{theme} (default: @code{%default-slim-theme})
  15600. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  15601. The graphical theme to use and its name.
  15602. @item @code{auto-login-session} (default: @code{#f})
  15603. If true, this must be the name of the executable to start as the default
  15604. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  15605. If false, a session described by one of the available @file{.desktop}
  15606. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  15607. will be used.
  15608. @quotation Note
  15609. You must install at least one window manager in the system profile or in
  15610. your user profile. Failing to do that, if @code{auto-login-session} is
  15611. false, you will be unable to log in.
  15612. @end quotation
  15613. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  15614. Configuration of the Xorg graphical server.
  15615. @item @code{display} (default @code{":0"})
  15616. The display on which to start the Xorg graphical server.
  15617. @item @code{vt} (default @code{"vt7"})
  15618. The VT on which to start the Xorg graphical server.
  15619. @item @code{xauth} (default: @code{xauth})
  15620. The XAuth package to use.
  15621. @item @code{shepherd} (default: @code{shepherd})
  15622. The Shepherd package used when invoking @command{halt} and
  15623. @command{reboot}.
  15624. @item @code{sessreg} (default: @code{sessreg})
  15625. The sessreg package used in order to register the session.
  15626. @item @code{slim} (default: @code{slim})
  15627. The SLiM package to use.
  15628. @end table
  15629. @end deftp
  15630. @defvr {Scheme Variable} %default-theme
  15631. @defvrx {Scheme Variable} %default-theme-name
  15632. The default SLiM theme and its name.
  15633. @end defvr
  15634. @deftp {Data Type} sddm-configuration
  15635. This is the data type representing the SDDM service configuration.
  15636. @table @asis
  15637. @item @code{display-server} (default: "x11")
  15638. Select display server to use for the greeter. Valid values are
  15639. @samp{"x11"} or @samp{"wayland"}.
  15640. @item @code{numlock} (default: "on")
  15641. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  15642. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  15643. Command to run when halting.
  15644. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  15645. Command to run when rebooting.
  15646. @item @code{theme} (default "maldives")
  15647. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  15648. @samp{"maldives"} or @samp{"maya"}.
  15649. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  15650. Directory to look for themes.
  15651. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  15652. Directory to look for faces.
  15653. @item @code{default-path} (default "/run/current-system/profile/bin")
  15654. Default PATH to use.
  15655. @item @code{minimum-uid} (default: 1000)
  15656. Minimum UID displayed in SDDM and allowed for log-in.
  15657. @item @code{maximum-uid} (default: 2000)
  15658. Maximum UID to display in SDDM.
  15659. @item @code{remember-last-user?} (default #t)
  15660. Remember last user.
  15661. @item @code{remember-last-session?} (default #t)
  15662. Remember last session.
  15663. @item @code{hide-users} (default "")
  15664. Usernames to hide from SDDM greeter.
  15665. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  15666. Users with shells listed will be hidden from the SDDM greeter.
  15667. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  15668. Script to run before starting a wayland session.
  15669. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  15670. Directory to look for desktop files starting wayland sessions.
  15671. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  15672. Configuration of the Xorg graphical server.
  15673. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  15674. Path to xauth.
  15675. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  15676. Path to Xephyr.
  15677. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  15678. Script to run after starting xorg-server.
  15679. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  15680. Script to run before stopping xorg-server.
  15681. @item @code{xsession-command} (default: @code{xinitrc})
  15682. Script to run before starting a X session.
  15683. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  15684. Directory to look for desktop files starting X sessions.
  15685. @item @code{minimum-vt} (default: 7)
  15686. Minimum VT to use.
  15687. @item @code{auto-login-user} (default "")
  15688. User to use for auto-login.
  15689. @item @code{auto-login-session} (default "")
  15690. Desktop file to use for auto-login.
  15691. @item @code{relogin?} (default #f)
  15692. Relogin after logout.
  15693. @end table
  15694. @end deftp
  15695. @cindex login manager
  15696. @cindex X11 login
  15697. @defvr {Scheme Variable} sddm-service-type
  15698. This is the type of the service to run the
  15699. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  15700. must be a @code{sddm-configuration} record (see below).
  15701. Here's an example use:
  15702. @lisp
  15703. (service sddm-service-type
  15704. (sddm-configuration
  15705. (auto-login-user "alice")
  15706. (auto-login-session "xfce.desktop")))
  15707. @end lisp
  15708. @end defvr
  15709. @deftp {Data Type} sddm-configuration
  15710. This data type represents the configuration of the SDDM login manager.
  15711. The available fields are:
  15712. @table @asis
  15713. @item @code{sddm} (default: @code{sddm})
  15714. The SDDM package to use.
  15715. @item @code{display-server} (default: @code{"x11"})
  15716. This must be either @code{"x11"} or @code{"wayland"}.
  15717. @c FIXME: Add more fields.
  15718. @item @code{auto-login-user} (default: @code{""})
  15719. If non-empty, this is the user account under which to log in
  15720. automatically.
  15721. @item @code{auto-login-session} (default: @code{""})
  15722. If non-empty, this is the @file{.desktop} file name to use as the
  15723. auto-login session.
  15724. @end table
  15725. @end deftp
  15726. @cindex Xorg, configuration
  15727. @deftp {Data Type} xorg-configuration
  15728. This data type represents the configuration of the Xorg graphical display
  15729. server. Note that there is no Xorg service; instead, the X server is started
  15730. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  15731. of these display managers aggregates an @code{xorg-configuration} record.
  15732. @table @asis
  15733. @item @code{modules} (default: @code{%default-xorg-modules})
  15734. This is a list of @dfn{module packages} loaded by the Xorg
  15735. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  15736. @item @code{fonts} (default: @code{%default-xorg-fonts})
  15737. This is a list of font directories to add to the server's @dfn{font path}.
  15738. @item @code{drivers} (default: @code{'()})
  15739. This must be either the empty list, in which case Xorg chooses a graphics
  15740. driver automatically, or a list of driver names that will be tried in this
  15741. order---e.g., @code{("modesetting" "vesa")}.
  15742. @item @code{resolutions} (default: @code{'()})
  15743. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  15744. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  15745. 768) (640 480))}.
  15746. @cindex keyboard layout, for Xorg
  15747. @cindex keymap, for Xorg
  15748. @item @code{keyboard-layout} (default: @code{#f})
  15749. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  15750. English (``qwerty'') for a 105-key PC keyboard.
  15751. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  15752. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  15753. information on how to specify the keyboard layout.
  15754. @item @code{extra-config} (default: @code{'()})
  15755. This is a list of strings or objects appended to the configuration file. It
  15756. is used to pass extra text to be added verbatim to the configuration file.
  15757. @item @code{server} (default: @code{xorg-server})
  15758. This is the package providing the Xorg server.
  15759. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  15760. This is the list of command-line arguments to pass to the X server. The
  15761. default is @code{-nolisten tcp}.
  15762. @end table
  15763. @end deftp
  15764. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  15765. [@var{login-manager-service-type}]
  15766. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  15767. @var{config}, an @code{<xorg-configuration>} record.
  15768. Since the Xorg configuration is embedded in the log-in manager's
  15769. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  15770. shorthand to set the Xorg configuration.
  15771. @end deffn
  15772. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  15773. Return a @code{startx} script in which the modules, fonts, etc. specified
  15774. in @var{config}, are available. The result should be used in place of
  15775. @code{startx}.
  15776. Usually the X server is started by a login manager.
  15777. @end deffn
  15778. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  15779. Add @var{package}, a package for a screen locker or screen saver whose
  15780. command is @var{program}, to the set of setuid programs and add a PAM entry
  15781. for it. For example:
  15782. @lisp
  15783. (screen-locker-service xlockmore "xlock")
  15784. @end lisp
  15785. makes the good ol' XlockMore usable.
  15786. @end deffn
  15787. @node Printing Services
  15788. @subsection Printing Services
  15789. @cindex printer support with CUPS
  15790. The @code{(gnu services cups)} module provides a Guix service definition
  15791. for the CUPS printing service. To add printer support to a Guix
  15792. system, add a @code{cups-service} to the operating system definition:
  15793. @deffn {Scheme Variable} cups-service-type
  15794. The service type for the CUPS print server. Its value should be a valid
  15795. CUPS configuration (see below). To use the default settings, simply
  15796. write:
  15797. @lisp
  15798. (service cups-service-type)
  15799. @end lisp
  15800. @end deffn
  15801. The CUPS configuration controls the basic things about your CUPS
  15802. installation: what interfaces it listens on, what to do if a print job
  15803. fails, how much logging to do, and so on. To actually add a printer,
  15804. you have to visit the @url{http://localhost:631} URL, or use a tool such
  15805. as GNOME's printer configuration services. By default, configuring a
  15806. CUPS service will generate a self-signed certificate if needed, for
  15807. secure connections to the print server.
  15808. Suppose you want to enable the Web interface of CUPS and also add
  15809. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  15810. package and for HP printers @i{via} the @code{hplip-minimal} package.
  15811. You can do that directly, like this (you need to use the
  15812. @code{(gnu packages cups)} module):
  15813. @lisp
  15814. (service cups-service-type
  15815. (cups-configuration
  15816. (web-interface? #t)
  15817. (extensions
  15818. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  15819. @end lisp
  15820. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  15821. package then it is suggested that you install the @code{hplip} package,
  15822. either in your OS configuration file or as your user.
  15823. The available configuration parameters follow. Each parameter
  15824. definition is preceded by its type; for example, @samp{string-list foo}
  15825. indicates that the @code{foo} parameter should be specified as a list of
  15826. strings. There is also a way to specify the configuration as a string,
  15827. if you have an old @code{cupsd.conf} file that you want to port over
  15828. from some other system; see the end for more details.
  15829. @c The following documentation was initially generated by
  15830. @c (generate-documentation) in (gnu services cups). Manually maintained
  15831. @c documentation is better, so we shouldn't hesitate to edit below as
  15832. @c needed. However if the change you want to make to this documentation
  15833. @c can be done in an automated way, it's probably easier to change
  15834. @c (generate-documentation) than to make it below and have to deal with
  15835. @c the churn as CUPS updates.
  15836. Available @code{cups-configuration} fields are:
  15837. @deftypevr {@code{cups-configuration} parameter} package cups
  15838. The CUPS package.
  15839. @end deftypevr
  15840. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  15841. Drivers and other extensions to the CUPS package.
  15842. @end deftypevr
  15843. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  15844. Configuration of where to write logs, what directories to use for print
  15845. spools, and related privileged configuration parameters.
  15846. Available @code{files-configuration} fields are:
  15847. @deftypevr {@code{files-configuration} parameter} log-location access-log
  15848. Defines the access log filename. Specifying a blank filename disables
  15849. access log generation. The value @code{stderr} causes log entries to be
  15850. sent to the standard error file when the scheduler is running in the
  15851. foreground, or to the system log daemon when run in the background. The
  15852. value @code{syslog} causes log entries to be sent to the system log
  15853. daemon. The server name may be included in filenames using the string
  15854. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  15855. Defaults to @samp{"/var/log/cups/access_log"}.
  15856. @end deftypevr
  15857. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  15858. Where CUPS should cache data.
  15859. Defaults to @samp{"/var/cache/cups"}.
  15860. @end deftypevr
  15861. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  15862. Specifies the permissions for all configuration files that the scheduler
  15863. writes.
  15864. Note that the permissions for the printers.conf file are currently
  15865. masked to only allow access from the scheduler user (typically root).
  15866. This is done because printer device URIs sometimes contain sensitive
  15867. authentication information that should not be generally known on the
  15868. system. There is no way to disable this security feature.
  15869. Defaults to @samp{"0640"}.
  15870. @end deftypevr
  15871. @deftypevr {@code{files-configuration} parameter} log-location error-log
  15872. Defines the error log filename. Specifying a blank filename disables
  15873. error log generation. The value @code{stderr} causes log entries to be
  15874. sent to the standard error file when the scheduler is running in the
  15875. foreground, or to the system log daemon when run in the background. The
  15876. value @code{syslog} causes log entries to be sent to the system log
  15877. daemon. The server name may be included in filenames using the string
  15878. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  15879. Defaults to @samp{"/var/log/cups/error_log"}.
  15880. @end deftypevr
  15881. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  15882. Specifies which errors are fatal, causing the scheduler to exit. The
  15883. kind strings are:
  15884. @table @code
  15885. @item none
  15886. No errors are fatal.
  15887. @item all
  15888. All of the errors below are fatal.
  15889. @item browse
  15890. Browsing initialization errors are fatal, for example failed connections
  15891. to the DNS-SD daemon.
  15892. @item config
  15893. Configuration file syntax errors are fatal.
  15894. @item listen
  15895. Listen or Port errors are fatal, except for IPv6 failures on the
  15896. loopback or @code{any} addresses.
  15897. @item log
  15898. Log file creation or write errors are fatal.
  15899. @item permissions
  15900. Bad startup file permissions are fatal, for example shared TLS
  15901. certificate and key files with world-read permissions.
  15902. @end table
  15903. Defaults to @samp{"all -browse"}.
  15904. @end deftypevr
  15905. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  15906. Specifies whether the file pseudo-device can be used for new printer
  15907. queues. The URI @uref{file:///dev/null} is always allowed.
  15908. Defaults to @samp{#f}.
  15909. @end deftypevr
  15910. @deftypevr {@code{files-configuration} parameter} string group
  15911. Specifies the group name or ID that will be used when executing external
  15912. programs.
  15913. Defaults to @samp{"lp"}.
  15914. @end deftypevr
  15915. @deftypevr {@code{files-configuration} parameter} string log-file-group
  15916. Specifies the group name or ID that will be used for log files.
  15917. Defaults to @samp{"lpadmin"}.
  15918. @end deftypevr
  15919. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  15920. Specifies the permissions for all log files that the scheduler writes.
  15921. Defaults to @samp{"0644"}.
  15922. @end deftypevr
  15923. @deftypevr {@code{files-configuration} parameter} log-location page-log
  15924. Defines the page log filename. Specifying a blank filename disables
  15925. page log generation. The value @code{stderr} causes log entries to be
  15926. sent to the standard error file when the scheduler is running in the
  15927. foreground, or to the system log daemon when run in the background. The
  15928. value @code{syslog} causes log entries to be sent to the system log
  15929. daemon. The server name may be included in filenames using the string
  15930. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  15931. Defaults to @samp{"/var/log/cups/page_log"}.
  15932. @end deftypevr
  15933. @deftypevr {@code{files-configuration} parameter} string remote-root
  15934. Specifies the username that is associated with unauthenticated accesses
  15935. by clients claiming to be the root user. The default is @code{remroot}.
  15936. Defaults to @samp{"remroot"}.
  15937. @end deftypevr
  15938. @deftypevr {@code{files-configuration} parameter} file-name request-root
  15939. Specifies the directory that contains print jobs and other HTTP request
  15940. data.
  15941. Defaults to @samp{"/var/spool/cups"}.
  15942. @end deftypevr
  15943. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  15944. Specifies the level of security sandboxing that is applied to print
  15945. filters, backends, and other child processes of the scheduler; either
  15946. @code{relaxed} or @code{strict}. This directive is currently only
  15947. used/supported on macOS.
  15948. Defaults to @samp{strict}.
  15949. @end deftypevr
  15950. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  15951. Specifies the location of TLS certificates and private keys. CUPS will
  15952. look for public and private keys in this directory: @file{.crt} files
  15953. for PEM-encoded certificates and corresponding @file{.key} files for
  15954. PEM-encoded private keys.
  15955. Defaults to @samp{"/etc/cups/ssl"}.
  15956. @end deftypevr
  15957. @deftypevr {@code{files-configuration} parameter} file-name server-root
  15958. Specifies the directory containing the server configuration files.
  15959. Defaults to @samp{"/etc/cups"}.
  15960. @end deftypevr
  15961. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  15962. Specifies whether the scheduler calls fsync(2) after writing
  15963. configuration or state files.
  15964. Defaults to @samp{#f}.
  15965. @end deftypevr
  15966. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  15967. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  15968. @end deftypevr
  15969. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  15970. Specifies the directory where temporary files are stored.
  15971. Defaults to @samp{"/var/spool/cups/tmp"}.
  15972. @end deftypevr
  15973. @deftypevr {@code{files-configuration} parameter} string user
  15974. Specifies the user name or ID that is used when running external
  15975. programs.
  15976. Defaults to @samp{"lp"}.
  15977. @end deftypevr
  15978. @deftypevr {@code{files-configuration} parameter} string set-env
  15979. Set the specified environment variable to be passed to child processes.
  15980. Defaults to @samp{"variable value"}.
  15981. @end deftypevr
  15982. @end deftypevr
  15983. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  15984. Specifies the logging level for the AccessLog file. The @code{config}
  15985. level logs when printers and classes are added, deleted, or modified and
  15986. when configuration files are accessed or updated. The @code{actions}
  15987. level logs when print jobs are submitted, held, released, modified, or
  15988. canceled, and any of the conditions for @code{config}. The @code{all}
  15989. level logs all requests.
  15990. Defaults to @samp{actions}.
  15991. @end deftypevr
  15992. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  15993. Specifies whether to purge job history data automatically when it is no
  15994. longer required for quotas.
  15995. Defaults to @samp{#f}.
  15996. @end deftypevr
  15997. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  15998. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  15999. For example, @samp{"_cups" "_print"} will tell network clients that both
  16000. CUPS sharing and IPP Everywhere are supported.
  16001. Defaults to @samp{"_cups"}.
  16002. @end deftypevr
  16003. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  16004. Specifies which protocols to use for local printer sharing.
  16005. Defaults to @samp{dnssd}.
  16006. @end deftypevr
  16007. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  16008. Specifies whether the CUPS web interface is advertised.
  16009. Defaults to @samp{#f}.
  16010. @end deftypevr
  16011. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  16012. Specifies whether shared printers are advertised.
  16013. Defaults to @samp{#f}.
  16014. @end deftypevr
  16015. @deftypevr {@code{cups-configuration} parameter} string classification
  16016. Specifies the security classification of the server. Any valid banner
  16017. name can be used, including @samp{"classified"}, @samp{"confidential"},
  16018. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  16019. banner can be omitted to disable secure printing functions.
  16020. Defaults to @samp{""}.
  16021. @end deftypevr
  16022. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  16023. Specifies whether users may override the classification (cover page) of
  16024. individual print jobs using the @code{job-sheets} option.
  16025. Defaults to @samp{#f}.
  16026. @end deftypevr
  16027. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  16028. Specifies the default type of authentication to use.
  16029. Defaults to @samp{Basic}.
  16030. @end deftypevr
  16031. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  16032. Specifies whether encryption will be used for authenticated requests.
  16033. Defaults to @samp{Required}.
  16034. @end deftypevr
  16035. @deftypevr {@code{cups-configuration} parameter} string default-language
  16036. Specifies the default language to use for text and web content.
  16037. Defaults to @samp{"en"}.
  16038. @end deftypevr
  16039. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  16040. Specifies the default paper size for new print queues. @samp{"Auto"}
  16041. uses a locale-specific default, while @samp{"None"} specifies there is
  16042. no default paper size. Specific size names are typically
  16043. @samp{"Letter"} or @samp{"A4"}.
  16044. Defaults to @samp{"Auto"}.
  16045. @end deftypevr
  16046. @deftypevr {@code{cups-configuration} parameter} string default-policy
  16047. Specifies the default access policy to use.
  16048. Defaults to @samp{"default"}.
  16049. @end deftypevr
  16050. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  16051. Specifies whether local printers are shared by default.
  16052. Defaults to @samp{#t}.
  16053. @end deftypevr
  16054. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  16055. Specifies the delay for updating of configuration and state files, in
  16056. seconds. A value of 0 causes the update to happen as soon as possible,
  16057. typically within a few milliseconds.
  16058. Defaults to @samp{30}.
  16059. @end deftypevr
  16060. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  16061. Specifies what to do when an error occurs. Possible values are
  16062. @code{abort-job}, which will discard the failed print job;
  16063. @code{retry-job}, which will retry the job at a later time;
  16064. @code{retry-current-job}, which retries the failed job immediately; and
  16065. @code{stop-printer}, which stops the printer.
  16066. Defaults to @samp{stop-printer}.
  16067. @end deftypevr
  16068. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  16069. Specifies the maximum cost of filters that are run concurrently, which
  16070. can be used to minimize disk, memory, and CPU resource problems. A
  16071. limit of 0 disables filter limiting. An average print to a
  16072. non-PostScript printer needs a filter limit of about 200. A PostScript
  16073. printer needs about half that (100). Setting the limit below these
  16074. thresholds will effectively limit the scheduler to printing a single job
  16075. at any time.
  16076. Defaults to @samp{0}.
  16077. @end deftypevr
  16078. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  16079. Specifies the scheduling priority of filters that are run to print a
  16080. job. The nice value ranges from 0, the highest priority, to 19, the
  16081. lowest priority.
  16082. Defaults to @samp{0}.
  16083. @end deftypevr
  16084. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  16085. Specifies whether to do reverse lookups on connecting clients. The
  16086. @code{double} setting causes @code{cupsd} to verify that the hostname
  16087. resolved from the address matches one of the addresses returned for that
  16088. hostname. Double lookups also prevent clients with unregistered
  16089. addresses from connecting to your server. Only set this option to
  16090. @code{#t} or @code{double} if absolutely required.
  16091. Defaults to @samp{#f}.
  16092. @end deftypevr
  16093. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  16094. Specifies the number of seconds to wait before killing the filters and
  16095. backend associated with a canceled or held job.
  16096. Defaults to @samp{30}.
  16097. @end deftypevr
  16098. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  16099. Specifies the interval between retries of jobs in seconds. This is
  16100. typically used for fax queues but can also be used with normal print
  16101. queues whose error policy is @code{retry-job} or
  16102. @code{retry-current-job}.
  16103. Defaults to @samp{30}.
  16104. @end deftypevr
  16105. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  16106. Specifies the number of retries that are done for jobs. This is
  16107. typically used for fax queues but can also be used with normal print
  16108. queues whose error policy is @code{retry-job} or
  16109. @code{retry-current-job}.
  16110. Defaults to @samp{5}.
  16111. @end deftypevr
  16112. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  16113. Specifies whether to support HTTP keep-alive connections.
  16114. Defaults to @samp{#t}.
  16115. @end deftypevr
  16116. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  16117. Specifies the maximum size of print files, IPP requests, and HTML form
  16118. data. A limit of 0 disables the limit check.
  16119. Defaults to @samp{0}.
  16120. @end deftypevr
  16121. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  16122. Listens on the specified interfaces for connections. Valid values are
  16123. of the form @var{address}:@var{port}, where @var{address} is either an
  16124. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  16125. indicate all addresses. Values can also be file names of local UNIX
  16126. domain sockets. The Listen directive is similar to the Port directive
  16127. but allows you to restrict access to specific interfaces or networks.
  16128. @end deftypevr
  16129. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  16130. Specifies the number of pending connections that will be allowed. This
  16131. normally only affects very busy servers that have reached the MaxClients
  16132. limit, but can also be triggered by large numbers of simultaneous
  16133. connections. When the limit is reached, the operating system will
  16134. refuse additional connections until the scheduler can accept the pending
  16135. ones.
  16136. Defaults to @samp{128}.
  16137. @end deftypevr
  16138. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  16139. Specifies a set of additional access controls.
  16140. Available @code{location-access-controls} fields are:
  16141. @deftypevr {@code{location-access-controls} parameter} file-name path
  16142. Specifies the URI path to which the access control applies.
  16143. @end deftypevr
  16144. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  16145. Access controls for all access to this path, in the same format as the
  16146. @code{access-controls} of @code{operation-access-control}.
  16147. Defaults to @samp{()}.
  16148. @end deftypevr
  16149. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  16150. Access controls for method-specific access to this path.
  16151. Defaults to @samp{()}.
  16152. Available @code{method-access-controls} fields are:
  16153. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  16154. If @code{#t}, apply access controls to all methods except the listed
  16155. methods. Otherwise apply to only the listed methods.
  16156. Defaults to @samp{#f}.
  16157. @end deftypevr
  16158. @deftypevr {@code{method-access-controls} parameter} method-list methods
  16159. Methods to which this access control applies.
  16160. Defaults to @samp{()}.
  16161. @end deftypevr
  16162. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  16163. Access control directives, as a list of strings. Each string should be
  16164. one directive, such as @samp{"Order allow,deny"}.
  16165. Defaults to @samp{()}.
  16166. @end deftypevr
  16167. @end deftypevr
  16168. @end deftypevr
  16169. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  16170. Specifies the number of debugging messages that are retained for logging
  16171. if an error occurs in a print job. Debug messages are logged regardless
  16172. of the LogLevel setting.
  16173. Defaults to @samp{100}.
  16174. @end deftypevr
  16175. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  16176. Specifies the level of logging for the ErrorLog file. The value
  16177. @code{none} stops all logging while @code{debug2} logs everything.
  16178. Defaults to @samp{info}.
  16179. @end deftypevr
  16180. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  16181. Specifies the format of the date and time in the log files. The value
  16182. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  16183. Defaults to @samp{standard}.
  16184. @end deftypevr
  16185. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  16186. Specifies the maximum number of simultaneous clients that are allowed by
  16187. the scheduler.
  16188. Defaults to @samp{100}.
  16189. @end deftypevr
  16190. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  16191. Specifies the maximum number of simultaneous clients that are allowed
  16192. from a single address.
  16193. Defaults to @samp{100}.
  16194. @end deftypevr
  16195. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  16196. Specifies the maximum number of copies that a user can print of each
  16197. job.
  16198. Defaults to @samp{9999}.
  16199. @end deftypevr
  16200. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  16201. Specifies the maximum time a job may remain in the @code{indefinite}
  16202. hold state before it is canceled. A value of 0 disables cancellation of
  16203. held jobs.
  16204. Defaults to @samp{0}.
  16205. @end deftypevr
  16206. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  16207. Specifies the maximum number of simultaneous jobs that are allowed. Set
  16208. to 0 to allow an unlimited number of jobs.
  16209. Defaults to @samp{500}.
  16210. @end deftypevr
  16211. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  16212. Specifies the maximum number of simultaneous jobs that are allowed per
  16213. printer. A value of 0 allows up to MaxJobs jobs per printer.
  16214. Defaults to @samp{0}.
  16215. @end deftypevr
  16216. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  16217. Specifies the maximum number of simultaneous jobs that are allowed per
  16218. user. A value of 0 allows up to MaxJobs jobs per user.
  16219. Defaults to @samp{0}.
  16220. @end deftypevr
  16221. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  16222. Specifies the maximum time a job may take to print before it is
  16223. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  16224. Defaults to @samp{10800}.
  16225. @end deftypevr
  16226. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  16227. Specifies the maximum size of the log files before they are rotated, in
  16228. bytes. The value 0 disables log rotation.
  16229. Defaults to @samp{1048576}.
  16230. @end deftypevr
  16231. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  16232. Specifies the maximum amount of time to allow between files in a
  16233. multiple file print job, in seconds.
  16234. Defaults to @samp{900}.
  16235. @end deftypevr
  16236. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  16237. Specifies the format of PageLog lines. Sequences beginning with percent
  16238. (@samp{%}) characters are replaced with the corresponding information,
  16239. while all other characters are copied literally. The following percent
  16240. sequences are recognized:
  16241. @table @samp
  16242. @item %%
  16243. insert a single percent character
  16244. @item %@{name@}
  16245. insert the value of the specified IPP attribute
  16246. @item %C
  16247. insert the number of copies for the current page
  16248. @item %P
  16249. insert the current page number
  16250. @item %T
  16251. insert the current date and time in common log format
  16252. @item %j
  16253. insert the job ID
  16254. @item %p
  16255. insert the printer name
  16256. @item %u
  16257. insert the username
  16258. @end table
  16259. A value of the empty string disables page logging. The string @code{%p
  16260. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  16261. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  16262. standard items.
  16263. Defaults to @samp{""}.
  16264. @end deftypevr
  16265. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  16266. Passes the specified environment variable(s) to child processes; a list
  16267. of strings.
  16268. Defaults to @samp{()}.
  16269. @end deftypevr
  16270. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  16271. Specifies named access control policies.
  16272. Available @code{policy-configuration} fields are:
  16273. @deftypevr {@code{policy-configuration} parameter} string name
  16274. Name of the policy.
  16275. @end deftypevr
  16276. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  16277. Specifies an access list for a job's private values. @code{@@ACL} maps
  16278. to the printer's requesting-user-name-allowed or
  16279. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  16280. owner. @code{@@SYSTEM} maps to the groups listed for the
  16281. @code{system-group} field of the @code{files-configuration},
  16282. which is reified into the @code{cups-files.conf(5)} file. Other
  16283. possible elements of the access list include specific user names, and
  16284. @code{@@@var{group}} to indicate members of a specific group. The
  16285. access list may also be simply @code{all} or @code{default}.
  16286. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  16287. @end deftypevr
  16288. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  16289. Specifies the list of job values to make private, or @code{all},
  16290. @code{default}, or @code{none}.
  16291. Defaults to @samp{"job-name job-originating-host-name
  16292. job-originating-user-name phone"}.
  16293. @end deftypevr
  16294. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  16295. Specifies an access list for a subscription's private values.
  16296. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  16297. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  16298. owner. @code{@@SYSTEM} maps to the groups listed for the
  16299. @code{system-group} field of the @code{files-configuration},
  16300. which is reified into the @code{cups-files.conf(5)} file. Other
  16301. possible elements of the access list include specific user names, and
  16302. @code{@@@var{group}} to indicate members of a specific group. The
  16303. access list may also be simply @code{all} or @code{default}.
  16304. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  16305. @end deftypevr
  16306. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  16307. Specifies the list of job values to make private, or @code{all},
  16308. @code{default}, or @code{none}.
  16309. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  16310. notify-subscriber-user-name notify-user-data"}.
  16311. @end deftypevr
  16312. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  16313. Access control by IPP operation.
  16314. Defaults to @samp{()}.
  16315. @end deftypevr
  16316. @end deftypevr
  16317. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  16318. Specifies whether job files (documents) are preserved after a job is
  16319. printed. If a numeric value is specified, job files are preserved for
  16320. the indicated number of seconds after printing. Otherwise a boolean
  16321. value applies indefinitely.
  16322. Defaults to @samp{86400}.
  16323. @end deftypevr
  16324. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  16325. Specifies whether the job history is preserved after a job is printed.
  16326. If a numeric value is specified, the job history is preserved for the
  16327. indicated number of seconds after printing. If @code{#t}, the job
  16328. history is preserved until the MaxJobs limit is reached.
  16329. Defaults to @samp{#t}.
  16330. @end deftypevr
  16331. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  16332. Specifies the amount of time to wait for job completion before
  16333. restarting the scheduler.
  16334. Defaults to @samp{30}.
  16335. @end deftypevr
  16336. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  16337. Specifies the maximum amount of memory to use when converting documents
  16338. into bitmaps for a printer.
  16339. Defaults to @samp{"128m"}.
  16340. @end deftypevr
  16341. @deftypevr {@code{cups-configuration} parameter} string server-admin
  16342. Specifies the email address of the server administrator.
  16343. Defaults to @samp{"root@@localhost.localdomain"}.
  16344. @end deftypevr
  16345. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  16346. The ServerAlias directive is used for HTTP Host header validation when
  16347. clients connect to the scheduler from external interfaces. Using the
  16348. special name @code{*} can expose your system to known browser-based DNS
  16349. rebinding attacks, even when accessing sites through a firewall. If the
  16350. auto-discovery of alternate names does not work, we recommend listing
  16351. each alternate name with a ServerAlias directive instead of using
  16352. @code{*}.
  16353. Defaults to @samp{*}.
  16354. @end deftypevr
  16355. @deftypevr {@code{cups-configuration} parameter} string server-name
  16356. Specifies the fully-qualified host name of the server.
  16357. Defaults to @samp{"localhost"}.
  16358. @end deftypevr
  16359. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  16360. Specifies what information is included in the Server header of HTTP
  16361. responses. @code{None} disables the Server header. @code{ProductOnly}
  16362. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  16363. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  16364. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  16365. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  16366. 2.0.0 (@var{uname}) IPP/2.0}.
  16367. Defaults to @samp{Minimal}.
  16368. @end deftypevr
  16369. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  16370. Listens on the specified interfaces for encrypted connections. Valid
  16371. values are of the form @var{address}:@var{port}, where @var{address} is
  16372. either an IPv6 address enclosed in brackets, an IPv4 address, or
  16373. @code{*} to indicate all addresses.
  16374. Defaults to @samp{()}.
  16375. @end deftypevr
  16376. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  16377. Sets encryption options. By default, CUPS only supports encryption
  16378. using TLS v1.0 or higher using known secure cipher suites. Security is
  16379. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  16380. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  16381. suites, which are required for some older clients. The @code{AllowSSL3} option
  16382. enables SSL v3.0, which is required for some older clients that do not support
  16383. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  16384. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  16385. protocol version to TLS v1.1.
  16386. Defaults to @samp{()}.
  16387. @end deftypevr
  16388. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  16389. Specifies whether the scheduler requires clients to strictly adhere to
  16390. the IPP specifications.
  16391. Defaults to @samp{#f}.
  16392. @end deftypevr
  16393. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  16394. Specifies the HTTP request timeout, in seconds.
  16395. Defaults to @samp{900}.
  16396. @end deftypevr
  16397. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  16398. Specifies whether the web interface is enabled.
  16399. Defaults to @samp{#f}.
  16400. @end deftypevr
  16401. At this point you're probably thinking ``oh dear, Guix manual, I like
  16402. you but you can stop already with the configuration options''. Indeed.
  16403. However, one more point: it could be that you have an existing
  16404. @code{cupsd.conf} that you want to use. In that case, you can pass an
  16405. @code{opaque-cups-configuration} as the configuration of a
  16406. @code{cups-service-type}.
  16407. Available @code{opaque-cups-configuration} fields are:
  16408. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  16409. The CUPS package.
  16410. @end deftypevr
  16411. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  16412. The contents of the @code{cupsd.conf}, as a string.
  16413. @end deftypevr
  16414. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  16415. The contents of the @code{cups-files.conf} file, as a string.
  16416. @end deftypevr
  16417. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  16418. strings of the same name, you could instantiate a CUPS service like
  16419. this:
  16420. @lisp
  16421. (service cups-service-type
  16422. (opaque-cups-configuration
  16423. (cupsd.conf cupsd.conf)
  16424. (cups-files.conf cups-files.conf)))
  16425. @end lisp
  16426. @node Desktop Services
  16427. @subsection Desktop Services
  16428. The @code{(gnu services desktop)} module provides services that are
  16429. usually useful in the context of a ``desktop'' setup---that is, on a
  16430. machine running a graphical display server, possibly with graphical user
  16431. interfaces, etc. It also defines services that provide specific desktop
  16432. environments like GNOME, Xfce or MATE.
  16433. To simplify things, the module defines a variable containing the set of
  16434. services that users typically expect on a machine with a graphical
  16435. environment and networking:
  16436. @defvr {Scheme Variable} %desktop-services
  16437. This is a list of services that builds upon @code{%base-services} and
  16438. adds or adjusts services for a typical ``desktop'' setup.
  16439. In particular, it adds a graphical login manager (@pxref{X Window,
  16440. @code{gdm-service-type}}), screen lockers, a network management tool
  16441. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  16442. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  16443. energy and color management services, the @code{elogind} login and seat
  16444. manager, the Polkit privilege service, the GeoClue location service, the
  16445. AccountsService daemon that allows authorized users change system passwords,
  16446. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  16447. name service switch service configured to be able to use @code{nss-mdns}
  16448. (@pxref{Name Service Switch, mDNS}).
  16449. @end defvr
  16450. The @code{%desktop-services} variable can be used as the @code{services}
  16451. field of an @code{operating-system} declaration (@pxref{operating-system
  16452. Reference, @code{services}}).
  16453. Additionally, the @code{gnome-desktop-service-type},
  16454. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  16455. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  16456. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  16457. ``add GNOME'' means that system-level services like the backlight adjustment
  16458. helpers and the power management utilities are added to the system, extending
  16459. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  16460. elevated privileges on a limited number of special-purpose system interfaces.
  16461. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  16462. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  16463. service not only adds the @code{xfce} metapackage to the system profile, but
  16464. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  16465. management window, if the user authenticates using the administrator's
  16466. password via the standard polkit graphical interface. To ``add MATE'' means
  16467. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  16468. to operate with elevated privileges on a limited number of special-purpose
  16469. system interfaces. Additionally, adding a service of type
  16470. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  16471. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  16472. appropriately, and several of Enlightenment's binaries are set as setuid,
  16473. allowing Enlightenment's screen locker and other functionality to work as
  16474. expected.
  16475. The desktop environments in Guix use the Xorg display server by
  16476. default. If you'd like to use the newer display server protocol
  16477. called Wayland, you need to enable Wayland support in GDM
  16478. (@pxref{wayland-gdm}). Another solution is to use the
  16479. @code{sddm-service} instead of GDM as the graphical login manager.
  16480. You should then select the ``GNOME (Wayland)'' session in SDDM@.
  16481. Alternatively you can also try starting GNOME on Wayland manually from a
  16482. TTY with the command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  16483. gnome-session``. Currently only GNOME has support for Wayland.
  16484. @defvr {Scheme Variable} gnome-desktop-service-type
  16485. This is the type of the service that adds the @uref{https://www.gnome.org,
  16486. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  16487. object (see below).
  16488. This service adds the @code{gnome} package to the system profile, and extends
  16489. polkit with the actions from @code{gnome-settings-daemon}.
  16490. @end defvr
  16491. @deftp {Data Type} gnome-desktop-configuration
  16492. Configuration record for the GNOME desktop environment.
  16493. @table @asis
  16494. @item @code{gnome} (default: @code{gnome})
  16495. The GNOME package to use.
  16496. @end table
  16497. @end deftp
  16498. @defvr {Scheme Variable} xfce-desktop-service-type
  16499. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  16500. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  16501. (see below).
  16502. This service adds the @code{xfce} package to the system profile, and
  16503. extends polkit with the ability for @code{thunar} to manipulate the file
  16504. system as root from within a user session, after the user has authenticated
  16505. with the administrator's password.
  16506. Note that @code{xfce4-panel} and its plugin packages should be installed in
  16507. the same profile to ensure compatibility. When using this service, you should
  16508. add extra plugins (@code{xfce4-whiskermenu-plugin},
  16509. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  16510. @code{operating-system}.
  16511. @end defvr
  16512. @deftp {Data Type} xfce-desktop-configuration
  16513. Configuration record for the Xfce desktop environment.
  16514. @table @asis
  16515. @item @code{xfce} (default: @code{xfce})
  16516. The Xfce package to use.
  16517. @end table
  16518. @end deftp
  16519. @deffn {Scheme Variable} mate-desktop-service-type
  16520. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  16521. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  16522. object (see below).
  16523. This service adds the @code{mate} package to the system
  16524. profile, and extends polkit with the actions from
  16525. @code{mate-settings-daemon}.
  16526. @end deffn
  16527. @deftp {Data Type} mate-desktop-configuration
  16528. Configuration record for the MATE desktop environment.
  16529. @table @asis
  16530. @item @code{mate} (default: @code{mate})
  16531. The MATE package to use.
  16532. @end table
  16533. @end deftp
  16534. @deffn {Scheme Variable} lxqt-desktop-service-type
  16535. This is the type of the service that runs the @uref{https://lxqt-project.org,
  16536. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  16537. object (see below).
  16538. This service adds the @code{lxqt} package to the system
  16539. profile.
  16540. @end deffn
  16541. @deftp {Data Type} lxqt-desktop-configuration
  16542. Configuration record for the LXQt desktop environment.
  16543. @table @asis
  16544. @item @code{lxqt} (default: @code{lxqt})
  16545. The LXQT package to use.
  16546. @end table
  16547. @end deftp
  16548. @deffn {Scheme Variable} enlightenment-desktop-service-type
  16549. Return a service that adds the @code{enlightenment} package to the system
  16550. profile, and extends dbus with actions from @code{efl}.
  16551. @end deffn
  16552. @deftp {Data Type} enlightenment-desktop-service-configuration
  16553. @table @asis
  16554. @item @code{enlightenment} (default: @code{enlightenment})
  16555. The enlightenment package to use.
  16556. @end table
  16557. @end deftp
  16558. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  16559. the default @code{%desktop-services} variable doesn't include any of
  16560. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  16561. @code{%desktop-services} in the @code{services} field of your
  16562. @code{operating-system}:
  16563. @lisp
  16564. (use-modules (gnu))
  16565. (use-service-modules desktop)
  16566. (operating-system
  16567. ...
  16568. ;; cons* adds items to the list given as its last argument.
  16569. (services (cons* (service gnome-desktop-service-type)
  16570. (service xfce-desktop-service)
  16571. %desktop-services))
  16572. ...)
  16573. @end lisp
  16574. These desktop environments will then be available as options in the
  16575. graphical login window.
  16576. The actual service definitions included in @code{%desktop-services} and
  16577. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  16578. are described below.
  16579. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  16580. Return a service that runs the ``system bus'', using @var{dbus}, with
  16581. support for @var{services}.
  16582. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  16583. facility. Its system bus is used to allow system services to communicate
  16584. and to be notified of system-wide events.
  16585. @var{services} must be a list of packages that provide an
  16586. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  16587. and policy files. For example, to allow avahi-daemon to use the system bus,
  16588. @var{services} must be equal to @code{(list avahi)}.
  16589. @end deffn
  16590. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  16591. Return a service that runs the @code{elogind} login and
  16592. seat management daemon. @uref{https://github.com/elogind/elogind,
  16593. Elogind} exposes a D-Bus interface that can be used to know which users
  16594. are logged in, know what kind of sessions they have open, suspend the
  16595. system, inhibit system suspend, reboot the system, and other tasks.
  16596. Elogind handles most system-level power events for a computer, for
  16597. example suspending the system when a lid is closed, or shutting it down
  16598. when the power button is pressed.
  16599. The @var{config} keyword argument specifies the configuration for
  16600. elogind, and should be the result of an @code{(elogind-configuration
  16601. (@var{parameter} @var{value})...)} invocation. Available parameters and
  16602. their default values are:
  16603. @table @code
  16604. @item kill-user-processes?
  16605. @code{#f}
  16606. @item kill-only-users
  16607. @code{()}
  16608. @item kill-exclude-users
  16609. @code{("root")}
  16610. @item inhibit-delay-max-seconds
  16611. @code{5}
  16612. @item handle-power-key
  16613. @code{poweroff}
  16614. @item handle-suspend-key
  16615. @code{suspend}
  16616. @item handle-hibernate-key
  16617. @code{hibernate}
  16618. @item handle-lid-switch
  16619. @code{suspend}
  16620. @item handle-lid-switch-docked
  16621. @code{ignore}
  16622. @item handle-lid-switch-external-power
  16623. @code{ignore}
  16624. @item power-key-ignore-inhibited?
  16625. @code{#f}
  16626. @item suspend-key-ignore-inhibited?
  16627. @code{#f}
  16628. @item hibernate-key-ignore-inhibited?
  16629. @code{#f}
  16630. @item lid-switch-ignore-inhibited?
  16631. @code{#t}
  16632. @item holdoff-timeout-seconds
  16633. @code{30}
  16634. @item idle-action
  16635. @code{ignore}
  16636. @item idle-action-seconds
  16637. @code{(* 30 60)}
  16638. @item runtime-directory-size-percent
  16639. @code{10}
  16640. @item runtime-directory-size
  16641. @code{#f}
  16642. @item remove-ipc?
  16643. @code{#t}
  16644. @item suspend-state
  16645. @code{("mem" "standby" "freeze")}
  16646. @item suspend-mode
  16647. @code{()}
  16648. @item hibernate-state
  16649. @code{("disk")}
  16650. @item hibernate-mode
  16651. @code{("platform" "shutdown")}
  16652. @item hybrid-sleep-state
  16653. @code{("disk")}
  16654. @item hybrid-sleep-mode
  16655. @code{("suspend" "platform" "shutdown")}
  16656. @end table
  16657. @end deffn
  16658. @deffn {Scheme Procedure} accountsservice-service @
  16659. [#:accountsservice @var{accountsservice}]
  16660. Return a service that runs AccountsService, a system service that can
  16661. list available accounts, change their passwords, and so on.
  16662. AccountsService integrates with PolicyKit to enable unprivileged users
  16663. to acquire the capability to modify their system configuration.
  16664. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  16665. accountsservice web site} for more information.
  16666. The @var{accountsservice} keyword argument is the @code{accountsservice}
  16667. package to expose as a service.
  16668. @end deffn
  16669. @deffn {Scheme Procedure} polkit-service @
  16670. [#:polkit @var{polkit}]
  16671. Return a service that runs the
  16672. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  16673. management service}, which allows system administrators to grant access to
  16674. privileged operations in a structured way. By querying the Polkit service, a
  16675. privileged system component can know when it should grant additional
  16676. capabilities to ordinary users. For example, an ordinary user can be granted
  16677. the capability to suspend the system if the user is logged in locally.
  16678. @end deffn
  16679. @defvr {Scheme Variable} polkit-wheel-service
  16680. Service that adds the @code{wheel} group as admins to the Polkit
  16681. service. This makes it so that users in the @code{wheel} group are queried
  16682. for their own passwords when performing administrative actions instead of
  16683. @code{root}'s, similar to the behaviour used by @code{sudo}.
  16684. @end defvr
  16685. @defvr {Scheme Variable} upower-service-type
  16686. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  16687. system-wide monitor for power consumption and battery levels, with the given
  16688. configuration settings.
  16689. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  16690. notably used by GNOME.
  16691. @end defvr
  16692. @deftp {Data Type} upower-configuration
  16693. Data type representation the configuration for UPower.
  16694. @table @asis
  16695. @item @code{upower} (default: @var{upower})
  16696. Package to use for @code{upower}.
  16697. @item @code{watts-up-pro?} (default: @code{#f})
  16698. Enable the Watts Up Pro device.
  16699. @item @code{poll-batteries?} (default: @code{#t})
  16700. Enable polling the kernel for battery level changes.
  16701. @item @code{ignore-lid?} (default: @code{#f})
  16702. Ignore the lid state, this can be useful if it's incorrect on a device.
  16703. @item @code{use-percentage-for-policy?} (default: @code{#f})
  16704. Whether battery percentage based policy should be used. The default is to use
  16705. the time left, change to @code{#t} to use the percentage.
  16706. @item @code{percentage-low} (default: @code{10})
  16707. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  16708. at which the battery is considered low.
  16709. @item @code{percentage-critical} (default: @code{3})
  16710. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  16711. at which the battery is considered critical.
  16712. @item @code{percentage-action} (default: @code{2})
  16713. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  16714. at which action will be taken.
  16715. @item @code{time-low} (default: @code{1200})
  16716. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  16717. seconds at which the battery is considered low.
  16718. @item @code{time-critical} (default: @code{300})
  16719. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  16720. seconds at which the battery is considered critical.
  16721. @item @code{time-action} (default: @code{120})
  16722. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  16723. seconds at which action will be taken.
  16724. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  16725. The action taken when @code{percentage-action} or @code{time-action} is
  16726. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  16727. Possible values are:
  16728. @itemize @bullet
  16729. @item
  16730. @code{'power-off}
  16731. @item
  16732. @code{'hibernate}
  16733. @item
  16734. @code{'hybrid-sleep}.
  16735. @end itemize
  16736. @end table
  16737. @end deftp
  16738. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  16739. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  16740. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  16741. with notifications and ways to mount/unmount disks. Programs that talk
  16742. to UDisks include the @command{udisksctl} command, part of UDisks, and
  16743. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  16744. it will only be able to use the file-system utilities installed in the
  16745. system profile. For example if you want to be able to mount NTFS
  16746. file-systems in read and write fashion, you'll need to have
  16747. @code{ntfs-3g} installed system-wide.
  16748. @end deffn
  16749. @deffn {Scheme Variable} colord-service-type
  16750. This is the type of the service that runs @command{colord}, a system
  16751. service with a D-Bus
  16752. interface to manage the color profiles of input and output devices such as
  16753. screens and scanners. It is notably used by the GNOME Color Manager graphical
  16754. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  16755. site} for more information.
  16756. @end deffn
  16757. @cindex scanner access
  16758. @defvr {Scheme Variable} sane-service-type
  16759. This service provides access to scanners @i{via}
  16760. @uref{http://www.sane-project.org, SANE} by installing the necessary
  16761. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  16762. Services}) and relies by default on @code{sane-backends-minimal} package
  16763. (see below) for hardware support.
  16764. @end defvr
  16765. @defvr {Scheme Variable} sane-backends-minimal
  16766. The default package which the @code{sane-service-type} installs. It
  16767. supports many recent scanners.
  16768. @end defvr
  16769. @defvr {Scheme Variable} sane-backends
  16770. This package includes support for all scanners that
  16771. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  16772. scanners supported by @code{hplip} package. In order to use this on
  16773. a system which relies on @code{%desktop-services}, you may use
  16774. @code{modify-services} (@pxref{Service Reference,
  16775. @code{modify-services}}) as illustrated below:
  16776. @lisp
  16777. (use-modules (gnu))
  16778. (use-service-modules
  16779. @dots{}
  16780. desktop)
  16781. (use-package-modules
  16782. @dots{}
  16783. scanner)
  16784. (define %my-desktop-services
  16785. ;; List of desktop services that supports a broader range of scanners.
  16786. (modify-services %desktop-services
  16787. (sane-service-type _ => sane-backends)))
  16788. (operating-system
  16789. @dots{}
  16790. (services %my-desktop-services))
  16791. @end lisp
  16792. @end defvr
  16793. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  16794. Return a configuration allowing an application to access GeoClue
  16795. location data. @var{name} is the Desktop ID of the application, without
  16796. the @code{.desktop} part. If @var{allowed?} is true, the application
  16797. will have access to location information by default. The boolean
  16798. @var{system?} value indicates whether an application is a system component
  16799. or not. Finally @var{users} is a list of UIDs of all users for which
  16800. this application is allowed location info access. An empty users list
  16801. means that all users are allowed.
  16802. @end deffn
  16803. @defvr {Scheme Variable} %standard-geoclue-applications
  16804. The standard list of well-known GeoClue application configurations,
  16805. granting authority to the GNOME date-and-time utility to ask for the
  16806. current location in order to set the time zone, and allowing the
  16807. IceCat and Epiphany web browsers to request location information.
  16808. IceCat and Epiphany both query the user before allowing a web page to
  16809. know the user's location.
  16810. @end defvr
  16811. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  16812. [#:whitelist '()] @
  16813. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  16814. [#:submit-data? #f]
  16815. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  16816. [#:submission-nick "geoclue"] @
  16817. [#:applications %standard-geoclue-applications]
  16818. Return a service that runs the GeoClue location service. This service
  16819. provides a D-Bus interface to allow applications to request access to a
  16820. user's physical location, and optionally to add information to online
  16821. location databases. See
  16822. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  16823. web site} for more information.
  16824. @end deffn
  16825. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  16826. [@w{#:auto-enable? #f}]
  16827. Return a service that runs the @command{bluetoothd} daemon, which
  16828. manages all the Bluetooth devices and provides a number of D-Bus
  16829. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  16830. powered automatically at boot, which can be useful when using a
  16831. bluetooth keyboard or mouse.
  16832. Users need to be in the @code{lp} group to access the D-Bus service.
  16833. @end deffn
  16834. @defvr {Scheme Variable} gnome-keyring-service-type
  16835. This is the type of the service that adds the
  16836. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  16837. value is a @code{gnome-keyring-configuration} object (see below).
  16838. This service adds the @code{gnome-keyring} package to the system profile
  16839. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  16840. a user's login keyring when they log in or setting its password with passwd.
  16841. @end defvr
  16842. @deftp {Data Type} gnome-keyring-configuration
  16843. Configuration record for the GNOME Keyring service.
  16844. @table @asis
  16845. @item @code{keyring} (default: @code{gnome-keyring})
  16846. The GNOME keyring package to use.
  16847. @item @code{pam-services}
  16848. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  16849. services to extend, where @var{service} is the name of an existing
  16850. service to extend and @var{kind} is one of @code{login} or
  16851. @code{passwd}.
  16852. If @code{login} is given, it adds an optional
  16853. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  16854. the session block with @code{auto_start}. If @code{passwd} is given, it
  16855. adds an optional @code{pam_gnome_keyring.so} to the password block
  16856. without arguments.
  16857. By default, this field contains ``gdm-password'' with the value @code{login}
  16858. and ``passwd'' is with the value @code{passwd}.
  16859. @end table
  16860. @end deftp
  16861. @node Sound Services
  16862. @subsection Sound Services
  16863. @cindex sound support
  16864. @cindex ALSA
  16865. @cindex PulseAudio, sound support
  16866. The @code{(gnu services sound)} module provides a service to configure the
  16867. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  16868. preferred ALSA output driver.
  16869. @deffn {Scheme Variable} alsa-service-type
  16870. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  16871. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  16872. configuration file. The value for this type is a @command{alsa-configuration}
  16873. record as in this example:
  16874. @lisp
  16875. (service alsa-service-type)
  16876. @end lisp
  16877. See below for details about @code{alsa-configuration}.
  16878. @end deffn
  16879. @deftp {Data Type} alsa-configuration
  16880. Data type representing the configuration for @code{alsa-service}.
  16881. @table @asis
  16882. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  16883. @code{alsa-plugins} package to use.
  16884. @item @code{pulseaudio?} (default: @var{#t})
  16885. Whether ALSA applications should transparently be made to use the
  16886. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  16887. Using PulseAudio allows you to run several sound-producing applications
  16888. at the same time and to individual control them @i{via}
  16889. @command{pavucontrol}, among other things.
  16890. @item @code{extra-options} (default: @var{""})
  16891. String to append to the @file{/etc/asound.conf} file.
  16892. @end table
  16893. @end deftp
  16894. Individual users who want to override the system configuration of ALSA can do
  16895. it with the @file{~/.asoundrc} file:
  16896. @example
  16897. # In guix, we have to specify the absolute path for plugins.
  16898. pcm_type.jack @{
  16899. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  16900. @}
  16901. # Routing ALSA to jack:
  16902. # <http://jackaudio.org/faq/routing_alsa.html>.
  16903. pcm.rawjack @{
  16904. type jack
  16905. playback_ports @{
  16906. 0 system:playback_1
  16907. 1 system:playback_2
  16908. @}
  16909. capture_ports @{
  16910. 0 system:capture_1
  16911. 1 system:capture_2
  16912. @}
  16913. @}
  16914. pcm.!default @{
  16915. type plug
  16916. slave @{
  16917. pcm "rawjack"
  16918. @}
  16919. @}
  16920. @end example
  16921. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  16922. details.
  16923. @deffn {Scheme Variable} pulseaudio-service-type
  16924. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  16925. sound server. It exists to allow system overrides of the default settings
  16926. via @code{pulseaudio-configuration}, see below.
  16927. @quotation Warning
  16928. This service overrides per-user configuration files. If you want
  16929. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  16930. have to unset the environment variables @env{PULSE_CONFIG} and
  16931. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  16932. @end quotation
  16933. @quotation Warning
  16934. This service on its own does not ensure, that the @code{pulseaudio} package
  16935. exists on your machine. It merely adds configuration files for it, as
  16936. detailed below. In the (admittedly unlikely) case, that you find yourself
  16937. without a @code{pulseaudio} package, consider enabling it through the
  16938. @code{alsa-service-type} above.
  16939. @end quotation
  16940. @end deffn
  16941. @deftp {Data Type} pulseaudio-configuration
  16942. Data type representing the configuration for @code{pulseaudio-service}.
  16943. @table @asis
  16944. @item @code{client-conf} (default: @code{'()})
  16945. List of settings to set in @file{client.conf}.
  16946. Accepts a list of strings or a symbol-value pairs. A string will be
  16947. inserted as-is with a newline added. A pair will be formatted as
  16948. ``key = value'', again with a newline added.
  16949. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  16950. List of settings to set in @file{daemon.conf}, formatted just like
  16951. @var{client-conf}.
  16952. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  16953. Script file to use as @file{default.pa}.
  16954. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  16955. Script file to use as @file{system.pa}.
  16956. @end table
  16957. @end deftp
  16958. @deffn {Scheme Variable} ladspa-service-type
  16959. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  16960. respect it, e.g. PulseAudio, can load LADSPA plugins.
  16961. The following example will setup the service to enable modules from the
  16962. @code{swh-plugins} package:
  16963. @lisp
  16964. (service ladspa-service-type
  16965. (ladspa-configuration (plugins (list swh-plugins))))
  16966. @end lisp
  16967. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  16968. details.
  16969. @end deffn
  16970. @node Database Services
  16971. @subsection Database Services
  16972. @cindex database
  16973. @cindex SQL
  16974. The @code{(gnu services databases)} module provides the following services.
  16975. @subsubheading PostgreSQL
  16976. The following example describes a PostgreSQL service with the default
  16977. configuration.
  16978. @lisp
  16979. (service postgresql-service-type
  16980. (postgresql-configuration
  16981. (postgresql postgresql-10)))
  16982. @end lisp
  16983. If the services fails to start, it may be due to an incompatible
  16984. cluster already present in @var{data-directory}. Adjust it (or, if you
  16985. don't need the cluster anymore, delete @var{data-directory}), then
  16986. restart the service.
  16987. Peer authentication is used by default and the @code{postgres} user
  16988. account has no shell, which prevents the direct execution of @code{psql}
  16989. commands as this user. To use @code{psql}, you can temporarily log in
  16990. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  16991. same name as one of the system users and then create the associated
  16992. database.
  16993. @example
  16994. sudo -u postgres -s /bin/sh
  16995. createuser --interactive
  16996. createdb $MY_USER_LOGIN # Replace appropriately.
  16997. @end example
  16998. @deftp {Data Type} postgresql-configuration
  16999. Data type representing the configuration for the
  17000. @code{postgresql-service-type}.
  17001. @table @asis
  17002. @item @code{postgresql}
  17003. PostgreSQL package to use for the service.
  17004. @item @code{port} (default: @code{5432})
  17005. Port on which PostgreSQL should listen.
  17006. @item @code{locale} (default: @code{"en_US.utf8"})
  17007. Locale to use as the default when creating the database cluster.
  17008. @item @code{config-file} (default: @code{(postgresql-config-file)})
  17009. The configuration file to use when running PostgreSQL@. The default
  17010. behaviour uses the postgresql-config-file record with the default values
  17011. for the fields.
  17012. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  17013. The directory where @command{pg_ctl} output will be written in a file
  17014. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  17015. configuration errors for instance.
  17016. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  17017. Directory in which to store the data.
  17018. @item @code{extension-packages} (default: @code{'()})
  17019. @cindex postgresql extension-packages
  17020. Additional extensions are loaded from packages listed in
  17021. @var{extension-packages}. Extensions are available at runtime. For instance,
  17022. to create a geographic database using the @code{postgis} extension, a user can
  17023. configure the postgresql-service as in this example:
  17024. @cindex postgis
  17025. @lisp
  17026. (use-package-modules databases geo)
  17027. (operating-system
  17028. ...
  17029. ;; postgresql is required to run `psql' but postgis is not required for
  17030. ;; proper operation.
  17031. (packages (cons* postgresql %base-packages))
  17032. (services
  17033. (cons*
  17034. (service postgresql-service-type
  17035. (postgresql-configuration
  17036. (postgresql postgresql-10)
  17037. (extension-packages (list postgis))))
  17038. %base-services)))
  17039. @end lisp
  17040. Then the extension becomes visible and you can initialise an empty geographic
  17041. database in this way:
  17042. @example
  17043. psql -U postgres
  17044. > create database postgistest;
  17045. > \connect postgistest;
  17046. > create extension postgis;
  17047. > create extension postgis_topology;
  17048. @end example
  17049. There is no need to add this field for contrib extensions such as hstore or
  17050. dblink as they are already loadable by postgresql. This field is only
  17051. required to add extensions provided by other packages.
  17052. @end table
  17053. @end deftp
  17054. @deftp {Data Type} postgresql-config-file
  17055. Data type representing the PostgreSQL configuration file. As shown in
  17056. the following example, this can be used to customize the configuration
  17057. of PostgreSQL@. Note that you can use any G-expression or filename in
  17058. place of this record, if you already have a configuration file you'd
  17059. like to use for example.
  17060. @lisp
  17061. (service postgresql-service-type
  17062. (postgresql-configuration
  17063. (config-file
  17064. (postgresql-config-file
  17065. (log-destination "stderr")
  17066. (hba-file
  17067. (plain-file "pg_hba.conf"
  17068. "
  17069. local all all trust
  17070. host all all 127.0.0.1/32 md5
  17071. host all all ::1/128 md5"))
  17072. (extra-config
  17073. '(("session_preload_libraries" "auto_explain")
  17074. ("random_page_cost" 2)
  17075. ("auto_explain.log_min_duration" "100 ms")
  17076. ("work_mem" "500 MB")
  17077. ("logging_collector" #t)
  17078. ("log_directory" "/var/log/postgresql")))))))
  17079. @end lisp
  17080. @table @asis
  17081. @item @code{log-destination} (default: @code{"syslog"})
  17082. The logging method to use for PostgreSQL@. Multiple values are accepted,
  17083. separated by commas.
  17084. @item @code{hba-file} (default: @code{%default-postgres-hba})
  17085. Filename or G-expression for the host-based authentication
  17086. configuration.
  17087. @item @code{ident-file} (default: @code{%default-postgres-ident})
  17088. Filename or G-expression for the user name mapping configuration.
  17089. @item @code{socket-directory} (default: @code{"/var/run/postgresql"})
  17090. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  17091. is to listen for connections from client applications. If set to
  17092. @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
  17093. which case only TCP/IP sockets can be used to connect to the server.
  17094. By default, the @code{#false} value means the PostgreSQL default value
  17095. will be used, which is currently @samp{/tmp}.
  17096. @item @code{extra-config} (default: @code{'()})
  17097. List of additional keys and values to include in the PostgreSQL config
  17098. file. Each entry in the list should be a list where the first element
  17099. is the key, and the remaining elements are the values.
  17100. The values can be numbers, booleans or strings and will be mapped to
  17101. PostgreSQL parameters types @code{Boolean}, @code{String},
  17102. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  17103. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  17104. here}.
  17105. @end table
  17106. @end deftp
  17107. @deffn {Scheme Variable} postgresql-role-service-type
  17108. This service allows to create PostgreSQL roles and databases after
  17109. PostgreSQL service start. Here is an example of its use.
  17110. @lisp
  17111. (service postgresql-role-service-type
  17112. (postgresql-role-configuration
  17113. (roles
  17114. (list (postgresql-role
  17115. (name "test")
  17116. (create-database? #t))))))
  17117. @end lisp
  17118. This service can be extended with extra roles, as in this
  17119. example:
  17120. @lisp
  17121. (service-extension postgresql-role-service-type
  17122. (const (postgresql-role
  17123. (name "alice")
  17124. (create-database? #t))))
  17125. @end lisp
  17126. @end deffn
  17127. @deftp {Data Type} postgresql-role
  17128. PostgreSQL manages database access permissions using the concept of
  17129. roles. A role can be thought of as either a database user, or a group
  17130. of database users, depending on how the role is set up. Roles can own
  17131. database objects (for example, tables) and can assign privileges on
  17132. those objects to other roles to control who has access to which objects.
  17133. @table @asis
  17134. @item @code{name}
  17135. The role name.
  17136. @item @code{permissions} (default: @code{'(createdb login)})
  17137. The role permissions list. Supported permissions are @code{bypassrls},
  17138. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  17139. @code{superuser}.
  17140. @item @code{create-database?} (default: @code{#f})
  17141. Whether to create a database with the same name as the role.
  17142. @end table
  17143. @end deftp
  17144. @deftp {Data Type} postgresql-role-configuration
  17145. Data type representing the configuration of
  17146. @var{postgresql-role-service-type}.
  17147. @table @asis
  17148. @item @code{host} (default: @code{"/var/run/postgresql"})
  17149. The PostgreSQL host to connect to.
  17150. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  17151. File name of the log file.
  17152. @item @code{roles} (default: @code{'()})
  17153. The initial PostgreSQL roles to create.
  17154. @end table
  17155. @end deftp
  17156. @subsubheading MariaDB/MySQL
  17157. @defvr {Scheme Variable} mysql-service-type
  17158. This is the service type for a MySQL or MariaDB database server. Its value
  17159. is a @code{mysql-configuration} object that specifies which package to use,
  17160. as well as various settings for the @command{mysqld} daemon.
  17161. @end defvr
  17162. @deftp {Data Type} mysql-configuration
  17163. Data type representing the configuration of @var{mysql-service-type}.
  17164. @table @asis
  17165. @item @code{mysql} (default: @var{mariadb})
  17166. Package object of the MySQL database server, can be either @var{mariadb}
  17167. or @var{mysql}.
  17168. For MySQL, a temporary root password will be displayed at activation time.
  17169. For MariaDB, the root password is empty.
  17170. @item @code{bind-address} (default: @code{"127.0.0.1"})
  17171. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  17172. to bind to all available network interfaces.
  17173. @item @code{port} (default: @code{3306})
  17174. TCP port on which the database server listens for incoming connections.
  17175. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  17176. Socket file to use for local (non-network) connections.
  17177. @item @code{extra-content} (default: @code{""})
  17178. Additional settings for the @file{my.cnf} configuration file.
  17179. @item @code{extra-environment} (default: @code{#~'()})
  17180. List of environment variables passed to the @command{mysqld} process.
  17181. @item @code{auto-upgrade?} (default: @code{#t})
  17182. Whether to automatically run @command{mysql_upgrade} after starting the
  17183. service. This is necessary to upgrade the @dfn{system schema} after
  17184. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  17185. be disabled if you would rather do that manually.
  17186. @end table
  17187. @end deftp
  17188. @subsubheading Memcached
  17189. @defvr {Scheme Variable} memcached-service-type
  17190. This is the service type for the @uref{https://memcached.org/,
  17191. Memcached} service, which provides a distributed in memory cache. The
  17192. value for the service type is a @code{memcached-configuration} object.
  17193. @end defvr
  17194. @lisp
  17195. (service memcached-service-type)
  17196. @end lisp
  17197. @deftp {Data Type} memcached-configuration
  17198. Data type representing the configuration of memcached.
  17199. @table @asis
  17200. @item @code{memcached} (default: @code{memcached})
  17201. The Memcached package to use.
  17202. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  17203. Network interfaces on which to listen.
  17204. @item @code{tcp-port} (default: @code{11211})
  17205. Port on which to accept connections.
  17206. @item @code{udp-port} (default: @code{11211})
  17207. Port on which to accept UDP connections on, a value of 0 will disable
  17208. listening on a UDP socket.
  17209. @item @code{additional-options} (default: @code{'()})
  17210. Additional command line options to pass to @code{memcached}.
  17211. @end table
  17212. @end deftp
  17213. @subsubheading Redis
  17214. @defvr {Scheme Variable} redis-service-type
  17215. This is the service type for the @uref{https://redis.io/, Redis}
  17216. key/value store, whose value is a @code{redis-configuration} object.
  17217. @end defvr
  17218. @deftp {Data Type} redis-configuration
  17219. Data type representing the configuration of redis.
  17220. @table @asis
  17221. @item @code{redis} (default: @code{redis})
  17222. The Redis package to use.
  17223. @item @code{bind} (default: @code{"127.0.0.1"})
  17224. Network interface on which to listen.
  17225. @item @code{port} (default: @code{6379})
  17226. Port on which to accept connections on, a value of 0 will disable
  17227. listening on a TCP socket.
  17228. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  17229. Directory in which to store the database and related files.
  17230. @end table
  17231. @end deftp
  17232. @node Mail Services
  17233. @subsection Mail Services
  17234. @cindex mail
  17235. @cindex email
  17236. The @code{(gnu services mail)} module provides Guix service definitions
  17237. for email services: IMAP, POP3, and LMTP servers, as well as mail
  17238. transport agents (MTAs). Lots of acronyms! These services are detailed
  17239. in the subsections below.
  17240. @subsubheading Dovecot Service
  17241. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  17242. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  17243. @end deffn
  17244. By default, Dovecot does not need much configuration; the default
  17245. configuration object created by @code{(dovecot-configuration)} will
  17246. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  17247. certificate will be generated for TLS-protected connections, though
  17248. Dovecot will also listen on cleartext ports by default. There are a
  17249. number of options, though, which mail administrators might need to change,
  17250. and as is the case with other services, Guix allows the system
  17251. administrator to specify these parameters via a uniform Scheme interface.
  17252. For example, to specify that mail is located at @code{maildir~/.mail},
  17253. one would instantiate the Dovecot service like this:
  17254. @lisp
  17255. (dovecot-service #:config
  17256. (dovecot-configuration
  17257. (mail-location "maildir:~/.mail")))
  17258. @end lisp
  17259. The available configuration parameters follow. Each parameter
  17260. definition is preceded by its type; for example, @samp{string-list foo}
  17261. indicates that the @code{foo} parameter should be specified as a list of
  17262. strings. There is also a way to specify the configuration as a string,
  17263. if you have an old @code{dovecot.conf} file that you want to port over
  17264. from some other system; see the end for more details.
  17265. @c The following documentation was initially generated by
  17266. @c (generate-documentation) in (gnu services mail). Manually maintained
  17267. @c documentation is better, so we shouldn't hesitate to edit below as
  17268. @c needed. However if the change you want to make to this documentation
  17269. @c can be done in an automated way, it's probably easier to change
  17270. @c (generate-documentation) than to make it below and have to deal with
  17271. @c the churn as dovecot updates.
  17272. Available @code{dovecot-configuration} fields are:
  17273. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  17274. The dovecot package.
  17275. @end deftypevr
  17276. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  17277. A list of IPs or hosts where to listen for connections. @samp{*}
  17278. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  17279. interfaces. If you want to specify non-default ports or anything more
  17280. complex, customize the address and port fields of the
  17281. @samp{inet-listener} of the specific services you are interested in.
  17282. @end deftypevr
  17283. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  17284. List of protocols we want to serve. Available protocols include
  17285. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  17286. Available @code{protocol-configuration} fields are:
  17287. @deftypevr {@code{protocol-configuration} parameter} string name
  17288. The name of the protocol.
  17289. @end deftypevr
  17290. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  17291. UNIX socket path to the master authentication server to find users.
  17292. This is used by imap (for shared users) and lda.
  17293. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  17294. @end deftypevr
  17295. @deftypevr {@code{protocol-configuration} parameter} boolean imap-metadata?
  17296. Whether to enable the @code{IMAP METADATA} extension as defined in
  17297. @uref{https://tools.ietf.org/html/rfc5464,RFC@tie{}5464}, which provides
  17298. a means for clients to set and retrieve per-mailbox, per-user metadata
  17299. and annotations over IMAP.
  17300. If this is @samp{#t}, you must also specify a dictionary @i{via} the
  17301. @code{mail-attribute-dict} setting.
  17302. Defaults to @samp{#f}.
  17303. @end deftypevr
  17304. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-notify-capabilities
  17305. Which NOTIFY capabilities to report to clients that first connect to
  17306. the ManageSieve service, before authentication. These may differ from the
  17307. capabilities offered to authenticated users. If this field is left empty,
  17308. report what the Sieve interpreter supports by default.
  17309. Defaults to @samp{()}.
  17310. @end deftypevr
  17311. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-sieve-capability
  17312. Which SIEVE capabilities to report to clients that first connect to
  17313. the ManageSieve service, before authentication. These may differ from the
  17314. capabilities offered to authenticated users. If this field is left empty,
  17315. report what the Sieve interpreter supports by default.
  17316. Defaults to @samp{()}.
  17317. @end deftypevr
  17318. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  17319. Space separated list of plugins to load.
  17320. @end deftypevr
  17321. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  17322. Maximum number of IMAP connections allowed for a user from each IP
  17323. address. NOTE: The username is compared case-sensitively.
  17324. Defaults to @samp{10}.
  17325. @end deftypevr
  17326. @end deftypevr
  17327. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  17328. List of services to enable. Available services include @samp{imap},
  17329. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  17330. @samp{lmtp}.
  17331. Available @code{service-configuration} fields are:
  17332. @deftypevr {@code{service-configuration} parameter} string kind
  17333. The service kind. Valid values include @code{director},
  17334. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  17335. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  17336. @code{tcpwrap}, @code{quota-warning}, or anything else.
  17337. @end deftypevr
  17338. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  17339. Listeners for the service. A listener is either a
  17340. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  17341. an @code{inet-listener-configuration}.
  17342. Defaults to @samp{()}.
  17343. Available @code{unix-listener-configuration} fields are:
  17344. @deftypevr {@code{unix-listener-configuration} parameter} string path
  17345. Path to the file, relative to @code{base-dir} field. This is also used as
  17346. the section name.
  17347. @end deftypevr
  17348. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  17349. The access mode for the socket.
  17350. Defaults to @samp{"0600"}.
  17351. @end deftypevr
  17352. @deftypevr {@code{unix-listener-configuration} parameter} string user
  17353. The user to own the socket.
  17354. Defaults to @samp{""}.
  17355. @end deftypevr
  17356. @deftypevr {@code{unix-listener-configuration} parameter} string group
  17357. The group to own the socket.
  17358. Defaults to @samp{""}.
  17359. @end deftypevr
  17360. Available @code{fifo-listener-configuration} fields are:
  17361. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  17362. Path to the file, relative to @code{base-dir} field. This is also used as
  17363. the section name.
  17364. @end deftypevr
  17365. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  17366. The access mode for the socket.
  17367. Defaults to @samp{"0600"}.
  17368. @end deftypevr
  17369. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  17370. The user to own the socket.
  17371. Defaults to @samp{""}.
  17372. @end deftypevr
  17373. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  17374. The group to own the socket.
  17375. Defaults to @samp{""}.
  17376. @end deftypevr
  17377. Available @code{inet-listener-configuration} fields are:
  17378. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  17379. The protocol to listen for.
  17380. @end deftypevr
  17381. @deftypevr {@code{inet-listener-configuration} parameter} string address
  17382. The address on which to listen, or empty for all addresses.
  17383. Defaults to @samp{""}.
  17384. @end deftypevr
  17385. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  17386. The port on which to listen.
  17387. @end deftypevr
  17388. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  17389. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  17390. @samp{required}.
  17391. Defaults to @samp{#t}.
  17392. @end deftypevr
  17393. @end deftypevr
  17394. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  17395. Maximum number of simultaneous client connections per process. Once
  17396. this number of connections is received, the next incoming connection
  17397. will prompt Dovecot to spawn another process. If set to 0,
  17398. @code{default-client-limit} is used instead.
  17399. Defaults to @samp{0}.
  17400. @end deftypevr
  17401. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  17402. Number of connections to handle before starting a new process.
  17403. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  17404. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  17405. Defaults to @samp{1}.
  17406. @end deftypevr
  17407. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  17408. Maximum number of processes that can exist for this service. If set to
  17409. 0, @code{default-process-limit} is used instead.
  17410. Defaults to @samp{0}.
  17411. @end deftypevr
  17412. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  17413. Number of processes to always keep waiting for more connections.
  17414. Defaults to @samp{0}.
  17415. @end deftypevr
  17416. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  17417. If you set @samp{service-count 0}, you probably need to grow
  17418. this.
  17419. Defaults to @samp{256000000}.
  17420. @end deftypevr
  17421. @end deftypevr
  17422. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  17423. Dict configuration, as created by the @code{dict-configuration}
  17424. constructor.
  17425. Available @code{dict-configuration} fields are:
  17426. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  17427. A list of key-value pairs that this dict should hold.
  17428. Defaults to @samp{()}.
  17429. @end deftypevr
  17430. @end deftypevr
  17431. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  17432. A list of passdb configurations, each one created by the
  17433. @code{passdb-configuration} constructor.
  17434. Available @code{passdb-configuration} fields are:
  17435. @deftypevr {@code{passdb-configuration} parameter} string driver
  17436. The driver that the passdb should use. Valid values include
  17437. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  17438. @samp{static}.
  17439. Defaults to @samp{"pam"}.
  17440. @end deftypevr
  17441. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  17442. Space separated list of arguments to the passdb driver.
  17443. Defaults to @samp{""}.
  17444. @end deftypevr
  17445. @end deftypevr
  17446. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  17447. List of userdb configurations, each one created by the
  17448. @code{userdb-configuration} constructor.
  17449. Available @code{userdb-configuration} fields are:
  17450. @deftypevr {@code{userdb-configuration} parameter} string driver
  17451. The driver that the userdb should use. Valid values include
  17452. @samp{passwd} and @samp{static}.
  17453. Defaults to @samp{"passwd"}.
  17454. @end deftypevr
  17455. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  17456. Space separated list of arguments to the userdb driver.
  17457. Defaults to @samp{""}.
  17458. @end deftypevr
  17459. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  17460. Override fields from passwd.
  17461. Defaults to @samp{()}.
  17462. @end deftypevr
  17463. @end deftypevr
  17464. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  17465. Plug-in configuration, created by the @code{plugin-configuration}
  17466. constructor.
  17467. @end deftypevr
  17468. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  17469. List of namespaces. Each item in the list is created by the
  17470. @code{namespace-configuration} constructor.
  17471. Available @code{namespace-configuration} fields are:
  17472. @deftypevr {@code{namespace-configuration} parameter} string name
  17473. Name for this namespace.
  17474. @end deftypevr
  17475. @deftypevr {@code{namespace-configuration} parameter} string type
  17476. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  17477. Defaults to @samp{"private"}.
  17478. @end deftypevr
  17479. @deftypevr {@code{namespace-configuration} parameter} string separator
  17480. Hierarchy separator to use. You should use the same separator for
  17481. all namespaces or some clients get confused. @samp{/} is usually a good
  17482. one. The default however depends on the underlying mail storage
  17483. format.
  17484. Defaults to @samp{""}.
  17485. @end deftypevr
  17486. @deftypevr {@code{namespace-configuration} parameter} string prefix
  17487. Prefix required to access this namespace. This needs to be
  17488. different for all namespaces. For example @samp{Public/}.
  17489. Defaults to @samp{""}.
  17490. @end deftypevr
  17491. @deftypevr {@code{namespace-configuration} parameter} string location
  17492. Physical location of the mailbox. This is in the same format as
  17493. mail_location, which is also the default for it.
  17494. Defaults to @samp{""}.
  17495. @end deftypevr
  17496. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  17497. There can be only one INBOX, and this setting defines which
  17498. namespace has it.
  17499. Defaults to @samp{#f}.
  17500. @end deftypevr
  17501. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  17502. If namespace is hidden, it's not advertised to clients via NAMESPACE
  17503. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  17504. useful when converting from another server with different namespaces
  17505. which you want to deprecate but still keep working. For example you can
  17506. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  17507. and @samp{mail/}.
  17508. Defaults to @samp{#f}.
  17509. @end deftypevr
  17510. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  17511. Show the mailboxes under this namespace with the LIST command. This
  17512. makes the namespace visible for clients that do not support the NAMESPACE
  17513. extension. The special @code{children} value lists child mailboxes, but
  17514. hides the namespace prefix.
  17515. Defaults to @samp{#t}.
  17516. @end deftypevr
  17517. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  17518. Namespace handles its own subscriptions. If set to @code{#f}, the
  17519. parent namespace handles them. The empty prefix should always have this
  17520. as @code{#t}).
  17521. Defaults to @samp{#t}.
  17522. @end deftypevr
  17523. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  17524. List of predefined mailboxes in this namespace.
  17525. Defaults to @samp{()}.
  17526. Available @code{mailbox-configuration} fields are:
  17527. @deftypevr {@code{mailbox-configuration} parameter} string name
  17528. Name for this mailbox.
  17529. @end deftypevr
  17530. @deftypevr {@code{mailbox-configuration} parameter} string auto
  17531. @samp{create} will automatically create this mailbox.
  17532. @samp{subscribe} will both create and subscribe to the mailbox.
  17533. Defaults to @samp{"no"}.
  17534. @end deftypevr
  17535. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  17536. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  17537. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  17538. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  17539. Defaults to @samp{()}.
  17540. @end deftypevr
  17541. @end deftypevr
  17542. @end deftypevr
  17543. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  17544. Base directory where to store runtime data.
  17545. Defaults to @samp{"/var/run/dovecot/"}.
  17546. @end deftypevr
  17547. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  17548. Greeting message for clients.
  17549. Defaults to @samp{"Dovecot ready."}.
  17550. @end deftypevr
  17551. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  17552. List of trusted network ranges. Connections from these IPs are
  17553. allowed to override their IP addresses and ports (for logging and for
  17554. authentication checks). @samp{disable-plaintext-auth} is also ignored
  17555. for these networks. Typically you would specify your IMAP proxy servers
  17556. here.
  17557. Defaults to @samp{()}.
  17558. @end deftypevr
  17559. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  17560. List of login access check sockets (e.g.@: tcpwrap).
  17561. Defaults to @samp{()}.
  17562. @end deftypevr
  17563. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  17564. Show more verbose process titles (in ps). Currently shows user name
  17565. and IP address. Useful for seeing who is actually using the IMAP
  17566. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  17567. accounts).
  17568. Defaults to @samp{#f}.
  17569. @end deftypevr
  17570. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  17571. Should all processes be killed when Dovecot master process shuts down.
  17572. Setting this to @code{#f} means that Dovecot can be upgraded without
  17573. forcing existing client connections to close (although that could also
  17574. be a problem if the upgrade is e.g.@: due to a security fix).
  17575. Defaults to @samp{#t}.
  17576. @end deftypevr
  17577. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  17578. If non-zero, run mail commands via this many connections to doveadm
  17579. server, instead of running them directly in the same process.
  17580. Defaults to @samp{0}.
  17581. @end deftypevr
  17582. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  17583. UNIX socket or host:port used for connecting to doveadm server.
  17584. Defaults to @samp{"doveadm-server"}.
  17585. @end deftypevr
  17586. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  17587. List of environment variables that are preserved on Dovecot startup
  17588. and passed down to all of its child processes. You can also give
  17589. key=value pairs to always set specific settings.
  17590. @end deftypevr
  17591. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  17592. Disable LOGIN command and all other plaintext authentications unless
  17593. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  17594. matches the local IP (i.e.@: you're connecting from the same computer),
  17595. the connection is considered secure and plaintext authentication is
  17596. allowed. See also ssl=required setting.
  17597. Defaults to @samp{#t}.
  17598. @end deftypevr
  17599. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  17600. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  17601. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  17602. for caching to be used.
  17603. Defaults to @samp{0}.
  17604. @end deftypevr
  17605. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  17606. Time to live for cached data. After TTL expires the cached record
  17607. is no longer used, *except* if the main database lookup returns internal
  17608. failure. We also try to handle password changes automatically: If
  17609. user's previous authentication was successful, but this one wasn't, the
  17610. cache isn't used. For now this works only with plaintext
  17611. authentication.
  17612. Defaults to @samp{"1 hour"}.
  17613. @end deftypevr
  17614. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  17615. TTL for negative hits (user not found, password mismatch).
  17616. 0 disables caching them completely.
  17617. Defaults to @samp{"1 hour"}.
  17618. @end deftypevr
  17619. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  17620. List of realms for SASL authentication mechanisms that need them.
  17621. You can leave it empty if you don't want to support multiple realms.
  17622. Many clients simply use the first one listed here, so keep the default
  17623. realm first.
  17624. Defaults to @samp{()}.
  17625. @end deftypevr
  17626. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  17627. Default realm/domain to use if none was specified. This is used for
  17628. both SASL realms and appending @@domain to username in plaintext
  17629. logins.
  17630. Defaults to @samp{""}.
  17631. @end deftypevr
  17632. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  17633. List of allowed characters in username. If the user-given username
  17634. contains a character not listed in here, the login automatically fails.
  17635. This is just an extra check to make sure user can't exploit any
  17636. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  17637. you want to allow all characters, set this value to empty.
  17638. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  17639. @end deftypevr
  17640. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  17641. Username character translations before it's looked up from
  17642. databases. The value contains series of from -> to characters. For
  17643. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  17644. translated to @samp{@@}.
  17645. Defaults to @samp{""}.
  17646. @end deftypevr
  17647. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  17648. Username formatting before it's looked up from databases. You can
  17649. use the standard variables here, e.g.@: %Lu would lowercase the username,
  17650. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  17651. change the @samp{@@} into @samp{-AT-}. This translation is done after
  17652. @samp{auth-username-translation} changes.
  17653. Defaults to @samp{"%Lu"}.
  17654. @end deftypevr
  17655. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  17656. If you want to allow master users to log in by specifying the master
  17657. username within the normal username string (i.e.@: not using SASL
  17658. mechanism's support for it), you can specify the separator character
  17659. here. The format is then <username><separator><master username>.
  17660. UW-IMAP uses @samp{*} as the separator, so that could be a good
  17661. choice.
  17662. Defaults to @samp{""}.
  17663. @end deftypevr
  17664. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  17665. Username to use for users logging in with ANONYMOUS SASL
  17666. mechanism.
  17667. Defaults to @samp{"anonymous"}.
  17668. @end deftypevr
  17669. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  17670. Maximum number of dovecot-auth worker processes. They're used to
  17671. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  17672. They're automatically created and destroyed as needed.
  17673. Defaults to @samp{30}.
  17674. @end deftypevr
  17675. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  17676. Host name to use in GSSAPI principal names. The default is to use
  17677. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  17678. allow all keytab entries.
  17679. Defaults to @samp{""}.
  17680. @end deftypevr
  17681. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  17682. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  17683. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  17684. need to change the auth service to run as root to be able to read this
  17685. file.
  17686. Defaults to @samp{""}.
  17687. @end deftypevr
  17688. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  17689. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  17690. and @samp{ntlm-auth} helper.
  17691. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  17692. Defaults to @samp{#f}.
  17693. @end deftypevr
  17694. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  17695. Path for Samba's @samp{ntlm-auth} helper binary.
  17696. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  17697. @end deftypevr
  17698. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  17699. Time to delay before replying to failed authentications.
  17700. Defaults to @samp{"2 secs"}.
  17701. @end deftypevr
  17702. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  17703. Require a valid SSL client certificate or the authentication
  17704. fails.
  17705. Defaults to @samp{#f}.
  17706. @end deftypevr
  17707. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  17708. Take the username from client's SSL certificate, using
  17709. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  17710. CommonName.
  17711. Defaults to @samp{#f}.
  17712. @end deftypevr
  17713. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  17714. List of wanted authentication mechanisms. Supported mechanisms are:
  17715. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  17716. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  17717. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  17718. @samp{disable-plaintext-auth} setting.
  17719. @end deftypevr
  17720. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  17721. List of IPs or hostnames to all director servers, including ourself.
  17722. Ports can be specified as ip:port. The default port is the same as what
  17723. director service's @samp{inet-listener} is using.
  17724. Defaults to @samp{()}.
  17725. @end deftypevr
  17726. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  17727. List of IPs or hostnames to all backend mail servers. Ranges are
  17728. allowed too, like 10.0.0.10-10.0.0.30.
  17729. Defaults to @samp{()}.
  17730. @end deftypevr
  17731. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  17732. How long to redirect users to a specific server after it no longer
  17733. has any connections.
  17734. Defaults to @samp{"15 min"}.
  17735. @end deftypevr
  17736. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  17737. How the username is translated before being hashed. Useful values
  17738. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  17739. are shared within domain.
  17740. Defaults to @samp{"%Lu"}.
  17741. @end deftypevr
  17742. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  17743. Log file to use for error messages. @samp{syslog} logs to syslog,
  17744. @samp{/dev/stderr} logs to stderr.
  17745. Defaults to @samp{"syslog"}.
  17746. @end deftypevr
  17747. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  17748. Log file to use for informational messages. Defaults to
  17749. @samp{log-path}.
  17750. Defaults to @samp{""}.
  17751. @end deftypevr
  17752. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  17753. Log file to use for debug messages. Defaults to
  17754. @samp{info-log-path}.
  17755. Defaults to @samp{""}.
  17756. @end deftypevr
  17757. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  17758. Syslog facility to use if you're logging to syslog. Usually if you
  17759. don't want to use @samp{mail}, you'll use local0..local7. Also other
  17760. standard facilities are supported.
  17761. Defaults to @samp{"mail"}.
  17762. @end deftypevr
  17763. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  17764. Log unsuccessful authentication attempts and the reasons why they
  17765. failed.
  17766. Defaults to @samp{#f}.
  17767. @end deftypevr
  17768. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  17769. In case of password mismatches, log the attempted password. Valid
  17770. values are no, plain and sha1. sha1 can be useful for detecting brute
  17771. force password attempts vs. user simply trying the same password over
  17772. and over again. You can also truncate the value to n chars by appending
  17773. ":n" (e.g.@: sha1:6).
  17774. Defaults to @samp{"no"}.
  17775. @end deftypevr
  17776. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  17777. Even more verbose logging for debugging purposes. Shows for example
  17778. SQL queries.
  17779. Defaults to @samp{#f}.
  17780. @end deftypevr
  17781. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  17782. In case of password mismatches, log the passwords and used scheme so
  17783. the problem can be debugged. Enabling this also enables
  17784. @samp{auth-debug}.
  17785. Defaults to @samp{#f}.
  17786. @end deftypevr
  17787. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  17788. Enable mail process debugging. This can help you figure out why
  17789. Dovecot isn't finding your mails.
  17790. Defaults to @samp{#f}.
  17791. @end deftypevr
  17792. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  17793. Show protocol level SSL errors.
  17794. Defaults to @samp{#f}.
  17795. @end deftypevr
  17796. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  17797. Prefix for each line written to log file. % codes are in
  17798. strftime(3) format.
  17799. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  17800. @end deftypevr
  17801. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  17802. List of elements we want to log. The elements which have a
  17803. non-empty variable value are joined together to form a comma-separated
  17804. string.
  17805. @end deftypevr
  17806. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  17807. Login log format. %s contains @samp{login-log-format-elements}
  17808. string, %$ contains the data we want to log.
  17809. Defaults to @samp{"%$: %s"}.
  17810. @end deftypevr
  17811. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  17812. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  17813. of possible variables you can use.
  17814. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  17815. @end deftypevr
  17816. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  17817. Format to use for logging mail deliveries. You can use variables:
  17818. @table @code
  17819. @item %$
  17820. Delivery status message (e.g.@: @samp{saved to INBOX})
  17821. @item %m
  17822. Message-ID
  17823. @item %s
  17824. Subject
  17825. @item %f
  17826. From address
  17827. @item %p
  17828. Physical size
  17829. @item %w
  17830. Virtual size.
  17831. @end table
  17832. Defaults to @samp{"msgid=%m: %$"}.
  17833. @end deftypevr
  17834. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  17835. Location for users' mailboxes. The default is empty, which means
  17836. that Dovecot tries to find the mailboxes automatically. This won't work
  17837. if the user doesn't yet have any mail, so you should explicitly tell
  17838. Dovecot the full location.
  17839. If you're using mbox, giving a path to the INBOX
  17840. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  17841. where the other mailboxes are kept. This is called the @emph{root mail
  17842. directory}, and it must be the first path given in the
  17843. @samp{mail-location} setting.
  17844. There are a few special variables you can use, e.g.:
  17845. @table @samp
  17846. @item %u
  17847. username
  17848. @item %n
  17849. user part in user@@domain, same as %u if there's no domain
  17850. @item %d
  17851. domain part in user@@domain, empty if there's no domain
  17852. @item %h
  17853. home director
  17854. @end table
  17855. See doc/wiki/Variables.txt for full list. Some examples:
  17856. @table @samp
  17857. @item maildir:~/Maildir
  17858. @item mbox:~/mail:INBOX=/var/mail/%u
  17859. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  17860. @end table
  17861. Defaults to @samp{""}.
  17862. @end deftypevr
  17863. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  17864. System user and group used to access mails. If you use multiple,
  17865. userdb can override these by returning uid or gid fields. You can use
  17866. either numbers or names. <doc/wiki/UserIds.txt>.
  17867. Defaults to @samp{""}.
  17868. @end deftypevr
  17869. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  17870. Defaults to @samp{""}.
  17871. @end deftypevr
  17872. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  17873. Group to enable temporarily for privileged operations. Currently
  17874. this is used only with INBOX when either its initial creation or
  17875. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  17876. @file{/var/mail}.
  17877. Defaults to @samp{""}.
  17878. @end deftypevr
  17879. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  17880. Grant access to these supplementary groups for mail processes.
  17881. Typically these are used to set up access to shared mailboxes. Note
  17882. that it may be dangerous to set these if users can create symlinks
  17883. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  17884. could allow a user to delete others' mailboxes, or @code{ln -s
  17885. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  17886. @samp{""}.
  17887. @end deftypevr
  17888. @deftypevr {@code{dovecot-configuration} parameter} string mail-attribute-dict
  17889. The location of a dictionary used to store @code{IMAP METADATA}
  17890. as defined by @uref{https://tools.ietf.org/html/rfc5464, RFC@tie{}5464}.
  17891. The IMAP METADATA commands are available only if the ``imap''
  17892. protocol configuration's @code{imap-metadata?} field is @samp{#t}.
  17893. Defaults to @samp{""}.
  17894. @end deftypevr
  17895. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  17896. Allow full file system access to clients. There's no access checks
  17897. other than what the operating system does for the active UID/GID@. It
  17898. works with both maildir and mboxes, allowing you to prefix mailboxes
  17899. names with e.g.@: @file{/path/} or @file{~user/}.
  17900. Defaults to @samp{#f}.
  17901. @end deftypevr
  17902. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  17903. Don't use @code{mmap()} at all. This is required if you store indexes to
  17904. shared file systems (NFS or clustered file system).
  17905. Defaults to @samp{#f}.
  17906. @end deftypevr
  17907. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  17908. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  17909. supports @samp{O_EXCL} since version 3, so this should be safe to use
  17910. nowadays by default.
  17911. Defaults to @samp{#t}.
  17912. @end deftypevr
  17913. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  17914. When to use fsync() or fdatasync() calls:
  17915. @table @code
  17916. @item optimized
  17917. Whenever necessary to avoid losing important data
  17918. @item always
  17919. Useful with e.g.@: NFS when @code{write()}s are delayed
  17920. @item never
  17921. Never use it (best performance, but crashes can lose data).
  17922. @end table
  17923. Defaults to @samp{"optimized"}.
  17924. @end deftypevr
  17925. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  17926. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  17927. NFS caches whenever needed. If you're using only a single mail server
  17928. this isn't needed.
  17929. Defaults to @samp{#f}.
  17930. @end deftypevr
  17931. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  17932. Mail index files also exist in NFS@. Setting this to yes requires
  17933. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  17934. Defaults to @samp{#f}.
  17935. @end deftypevr
  17936. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  17937. Locking method for index files. Alternatives are fcntl, flock and
  17938. dotlock. Dotlocking uses some tricks which may create more disk I/O
  17939. than other locking methods. NFS users: flock doesn't work, remember to
  17940. change @samp{mmap-disable}.
  17941. Defaults to @samp{"fcntl"}.
  17942. @end deftypevr
  17943. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  17944. Directory in which LDA/LMTP temporarily stores incoming mails >128
  17945. kB.
  17946. Defaults to @samp{"/tmp"}.
  17947. @end deftypevr
  17948. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  17949. Valid UID range for users. This is mostly to make sure that users can't
  17950. log in as daemons or other system users. Note that denying root logins is
  17951. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  17952. is set to 0.
  17953. Defaults to @samp{500}.
  17954. @end deftypevr
  17955. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  17956. Defaults to @samp{0}.
  17957. @end deftypevr
  17958. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  17959. Valid GID range for users. Users having non-valid GID as primary group ID
  17960. aren't allowed to log in. If user belongs to supplementary groups with
  17961. non-valid GIDs, those groups are not set.
  17962. Defaults to @samp{1}.
  17963. @end deftypevr
  17964. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  17965. Defaults to @samp{0}.
  17966. @end deftypevr
  17967. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  17968. Maximum allowed length for mail keyword name. It's only forced when
  17969. trying to create new keywords.
  17970. Defaults to @samp{50}.
  17971. @end deftypevr
  17972. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  17973. List of directories under which chrooting is allowed for mail
  17974. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  17975. too). This setting doesn't affect @samp{login-chroot}
  17976. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  17977. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  17978. which local users can modify, that may lead to root exploit. Usually
  17979. this should be done only if you don't allow shell access for users.
  17980. <doc/wiki/Chrooting.txt>.
  17981. Defaults to @samp{()}.
  17982. @end deftypevr
  17983. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  17984. Default chroot directory for mail processes. This can be overridden
  17985. for specific users in user database by giving @samp{/./} in user's home
  17986. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  17987. there is no real need to do chrooting, Dovecot doesn't allow users to
  17988. access files outside their mail directory anyway. If your home
  17989. directories are prefixed with the chroot directory, append @samp{/.} to
  17990. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  17991. Defaults to @samp{""}.
  17992. @end deftypevr
  17993. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  17994. UNIX socket path to master authentication server to find users.
  17995. This is used by imap (for shared users) and lda.
  17996. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  17997. @end deftypevr
  17998. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  17999. Directory where to look up mail plugins.
  18000. Defaults to @samp{"/usr/lib/dovecot"}.
  18001. @end deftypevr
  18002. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  18003. List of plugins to load for all services. Plugins specific to IMAP,
  18004. LDA, etc.@: are added to this list in their own .conf files.
  18005. Defaults to @samp{()}.
  18006. @end deftypevr
  18007. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  18008. The minimum number of mails in a mailbox before updates are done to
  18009. cache file. This allows optimizing Dovecot's behavior to do less disk
  18010. writes at the cost of more disk reads.
  18011. Defaults to @samp{0}.
  18012. @end deftypevr
  18013. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  18014. When IDLE command is running, mailbox is checked once in a while to
  18015. see if there are any new mails or other changes. This setting defines
  18016. the minimum time to wait between those checks. Dovecot can also use
  18017. dnotify, inotify and kqueue to find out immediately when changes
  18018. occur.
  18019. Defaults to @samp{"30 secs"}.
  18020. @end deftypevr
  18021. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  18022. Save mails with CR+LF instead of plain LF@. This makes sending those
  18023. mails take less CPU, especially with sendfile() syscall with Linux and
  18024. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  18025. slower. Also note that if other software reads the mboxes/maildirs,
  18026. they may handle the extra CRs wrong and cause problems.
  18027. Defaults to @samp{#f}.
  18028. @end deftypevr
  18029. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  18030. By default LIST command returns all entries in maildir beginning
  18031. with a dot. Enabling this option makes Dovecot return only entries
  18032. which are directories. This is done by stat()ing each entry, so it
  18033. causes more disk I/O.
  18034. (For systems setting struct @samp{dirent->d_type} this check is free
  18035. and it's done always regardless of this setting).
  18036. Defaults to @samp{#f}.
  18037. @end deftypevr
  18038. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  18039. When copying a message, do it with hard links whenever possible.
  18040. This makes the performance much better, and it's unlikely to have any
  18041. side effects.
  18042. Defaults to @samp{#t}.
  18043. @end deftypevr
  18044. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  18045. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  18046. directory only when its mtime changes unexpectedly or when we can't find
  18047. the mail otherwise.
  18048. Defaults to @samp{#f}.
  18049. @end deftypevr
  18050. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  18051. Which locking methods to use for locking mbox. There are four
  18052. available:
  18053. @table @code
  18054. @item dotlock
  18055. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  18056. solution. If you want to use /var/mail/ like directory, the users will
  18057. need write access to that directory.
  18058. @item dotlock-try
  18059. Same as dotlock, but if it fails because of permissions or because there
  18060. isn't enough disk space, just skip it.
  18061. @item fcntl
  18062. Use this if possible. Works with NFS too if lockd is used.
  18063. @item flock
  18064. May not exist in all systems. Doesn't work with NFS.
  18065. @item lockf
  18066. May not exist in all systems. Doesn't work with NFS.
  18067. @end table
  18068. You can use multiple locking methods; if you do the order they're declared
  18069. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  18070. locking methods as well. Some operating systems don't allow using some of
  18071. them simultaneously.
  18072. @end deftypevr
  18073. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  18074. @end deftypevr
  18075. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  18076. Maximum time to wait for lock (all of them) before aborting.
  18077. Defaults to @samp{"5 mins"}.
  18078. @end deftypevr
  18079. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  18080. If dotlock exists but the mailbox isn't modified in any way,
  18081. override the lock file after this much time.
  18082. Defaults to @samp{"2 mins"}.
  18083. @end deftypevr
  18084. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  18085. When mbox changes unexpectedly we have to fully read it to find out
  18086. what changed. If the mbox is large this can take a long time. Since
  18087. the change is usually just a newly appended mail, it'd be faster to
  18088. simply read the new mails. If this setting is enabled, Dovecot does
  18089. this but still safely fallbacks to re-reading the whole mbox file
  18090. whenever something in mbox isn't how it's expected to be. The only real
  18091. downside to this setting is that if some other MUA changes message
  18092. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  18093. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  18094. Defaults to @samp{#t}.
  18095. @end deftypevr
  18096. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  18097. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  18098. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  18099. @samp{mbox-dirty-syncs} is ignored.
  18100. Defaults to @samp{#f}.
  18101. @end deftypevr
  18102. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  18103. Delay writing mbox headers until doing a full write sync (EXPUNGE
  18104. and CHECK commands and when closing the mailbox). This is especially
  18105. useful for POP3 where clients often delete all mails. The downside is
  18106. that our changes aren't immediately visible to other MUAs.
  18107. Defaults to @samp{#t}.
  18108. @end deftypevr
  18109. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  18110. If mbox size is smaller than this (e.g.@: 100k), don't write index
  18111. files. If an index file already exists it's still read, just not
  18112. updated.
  18113. Defaults to @samp{0}.
  18114. @end deftypevr
  18115. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  18116. Maximum dbox file size until it's rotated.
  18117. Defaults to @samp{10000000}.
  18118. @end deftypevr
  18119. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  18120. Maximum dbox file age until it's rotated. Typically in days. Day
  18121. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  18122. disabled.
  18123. Defaults to @samp{"1d"}.
  18124. @end deftypevr
  18125. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  18126. When creating new mdbox files, immediately preallocate their size to
  18127. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  18128. with some file systems (ext4, xfs).
  18129. Defaults to @samp{#f}.
  18130. @end deftypevr
  18131. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  18132. sdbox and mdbox support saving mail attachments to external files,
  18133. which also allows single instance storage for them. Other backends
  18134. don't support this for now.
  18135. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  18136. Directory root where to store mail attachments. Disabled, if empty.
  18137. Defaults to @samp{""}.
  18138. @end deftypevr
  18139. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  18140. Attachments smaller than this aren't saved externally. It's also
  18141. possible to write a plugin to disable saving specific attachments
  18142. externally.
  18143. Defaults to @samp{128000}.
  18144. @end deftypevr
  18145. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  18146. File system backend to use for saving attachments:
  18147. @table @code
  18148. @item posix
  18149. No SiS done by Dovecot (but this might help FS's own deduplication)
  18150. @item sis posix
  18151. SiS with immediate byte-by-byte comparison during saving
  18152. @item sis-queue posix
  18153. SiS with delayed comparison and deduplication.
  18154. @end table
  18155. Defaults to @samp{"sis posix"}.
  18156. @end deftypevr
  18157. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  18158. Hash format to use in attachment filenames. You can add any text and
  18159. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  18160. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  18161. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  18162. Defaults to @samp{"%@{sha1@}"}.
  18163. @end deftypevr
  18164. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  18165. Defaults to @samp{100}.
  18166. @end deftypevr
  18167. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  18168. Defaults to @samp{1000}.
  18169. @end deftypevr
  18170. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  18171. Default VSZ (virtual memory size) limit for service processes.
  18172. This is mainly intended to catch and kill processes that leak memory
  18173. before they eat up everything.
  18174. Defaults to @samp{256000000}.
  18175. @end deftypevr
  18176. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  18177. Login user is internally used by login processes. This is the most
  18178. untrusted user in Dovecot system. It shouldn't have access to anything
  18179. at all.
  18180. Defaults to @samp{"dovenull"}.
  18181. @end deftypevr
  18182. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  18183. Internal user is used by unprivileged processes. It should be
  18184. separate from login user, so that login processes can't disturb other
  18185. processes.
  18186. Defaults to @samp{"dovecot"}.
  18187. @end deftypevr
  18188. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  18189. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  18190. Defaults to @samp{"required"}.
  18191. @end deftypevr
  18192. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  18193. PEM encoded X.509 SSL/TLS certificate (public key).
  18194. Defaults to @samp{"</etc/dovecot/default.pem"}.
  18195. @end deftypevr
  18196. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  18197. PEM encoded SSL/TLS private key. The key is opened before
  18198. dropping root privileges, so keep the key file unreadable by anyone but
  18199. root.
  18200. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  18201. @end deftypevr
  18202. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  18203. If key file is password protected, give the password here.
  18204. Alternatively give it when starting dovecot with -p parameter. Since
  18205. this file is often world-readable, you may want to place this setting
  18206. instead to a different.
  18207. Defaults to @samp{""}.
  18208. @end deftypevr
  18209. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  18210. PEM encoded trusted certificate authority. Set this only if you
  18211. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  18212. contain the CA certificate(s) followed by the matching
  18213. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  18214. Defaults to @samp{""}.
  18215. @end deftypevr
  18216. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  18217. Require that CRL check succeeds for client certificates.
  18218. Defaults to @samp{#t}.
  18219. @end deftypevr
  18220. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  18221. Request client to send a certificate. If you also want to require
  18222. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  18223. Defaults to @samp{#f}.
  18224. @end deftypevr
  18225. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  18226. Which field from certificate to use for username. commonName and
  18227. x500UniqueIdentifier are the usual choices. You'll also need to set
  18228. @samp{auth-ssl-username-from-cert? #t}.
  18229. Defaults to @samp{"commonName"}.
  18230. @end deftypevr
  18231. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  18232. Minimum SSL protocol version to accept.
  18233. Defaults to @samp{"TLSv1"}.
  18234. @end deftypevr
  18235. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  18236. SSL ciphers to use.
  18237. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  18238. @end deftypevr
  18239. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  18240. SSL crypto device to use, for valid values run "openssl engine".
  18241. Defaults to @samp{""}.
  18242. @end deftypevr
  18243. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  18244. Address to use when sending rejection mails.
  18245. %d expands to recipient domain.
  18246. Defaults to @samp{"postmaster@@%d"}.
  18247. @end deftypevr
  18248. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  18249. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  18250. and in LMTP replies. Default is the system's real hostname@@domain.
  18251. Defaults to @samp{""}.
  18252. @end deftypevr
  18253. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  18254. If user is over quota, return with temporary failure instead of
  18255. bouncing the mail.
  18256. Defaults to @samp{#f}.
  18257. @end deftypevr
  18258. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  18259. Binary to use for sending mails.
  18260. Defaults to @samp{"/usr/sbin/sendmail"}.
  18261. @end deftypevr
  18262. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  18263. If non-empty, send mails via this SMTP host[:port] instead of
  18264. sendmail.
  18265. Defaults to @samp{""}.
  18266. @end deftypevr
  18267. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  18268. Subject: header to use for rejection mails. You can use the same
  18269. variables as for @samp{rejection-reason} below.
  18270. Defaults to @samp{"Rejected: %s"}.
  18271. @end deftypevr
  18272. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  18273. Human readable error message for rejection mails. You can use
  18274. variables:
  18275. @table @code
  18276. @item %n
  18277. CRLF
  18278. @item %r
  18279. reason
  18280. @item %s
  18281. original subject
  18282. @item %t
  18283. recipient
  18284. @end table
  18285. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  18286. @end deftypevr
  18287. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  18288. Delimiter character between local-part and detail in email
  18289. address.
  18290. Defaults to @samp{"+"}.
  18291. @end deftypevr
  18292. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  18293. Header where the original recipient address (SMTP's RCPT TO:
  18294. address) is taken from if not available elsewhere. With dovecot-lda -a
  18295. parameter overrides this. A commonly used header for this is
  18296. X-Original-To.
  18297. Defaults to @samp{""}.
  18298. @end deftypevr
  18299. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  18300. Should saving a mail to a nonexistent mailbox automatically create
  18301. it?.
  18302. Defaults to @samp{#f}.
  18303. @end deftypevr
  18304. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  18305. Should automatically created mailboxes be also automatically
  18306. subscribed?.
  18307. Defaults to @samp{#f}.
  18308. @end deftypevr
  18309. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  18310. Maximum IMAP command line length. Some clients generate very long
  18311. command lines with huge mailboxes, so you may need to raise this if you
  18312. get "Too long argument" or "IMAP command line too large" errors
  18313. often.
  18314. Defaults to @samp{64000}.
  18315. @end deftypevr
  18316. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  18317. IMAP logout format string:
  18318. @table @code
  18319. @item %i
  18320. total number of bytes read from client
  18321. @item %o
  18322. total number of bytes sent to client.
  18323. @end table
  18324. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  18325. 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@}"}.
  18326. @end deftypevr
  18327. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  18328. Override the IMAP CAPABILITY response. If the value begins with '+',
  18329. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  18330. Defaults to @samp{""}.
  18331. @end deftypevr
  18332. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  18333. How long to wait between "OK Still here" notifications when client
  18334. is IDLEing.
  18335. Defaults to @samp{"2 mins"}.
  18336. @end deftypevr
  18337. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  18338. ID field names and values to send to clients. Using * as the value
  18339. makes Dovecot use the default value. The following fields have default
  18340. values currently: name, version, os, os-version, support-url,
  18341. support-email.
  18342. Defaults to @samp{""}.
  18343. @end deftypevr
  18344. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  18345. ID fields sent by client to log. * means everything.
  18346. Defaults to @samp{""}.
  18347. @end deftypevr
  18348. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  18349. Workarounds for various client bugs:
  18350. @table @code
  18351. @item delay-newmail
  18352. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  18353. CHECK commands. Some clients ignore them otherwise, for example OSX
  18354. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  18355. may show user "Message no longer in server" errors. Note that OE6
  18356. still breaks even with this workaround if synchronization is set to
  18357. "Headers Only".
  18358. @item tb-extra-mailbox-sep
  18359. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  18360. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  18361. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  18362. @item tb-lsub-flags
  18363. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  18364. This makes Thunderbird realize they aren't selectable and show them
  18365. greyed out, instead of only later giving "not selectable" popup error.
  18366. @end table
  18367. Defaults to @samp{()}.
  18368. @end deftypevr
  18369. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  18370. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  18371. Defaults to @samp{""}.
  18372. @end deftypevr
  18373. Whew! Lots of configuration options. The nice thing about it though is
  18374. that Guix has a complete interface to Dovecot's configuration
  18375. language. This allows not only a nice way to declare configurations,
  18376. but also offers reflective capabilities as well: users can write code to
  18377. inspect and transform configurations from within Scheme.
  18378. However, it could be that you just want to get a @code{dovecot.conf} up
  18379. and running. In that case, you can pass an
  18380. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  18381. @code{dovecot-service}. As its name indicates, an opaque configuration
  18382. does not have easy reflective capabilities.
  18383. Available @code{opaque-dovecot-configuration} fields are:
  18384. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  18385. The dovecot package.
  18386. @end deftypevr
  18387. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  18388. The contents of the @code{dovecot.conf}, as a string.
  18389. @end deftypevr
  18390. For example, if your @code{dovecot.conf} is just the empty string, you
  18391. could instantiate a dovecot service like this:
  18392. @lisp
  18393. (dovecot-service #:config
  18394. (opaque-dovecot-configuration
  18395. (string "")))
  18396. @end lisp
  18397. @subsubheading OpenSMTPD Service
  18398. @deffn {Scheme Variable} opensmtpd-service-type
  18399. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  18400. service, whose value should be an @code{opensmtpd-configuration} object
  18401. as in this example:
  18402. @lisp
  18403. (service opensmtpd-service-type
  18404. (opensmtpd-configuration
  18405. (config-file (local-file "./my-smtpd.conf"))))
  18406. @end lisp
  18407. @end deffn
  18408. @deftp {Data Type} opensmtpd-configuration
  18409. Data type representing the configuration of opensmtpd.
  18410. @table @asis
  18411. @item @code{package} (default: @var{opensmtpd})
  18412. Package object of the OpenSMTPD SMTP server.
  18413. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  18414. File-like object of the OpenSMTPD configuration file to use. By default
  18415. it listens on the loopback network interface, and allows for mail from
  18416. users and daemons on the local machine, as well as permitting email to
  18417. remote servers. Run @command{man smtpd.conf} for more information.
  18418. @end table
  18419. @end deftp
  18420. @subsubheading Exim Service
  18421. @cindex mail transfer agent (MTA)
  18422. @cindex MTA (mail transfer agent)
  18423. @cindex SMTP
  18424. @deffn {Scheme Variable} exim-service-type
  18425. This is the type of the @uref{https://exim.org, Exim} mail transfer
  18426. agent (MTA), whose value should be an @code{exim-configuration} object
  18427. as in this example:
  18428. @lisp
  18429. (service exim-service-type
  18430. (exim-configuration
  18431. (config-file (local-file "./my-exim.conf"))))
  18432. @end lisp
  18433. @end deffn
  18434. In order to use an @code{exim-service-type} service you must also have a
  18435. @code{mail-aliases-service-type} service present in your
  18436. @code{operating-system} (even if it has no aliases).
  18437. @deftp {Data Type} exim-configuration
  18438. Data type representing the configuration of exim.
  18439. @table @asis
  18440. @item @code{package} (default: @var{exim})
  18441. Package object of the Exim server.
  18442. @item @code{config-file} (default: @code{#f})
  18443. File-like object of the Exim configuration file to use. If its value is
  18444. @code{#f} then use the default configuration file from the package
  18445. provided in @code{package}. The resulting configuration file is loaded
  18446. after setting the @code{exim_user} and @code{exim_group} configuration
  18447. variables.
  18448. @end table
  18449. @end deftp
  18450. @subsubheading Getmail service
  18451. @cindex IMAP
  18452. @cindex POP
  18453. @deffn {Scheme Variable} getmail-service-type
  18454. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  18455. mail retriever, whose value should be an @code{getmail-configuration}.
  18456. @end deffn
  18457. Available @code{getmail-configuration} fields are:
  18458. @deftypevr {@code{getmail-configuration} parameter} symbol name
  18459. A symbol to identify the getmail service.
  18460. Defaults to @samp{"unset"}.
  18461. @end deftypevr
  18462. @deftypevr {@code{getmail-configuration} parameter} package package
  18463. The getmail package to use.
  18464. @end deftypevr
  18465. @deftypevr {@code{getmail-configuration} parameter} string user
  18466. The user to run getmail as.
  18467. Defaults to @samp{"getmail"}.
  18468. @end deftypevr
  18469. @deftypevr {@code{getmail-configuration} parameter} string group
  18470. The group to run getmail as.
  18471. Defaults to @samp{"getmail"}.
  18472. @end deftypevr
  18473. @deftypevr {@code{getmail-configuration} parameter} string directory
  18474. The getmail directory to use.
  18475. Defaults to @samp{"/var/lib/getmail/default"}.
  18476. @end deftypevr
  18477. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  18478. The getmail configuration file to use.
  18479. Available @code{getmail-configuration-file} fields are:
  18480. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  18481. What mail account to retrieve mail from, and how to access that account.
  18482. Available @code{getmail-retriever-configuration} fields are:
  18483. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  18484. The type of mail retriever to use. Valid values include @samp{passwd}
  18485. and @samp{static}.
  18486. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  18487. @end deftypevr
  18488. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  18489. Username to login to the mail server with.
  18490. Defaults to @samp{unset}.
  18491. @end deftypevr
  18492. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  18493. Username to login to the mail server with.
  18494. Defaults to @samp{unset}.
  18495. @end deftypevr
  18496. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  18497. Port number to connect to.
  18498. Defaults to @samp{#f}.
  18499. @end deftypevr
  18500. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  18501. Override fields from passwd.
  18502. Defaults to @samp{""}.
  18503. @end deftypevr
  18504. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  18505. Override fields from passwd.
  18506. Defaults to @samp{()}.
  18507. @end deftypevr
  18508. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  18509. PEM-formatted key file to use for the TLS negotiation.
  18510. Defaults to @samp{""}.
  18511. @end deftypevr
  18512. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  18513. PEM-formatted certificate file to use for the TLS negotiation.
  18514. Defaults to @samp{""}.
  18515. @end deftypevr
  18516. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  18517. CA certificates to use.
  18518. Defaults to @samp{""}.
  18519. @end deftypevr
  18520. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  18521. Extra retriever parameters.
  18522. Defaults to @samp{()}.
  18523. @end deftypevr
  18524. @end deftypevr
  18525. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  18526. What to do with retrieved messages.
  18527. Available @code{getmail-destination-configuration} fields are:
  18528. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  18529. The type of mail destination. Valid values include @samp{Maildir},
  18530. @samp{Mboxrd} and @samp{MDA_external}.
  18531. Defaults to @samp{unset}.
  18532. @end deftypevr
  18533. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  18534. The path option for the mail destination. The behaviour depends on the
  18535. chosen type.
  18536. Defaults to @samp{""}.
  18537. @end deftypevr
  18538. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  18539. Extra destination parameters
  18540. Defaults to @samp{()}.
  18541. @end deftypevr
  18542. @end deftypevr
  18543. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  18544. Configure getmail.
  18545. Available @code{getmail-options-configuration} fields are:
  18546. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  18547. If set to @samp{0}, getmail will only print warnings and errors. A
  18548. value of @samp{1} means that messages will be printed about retrieving
  18549. and deleting messages. If set to @samp{2}, getmail will print messages
  18550. about each of its actions.
  18551. Defaults to @samp{1}.
  18552. @end deftypevr
  18553. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  18554. If true, getmail will retrieve all available messages. Otherwise it
  18555. will only retrieve messages it hasn't seen previously.
  18556. Defaults to @samp{#t}.
  18557. @end deftypevr
  18558. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  18559. If set to true, messages will be deleted from the server after
  18560. retrieving and successfully delivering them. Otherwise, messages will
  18561. be left on the server.
  18562. Defaults to @samp{#f}.
  18563. @end deftypevr
  18564. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  18565. Getmail will delete messages this number of days after seeing them, if
  18566. they have been delivered. This means messages will be left on the
  18567. server this number of days after delivering them. A value of @samp{0}
  18568. disabled this feature.
  18569. Defaults to @samp{0}.
  18570. @end deftypevr
  18571. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  18572. Delete messages larger than this of bytes after retrieving them, even if
  18573. the delete and delete-after options are disabled. A value of @samp{0}
  18574. disables this feature.
  18575. Defaults to @samp{0}.
  18576. @end deftypevr
  18577. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  18578. Retrieve messages totalling up to this number of bytes before closing
  18579. the session with the server. A value of @samp{0} disables this feature.
  18580. Defaults to @samp{0}.
  18581. @end deftypevr
  18582. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  18583. Don't retrieve messages larger than this number of bytes. A value of
  18584. @samp{0} disables this feature.
  18585. Defaults to @samp{0}.
  18586. @end deftypevr
  18587. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  18588. If true, getmail will add a Delivered-To header to messages.
  18589. Defaults to @samp{#t}.
  18590. @end deftypevr
  18591. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  18592. If set, getmail adds a Received header to the messages.
  18593. Defaults to @samp{#t}.
  18594. @end deftypevr
  18595. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  18596. Getmail will record a log of its actions to the named file. A value of
  18597. @samp{""} disables this feature.
  18598. Defaults to @samp{""}.
  18599. @end deftypevr
  18600. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  18601. If true, getmail will record a log of its actions using the system
  18602. logger.
  18603. Defaults to @samp{#f}.
  18604. @end deftypevr
  18605. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  18606. If true, getmail will log information about messages not retrieved and
  18607. the reason for not retrieving them, as well as starting and ending
  18608. information lines.
  18609. Defaults to @samp{#f}.
  18610. @end deftypevr
  18611. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  18612. Extra options to include.
  18613. Defaults to @samp{()}.
  18614. @end deftypevr
  18615. @end deftypevr
  18616. @end deftypevr
  18617. @deftypevr {@code{getmail-configuration} parameter} list idle
  18618. A list of mailboxes that getmail should wait on the server for new mail
  18619. notifications. This depends on the server supporting the IDLE
  18620. extension.
  18621. Defaults to @samp{()}.
  18622. @end deftypevr
  18623. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  18624. Environment variables to set for getmail.
  18625. Defaults to @samp{()}.
  18626. @end deftypevr
  18627. @subsubheading Mail Aliases Service
  18628. @cindex email aliases
  18629. @cindex aliases, for email addresses
  18630. @deffn {Scheme Variable} mail-aliases-service-type
  18631. This is the type of the service which provides @code{/etc/aliases},
  18632. specifying how to deliver mail to users on this system.
  18633. @lisp
  18634. (service mail-aliases-service-type
  18635. '(("postmaster" "bob")
  18636. ("bob" "bob@@example.com" "bob@@example2.com")))
  18637. @end lisp
  18638. @end deffn
  18639. The configuration for a @code{mail-aliases-service-type} service is an
  18640. association list denoting how to deliver mail that comes to this
  18641. system. Each entry is of the form @code{(alias addresses ...)}, with
  18642. @code{alias} specifying the local alias and @code{addresses} specifying
  18643. where to deliver this user's mail.
  18644. The aliases aren't required to exist as users on the local system. In
  18645. the above example, there doesn't need to be a @code{postmaster} entry in
  18646. the @code{operating-system}'s @code{user-accounts} in order to deliver
  18647. the @code{postmaster} mail to @code{bob} (which subsequently would
  18648. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  18649. @subsubheading GNU Mailutils IMAP4 Daemon
  18650. @cindex GNU Mailutils IMAP4 Daemon
  18651. @deffn {Scheme Variable} imap4d-service-type
  18652. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  18653. mailutils, GNU Mailutils Manual}), whose value should be an
  18654. @code{imap4d-configuration} object as in this example:
  18655. @lisp
  18656. (service imap4d-service-type
  18657. (imap4d-configuration
  18658. (config-file (local-file "imap4d.conf"))))
  18659. @end lisp
  18660. @end deffn
  18661. @deftp {Data Type} imap4d-configuration
  18662. Data type representing the configuration of @command{imap4d}.
  18663. @table @asis
  18664. @item @code{package} (default: @code{mailutils})
  18665. The package that provides @command{imap4d}.
  18666. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  18667. File-like object of the configuration file to use, by default it will listen
  18668. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  18669. Mailutils Manual}, for details.
  18670. @end table
  18671. @end deftp
  18672. @subsubheading Radicale Service
  18673. @cindex CalDAV
  18674. @cindex CardDAV
  18675. @deffn {Scheme Variable} radicale-service-type
  18676. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  18677. server whose value should be a @code{radicale-configuration}.
  18678. @end deffn
  18679. @deftp {Data Type} radicale-configuration
  18680. Data type representing the configuration of @command{radicale}.
  18681. @table @asis
  18682. @item @code{package} (default: @code{radicale})
  18683. The package that provides @command{radicale}.
  18684. @item @code{config-file} (default: @code{%default-radicale-config-file})
  18685. File-like object of the configuration file to use, by default it will listen
  18686. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  18687. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  18688. @end table
  18689. @end deftp
  18690. @node Messaging Services
  18691. @subsection Messaging Services
  18692. @cindex messaging
  18693. @cindex jabber
  18694. @cindex XMPP
  18695. The @code{(gnu services messaging)} module provides Guix service
  18696. definitions for messaging services. Currently it provides the following
  18697. services:
  18698. @subsubheading Prosody Service
  18699. @deffn {Scheme Variable} prosody-service-type
  18700. This is the type for the @uref{https://prosody.im, Prosody XMPP
  18701. communication server}. Its value must be a @code{prosody-configuration}
  18702. record as in this example:
  18703. @lisp
  18704. (service prosody-service-type
  18705. (prosody-configuration
  18706. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  18707. (int-components
  18708. (list
  18709. (int-component-configuration
  18710. (hostname "conference.example.net")
  18711. (plugin "muc")
  18712. (mod-muc (mod-muc-configuration)))))
  18713. (virtualhosts
  18714. (list
  18715. (virtualhost-configuration
  18716. (domain "example.net"))))))
  18717. @end lisp
  18718. See below for details about @code{prosody-configuration}.
  18719. @end deffn
  18720. By default, Prosody does not need much configuration. Only one
  18721. @code{virtualhosts} field is needed: it specifies the domain you wish
  18722. Prosody to serve.
  18723. You can perform various sanity checks on the generated configuration
  18724. with the @code{prosodyctl check} command.
  18725. Prosodyctl will also help you to import certificates from the
  18726. @code{letsencrypt} directory so that the @code{prosody} user can access
  18727. them. See @url{https://prosody.im/doc/letsencrypt}.
  18728. @example
  18729. prosodyctl --root cert import /etc/letsencrypt/live
  18730. @end example
  18731. The available configuration parameters follow. Each parameter
  18732. definition is preceded by its type; for example, @samp{string-list foo}
  18733. indicates that the @code{foo} parameter should be specified as a list of
  18734. strings. Types starting with @code{maybe-} denote parameters that won't
  18735. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  18736. There is also a way to specify the configuration as a string, if you
  18737. have an old @code{prosody.cfg.lua} file that you want to port over from
  18738. some other system; see the end for more details.
  18739. The @code{file-object} type designates either a file-like object
  18740. (@pxref{G-Expressions, file-like objects}) or a file name.
  18741. @c The following documentation was initially generated by
  18742. @c (generate-documentation) in (gnu services messaging). Manually maintained
  18743. @c documentation is better, so we shouldn't hesitate to edit below as
  18744. @c needed. However if the change you want to make to this documentation
  18745. @c can be done in an automated way, it's probably easier to change
  18746. @c (generate-documentation) than to make it below and have to deal with
  18747. @c the churn as Prosody updates.
  18748. Available @code{prosody-configuration} fields are:
  18749. @deftypevr {@code{prosody-configuration} parameter} package prosody
  18750. The Prosody package.
  18751. @end deftypevr
  18752. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  18753. Location of the Prosody data storage directory. See
  18754. @url{https://prosody.im/doc/configure}.
  18755. Defaults to @samp{"/var/lib/prosody"}.
  18756. @end deftypevr
  18757. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  18758. Additional plugin directories. They are searched in all the specified
  18759. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  18760. Defaults to @samp{()}.
  18761. @end deftypevr
  18762. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  18763. Every virtual host and component needs a certificate so that clients and
  18764. servers can securely verify its identity. Prosody will automatically load
  18765. certificates/keys from the directory specified here.
  18766. Defaults to @samp{"/etc/prosody/certs"}.
  18767. @end deftypevr
  18768. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  18769. This is a list of accounts that are admins for the server. Note that you
  18770. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  18771. @url{https://prosody.im/doc/creating_accounts}.
  18772. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  18773. Defaults to @samp{()}.
  18774. @end deftypevr
  18775. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  18776. Enable use of libevent for better performance under high load. See
  18777. @url{https://prosody.im/doc/libevent}.
  18778. Defaults to @samp{#f}.
  18779. @end deftypevr
  18780. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  18781. This is the list of modules Prosody will load on startup. It looks for
  18782. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  18783. Documentation on modules can be found at:
  18784. @url{https://prosody.im/doc/modules}.
  18785. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  18786. @end deftypevr
  18787. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  18788. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  18789. should you want to disable them then add them to this list.
  18790. Defaults to @samp{()}.
  18791. @end deftypevr
  18792. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  18793. Path to a text file where the shared groups are defined. If this path is
  18794. empty then @samp{mod_groups} does nothing. See
  18795. @url{https://prosody.im/doc/modules/mod_groups}.
  18796. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  18797. @end deftypevr
  18798. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  18799. Disable account creation by default, for security. See
  18800. @url{https://prosody.im/doc/creating_accounts}.
  18801. Defaults to @samp{#f}.
  18802. @end deftypevr
  18803. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  18804. These are the SSL/TLS-related settings. Most of them are disabled so to
  18805. use Prosody's defaults. If you do not completely understand these options, do
  18806. not add them to your config, it is easy to lower the security of your server
  18807. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  18808. Available @code{ssl-configuration} fields are:
  18809. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  18810. This determines what handshake to use.
  18811. @end deftypevr
  18812. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  18813. Path to your private key file.
  18814. @end deftypevr
  18815. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  18816. Path to your certificate file.
  18817. @end deftypevr
  18818. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  18819. Path to directory containing root certificates that you wish Prosody to
  18820. trust when verifying the certificates of remote servers.
  18821. Defaults to @samp{"/etc/ssl/certs"}.
  18822. @end deftypevr
  18823. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  18824. Path to a file containing root certificates that you wish Prosody to trust.
  18825. Similar to @code{capath} but with all certificates concatenated together.
  18826. @end deftypevr
  18827. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  18828. A list of verification options (these mostly map to OpenSSL's
  18829. @code{set_verify()} flags).
  18830. @end deftypevr
  18831. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  18832. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  18833. @code{set_options()}. For a full list of options available in LuaSec, see the
  18834. LuaSec source.
  18835. @end deftypevr
  18836. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  18837. How long a chain of certificate authorities to check when looking for a
  18838. trusted root certificate.
  18839. @end deftypevr
  18840. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  18841. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  18842. clients, and in what order.
  18843. @end deftypevr
  18844. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  18845. A path to a file containing parameters for Diffie-Hellman key exchange. You
  18846. can create such a file with:
  18847. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  18848. @end deftypevr
  18849. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  18850. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  18851. @samp{"secp384r1"}.
  18852. @end deftypevr
  18853. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  18854. A list of ``extra'' verification options.
  18855. @end deftypevr
  18856. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  18857. Password for encrypted private keys.
  18858. @end deftypevr
  18859. @end deftypevr
  18860. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  18861. Whether to force all client-to-server connections to be encrypted or not.
  18862. See @url{https://prosody.im/doc/modules/mod_tls}.
  18863. Defaults to @samp{#f}.
  18864. @end deftypevr
  18865. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  18866. Set of mechanisms that will never be offered. See
  18867. @url{https://prosody.im/doc/modules/mod_saslauth}.
  18868. Defaults to @samp{("DIGEST-MD5")}.
  18869. @end deftypevr
  18870. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  18871. Whether to force all server-to-server connections to be encrypted or not.
  18872. See @url{https://prosody.im/doc/modules/mod_tls}.
  18873. Defaults to @samp{#f}.
  18874. @end deftypevr
  18875. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  18876. Whether to require encryption and certificate authentication. This
  18877. provides ideal security, but requires servers you communicate with to support
  18878. encryption AND present valid, trusted certificates. See
  18879. @url{https://prosody.im/doc/s2s#security}.
  18880. Defaults to @samp{#f}.
  18881. @end deftypevr
  18882. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  18883. Many servers don't support encryption or have invalid or self-signed
  18884. certificates. You can list domains here that will not be required to
  18885. authenticate using certificates. They will be authenticated using DNS@. See
  18886. @url{https://prosody.im/doc/s2s#security}.
  18887. Defaults to @samp{()}.
  18888. @end deftypevr
  18889. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  18890. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  18891. valid certificates for some domains by specifying a list here. See
  18892. @url{https://prosody.im/doc/s2s#security}.
  18893. Defaults to @samp{()}.
  18894. @end deftypevr
  18895. @deftypevr {@code{prosody-configuration} parameter} string authentication
  18896. Select the authentication backend to use. The default provider stores
  18897. passwords in plaintext and uses Prosody's configured data storage to store the
  18898. authentication data. If you do not trust your server please see
  18899. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  18900. about using the hashed backend. See also
  18901. @url{https://prosody.im/doc/authentication}
  18902. Defaults to @samp{"internal_plain"}.
  18903. @end deftypevr
  18904. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  18905. Set logging options. Advanced logging configuration is not yet supported
  18906. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  18907. Defaults to @samp{"*syslog"}.
  18908. @end deftypevr
  18909. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  18910. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  18911. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  18912. @end deftypevr
  18913. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  18914. Maximum allowed size of the HTTP body (in bytes).
  18915. @end deftypevr
  18916. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  18917. Some modules expose their own URL in various ways. This URL is built
  18918. from the protocol, host and port used. If Prosody sits behind a proxy, the
  18919. public URL will be @code{http-external-url} instead. See
  18920. @url{https://prosody.im/doc/http#external_url}.
  18921. @end deftypevr
  18922. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  18923. A host in Prosody is a domain on which user accounts can be created. For
  18924. example if you want your users to have addresses like
  18925. @samp{"john.smith@@example.com"} then you need to add a host
  18926. @samp{"example.com"}. All options in this list will apply only to this host.
  18927. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  18928. the actual physical host that Prosody is installed on. A single Prosody
  18929. instance can serve many domains, each one defined as a VirtualHost entry in
  18930. Prosody's configuration. Conversely a server that hosts a single domain would
  18931. have just one VirtualHost entry.
  18932. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  18933. Available @code{virtualhost-configuration} fields are:
  18934. 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:
  18935. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  18936. Domain you wish Prosody to serve.
  18937. @end deftypevr
  18938. @end deftypevr
  18939. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  18940. Components are extra services on a server which are available to clients,
  18941. usually on a subdomain of the main server (such as
  18942. @samp{"mycomponent.example.com"}). Example components might be chatroom
  18943. servers, user directories, or gateways to other protocols.
  18944. Internal components are implemented with Prosody-specific plugins. To add an
  18945. internal component, you simply fill the hostname field, and the plugin you wish
  18946. to use for the component.
  18947. See @url{https://prosody.im/doc/components}.
  18948. Defaults to @samp{()}.
  18949. Available @code{int-component-configuration} fields are:
  18950. 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:
  18951. @deftypevr {@code{int-component-configuration} parameter} string hostname
  18952. Hostname of the component.
  18953. @end deftypevr
  18954. @deftypevr {@code{int-component-configuration} parameter} string plugin
  18955. Plugin you wish to use for the component.
  18956. @end deftypevr
  18957. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  18958. Multi-user chat (MUC) is Prosody's module for allowing you to create
  18959. hosted chatrooms/conferences for XMPP users.
  18960. General information on setting up and using multi-user chatrooms can be found
  18961. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  18962. which you should read if you are new to XMPP chatrooms.
  18963. See also @url{https://prosody.im/doc/modules/mod_muc}.
  18964. Available @code{mod-muc-configuration} fields are:
  18965. @deftypevr {@code{mod-muc-configuration} parameter} string name
  18966. The name to return in service discovery responses.
  18967. Defaults to @samp{"Prosody Chatrooms"}.
  18968. @end deftypevr
  18969. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  18970. If @samp{#t}, this will only allow admins to create new chatrooms.
  18971. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  18972. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  18973. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  18974. restricts to service administrators only.
  18975. Defaults to @samp{#f}.
  18976. @end deftypevr
  18977. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  18978. Maximum number of history messages that will be sent to the member that has
  18979. just joined the room.
  18980. Defaults to @samp{20}.
  18981. @end deftypevr
  18982. @end deftypevr
  18983. @end deftypevr
  18984. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  18985. External components use XEP-0114, which most standalone components
  18986. support. To add an external component, you simply fill the hostname field. See
  18987. @url{https://prosody.im/doc/components}.
  18988. Defaults to @samp{()}.
  18989. Available @code{ext-component-configuration} fields are:
  18990. 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:
  18991. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  18992. Password which the component will use to log in.
  18993. @end deftypevr
  18994. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  18995. Hostname of the component.
  18996. @end deftypevr
  18997. @end deftypevr
  18998. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  18999. Port(s) Prosody listens on for component connections.
  19000. Defaults to @samp{(5347)}.
  19001. @end deftypevr
  19002. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  19003. Interface Prosody listens on for component connections.
  19004. Defaults to @samp{"127.0.0.1"}.
  19005. @end deftypevr
  19006. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  19007. Raw content that will be added to the configuration file.
  19008. @end deftypevr
  19009. It could be that you just want to get a @code{prosody.cfg.lua}
  19010. up and running. In that case, you can pass an
  19011. @code{opaque-prosody-configuration} record as the value of
  19012. @code{prosody-service-type}. As its name indicates, an opaque configuration
  19013. does not have easy reflective capabilities.
  19014. Available @code{opaque-prosody-configuration} fields are:
  19015. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  19016. The prosody package.
  19017. @end deftypevr
  19018. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  19019. The contents of the @code{prosody.cfg.lua} to use.
  19020. @end deftypevr
  19021. For example, if your @code{prosody.cfg.lua} is just the empty
  19022. string, you could instantiate a prosody service like this:
  19023. @lisp
  19024. (service prosody-service-type
  19025. (opaque-prosody-configuration
  19026. (prosody.cfg.lua "")))
  19027. @end lisp
  19028. @c end of Prosody auto-generated documentation
  19029. @subsubheading BitlBee Service
  19030. @cindex IRC (Internet Relay Chat)
  19031. @cindex IRC gateway
  19032. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  19033. interface to a variety of messaging protocols such as XMPP.
  19034. @defvr {Scheme Variable} bitlbee-service-type
  19035. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  19036. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  19037. below).
  19038. To have BitlBee listen on port 6667 on localhost, add this line to your
  19039. services:
  19040. @lisp
  19041. (service bitlbee-service-type)
  19042. @end lisp
  19043. @end defvr
  19044. @deftp {Data Type} bitlbee-configuration
  19045. This is the configuration for BitlBee, with the following fields:
  19046. @table @asis
  19047. @item @code{interface} (default: @code{"127.0.0.1"})
  19048. @itemx @code{port} (default: @code{6667})
  19049. Listen on the network interface corresponding to the IP address
  19050. specified in @var{interface}, on @var{port}.
  19051. When @var{interface} is @code{127.0.0.1}, only local clients can
  19052. connect; when it is @code{0.0.0.0}, connections can come from any
  19053. networking interface.
  19054. @item @code{bitlbee} (default: @code{bitlbee})
  19055. The BitlBee package to use.
  19056. @item @code{plugins} (default: @code{'()})
  19057. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  19058. @item @code{extra-settings} (default: @code{""})
  19059. Configuration snippet added as-is to the BitlBee configuration file.
  19060. @end table
  19061. @end deftp
  19062. @subsubheading Quassel Service
  19063. @cindex IRC (Internet Relay Chat)
  19064. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  19065. meaning that one or more clients can attach to and detach from the
  19066. central core.
  19067. @defvr {Scheme Variable} quassel-service-type
  19068. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  19069. IRC backend daemon. Its value is a @code{quassel-configuration}
  19070. (see below).
  19071. @end defvr
  19072. @deftp {Data Type} quassel-configuration
  19073. This is the configuration for Quassel, with the following fields:
  19074. @table @asis
  19075. @item @code{quassel} (default: @code{quassel})
  19076. The Quassel package to use.
  19077. @item @code{interface} (default: @code{"::,0.0.0.0"})
  19078. @item @code{port} (default: @code{4242})
  19079. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  19080. interfaces specified in the comma delimited @var{interface}, on
  19081. @var{port}.
  19082. @item @code{loglevel} (default: @code{"Info"})
  19083. The level of logging desired. Accepted values are Debug, Info, Warning
  19084. and Error.
  19085. @end table
  19086. @end deftp
  19087. @node Telephony Services
  19088. @subsection Telephony Services
  19089. @cindex telephony, services
  19090. The @code{(gnu services telephony)} module contains Guix service
  19091. definitions for telephony services. Currently it provides the following
  19092. services:
  19093. @subsubheading Jami
  19094. @cindex jami, service
  19095. This section describes how to configure a Jami server that can be used
  19096. to host video (or audio) conferences, among other uses. The following
  19097. example demonstrates how to specify Jami account archives (backups) to
  19098. be provisioned automatically:
  19099. @lisp
  19100. (service jami-service-type
  19101. (jami-configuration
  19102. (accounts
  19103. (list (jami-account
  19104. (archive "/etc/jami/unencrypted-account-1.gz"))
  19105. (jami-account
  19106. (archive "/etc/jami/unencrypted-account-2.gz"))))))
  19107. @end lisp
  19108. When the accounts field is specified, the Jami account files of the
  19109. service found under @file{/var/lib/jami} are recreated every time the
  19110. service starts.
  19111. Jami accounts and their corresponding backup archives can be generated
  19112. using either the @code{jami-qt} or @code{jami-gnome} Jami clients. The
  19113. accounts should not be password-protected, but it is wise to ensure
  19114. their files are only readable by @samp{root}.
  19115. The next example shows how to declare that only some contacts should be
  19116. allowed to communicate with a given account:
  19117. @lisp
  19118. (service jami-service-type
  19119. (jami-configuration
  19120. (accounts
  19121. (list (jami-account
  19122. (archive "/etc/jami/unencrypted-account-1.gz")
  19123. (peer-discovery? #t)
  19124. (rendezvous-point? #t)
  19125. (allowed-contacts
  19126. '("1dbcb0f5f37324228235564b79f2b9737e9a008f"
  19127. "2dbcb0f5f37324228235564b79f2b9737e9a008f")))))))
  19128. @end lisp
  19129. In this mode, only the declared @code{allowed-contacts} can initiate
  19130. communication with the Jami account. This can be used, for example,
  19131. with rendezvous point accounts to create a private video conferencing
  19132. space.
  19133. To put the system administrator in full control of the conferences
  19134. hosted on their system, the Jami service supports the following actions:
  19135. @example sh
  19136. # herd doc jami list-actions
  19137. (list-accounts
  19138. list-account-details
  19139. list-banned-contacts
  19140. list-contacts
  19141. list-moderators
  19142. add-moderator
  19143. ban-contact
  19144. enable-account
  19145. disable-account)
  19146. @end example
  19147. The above actions aim to provide the most valuable actions for
  19148. moderation purposes, not to cover the whole Jami API. Users wanting to
  19149. interact with the Jami daemon from Guile may be interested in
  19150. experimenting with the @code{(gnu build jami-service)} module, which
  19151. powers the above Shepherd actions.
  19152. @c TODO: This should be auto-generated from the doc already defined on
  19153. @c the shepherd-actions themselves in (gnu services telephony).
  19154. The @code{add-moderator} and @code{ban-contact} actions accept a contact
  19155. @emph{fingerprint} (40 characters long hash) as first argument and an
  19156. account fingerprint or username as second argument:
  19157. @example sh
  19158. # herd add-moderator jami 1dbcb0f5f37324228235564b79f2b9737e9a008f \
  19159. f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19160. # herd list-moderators jami
  19161. Moderators for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  19162. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19163. @end example
  19164. In the case of @code{ban-contact}, the second username argument is
  19165. optional; when omitted, the account is banned from all Jami accounts:
  19166. @example sh
  19167. # herd ban-contact jami 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19168. # herd list-banned-contacts jami
  19169. Banned contacts for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  19170. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19171. @end example
  19172. Banned contacts are also stripped from their moderation privileges.
  19173. The @code{disable-account} action allows to completely disconnect an
  19174. account from the network, making it unreachable, while
  19175. @code{enable-account} does the inverse. They accept a single account
  19176. username or fingerprint as first argument:
  19177. @example sh
  19178. # herd disable-account jami f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19179. # herd list-accounts jami
  19180. The following Jami accounts are available:
  19181. - f3345f2775ddfe07a4b0d95daea111d15fbc1199 (dummy) [disabled]
  19182. @end example
  19183. The @code{list-account-details} action prints the detailed parameters of
  19184. each accounts in the Recutils format, which means the @command{recsel}
  19185. command can be used to select accounts of interest (@pxref{Selection
  19186. Expressions,,,recutils, GNU recutils manual}). Note that period
  19187. characters (@samp{.}) found in the account parameter keys are mapped to
  19188. underscores (@samp{_}) in the output, to meet the requirements of the
  19189. Recutils format. The following example shows how to print the account
  19190. fingerprints for all accounts operating in the rendezvous point mode:
  19191. @example sh
  19192. # herd list-account-details jami | \
  19193. recsel -p Account.username -e 'Account.rendezVous ~ "true"'
  19194. Account_username: f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19195. @end example
  19196. The remaining actions should be self-explanatory.
  19197. The complete set of available configuration options is detailed below.
  19198. @c TODO: Ideally, the following fragments would be auto-generated at
  19199. @c build time, so that they needn't be manually duplicated.
  19200. @c Auto-generated via (configuration->documentation 'jami-configuration)
  19201. @deftp {Data Type} jami-configuration
  19202. Available @code{jami-configuration} fields are:
  19203. @table @asis
  19204. @item @code{jamid} (default: @code{libring}) (type: package)
  19205. The Jami daemon package to use.
  19206. @item @code{dbus} (default: @code{dbus}) (type: package)
  19207. The D-Bus package to use to start the required D-Bus session.
  19208. @item @code{nss-certs} (default: @code{nss-certs}) (type: package)
  19209. The nss-certs package to use to provide TLS certificates.
  19210. @item @code{enable-logging?} (default: @code{#t}) (type: boolean)
  19211. Whether to enable logging to syslog.
  19212. @item @code{debug?} (default: @code{#f}) (type: boolean)
  19213. Whether to enable debug level messages.
  19214. @item @code{auto-answer?} (default: @code{#f}) (type: boolean)
  19215. Whether to force automatic answer to incoming calls.
  19216. @item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
  19217. A list of Jami accounts to be (re-)provisioned every time the Jami
  19218. daemon service starts. When providing this field, the account
  19219. directories under @file{/var/lib/jami/} are recreated every time the
  19220. service starts, ensuring a consistent state.
  19221. @end table
  19222. @end deftp
  19223. @c Auto-generated via (configuration->documentation 'jami-account)
  19224. @deftp {Data Type} jami-account
  19225. Available @code{jami-account} fields are:
  19226. @table @asis
  19227. @item @code{archive} (type: string-or-computed-file)
  19228. The account archive (backup) file name of the account. This is used to
  19229. provision the account when the service starts. The account archive
  19230. should @emph{not} be encrypted. It is highly recommended to make it
  19231. readable only to the @samp{root} user (i.e., not in the store), to guard
  19232. against leaking the secret key material of the Jami account it contains.
  19233. @item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  19234. The list of allowed contacts for the account, entered as their 40
  19235. characters long fingerprint. Messages or calls from accounts not in
  19236. that list will be rejected. When unspecified, the configuration of the
  19237. account archive is used as-is with respect to contacts and public
  19238. inbound calls/messaging allowance, which typically defaults to allow any
  19239. contact to communicate with the account.
  19240. @item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  19241. The list of contacts that should have moderation privileges (to ban,
  19242. mute, etc. other users) in rendezvous conferences, entered as their 40
  19243. characters long fingerprint. When unspecified, the configuration of the
  19244. account archive is used as-is with respect to moderation, which
  19245. typically defaults to allow anyone to moderate.
  19246. @item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
  19247. Whether the account should operate in the rendezvous mode. In this
  19248. mode, all the incoming audio/video calls are mixed into a conference.
  19249. When left unspecified, the value from the account archive prevails.
  19250. @item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
  19251. Whether peer discovery should be enabled. Peer discovery is used to
  19252. discover other OpenDHT nodes on the local network, which can be useful
  19253. to maintain communication between devices on such network even when the
  19254. connection to the the Internet has been lost. When left unspecified,
  19255. the value from the account archive prevails.
  19256. @item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
  19257. A list of hostnames or IPs pointing to OpenDHT nodes, that should be
  19258. used to initially join the OpenDHT network. When left unspecified, the
  19259. value from the account archive prevails.
  19260. @item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
  19261. The URI of the name server to use, that can be used to retrieve the
  19262. account fingerprint for a registered username.
  19263. @end table
  19264. @end deftp
  19265. @subsubheading Murmur (VoIP server)
  19266. @cindex Murmur (VoIP server)
  19267. @cindex VoIP server
  19268. This section describes how to set up and run a Murmur server. Murmur is
  19269. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  19270. (VoIP) suite.
  19271. @deftp {Data Type} murmur-configuration
  19272. The service type for the Murmur server. An example configuration can
  19273. look like this:
  19274. @lisp
  19275. (service murmur-service-type
  19276. (murmur-configuration
  19277. (welcome-text
  19278. "Welcome to this Mumble server running on Guix!")
  19279. (cert-required? #t) ;disallow text password logins
  19280. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  19281. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  19282. @end lisp
  19283. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  19284. password with the command that is printed during the activation phase.
  19285. It is recommended to register a normal Mumble user account
  19286. and grant it admin or moderator rights.
  19287. You can use the @code{mumble} client to
  19288. login as new normal user, register yourself, and log out.
  19289. For the next step login with the name @code{SuperUser} use
  19290. the @code{SuperUser} password that you set previously,
  19291. and grant your newly registered mumble user administrator or moderator
  19292. rights and create some channels.
  19293. Available @code{murmur-configuration} fields are:
  19294. @table @asis
  19295. @item @code{package} (default: @code{mumble})
  19296. Package that contains @code{bin/murmurd}.
  19297. @item @code{user} (default: @code{"murmur"})
  19298. User who will run the Murmur server.
  19299. @item @code{group} (default: @code{"murmur"})
  19300. Group of the user who will run the murmur server.
  19301. @item @code{port} (default: @code{64738})
  19302. Port on which the server will listen.
  19303. @item @code{welcome-text} (default: @code{""})
  19304. Welcome text sent to clients when they connect.
  19305. @item @code{server-password} (default: @code{""})
  19306. Password the clients have to enter in order to connect.
  19307. @item @code{max-users} (default: @code{100})
  19308. Maximum of users that can be connected to the server at once.
  19309. @item @code{max-user-bandwidth} (default: @code{#f})
  19310. Maximum voice traffic a user can send per second.
  19311. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  19312. File name of the sqlite database.
  19313. The service's user will become the owner of the directory.
  19314. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  19315. File name of the log file.
  19316. The service's user will become the owner of the directory.
  19317. @item @code{autoban-attempts} (default: @code{10})
  19318. Maximum number of logins a user can make in @code{autoban-timeframe}
  19319. without getting auto banned for @code{autoban-time}.
  19320. @item @code{autoban-timeframe} (default: @code{120})
  19321. Timeframe for autoban in seconds.
  19322. @item @code{autoban-time} (default: @code{300})
  19323. Amount of time in seconds for which a client gets banned
  19324. when violating the autoban limits.
  19325. @item @code{opus-threshold} (default: @code{100})
  19326. Percentage of clients that need to support opus
  19327. before switching over to opus audio codec.
  19328. @item @code{channel-nesting-limit} (default: @code{10})
  19329. How deep channels can be nested at maximum.
  19330. @item @code{channelname-regex} (default: @code{#f})
  19331. A string in form of a Qt regular expression that channel names must conform to.
  19332. @item @code{username-regex} (default: @code{#f})
  19333. A string in form of a Qt regular expression that user names must conform to.
  19334. @item @code{text-message-length} (default: @code{5000})
  19335. Maximum size in bytes that a user can send in one text chat message.
  19336. @item @code{image-message-length} (default: @code{(* 128 1024)})
  19337. Maximum size in bytes that a user can send in one image message.
  19338. @item @code{cert-required?} (default: @code{#f})
  19339. If it is set to @code{#t} clients that use weak password authentication
  19340. will not be accepted. Users must have completed the certificate wizard to join.
  19341. @item @code{remember-channel?} (default: @code{#f})
  19342. Should murmur remember the last channel each user was in when they disconnected
  19343. and put them into the remembered channel when they rejoin.
  19344. @item @code{allow-html?} (default: @code{#f})
  19345. Should html be allowed in text messages, user comments, and channel descriptions.
  19346. @item @code{allow-ping?} (default: @code{#f})
  19347. Setting to true exposes the current user count, the maximum user count, and
  19348. the server's maximum bandwidth per client to unauthenticated users. In the
  19349. Mumble client, this information is shown in the Connect dialog.
  19350. Disabling this setting will prevent public listing of the server.
  19351. @item @code{bonjour?} (default: @code{#f})
  19352. Should the server advertise itself in the local network through the bonjour protocol.
  19353. @item @code{send-version?} (default: @code{#f})
  19354. Should the murmur server version be exposed in ping requests.
  19355. @item @code{log-days} (default: @code{31})
  19356. Murmur also stores logs in the database, which are accessible via RPC.
  19357. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  19358. or -1 to disable logging to the database.
  19359. @item @code{obfuscate-ips?} (default: @code{#t})
  19360. Should logged ips be obfuscated to protect the privacy of users.
  19361. @item @code{ssl-cert} (default: @code{#f})
  19362. File name of the SSL/TLS certificate used for encrypted connections.
  19363. @lisp
  19364. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  19365. @end lisp
  19366. @item @code{ssl-key} (default: @code{#f})
  19367. Filepath to the ssl private key used for encrypted connections.
  19368. @lisp
  19369. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  19370. @end lisp
  19371. @item @code{ssl-dh-params} (default: @code{#f})
  19372. File name of a PEM-encoded file with Diffie-Hellman parameters
  19373. for the SSL/TLS encryption. Alternatively you set it to
  19374. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  19375. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  19376. @item @code{ssl-ciphers} (default: @code{#f})
  19377. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  19378. in SSL/TLS.
  19379. This option is specified using
  19380. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  19381. OpenSSL cipher list notation}.
  19382. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  19383. before setting it here, to get a feel for which cipher suites you will get.
  19384. After setting this option, it is recommend that you inspect your Murmur log
  19385. to ensure that Murmur is using the cipher suites that you expected it to.
  19386. Note: Changing this option may impact the backwards compatibility of your
  19387. Murmur server, and can remove the ability for older Mumble clients to be able
  19388. to connect to it.
  19389. @item @code{public-registration} (default: @code{#f})
  19390. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  19391. You can optionally register your server in the public server list that the
  19392. @code{mumble} client shows on startup.
  19393. You cannot register your server if you have set a @code{server-password},
  19394. or set @code{allow-ping} to @code{#f}.
  19395. It might take a few hours until it shows up in the public list.
  19396. @item @code{file} (default: @code{#f})
  19397. Optional alternative override for this configuration.
  19398. @end table
  19399. @end deftp
  19400. @deftp {Data Type} murmur-public-registration-configuration
  19401. Configuration for public registration of a murmur service.
  19402. @table @asis
  19403. @item @code{name}
  19404. This is a display name for your server. Not to be confused with the hostname.
  19405. @item @code{password}
  19406. A password to identify your registration.
  19407. Subsequent updates will need the same password. Don't lose your password.
  19408. @item @code{url}
  19409. This should be a @code{http://} or @code{https://} link to your web
  19410. site.
  19411. @item @code{hostname} (default: @code{#f})
  19412. By default your server will be listed by its IP address.
  19413. If it is set your server will be linked by this host name instead.
  19414. @end table
  19415. @end deftp
  19416. @node File-Sharing Services
  19417. @subsection File-Sharing Services
  19418. The @code{(gnu services file-sharing)} module provides services that
  19419. assist with transferring files over peer-to-peer file-sharing networks.
  19420. @subsubheading Transmission Daemon Service
  19421. @uref{https://transmissionbt.com/, Transmission} is a flexible
  19422. BitTorrent client that offers a variety of graphical and command-line
  19423. interfaces. A @code{transmission-daemon-service-type} service provides
  19424. Transmission's headless variant, @command{transmission-daemon}, as a
  19425. system service, allowing users to share files via BitTorrent even when
  19426. they are not logged in.
  19427. @deffn {Scheme Variable} transmission-daemon-service-type
  19428. The service type for the Transmission Daemon BitTorrent client. Its
  19429. value must be a @code{transmission-daemon-configuration} object as in
  19430. this example:
  19431. @lisp
  19432. (service transmission-daemon-service-type
  19433. (transmission-daemon-configuration
  19434. ;; Restrict access to the RPC ("control") interface
  19435. (rpc-authentication-required? #t)
  19436. (rpc-username "transmission")
  19437. (rpc-password
  19438. (transmission-password-hash
  19439. "transmission" ; desired password
  19440. "uKd1uMs9")) ; arbitrary salt value
  19441. ;; Accept requests from this and other hosts on the
  19442. ;; local network
  19443. (rpc-whitelist-enabled? #t)
  19444. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  19445. ;; Limit bandwidth use during work hours
  19446. (alt-speed-down (* 1024 2)) ; 2 MB/s
  19447. (alt-speed-up 512) ; 512 kB/s
  19448. (alt-speed-time-enabled? #t)
  19449. (alt-speed-time-day 'weekdays)
  19450. (alt-speed-time-begin
  19451. (+ (* 60 8) 30)) ; 8:30 am
  19452. (alt-speed-time-end
  19453. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  19454. @end lisp
  19455. @end deffn
  19456. Once the service is started, users can interact with the daemon through
  19457. its Web interface (at @code{http://localhost:9091/}) or by using the
  19458. @command{transmission-remote} command-line tool, available in the
  19459. @code{transmission} package. (Emacs users may want to also consider the
  19460. @code{emacs-transmission} package.) Both communicate with the daemon
  19461. through its remote procedure call (RPC) interface, which by default is
  19462. available to all users on the system; you may wish to change this by
  19463. assigning values to the @code{rpc-authentication-required?},
  19464. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  19465. example above and documented further below.
  19466. The value for @code{rpc-password} must be a password hash of the type
  19467. generated and used by Transmission clients. This can be copied verbatim
  19468. from an existing @file{settings.json} file, if another Transmission
  19469. client is already being used. Otherwise, the
  19470. @code{transmission-password-hash} and @code{transmission-random-salt}
  19471. procedures provided by this module can be used to obtain a suitable hash
  19472. value.
  19473. @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
  19474. Returns a string containing the result of hashing @var{password}
  19475. together with @var{salt}, in the format recognized by Transmission
  19476. clients for their @code{rpc-password} configuration setting.
  19477. @var{salt} must be an eight-character string. The
  19478. @code{transmission-random-salt} procedure can be used to generate a
  19479. suitable salt value at random.
  19480. @end deffn
  19481. @deffn {Scheme Procedure} transmission-random-salt
  19482. Returns a string containing a random, eight-character salt value of the
  19483. type generated and used by Transmission clients, suitable for passing to
  19484. the @code{transmission-password-hash} procedure.
  19485. @end deffn
  19486. These procedures are accessible from within a Guile REPL started with
  19487. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  19488. useful for obtaining a random salt value to provide as the second
  19489. parameter to `transmission-password-hash`, as in this example session:
  19490. @example
  19491. $ guix repl
  19492. scheme@@(guix-user)> ,use (gnu services file-sharing)
  19493. scheme@@(guix-user)> (transmission-random-salt)
  19494. $1 = "uKd1uMs9"
  19495. @end example
  19496. Alternatively, a complete password hash can generated in a single step:
  19497. @example
  19498. scheme@@(guix-user)> (transmission-password-hash "transmission"
  19499. (transmission-random-salt))
  19500. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  19501. @end example
  19502. The resulting string can be used as-is for the value of
  19503. @code{rpc-password}, allowing the password to be kept hidden even in the
  19504. operating-system configuration.
  19505. Torrent files downloaded by the daemon are directly accessible only to
  19506. users in the ``transmission'' user group, who receive read-only access
  19507. to the directory specified by the @code{download-dir} configuration
  19508. setting (and also the directory specified by @code{incomplete-dir}, if
  19509. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  19510. moved to another directory or deleted altogether using
  19511. @command{transmission-remote} with its @code{--move} and
  19512. @code{--remove-and-delete} options.
  19513. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  19514. the ``transmission'' group are able also to place @file{.torrent} files
  19515. in the directory specified by @code{watch-dir} to have the corresponding
  19516. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  19517. setting controls whether the daemon deletes these files after processing
  19518. them.)
  19519. Some of the daemon's configuration settings can be changed temporarily
  19520. by @command{transmission-remote} and similar tools. To undo these
  19521. changes, use the service's @code{reload} action to have the daemon
  19522. reload its settings from disk:
  19523. @example
  19524. # herd reload transmission-daemon
  19525. @end example
  19526. The full set of available configuration settings is defined by the
  19527. @code{transmission-daemon-configuration} data type.
  19528. @deftp {Data Type} transmission-daemon-configuration
  19529. The data type representing configuration settings for Transmission
  19530. Daemon. These correspond directly to the settings recognized by
  19531. Transmission clients in their @file{settings.json} file.
  19532. @end deftp
  19533. @c The following documentation was initially generated by
  19534. @c (generate-transmission-daemon-documentation) in (gnu services
  19535. @c file-sharing). Manually maintained documentation is better, so we
  19536. @c shouldn't hesitate to edit below as needed. However if the change
  19537. @c you want to make to this documentation can be done in an automated
  19538. @c way, it's probably easier to change (generate-documentation) than to
  19539. @c make it below and have to deal with the churn as Transmission Daemon
  19540. @c updates.
  19541. @c %start of fragment
  19542. Available @code{transmission-daemon-configuration} fields are:
  19543. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  19544. The Transmission package to use.
  19545. @end deftypevr
  19546. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  19547. The period, in seconds, to wait when stopping the service for
  19548. @command{transmission-daemon} to exit before killing its process. This
  19549. allows the daemon time to complete its housekeeping and send a final
  19550. update to trackers as it shuts down. On slow hosts, or hosts with a
  19551. slow network connection, this value may need to be increased.
  19552. Defaults to @samp{10}.
  19553. @end deftypevr
  19554. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  19555. The directory to which torrent files are downloaded.
  19556. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  19557. @end deftypevr
  19558. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  19559. If @code{#t}, files will be held in @code{incomplete-dir} while their
  19560. torrent is being downloaded, then moved to @code{download-dir} once the
  19561. torrent is complete. Otherwise, files for all torrents (including those
  19562. still being downloaded) will be placed in @code{download-dir}.
  19563. Defaults to @samp{#f}.
  19564. @end deftypevr
  19565. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  19566. The directory in which files from incompletely downloaded torrents will
  19567. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  19568. Defaults to @samp{disabled}.
  19569. @end deftypevr
  19570. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  19571. The file mode creation mask used for downloaded files. (See the
  19572. @command{umask} man page for more information.)
  19573. Defaults to @samp{18}.
  19574. @end deftypevr
  19575. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  19576. When @code{#t}, ``.part'' is appended to the name of partially
  19577. downloaded files.
  19578. Defaults to @samp{#t}.
  19579. @end deftypevr
  19580. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  19581. The mode by which space should be preallocated for downloaded files, one
  19582. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  19583. Specifying @code{full} will minimize disk fragmentation at a cost to
  19584. file-creation speed.
  19585. Defaults to @samp{fast}.
  19586. @end deftypevr
  19587. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  19588. If @code{#t}, the directory specified by @code{watch-dir} will be
  19589. watched for new @file{.torrent} files and the torrents they describe
  19590. added automatically (and the original files removed, if
  19591. @code{trash-original-torrent-files?} is @code{#t}).
  19592. Defaults to @samp{#f}.
  19593. @end deftypevr
  19594. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  19595. The directory to be watched for @file{.torrent} files indicating new
  19596. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  19597. Defaults to @samp{disabled}.
  19598. @end deftypevr
  19599. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  19600. When @code{#t}, @file{.torrent} files will be deleted from the watch
  19601. directory once their torrent has been added (see
  19602. @code{watch-directory-enabled?}).
  19603. Defaults to @samp{#f}.
  19604. @end deftypevr
  19605. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  19606. When @code{#t}, the daemon's download speed will be limited to the rate
  19607. specified by @code{speed-limit-down}.
  19608. Defaults to @samp{#f}.
  19609. @end deftypevr
  19610. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  19611. The default global-maximum download speed, in kilobytes per second.
  19612. Defaults to @samp{100}.
  19613. @end deftypevr
  19614. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  19615. When @code{#t}, the daemon's upload speed will be limited to the rate
  19616. specified by @code{speed-limit-up}.
  19617. Defaults to @samp{#f}.
  19618. @end deftypevr
  19619. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  19620. The default global-maximum upload speed, in kilobytes per second.
  19621. Defaults to @samp{100}.
  19622. @end deftypevr
  19623. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  19624. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  19625. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  19626. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  19627. bandwidth usage. This can be scheduled to occur automatically at
  19628. certain times during the week; see @code{alt-speed-time-enabled?}.
  19629. Defaults to @samp{#f}.
  19630. @end deftypevr
  19631. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  19632. The alternate global-maximum download speed, in kilobytes per second.
  19633. Defaults to @samp{50}.
  19634. @end deftypevr
  19635. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  19636. The alternate global-maximum upload speed, in kilobytes per second.
  19637. Defaults to @samp{50}.
  19638. @end deftypevr
  19639. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  19640. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  19641. @code{alt-speed-up} will be enabled automatically during the periods
  19642. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  19643. @code{alt-time-speed-end}.
  19644. Defaults to @samp{#f}.
  19645. @end deftypevr
  19646. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  19647. The days of the week on which the alternate-speed schedule should be
  19648. used, specified either as a list of days (@code{sunday}, @code{monday},
  19649. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  19650. or @code{all}.
  19651. Defaults to @samp{all}.
  19652. @end deftypevr
  19653. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  19654. The time of day at which to enable the alternate speed limits, expressed
  19655. as a number of minutes since midnight.
  19656. Defaults to @samp{540}.
  19657. @end deftypevr
  19658. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  19659. The time of day at which to disable the alternate speed limits,
  19660. expressed as a number of minutes since midnight.
  19661. Defaults to @samp{1020}.
  19662. @end deftypevr
  19663. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  19664. The IP address at which to listen for peer connections, or ``0.0.0.0''
  19665. to listen at all available IP addresses.
  19666. Defaults to @samp{"0.0.0.0"}.
  19667. @end deftypevr
  19668. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  19669. The IPv6 address at which to listen for peer connections, or ``::'' to
  19670. listen at all available IPv6 addresses.
  19671. Defaults to @samp{"::"}.
  19672. @end deftypevr
  19673. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  19674. If @code{#t}, when the daemon starts it will select a port at random on
  19675. which to listen for peer connections, from the range specified
  19676. (inclusively) by @code{peer-port-random-low} and
  19677. @code{peer-port-random-high}. Otherwise, it listens on the port
  19678. specified by @code{peer-port}.
  19679. Defaults to @samp{#f}.
  19680. @end deftypevr
  19681. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  19682. The lowest selectable port number when @code{peer-port-random-on-start?}
  19683. is @code{#t}.
  19684. Defaults to @samp{49152}.
  19685. @end deftypevr
  19686. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  19687. The highest selectable port number when @code{peer-port-random-on-start}
  19688. is @code{#t}.
  19689. Defaults to @samp{65535}.
  19690. @end deftypevr
  19691. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  19692. The port on which to listen for peer connections when
  19693. @code{peer-port-random-on-start?} is @code{#f}.
  19694. Defaults to @samp{51413}.
  19695. @end deftypevr
  19696. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  19697. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  19698. upstream gateway automatically using @acronym{UPnP} and
  19699. @acronym{NAT-PMP}.
  19700. Defaults to @samp{#t}.
  19701. @end deftypevr
  19702. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  19703. The encryption preference for peer connections, one of
  19704. @code{prefer-unencrypted-connections},
  19705. @code{prefer-encrypted-connections} or
  19706. @code{require-encrypted-connections}.
  19707. Defaults to @samp{prefer-encrypted-connections}.
  19708. @end deftypevr
  19709. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  19710. The TCP congestion-control algorithm to use for peer connections,
  19711. specified using a string recognized by the operating system in calls to
  19712. @code{setsockopt} (or set to @code{disabled}, in which case the
  19713. operating-system default is used).
  19714. Note that on GNU/Linux systems, the kernel must be configured to allow
  19715. processes to use a congestion-control algorithm not in the default set;
  19716. otherwise, it will deny these requests with ``Operation not permitted''.
  19717. To see which algorithms are available on your system and which are
  19718. currently permitted for use, look at the contents of the files
  19719. @file{tcp_available_congestion_control} and
  19720. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  19721. directory.
  19722. As an example, to have Transmission Daemon use
  19723. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  19724. congestion-control algorithm}, you'll need to modify your kernel
  19725. configuration to build in support for the algorithm, then update your
  19726. operating-system configuration to allow its use by adding a
  19727. @code{sysctl-service-type} service (or updating the existing one's
  19728. configuration) with lines like the following:
  19729. @lisp
  19730. (service sysctl-service-type
  19731. (sysctl-configuration
  19732. (settings
  19733. ("net.ipv4.tcp_allowed_congestion_control" .
  19734. "reno cubic lp"))))
  19735. @end lisp
  19736. The Transmission Daemon configuration can then be updated with
  19737. @lisp
  19738. (peer-congestion-algorithm "lp")
  19739. @end lisp
  19740. and the system reconfigured to have the changes take effect.
  19741. Defaults to @samp{disabled}.
  19742. @end deftypevr
  19743. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  19744. The type of service to request in outgoing @acronym{TCP} packets, one of
  19745. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  19746. @code{reliability}.
  19747. Defaults to @samp{default}.
  19748. @end deftypevr
  19749. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  19750. The global limit on the number of connected peers.
  19751. Defaults to @samp{200}.
  19752. @end deftypevr
  19753. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  19754. The per-torrent limit on the number of connected peers.
  19755. Defaults to @samp{50}.
  19756. @end deftypevr
  19757. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  19758. The maximum number of peers to which the daemon will upload data
  19759. simultaneously for each torrent.
  19760. Defaults to @samp{14}.
  19761. @end deftypevr
  19762. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  19763. The maximum lifespan, in hours, of the peer ID associated with each
  19764. public torrent before it is regenerated.
  19765. Defaults to @samp{6}.
  19766. @end deftypevr
  19767. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  19768. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  19769. it has most recently downloaded from @code{blocklist-url}.
  19770. Defaults to @samp{#f}.
  19771. @end deftypevr
  19772. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  19773. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  19774. @file{.dat} format) to be periodically downloaded and applied when
  19775. @code{blocklist-enabled?} is @code{#t}.
  19776. Defaults to @samp{disabled}.
  19777. @end deftypevr
  19778. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  19779. If @code{#t}, the daemon will be limited to downloading at most
  19780. @code{download-queue-size} non-stalled torrents simultaneously.
  19781. Defaults to @samp{#t}.
  19782. @end deftypevr
  19783. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  19784. The size of the daemon's download queue, which limits the number of
  19785. non-stalled torrents it will download at any one time when
  19786. @code{download-queue-enabled?} is @code{#t}.
  19787. Defaults to @samp{5}.
  19788. @end deftypevr
  19789. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  19790. If @code{#t}, the daemon will be limited to seeding at most
  19791. @code{seed-queue-size} non-stalled torrents simultaneously.
  19792. Defaults to @samp{#f}.
  19793. @end deftypevr
  19794. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  19795. The size of the daemon's seed queue, which limits the number of
  19796. non-stalled torrents it will seed at any one time when
  19797. @code{seed-queue-enabled?} is @code{#t}.
  19798. Defaults to @samp{10}.
  19799. @end deftypevr
  19800. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  19801. When @code{#t}, the daemon will consider torrents for which it has not
  19802. shared data in the past @code{queue-stalled-minutes} minutes to be
  19803. stalled and not count them against its @code{download-queue-size} and
  19804. @code{seed-queue-size} limits.
  19805. Defaults to @samp{#t}.
  19806. @end deftypevr
  19807. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  19808. The maximum period, in minutes, a torrent may be idle before it is
  19809. considered to be stalled, when @code{queue-stalled-enabled?} is
  19810. @code{#t}.
  19811. Defaults to @samp{30}.
  19812. @end deftypevr
  19813. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  19814. When @code{#t}, a torrent being seeded will automatically be paused once
  19815. it reaches the ratio specified by @code{ratio-limit}.
  19816. Defaults to @samp{#f}.
  19817. @end deftypevr
  19818. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  19819. The ratio at which a torrent being seeded will be paused, when
  19820. @code{ratio-limit-enabled?} is @code{#t}.
  19821. Defaults to @samp{2.0}.
  19822. @end deftypevr
  19823. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  19824. When @code{#t}, a torrent being seeded will automatically be paused once
  19825. it has been idle for @code{idle-seeding-limit} minutes.
  19826. Defaults to @samp{#f}.
  19827. @end deftypevr
  19828. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  19829. The maximum period, in minutes, a torrent being seeded may be idle
  19830. before it is paused, when @code{idle-seeding-limit-enabled?} is
  19831. @code{#t}.
  19832. Defaults to @samp{30}.
  19833. @end deftypevr
  19834. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  19835. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  19836. hash table (@acronym{DHT}) protocol}, which supports the use of
  19837. trackerless torrents.
  19838. Defaults to @samp{#t}.
  19839. @end deftypevr
  19840. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  19841. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  19842. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  19843. the local network and may reduce the amount of data sent over the public
  19844. Internet.
  19845. Defaults to @samp{#f}.
  19846. @end deftypevr
  19847. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  19848. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  19849. (@acronym{PEX}), which reduces the daemon's reliance on external
  19850. trackers and may improve its performance.
  19851. Defaults to @samp{#t}.
  19852. @end deftypevr
  19853. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  19854. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  19855. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  19856. BitTorrent traffic on other users of the local network while maintaining
  19857. full utilization of the available bandwidth.
  19858. Defaults to @samp{#t}.
  19859. @end deftypevr
  19860. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  19861. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  19862. interface, which allows remote control of the daemon via its Web
  19863. interface, the @command{transmission-remote} command-line client, and
  19864. similar tools.
  19865. Defaults to @samp{#t}.
  19866. @end deftypevr
  19867. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  19868. The IP address at which to listen for @acronym{RPC} connections, or
  19869. ``0.0.0.0'' to listen at all available IP addresses.
  19870. Defaults to @samp{"0.0.0.0"}.
  19871. @end deftypevr
  19872. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  19873. The port on which to listen for @acronym{RPC} connections.
  19874. Defaults to @samp{9091}.
  19875. @end deftypevr
  19876. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  19877. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  19878. Defaults to @samp{"/transmission/"}.
  19879. @end deftypevr
  19880. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  19881. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  19882. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  19883. has the side effect of disabling host-name whitelisting (see
  19884. @code{rpc-host-whitelist-enabled?}.
  19885. Defaults to @samp{#f}.
  19886. @end deftypevr
  19887. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  19888. The username required by clients to access the @acronym{RPC} interface
  19889. when @code{rpc-authentication-required?} is @code{#t}.
  19890. Defaults to @samp{disabled}.
  19891. @end deftypevr
  19892. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  19893. The password required by clients to access the @acronym{RPC} interface
  19894. when @code{rpc-authentication-required?} is @code{#t}. This must be
  19895. specified using a password hash in the format recognized by Transmission
  19896. clients, either copied from an existing @file{settings.json} file or
  19897. generated using the @code{transmission-password-hash} procedure.
  19898. Defaults to @samp{disabled}.
  19899. @end deftypevr
  19900. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  19901. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  19902. originate from an address specified in @code{rpc-whitelist}.
  19903. Defaults to @samp{#t}.
  19904. @end deftypevr
  19905. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  19906. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  19907. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  19908. may be specified using @samp{*}.
  19909. Defaults to @samp{("127.0.0.1" "::1")}.
  19910. @end deftypevr
  19911. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  19912. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  19913. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  19914. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  19915. are always accepted regardless of these settings.
  19916. Note also this functionality is disabled when
  19917. @code{rpc-authentication-required?} is @code{#t}.
  19918. Defaults to @samp{#t}.
  19919. @end deftypevr
  19920. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  19921. The list of host names recognized by the @acronym{RPC} server when
  19922. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  19923. Defaults to @samp{()}.
  19924. @end deftypevr
  19925. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  19926. The minimum severity level of messages to be logged (to
  19927. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  19928. logging), @code{error}, @code{info} and @code{debug}.
  19929. Defaults to @samp{info}.
  19930. @end deftypevr
  19931. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  19932. When @code{#t}, torrents are started as soon as they are added;
  19933. otherwise, they are added in ``paused'' state.
  19934. Defaults to @samp{#t}.
  19935. @end deftypevr
  19936. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  19937. When @code{#t}, the script specified by
  19938. @code{script-torrent-done-filename} will be invoked each time a torrent
  19939. completes.
  19940. Defaults to @samp{#f}.
  19941. @end deftypevr
  19942. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  19943. A file name or file-like object specifying a script to run each time a
  19944. torrent completes, when @code{script-torrent-done-enabled?} is
  19945. @code{#t}.
  19946. Defaults to @samp{disabled}.
  19947. @end deftypevr
  19948. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  19949. When @code{#t}, the daemon will scrape trackers for a torrent even when
  19950. the torrent is paused.
  19951. Defaults to @samp{#t}.
  19952. @end deftypevr
  19953. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  19954. The amount of memory, in megabytes, to allocate for the daemon's
  19955. in-memory cache. A larger value may increase performance by reducing
  19956. the frequency of disk I/O.
  19957. Defaults to @samp{4}.
  19958. @end deftypevr
  19959. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  19960. When @code{#t}, the daemon will try to improve I/O performance by
  19961. hinting to the operating system which data is likely to be read next
  19962. from disk to satisfy requests from peers.
  19963. Defaults to @samp{#t}.
  19964. @end deftypevr
  19965. @c %end of fragment
  19966. @node Monitoring Services
  19967. @subsection Monitoring Services
  19968. @subsubheading Tailon Service
  19969. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  19970. viewing and searching log files.
  19971. The following example will configure the service with default values.
  19972. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  19973. @lisp
  19974. (service tailon-service-type)
  19975. @end lisp
  19976. The following example customises more of the Tailon configuration,
  19977. adding @command{sed} to the list of allowed commands.
  19978. @lisp
  19979. (service tailon-service-type
  19980. (tailon-configuration
  19981. (config-file
  19982. (tailon-configuration-file
  19983. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  19984. @end lisp
  19985. @deftp {Data Type} tailon-configuration
  19986. Data type representing the configuration of Tailon.
  19987. This type has the following parameters:
  19988. @table @asis
  19989. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  19990. The configuration file to use for Tailon. This can be set to a
  19991. @dfn{tailon-configuration-file} record value, or any gexp
  19992. (@pxref{G-Expressions}).
  19993. For example, to instead use a local file, the @code{local-file} function
  19994. can be used:
  19995. @lisp
  19996. (service tailon-service-type
  19997. (tailon-configuration
  19998. (config-file (local-file "./my-tailon.conf"))))
  19999. @end lisp
  20000. @item @code{package} (default: @code{tailon})
  20001. The tailon package to use.
  20002. @end table
  20003. @end deftp
  20004. @deftp {Data Type} tailon-configuration-file
  20005. Data type representing the configuration options for Tailon.
  20006. This type has the following parameters:
  20007. @table @asis
  20008. @item @code{files} (default: @code{(list "/var/log")})
  20009. List of files to display. The list can include strings for a single file
  20010. or directory, or a list, where the first item is the name of a
  20011. subsection, and the remaining items are the files or directories in that
  20012. subsection.
  20013. @item @code{bind} (default: @code{"localhost:8080"})
  20014. Address and port to which Tailon should bind on.
  20015. @item @code{relative-root} (default: @code{#f})
  20016. URL path to use for Tailon, set to @code{#f} to not use a path.
  20017. @item @code{allow-transfers?} (default: @code{#t})
  20018. Allow downloading the log files in the web interface.
  20019. @item @code{follow-names?} (default: @code{#t})
  20020. Allow tailing of not-yet existent files.
  20021. @item @code{tail-lines} (default: @code{200})
  20022. Number of lines to read initially from each file.
  20023. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  20024. Commands to allow running. By default, @code{sed} is disabled.
  20025. @item @code{debug?} (default: @code{#f})
  20026. Set @code{debug?} to @code{#t} to show debug messages.
  20027. @item @code{wrap-lines} (default: @code{#t})
  20028. Initial line wrapping state in the web interface. Set to @code{#t} to
  20029. initially wrap lines (the default), or to @code{#f} to initially not
  20030. wrap lines.
  20031. @item @code{http-auth} (default: @code{#f})
  20032. HTTP authentication type to use. Set to @code{#f} to disable
  20033. authentication (the default). Supported values are @code{"digest"} or
  20034. @code{"basic"}.
  20035. @item @code{users} (default: @code{#f})
  20036. If HTTP authentication is enabled (see @code{http-auth}), access will be
  20037. restricted to the credentials provided here. To configure users, use a
  20038. list of pairs, where the first element of the pair is the username, and
  20039. the 2nd element of the pair is the password.
  20040. @lisp
  20041. (tailon-configuration-file
  20042. (http-auth "basic")
  20043. (users '(("user1" . "password1")
  20044. ("user2" . "password2"))))
  20045. @end lisp
  20046. @end table
  20047. @end deftp
  20048. @subsubheading Darkstat Service
  20049. @cindex darkstat
  20050. Darkstat is a packet sniffer that captures network traffic, calculates
  20051. statistics about usage, and serves reports over HTTP.
  20052. @defvar {Scheme Variable} darkstat-service-type
  20053. This is the service type for the
  20054. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  20055. service, its value must be a @code{darkstat-configuration} record as in
  20056. this example:
  20057. @lisp
  20058. (service darkstat-service-type
  20059. (darkstat-configuration
  20060. (interface "eno1")))
  20061. @end lisp
  20062. @end defvar
  20063. @deftp {Data Type} darkstat-configuration
  20064. Data type representing the configuration of @command{darkstat}.
  20065. @table @asis
  20066. @item @code{package} (default: @code{darkstat})
  20067. The darkstat package to use.
  20068. @item @code{interface}
  20069. Capture traffic on the specified network interface.
  20070. @item @code{port} (default: @code{"667"})
  20071. Bind the web interface to the specified port.
  20072. @item @code{bind-address} (default: @code{"127.0.0.1"})
  20073. Bind the web interface to the specified address.
  20074. @item @code{base} (default: @code{"/"})
  20075. Specify the path of the base URL@. This can be useful if
  20076. @command{darkstat} is accessed via a reverse proxy.
  20077. @end table
  20078. @end deftp
  20079. @subsubheading Prometheus Node Exporter Service
  20080. @cindex prometheus-node-exporter
  20081. The Prometheus ``node exporter'' makes hardware and operating system statistics
  20082. provided by the Linux kernel available for the Prometheus monitoring system.
  20083. This service should be deployed on all physical nodes and virtual machines,
  20084. where monitoring these statistics is desirable.
  20085. @defvar {Scheme variable} prometheus-node-exporter-service-type
  20086. This is the service type for the
  20087. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  20088. service, its value must be a @code{prometheus-node-exporter-configuration}.
  20089. @lisp
  20090. (service prometheus-node-exporter-service-type)
  20091. @end lisp
  20092. @end defvar
  20093. @deftp {Data Type} prometheus-node-exporter-configuration
  20094. Data type representing the configuration of @command{node_exporter}.
  20095. @table @asis
  20096. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  20097. The prometheus-node-exporter package to use.
  20098. @item @code{web-listen-address} (default: @code{":9100"})
  20099. Bind the web interface to the specified address.
  20100. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  20101. This directory can be used to export metrics specific to this machine.
  20102. Files containing metrics in the text format, with the filename ending in
  20103. @code{.prom} should be placed in this directory.
  20104. @item @code{extra-options} (default: @code{'()})
  20105. Extra options to pass to the Prometheus node exporter.
  20106. @end table
  20107. @end deftp
  20108. @subsubheading Zabbix server
  20109. @cindex zabbix zabbix-server
  20110. Zabbix provides monitoring metrics, among others network utilization, CPU load
  20111. and disk space consumption:
  20112. @itemize
  20113. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  20114. @item Auto-discovery of servers and network devices and interfaces.
  20115. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  20116. @item Distributed monitoring with centralized web administration.
  20117. @item Native high performance agents.
  20118. @item SLA, and ITIL KPI metrics on reporting.
  20119. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  20120. @item Remote command execution through Zabbix proxies.
  20121. @end itemize
  20122. @c %start of fragment
  20123. Available @code{zabbix-server-configuration} fields are:
  20124. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  20125. The zabbix-server package.
  20126. @end deftypevr
  20127. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  20128. User who will run the Zabbix server.
  20129. Defaults to @samp{"zabbix"}.
  20130. @end deftypevr
  20131. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  20132. Group who will run the Zabbix server.
  20133. Defaults to @samp{"zabbix"}.
  20134. @end deftypevr
  20135. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  20136. Database host name.
  20137. Defaults to @samp{"127.0.0.1"}.
  20138. @end deftypevr
  20139. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  20140. Database name.
  20141. Defaults to @samp{"zabbix"}.
  20142. @end deftypevr
  20143. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  20144. Database user.
  20145. Defaults to @samp{"zabbix"}.
  20146. @end deftypevr
  20147. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  20148. Database password. Please, use @code{include-files} with
  20149. @code{DBPassword=SECRET} inside a specified file instead.
  20150. Defaults to @samp{""}.
  20151. @end deftypevr
  20152. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  20153. Database port.
  20154. Defaults to @samp{5432}.
  20155. @end deftypevr
  20156. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  20157. Specifies where log messages are written to:
  20158. @itemize @bullet
  20159. @item
  20160. @code{system} - syslog.
  20161. @item
  20162. @code{file} - file specified with @code{log-file} parameter.
  20163. @item
  20164. @code{console} - standard output.
  20165. @end itemize
  20166. Defaults to @samp{""}.
  20167. @end deftypevr
  20168. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  20169. Log file name for @code{log-type} @code{file} parameter.
  20170. Defaults to @samp{"/var/log/zabbix/server.log"}.
  20171. @end deftypevr
  20172. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  20173. Name of PID file.
  20174. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  20175. @end deftypevr
  20176. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  20177. The location of certificate authority (CA) files for SSL server
  20178. certificate verification.
  20179. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  20180. @end deftypevr
  20181. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  20182. Location of SSL client certificates.
  20183. Defaults to @samp{"/etc/ssl/certs"}.
  20184. @end deftypevr
  20185. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  20186. Extra options will be appended to Zabbix server configuration file.
  20187. Defaults to @samp{""}.
  20188. @end deftypevr
  20189. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  20190. You may include individual files or all files in a directory in the
  20191. configuration file.
  20192. Defaults to @samp{()}.
  20193. @end deftypevr
  20194. @c %end of fragment
  20195. @subsubheading Zabbix agent
  20196. @cindex zabbix zabbix-agent
  20197. Zabbix agent gathers information for Zabbix server.
  20198. @c %start of fragment
  20199. Available @code{zabbix-agent-configuration} fields are:
  20200. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  20201. The zabbix-agent package.
  20202. @end deftypevr
  20203. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  20204. User who will run the Zabbix agent.
  20205. Defaults to @samp{"zabbix"}.
  20206. @end deftypevr
  20207. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  20208. Group who will run the Zabbix agent.
  20209. Defaults to @samp{"zabbix"}.
  20210. @end deftypevr
  20211. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  20212. Unique, case sensitive hostname which is required for active checks and
  20213. must match hostname as configured on the server.
  20214. Defaults to @samp{""}.
  20215. @end deftypevr
  20216. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  20217. Specifies where log messages are written to:
  20218. @itemize @bullet
  20219. @item
  20220. @code{system} - syslog.
  20221. @item
  20222. @code{file} - file specified with @code{log-file} parameter.
  20223. @item
  20224. @code{console} - standard output.
  20225. @end itemize
  20226. Defaults to @samp{""}.
  20227. @end deftypevr
  20228. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  20229. Log file name for @code{log-type} @code{file} parameter.
  20230. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  20231. @end deftypevr
  20232. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  20233. Name of PID file.
  20234. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  20235. @end deftypevr
  20236. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  20237. List of IP addresses, optionally in CIDR notation, or hostnames of
  20238. Zabbix servers and Zabbix proxies. Incoming connections will be
  20239. accepted only from the hosts listed here.
  20240. Defaults to @samp{("127.0.0.1")}.
  20241. @end deftypevr
  20242. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  20243. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  20244. proxies for active checks. If port is not specified, default port is
  20245. used. If this parameter is not specified, active checks are disabled.
  20246. Defaults to @samp{("127.0.0.1")}.
  20247. @end deftypevr
  20248. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  20249. Extra options will be appended to Zabbix server configuration file.
  20250. Defaults to @samp{""}.
  20251. @end deftypevr
  20252. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  20253. You may include individual files or all files in a directory in the
  20254. configuration file.
  20255. Defaults to @samp{()}.
  20256. @end deftypevr
  20257. @c %end of fragment
  20258. @subsubheading Zabbix front-end
  20259. @cindex zabbix zabbix-front-end
  20260. This service provides a WEB interface to Zabbix server.
  20261. @c %start of fragment
  20262. Available @code{zabbix-front-end-configuration} fields are:
  20263. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  20264. NGINX configuration.
  20265. @end deftypevr
  20266. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  20267. Database host name.
  20268. Defaults to @samp{"localhost"}.
  20269. @end deftypevr
  20270. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  20271. Database port.
  20272. Defaults to @samp{5432}.
  20273. @end deftypevr
  20274. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  20275. Database name.
  20276. Defaults to @samp{"zabbix"}.
  20277. @end deftypevr
  20278. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  20279. Database user.
  20280. Defaults to @samp{"zabbix"}.
  20281. @end deftypevr
  20282. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  20283. Database password. Please, use @code{db-secret-file} instead.
  20284. Defaults to @samp{""}.
  20285. @end deftypevr
  20286. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  20287. Secret file containing the credentials for the Zabbix front-end. The value
  20288. must be a local file name, not a G-expression. You are expected to create
  20289. this file manually. Its contents will be copied into @file{zabbix.conf.php}
  20290. as the value of @code{$DB['PASSWORD']}.
  20291. Defaults to @samp{""}.
  20292. @end deftypevr
  20293. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  20294. Zabbix server hostname.
  20295. Defaults to @samp{"localhost"}.
  20296. @end deftypevr
  20297. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  20298. Zabbix server port.
  20299. Defaults to @samp{10051}.
  20300. @end deftypevr
  20301. @c %end of fragment
  20302. @node Kerberos Services
  20303. @subsection Kerberos Services
  20304. @cindex Kerberos
  20305. The @code{(gnu services kerberos)} module provides services relating to
  20306. the authentication protocol @dfn{Kerberos}.
  20307. @subsubheading Krb5 Service
  20308. Programs using a Kerberos client library normally
  20309. expect a configuration file in @file{/etc/krb5.conf}.
  20310. This service generates such a file from a definition provided in the
  20311. operating system declaration.
  20312. It does not cause any daemon to be started.
  20313. No ``keytab'' files are provided by this service---you must explicitly create them.
  20314. This service is known to work with the MIT client library, @code{mit-krb5}.
  20315. Other implementations have not been tested.
  20316. @defvr {Scheme Variable} krb5-service-type
  20317. A service type for Kerberos 5 clients.
  20318. @end defvr
  20319. @noindent
  20320. Here is an example of its use:
  20321. @lisp
  20322. (service krb5-service-type
  20323. (krb5-configuration
  20324. (default-realm "EXAMPLE.COM")
  20325. (allow-weak-crypto? #t)
  20326. (realms (list
  20327. (krb5-realm
  20328. (name "EXAMPLE.COM")
  20329. (admin-server "groucho.example.com")
  20330. (kdc "karl.example.com"))
  20331. (krb5-realm
  20332. (name "ARGRX.EDU")
  20333. (admin-server "kerb-admin.argrx.edu")
  20334. (kdc "keys.argrx.edu"))))))
  20335. @end lisp
  20336. @noindent
  20337. This example provides a Kerberos@tie{}5 client configuration which:
  20338. @itemize
  20339. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  20340. of which have distinct administration servers and key distribution centers;
  20341. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  20342. specified by clients;
  20343. @item Accepts services which only support encryption types known to be weak.
  20344. @end itemize
  20345. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  20346. Only the most commonly used ones are described here.
  20347. For a full list, and more detailed explanation of each, see the MIT
  20348. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  20349. documentation.
  20350. @deftp {Data Type} krb5-realm
  20351. @cindex realm, kerberos
  20352. @table @asis
  20353. @item @code{name}
  20354. This field is a string identifying the name of the realm.
  20355. A common convention is to use the fully qualified DNS name of your organization,
  20356. converted to upper case.
  20357. @item @code{admin-server}
  20358. This field is a string identifying the host where the administration server is
  20359. running.
  20360. @item @code{kdc}
  20361. This field is a string identifying the key distribution center
  20362. for the realm.
  20363. @end table
  20364. @end deftp
  20365. @deftp {Data Type} krb5-configuration
  20366. @table @asis
  20367. @item @code{allow-weak-crypto?} (default: @code{#f})
  20368. If this flag is @code{#t} then services which only offer encryption algorithms
  20369. known to be weak will be accepted.
  20370. @item @code{default-realm} (default: @code{#f})
  20371. This field should be a string identifying the default Kerberos
  20372. realm for the client.
  20373. You should set this field to the name of your Kerberos realm.
  20374. If this value is @code{#f}
  20375. then a realm must be specified with every Kerberos principal when invoking programs
  20376. such as @command{kinit}.
  20377. @item @code{realms}
  20378. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  20379. access.
  20380. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  20381. field.
  20382. @end table
  20383. @end deftp
  20384. @subsubheading PAM krb5 Service
  20385. @cindex pam-krb5
  20386. The @code{pam-krb5} service allows for login authentication and password
  20387. management via Kerberos.
  20388. You will need this service if you want PAM enabled applications to authenticate
  20389. users using Kerberos.
  20390. @defvr {Scheme Variable} pam-krb5-service-type
  20391. A service type for the Kerberos 5 PAM module.
  20392. @end defvr
  20393. @deftp {Data Type} pam-krb5-configuration
  20394. Data type representing the configuration of the Kerberos 5 PAM module.
  20395. This type has the following parameters:
  20396. @table @asis
  20397. @item @code{pam-krb5} (default: @code{pam-krb5})
  20398. The pam-krb5 package to use.
  20399. @item @code{minimum-uid} (default: @code{1000})
  20400. The smallest user ID for which Kerberos authentications should be attempted.
  20401. Local accounts with lower values will silently fail to authenticate.
  20402. @end table
  20403. @end deftp
  20404. @node LDAP Services
  20405. @subsection LDAP Services
  20406. @cindex LDAP
  20407. @cindex nslcd, LDAP service
  20408. The @code{(gnu services authentication)} module provides the
  20409. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  20410. server. In addition to configuring the service itself, you may want to add
  20411. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  20412. Switch} for detailed information.
  20413. Here is a simple operating system declaration with a default configuration of
  20414. the @code{nslcd-service-type} and a Name Service Switch configuration that
  20415. consults the @code{ldap} name service last:
  20416. @lisp
  20417. (use-service-modules authentication)
  20418. (use-modules (gnu system nss))
  20419. ...
  20420. (operating-system
  20421. ...
  20422. (services
  20423. (cons*
  20424. (service nslcd-service-type)
  20425. (service dhcp-client-service-type)
  20426. %base-services))
  20427. (name-service-switch
  20428. (let ((services (list (name-service (name "db"))
  20429. (name-service (name "files"))
  20430. (name-service (name "ldap")))))
  20431. (name-service-switch
  20432. (inherit %mdns-host-lookup-nss)
  20433. (password services)
  20434. (shadow services)
  20435. (group services)
  20436. (netgroup services)
  20437. (gshadow services)))))
  20438. @end lisp
  20439. @c %start of generated documentation for nslcd-configuration
  20440. Available @code{nslcd-configuration} fields are:
  20441. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  20442. The @code{nss-pam-ldapd} package to use.
  20443. @end deftypevr
  20444. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  20445. The number of threads to start that can handle requests and perform LDAP
  20446. queries. Each thread opens a separate connection to the LDAP server.
  20447. The default is to start 5 threads.
  20448. Defaults to @samp{disabled}.
  20449. @end deftypevr
  20450. @deftypevr {@code{nslcd-configuration} parameter} string uid
  20451. This specifies the user id with which the daemon should be run.
  20452. Defaults to @samp{"nslcd"}.
  20453. @end deftypevr
  20454. @deftypevr {@code{nslcd-configuration} parameter} string gid
  20455. This specifies the group id with which the daemon should be run.
  20456. Defaults to @samp{"nslcd"}.
  20457. @end deftypevr
  20458. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  20459. This option controls the way logging is done via a list containing
  20460. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  20461. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  20462. argument is optional and specifies the log level. The log level may be
  20463. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  20464. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  20465. specified log level or higher are logged.
  20466. Defaults to @samp{("/var/log/nslcd" info)}.
  20467. @end deftypevr
  20468. @deftypevr {@code{nslcd-configuration} parameter} list uri
  20469. The list of LDAP server URIs. Normally, only the first server will be
  20470. used with the following servers as fall-back.
  20471. Defaults to @samp{("ldap://localhost:389/")}.
  20472. @end deftypevr
  20473. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  20474. The version of the LDAP protocol to use. The default is to use the
  20475. maximum version supported by the LDAP library.
  20476. Defaults to @samp{disabled}.
  20477. @end deftypevr
  20478. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  20479. Specifies the distinguished name with which to bind to the directory
  20480. server for lookups. The default is to bind anonymously.
  20481. Defaults to @samp{disabled}.
  20482. @end deftypevr
  20483. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  20484. Specifies the credentials with which to bind. This option is only
  20485. applicable when used with binddn.
  20486. Defaults to @samp{disabled}.
  20487. @end deftypevr
  20488. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  20489. Specifies the distinguished name to use when the root user tries to
  20490. modify a user's password using the PAM module.
  20491. Defaults to @samp{disabled}.
  20492. @end deftypevr
  20493. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  20494. Specifies the credentials with which to bind if the root user tries to
  20495. change a user's password. This option is only applicable when used with
  20496. rootpwmoddn
  20497. Defaults to @samp{disabled}.
  20498. @end deftypevr
  20499. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  20500. Specifies the SASL mechanism to be used when performing SASL
  20501. authentication.
  20502. Defaults to @samp{disabled}.
  20503. @end deftypevr
  20504. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  20505. Specifies the SASL realm to be used when performing SASL authentication.
  20506. Defaults to @samp{disabled}.
  20507. @end deftypevr
  20508. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  20509. Specifies the authentication identity to be used when performing SASL
  20510. authentication.
  20511. Defaults to @samp{disabled}.
  20512. @end deftypevr
  20513. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  20514. Specifies the authorization identity to be used when performing SASL
  20515. authentication.
  20516. Defaults to @samp{disabled}.
  20517. @end deftypevr
  20518. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  20519. Determines whether the LDAP server host name should be canonicalised. If
  20520. this is enabled the LDAP library will do a reverse host name lookup. By
  20521. default, it is left up to the LDAP library whether this check is
  20522. performed or not.
  20523. Defaults to @samp{disabled}.
  20524. @end deftypevr
  20525. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  20526. Set the name for the GSS-API Kerberos credentials cache.
  20527. Defaults to @samp{disabled}.
  20528. @end deftypevr
  20529. @deftypevr {@code{nslcd-configuration} parameter} string base
  20530. The directory search base.
  20531. Defaults to @samp{"dc=example,dc=com"}.
  20532. @end deftypevr
  20533. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  20534. Specifies the search scope (subtree, onelevel, base or children). The
  20535. default scope is subtree; base scope is almost never useful for name
  20536. service lookups; children scope is not supported on all servers.
  20537. Defaults to @samp{(subtree)}.
  20538. @end deftypevr
  20539. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  20540. Specifies the policy for dereferencing aliases. The default policy is
  20541. to never dereference aliases.
  20542. Defaults to @samp{disabled}.
  20543. @end deftypevr
  20544. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  20545. Specifies whether automatic referral chasing should be enabled. The
  20546. default behaviour is to chase referrals.
  20547. Defaults to @samp{disabled}.
  20548. @end deftypevr
  20549. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  20550. This option allows for custom attributes to be looked up instead of the
  20551. default RFC 2307 attributes. It is a list of maps, each consisting of
  20552. the name of a map, the RFC 2307 attribute to match and the query
  20553. expression for the attribute as it is available in the directory.
  20554. Defaults to @samp{()}.
  20555. @end deftypevr
  20556. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  20557. A list of filters consisting of the name of a map to which the filter
  20558. applies and an LDAP search filter expression.
  20559. Defaults to @samp{()}.
  20560. @end deftypevr
  20561. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  20562. Specifies the time limit in seconds to use when connecting to the
  20563. directory server. The default value is 10 seconds.
  20564. Defaults to @samp{disabled}.
  20565. @end deftypevr
  20566. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  20567. Specifies the time limit (in seconds) to wait for a response from the
  20568. LDAP server. A value of zero, which is the default, is to wait
  20569. indefinitely for searches to be completed.
  20570. Defaults to @samp{disabled}.
  20571. @end deftypevr
  20572. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  20573. Specifies the period if inactivity (in seconds) after which the con‐
  20574. nection to the LDAP server will be closed. The default is not to time
  20575. out connections.
  20576. Defaults to @samp{disabled}.
  20577. @end deftypevr
  20578. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  20579. Specifies the number of seconds to sleep when connecting to all LDAP
  20580. servers fails. By default one second is waited between the first
  20581. failure and the first retry.
  20582. Defaults to @samp{disabled}.
  20583. @end deftypevr
  20584. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  20585. Specifies the time after which the LDAP server is considered to be
  20586. permanently unavailable. Once this time is reached retries will be done
  20587. only once per this time period. The default value is 10 seconds.
  20588. Defaults to @samp{disabled}.
  20589. @end deftypevr
  20590. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  20591. Specifies whether to use SSL/TLS or not (the default is not to). If
  20592. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  20593. SSL.
  20594. Defaults to @samp{disabled}.
  20595. @end deftypevr
  20596. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  20597. Specifies what checks to perform on a server-supplied certificate. The
  20598. meaning of the values is described in the ldap.conf(5) manual page.
  20599. Defaults to @samp{disabled}.
  20600. @end deftypevr
  20601. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  20602. Specifies the directory containing X.509 certificates for peer authen‐
  20603. tication. This parameter is ignored when using GnuTLS.
  20604. Defaults to @samp{disabled}.
  20605. @end deftypevr
  20606. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  20607. Specifies the path to the X.509 certificate for peer authentication.
  20608. Defaults to @samp{disabled}.
  20609. @end deftypevr
  20610. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  20611. Specifies the path to an entropy source. This parameter is ignored when
  20612. using GnuTLS.
  20613. Defaults to @samp{disabled}.
  20614. @end deftypevr
  20615. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  20616. Specifies the ciphers to use for TLS as a string.
  20617. Defaults to @samp{disabled}.
  20618. @end deftypevr
  20619. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  20620. Specifies the path to the file containing the local certificate for
  20621. client TLS authentication.
  20622. Defaults to @samp{disabled}.
  20623. @end deftypevr
  20624. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  20625. Specifies the path to the file containing the private key for client TLS
  20626. authentication.
  20627. Defaults to @samp{disabled}.
  20628. @end deftypevr
  20629. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  20630. Set this to a number greater than 0 to request paged results from the
  20631. LDAP server in accordance with RFC2696. The default (0) is to not
  20632. request paged results.
  20633. Defaults to @samp{disabled}.
  20634. @end deftypevr
  20635. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  20636. This option prevents group membership lookups through LDAP for the
  20637. specified users. Alternatively, the value 'all-local may be used. With
  20638. that value nslcd builds a full list of non-LDAP users on startup.
  20639. Defaults to @samp{disabled}.
  20640. @end deftypevr
  20641. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  20642. This option ensures that LDAP users with a numeric user id lower than
  20643. the specified value are ignored.
  20644. Defaults to @samp{disabled}.
  20645. @end deftypevr
  20646. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  20647. This option specifies an offset that is added to all LDAP numeric user
  20648. ids. This can be used to avoid user id collisions with local users.
  20649. Defaults to @samp{disabled}.
  20650. @end deftypevr
  20651. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  20652. This option specifies an offset that is added to all LDAP numeric group
  20653. ids. This can be used to avoid user id collisions with local groups.
  20654. Defaults to @samp{disabled}.
  20655. @end deftypevr
  20656. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  20657. If this option is set, the member attribute of a group may point to
  20658. another group. Members of nested groups are also returned in the higher
  20659. level group and parent groups are returned when finding groups for a
  20660. specific user. The default is not to perform extra searches for nested
  20661. groups.
  20662. Defaults to @samp{disabled}.
  20663. @end deftypevr
  20664. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  20665. If this option is set, the group member list is not retrieved when
  20666. looking up groups. Lookups for finding which groups a user belongs to
  20667. will remain functional so the user will likely still get the correct
  20668. groups assigned on login.
  20669. Defaults to @samp{disabled}.
  20670. @end deftypevr
  20671. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  20672. If this option is set, functions which cause all user/group entries to
  20673. be loaded from the directory will not succeed in doing so. This can
  20674. dramatically reduce LDAP server load in situations where there are a
  20675. great number of users and/or groups. This option is not recommended for
  20676. most configurations.
  20677. Defaults to @samp{disabled}.
  20678. @end deftypevr
  20679. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  20680. This option can be used to specify how user and group names are verified
  20681. within the system. This pattern is used to check all user and group
  20682. names that are requested and returned from LDAP.
  20683. Defaults to @samp{disabled}.
  20684. @end deftypevr
  20685. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  20686. This specifies whether or not to perform searches using case-insensitive
  20687. matching. Enabling this could open up the system to authorization
  20688. bypass vulnerabilities and introduce nscd cache poisoning
  20689. vulnerabilities which allow denial of service.
  20690. Defaults to @samp{disabled}.
  20691. @end deftypevr
  20692. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  20693. This option specifies whether password policy controls are requested and
  20694. handled from the LDAP server when performing user authentication.
  20695. Defaults to @samp{disabled}.
  20696. @end deftypevr
  20697. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  20698. By default nslcd performs an LDAP search with the user's credentials
  20699. after BIND (authentication) to ensure that the BIND operation was
  20700. successful. The default search is a simple check to see if the user's
  20701. DN exists. A search filter can be specified that will be used instead.
  20702. It should return at least one entry.
  20703. Defaults to @samp{disabled}.
  20704. @end deftypevr
  20705. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  20706. This option allows flexible fine tuning of the authorisation check that
  20707. should be performed. The search filter specified is executed and if any
  20708. entries match, access is granted, otherwise access is denied.
  20709. Defaults to @samp{disabled}.
  20710. @end deftypevr
  20711. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  20712. If this option is set password modification using pam_ldap will be
  20713. denied and the specified message will be presented to the user instead.
  20714. The message can be used to direct the user to an alternative means of
  20715. changing their password.
  20716. Defaults to @samp{disabled}.
  20717. @end deftypevr
  20718. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  20719. List of pam service names for which LDAP authentication should suffice.
  20720. Defaults to @samp{()}.
  20721. @end deftypevr
  20722. @c %end of generated documentation for nslcd-configuration
  20723. @node Web Services
  20724. @subsection Web Services
  20725. @cindex web
  20726. @cindex www
  20727. @cindex HTTP
  20728. The @code{(gnu services web)} module provides the Apache HTTP Server,
  20729. the nginx web server, and also a fastcgi wrapper daemon.
  20730. @subsubheading Apache HTTP Server
  20731. @deffn {Scheme Variable} httpd-service-type
  20732. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  20733. (@dfn{httpd}). The value for this service type is a
  20734. @code{httpd-configuration} record.
  20735. A simple example configuration is given below.
  20736. @lisp
  20737. (service httpd-service-type
  20738. (httpd-configuration
  20739. (config
  20740. (httpd-config-file
  20741. (server-name "www.example.com")
  20742. (document-root "/srv/http/www.example.com")))))
  20743. @end lisp
  20744. Other services can also extend the @code{httpd-service-type} to add to
  20745. the configuration.
  20746. @lisp
  20747. (simple-service 'www.example.com-server httpd-service-type
  20748. (list
  20749. (httpd-virtualhost
  20750. "*:80"
  20751. (list (string-join '("ServerName www.example.com"
  20752. "DocumentRoot /srv/http/www.example.com")
  20753. "\n")))))
  20754. @end lisp
  20755. @end deffn
  20756. The details for the @code{httpd-configuration}, @code{httpd-module},
  20757. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  20758. given below.
  20759. @deffn {Data Type} httpd-configuration
  20760. This data type represents the configuration for the httpd service.
  20761. @table @asis
  20762. @item @code{package} (default: @code{httpd})
  20763. The httpd package to use.
  20764. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  20765. The pid file used by the shepherd-service.
  20766. @item @code{config} (default: @code{(httpd-config-file)})
  20767. The configuration file to use with the httpd service. The default value
  20768. is a @code{httpd-config-file} record, but this can also be a different
  20769. G-expression that generates a file, for example a @code{plain-file}. A
  20770. file outside of the store can also be specified through a string.
  20771. @end table
  20772. @end deffn
  20773. @deffn {Data Type} httpd-module
  20774. This data type represents a module for the httpd service.
  20775. @table @asis
  20776. @item @code{name}
  20777. The name of the module.
  20778. @item @code{file}
  20779. The file for the module. This can be relative to the httpd package being
  20780. used, the absolute location of a file, or a G-expression for a file
  20781. within the store, for example @code{(file-append mod-wsgi
  20782. "/modules/mod_wsgi.so")}.
  20783. @end table
  20784. @end deffn
  20785. @defvr {Scheme Variable} %default-httpd-modules
  20786. A default list of @code{httpd-module} objects.
  20787. @end defvr
  20788. @deffn {Data Type} httpd-config-file
  20789. This data type represents a configuration file for the httpd service.
  20790. @table @asis
  20791. @item @code{modules} (default: @code{%default-httpd-modules})
  20792. The modules to load. Additional modules can be added here, or loaded by
  20793. additional configuration.
  20794. For example, in order to handle requests for PHP files, you can use Apache’s
  20795. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  20796. @lisp
  20797. (service httpd-service-type
  20798. (httpd-configuration
  20799. (config
  20800. (httpd-config-file
  20801. (modules (cons*
  20802. (httpd-module
  20803. (name "proxy_module")
  20804. (file "modules/mod_proxy.so"))
  20805. (httpd-module
  20806. (name "proxy_fcgi_module")
  20807. (file "modules/mod_proxy_fcgi.so"))
  20808. %default-httpd-modules))
  20809. (extra-config (list "\
  20810. <FilesMatch \\.php$>
  20811. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  20812. </FilesMatch>"))))))
  20813. (service php-fpm-service-type
  20814. (php-fpm-configuration
  20815. (socket "/var/run/php-fpm.sock")
  20816. (socket-group "httpd")))
  20817. @end lisp
  20818. @item @code{server-root} (default: @code{httpd})
  20819. The @code{ServerRoot} in the configuration file, defaults to the httpd
  20820. package. Directives including @code{Include} and @code{LoadModule} are
  20821. taken as relative to the server root.
  20822. @item @code{server-name} (default: @code{#f})
  20823. The @code{ServerName} in the configuration file, used to specify the
  20824. request scheme, hostname and port that the server uses to identify
  20825. itself.
  20826. This doesn't need to be set in the server config, and can be specified
  20827. in virtual hosts. The default is @code{#f} to not specify a
  20828. @code{ServerName}.
  20829. @item @code{document-root} (default: @code{"/srv/http"})
  20830. The @code{DocumentRoot} from which files will be served.
  20831. @item @code{listen} (default: @code{'("80")})
  20832. The list of values for the @code{Listen} directives in the config
  20833. file. The value should be a list of strings, when each string can
  20834. specify the port number to listen on, and optionally the IP address and
  20835. protocol to use.
  20836. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  20837. The @code{PidFile} to use. This should match the @code{pid-file} set in
  20838. the @code{httpd-configuration} so that the Shepherd service is
  20839. configured correctly.
  20840. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  20841. The @code{ErrorLog} to which the server will log errors.
  20842. @item @code{user} (default: @code{"httpd"})
  20843. The @code{User} which the server will answer requests as.
  20844. @item @code{group} (default: @code{"httpd"})
  20845. The @code{Group} which the server will answer requests as.
  20846. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  20847. A flat list of strings and G-expressions which will be added to the end
  20848. of the configuration file.
  20849. Any values which the service is extended with will be appended to this
  20850. list.
  20851. @end table
  20852. @end deffn
  20853. @deffn {Data Type} httpd-virtualhost
  20854. This data type represents a virtualhost configuration block for the httpd service.
  20855. These should be added to the extra-config for the httpd-service.
  20856. @lisp
  20857. (simple-service 'www.example.com-server httpd-service-type
  20858. (list
  20859. (httpd-virtualhost
  20860. "*:80"
  20861. (list (string-join '("ServerName www.example.com"
  20862. "DocumentRoot /srv/http/www.example.com")
  20863. "\n")))))
  20864. @end lisp
  20865. @table @asis
  20866. @item @code{addresses-and-ports}
  20867. The addresses and ports for the @code{VirtualHost} directive.
  20868. @item @code{contents}
  20869. The contents of the @code{VirtualHost} directive, this should be a list
  20870. of strings and G-expressions.
  20871. @end table
  20872. @end deffn
  20873. @anchor{NGINX}
  20874. @subsubheading NGINX
  20875. @deffn {Scheme Variable} nginx-service-type
  20876. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  20877. value for this service type is a @code{<nginx-configuration>} record.
  20878. A simple example configuration is given below.
  20879. @lisp
  20880. (service nginx-service-type
  20881. (nginx-configuration
  20882. (server-blocks
  20883. (list (nginx-server-configuration
  20884. (server-name '("www.example.com"))
  20885. (root "/srv/http/www.example.com"))))))
  20886. @end lisp
  20887. In addition to adding server blocks to the service configuration
  20888. directly, this service can be extended by other services to add server
  20889. blocks, as in this example:
  20890. @lisp
  20891. (simple-service 'my-extra-server nginx-service-type
  20892. (list (nginx-server-configuration
  20893. (root "/srv/http/extra-website")
  20894. (try-files (list "$uri" "$uri/index.html")))))
  20895. @end lisp
  20896. @end deffn
  20897. At startup, @command{nginx} has not yet read its configuration file, so
  20898. it uses a default file to log error messages. If it fails to load its
  20899. configuration file, that is where error messages are logged. After the
  20900. configuration file is loaded, the default error log file changes as per
  20901. configuration. In our case, startup error messages can be found in
  20902. @file{/var/run/nginx/logs/error.log}, and after configuration in
  20903. @file{/var/log/nginx/error.log}. The second location can be changed
  20904. with the @var{log-directory} configuration option.
  20905. @deffn {Data Type} nginx-configuration
  20906. This data type represents the configuration for NGinx. Some
  20907. configuration can be done through this and the other provided record
  20908. types, or alternatively, a config file can be provided.
  20909. @table @asis
  20910. @item @code{nginx} (default: @code{nginx})
  20911. The nginx package to use.
  20912. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  20913. The directory to which NGinx will write log files.
  20914. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  20915. The directory in which NGinx will create a pid file, and write temporary
  20916. files.
  20917. @item @code{server-blocks} (default: @code{'()})
  20918. A list of @dfn{server blocks} to create in the generated configuration
  20919. file, the elements should be of type
  20920. @code{<nginx-server-configuration>}.
  20921. The following example would setup NGinx to serve @code{www.example.com}
  20922. from the @code{/srv/http/www.example.com} directory, without using
  20923. HTTPS.
  20924. @lisp
  20925. (service nginx-service-type
  20926. (nginx-configuration
  20927. (server-blocks
  20928. (list (nginx-server-configuration
  20929. (server-name '("www.example.com"))
  20930. (root "/srv/http/www.example.com"))))))
  20931. @end lisp
  20932. @item @code{upstream-blocks} (default: @code{'()})
  20933. A list of @dfn{upstream blocks} to create in the generated configuration
  20934. file, the elements should be of type
  20935. @code{<nginx-upstream-configuration>}.
  20936. Configuring upstreams through the @code{upstream-blocks} can be useful
  20937. when combined with @code{locations} in the
  20938. @code{<nginx-server-configuration>} records. The following example
  20939. creates a server configuration with one location configuration, that
  20940. will proxy requests to a upstream configuration, which will handle
  20941. requests with two servers.
  20942. @lisp
  20943. (service
  20944. nginx-service-type
  20945. (nginx-configuration
  20946. (server-blocks
  20947. (list (nginx-server-configuration
  20948. (server-name '("www.example.com"))
  20949. (root "/srv/http/www.example.com")
  20950. (locations
  20951. (list
  20952. (nginx-location-configuration
  20953. (uri "/path1")
  20954. (body '("proxy_pass http://server-proxy;"))))))))
  20955. (upstream-blocks
  20956. (list (nginx-upstream-configuration
  20957. (name "server-proxy")
  20958. (servers (list "server1.example.com"
  20959. "server2.example.com")))))))
  20960. @end lisp
  20961. @item @code{file} (default: @code{#f})
  20962. If a configuration @var{file} is provided, this will be used, rather than
  20963. generating a configuration file from the provided @code{log-directory},
  20964. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  20965. proper operation, these arguments should match what is in @var{file} to ensure
  20966. that the directories are created when the service is activated.
  20967. This can be useful if you have an existing configuration file, or it's
  20968. not possible to do what is required through the other parts of the
  20969. nginx-configuration record.
  20970. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  20971. Bucket size for the server names hash tables, defaults to @code{#f} to
  20972. use the size of the processors cache line.
  20973. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  20974. Maximum bucket size for the server names hash tables.
  20975. @item @code{modules} (default: @code{'()})
  20976. List of nginx dynamic modules to load. This should be a list of file
  20977. names of loadable modules, as in this example:
  20978. @lisp
  20979. (modules
  20980. (list
  20981. (file-append nginx-accept-language-module "\
  20982. /etc/nginx/modules/ngx_http_accept_language_module.so")
  20983. (file-append nginx-lua-module "\
  20984. /etc/nginx/modules/ngx_http_lua_module.so")))
  20985. @end lisp
  20986. @item @code{lua-package-path} (default: @code{'()})
  20987. List of nginx lua packages to load. This should be a list of package
  20988. names of loadable lua modules, as in this example:
  20989. @lisp
  20990. (lua-package-path (list lua-resty-core
  20991. lua-resty-lrucache
  20992. lua-resty-signal
  20993. lua-tablepool
  20994. lua-resty-shell))
  20995. @end lisp
  20996. @item @code{lua-package-cpath} (default: @code{'()})
  20997. List of nginx lua C packages to load. This should be a list of package
  20998. names of loadable lua C modules, as in this example:
  20999. @lisp
  21000. (lua-package-cpath (list lua-resty-signal))
  21001. @end lisp
  21002. @item @code{global-directives} (default: @code{'((events . ()))})
  21003. Association list of global directives for the top level of the nginx
  21004. configuration. Values may themselves be association lists.
  21005. @lisp
  21006. (global-directives
  21007. `((worker_processes . 16)
  21008. (pcre_jit . on)
  21009. (events . ((worker_connections . 1024)))))
  21010. @end lisp
  21011. @item @code{extra-content} (default: @code{""})
  21012. Extra content for the @code{http} block. Should be string or a string
  21013. valued G-expression.
  21014. @end table
  21015. @end deffn
  21016. @deftp {Data Type} nginx-server-configuration
  21017. Data type representing the configuration of an nginx server block.
  21018. This type has the following parameters:
  21019. @table @asis
  21020. @item @code{listen} (default: @code{'("80" "443 ssl")})
  21021. Each @code{listen} directive sets the address and port for IP, or the
  21022. path for a UNIX-domain socket on which the server will accept requests.
  21023. Both address and port, or only address or only port can be specified.
  21024. An address may also be a hostname, for example:
  21025. @lisp
  21026. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  21027. @end lisp
  21028. @item @code{server-name} (default: @code{(list 'default)})
  21029. A list of server names this server represents. @code{'default} represents the
  21030. default server for connections matching no other server.
  21031. @item @code{root} (default: @code{"/srv/http"})
  21032. Root of the website nginx will serve.
  21033. @item @code{locations} (default: @code{'()})
  21034. A list of @dfn{nginx-location-configuration} or
  21035. @dfn{nginx-named-location-configuration} records to use within this
  21036. server block.
  21037. @item @code{index} (default: @code{(list "index.html")})
  21038. Index files to look for when clients ask for a directory. If it cannot be found,
  21039. Nginx will send the list of files in the directory.
  21040. @item @code{try-files} (default: @code{'()})
  21041. A list of files whose existence is checked in the specified order.
  21042. @code{nginx} will use the first file it finds to process the request.
  21043. @item @code{ssl-certificate} (default: @code{#f})
  21044. Where to find the certificate for secure connections. Set it to @code{#f} if
  21045. you don't have a certificate or you don't want to use HTTPS.
  21046. @item @code{ssl-certificate-key} (default: @code{#f})
  21047. Where to find the private key for secure connections. Set it to @code{#f} if
  21048. you don't have a key or you don't want to use HTTPS.
  21049. @item @code{server-tokens?} (default: @code{#f})
  21050. Whether the server should add its configuration to response.
  21051. @item @code{raw-content} (default: @code{'()})
  21052. A list of raw lines added to the server block.
  21053. @end table
  21054. @end deftp
  21055. @deftp {Data Type} nginx-upstream-configuration
  21056. Data type representing the configuration of an nginx @code{upstream}
  21057. block. This type has the following parameters:
  21058. @table @asis
  21059. @item @code{name}
  21060. Name for this group of servers.
  21061. @item @code{servers}
  21062. Specify the addresses of the servers in the group. The address can be
  21063. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  21064. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  21065. prefix @samp{unix:}. For addresses using an IP address or domain name,
  21066. the default port is 80, and a different port can be specified
  21067. explicitly.
  21068. @end table
  21069. @end deftp
  21070. @deftp {Data Type} nginx-location-configuration
  21071. Data type representing the configuration of an nginx @code{location}
  21072. block. This type has the following parameters:
  21073. @table @asis
  21074. @item @code{uri}
  21075. URI which this location block matches.
  21076. @anchor{nginx-location-configuration body}
  21077. @item @code{body}
  21078. Body of the location block, specified as a list of strings. This can contain
  21079. many
  21080. configuration directives. For example, to pass requests to a upstream
  21081. server group defined using an @code{nginx-upstream-configuration} block,
  21082. the following directive would be specified in the body @samp{(list "proxy_pass
  21083. http://upstream-name;")}.
  21084. @end table
  21085. @end deftp
  21086. @deftp {Data Type} nginx-named-location-configuration
  21087. Data type representing the configuration of an nginx named location
  21088. block. Named location blocks are used for request redirection, and not
  21089. used for regular request processing. This type has the following
  21090. parameters:
  21091. @table @asis
  21092. @item @code{name}
  21093. Name to identify this location block.
  21094. @item @code{body}
  21095. @xref{nginx-location-configuration body}, as the body for named location
  21096. blocks can be used in a similar way to the
  21097. @code{nginx-location-configuration body}. One restriction is that the
  21098. body of a named location block cannot contain location blocks.
  21099. @end table
  21100. @end deftp
  21101. @subsubheading Varnish Cache
  21102. @cindex Varnish
  21103. Varnish is a fast cache server that sits in between web applications
  21104. and end users. It proxies requests from clients and caches the
  21105. accessed URLs such that multiple requests for the same resource only
  21106. creates one request to the back-end.
  21107. @defvr {Scheme Variable} varnish-service-type
  21108. Service type for the Varnish daemon.
  21109. @end defvr
  21110. @deftp {Data Type} varnish-configuration
  21111. Data type representing the @code{varnish} service configuration.
  21112. This type has the following parameters:
  21113. @table @asis
  21114. @item @code{package} (default: @code{varnish})
  21115. The Varnish package to use.
  21116. @item @code{name} (default: @code{"default"})
  21117. A name for this Varnish instance. Varnish will create a directory in
  21118. @file{/var/varnish/} with this name and keep temporary files there. If
  21119. the name starts with a forward slash, it is interpreted as an absolute
  21120. directory name.
  21121. Pass the @code{-n} argument to other Varnish programs to connect to the
  21122. named instance, e.g.@: @command{varnishncsa -n default}.
  21123. @item @code{backend} (default: @code{"localhost:8080"})
  21124. The backend to use. This option has no effect if @code{vcl} is set.
  21125. @item @code{vcl} (default: #f)
  21126. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  21127. is @code{#f}, Varnish will proxy @code{backend} using the default
  21128. configuration. Otherwise this must be a file-like object with valid
  21129. VCL syntax.
  21130. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  21131. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  21132. can do something along these lines:
  21133. @lisp
  21134. (define %gnu-mirror
  21135. (plain-file "gnu.vcl"
  21136. "vcl 4.1;
  21137. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  21138. (operating-system
  21139. ;; @dots{}
  21140. (services (cons (service varnish-service-type
  21141. (varnish-configuration
  21142. (listen '(":80"))
  21143. (vcl %gnu-mirror)))
  21144. %base-services)))
  21145. @end lisp
  21146. The configuration of an already running Varnish instance can be inspected
  21147. and changed using the @command{varnishadm} program.
  21148. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  21149. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  21150. comprehensive documentation on Varnish and its configuration language.
  21151. @item @code{listen} (default: @code{'("localhost:80")})
  21152. List of addresses Varnish will listen on.
  21153. @item @code{storage} (default: @code{'("malloc,128m")})
  21154. List of storage backends that will be available in VCL.
  21155. @item @code{parameters} (default: @code{'()})
  21156. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  21157. @item @code{extra-options} (default: @code{'()})
  21158. Additional arguments to pass to the @command{varnishd} process.
  21159. @end table
  21160. @end deftp
  21161. @subsubheading Patchwork
  21162. @cindex Patchwork
  21163. Patchwork is a patch tracking system. It can collect patches sent to a
  21164. mailing list, and display them in a web interface.
  21165. @defvr {Scheme Variable} patchwork-service-type
  21166. Service type for Patchwork.
  21167. @end defvr
  21168. The following example is an example of a minimal service for Patchwork, for
  21169. the @code{patchwork.example.com} domain.
  21170. @lisp
  21171. (service patchwork-service-type
  21172. (patchwork-configuration
  21173. (domain "patchwork.example.com")
  21174. (settings-module
  21175. (patchwork-settings-module
  21176. (allowed-hosts (list domain))
  21177. (default-from-email "patchwork@@patchwork.example.com")))
  21178. (getmail-retriever-config
  21179. (getmail-retriever-configuration
  21180. (type "SimpleIMAPSSLRetriever")
  21181. (server "imap.example.com")
  21182. (port 993)
  21183. (username "patchwork")
  21184. (password-command
  21185. (list (file-append coreutils "/bin/cat")
  21186. "/etc/getmail-patchwork-imap-password"))
  21187. (extra-parameters
  21188. '((mailboxes . ("Patches"))))))))
  21189. @end lisp
  21190. There are three records for configuring the Patchwork service. The
  21191. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  21192. within the HTTPD service.
  21193. The @code{settings-module} field within the @code{<patchwork-configuration>}
  21194. record can be populated with the @code{<patchwork-settings-module>} record,
  21195. which describes a settings module that is generated within the Guix store.
  21196. For the @code{database-configuration} field within the
  21197. @code{<patchwork-settings-module>}, the
  21198. @code{<patchwork-database-configuration>} must be used.
  21199. @deftp {Data Type} patchwork-configuration
  21200. Data type representing the Patchwork service configuration. This type has the
  21201. following parameters:
  21202. @table @asis
  21203. @item @code{patchwork} (default: @code{patchwork})
  21204. The Patchwork package to use.
  21205. @item @code{domain}
  21206. The domain to use for Patchwork, this is used in the HTTPD service virtual
  21207. host.
  21208. @item @code{settings-module}
  21209. The settings module to use for Patchwork. As a Django application, Patchwork
  21210. is configured with a Python module containing the settings. This can either be
  21211. an instance of the @code{<patchwork-settings-module>} record, any other record
  21212. that represents the settings in the store, or a directory outside of the
  21213. store.
  21214. @item @code{static-path} (default: @code{"/static/"})
  21215. The path under which the HTTPD service should serve the static files.
  21216. @item @code{getmail-retriever-config}
  21217. The getmail-retriever-configuration record value to use with
  21218. Patchwork. Getmail will be configured with this value, the messages will be
  21219. delivered to Patchwork.
  21220. @end table
  21221. @end deftp
  21222. @deftp {Data Type} patchwork-settings-module
  21223. Data type representing a settings module for Patchwork. Some of these
  21224. settings relate directly to Patchwork, but others relate to Django, the web
  21225. framework used by Patchwork, or the Django Rest Framework library. This type
  21226. has the following parameters:
  21227. @table @asis
  21228. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  21229. The database connection settings used for Patchwork. See the
  21230. @code{<patchwork-database-configuration>} record type for more information.
  21231. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  21232. Patchwork, as a Django web application uses a secret key for cryptographically
  21233. signing values. This file should contain a unique unpredictable value.
  21234. If this file does not exist, it will be created and populated with a random
  21235. value by the patchwork-setup shepherd service.
  21236. This setting relates to Django.
  21237. @item @code{allowed-hosts}
  21238. A list of valid hosts for this Patchwork service. This should at least include
  21239. the domain specified in the @code{<patchwork-configuration>} record.
  21240. This is a Django setting.
  21241. @item @code{default-from-email}
  21242. The email address from which Patchwork should send email by default.
  21243. This is a Patchwork setting.
  21244. @item @code{static-url} (default: @code{#f})
  21245. The URL to use when serving static assets. It can be part of a URL, or a full
  21246. URL, but must end in a @code{/}.
  21247. If the default value is used, the @code{static-path} value from the
  21248. @code{<patchwork-configuration>} record will be used.
  21249. This is a Django setting.
  21250. @item @code{admins} (default: @code{'()})
  21251. Email addresses to send the details of errors that occur. Each value should
  21252. be a list containing two elements, the name and then the email address.
  21253. This is a Django setting.
  21254. @item @code{debug?} (default: @code{#f})
  21255. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  21256. messages will be shown.
  21257. This is a Django setting.
  21258. @item @code{enable-rest-api?} (default: @code{#t})
  21259. Whether to enable the Patchwork REST API.
  21260. This is a Patchwork setting.
  21261. @item @code{enable-xmlrpc?} (default: @code{#t})
  21262. Whether to enable the XML RPC API.
  21263. This is a Patchwork setting.
  21264. @item @code{force-https-links?} (default: @code{#t})
  21265. Whether to use HTTPS links on Patchwork pages.
  21266. This is a Patchwork setting.
  21267. @item @code{extra-settings} (default: @code{""})
  21268. Extra code to place at the end of the Patchwork settings module.
  21269. @end table
  21270. @end deftp
  21271. @deftp {Data Type} patchwork-database-configuration
  21272. Data type representing the database configuration for Patchwork.
  21273. @table @asis
  21274. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  21275. The database engine to use.
  21276. @item @code{name} (default: @code{"patchwork"})
  21277. The name of the database to use.
  21278. @item @code{user} (default: @code{"httpd"})
  21279. The user to connect to the database as.
  21280. @item @code{password} (default: @code{""})
  21281. The password to use when connecting to the database.
  21282. @item @code{host} (default: @code{""})
  21283. The host to make the database connection to.
  21284. @item @code{port} (default: @code{""})
  21285. The port on which to connect to the database.
  21286. @end table
  21287. @end deftp
  21288. @subsubheading Mumi
  21289. @cindex Mumi, Debbugs Web interface
  21290. @cindex Debbugs, Mumi Web interface
  21291. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  21292. Web interface to the Debbugs bug tracker, by default for
  21293. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  21294. but it also fetches and indexes mail retrieved from Debbugs.
  21295. @defvr {Scheme Variable} mumi-service-type
  21296. This is the service type for Mumi.
  21297. @end defvr
  21298. @deftp {Data Type} mumi-configuration
  21299. Data type representing the Mumi service configuration. This type has the
  21300. following fields:
  21301. @table @asis
  21302. @item @code{mumi} (default: @code{mumi})
  21303. The Mumi package to use.
  21304. @item @code{mailer?} (default: @code{#true})
  21305. Whether to enable or disable the mailer component.
  21306. @item @code{mumi-configuration-sender}
  21307. The email address used as the sender for comments.
  21308. @item @code{mumi-configuration-smtp}
  21309. A URI to configure the SMTP settings for Mailutils. This could be
  21310. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  21311. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  21312. mailutils, GNU@tie{}Mailutils}.
  21313. @end table
  21314. @end deftp
  21315. @subsubheading FastCGI
  21316. @cindex fastcgi
  21317. @cindex fcgiwrap
  21318. FastCGI is an interface between the front-end and the back-end of a web
  21319. service. It is a somewhat legacy facility; new web services should
  21320. generally just talk HTTP between the front-end and the back-end.
  21321. However there are a number of back-end services such as PHP or the
  21322. optimized HTTP Git repository access that use FastCGI, so we have
  21323. support for it in Guix.
  21324. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  21325. dispatch some subset of its requests to the fastcgi backend, which
  21326. listens on a local TCP or UNIX socket. There is an intermediary
  21327. @code{fcgiwrap} program that sits between the actual backend process and
  21328. the web server. The front-end indicates which backend program to run,
  21329. passing that information to the @code{fcgiwrap} process.
  21330. @defvr {Scheme Variable} fcgiwrap-service-type
  21331. A service type for the @code{fcgiwrap} FastCGI proxy.
  21332. @end defvr
  21333. @deftp {Data Type} fcgiwrap-configuration
  21334. Data type representing the configuration of the @code{fcgiwrap} service.
  21335. This type has the following parameters:
  21336. @table @asis
  21337. @item @code{package} (default: @code{fcgiwrap})
  21338. The fcgiwrap package to use.
  21339. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  21340. The socket on which the @code{fcgiwrap} process should listen, as a
  21341. string. Valid @var{socket} values include
  21342. @code{unix:@var{/path/to/unix/socket}},
  21343. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  21344. @code{tcp6:[@var{ipv6_addr}]:port}.
  21345. @item @code{user} (default: @code{fcgiwrap})
  21346. @itemx @code{group} (default: @code{fcgiwrap})
  21347. The user and group names, as strings, under which to run the
  21348. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  21349. the user asks for the specific user or group names @code{fcgiwrap} that
  21350. the corresponding user and/or group is present on the system.
  21351. It is possible to configure a FastCGI-backed web service to pass HTTP
  21352. authentication information from the front-end to the back-end, and to
  21353. allow @code{fcgiwrap} to run the back-end process as a corresponding
  21354. local user. To enable this capability on the back-end, run
  21355. @code{fcgiwrap} as the @code{root} user and group. Note that this
  21356. capability also has to be configured on the front-end as well.
  21357. @end table
  21358. @end deftp
  21359. @cindex php-fpm
  21360. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  21361. with some additional features useful for sites of any size.
  21362. These features include:
  21363. @itemize @bullet
  21364. @item Adaptive process spawning
  21365. @item Basic statistics (similar to Apache's mod_status)
  21366. @item Advanced process management with graceful stop/start
  21367. @item Ability to start workers with different uid/gid/chroot/environment
  21368. and different php.ini (replaces safe_mode)
  21369. @item Stdout & stderr logging
  21370. @item Emergency restart in case of accidental opcode cache destruction
  21371. @item Accelerated upload support
  21372. @item Support for a "slowlog"
  21373. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  21374. a special function to finish request & flush all data while continuing to do
  21375. something time-consuming (video converting, stats processing, etc.)
  21376. @end itemize
  21377. ...@: and much more.
  21378. @defvr {Scheme Variable} php-fpm-service-type
  21379. A Service type for @code{php-fpm}.
  21380. @end defvr
  21381. @deftp {Data Type} php-fpm-configuration
  21382. Data Type for php-fpm service configuration.
  21383. @table @asis
  21384. @item @code{php} (default: @code{php})
  21385. The php package to use.
  21386. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  21387. The address on which to accept FastCGI requests. Valid syntaxes are:
  21388. @table @asis
  21389. @item @code{"ip.add.re.ss:port"}
  21390. Listen on a TCP socket to a specific address on a specific port.
  21391. @item @code{"port"}
  21392. Listen on a TCP socket to all addresses on a specific port.
  21393. @item @code{"/path/to/unix/socket"}
  21394. Listen on a unix socket.
  21395. @end table
  21396. @item @code{user} (default: @code{php-fpm})
  21397. User who will own the php worker processes.
  21398. @item @code{group} (default: @code{php-fpm})
  21399. Group of the worker processes.
  21400. @item @code{socket-user} (default: @code{php-fpm})
  21401. User who can speak to the php-fpm socket.
  21402. @item @code{socket-group} (default: @code{nginx})
  21403. Group that can speak to the php-fpm socket.
  21404. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  21405. The process id of the php-fpm process is written to this file
  21406. once the service has started.
  21407. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  21408. Log for the php-fpm master process.
  21409. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  21410. Detailed settings for the php-fpm process manager.
  21411. Must be one of:
  21412. @table @asis
  21413. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  21414. @item @code{<php-fpm-static-process-manager-configuration>}
  21415. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  21416. @end table
  21417. @item @code{display-errors} (default @code{#f})
  21418. Determines whether php errors and warning should be sent to clients
  21419. and displayed in their browsers.
  21420. This is useful for local php development, but a security risk for public sites,
  21421. as error messages can reveal passwords and personal data.
  21422. @item @code{timezone} (default @code{#f})
  21423. Specifies @code{php_admin_value[date.timezone]} parameter.
  21424. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  21425. This file will log the @code{stderr} outputs of php worker processes.
  21426. Can be set to @code{#f} to disable logging.
  21427. @item @code{file} (default @code{#f})
  21428. An optional override of the whole configuration.
  21429. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  21430. @item @code{php-ini-file} (default @code{#f})
  21431. An optional override of the default php settings.
  21432. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  21433. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  21434. For local development it is useful to set a higher timeout and memory
  21435. limit for spawned php processes. This be accomplished with the
  21436. following operating system configuration snippet:
  21437. @lisp
  21438. (define %local-php-ini
  21439. (plain-file "php.ini"
  21440. "memory_limit = 2G
  21441. max_execution_time = 1800"))
  21442. (operating-system
  21443. ;; @dots{}
  21444. (services (cons (service php-fpm-service-type
  21445. (php-fpm-configuration
  21446. (php-ini-file %local-php-ini)))
  21447. %base-services)))
  21448. @end lisp
  21449. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  21450. directives} for comprehensive documentation on the acceptable
  21451. @file{php.ini} directives.
  21452. @end table
  21453. @end deftp
  21454. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  21455. Data Type for the @code{dynamic} php-fpm process manager. With the
  21456. @code{dynamic} process manager, spare worker processes are kept around
  21457. based on its configured limits.
  21458. @table @asis
  21459. @item @code{max-children} (default: @code{5})
  21460. Maximum of worker processes.
  21461. @item @code{start-servers} (default: @code{2})
  21462. How many worker processes should be started on start-up.
  21463. @item @code{min-spare-servers} (default: @code{1})
  21464. How many spare worker processes should be kept around at minimum.
  21465. @item @code{max-spare-servers} (default: @code{3})
  21466. How many spare worker processes should be kept around at maximum.
  21467. @end table
  21468. @end deftp
  21469. @deftp {Data type} php-fpm-static-process-manager-configuration
  21470. Data Type for the @code{static} php-fpm process manager. With the
  21471. @code{static} process manager, an unchanging number of worker processes
  21472. are created.
  21473. @table @asis
  21474. @item @code{max-children} (default: @code{5})
  21475. Maximum of worker processes.
  21476. @end table
  21477. @end deftp
  21478. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  21479. Data Type for the @code{on-demand} php-fpm process manager. With the
  21480. @code{on-demand} process manager, worker processes are only created as
  21481. requests arrive.
  21482. @table @asis
  21483. @item @code{max-children} (default: @code{5})
  21484. Maximum of worker processes.
  21485. @item @code{process-idle-timeout} (default: @code{10})
  21486. The time in seconds after which a process with no requests is killed.
  21487. @end table
  21488. @end deftp
  21489. @deffn {Scheme Procedure} nginx-php-location @
  21490. [#:nginx-package nginx] @
  21491. [socket (string-append "/var/run/php" @
  21492. (version-major (package-version php)) @
  21493. "-fpm.sock")]
  21494. A helper function to quickly add php to an @code{nginx-server-configuration}.
  21495. @end deffn
  21496. A simple services setup for nginx with php can look like this:
  21497. @lisp
  21498. (services (cons* (service dhcp-client-service-type)
  21499. (service php-fpm-service-type)
  21500. (service nginx-service-type
  21501. (nginx-server-configuration
  21502. (server-name '("example.com"))
  21503. (root "/srv/http/")
  21504. (locations
  21505. (list (nginx-php-location)))
  21506. (listen '("80"))
  21507. (ssl-certificate #f)
  21508. (ssl-certificate-key #f)))
  21509. %base-services))
  21510. @end lisp
  21511. @cindex cat-avatar-generator
  21512. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  21513. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  21514. the hash of a user's email address.
  21515. @deffn {Scheme Procedure} cat-avatar-generator-service @
  21516. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  21517. [#:package cat-avatar-generator] @
  21518. [#:configuration (nginx-server-configuration)]
  21519. Returns an nginx-server-configuration that inherits @code{configuration}. It
  21520. extends the nginx configuration to add a server block that serves @code{package},
  21521. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  21522. be able to use @code{cache-dir} as its cache directory.
  21523. @end deffn
  21524. A simple setup for cat-avatar-generator can look like this:
  21525. @lisp
  21526. (services (cons* (cat-avatar-generator-service
  21527. #:configuration
  21528. (nginx-server-configuration
  21529. (server-name '("example.com"))))
  21530. ...
  21531. %base-services))
  21532. @end lisp
  21533. @subsubheading Hpcguix-web
  21534. @cindex hpcguix-web
  21535. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  21536. program is a customizable web interface to browse Guix packages,
  21537. initially designed for users of high-performance computing (HPC)
  21538. clusters.
  21539. @defvr {Scheme Variable} hpcguix-web-service-type
  21540. The service type for @code{hpcguix-web}.
  21541. @end defvr
  21542. @deftp {Data Type} hpcguix-web-configuration
  21543. Data type for the hpcguix-web service configuration.
  21544. @table @asis
  21545. @item @code{specs}
  21546. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  21547. configuration. The main items available in this spec are:
  21548. @table @asis
  21549. @item @code{title-prefix} (default: @code{"hpcguix | "})
  21550. The page title prefix.
  21551. @item @code{guix-command} (default: @code{"guix"})
  21552. The @command{guix} command.
  21553. @item @code{package-filter-proc} (default: @code{(const #t)})
  21554. A procedure specifying how to filter packages that are displayed.
  21555. @item @code{package-page-extension-proc} (default: @code{(const '())})
  21556. Extension package for @code{hpcguix-web}.
  21557. @item @code{menu} (default: @code{'()})
  21558. Additional entry in page @code{menu}.
  21559. @item @code{channels} (default: @code{%default-channels})
  21560. List of channels from which the package list is built (@pxref{Channels}).
  21561. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  21562. The expiration time, in seconds, after which the package list is rebuilt from
  21563. the latest instances of the given channels.
  21564. @end table
  21565. See the hpcguix-web repository for a
  21566. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  21567. complete example}.
  21568. @item @code{package} (default: @code{hpcguix-web})
  21569. The hpcguix-web package to use.
  21570. @item @code{address} (default: @code{"127.0.0.1"})
  21571. The IP address to listen to.
  21572. @item @code{port} (default: @code{5000})
  21573. The port number to listen to.
  21574. @end table
  21575. @end deftp
  21576. A typical hpcguix-web service declaration looks like this:
  21577. @lisp
  21578. (service hpcguix-web-service-type
  21579. (hpcguix-web-configuration
  21580. (specs
  21581. #~(define site-config
  21582. (hpcweb-configuration
  21583. (title-prefix "Guix-HPC - ")
  21584. (menu '(("/about" "ABOUT"))))))))
  21585. @end lisp
  21586. @quotation Note
  21587. The hpcguix-web service periodically updates the package list it publishes by
  21588. pulling channels from Git. To that end, it needs to access X.509 certificates
  21589. so that it can authenticate Git servers when communicating over HTTPS, and it
  21590. assumes that @file{/etc/ssl/certs} contains those certificates.
  21591. Thus, make sure to add @code{nss-certs} or another certificate package to the
  21592. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  21593. more information on X.509 certificates.
  21594. @end quotation
  21595. @subsubheading gmnisrv
  21596. @cindex gmnisrv
  21597. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  21598. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  21599. @deffn {Scheme Variable} gmnisrv-service-type
  21600. This is the type of the gmnisrv service, whose value should be a
  21601. @code{gmnisrv-configuration} object, as in this example:
  21602. @lisp
  21603. (service gmnisrv-service-type
  21604. (gmnisrv-configuration
  21605. (config-file (local-file "./my-gmnisrv.ini"))))
  21606. @end lisp
  21607. @end deffn
  21608. @deftp {Data Type} gmnisrv-configuration
  21609. Data type representing the configuration of gmnisrv.
  21610. @table @asis
  21611. @item @code{package} (default: @var{gmnisrv})
  21612. Package object of the gmnisrv server.
  21613. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  21614. File-like object of the gmnisrv configuration file to use. The default
  21615. configuration listens on port 1965 and serves files from
  21616. @file{/srv/gemini}. Certificates are stored in
  21617. @file{/var/lib/gemini/certs}. For more information, run @command{man
  21618. gmnisrv} and @command{man gmnisrv.ini}.
  21619. @end table
  21620. @end deftp
  21621. @subsubheading Agate
  21622. @cindex agate
  21623. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  21624. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  21625. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  21626. protocol server written in Rust.
  21627. @deffn {Scheme Variable} agate-service-type
  21628. This is the type of the agate service, whose value should be an
  21629. @code{agate-service-type} object, as in this example:
  21630. @lisp
  21631. (service agate-service-type
  21632. (agate-configuration
  21633. (content "/srv/gemini")
  21634. (cert "/srv/cert.pem")
  21635. (key "/srv/key.rsa")))
  21636. @end lisp
  21637. The example above represents the minimal tweaking necessary to get Agate
  21638. up and running. Specifying the path to the certificate and key is
  21639. always necessary, as the Gemini protocol requires TLS by default.
  21640. To obtain a certificate and a key, you could, for example, use OpenSSL,
  21641. running a command similar to the following example:
  21642. @example
  21643. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  21644. -days 3650 -nodes -subj "/CN=example.com"
  21645. @end example
  21646. Of course, you'll have to replace @i{example.com} with your own domain
  21647. name, and then point the Agate configuration towards the path of the
  21648. generated key and certificate.
  21649. @end deffn
  21650. @deftp {Data Type} agate-configuration
  21651. Data type representing the configuration of Agate.
  21652. @table @asis
  21653. @item @code{package} (default: @code{agate})
  21654. The package object of the Agate server.
  21655. @item @code{content} (default: @file{"/srv/gemini"})
  21656. The directory from which Agate will serve files.
  21657. @item @code{cert} (default: @code{#f})
  21658. The path to the TLS certificate PEM file to be used for encrypted
  21659. connections. Must be filled in with a value from the user.
  21660. @item @code{key} (default: @code{#f})
  21661. The path to the PKCS8 private key file to be used for encrypted
  21662. connections. Must be filled in with a value from the user.
  21663. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  21664. A list of the addresses to listen on.
  21665. @item @code{hostname} (default: @code{#f})
  21666. The domain name of this Gemini server. Optional.
  21667. @item @code{lang} (default: @code{#f})
  21668. RFC 4646 language code(s) for text/gemini documents. Optional.
  21669. @item @code{silent?} (default: @code{#f})
  21670. Set to @code{#t} to disable logging output.
  21671. @item @code{serve-secret?} (default: @code{#f})
  21672. Set to @code{#t} to serve secret files (files/directories starting with
  21673. a dot).
  21674. @item @code{log-ip?} (default: @code{#t})
  21675. Whether or not to output IP addresses when logging.
  21676. @item @code{user} (default: @code{"agate"})
  21677. Owner of the @code{agate} process.
  21678. @item @code{group} (default: @code{"agate"})
  21679. Owner's group of the @code{agate} process.
  21680. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  21681. The file which should store the logging output of Agate.
  21682. @end table
  21683. @end deftp
  21684. @node Certificate Services
  21685. @subsection Certificate Services
  21686. @cindex Web
  21687. @cindex HTTP, HTTPS
  21688. @cindex Let's Encrypt
  21689. @cindex TLS certificates
  21690. The @code{(gnu services certbot)} module provides a service to
  21691. automatically obtain a valid TLS certificate from the Let's Encrypt
  21692. certificate authority. These certificates can then be used to serve
  21693. content securely over HTTPS or other TLS-based protocols, with the
  21694. knowledge that the client will be able to verify the server's
  21695. authenticity.
  21696. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  21697. @code{certbot} tool to automate the certification process. This tool
  21698. first securely generates a key on the server. It then makes a request
  21699. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  21700. checks that the request originates from the host in question by using a
  21701. challenge-response protocol, requiring the server to provide its
  21702. response over HTTP@. If that protocol completes successfully, the CA
  21703. signs the key, resulting in a certificate. That certificate is valid
  21704. for a limited period of time, and therefore to continue to provide TLS
  21705. services, the server needs to periodically ask the CA to renew its
  21706. signature.
  21707. The certbot service automates this process: the initial key
  21708. generation, the initial certification request to the Let's Encrypt
  21709. service, the web server challenge/response integration, writing the
  21710. certificate to disk, the automated periodic renewals, and the deployment
  21711. tasks associated with the renewal (e.g.@: reloading services, copying keys
  21712. with different permissions).
  21713. Certbot is run twice a day, at a random minute within the hour. It
  21714. won't do anything until your certificates are due for renewal or
  21715. revoked, but running it regularly would give your service a chance of
  21716. staying online in case a Let's Encrypt-initiated revocation happened for
  21717. some reason.
  21718. By using this service, you agree to the ACME Subscriber Agreement, which
  21719. can be found there:
  21720. @url{https://acme-v01.api.letsencrypt.org/directory}.
  21721. @defvr {Scheme Variable} certbot-service-type
  21722. A service type for the @code{certbot} Let's Encrypt client. Its value
  21723. must be a @code{certbot-configuration} record as in this example:
  21724. @lisp
  21725. (define %nginx-deploy-hook
  21726. (program-file
  21727. "nginx-deploy-hook"
  21728. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  21729. (kill pid SIGHUP))))
  21730. (service certbot-service-type
  21731. (certbot-configuration
  21732. (email "foo@@example.net")
  21733. (certificates
  21734. (list
  21735. (certificate-configuration
  21736. (domains '("example.net" "www.example.net"))
  21737. (deploy-hook %nginx-deploy-hook))
  21738. (certificate-configuration
  21739. (domains '("bar.example.net")))))))
  21740. @end lisp
  21741. See below for details about @code{certbot-configuration}.
  21742. @end defvr
  21743. @deftp {Data Type} certbot-configuration
  21744. Data type representing the configuration of the @code{certbot} service.
  21745. This type has the following parameters:
  21746. @table @asis
  21747. @item @code{package} (default: @code{certbot})
  21748. The certbot package to use.
  21749. @item @code{webroot} (default: @code{/var/www})
  21750. The directory from which to serve the Let's Encrypt challenge/response
  21751. files.
  21752. @item @code{certificates} (default: @code{()})
  21753. A list of @code{certificates-configuration}s for which to generate
  21754. certificates and request signatures. Each certificate has a @code{name}
  21755. and several @code{domains}.
  21756. @item @code{email} (default: @code{#f})
  21757. Optional email address used for registration and recovery contact.
  21758. Setting this is encouraged as it allows you to receive important
  21759. notifications about the account and issued certificates.
  21760. @item @code{server} (default: @code{#f})
  21761. Optional URL of ACME server. Setting this overrides certbot's default,
  21762. which is the Let's Encrypt server.
  21763. @item @code{rsa-key-size} (default: @code{2048})
  21764. Size of the RSA key.
  21765. @item @code{default-location} (default: @i{see below})
  21766. The default @code{nginx-location-configuration}. Because @code{certbot}
  21767. needs to be able to serve challenges and responses, it needs to be able
  21768. to run a web server. It does so by extending the @code{nginx} web
  21769. service with an @code{nginx-server-configuration} listening on the
  21770. @var{domains} on port 80, and which has a
  21771. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  21772. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  21773. these nginx configuration data types.
  21774. Requests to other URL paths will be matched by the
  21775. @code{default-location}, which if present is added to all
  21776. @code{nginx-server-configuration}s.
  21777. By default, the @code{default-location} will issue a redirect from
  21778. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  21779. you to define what to serve on your site via @code{https}.
  21780. Pass @code{#f} to not issue a default location.
  21781. @end table
  21782. @end deftp
  21783. @deftp {Data Type} certificate-configuration
  21784. Data type representing the configuration of a certificate.
  21785. This type has the following parameters:
  21786. @table @asis
  21787. @item @code{name} (default: @i{see below})
  21788. This name is used by Certbot for housekeeping and in file paths; it
  21789. doesn't affect the content of the certificate itself. To see
  21790. certificate names, run @code{certbot certificates}.
  21791. Its default is the first provided domain.
  21792. @item @code{domains} (default: @code{()})
  21793. The first domain provided will be the subject CN of the certificate, and
  21794. all domains will be Subject Alternative Names on the certificate.
  21795. @item @code{challenge} (default: @code{#f})
  21796. The challenge type that has to be run by certbot. If @code{#f} is specified,
  21797. default to the HTTP challenge. If a value is specified, defaults to the
  21798. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  21799. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  21800. and gives Let's Encrypt permission to log the public IP address of the
  21801. requesting machine.
  21802. @item @code{csr} (default: @code{#f})
  21803. File name of Certificate Signing Request (CSR) in DER or PEM format.
  21804. If @code{#f} is specified, this argument will not be passed to certbot.
  21805. If a value is specified, certbot will use it to obtain a certificate, instead of
  21806. using a self-generated CSR.
  21807. The domain-name(s) mentioned in @code{domains}, must be consistent with the
  21808. domain-name(s) mentioned in CSR file.
  21809. @item @code{authentication-hook} (default: @code{#f})
  21810. Command to be run in a shell once for each certificate challenge to be
  21811. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  21812. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  21813. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  21814. file name of the resource requested when performing an HTTP-01 challenge.
  21815. @item @code{cleanup-hook} (default: @code{#f})
  21816. Command to be run in a shell once for each certificate challenge that
  21817. have been answered by the @code{auth-hook}. For this command, the shell
  21818. variables available in the @code{auth-hook} script are still available, and
  21819. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  21820. of the @code{auth-hook} script.
  21821. @item @code{deploy-hook} (default: @code{#f})
  21822. Command to be run in a shell once for each successfully issued
  21823. certificate. For this command, the shell variable
  21824. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  21825. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  21826. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  21827. contain a space-delimited list of renewed certificate domains (for
  21828. example, @samp{"example.com www.example.com"}.
  21829. @end table
  21830. @end deftp
  21831. For each @code{certificate-configuration}, the certificate is saved to
  21832. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  21833. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  21834. @node DNS Services
  21835. @subsection DNS Services
  21836. @cindex DNS (domain name system)
  21837. @cindex domain name system (DNS)
  21838. The @code{(gnu services dns)} module provides services related to the
  21839. @dfn{domain name system} (DNS). It provides a server service for hosting
  21840. an @emph{authoritative} DNS server for multiple zones, slave or master.
  21841. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  21842. caching and forwarding DNS server for the LAN, which uses
  21843. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  21844. @subsubheading Knot Service
  21845. An example configuration of an authoritative server for two zones, one master
  21846. and one slave, is:
  21847. @lisp
  21848. (define-zone-entries example.org.zone
  21849. ;; Name TTL Class Type Data
  21850. ("@@" "" "IN" "A" "127.0.0.1")
  21851. ("@@" "" "IN" "NS" "ns")
  21852. ("ns" "" "IN" "A" "127.0.0.1"))
  21853. (define master-zone
  21854. (knot-zone-configuration
  21855. (domain "example.org")
  21856. (zone (zone-file
  21857. (origin "example.org")
  21858. (entries example.org.zone)))))
  21859. (define slave-zone
  21860. (knot-zone-configuration
  21861. (domain "plop.org")
  21862. (dnssec-policy "default")
  21863. (master (list "plop-master"))))
  21864. (define plop-master
  21865. (knot-remote-configuration
  21866. (id "plop-master")
  21867. (address (list "208.76.58.171"))))
  21868. (operating-system
  21869. ;; ...
  21870. (services (cons* (service knot-service-type
  21871. (knot-configuration
  21872. (remotes (list plop-master))
  21873. (zones (list master-zone slave-zone))))
  21874. ;; ...
  21875. %base-services)))
  21876. @end lisp
  21877. @deffn {Scheme Variable} knot-service-type
  21878. This is the type for the Knot DNS server.
  21879. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  21880. zones, that is to say domain names you would buy from a registrar. This server
  21881. is not a resolver, meaning that it can only resolve names for which it is
  21882. authoritative. This server can be configured to serve zones as a master server
  21883. or a slave server as a per-zone basis. Slave zones will get their data from
  21884. masters, and will serve it as an authoritative server. From the point of view
  21885. of a resolver, there is no difference between master and slave.
  21886. The following data types are used to configure the Knot DNS server:
  21887. @end deffn
  21888. @deftp {Data Type} knot-key-configuration
  21889. Data type representing a key.
  21890. This type has the following parameters:
  21891. @table @asis
  21892. @item @code{id} (default: @code{""})
  21893. An identifier for other configuration fields to refer to this key. IDs must
  21894. be unique and must not be empty.
  21895. @item @code{algorithm} (default: @code{#f})
  21896. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  21897. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  21898. and @code{'hmac-sha512}.
  21899. @item @code{secret} (default: @code{""})
  21900. The secret key itself.
  21901. @end table
  21902. @end deftp
  21903. @deftp {Data Type} knot-acl-configuration
  21904. Data type representing an Access Control List (ACL) configuration.
  21905. This type has the following parameters:
  21906. @table @asis
  21907. @item @code{id} (default: @code{""})
  21908. An identifier for other configuration fields to refer to this key. IDs must be
  21909. unique and must not be empty.
  21910. @item @code{address} (default: @code{'()})
  21911. An ordered list of IP addresses, network subnets, or network ranges represented
  21912. with strings. The query must match one of them. Empty value means that
  21913. address match is not required.
  21914. @item @code{key} (default: @code{'()})
  21915. An ordered list of references to keys represented with strings. The string
  21916. must match a key ID defined in a @code{knot-key-configuration}. No key means
  21917. that a key is not require to match that ACL.
  21918. @item @code{action} (default: @code{'()})
  21919. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  21920. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  21921. and @code{'update}.
  21922. @item @code{deny?} (default: @code{#f})
  21923. When true, the ACL defines restrictions. Listed actions are forbidden. When
  21924. false, listed actions are allowed.
  21925. @end table
  21926. @end deftp
  21927. @deftp {Data Type} zone-entry
  21928. Data type representing a record entry in a zone file.
  21929. This type has the following parameters:
  21930. @table @asis
  21931. @item @code{name} (default: @code{"@@"})
  21932. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  21933. are relative to the origin of the zone. For example, in the @code{example.org}
  21934. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  21935. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  21936. refers to @code{ns.example.org}.
  21937. @item @code{ttl} (default: @code{""})
  21938. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  21939. @item @code{class} (default: @code{"IN"})
  21940. The class of the record. Knot currently supports only @code{"IN"} and
  21941. partially @code{"CH"}.
  21942. @item @code{type} (default: @code{"A"})
  21943. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  21944. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  21945. defined.
  21946. @item @code{data} (default: @code{""})
  21947. The data contained in the record. For instance an IP address associated with
  21948. an A record, or a domain name associated with an NS record. Remember that
  21949. domain names are relative to the origin unless they end with a dot.
  21950. @end table
  21951. @end deftp
  21952. @deftp {Data Type} zone-file
  21953. Data type representing the content of a zone file.
  21954. This type has the following parameters:
  21955. @table @asis
  21956. @item @code{entries} (default: @code{'()})
  21957. The list of entries. The SOA record is taken care of, so you don't need to
  21958. put it in the list of entries. This list should probably contain an entry
  21959. for your primary authoritative DNS server. Other than using a list of entries
  21960. directly, you can use @code{define-zone-entries} to define a object containing
  21961. the list of entries more easily, that you can later pass to the @code{entries}
  21962. field of the @code{zone-file}.
  21963. @item @code{origin} (default: @code{""})
  21964. The name of your zone. This parameter cannot be empty.
  21965. @item @code{ns} (default: @code{"ns"})
  21966. The domain of your primary authoritative DNS server. The name is relative to
  21967. the origin, unless it ends with a dot. It is mandatory that this primary
  21968. DNS server corresponds to an NS record in the zone and that it is associated
  21969. to an IP address in the list of entries.
  21970. @item @code{mail} (default: @code{"hostmaster"})
  21971. An email address people can contact you at, as the owner of the zone. This
  21972. is translated as @code{<mail>@@<origin>}.
  21973. @item @code{serial} (default: @code{1})
  21974. The serial number of the zone. As this is used to keep track of changes by
  21975. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  21976. Always increment it when you make a change in your zone.
  21977. @item @code{refresh} (default: @code{(* 2 24 3600)})
  21978. The frequency at which slaves will do a zone transfer. This value is a number
  21979. of seconds. It can be computed by multiplications or with
  21980. @code{(string->duration)}.
  21981. @item @code{retry} (default: @code{(* 15 60)})
  21982. The period after which a slave will retry to contact its master when it fails
  21983. to do so a first time.
  21984. @item @code{expiry} (default: @code{(* 14 24 3600)})
  21985. Default TTL of records. Existing records are considered correct for at most
  21986. this amount of time. After this period, resolvers will invalidate their cache
  21987. and check again that it still exists.
  21988. @item @code{nx} (default: @code{3600})
  21989. Default TTL of inexistent records. This delay is usually short because you want
  21990. your new domains to reach everyone quickly.
  21991. @end table
  21992. @end deftp
  21993. @deftp {Data Type} knot-remote-configuration
  21994. Data type representing a remote configuration.
  21995. This type has the following parameters:
  21996. @table @asis
  21997. @item @code{id} (default: @code{""})
  21998. An identifier for other configuration fields to refer to this remote. IDs must
  21999. be unique and must not be empty.
  22000. @item @code{address} (default: @code{'()})
  22001. An ordered list of destination IP addresses. Addresses are tried in sequence.
  22002. An optional port can be given with the @@ separator. For instance:
  22003. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  22004. @item @code{via} (default: @code{'()})
  22005. An ordered list of source IP addresses. An empty list will have Knot choose
  22006. an appropriate source IP@. An optional port can be given with the @@ separator.
  22007. The default is to choose at random.
  22008. @item @code{key} (default: @code{#f})
  22009. A reference to a key, that is a string containing the identifier of a key
  22010. defined in a @code{knot-key-configuration} field.
  22011. @end table
  22012. @end deftp
  22013. @deftp {Data Type} knot-keystore-configuration
  22014. Data type representing a keystore to hold dnssec keys.
  22015. This type has the following parameters:
  22016. @table @asis
  22017. @item @code{id} (default: @code{""})
  22018. The id of the keystore. It must not be empty.
  22019. @item @code{backend} (default: @code{'pem})
  22020. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  22021. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  22022. The configuration string of the backend. An example for the PKCS#11 is:
  22023. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  22024. For the pem backend, the string represents a path in the file system.
  22025. @end table
  22026. @end deftp
  22027. @deftp {Data Type} knot-policy-configuration
  22028. Data type representing a dnssec policy. Knot DNS is able to automatically
  22029. sign your zones. It can either generate and manage your keys automatically or
  22030. use keys that you generate.
  22031. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  22032. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  22033. zone. In order to be trusted, the KSK needs to be present in the parent zone
  22034. (usually a top-level domain). If your registrar supports dnssec, you will
  22035. have to send them your KSK's hash so they can add a DS record in their zone.
  22036. This is not automated and need to be done each time you change your KSK.
  22037. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  22038. easily and use weaker cryptographic functions (they use lower parameters) in
  22039. order to sign records quickly, so they are changed often. The KSK however
  22040. requires manual interaction with the registrar, so they are changed less often
  22041. and use stronger parameters because they sign only one record.
  22042. This type has the following parameters:
  22043. @table @asis
  22044. @item @code{id} (default: @code{""})
  22045. The id of the policy. It must not be empty.
  22046. @item @code{keystore} (default: @code{"default"})
  22047. A reference to a keystore, that is a string containing the identifier of a
  22048. keystore defined in a @code{knot-keystore-configuration} field. The
  22049. @code{"default"} identifier means the default keystore (a kasp database that
  22050. was setup by this service).
  22051. @item @code{manual?} (default: @code{#f})
  22052. Whether the key management is manual or automatic.
  22053. @item @code{single-type-signing?} (default: @code{#f})
  22054. When @code{#t}, use the Single-Type Signing Scheme.
  22055. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  22056. An algorithm of signing keys and issued signatures.
  22057. @item @code{ksk-size} (default: @code{256})
  22058. The length of the KSK@. Note that this value is correct for the default
  22059. algorithm, but would be unsecure for other algorithms.
  22060. @item @code{zsk-size} (default: @code{256})
  22061. The length of the ZSK@. Note that this value is correct for the default
  22062. algorithm, but would be unsecure for other algorithms.
  22063. @item @code{dnskey-ttl} (default: @code{'default})
  22064. The TTL value for DNSKEY records added into zone apex. The special
  22065. @code{'default} value means same as the zone SOA TTL.
  22066. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  22067. The period between ZSK publication and the next rollover initiation.
  22068. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  22069. An extra delay added for each key rollover step. This value should be high
  22070. enough to cover propagation of data from the master server to all slaves.
  22071. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  22072. A validity period of newly issued signatures.
  22073. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  22074. A period how long before a signature expiration the signature will be refreshed.
  22075. @item @code{nsec3?} (default: @code{#f})
  22076. When @code{#t}, NSEC3 will be used instead of NSEC.
  22077. @item @code{nsec3-iterations} (default: @code{5})
  22078. The number of additional times the hashing is performed.
  22079. @item @code{nsec3-salt-length} (default: @code{8})
  22080. The length of a salt field in octets, which is appended to the original owner
  22081. name before hashing.
  22082. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  22083. The validity period of newly issued salt field.
  22084. @end table
  22085. @end deftp
  22086. @deftp {Data Type} knot-zone-configuration
  22087. Data type representing a zone served by Knot.
  22088. This type has the following parameters:
  22089. @table @asis
  22090. @item @code{domain} (default: @code{""})
  22091. The domain served by this configuration. It must not be empty.
  22092. @item @code{file} (default: @code{""})
  22093. The file where this zone is saved. This parameter is ignored by master zones.
  22094. Empty means default location that depends on the domain name.
  22095. @item @code{zone} (default: @code{(zone-file)})
  22096. The content of the zone file. This parameter is ignored by slave zones. It
  22097. must contain a zone-file record.
  22098. @item @code{master} (default: @code{'()})
  22099. A list of master remotes. When empty, this zone is a master. When set, this
  22100. zone is a slave. This is a list of remotes identifiers.
  22101. @item @code{ddns-master} (default: @code{#f})
  22102. The main master. When empty, it defaults to the first master in the list of
  22103. masters.
  22104. @item @code{notify} (default: @code{'()})
  22105. A list of slave remote identifiers.
  22106. @item @code{acl} (default: @code{'()})
  22107. A list of acl identifiers.
  22108. @item @code{semantic-checks?} (default: @code{#f})
  22109. When set, this adds more semantic checks to the zone.
  22110. @item @code{zonefile-sync} (default: @code{0})
  22111. The delay between a modification in memory and on disk. 0 means immediate
  22112. synchronization.
  22113. @item @code{zonefile-load} (default: @code{#f})
  22114. The way the zone file contents are applied during zone load. Possible values
  22115. are:
  22116. @itemize
  22117. @item @code{#f} for using the default value from Knot,
  22118. @item @code{'none} for not using the zone file at all,
  22119. @item @code{'difference} for computing the difference between already available
  22120. contents and zone contents and applying it to the current zone contents,
  22121. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  22122. ignoring the SOA serial in the zone file, while the server takes care of it
  22123. automatically.
  22124. @item @code{'whole} for loading zone contents from the zone file.
  22125. @end itemize
  22126. @item @code{journal-content} (default: @code{#f})
  22127. The way the journal is used to store zone and its changes. Possible values
  22128. are @code{'none} to not use it at all, @code{'changes} to store changes and
  22129. @code{'all} to store contents. @code{#f} does not set this option, so the
  22130. default value from Knot is used.
  22131. @item @code{max-journal-usage} (default: @code{#f})
  22132. The maximum size for the journal on disk. @code{#f} does not set this option,
  22133. so the default value from Knot is used.
  22134. @item @code{max-journal-depth} (default: @code{#f})
  22135. The maximum size of the history. @code{#f} does not set this option, so the
  22136. default value from Knot is used.
  22137. @item @code{max-zone-size} (default: @code{#f})
  22138. The maximum size of the zone file. This limit is enforced for incoming
  22139. transfer and updates. @code{#f} does not set this option, so the default
  22140. value from Knot is used.
  22141. @item @code{dnssec-policy} (default: @code{#f})
  22142. A reference to a @code{knot-policy-configuration} record, or the special
  22143. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  22144. on this zone.
  22145. @item @code{serial-policy} (default: @code{'increment})
  22146. A policy between @code{'increment} and @code{'unixtime}.
  22147. @end table
  22148. @end deftp
  22149. @deftp {Data Type} knot-configuration
  22150. Data type representing the Knot configuration.
  22151. This type has the following parameters:
  22152. @table @asis
  22153. @item @code{knot} (default: @code{knot})
  22154. The Knot package.
  22155. @item @code{run-directory} (default: @code{"/var/run/knot"})
  22156. The run directory. This directory will be used for pid file and sockets.
  22157. @item @code{includes} (default: @code{'()})
  22158. A list of strings or file-like objects denoting other files that must be
  22159. included at the top of the configuration file.
  22160. @cindex secrets, Knot service
  22161. This can be used to manage secrets out-of-band. For example, secret
  22162. keys may be stored in an out-of-band file not managed by Guix, and
  22163. thus not visible in @file{/gnu/store}---e.g., you could store secret
  22164. key configuration in @file{/etc/knot/secrets.conf} and add this file
  22165. to the @code{includes} list.
  22166. One can generate a secret tsig key (for nsupdate and zone transfers with the
  22167. keymgr command from the knot package. Note that the package is not automatically
  22168. installed by the service. The following example shows how to generate a new
  22169. tsig key:
  22170. @example
  22171. keymgr -t mysecret > /etc/knot/secrets.conf
  22172. chmod 600 /etc/knot/secrets.conf
  22173. @end example
  22174. Also note that the generated key will be named @var{mysecret}, so it is the
  22175. name that needs to be used in the @var{key} field of the
  22176. @code{knot-acl-configuration} record and in other places that need to refer
  22177. to that key.
  22178. It can also be used to add configuration not supported by this interface.
  22179. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  22180. An ip address on which to listen.
  22181. @item @code{listen-v6} (default: @code{"::"})
  22182. An ip address on which to listen.
  22183. @item @code{listen-port} (default: @code{53})
  22184. A port on which to listen.
  22185. @item @code{keys} (default: @code{'()})
  22186. The list of knot-key-configuration used by this configuration.
  22187. @item @code{acls} (default: @code{'()})
  22188. The list of knot-acl-configuration used by this configuration.
  22189. @item @code{remotes} (default: @code{'()})
  22190. The list of knot-remote-configuration used by this configuration.
  22191. @item @code{zones} (default: @code{'()})
  22192. The list of knot-zone-configuration used by this configuration.
  22193. @end table
  22194. @end deftp
  22195. @subsubheading Knot Resolver Service
  22196. @deffn {Scheme Variable} knot-resolver-service-type
  22197. This is the type of the knot resolver service, whose value should be
  22198. an @code{knot-resolver-configuration} object as in this example:
  22199. @lisp
  22200. (service knot-resolver-service-type
  22201. (knot-resolver-configuration
  22202. (kresd-config-file (plain-file "kresd.conf" "
  22203. net.listen('192.168.0.1', 5353)
  22204. user('knot-resolver', 'knot-resolver')
  22205. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  22206. cache.size = 100 * MB
  22207. "))))
  22208. @end lisp
  22209. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  22210. @end deffn
  22211. @deftp {Data Type} knot-resolver-configuration
  22212. Data type representing the configuration of knot-resolver.
  22213. @table @asis
  22214. @item @code{package} (default: @var{knot-resolver})
  22215. Package object of the knot DNS resolver.
  22216. @item @code{kresd-config-file} (default: %kresd.conf)
  22217. File-like object of the kresd configuration file to use, by default it
  22218. will listen on @code{127.0.0.1} and @code{::1}.
  22219. @item @code{garbage-collection-interval} (default: 1000)
  22220. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  22221. @end table
  22222. @end deftp
  22223. @subsubheading Dnsmasq Service
  22224. @deffn {Scheme Variable} dnsmasq-service-type
  22225. This is the type of the dnsmasq service, whose value should be an
  22226. @code{dnsmasq-configuration} object as in this example:
  22227. @lisp
  22228. (service dnsmasq-service-type
  22229. (dnsmasq-configuration
  22230. (no-resolv? #t)
  22231. (servers '("192.168.1.1"))))
  22232. @end lisp
  22233. @end deffn
  22234. @deftp {Data Type} dnsmasq-configuration
  22235. Data type representing the configuration of dnsmasq.
  22236. @table @asis
  22237. @item @code{package} (default: @var{dnsmasq})
  22238. Package object of the dnsmasq server.
  22239. @item @code{no-hosts?} (default: @code{#f})
  22240. When true, don't read the hostnames in /etc/hosts.
  22241. @item @code{port} (default: @code{53})
  22242. The port to listen on. Setting this to zero completely disables DNS
  22243. responses, leaving only DHCP and/or TFTP functions.
  22244. @item @code{local-service?} (default: @code{#t})
  22245. Accept DNS queries only from hosts whose address is on a local subnet,
  22246. ie a subnet for which an interface exists on the server.
  22247. @item @code{listen-addresses} (default: @code{'()})
  22248. Listen on the given IP addresses.
  22249. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  22250. The file to read the IP address of the upstream nameservers from.
  22251. @item @code{no-resolv?} (default: @code{#f})
  22252. When true, don't read @var{resolv-file}.
  22253. @item @code{servers} (default: @code{'()})
  22254. Specify IP address of upstream servers directly.
  22255. @item @code{addresses} (default: @code{'()})
  22256. For each entry, specify an IP address to return for any host in the
  22257. given domains. Queries in the domains are never forwarded and always
  22258. replied to with the specified IP address.
  22259. This is useful for redirecting hosts locally, for example:
  22260. @lisp
  22261. (service dnsmasq-service-type
  22262. (dnsmasq-configuration
  22263. (addresses
  22264. '(; Redirect to a local web-server.
  22265. "/example.org/127.0.0.1"
  22266. ; Redirect subdomain to a specific IP.
  22267. "/subdomain.example.org/192.168.1.42"))))
  22268. @end lisp
  22269. Note that rules in @file{/etc/hosts} take precedence over this.
  22270. @item @code{cache-size} (default: @code{150})
  22271. Set the size of dnsmasq's cache. Setting the cache size to zero
  22272. disables caching.
  22273. @item @code{negative-cache?} (default: @code{#t})
  22274. When false, disable negative caching.
  22275. @item @code{tftp-enable?} (default: @code{#f})
  22276. Whether to enable the built-in TFTP server.
  22277. @item @code{tftp-no-fail?} (default: @code{#f})
  22278. If true, does not fail dnsmasq if the TFTP server could not start up.
  22279. @item @code{tftp-single-port?} (default: @code{#f})
  22280. Whether to use only one single port for TFTP.
  22281. @item @code{tftp-secure?} (default: @code{#f})
  22282. If true, only files owned by the user running the dnsmasq process are accessible.
  22283. If dnsmasq is being run as root, different rules apply:
  22284. @code{tftp-secure?} has no effect, but only files which have the
  22285. world-readable bit set are accessible.
  22286. @item @code{tftp-max} (default: @code{#f})
  22287. If set, sets the maximal number of concurrent connections allowed.
  22288. @item @code{tftp-mtu} (default: @code{#f})
  22289. If set, sets the MTU for TFTP packets to that value.
  22290. @item @code{tftp-no-blocksize?} (default: @code{#f})
  22291. If true, stops the TFTP server from negotiating the blocksize with a client.
  22292. @item @code{tftp-lowercase?} (default: @code{#f})
  22293. Whether to convert all filenames in TFTP requests to lowercase.
  22294. @item @code{tftp-port-range} (default: @code{#f})
  22295. If set, fixes the dynamical ports (one per client) to the given range
  22296. (@code{"<start>,<end>"}).
  22297. @item @code{tftp-root} (default: @code{/var/empty,lo})
  22298. Look for files to transfer using TFTP relative to the given directory.
  22299. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  22300. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  22301. allowed, but they must be within the TFTP-root. If the optional interface
  22302. argument is given, the directory is only used for TFTP requests via that
  22303. interface.
  22304. @item @code{tftp-unique-root} (default: @code{#f})
  22305. If set, add the IP or hardware address of the TFTP client as a path component
  22306. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  22307. directory exists. Defaults to adding IP address (in standard dotted-quad
  22308. format).
  22309. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  22310. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  22311. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  22312. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  22313. append the MAC address instead, using lowercase zero padded digits
  22314. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  22315. resolving MAC addresses is only possible if the client is in the local
  22316. network or obtained a DHCP lease from dnsmasq.
  22317. @end table
  22318. @end deftp
  22319. @subsubheading ddclient Service
  22320. @cindex ddclient
  22321. The ddclient service described below runs the ddclient daemon, which takes
  22322. care of automatically updating DNS entries for service providers such as
  22323. @uref{https://dyn.com/dns/, Dyn}.
  22324. The following example show instantiates the service with its default
  22325. configuration:
  22326. @lisp
  22327. (service ddclient-service-type)
  22328. @end lisp
  22329. Note that ddclient needs to access credentials that are stored in a
  22330. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  22331. @code{secret-file} below). You are expected to create this file manually, in
  22332. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  22333. service configuration, for instance by using @code{plain-file}, but it will be
  22334. world-readable @i{via} @file{/gnu/store}). See the examples in the
  22335. @file{share/ddclient} directory of the @code{ddclient} package.
  22336. @c %start of fragment
  22337. Available @code{ddclient-configuration} fields are:
  22338. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  22339. The ddclient package.
  22340. @end deftypevr
  22341. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  22342. The period after which ddclient will retry to check IP and domain name.
  22343. Defaults to @samp{300}.
  22344. @end deftypevr
  22345. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  22346. Use syslog for the output.
  22347. Defaults to @samp{#t}.
  22348. @end deftypevr
  22349. @deftypevr {@code{ddclient-configuration} parameter} string mail
  22350. Mail to user.
  22351. Defaults to @samp{"root"}.
  22352. @end deftypevr
  22353. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  22354. Mail failed update to user.
  22355. Defaults to @samp{"root"}.
  22356. @end deftypevr
  22357. @deftypevr {@code{ddclient-configuration} parameter} string pid
  22358. The ddclient PID file.
  22359. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  22360. @end deftypevr
  22361. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  22362. Enable SSL support.
  22363. Defaults to @samp{#t}.
  22364. @end deftypevr
  22365. @deftypevr {@code{ddclient-configuration} parameter} string user
  22366. Specifies the user name or ID that is used when running ddclient
  22367. program.
  22368. Defaults to @samp{"ddclient"}.
  22369. @end deftypevr
  22370. @deftypevr {@code{ddclient-configuration} parameter} string group
  22371. Group of the user who will run the ddclient program.
  22372. Defaults to @samp{"ddclient"}.
  22373. @end deftypevr
  22374. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  22375. Secret file which will be appended to @file{ddclient.conf} file. This
  22376. file contains credentials for use by ddclient. You are expected to
  22377. create it manually.
  22378. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  22379. @end deftypevr
  22380. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  22381. Extra options will be appended to @file{ddclient.conf} file.
  22382. Defaults to @samp{()}.
  22383. @end deftypevr
  22384. @c %end of fragment
  22385. @node VPN Services
  22386. @subsection VPN Services
  22387. @cindex VPN (virtual private network)
  22388. @cindex virtual private network (VPN)
  22389. The @code{(gnu services vpn)} module provides services related to
  22390. @dfn{virtual private networks} (VPNs).
  22391. @subsubheading Bitmask
  22392. @defvr {Scheme Variable} bitmask-service-type
  22393. A service type for the @uref{https://bitmask.net, Bitmask} VPN client. It makes
  22394. the client available in the system and loads its polkit policy. Please note that
  22395. the client expects an active polkit-agent, which is either run by your
  22396. desktop-environment or should be run manually.
  22397. @end defvr
  22398. @subsubheading OpenVPN
  22399. It provides a @emph{client} service for your machine to connect to a
  22400. VPN, and a @emph{server} service for your machine to host a VPN@.
  22401. @deffn {Scheme Procedure} openvpn-client-service @
  22402. [#:config (openvpn-client-configuration)]
  22403. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  22404. @end deffn
  22405. @deffn {Scheme Procedure} openvpn-server-service @
  22406. [#:config (openvpn-server-configuration)]
  22407. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  22408. Both can be run simultaneously.
  22409. @end deffn
  22410. @c %automatically generated documentation
  22411. Available @code{openvpn-client-configuration} fields are:
  22412. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  22413. The OpenVPN package.
  22414. @end deftypevr
  22415. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  22416. The OpenVPN pid file.
  22417. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  22418. @end deftypevr
  22419. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  22420. The protocol (UDP or TCP) used to open a channel between clients and
  22421. servers.
  22422. Defaults to @samp{udp}.
  22423. @end deftypevr
  22424. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  22425. The device type used to represent the VPN connection.
  22426. Defaults to @samp{tun}.
  22427. @end deftypevr
  22428. If you do not have some of these files (eg.@: you use a username and
  22429. password), you can disable any of the following three fields by setting
  22430. it to @code{'disabled}.
  22431. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  22432. The certificate authority to check connections against.
  22433. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  22434. @end deftypevr
  22435. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  22436. The certificate of the machine the daemon is running on. It should be
  22437. signed by the authority given in @code{ca}.
  22438. Defaults to @samp{"/etc/openvpn/client.crt"}.
  22439. @end deftypevr
  22440. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  22441. The key of the machine the daemon is running on. It must be the key whose
  22442. certificate is @code{cert}.
  22443. Defaults to @samp{"/etc/openvpn/client.key"}.
  22444. @end deftypevr
  22445. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  22446. Whether to use the lzo compression algorithm.
  22447. Defaults to @samp{#t}.
  22448. @end deftypevr
  22449. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  22450. Don't re-read key files across SIGUSR1 or --ping-restart.
  22451. Defaults to @samp{#t}.
  22452. @end deftypevr
  22453. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  22454. Don't close and reopen TUN/TAP device or run up/down scripts across
  22455. SIGUSR1 or --ping-restart restarts.
  22456. Defaults to @samp{#t}.
  22457. @end deftypevr
  22458. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  22459. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  22460. poll/epoll/select prior to the write operation.
  22461. Defaults to @samp{#f}.
  22462. @end deftypevr
  22463. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  22464. Verbosity level.
  22465. Defaults to @samp{3}.
  22466. @end deftypevr
  22467. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  22468. Add an additional layer of HMAC authentication on top of the TLS control
  22469. channel to protect against DoS attacks.
  22470. Defaults to @samp{#f}.
  22471. @end deftypevr
  22472. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  22473. Authenticate with server using username/password. The option is a file
  22474. containing username/password on 2 lines. Do not use a file-like object as it
  22475. would be added to the store and readable by any user.
  22476. Defaults to @samp{'disabled}.
  22477. @end deftypevr
  22478. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  22479. Whether to check the server certificate has server usage extension.
  22480. Defaults to @samp{#t}.
  22481. @end deftypevr
  22482. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  22483. Bind to a specific local port number.
  22484. Defaults to @samp{#f}.
  22485. @end deftypevr
  22486. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  22487. Retry resolving server address.
  22488. Defaults to @samp{#t}.
  22489. @end deftypevr
  22490. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  22491. A list of remote servers to connect to.
  22492. Defaults to @samp{()}.
  22493. Available @code{openvpn-remote-configuration} fields are:
  22494. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  22495. Server name.
  22496. Defaults to @samp{"my-server"}.
  22497. @end deftypevr
  22498. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  22499. Port number the server listens to.
  22500. Defaults to @samp{1194}.
  22501. @end deftypevr
  22502. @end deftypevr
  22503. @c %end of automatic openvpn-client documentation
  22504. @c %automatically generated documentation
  22505. Available @code{openvpn-server-configuration} fields are:
  22506. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  22507. The OpenVPN package.
  22508. @end deftypevr
  22509. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  22510. The OpenVPN pid file.
  22511. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  22512. @end deftypevr
  22513. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  22514. The protocol (UDP or TCP) used to open a channel between clients and
  22515. servers.
  22516. Defaults to @samp{udp}.
  22517. @end deftypevr
  22518. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  22519. The device type used to represent the VPN connection.
  22520. Defaults to @samp{tun}.
  22521. @end deftypevr
  22522. If you do not have some of these files (eg.@: you use a username and
  22523. password), you can disable any of the following three fields by setting
  22524. it to @code{'disabled}.
  22525. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  22526. The certificate authority to check connections against.
  22527. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  22528. @end deftypevr
  22529. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  22530. The certificate of the machine the daemon is running on. It should be
  22531. signed by the authority given in @code{ca}.
  22532. Defaults to @samp{"/etc/openvpn/client.crt"}.
  22533. @end deftypevr
  22534. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  22535. The key of the machine the daemon is running on. It must be the key whose
  22536. certificate is @code{cert}.
  22537. Defaults to @samp{"/etc/openvpn/client.key"}.
  22538. @end deftypevr
  22539. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  22540. Whether to use the lzo compression algorithm.
  22541. Defaults to @samp{#t}.
  22542. @end deftypevr
  22543. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  22544. Don't re-read key files across SIGUSR1 or --ping-restart.
  22545. Defaults to @samp{#t}.
  22546. @end deftypevr
  22547. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  22548. Don't close and reopen TUN/TAP device or run up/down scripts across
  22549. SIGUSR1 or --ping-restart restarts.
  22550. Defaults to @samp{#t}.
  22551. @end deftypevr
  22552. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  22553. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  22554. poll/epoll/select prior to the write operation.
  22555. Defaults to @samp{#f}.
  22556. @end deftypevr
  22557. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  22558. Verbosity level.
  22559. Defaults to @samp{3}.
  22560. @end deftypevr
  22561. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  22562. Add an additional layer of HMAC authentication on top of the TLS control
  22563. channel to protect against DoS attacks.
  22564. Defaults to @samp{#f}.
  22565. @end deftypevr
  22566. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  22567. Specifies the port number on which the server listens.
  22568. Defaults to @samp{1194}.
  22569. @end deftypevr
  22570. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  22571. An ip and mask specifying the subnet inside the virtual network.
  22572. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  22573. @end deftypevr
  22574. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  22575. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  22576. Defaults to @samp{#f}.
  22577. @end deftypevr
  22578. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  22579. The Diffie-Hellman parameters file.
  22580. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  22581. @end deftypevr
  22582. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  22583. The file that records client IPs.
  22584. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  22585. @end deftypevr
  22586. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  22587. When true, the server will act as a gateway for its clients.
  22588. Defaults to @samp{#f}.
  22589. @end deftypevr
  22590. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  22591. When true, clients are allowed to talk to each other inside the VPN.
  22592. Defaults to @samp{#f}.
  22593. @end deftypevr
  22594. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  22595. Causes ping-like messages to be sent back and forth over the link so
  22596. that each side knows when the other side has gone down. @code{keepalive}
  22597. requires a pair. The first element is the period of the ping sending,
  22598. and the second element is the timeout before considering the other side
  22599. down.
  22600. @end deftypevr
  22601. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  22602. The maximum number of clients.
  22603. Defaults to @samp{100}.
  22604. @end deftypevr
  22605. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  22606. The status file. This file shows a small report on current connection.
  22607. It is truncated and rewritten every minute.
  22608. Defaults to @samp{"/var/run/openvpn/status"}.
  22609. @end deftypevr
  22610. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  22611. The list of configuration for some clients.
  22612. Defaults to @samp{()}.
  22613. Available @code{openvpn-ccd-configuration} fields are:
  22614. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  22615. Client name.
  22616. Defaults to @samp{"client"}.
  22617. @end deftypevr
  22618. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  22619. Client own network
  22620. Defaults to @samp{#f}.
  22621. @end deftypevr
  22622. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  22623. Client VPN IP.
  22624. Defaults to @samp{#f}.
  22625. @end deftypevr
  22626. @end deftypevr
  22627. @c %end of automatic openvpn-server documentation
  22628. @subheading strongSwan
  22629. Currently, the strongSwan service only provides legacy-style configuration with
  22630. @file{ipsec.conf} and @file{ipsec.secrets} files.
  22631. @defvr {Scheme Variable} strongswan-service-type
  22632. A service type for configuring strongSwan for IPsec @acronym{VPN,
  22633. Virtual Private Networking}. Its value must be a
  22634. @code{strongswan-configuration} record as in this example:
  22635. @lisp
  22636. (service strongswan-service-type
  22637. (strongswan-configuration
  22638. (ipsec-conf "/etc/ipsec.conf")
  22639. (ipsec-secrets "/etc/ipsec.secrets")))
  22640. @end lisp
  22641. @end defvr
  22642. @deftp {Data Type} strongswan-configuration
  22643. Data type representing the configuration of the StrongSwan service.
  22644. @table @asis
  22645. @item @code{strongswan}
  22646. The strongSwan package to use for this service.
  22647. @item @code{ipsec-conf} (default: @code{#f})
  22648. The file name of your @file{ipsec.conf}. If not @code{#f}, then this and
  22649. @code{ipsec-secrets} must both be strings.
  22650. @item @code{ipsec-secrets} (default @code{#f})
  22651. The file name of your @file{ipsec.secrets}. If not @code{#f}, then this and
  22652. @code{ipsec-conf} must both be strings.
  22653. @end table
  22654. @end deftp
  22655. @subsubheading Wireguard
  22656. @defvr {Scheme Variable} wireguard-service-type
  22657. A service type for a Wireguard tunnel interface. Its value must be a
  22658. @code{wireguard-configuration} record as in this example:
  22659. @lisp
  22660. (service wireguard-service-type
  22661. (wireguard-configuration
  22662. (peers
  22663. (list
  22664. (wireguard-peer
  22665. (name "my-peer")
  22666. (endpoint "my.wireguard.com:51820")
  22667. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  22668. (allowed-ips '("10.0.0.2/32")))))))
  22669. @end lisp
  22670. @end defvr
  22671. @deftp {Data Type} wireguard-configuration
  22672. Data type representing the configuration of the Wireguard service.
  22673. @table @asis
  22674. @item @code{wireguard}
  22675. The wireguard package to use for this service.
  22676. @item @code{interface} (default: @code{"wg0"})
  22677. The interface name for the VPN.
  22678. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  22679. The IP addresses to be assigned to the above interface.
  22680. @item @code{port} (default: @code{51820})
  22681. The port on which to listen for incoming connections.
  22682. @item @code{dns} (default: @code{#f})
  22683. The DNS server(s) to announce to VPN clients via DHCP.
  22684. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  22685. The private key file for the interface. It is automatically generated if
  22686. the file does not exist.
  22687. @item @code{peers} (default: @code{'()})
  22688. The authorized peers on this interface. This is a list of
  22689. @var{wireguard-peer} records.
  22690. @end table
  22691. @end deftp
  22692. @deftp {Data Type} wireguard-peer
  22693. Data type representing a Wireguard peer attached to a given interface.
  22694. @table @asis
  22695. @item @code{name}
  22696. The peer name.
  22697. @item @code{endpoint} (default: @code{#f})
  22698. The optional endpoint for the peer, such as
  22699. @code{"demo.wireguard.com:51820"}.
  22700. @item @code{public-key}
  22701. The peer public-key represented as a base64 string.
  22702. @item @code{allowed-ips}
  22703. A list of IP addresses from which incoming traffic for this peer is
  22704. allowed and to which incoming traffic for this peer is directed.
  22705. @item @code{keep-alive} (default: @code{#f})
  22706. An optional time interval in seconds. A packet will be sent to the
  22707. server endpoint once per time interval. This helps receiving
  22708. incoming connections from this peer when you are behind a NAT or
  22709. a firewall.
  22710. @end table
  22711. @end deftp
  22712. @node Network File System
  22713. @subsection Network File System
  22714. @cindex NFS
  22715. The @code{(gnu services nfs)} module provides the following services,
  22716. which are most commonly used in relation to mounting or exporting
  22717. directory trees as @dfn{network file systems} (NFS).
  22718. While it is possible to use the individual components that together make
  22719. up a Network File System service, we recommended to configure an NFS
  22720. server with the @code{nfs-service-type}.
  22721. @subsubheading NFS Service
  22722. @cindex NFS, server
  22723. The NFS service takes care of setting up all NFS component services,
  22724. kernel configuration file systems, and installs configuration files in
  22725. the locations that NFS expects.
  22726. @defvr {Scheme Variable} nfs-service-type
  22727. A service type for a complete NFS server.
  22728. @end defvr
  22729. @deftp {Data Type} nfs-configuration
  22730. This data type represents the configuration of the NFS service and all
  22731. of its subsystems.
  22732. It has the following parameters:
  22733. @table @asis
  22734. @item @code{nfs-utils} (default: @code{nfs-utils})
  22735. The nfs-utils package to use.
  22736. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  22737. If a list of string values is provided, the @command{rpc.nfsd} daemon
  22738. will be limited to supporting the given versions of the NFS protocol.
  22739. @item @code{exports} (default: @code{'()})
  22740. This is a list of directories the NFS server should export. Each entry
  22741. is a list consisting of two elements: a directory name and a string
  22742. containing all options. This is an example in which the directory
  22743. @file{/export} is served to all NFS clients as a read-only share:
  22744. @lisp
  22745. (nfs-configuration
  22746. (exports
  22747. '(("/export"
  22748. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  22749. @end lisp
  22750. @item @code{rpcmountd-port} (default: @code{#f})
  22751. The network port that the @command{rpc.mountd} daemon should use.
  22752. @item @code{rpcstatd-port} (default: @code{#f})
  22753. The network port that the @command{rpc.statd} daemon should use.
  22754. @item @code{rpcbind} (default: @code{rpcbind})
  22755. The rpcbind package to use.
  22756. @item @code{idmap-domain} (default: @code{"localdomain"})
  22757. The local NFSv4 domain name.
  22758. @item @code{nfsd-port} (default: @code{2049})
  22759. The network port that the @command{nfsd} daemon should use.
  22760. @item @code{nfsd-threads} (default: @code{8})
  22761. The number of threads used by the @command{nfsd} daemon.
  22762. @item @code{nfsd-tcp?} (default: @code{#t})
  22763. Whether the @command{nfsd} daemon should listen on a TCP socket.
  22764. @item @code{nfsd-udp?} (default: @code{#f})
  22765. Whether the @command{nfsd} daemon should listen on a UDP socket.
  22766. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22767. The directory where the pipefs file system is mounted.
  22768. @item @code{debug} (default: @code{'()"})
  22769. A list of subsystems for which debugging output should be enabled. This
  22770. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  22771. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  22772. @end table
  22773. @end deftp
  22774. If you don't need a complete NFS service or prefer to build it yourself
  22775. you can use the individual component services that are documented below.
  22776. @subsubheading RPC Bind Service
  22777. @cindex rpcbind
  22778. The RPC Bind service provides a facility to map program numbers into
  22779. universal addresses.
  22780. Many NFS related services use this facility. Hence it is automatically
  22781. started when a dependent service starts.
  22782. @defvr {Scheme Variable} rpcbind-service-type
  22783. A service type for the RPC portmapper daemon.
  22784. @end defvr
  22785. @deftp {Data Type} rpcbind-configuration
  22786. Data type representing the configuration of the RPC Bind Service.
  22787. This type has the following parameters:
  22788. @table @asis
  22789. @item @code{rpcbind} (default: @code{rpcbind})
  22790. The rpcbind package to use.
  22791. @item @code{warm-start?} (default: @code{#t})
  22792. If this parameter is @code{#t}, then the daemon will read a
  22793. state file on startup thus reloading state information saved by a previous
  22794. instance.
  22795. @end table
  22796. @end deftp
  22797. @subsubheading Pipefs Pseudo File System
  22798. @cindex pipefs
  22799. @cindex rpc_pipefs
  22800. The pipefs file system is used to transfer NFS related data
  22801. between the kernel and user space programs.
  22802. @defvr {Scheme Variable} pipefs-service-type
  22803. A service type for the pipefs pseudo file system.
  22804. @end defvr
  22805. @deftp {Data Type} pipefs-configuration
  22806. Data type representing the configuration of the pipefs pseudo file system service.
  22807. This type has the following parameters:
  22808. @table @asis
  22809. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22810. The directory to which the file system is to be attached.
  22811. @end table
  22812. @end deftp
  22813. @subsubheading GSS Daemon Service
  22814. @cindex GSSD
  22815. @cindex GSS
  22816. @cindex global security system
  22817. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  22818. based protocols.
  22819. Before exchanging RPC requests an RPC client must establish a security
  22820. context. Typically this is done using the Kerberos command @command{kinit}
  22821. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  22822. @defvr {Scheme Variable} gss-service-type
  22823. A service type for the Global Security System (GSS) daemon.
  22824. @end defvr
  22825. @deftp {Data Type} gss-configuration
  22826. Data type representing the configuration of the GSS daemon service.
  22827. This type has the following parameters:
  22828. @table @asis
  22829. @item @code{nfs-utils} (default: @code{nfs-utils})
  22830. The package in which the @command{rpc.gssd} command is to be found.
  22831. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22832. The directory where the pipefs file system is mounted.
  22833. @end table
  22834. @end deftp
  22835. @subsubheading IDMAP Daemon Service
  22836. @cindex idmapd
  22837. @cindex name mapper
  22838. The idmap daemon service provides mapping between user IDs and user names.
  22839. Typically it is required in order to access file systems mounted via NFSv4.
  22840. @defvr {Scheme Variable} idmap-service-type
  22841. A service type for the Identity Mapper (IDMAP) daemon.
  22842. @end defvr
  22843. @deftp {Data Type} idmap-configuration
  22844. Data type representing the configuration of the IDMAP daemon service.
  22845. This type has the following parameters:
  22846. @table @asis
  22847. @item @code{nfs-utils} (default: @code{nfs-utils})
  22848. The package in which the @command{rpc.idmapd} command is to be found.
  22849. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22850. The directory where the pipefs file system is mounted.
  22851. @item @code{domain} (default: @code{#f})
  22852. The local NFSv4 domain name.
  22853. This must be a string or @code{#f}.
  22854. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  22855. @item @code{verbosity} (default: @code{0})
  22856. The verbosity level of the daemon.
  22857. @end table
  22858. @end deftp
  22859. @node Continuous Integration
  22860. @subsection Continuous Integration
  22861. @cindex continuous integration
  22862. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  22863. integration tool for Guix. It can be used both for development and for
  22864. providing substitutes to others (@pxref{Substitutes}).
  22865. The @code{(gnu services cuirass)} module provides the following service.
  22866. @defvr {Scheme Procedure} cuirass-service-type
  22867. The type of the Cuirass service. Its value must be a
  22868. @code{cuirass-configuration} object, as described below.
  22869. @end defvr
  22870. To add build jobs, you have to set the @code{specifications} field of
  22871. the configuration. For instance, the following example will build all
  22872. the packages provided by the @code{my-channel} channel.
  22873. @lisp
  22874. (define %cuirass-specs
  22875. #~(list (specification
  22876. (name "my-channel")
  22877. (build '(channels my-channel))
  22878. (channels
  22879. (cons (channel
  22880. (name 'my-channel)
  22881. (url "https://my-channel.git"))
  22882. %default-channels)))))
  22883. (service cuirass-service-type
  22884. (cuirass-configuration
  22885. (specifications %cuirass-specs)))
  22886. @end lisp
  22887. To build the @code{linux-libre} package defined by the default Guix
  22888. channel, one can use the following configuration.
  22889. @lisp
  22890. (define %cuirass-specs
  22891. #~(list (specification
  22892. (name "my-linux")
  22893. (build '(packages "linux-libre")))))
  22894. (service cuirass-service-type
  22895. (cuirass-configuration
  22896. (specifications %cuirass-specs)))
  22897. @end lisp
  22898. The other configuration possibilities, as well as the specification
  22899. record itself are described in the Cuirass manual
  22900. (@pxref{Specifications,,, cuirass, Cuirass}).
  22901. While information related to build jobs is located directly in the
  22902. specifications, global settings for the @command{cuirass} process are
  22903. accessible in other @code{cuirass-configuration} fields.
  22904. @deftp {Data Type} cuirass-configuration
  22905. Data type representing the configuration of Cuirass.
  22906. @table @asis
  22907. @item @code{cuirass} (default: @code{cuirass})
  22908. The Cuirass package to use.
  22909. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  22910. Location of the log file.
  22911. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  22912. Location of the log file used by the web interface.
  22913. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  22914. Location of the repository cache.
  22915. @item @code{user} (default: @code{"cuirass"})
  22916. Owner of the @code{cuirass} process.
  22917. @item @code{group} (default: @code{"cuirass"})
  22918. Owner's group of the @code{cuirass} process.
  22919. @item @code{interval} (default: @code{60})
  22920. Number of seconds between the poll of the repositories followed by the
  22921. Cuirass jobs.
  22922. @item @code{parameters} (default: @code{#f})
  22923. Read parameters from the given @var{parameters} file. The supported
  22924. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  22925. @item @code{remote-server} (default: @code{#f})
  22926. A @code{cuirass-remote-server-configuration} record to use the build
  22927. remote mechanism or @code{#f} to use the default build mechanism.
  22928. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  22929. Use @var{database} as the database containing the jobs and the past
  22930. build results. Since Cuirass uses PostgreSQL as a database engine,
  22931. @var{database} must be a string such as @code{"dbname=cuirass
  22932. host=localhost"}.
  22933. @item @code{port} (default: @code{8081})
  22934. Port number used by the HTTP server.
  22935. @item @code{host} (default: @code{"localhost"})
  22936. Listen on the network interface for @var{host}. The default is to
  22937. accept connections from localhost.
  22938. @item @code{specifications} (default: @code{#~'()})
  22939. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  22940. specifications records. The specification record is described in the
  22941. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  22942. @item @code{use-substitutes?} (default: @code{#f})
  22943. This allows using substitutes to avoid building every dependencies of a job
  22944. from source.
  22945. @item @code{one-shot?} (default: @code{#f})
  22946. Only evaluate specifications and build derivations once.
  22947. @item @code{fallback?} (default: @code{#f})
  22948. When substituting a pre-built binary fails, fall back to building
  22949. packages locally.
  22950. @item @code{extra-options} (default: @code{'()})
  22951. Extra options to pass when running the Cuirass processes.
  22952. @end table
  22953. @end deftp
  22954. @cindex remote build
  22955. @subsubheading Cuirass remote building
  22956. Cuirass supports two mechanisms to build derivations.
  22957. @itemize
  22958. @item Using the local Guix daemon.
  22959. This is the default build mechanism. Once the build jobs are
  22960. evaluated, they are sent to the local Guix daemon. Cuirass then
  22961. listens to the Guix daemon output to detect the various build events.
  22962. @item Using the remote build mechanism.
  22963. The build jobs are not submitted to the local Guix daemon. Instead, a
  22964. remote server dispatches build requests to the connect remote workers,
  22965. according to the build priorities.
  22966. @end itemize
  22967. To enable this build mode a @code{cuirass-remote-server-configuration}
  22968. record must be passed as @code{remote-server} argument of the
  22969. @code{cuirass-configuration} record. The
  22970. @code{cuirass-remote-server-configuration} record is described below.
  22971. This build mode scales way better than the default build mode. This is
  22972. the build mode that is used on the GNU Guix build farm at
  22973. @url{https://ci.guix.gnu.org}. It should be preferred when using
  22974. Cuirass to build large amount of packages.
  22975. @deftp {Data Type} cuirass-remote-server-configuration
  22976. Data type representing the configuration of the Cuirass remote-server.
  22977. @table @asis
  22978. @item @code{backend-port} (default: @code{5555})
  22979. The TCP port for communicating with @code{remote-worker} processes
  22980. using ZMQ. It defaults to @code{5555}.
  22981. @item @code{log-port} (default: @code{5556})
  22982. The TCP port of the log server. It defaults to @code{5556}.
  22983. @item @code{publish-port} (default: @code{5557})
  22984. The TCP port of the publish server. It defaults to @code{5557}.
  22985. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  22986. Location of the log file.
  22987. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  22988. Use @var{cache} directory to cache build log files.
  22989. @item @code{trigger-url} (default: @code{#f})
  22990. Once a substitute is successfully fetched, trigger substitute baking at
  22991. @var{trigger-url}.
  22992. @item @code{publish?} (default: @code{#t})
  22993. If set to false, do not start a publish server and ignore the
  22994. @code{publish-port} argument. This can be useful if there is already a
  22995. standalone publish server standing next to the remote server.
  22996. @item @code{public-key}
  22997. @item @code{private-key}
  22998. Use the specific @var{file}s as the public/private key pair used to sign
  22999. the store items being published.
  23000. @end table
  23001. @end deftp
  23002. At least one remote worker must also be started on any machine of the
  23003. local network to actually perform the builds and report their status.
  23004. @deftp {Data Type} cuirass-remote-worker-configuration
  23005. Data type representing the configuration of the Cuirass remote-worker.
  23006. @table @asis
  23007. @item @code{cuirass} (default: @code{cuirass})
  23008. The Cuirass package to use.
  23009. @item @code{workers} (default: @code{1})
  23010. Start @var{workers} parallel workers.
  23011. @item @code{server} (default: @code{#f})
  23012. Do not use Avahi discovery and connect to the given @code{server} IP
  23013. address instead.
  23014. @item @code{systems} (default: @code{(list (%current-system))})
  23015. Only request builds for the given @var{systems}.
  23016. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  23017. Location of the log file.
  23018. @item @code{publish-port} (default: @code{5558})
  23019. The TCP port of the publish server. It defaults to @code{5558}.
  23020. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  23021. The list of URLs where to look for substitutes by default.
  23022. @item @code{public-key}
  23023. @item @code{private-key}
  23024. Use the specific @var{file}s as the public/private key pair used to sign
  23025. the store items being published.
  23026. @end table
  23027. @end deftp
  23028. @subsubheading Laminar
  23029. @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
  23030. Continuous Integration service. It doesn't have a configuration web UI
  23031. instead uses version-controllable configuration files and scripts.
  23032. Laminar encourages the use of existing tools such as bash and cron
  23033. instead of reinventing them.
  23034. @defvr {Scheme Procedure} laminar-service-type
  23035. The type of the Laminar service. Its value must be a
  23036. @code{laminar-configuration} object, as described below.
  23037. All configuration values have defaults, a minimal configuration to get
  23038. Laminar running is shown below. By default, the web interface is
  23039. available on port 8080.
  23040. @lisp
  23041. (service laminar-service-type)
  23042. @end lisp
  23043. @end defvr
  23044. @deftp {Data Type} laminar-configuration
  23045. Data type representing the configuration of Laminar.
  23046. @table @asis
  23047. @item @code{laminar} (default: @code{laminar})
  23048. The Laminar package to use.
  23049. @item @code{home-directory} (default: @code{"/var/lib/laminar"})
  23050. The directory for job configurations and run directories.
  23051. @item @code{bind-http} (default: @code{"*:8080"})
  23052. The interface/port or unix socket on which laminard should listen for
  23053. incoming connections to the web frontend.
  23054. @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
  23055. The interface/port or unix socket on which laminard should listen for
  23056. incoming commands such as build triggers.
  23057. @item @code{title} (default: @code{"Laminar"})
  23058. The page title to show in the web frontend.
  23059. @item @code{keep-rundirs} (default: @code{0})
  23060. Set to an integer defining how many rundirs to keep per job. The
  23061. lowest-numbered ones will be deleted. The default is 0, meaning all run
  23062. dirs will be immediately deleted.
  23063. @item @code{archive-url} (default: @code{#f})
  23064. The web frontend served by laminard will use this URL to form links to
  23065. artefacts archived jobs.
  23066. @item @code{base-url} (default: @code{#f})
  23067. Base URL to use for links to laminar itself.
  23068. @end table
  23069. @end deftp
  23070. @node Power Management Services
  23071. @subsection Power Management Services
  23072. @cindex tlp
  23073. @cindex power management with TLP
  23074. @subsubheading TLP daemon
  23075. The @code{(gnu services pm)} module provides a Guix service definition
  23076. for the Linux power management tool TLP.
  23077. TLP enables various powersaving modes in userspace and kernel.
  23078. Contrary to @code{upower-service}, it is not a passive,
  23079. monitoring tool, as it will apply custom settings each time a new power
  23080. source is detected. More information can be found at
  23081. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  23082. @deffn {Scheme Variable} tlp-service-type
  23083. The service type for the TLP tool. The default settings are optimised
  23084. for battery life on most systems, but you can tweak them to your heart's
  23085. content by adding a valid @code{tlp-configuration}:
  23086. @lisp
  23087. (service tlp-service-type
  23088. (tlp-configuration
  23089. (cpu-scaling-governor-on-ac (list "performance"))
  23090. (sched-powersave-on-bat? #t)))
  23091. @end lisp
  23092. @end deffn
  23093. Each parameter definition is preceded by its type; for example,
  23094. @samp{boolean foo} indicates that the @code{foo} parameter
  23095. should be specified as a boolean. Types starting with
  23096. @code{maybe-} denote parameters that won't show up in TLP config file
  23097. when their value is @code{'disabled}.
  23098. @c The following documentation was initially generated by
  23099. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  23100. @c documentation is better, so we shouldn't hesitate to edit below as
  23101. @c needed. However if the change you want to make to this documentation
  23102. @c can be done in an automated way, it's probably easier to change
  23103. @c (generate-documentation) than to make it below and have to deal with
  23104. @c the churn as TLP updates.
  23105. Available @code{tlp-configuration} fields are:
  23106. @deftypevr {@code{tlp-configuration} parameter} package tlp
  23107. The TLP package.
  23108. @end deftypevr
  23109. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  23110. Set to true if you wish to enable TLP.
  23111. Defaults to @samp{#t}.
  23112. @end deftypevr
  23113. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  23114. Default mode when no power supply can be detected. Alternatives are AC
  23115. and BAT.
  23116. Defaults to @samp{"AC"}.
  23117. @end deftypevr
  23118. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  23119. Number of seconds Linux kernel has to wait after the disk goes idle,
  23120. before syncing on AC.
  23121. Defaults to @samp{0}.
  23122. @end deftypevr
  23123. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  23124. Same as @code{disk-idle-ac} but on BAT mode.
  23125. Defaults to @samp{2}.
  23126. @end deftypevr
  23127. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  23128. Dirty pages flushing periodicity, expressed in seconds.
  23129. Defaults to @samp{15}.
  23130. @end deftypevr
  23131. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  23132. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  23133. Defaults to @samp{60}.
  23134. @end deftypevr
  23135. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  23136. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  23137. alternatives are powersave and performance. With acpi-cpufreq driver,
  23138. alternatives are ondemand, powersave, performance and conservative.
  23139. Defaults to @samp{disabled}.
  23140. @end deftypevr
  23141. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  23142. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  23143. Defaults to @samp{disabled}.
  23144. @end deftypevr
  23145. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  23146. Set the min available frequency for the scaling governor on AC.
  23147. Defaults to @samp{disabled}.
  23148. @end deftypevr
  23149. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  23150. Set the max available frequency for the scaling governor on AC.
  23151. Defaults to @samp{disabled}.
  23152. @end deftypevr
  23153. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  23154. Set the min available frequency for the scaling governor on BAT.
  23155. Defaults to @samp{disabled}.
  23156. @end deftypevr
  23157. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  23158. Set the max available frequency for the scaling governor on BAT.
  23159. Defaults to @samp{disabled}.
  23160. @end deftypevr
  23161. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  23162. Limit the min P-state to control the power dissipation of the CPU, in AC
  23163. mode. Values are stated as a percentage of the available performance.
  23164. Defaults to @samp{disabled}.
  23165. @end deftypevr
  23166. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  23167. Limit the max P-state to control the power dissipation of the CPU, in AC
  23168. mode. Values are stated as a percentage of the available performance.
  23169. Defaults to @samp{disabled}.
  23170. @end deftypevr
  23171. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  23172. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  23173. Defaults to @samp{disabled}.
  23174. @end deftypevr
  23175. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  23176. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  23177. Defaults to @samp{disabled}.
  23178. @end deftypevr
  23179. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  23180. Enable CPU turbo boost feature on AC mode.
  23181. Defaults to @samp{disabled}.
  23182. @end deftypevr
  23183. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  23184. Same as @code{cpu-boost-on-ac?} on BAT mode.
  23185. Defaults to @samp{disabled}.
  23186. @end deftypevr
  23187. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  23188. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  23189. used under light load conditions.
  23190. Defaults to @samp{#f}.
  23191. @end deftypevr
  23192. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  23193. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  23194. Defaults to @samp{#t}.
  23195. @end deftypevr
  23196. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  23197. Enable Linux kernel NMI watchdog.
  23198. Defaults to @samp{#f}.
  23199. @end deftypevr
  23200. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  23201. For Linux kernels with PHC patch applied, change CPU voltages. An
  23202. example value would be @samp{"F:V F:V F:V F:V"}.
  23203. Defaults to @samp{disabled}.
  23204. @end deftypevr
  23205. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  23206. Set CPU performance versus energy saving policy on AC@. Alternatives are
  23207. performance, normal, powersave.
  23208. Defaults to @samp{"performance"}.
  23209. @end deftypevr
  23210. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  23211. Same as @code{energy-perf-policy-ac} but on BAT mode.
  23212. Defaults to @samp{"powersave"}.
  23213. @end deftypevr
  23214. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  23215. Hard disk devices.
  23216. @end deftypevr
  23217. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  23218. Hard disk advanced power management level.
  23219. @end deftypevr
  23220. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  23221. Same as @code{disk-apm-bat} but on BAT mode.
  23222. @end deftypevr
  23223. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  23224. Hard disk spin down timeout. One value has to be specified for each
  23225. declared hard disk.
  23226. Defaults to @samp{disabled}.
  23227. @end deftypevr
  23228. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  23229. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  23230. Defaults to @samp{disabled}.
  23231. @end deftypevr
  23232. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  23233. Select IO scheduler for disk devices. One value has to be specified for
  23234. each declared hard disk. Example alternatives are cfq, deadline and
  23235. noop.
  23236. Defaults to @samp{disabled}.
  23237. @end deftypevr
  23238. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  23239. SATA aggressive link power management (ALPM) level. Alternatives are
  23240. min_power, medium_power, max_performance.
  23241. Defaults to @samp{"max_performance"}.
  23242. @end deftypevr
  23243. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  23244. Same as @code{sata-linkpwr-ac} but on BAT mode.
  23245. Defaults to @samp{"min_power"}.
  23246. @end deftypevr
  23247. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  23248. Exclude specified SATA host devices for link power management.
  23249. Defaults to @samp{disabled}.
  23250. @end deftypevr
  23251. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  23252. Enable Runtime Power Management for AHCI controller and disks on AC
  23253. mode.
  23254. Defaults to @samp{disabled}.
  23255. @end deftypevr
  23256. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  23257. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  23258. Defaults to @samp{disabled}.
  23259. @end deftypevr
  23260. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  23261. Seconds of inactivity before disk is suspended.
  23262. Defaults to @samp{15}.
  23263. @end deftypevr
  23264. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  23265. PCI Express Active State Power Management level. Alternatives are
  23266. default, performance, powersave.
  23267. Defaults to @samp{"performance"}.
  23268. @end deftypevr
  23269. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  23270. Same as @code{pcie-aspm-ac} but on BAT mode.
  23271. Defaults to @samp{"powersave"}.
  23272. @end deftypevr
  23273. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  23274. Radeon graphics clock speed level. Alternatives are low, mid, high,
  23275. auto, default.
  23276. Defaults to @samp{"high"}.
  23277. @end deftypevr
  23278. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  23279. Same as @code{radeon-power-ac} but on BAT mode.
  23280. Defaults to @samp{"low"}.
  23281. @end deftypevr
  23282. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  23283. Radeon dynamic power management method (DPM). Alternatives are battery,
  23284. performance.
  23285. Defaults to @samp{"performance"}.
  23286. @end deftypevr
  23287. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  23288. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  23289. Defaults to @samp{"battery"}.
  23290. @end deftypevr
  23291. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  23292. Radeon DPM performance level. Alternatives are auto, low, high.
  23293. Defaults to @samp{"auto"}.
  23294. @end deftypevr
  23295. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  23296. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  23297. Defaults to @samp{"auto"}.
  23298. @end deftypevr
  23299. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  23300. Wifi power saving mode.
  23301. Defaults to @samp{#f}.
  23302. @end deftypevr
  23303. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  23304. Same as @code{wifi-power-ac?} but on BAT mode.
  23305. Defaults to @samp{#t}.
  23306. @end deftypevr
  23307. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  23308. Disable wake on LAN.
  23309. Defaults to @samp{#t}.
  23310. @end deftypevr
  23311. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  23312. Timeout duration in seconds before activating audio power saving on
  23313. Intel HDA and AC97 devices. A value of 0 disables power saving.
  23314. Defaults to @samp{0}.
  23315. @end deftypevr
  23316. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  23317. Same as @code{sound-powersave-ac} but on BAT mode.
  23318. Defaults to @samp{1}.
  23319. @end deftypevr
  23320. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  23321. Disable controller in powersaving mode on Intel HDA devices.
  23322. Defaults to @samp{#t}.
  23323. @end deftypevr
  23324. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  23325. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  23326. powered on again by releasing (and reinserting) the eject lever or by
  23327. pressing the disc eject button on newer models.
  23328. Defaults to @samp{#f}.
  23329. @end deftypevr
  23330. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  23331. Name of the optical drive device to power off.
  23332. Defaults to @samp{"sr0"}.
  23333. @end deftypevr
  23334. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  23335. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  23336. and auto.
  23337. Defaults to @samp{"on"}.
  23338. @end deftypevr
  23339. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  23340. Same as @code{runtime-pm-ac} but on BAT mode.
  23341. Defaults to @samp{"auto"}.
  23342. @end deftypevr
  23343. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  23344. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  23345. ones.
  23346. Defaults to @samp{#t}.
  23347. @end deftypevr
  23348. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  23349. Exclude specified PCI(e) device addresses from Runtime Power Management.
  23350. Defaults to @samp{disabled}.
  23351. @end deftypevr
  23352. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  23353. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  23354. Power Management.
  23355. @end deftypevr
  23356. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  23357. Enable USB autosuspend feature.
  23358. Defaults to @samp{#t}.
  23359. @end deftypevr
  23360. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  23361. Exclude specified devices from USB autosuspend.
  23362. Defaults to @samp{disabled}.
  23363. @end deftypevr
  23364. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  23365. Exclude WWAN devices from USB autosuspend.
  23366. Defaults to @samp{#t}.
  23367. @end deftypevr
  23368. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  23369. Include specified devices into USB autosuspend, even if they are already
  23370. excluded by the driver or via @code{usb-blacklist-wwan?}.
  23371. Defaults to @samp{disabled}.
  23372. @end deftypevr
  23373. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  23374. Enable USB autosuspend before shutdown.
  23375. Defaults to @samp{disabled}.
  23376. @end deftypevr
  23377. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  23378. Restore radio device state (bluetooth, wifi, wwan) from previous
  23379. shutdown on system startup.
  23380. Defaults to @samp{#f}.
  23381. @end deftypevr
  23382. @cindex thermald
  23383. @cindex CPU frequency scaling with thermald
  23384. @subsubheading Thermald daemon
  23385. The @code{(gnu services pm)} module provides an interface to
  23386. thermald, a CPU frequency scaling service which helps prevent overheating.
  23387. @defvr {Scheme Variable} thermald-service-type
  23388. This is the service type for
  23389. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  23390. Thermal Daemon, which is responsible for controlling the thermal state
  23391. of processors and preventing overheating.
  23392. @end defvr
  23393. @deftp {Data Type} thermald-configuration
  23394. Data type representing the configuration of @code{thermald-service-type}.
  23395. @table @asis
  23396. @item @code{ignore-cpuid-check?} (default: @code{#f})
  23397. Ignore cpuid check for supported CPU models.
  23398. @item @code{thermald} (default: @var{thermald})
  23399. Package object of thermald.
  23400. @end table
  23401. @end deftp
  23402. @node Audio Services
  23403. @subsection Audio Services
  23404. The @code{(gnu services audio)} module provides a service to start MPD
  23405. (the Music Player Daemon).
  23406. @cindex mpd
  23407. @subsubheading Music Player Daemon
  23408. The Music Player Daemon (MPD) is a service that can play music while
  23409. being controlled from the local machine or over the network by a variety
  23410. of clients.
  23411. The following example shows how one might run @code{mpd} as user
  23412. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  23413. @lisp
  23414. (service mpd-service-type
  23415. (mpd-configuration
  23416. (user "bob")
  23417. (port "6666")))
  23418. @end lisp
  23419. @defvr {Scheme Variable} mpd-service-type
  23420. The service type for @command{mpd}
  23421. @end defvr
  23422. @deftp {Data Type} mpd-configuration
  23423. Data type representing the configuration of @command{mpd}.
  23424. @table @asis
  23425. @item @code{user} (default: @code{"mpd"})
  23426. The user to run mpd as.
  23427. @item @code{music-dir} (default: @code{"~/Music"})
  23428. The directory to scan for music files.
  23429. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  23430. The directory to store playlists.
  23431. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  23432. The location of the music database.
  23433. @item @code{state-file} (default: @code{"~/.mpd/state"})
  23434. The location of the file that stores current MPD's state.
  23435. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  23436. The location of the sticker database.
  23437. @item @code{port} (default: @code{"6600"})
  23438. The port to run mpd on.
  23439. @item @code{address} (default: @code{"any"})
  23440. The address that mpd will bind to. To use a Unix domain socket,
  23441. an absolute path can be specified here.
  23442. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  23443. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  23444. @end table
  23445. @end deftp
  23446. @deftp {Data Type} mpd-output
  23447. Data type representing an @command{mpd} audio output.
  23448. @table @asis
  23449. @item @code{name} (default: @code{"MPD"})
  23450. The name of the audio output.
  23451. @item @code{type} (default: @code{"pulse"})
  23452. The type of audio output.
  23453. @item @code{enabled?} (default: @code{#t})
  23454. Specifies whether this audio output is enabled when MPD is started. By
  23455. default, all audio outputs are enabled. This is just the default
  23456. setting when there is no state file; with a state file, the previous
  23457. state is restored.
  23458. @item @code{tags?} (default: @code{#t})
  23459. If set to @code{#f}, then MPD will not send tags to this output. This
  23460. is only useful for output plugins that can receive tags, for example the
  23461. @code{httpd} output plugin.
  23462. @item @code{always-on?} (default: @code{#f})
  23463. If set to @code{#t}, then MPD attempts to keep this audio output always
  23464. open. This may be useful for streaming servers, when you don’t want to
  23465. disconnect all listeners even when playback is accidentally stopped.
  23466. @item @code{mixer-type}
  23467. This field accepts a symbol that specifies which mixer should be used
  23468. for this audio output: the @code{hardware} mixer, the @code{software}
  23469. mixer, the @code{null} mixer (allows setting the volume, but with no
  23470. effect; this can be used as a trick to implement an external mixer
  23471. External Mixer) or no mixer (@code{none}).
  23472. @item @code{extra-options} (default: @code{'()})
  23473. An association list of option symbols to string values to be appended to
  23474. the audio output configuration.
  23475. @end table
  23476. @end deftp
  23477. The following example shows a configuration of @code{mpd} that provides
  23478. an HTTP audio streaming output.
  23479. @lisp
  23480. (service mpd-service-type
  23481. (mpd-configuration
  23482. (outputs
  23483. (list (mpd-output
  23484. (name "streaming")
  23485. (type "httpd")
  23486. (mixer-type 'null)
  23487. (extra-options
  23488. `((encoder . "vorbis")
  23489. (port . "8080"))))))))
  23490. @end lisp
  23491. @node Virtualization Services
  23492. @subsection Virtualization Services
  23493. The @code{(gnu services virtualization)} module provides services for
  23494. the libvirt and virtlog daemons, as well as other virtualization-related
  23495. services.
  23496. @subsubheading Libvirt daemon
  23497. @code{libvirtd} is the server side daemon component of the libvirt
  23498. virtualization management system. This daemon runs on host servers
  23499. and performs required management tasks for virtualized guests.
  23500. @deffn {Scheme Variable} libvirt-service-type
  23501. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  23502. Its value must be a @code{libvirt-configuration}.
  23503. @lisp
  23504. (service libvirt-service-type
  23505. (libvirt-configuration
  23506. (unix-sock-group "libvirt")
  23507. (tls-port "16555")))
  23508. @end lisp
  23509. @end deffn
  23510. @c Auto-generated with (generate-libvirt-documentation)
  23511. Available @code{libvirt-configuration} fields are:
  23512. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  23513. Libvirt package.
  23514. @end deftypevr
  23515. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  23516. Flag listening for secure TLS connections on the public TCP/IP port.
  23517. You must set @code{listen} for this to have any effect.
  23518. It is necessary to setup a CA and issue server certificates before using
  23519. this capability.
  23520. Defaults to @samp{#t}.
  23521. @end deftypevr
  23522. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  23523. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  23524. set @code{listen} for this to have any effect.
  23525. Using the TCP socket requires SASL authentication by default. Only SASL
  23526. mechanisms which support data encryption are allowed. This is
  23527. DIGEST_MD5 and GSSAPI (Kerberos5).
  23528. Defaults to @samp{#f}.
  23529. @end deftypevr
  23530. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  23531. Port for accepting secure TLS connections. This can be a port number,
  23532. or service name.
  23533. Defaults to @samp{"16514"}.
  23534. @end deftypevr
  23535. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  23536. Port for accepting insecure TCP connections. This can be a port number,
  23537. or service name.
  23538. Defaults to @samp{"16509"}.
  23539. @end deftypevr
  23540. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  23541. IP address or hostname used for client connections.
  23542. Defaults to @samp{"0.0.0.0"}.
  23543. @end deftypevr
  23544. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  23545. Flag toggling mDNS advertisement of the libvirt service.
  23546. Alternatively can disable for all services on a host by stopping the
  23547. Avahi daemon.
  23548. Defaults to @samp{#f}.
  23549. @end deftypevr
  23550. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  23551. Default mDNS advertisement name. This must be unique on the immediate
  23552. broadcast network.
  23553. Defaults to @samp{"Virtualization Host <hostname>"}.
  23554. @end deftypevr
  23555. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  23556. UNIX domain socket group ownership. This can be used to allow a
  23557. 'trusted' set of users access to management capabilities without
  23558. becoming root.
  23559. Defaults to @samp{"root"}.
  23560. @end deftypevr
  23561. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  23562. UNIX socket permissions for the R/O socket. This is used for monitoring
  23563. VM status only.
  23564. Defaults to @samp{"0777"}.
  23565. @end deftypevr
  23566. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  23567. UNIX socket permissions for the R/W socket. Default allows only root.
  23568. If PolicyKit is enabled on the socket, the default will change to allow
  23569. everyone (eg, 0777)
  23570. Defaults to @samp{"0770"}.
  23571. @end deftypevr
  23572. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  23573. UNIX socket permissions for the admin socket. Default allows only owner
  23574. (root), do not change it unless you are sure to whom you are exposing
  23575. the access to.
  23576. Defaults to @samp{"0777"}.
  23577. @end deftypevr
  23578. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  23579. The directory in which sockets will be found/created.
  23580. Defaults to @samp{"/var/run/libvirt"}.
  23581. @end deftypevr
  23582. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  23583. Authentication scheme for UNIX read-only sockets. By default socket
  23584. permissions allow anyone to connect
  23585. Defaults to @samp{"polkit"}.
  23586. @end deftypevr
  23587. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  23588. Authentication scheme for UNIX read-write sockets. By default socket
  23589. permissions only allow root. If PolicyKit support was compiled into
  23590. libvirt, the default will be to use 'polkit' auth.
  23591. Defaults to @samp{"polkit"}.
  23592. @end deftypevr
  23593. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  23594. Authentication scheme for TCP sockets. If you don't enable SASL, then
  23595. all TCP traffic is cleartext. Don't do this outside of a dev/test
  23596. scenario.
  23597. Defaults to @samp{"sasl"}.
  23598. @end deftypevr
  23599. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  23600. Authentication scheme for TLS sockets. TLS sockets already have
  23601. encryption provided by the TLS layer, and limited authentication is done
  23602. by certificates.
  23603. It is possible to make use of any SASL authentication mechanism as well,
  23604. by using 'sasl' for this option
  23605. Defaults to @samp{"none"}.
  23606. @end deftypevr
  23607. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  23608. API access control scheme.
  23609. By default an authenticated user is allowed access to all APIs. Access
  23610. drivers can place restrictions on this.
  23611. Defaults to @samp{()}.
  23612. @end deftypevr
  23613. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  23614. Server key file path. If set to an empty string, then no private key is
  23615. loaded.
  23616. Defaults to @samp{""}.
  23617. @end deftypevr
  23618. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  23619. Server key file path. If set to an empty string, then no certificate is
  23620. loaded.
  23621. Defaults to @samp{""}.
  23622. @end deftypevr
  23623. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  23624. Server key file path. If set to an empty string, then no CA certificate
  23625. is loaded.
  23626. Defaults to @samp{""}.
  23627. @end deftypevr
  23628. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  23629. Certificate revocation list path. If set to an empty string, then no
  23630. CRL is loaded.
  23631. Defaults to @samp{""}.
  23632. @end deftypevr
  23633. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  23634. Disable verification of our own server certificates.
  23635. When libvirtd starts it performs some sanity checks against its own
  23636. certificates.
  23637. Defaults to @samp{#f}.
  23638. @end deftypevr
  23639. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  23640. Disable verification of client certificates.
  23641. Client certificate verification is the primary authentication mechanism.
  23642. Any client which does not present a certificate signed by the CA will be
  23643. rejected.
  23644. Defaults to @samp{#f}.
  23645. @end deftypevr
  23646. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  23647. Whitelist of allowed x509 Distinguished Name.
  23648. Defaults to @samp{()}.
  23649. @end deftypevr
  23650. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  23651. Whitelist of allowed SASL usernames. The format for username depends on
  23652. the SASL authentication mechanism.
  23653. Defaults to @samp{()}.
  23654. @end deftypevr
  23655. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  23656. Override the compile time default TLS priority string. The default is
  23657. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  23658. is desired for libvirt to deviate from the global default settings.
  23659. Defaults to @samp{"NORMAL"}.
  23660. @end deftypevr
  23661. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  23662. Maximum number of concurrent client connections to allow over all
  23663. sockets combined.
  23664. Defaults to @samp{5000}.
  23665. @end deftypevr
  23666. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  23667. Maximum length of queue of connections waiting to be accepted by the
  23668. daemon. Note, that some protocols supporting retransmission may obey
  23669. this so that a later reattempt at connection succeeds.
  23670. Defaults to @samp{1000}.
  23671. @end deftypevr
  23672. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  23673. Maximum length of queue of accepted but not yet authenticated clients.
  23674. Set this to zero to turn this feature off
  23675. Defaults to @samp{20}.
  23676. @end deftypevr
  23677. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  23678. Number of workers to start up initially.
  23679. Defaults to @samp{5}.
  23680. @end deftypevr
  23681. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  23682. Maximum number of worker threads.
  23683. If the number of active clients exceeds @code{min-workers}, then more
  23684. threads are spawned, up to max_workers limit. Typically you'd want
  23685. max_workers to equal maximum number of clients allowed.
  23686. Defaults to @samp{20}.
  23687. @end deftypevr
  23688. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  23689. Number of priority workers. If all workers from above pool are stuck,
  23690. some calls marked as high priority (notably domainDestroy) can be
  23691. executed in this pool.
  23692. Defaults to @samp{5}.
  23693. @end deftypevr
  23694. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  23695. Total global limit on concurrent RPC calls.
  23696. Defaults to @samp{20}.
  23697. @end deftypevr
  23698. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  23699. Limit on concurrent requests from a single client connection. To avoid
  23700. one client monopolizing the server this should be a small fraction of
  23701. the global max_requests and max_workers parameter.
  23702. Defaults to @samp{5}.
  23703. @end deftypevr
  23704. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  23705. Same as @code{min-workers} but for the admin interface.
  23706. Defaults to @samp{1}.
  23707. @end deftypevr
  23708. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  23709. Same as @code{max-workers} but for the admin interface.
  23710. Defaults to @samp{5}.
  23711. @end deftypevr
  23712. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  23713. Same as @code{max-clients} but for the admin interface.
  23714. Defaults to @samp{5}.
  23715. @end deftypevr
  23716. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  23717. Same as @code{max-queued-clients} but for the admin interface.
  23718. Defaults to @samp{5}.
  23719. @end deftypevr
  23720. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  23721. Same as @code{max-client-requests} but for the admin interface.
  23722. Defaults to @samp{5}.
  23723. @end deftypevr
  23724. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  23725. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  23726. Defaults to @samp{3}.
  23727. @end deftypevr
  23728. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  23729. Logging filters.
  23730. A filter allows to select a different logging level for a given category
  23731. of logs. The format for a filter is one of:
  23732. @itemize @bullet
  23733. @item
  23734. x:name
  23735. @item
  23736. x:+name
  23737. @end itemize
  23738. where @code{name} is a string which is matched against the category
  23739. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  23740. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  23741. name in the filter can be a substring of the full category name, in
  23742. order to match multiple similar categories), the optional @samp{"+"}
  23743. prefix tells libvirt to log stack trace for each message matching name,
  23744. and @code{x} is the minimal level where matching messages should be
  23745. logged:
  23746. @itemize @bullet
  23747. @item
  23748. 1: DEBUG
  23749. @item
  23750. 2: INFO
  23751. @item
  23752. 3: WARNING
  23753. @item
  23754. 4: ERROR
  23755. @end itemize
  23756. Multiple filters can be defined in a single filters statement, they just
  23757. need to be separated by spaces.
  23758. Defaults to @samp{"3:remote 4:event"}.
  23759. @end deftypevr
  23760. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  23761. Logging outputs.
  23762. An output is one of the places to save logging information. The format
  23763. for an output can be:
  23764. @table @code
  23765. @item x:stderr
  23766. output goes to stderr
  23767. @item x:syslog:name
  23768. use syslog for the output and use the given name as the ident
  23769. @item x:file:file_path
  23770. output to a file, with the given filepath
  23771. @item x:journald
  23772. output to journald logging system
  23773. @end table
  23774. In all case the x prefix is the minimal level, acting as a filter
  23775. @itemize @bullet
  23776. @item
  23777. 1: DEBUG
  23778. @item
  23779. 2: INFO
  23780. @item
  23781. 3: WARNING
  23782. @item
  23783. 4: ERROR
  23784. @end itemize
  23785. Multiple outputs can be defined, they just need to be separated by
  23786. spaces.
  23787. Defaults to @samp{"3:stderr"}.
  23788. @end deftypevr
  23789. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  23790. Allows usage of the auditing subsystem to be altered
  23791. @itemize @bullet
  23792. @item
  23793. 0: disable all auditing
  23794. @item
  23795. 1: enable auditing, only if enabled on host
  23796. @item
  23797. 2: enable auditing, and exit if disabled on host.
  23798. @end itemize
  23799. Defaults to @samp{1}.
  23800. @end deftypevr
  23801. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  23802. Send audit messages via libvirt logging infrastructure.
  23803. Defaults to @samp{#f}.
  23804. @end deftypevr
  23805. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  23806. Host UUID@. UUID must not have all digits be the same.
  23807. Defaults to @samp{""}.
  23808. @end deftypevr
  23809. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  23810. Source to read host UUID.
  23811. @itemize @bullet
  23812. @item
  23813. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  23814. @item
  23815. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  23816. @end itemize
  23817. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  23818. be generated.
  23819. Defaults to @samp{"smbios"}.
  23820. @end deftypevr
  23821. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  23822. A keepalive message is sent to a client after @code{keepalive_interval}
  23823. seconds of inactivity to check if the client is still responding. If
  23824. set to -1, libvirtd will never send keepalive requests; however clients
  23825. can still send them and the daemon will send responses.
  23826. Defaults to @samp{5}.
  23827. @end deftypevr
  23828. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  23829. Maximum number of keepalive messages that are allowed to be sent to the
  23830. client without getting any response before the connection is considered
  23831. broken.
  23832. In other words, the connection is automatically closed approximately
  23833. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  23834. the last message received from the client. When @code{keepalive-count}
  23835. is set to 0, connections will be automatically closed after
  23836. @code{keepalive-interval} seconds of inactivity without sending any
  23837. keepalive messages.
  23838. Defaults to @samp{5}.
  23839. @end deftypevr
  23840. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  23841. Same as above but for admin interface.
  23842. Defaults to @samp{5}.
  23843. @end deftypevr
  23844. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  23845. Same as above but for admin interface.
  23846. Defaults to @samp{5}.
  23847. @end deftypevr
  23848. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  23849. Timeout for Open vSwitch calls.
  23850. The @code{ovs-vsctl} utility is used for the configuration and its
  23851. timeout option is set by default to 5 seconds to avoid potential
  23852. infinite waits blocking libvirt.
  23853. Defaults to @samp{5}.
  23854. @end deftypevr
  23855. @c %end of autogenerated docs
  23856. @subsubheading Virtlog daemon
  23857. The virtlogd service is a server side daemon component of libvirt that is
  23858. used to manage logs from virtual machine consoles.
  23859. This daemon is not used directly by libvirt client applications, rather it
  23860. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  23861. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  23862. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  23863. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  23864. @deffn {Scheme Variable} virtlog-service-type
  23865. This is the type of the virtlog daemon.
  23866. Its value must be a @code{virtlog-configuration}.
  23867. @lisp
  23868. (service virtlog-service-type
  23869. (virtlog-configuration
  23870. (max-clients 1000)))
  23871. @end lisp
  23872. @end deffn
  23873. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  23874. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  23875. Defaults to @samp{3}.
  23876. @end deftypevr
  23877. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  23878. Logging filters.
  23879. A filter allows to select a different logging level for a given category
  23880. of logs The format for a filter is one of:
  23881. @itemize @bullet
  23882. @item
  23883. x:name
  23884. @item
  23885. x:+name
  23886. @end itemize
  23887. where @code{name} is a string which is matched against the category
  23888. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  23889. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  23890. be a substring of the full category name, in order to match multiple
  23891. similar categories), the optional "+" prefix tells libvirt to log stack
  23892. trace for each message matching name, and @code{x} is the minimal level
  23893. where matching messages should be logged:
  23894. @itemize @bullet
  23895. @item
  23896. 1: DEBUG
  23897. @item
  23898. 2: INFO
  23899. @item
  23900. 3: WARNING
  23901. @item
  23902. 4: ERROR
  23903. @end itemize
  23904. Multiple filters can be defined in a single filters statement, they just
  23905. need to be separated by spaces.
  23906. Defaults to @samp{"3:remote 4:event"}.
  23907. @end deftypevr
  23908. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  23909. Logging outputs.
  23910. An output is one of the places to save logging information The format
  23911. for an output can be:
  23912. @table @code
  23913. @item x:stderr
  23914. output goes to stderr
  23915. @item x:syslog:name
  23916. use syslog for the output and use the given name as the ident
  23917. @item x:file:file_path
  23918. output to a file, with the given filepath
  23919. @item x:journald
  23920. output to journald logging system
  23921. @end table
  23922. In all case the x prefix is the minimal level, acting as a filter
  23923. @itemize @bullet
  23924. @item
  23925. 1: DEBUG
  23926. @item
  23927. 2: INFO
  23928. @item
  23929. 3: WARNING
  23930. @item
  23931. 4: ERROR
  23932. @end itemize
  23933. Multiple outputs can be defined, they just need to be separated by
  23934. spaces.
  23935. Defaults to @samp{"3:stderr"}.
  23936. @end deftypevr
  23937. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  23938. Maximum number of concurrent client connections to allow over all
  23939. sockets combined.
  23940. Defaults to @samp{1024}.
  23941. @end deftypevr
  23942. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  23943. Maximum file size before rolling over.
  23944. Defaults to @samp{2MB}
  23945. @end deftypevr
  23946. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  23947. Maximum number of backup files to keep.
  23948. Defaults to @samp{3}
  23949. @end deftypevr
  23950. @anchor{transparent-emulation-qemu}
  23951. @subsubheading Transparent Emulation with QEMU
  23952. @cindex emulation
  23953. @cindex @code{binfmt_misc}
  23954. @code{qemu-binfmt-service-type} provides support for transparent
  23955. emulation of program binaries built for different architectures---e.g.,
  23956. it allows you to transparently execute an ARMv7 program on an x86_64
  23957. machine. It achieves this by combining the @uref{https://www.qemu.org,
  23958. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  23959. This feature only allows you to emulate GNU/Linux on a different
  23960. architecture, but see below for GNU/Hurd support.
  23961. @defvr {Scheme Variable} qemu-binfmt-service-type
  23962. This is the type of the QEMU/binfmt service for transparent emulation.
  23963. Its value must be a @code{qemu-binfmt-configuration} object, which
  23964. specifies the QEMU package to use as well as the architecture we want to
  23965. emulated:
  23966. @lisp
  23967. (service qemu-binfmt-service-type
  23968. (qemu-binfmt-configuration
  23969. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  23970. @end lisp
  23971. In this example, we enable transparent emulation for the ARM and aarch64
  23972. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  23973. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  23974. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  23975. @end defvr
  23976. @deftp {Data Type} qemu-binfmt-configuration
  23977. This is the configuration for the @code{qemu-binfmt} service.
  23978. @table @asis
  23979. @item @code{platforms} (default: @code{'()})
  23980. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  23981. object} as returned by @code{lookup-qemu-platforms} (see below).
  23982. For example, let's suppose you're on an x86_64 machine and you have this
  23983. service:
  23984. @lisp
  23985. (service qemu-binfmt-service-type
  23986. (qemu-binfmt-configuration
  23987. (platforms (lookup-qemu-platforms "arm"))))
  23988. @end lisp
  23989. You can run:
  23990. @example
  23991. guix build -s armhf-linux inkscape
  23992. @end example
  23993. @noindent
  23994. and it will build Inkscape for ARMv7 @emph{as if it were a native
  23995. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  23996. if you'd like to test a package build for an architecture you don't have
  23997. access to!
  23998. @item @code{qemu} (default: @code{qemu})
  23999. The QEMU package to use.
  24000. @end table
  24001. @end deftp
  24002. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  24003. Return the list of QEMU platform objects corresponding to
  24004. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  24005. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  24006. @code{"mips64el"}, and so on.
  24007. @end deffn
  24008. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  24009. Return true if @var{obj} is a platform object.
  24010. @end deffn
  24011. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  24012. Return the name of @var{platform}---a string such as @code{"arm"}.
  24013. @end deffn
  24014. @subsubheading QEMU Guest Agent
  24015. @cindex emulation
  24016. The QEMU guest agent provides control over the emulated system to the
  24017. host. The @code{qemu-guest-agent} service runs the agent on Guix
  24018. guests. To control the agent from the host, open a socket by invoking
  24019. QEMU with the following arguments:
  24020. @example
  24021. qemu-system-x86_64 \
  24022. -chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0 \
  24023. -device virtio-serial \
  24024. -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
  24025. ...
  24026. @end example
  24027. This creates a socket at @file{/tmp/qga.sock} on the host. Once the
  24028. guest agent is running, you can issue commands with @code{socat}:
  24029. @example
  24030. $ guix shell socat -- socat unix-connect:/tmp/qga.sock stdio
  24031. @{"execute": "guest-get-host-name"@}
  24032. @{"return": @{"host-name": "guix"@}@}
  24033. @end example
  24034. See @url{https://wiki.qemu.org/Features/GuestAgent,QEMU guest agent
  24035. documentation} for more options and commands.
  24036. @defvr {Scheme Variable} qemu-guest-agent-service-type
  24037. Service type for the QEMU guest agent service.
  24038. @end defvr
  24039. @deftp {Data Type} qemu-guest-agent-configuration
  24040. Configuration for the @code{qemu-guest-agent} service.
  24041. @table @asis
  24042. @item @code{qemu} (default: @code{qemu-minimal})
  24043. The QEMU package to use.
  24044. @item @code{device} (default: @code{""})
  24045. File name of the device or socket the agent uses to communicate with the
  24046. host. If empty, QEMU uses a default file name.
  24047. @end table
  24048. @end deftp
  24049. @subsubheading The Hurd in a Virtual Machine
  24050. @cindex @code{hurd}
  24051. @cindex the Hurd
  24052. @cindex childhurd
  24053. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  24054. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  24055. to be used on GNU/Linux and the given GNU/Hurd operating system
  24056. configuration is cross-compiled. The virtual machine is a Shepherd
  24057. service that can be referred to by the names @code{hurd-vm} and
  24058. @code{childhurd} and be controlled with commands such as:
  24059. @example
  24060. herd start hurd-vm
  24061. herd stop childhurd
  24062. @end example
  24063. When the service is running, you can view its console by connecting to
  24064. it with a VNC client, for example with:
  24065. @example
  24066. guix shell tigervnc-client -- vncviewer localhost:5900
  24067. @end example
  24068. The default configuration (see @code{hurd-vm-configuration} below)
  24069. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  24070. (the virtual machine emulator) redirects to port 10222 on the host.
  24071. Thus, you can connect over SSH to the childhurd with:
  24072. @example
  24073. ssh root@@localhost -p 10022
  24074. @end example
  24075. The childhurd is volatile and stateless: it starts with a fresh root
  24076. file system every time you restart it. By default though, all the files
  24077. under @file{/etc/childhurd} on the host are copied as is to the root
  24078. file system of the childhurd when it boots. This allows you to
  24079. initialize ``secrets'' inside the VM: SSH host keys, authorized
  24080. substitute keys, and so on---see the explanation of @code{secret-root}
  24081. below.
  24082. @defvr {Scheme Variable} hurd-vm-service-type
  24083. This is the type of the Hurd in a Virtual Machine service. Its value
  24084. must be a @code{hurd-vm-configuration} object, which specifies the
  24085. operating system (@pxref{operating-system Reference}) and the disk size
  24086. for the Hurd Virtual Machine, the QEMU package to use as well as the
  24087. options for running it.
  24088. For example:
  24089. @lisp
  24090. (service hurd-vm-service-type
  24091. (hurd-vm-configuration
  24092. (disk-size (* 5000 (expt 2 20))) ;5G
  24093. (memory-size 1024))) ;1024MiB
  24094. @end lisp
  24095. would create a disk image big enough to build GNU@tie{}Hello, with some
  24096. extra memory.
  24097. @end defvr
  24098. @deftp {Data Type} hurd-vm-configuration
  24099. The data type representing the configuration for
  24100. @code{hurd-vm-service-type}.
  24101. @table @asis
  24102. @item @code{os} (default: @var{%hurd-vm-operating-system})
  24103. The operating system to instantiate. This default is bare-bones with a
  24104. permissive OpenSSH secure shell daemon listening on port 2222
  24105. (@pxref{Networking Services, @code{openssh-service-type}}).
  24106. @item @code{qemu} (default: @code{qemu-minimal})
  24107. The QEMU package to use.
  24108. @item @code{image} (default: @var{hurd-vm-disk-image})
  24109. The procedure used to build the disk-image built from this
  24110. configuration.
  24111. @item @code{disk-size} (default: @code{'guess})
  24112. The size of the disk image.
  24113. @item @code{memory-size} (default: @code{512})
  24114. The memory size of the Virtual Machine in mebibytes.
  24115. @item @code{options} (default: @code{'("--snapshot")})
  24116. The extra options for running QEMU.
  24117. @item @code{id} (default: @code{#f})
  24118. If set, a non-zero positive integer used to parameterize Childhurd
  24119. instances. It is appended to the service's name,
  24120. e.g. @code{childhurd1}.
  24121. @item @code{net-options} (default: @var{hurd-vm-net-options})
  24122. The procedure used to produce the list of QEMU networking options.
  24123. By default, it produces
  24124. @lisp
  24125. '("--device" "rtl8139,netdev=net0"
  24126. "--netdev" (string-append
  24127. "user,id=net0,"
  24128. "hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004,"
  24129. "hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222,"
  24130. "hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900"))
  24131. @end lisp
  24132. with forwarded ports:
  24133. @example
  24134. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  24135. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  24136. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  24137. @end example
  24138. @item @code{secret-root} (default: @file{/etc/childhurd})
  24139. The root directory with out-of-band secrets to be installed into the
  24140. childhurd once it runs. Childhurds are volatile which means that on
  24141. every startup, secrets such as the SSH host keys and Guix signing key
  24142. are recreated.
  24143. If the @file{/etc/childhurd} directory does not exist, the
  24144. @code{secret-service} running in the Childhurd will be sent an empty
  24145. list of secrets.
  24146. By default, the service automatically populates @file{/etc/childhurd}
  24147. with the following non-volatile secrets, unless they already exist:
  24148. @example
  24149. /etc/childhurd/etc/guix/acl
  24150. /etc/childhurd/etc/guix/signing-key.pub
  24151. /etc/childhurd/etc/guix/signing-key.sec
  24152. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  24153. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  24154. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  24155. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  24156. @end example
  24157. These files are automatically sent to the guest Hurd VM when it boots,
  24158. including permissions.
  24159. @cindex childhurd, offloading
  24160. @cindex Hurd, offloading
  24161. Having these files in place means that only a couple of things are
  24162. missing to allow the host to offload @code{i586-gnu} builds to the
  24163. childhurd:
  24164. @enumerate
  24165. @item
  24166. Authorizing the childhurd's key on the host so that the host accepts
  24167. build results coming from the childhurd, which can be done like so:
  24168. @example
  24169. guix archive --authorize < \
  24170. /etc/childhurd/etc/guix/signing-key.pub
  24171. @end example
  24172. @item
  24173. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  24174. Offload Setup}).
  24175. @end enumerate
  24176. We're working towards making that happen automatically---get in touch
  24177. with us at @email{guix-devel@@gnu.org} to discuss it!
  24178. @end table
  24179. @end deftp
  24180. Note that by default the VM image is volatile, i.e., once stopped the
  24181. contents are lost. If you want a stateful image instead, override the
  24182. configuration's @code{image} and @code{options} without
  24183. the @code{--snapshot} flag using something along these lines:
  24184. @lisp
  24185. (service hurd-vm-service-type
  24186. (hurd-vm-configuration
  24187. (image (const "/out/of/store/writable/hurd.img"))
  24188. (options '())))
  24189. @end lisp
  24190. @subsubheading Ganeti
  24191. @cindex ganeti
  24192. @quotation Note
  24193. This service is considered experimental. Configuration options may be changed
  24194. in a backwards-incompatible manner, and not all features have been thorougly
  24195. tested. Users of this service are encouraged to share their experience at
  24196. @email{guix-devel@@gnu.org}.
  24197. @end quotation
  24198. Ganeti is a virtual machine management system. It is designed to keep virtual
  24199. machines running on a cluster of servers even in the event of hardware failures,
  24200. and to make maintenance and recovery tasks easy. It consists of multiple
  24201. services which are described later in this section. In addition to the Ganeti
  24202. service, you will need the OpenSSH service (@pxref{Networking Services,
  24203. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  24204. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  24205. and address (or use a DNS server).
  24206. All nodes participating in a Ganeti cluster should have the same Ganeti and
  24207. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  24208. cluster node that supports multiple storage backends, and installs the
  24209. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  24210. @lisp
  24211. (use-package-modules virtualization)
  24212. (use-service-modules base ganeti networking ssh)
  24213. (operating-system
  24214. ;; @dots{}
  24215. (host-name "node1")
  24216. (hosts-file (plain-file "hosts" (format #f "
  24217. 127.0.0.1 localhost
  24218. ::1 localhost
  24219. 192.168.1.200 ganeti.example.com
  24220. 192.168.1.201 node1.example.com node1
  24221. 192.168.1.202 node2.example.com node2
  24222. ")))
  24223. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  24224. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  24225. (packages (append (map specification->package
  24226. '("qemu" "lvm2" "drbd-utils" "ceph"
  24227. ;; Add the debootstrap and guix OS providers.
  24228. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  24229. %base-packages))
  24230. (services
  24231. (append (list (service static-networking-service-type
  24232. (list (static-networking
  24233. (addresses
  24234. (list (network-address
  24235. (device "eth0")
  24236. (value "192.168.1.201/24"))))
  24237. (routes
  24238. (list (network-route
  24239. (destination "default")
  24240. (gateway "192.168.1.254"))))
  24241. (name-servers '("192.168.1.252"
  24242. "192.168.1.253")))))
  24243. ;; Ganeti uses SSH to communicate between nodes.
  24244. (service openssh-service-type
  24245. (openssh-configuration
  24246. (permit-root-login 'prohibit-password)))
  24247. (service ganeti-service-type
  24248. (ganeti-configuration
  24249. ;; This list specifies allowed file system paths
  24250. ;; for storing virtual machine images.
  24251. (file-storage-paths '("/srv/ganeti/file-storage"))
  24252. ;; This variable configures a single "variant" for
  24253. ;; both Debootstrap and Guix that works with KVM.
  24254. (os %default-ganeti-os))))
  24255. %base-services)))
  24256. @end lisp
  24257. Users are advised to read the
  24258. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  24259. administrators guide} to learn about the various cluster options and
  24260. day-to-day operations. There is also a
  24261. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  24262. describing how to configure and initialize a small cluster.
  24263. @defvr {Scheme Variable} ganeti-service-type
  24264. This is a service type that includes all the various services that Ganeti
  24265. nodes should run.
  24266. Its value is a @code{ganeti-configuration} object that defines the package
  24267. to use for CLI operations, as well as configuration for the various daemons.
  24268. Allowed file storage paths and available guest operating systems are also
  24269. configured through this data type.
  24270. @end defvr
  24271. @deftp {Data Type} ganeti-configuration
  24272. The @code{ganeti} service takes the following configuration options:
  24273. @table @asis
  24274. @item @code{ganeti} (default: @code{ganeti})
  24275. The @code{ganeti} package to use. It will be installed to the system profile
  24276. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  24277. that the value specified here does not affect the other services as each refer
  24278. to a specific @code{ganeti} package (see below).
  24279. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  24280. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  24281. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  24282. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  24283. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  24284. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  24285. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  24286. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  24287. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  24288. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  24289. These options control the various daemons and cron jobs that are distributed
  24290. with Ganeti. The possible values for these are described in detail below.
  24291. To override a setting, you must use the configuration type for that service:
  24292. @lisp
  24293. (service ganeti-service-type
  24294. (ganeti-configuration
  24295. (rapi-configuration
  24296. (ganeti-rapi-configuration
  24297. (interface "eth1"))))
  24298. (watcher-configuration
  24299. (ganeti-watcher-configuration
  24300. (rapi-ip "10.0.0.1"))))
  24301. @end lisp
  24302. @item @code{file-storage-paths} (default: @code{'()})
  24303. List of allowed directories for file storage backend.
  24304. @item @code{os} (default: @code{%default-ganeti-os})
  24305. List of @code{<ganeti-os>} records.
  24306. @end table
  24307. In essence @code{ganeti-service-type} is shorthand for declaring each service
  24308. individually:
  24309. @lisp
  24310. (service ganeti-noded-service-type)
  24311. (service ganeti-confd-service-type)
  24312. (service ganeti-wconfd-service-type)
  24313. (service ganeti-luxid-service-type)
  24314. (service ganeti-kvmd-service-type)
  24315. (service ganeti-mond-service-type)
  24316. (service ganeti-metad-service-type)
  24317. (service ganeti-watcher-service-type)
  24318. (service ganeti-cleaner-service-type)
  24319. @end lisp
  24320. Plus a service extension for @code{etc-service-type} that configures the file
  24321. storage backend and OS variants.
  24322. @end deftp
  24323. @deftp {Data Type} ganeti-os
  24324. This data type is suitable for passing to the @code{os} parameter of
  24325. @code{ganeti-configuration}. It takes the following parameters:
  24326. @table @asis
  24327. @item @code{name}
  24328. The name for this OS provider. It is only used to specify where the
  24329. configuration ends up. Setting it to ``debootstrap'' will create
  24330. @file{/etc/ganeti/instance-debootstrap}.
  24331. @item @code{extension}
  24332. The file extension for variants of this OS type. For example
  24333. @file{.conf} or @file{.scm}.
  24334. @item @code{variants} (default: @code{'()})
  24335. List of @code{ganeti-os-variant} objects for this OS.
  24336. @end table
  24337. @end deftp
  24338. @deftp {Data Type} ganeti-os-variant
  24339. This is the data type for a Ganeti OS variant. It takes the following
  24340. parameters:
  24341. @table @asis
  24342. @item @code{name}
  24343. The name of this variant.
  24344. @item @code{configuration}
  24345. A configuration file for this variant.
  24346. @end table
  24347. @end deftp
  24348. @defvr {Scheme Variable} %default-debootstrap-hooks
  24349. This variable contains hooks to configure networking and the GRUB bootloader.
  24350. @end defvr
  24351. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  24352. This variable contains a list of packages suitable for a fully-virtualized guest.
  24353. @end defvr
  24354. @deftp {Data Type} debootstrap-configuration
  24355. This data type creates configuration files suitable for the debootstrap OS provider.
  24356. @table @asis
  24357. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  24358. When not @code{#f}, this must be a G-expression that specifies a directory with
  24359. scripts that will run when the OS is installed. It can also be a list of
  24360. @code{(name . file-like)} pairs. For example:
  24361. @lisp
  24362. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  24363. @end lisp
  24364. That will create a directory with one executable named @code{99-hello-world}
  24365. and run it every time this variant is installed. If set to @code{#f}, hooks
  24366. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  24367. @item @code{proxy} (default: @code{#f})
  24368. Optional HTTP proxy to use.
  24369. @item @code{mirror} (default: @code{#f})
  24370. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  24371. The default varies depending on the distribution.
  24372. @item @code{arch} (default: @code{#f})
  24373. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  24374. on an AArch64 host. Default is to use the current system architecture.
  24375. @item @code{suite} (default: @code{"stable"})
  24376. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  24377. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  24378. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  24379. List of extra packages that will get installed by dpkg in addition
  24380. to the minimal system.
  24381. @item @code{components} (default: @code{#f})
  24382. When set, must be a list of Debian repository ``components''. For example
  24383. @code{'("main" "contrib")}.
  24384. @item @code{generate-cache?} (default: @code{#t})
  24385. Whether to automatically cache the generated debootstrap archive.
  24386. @item @code{clean-cache} (default: @code{14})
  24387. Discard the cache after this amount of days. Use @code{#f} to never
  24388. clear the cache.
  24389. @item @code{partition-style} (default: @code{'msdos})
  24390. The type of partition to create. When set, it must be one of
  24391. @code{'msdos}, @code{'none} or a string.
  24392. @item @code{partition-alignment} (default: @code{2048})
  24393. Alignment of the partition in sectors.
  24394. @end table
  24395. @end deftp
  24396. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  24397. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  24398. takes two parameters: a name and a @code{debootstrap-configuration} object.
  24399. @end deffn
  24400. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  24401. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  24402. a list of variants created with @code{debootstrap-variant}.
  24403. @end deffn
  24404. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  24405. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  24406. use with the Guix OS provider. It takes a name and a G-expression that returns
  24407. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  24408. Guix System configuration.
  24409. @end deffn
  24410. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  24411. This is a helper procedure that creates a @code{ganeti-os} record. It
  24412. takes a list of variants produced by @code{guix-variant}.
  24413. @end deffn
  24414. @defvr {Scheme Variable} %default-debootstrap-variants
  24415. This is a convenience variable to make the debootstrap provider work
  24416. ``out of the box'' without users having to declare variants manually. It
  24417. contains a single debootstrap variant with the default configuration:
  24418. @lisp
  24419. (list (debootstrap-variant
  24420. "default"
  24421. (debootstrap-configuration)))
  24422. @end lisp
  24423. @end defvr
  24424. @defvr {Scheme Variable} %default-guix-variants
  24425. This is a convenience variable to make the Guix OS provider work without
  24426. additional configuration. It creates a virtual machine that has an SSH
  24427. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  24428. @lisp
  24429. (list (guix-variant
  24430. "default"
  24431. (file-append ganeti-instance-guix
  24432. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  24433. @end lisp
  24434. @end defvr
  24435. Users can implement support for OS providers unbeknownst to Guix by extending
  24436. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  24437. For example:
  24438. @lisp
  24439. (ganeti-os
  24440. (name "custom")
  24441. (extension ".conf")
  24442. (variants
  24443. (list (ganeti-os-variant
  24444. (name "foo")
  24445. (configuration (plain-file "bar" "this is fine"))))))
  24446. @end lisp
  24447. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  24448. to a file in the store with contents @code{this is fine}. It also creates
  24449. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  24450. Obviously this may not work for all OS providers out there. If you find the
  24451. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  24452. The rest of this section documents the various services that are included by
  24453. @code{ganeti-service-type}.
  24454. @defvr {Scheme Variable} ganeti-noded-service-type
  24455. @command{ganeti-noded} is the daemon responsible for node-specific functions
  24456. within the Ganeti system. The value of this service must be a
  24457. @code{ganeti-noded-configuration} object.
  24458. @end defvr
  24459. @deftp {Data Type} ganeti-noded-configuration
  24460. This is the configuration for the @code{ganeti-noded} service.
  24461. @table @asis
  24462. @item @code{ganeti} (default: @code{ganeti})
  24463. The @code{ganeti} package to use for this service.
  24464. @item @code{port} (default: @code{1811})
  24465. The TCP port on which the node daemon listens for network requests.
  24466. @item @code{address} (default: @code{"0.0.0.0"})
  24467. The network address that the daemon will bind to. The default address means
  24468. bind to all available addresses.
  24469. @item @code{interface} (default: @code{#f})
  24470. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  24471. that the daemon will bind to.
  24472. @item @code{max-clients} (default: @code{20})
  24473. This sets a limit on the maximum number of simultaneous client connections
  24474. that the daemon will handle. Connections above this count are accepted, but
  24475. no responses will be sent until enough connections have closed.
  24476. @item @code{ssl?} (default: @code{#t})
  24477. Whether to use SSL/TLS to encrypt network communications. The certificate
  24478. is automatically provisioned by the cluster and can be rotated with
  24479. @command{gnt-cluster renew-crypto}.
  24480. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  24481. This can be used to provide a specific encryption key for TLS communications.
  24482. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  24483. This can be used to provide a specific certificate for TLS communications.
  24484. @item @code{debug?} (default: @code{#f})
  24485. When true, the daemon performs additional logging for debugging purposes.
  24486. Note that this will leak encryption details to the log files, use with caution.
  24487. @end table
  24488. @end deftp
  24489. @defvr {Scheme Variable} ganeti-confd-service-type
  24490. @command{ganeti-confd} answers queries related to the configuration of a
  24491. Ganeti cluster. The purpose of this daemon is to have a highly available
  24492. and fast way to query cluster configuration values. It is automatically
  24493. active on all @dfn{master candidates}. The value of this service must be a
  24494. @code{ganeti-confd-configuration} object.
  24495. @end defvr
  24496. @deftp {Data Type} ganeti-confd-configuration
  24497. This is the configuration for the @code{ganeti-confd} service.
  24498. @table @asis
  24499. @item @code{ganeti} (default: @code{ganeti})
  24500. The @code{ganeti} package to use for this service.
  24501. @item @code{port} (default: @code{1814})
  24502. The UDP port on which to listen for network requests.
  24503. @item @code{address} (default: @code{"0.0.0.0"})
  24504. Network address that the daemon will bind to.
  24505. @item @code{debug?} (default: @code{#f})
  24506. When true, the daemon performs additional logging for debugging purposes.
  24507. @end table
  24508. @end deftp
  24509. @defvr {Scheme Variable} ganeti-wconfd-service-type
  24510. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  24511. about the cluster configuration and is the only entity that can accept
  24512. changes to it. All jobs that need to modify the configuration will do so
  24513. by sending appropriate requests to this daemon. It only runs on the
  24514. @dfn{master node} and will automatically disable itself on other nodes.
  24515. The value of this service must be a
  24516. @code{ganeti-wconfd-configuration} object.
  24517. @end defvr
  24518. @deftp {Data Type} ganeti-wconfd-configuration
  24519. This is the configuration for the @code{ganeti-wconfd} service.
  24520. @table @asis
  24521. @item @code{ganeti} (default: @code{ganeti})
  24522. The @code{ganeti} package to use for this service.
  24523. @item @code{no-voting?} (default: @code{#f})
  24524. The daemon will refuse to start if the majority of cluster nodes does not
  24525. agree that it is running on the master node. Set to @code{#t} to start
  24526. even if a quorum can not be reached (dangerous, use with caution).
  24527. @item @code{debug?} (default: @code{#f})
  24528. When true, the daemon performs additional logging for debugging purposes.
  24529. @end table
  24530. @end deftp
  24531. @defvr {Scheme Variable} ganeti-luxid-service-type
  24532. @command{ganeti-luxid} is a daemon used to answer queries related to the
  24533. configuration and the current live state of a Ganeti cluster. Additionally,
  24534. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  24535. submitted via this daemon and it schedules and starts them.
  24536. It takes a @code{ganeti-luxid-configuration} object.
  24537. @end defvr
  24538. @deftp {Data Type} ganeti-luxid-configuration
  24539. This is the configuration for the @code{ganeti-luxid} service.
  24540. @table @asis
  24541. @item @code{ganeti} (default: @code{ganeti})
  24542. The @code{ganeti} package to use for this service.
  24543. @item @code{no-voting?} (default: @code{#f})
  24544. The daemon will refuse to start if it cannot verify that the majority of
  24545. cluster nodes believes that it is running on the master node. Set to
  24546. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  24547. @item @code{debug?} (default: @code{#f})
  24548. When true, the daemon performs additional logging for debugging purposes.
  24549. @end table
  24550. @end deftp
  24551. @defvr {Scheme Variable} ganeti-rapi-service-type
  24552. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  24553. the master node and can be used to perform cluster actions programmatically
  24554. via a JSON-based RPC protocol.
  24555. Most query operations are allowed without authentication (unless
  24556. @var{require-authentication?} is set), whereas write operations require
  24557. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  24558. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  24559. API documentation} for more information.
  24560. The value of this service must be a @code{ganeti-rapi-configuration} object.
  24561. @end defvr
  24562. @deftp {Data Type} ganeti-rapi-configuration
  24563. This is the configuration for the @code{ganeti-rapi} service.
  24564. @table @asis
  24565. @item @code{ganeti} (default: @code{ganeti})
  24566. The @code{ganeti} package to use for this service.
  24567. @item @code{require-authentication?} (default: @code{#f})
  24568. Whether to require authentication even for read-only operations.
  24569. @item @code{port} (default: @code{5080})
  24570. The TCP port on which to listen to API requests.
  24571. @item @code{address} (default: @code{"0.0.0.0"})
  24572. The network address that the service will bind to. By default it listens
  24573. on all configured addresses.
  24574. @item @code{interface} (default: @code{#f})
  24575. When set, it must specify a specific network interface such as @code{eth0}
  24576. that the daemon will bind to.
  24577. @item @code{max-clients} (default: @code{20})
  24578. The maximum number of simultaneous client requests to handle. Further
  24579. connections are allowed, but no responses are sent until enough connections
  24580. have closed.
  24581. @item @code{ssl?} (default: @code{#t})
  24582. Whether to use SSL/TLS encryption on the RAPI port.
  24583. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  24584. This can be used to provide a specific encryption key for TLS communications.
  24585. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  24586. This can be used to provide a specific certificate for TLS communications.
  24587. @item @code{debug?} (default: @code{#f})
  24588. When true, the daemon performs additional logging for debugging purposes.
  24589. Note that this will leak encryption details to the log files, use with caution.
  24590. @end table
  24591. @end deftp
  24592. @defvr {Scheme Variable} ganeti-kvmd-service-type
  24593. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  24594. instance was shut down by an administrator or a user. Normally Ganeti will
  24595. restart an instance that was not stopped through Ganeti itself. If the
  24596. cluster option @code{user_shutdown} is true, this daemon monitors the
  24597. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  24598. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  24599. it shuts down gracefully by itself.
  24600. It takes a @code{ganeti-kvmd-configuration} object.
  24601. @end defvr
  24602. @deftp {Data Type} ganeti-kvmd-configuration
  24603. @table @asis
  24604. @item @code{ganeti} (default: @code{ganeti})
  24605. The @code{ganeti} package to use for this service.
  24606. @item @code{debug?} (default: @code{#f})
  24607. When true, the daemon performs additional logging for debugging purposes.
  24608. @end table
  24609. @end deftp
  24610. @defvr {Scheme Variable} ganeti-mond-service-type
  24611. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  24612. functionality. It is responsible for running data collectors and publish the
  24613. collected information through a HTTP interface.
  24614. It takes a @code{ganeti-mond-configuration} object.
  24615. @end defvr
  24616. @deftp {Data Type} ganeti-mond-configuration
  24617. @table @asis
  24618. @item @code{ganeti} (default: @code{ganeti})
  24619. The @code{ganeti} package to use for this service.
  24620. @item @code{port} (default: @code{1815})
  24621. The port on which the daemon will listen.
  24622. @item @code{address} (default: @code{"0.0.0.0"})
  24623. The network address that the daemon will bind to. By default it binds to all
  24624. available interfaces.
  24625. @item @code{debug?} (default: @code{#f})
  24626. When true, the daemon performs additional logging for debugging purposes.
  24627. @end table
  24628. @end deftp
  24629. @defvr {Scheme Variable} ganeti-metad-service-type
  24630. @command{ganeti-metad} is an optional daemon that can be used to provide
  24631. information about the cluster to instances or OS install scripts.
  24632. It takes a @code{ganeti-metad-configuration} object.
  24633. @end defvr
  24634. @deftp {Data Type} ganeti-metad-configuration
  24635. @table @asis
  24636. @item @code{ganeti} (default: @code{ganeti})
  24637. The @code{ganeti} package to use for this service.
  24638. @item @code{port} (default: @code{80})
  24639. The port on which the daemon will listen.
  24640. @item @code{address} (default: @code{#f})
  24641. If set, the daemon will bind to this address only. If left unset, the behavior
  24642. depends on the cluster configuration.
  24643. @item @code{debug?} (default: @code{#f})
  24644. When true, the daemon performs additional logging for debugging purposes.
  24645. @end table
  24646. @end deftp
  24647. @defvr {Scheme Variable} ganeti-watcher-service-type
  24648. @command{ganeti-watcher} is a script designed to run periodically and ensure
  24649. the health of a cluster. It will automatically restart instances that have
  24650. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  24651. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  24652. that are not running. If the cluster parameter @code{ensure_node_health}
  24653. is set, the watcher will also shutdown instances and DRBD devices if the
  24654. node it is running on is declared offline by known master candidates.
  24655. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  24656. The service takes a @code{ganeti-watcher-configuration} object.
  24657. @end defvr
  24658. @deftp {Data Type} ganeti-watcher-configuration
  24659. @table @asis
  24660. @item @code{ganeti} (default: @code{ganeti})
  24661. The @code{ganeti} package to use for this service.
  24662. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  24663. How often to run the script. The default is every five minutes.
  24664. @item @code{rapi-ip} (default: @code{#f})
  24665. This option needs to be specified only if the RAPI daemon is configured to use
  24666. a particular interface or address. By default the cluster address is used.
  24667. @item @code{job-age} (default: @code{(* 6 3600)})
  24668. Archive cluster jobs older than this age, specified in seconds. The default
  24669. is 6 hours. This keeps @command{gnt-job list} manageable.
  24670. @item @code{verify-disks?} (default: @code{#t})
  24671. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  24672. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  24673. manually instead.
  24674. @item @code{debug?} (default: @code{#f})
  24675. When @code{#t}, the script performs additional logging for debugging purposes.
  24676. @end table
  24677. @end deftp
  24678. @defvr {Scheme Variable} ganeti-cleaner-service-type
  24679. @command{ganeti-cleaner} is a script designed to run periodically and remove
  24680. old files from the cluster. This service type controls two @dfn{cron jobs}:
  24681. one intended for the master node that permanently purges old cluster jobs,
  24682. and one intended for every node that removes expired X509 certificates, keys,
  24683. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  24684. it is safe to include even on non-master nodes as it will disable itself as
  24685. necessary.
  24686. It takes a @code{ganeti-cleaner-configuration} object.
  24687. @end defvr
  24688. @deftp {Data Type} ganeti-cleaner-configuration
  24689. @table @asis
  24690. @item @code{ganeti} (default: @code{ganeti})
  24691. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  24692. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  24693. How often to run the master cleaning job. The default is once per day, at
  24694. 01:45:00.
  24695. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  24696. How often to run the node cleaning job. The default is once per day, at
  24697. 02:45:00.
  24698. @end table
  24699. @end deftp
  24700. @node Version Control Services
  24701. @subsection Version Control Services
  24702. The @code{(gnu services version-control)} module provides a service to
  24703. allow remote access to local Git repositories. There are three options:
  24704. the @code{git-daemon-service}, which provides access to repositories via
  24705. the @code{git://} unsecured TCP-based protocol, extending the
  24706. @code{nginx} web server to proxy some requests to
  24707. @code{git-http-backend}, or providing a web interface with
  24708. @code{cgit-service-type}.
  24709. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  24710. Return a service that runs @command{git daemon}, a simple TCP server to
  24711. expose repositories over the Git protocol for anonymous access.
  24712. The optional @var{config} argument should be a
  24713. @code{<git-daemon-configuration>} object, by default it allows read-only
  24714. access to exported@footnote{By creating the magic file
  24715. @file{git-daemon-export-ok} in the repository directory.} repositories under
  24716. @file{/srv/git}.
  24717. @end deffn
  24718. @deftp {Data Type} git-daemon-configuration
  24719. Data type representing the configuration for @code{git-daemon-service}.
  24720. @table @asis
  24721. @item @code{package} (default: @code{git})
  24722. Package object of the Git distributed version control system.
  24723. @item @code{export-all?} (default: @code{#f})
  24724. Whether to allow access for all Git repositories, even if they do not
  24725. have the @file{git-daemon-export-ok} file.
  24726. @item @code{base-path} (default: @file{/srv/git})
  24727. Whether to remap all the path requests as relative to the given path.
  24728. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  24729. @samp{example.com}, then if you later try to pull
  24730. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  24731. path as @file{/srv/git/hello.git}.
  24732. @item @code{user-path} (default: @code{#f})
  24733. Whether to allow @code{~user} notation to be used in requests. When
  24734. specified with empty string, requests to
  24735. @indicateurl{git://host/~alice/foo} is taken as a request to access
  24736. @code{foo} repository in the home directory of user @code{alice}. If
  24737. @code{(user-path "@var{path}")} is specified, the same request is taken
  24738. as a request to access @file{@var{path}/foo} repository in the home
  24739. directory of user @code{alice}.
  24740. @item @code{listen} (default: @code{'()})
  24741. Whether to listen on specific IP addresses or hostnames, defaults to
  24742. all.
  24743. @item @code{port} (default: @code{#f})
  24744. Whether to listen on an alternative port, which defaults to 9418.
  24745. @item @code{whitelist} (default: @code{'()})
  24746. If not empty, only allow access to this list of directories.
  24747. @item @code{extra-options} (default: @code{'()})
  24748. Extra options will be passed to @command{git daemon}, please run
  24749. @command{man git-daemon} for more information.
  24750. @end table
  24751. @end deftp
  24752. The @code{git://} protocol lacks authentication. When you pull from a
  24753. repository fetched via @code{git://}, you don't know whether the data you
  24754. receive was modified or is even coming from the specified host, and your
  24755. connection is subject to eavesdropping. It's better to use an authenticated
  24756. and encrypted transport, such as @code{https}. Although Git allows you
  24757. to serve repositories using unsophisticated file-based web servers,
  24758. there is a faster protocol implemented by the @code{git-http-backend}
  24759. program. This program is the back-end of a proper Git web service. It
  24760. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  24761. on running the necessary @code{fcgiwrap} daemon.
  24762. Guix has a separate configuration data type for serving Git repositories
  24763. over HTTP.
  24764. @deftp {Data Type} git-http-configuration
  24765. Data type representing the configuration for a future
  24766. @code{git-http-service-type}; can currently be used to configure Nginx
  24767. through @code{git-http-nginx-location-configuration}.
  24768. @table @asis
  24769. @item @code{package} (default: @var{git})
  24770. Package object of the Git distributed version control system.
  24771. @item @code{git-root} (default: @file{/srv/git})
  24772. Directory containing the Git repositories to expose to the world.
  24773. @item @code{export-all?} (default: @code{#f})
  24774. Whether to expose access for all Git repositories in @var{git-root},
  24775. even if they do not have the @file{git-daemon-export-ok} file.
  24776. @item @code{uri-path} (default: @samp{/git/})
  24777. Path prefix for Git access. With the default @samp{/git/} prefix, this
  24778. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  24779. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  24780. with this prefix are not passed on to this Git instance.
  24781. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  24782. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  24783. Services}.
  24784. @end table
  24785. @end deftp
  24786. There is no @code{git-http-service-type}, currently; instead you can
  24787. create an @code{nginx-location-configuration} from a
  24788. @code{git-http-configuration} and then add that location to a web
  24789. server.
  24790. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  24791. [config=(git-http-configuration)]
  24792. Compute an @code{nginx-location-configuration} that corresponds to the
  24793. given Git http configuration. An example nginx service definition to
  24794. serve the default @file{/srv/git} over HTTPS might be:
  24795. @lisp
  24796. (service nginx-service-type
  24797. (nginx-configuration
  24798. (server-blocks
  24799. (list
  24800. (nginx-server-configuration
  24801. (listen '("443 ssl"))
  24802. (server-name "git.my-host.org")
  24803. (ssl-certificate
  24804. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  24805. (ssl-certificate-key
  24806. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  24807. (locations
  24808. (list
  24809. (git-http-nginx-location-configuration
  24810. (git-http-configuration (uri-path "/"))))))))))
  24811. @end lisp
  24812. This example assumes that you are using Let's Encrypt to get your TLS
  24813. certificate. @xref{Certificate Services}. The default @code{certbot}
  24814. service will redirect all HTTP traffic on @code{git.my-host.org} to
  24815. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  24816. system services. @xref{Web Services}.
  24817. @end deffn
  24818. @subsubheading Cgit Service
  24819. @cindex Cgit service
  24820. @cindex Git, web interface
  24821. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  24822. repositories written in C.
  24823. The following example will configure the service with default values.
  24824. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  24825. @lisp
  24826. (service cgit-service-type)
  24827. @end lisp
  24828. The @code{file-object} type designates either a file-like object
  24829. (@pxref{G-Expressions, file-like objects}) or a string.
  24830. @c %start of fragment
  24831. Available @code{cgit-configuration} fields are:
  24832. @deftypevr {@code{cgit-configuration} parameter} package package
  24833. The CGIT package.
  24834. @end deftypevr
  24835. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  24836. NGINX configuration.
  24837. @end deftypevr
  24838. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  24839. Specifies a command which will be invoked to format the content of about
  24840. pages (both top-level and for each repository).
  24841. Defaults to @samp{""}.
  24842. @end deftypevr
  24843. @deftypevr {@code{cgit-configuration} parameter} string agefile
  24844. Specifies a path, relative to each repository path, which can be used to
  24845. specify the date and time of the youngest commit in the repository.
  24846. Defaults to @samp{""}.
  24847. @end deftypevr
  24848. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  24849. Specifies a command that will be invoked for authenticating repository
  24850. access.
  24851. Defaults to @samp{""}.
  24852. @end deftypevr
  24853. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  24854. Flag which, when set to @samp{age}, enables date ordering in the branch
  24855. ref list, and when set @samp{name} enables ordering by branch name.
  24856. Defaults to @samp{"name"}.
  24857. @end deftypevr
  24858. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  24859. Path used to store the cgit cache entries.
  24860. Defaults to @samp{"/var/cache/cgit"}.
  24861. @end deftypevr
  24862. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  24863. Number which specifies the time-to-live, in minutes, for the cached
  24864. version of repository pages accessed with a fixed SHA1.
  24865. Defaults to @samp{-1}.
  24866. @end deftypevr
  24867. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  24868. Number which specifies the time-to-live, in minutes, for the cached
  24869. version of repository pages accessed without a fixed SHA1.
  24870. Defaults to @samp{5}.
  24871. @end deftypevr
  24872. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  24873. Number which specifies the time-to-live, in minutes, for the cached
  24874. version of the repository summary page.
  24875. Defaults to @samp{5}.
  24876. @end deftypevr
  24877. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  24878. Number which specifies the time-to-live, in minutes, for the cached
  24879. version of the repository index page.
  24880. Defaults to @samp{5}.
  24881. @end deftypevr
  24882. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  24883. Number which specifies the time-to-live, in minutes, for the result of
  24884. scanning a path for Git repositories.
  24885. Defaults to @samp{15}.
  24886. @end deftypevr
  24887. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  24888. Number which specifies the time-to-live, in minutes, for the cached
  24889. version of the repository about page.
  24890. Defaults to @samp{15}.
  24891. @end deftypevr
  24892. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  24893. Number which specifies the time-to-live, in minutes, for the cached
  24894. version of snapshots.
  24895. Defaults to @samp{5}.
  24896. @end deftypevr
  24897. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  24898. The maximum number of entries in the cgit cache. When set to @samp{0},
  24899. caching is disabled.
  24900. Defaults to @samp{0}.
  24901. @end deftypevr
  24902. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  24903. Sort items in the repo list case sensitively.
  24904. Defaults to @samp{#t}.
  24905. @end deftypevr
  24906. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  24907. List of common prefixes which, when combined with a repository URL,
  24908. generates valid clone URLs for the repository.
  24909. Defaults to @samp{()}.
  24910. @end deftypevr
  24911. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  24912. List of @code{clone-url} templates.
  24913. Defaults to @samp{()}.
  24914. @end deftypevr
  24915. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  24916. Command which will be invoked to format commit messages.
  24917. Defaults to @samp{""}.
  24918. @end deftypevr
  24919. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  24920. Flag which, when set to @samp{date}, enables strict date ordering in the
  24921. commit log, and when set to @samp{topo} enables strict topological
  24922. ordering.
  24923. Defaults to @samp{"git log"}.
  24924. @end deftypevr
  24925. @deftypevr {@code{cgit-configuration} parameter} file-object css
  24926. URL which specifies the css document to include in all cgit pages.
  24927. Defaults to @samp{"/share/cgit/cgit.css"}.
  24928. @end deftypevr
  24929. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  24930. Specifies a command which will be invoked to format names and email
  24931. address of committers, authors, and taggers, as represented in various
  24932. places throughout the cgit interface.
  24933. Defaults to @samp{""}.
  24934. @end deftypevr
  24935. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  24936. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  24937. fragment suitable for embedding in other HTML pages.
  24938. Defaults to @samp{#f}.
  24939. @end deftypevr
  24940. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  24941. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  24942. commit history graph to the left of the commit messages in the
  24943. repository log page.
  24944. Defaults to @samp{#f}.
  24945. @end deftypevr
  24946. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  24947. Flag which, when set to @samp{#t}, allows all filter settings to be
  24948. overridden in repository-specific cgitrc files.
  24949. Defaults to @samp{#f}.
  24950. @end deftypevr
  24951. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  24952. Flag which, when set to @samp{#t}, allows users to follow a file in the
  24953. log view.
  24954. Defaults to @samp{#f}.
  24955. @end deftypevr
  24956. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  24957. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  24958. clones.
  24959. Defaults to @samp{#t}.
  24960. @end deftypevr
  24961. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  24962. Flag which, when set to @samp{#t}, will make cgit generate extra links
  24963. "summary", "commit", "tree" for each repo in the repository index.
  24964. Defaults to @samp{#f}.
  24965. @end deftypevr
  24966. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  24967. Flag which, when set to @samp{#t}, will make cgit display the owner of
  24968. each repo in the repository index.
  24969. Defaults to @samp{#t}.
  24970. @end deftypevr
  24971. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  24972. Flag which, when set to @samp{#t}, will make cgit print the number of
  24973. modified files for each commit on the repository log page.
  24974. Defaults to @samp{#f}.
  24975. @end deftypevr
  24976. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  24977. Flag which, when set to @samp{#t}, will make cgit print the number of
  24978. added and removed lines for each commit on the repository log page.
  24979. Defaults to @samp{#f}.
  24980. @end deftypevr
  24981. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  24982. Flag which, when set to @code{#t}, will make cgit display remote
  24983. branches in the summary and refs views.
  24984. Defaults to @samp{#f}.
  24985. @end deftypevr
  24986. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  24987. Flag which, when set to @code{1}, will make cgit use the subject of the
  24988. parent commit as link text when generating links to parent commits in
  24989. commit view.
  24990. Defaults to @samp{#f}.
  24991. @end deftypevr
  24992. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  24993. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  24994. parent commit as link text when generating links to parent commits in
  24995. commit view.
  24996. Defaults to @samp{#f}.
  24997. @end deftypevr
  24998. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  24999. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  25000. links for plaintext blobs printed in the tree view.
  25001. Defaults to @samp{#t}.
  25002. @end deftypevr
  25003. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  25004. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  25005. set any repo specific settings.
  25006. Defaults to @samp{#f}.
  25007. @end deftypevr
  25008. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  25009. URL used as link to a shortcut icon for cgit.
  25010. Defaults to @samp{"/favicon.ico"}.
  25011. @end deftypevr
  25012. @deftypevr {@code{cgit-configuration} parameter} string footer
  25013. The content of the file specified with this option will be included
  25014. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  25015. "generated by..."@: message).
  25016. Defaults to @samp{""}.
  25017. @end deftypevr
  25018. @deftypevr {@code{cgit-configuration} parameter} string head-include
  25019. The content of the file specified with this option will be included
  25020. verbatim in the HTML HEAD section on all pages.
  25021. Defaults to @samp{""}.
  25022. @end deftypevr
  25023. @deftypevr {@code{cgit-configuration} parameter} string header
  25024. The content of the file specified with this option will be included
  25025. verbatim at the top of all pages.
  25026. Defaults to @samp{""}.
  25027. @end deftypevr
  25028. @deftypevr {@code{cgit-configuration} parameter} file-object include
  25029. Name of a configfile to include before the rest of the current config-
  25030. file is parsed.
  25031. Defaults to @samp{""}.
  25032. @end deftypevr
  25033. @deftypevr {@code{cgit-configuration} parameter} string index-header
  25034. The content of the file specified with this option will be included
  25035. verbatim above the repository index.
  25036. Defaults to @samp{""}.
  25037. @end deftypevr
  25038. @deftypevr {@code{cgit-configuration} parameter} string index-info
  25039. The content of the file specified with this option will be included
  25040. verbatim below the heading on the repository index page.
  25041. Defaults to @samp{""}.
  25042. @end deftypevr
  25043. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  25044. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  25045. in the servers timezone.
  25046. Defaults to @samp{#f}.
  25047. @end deftypevr
  25048. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  25049. URL which specifies the source of an image which will be used as a logo
  25050. on all cgit pages.
  25051. Defaults to @samp{"/share/cgit/cgit.png"}.
  25052. @end deftypevr
  25053. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  25054. URL loaded when clicking on the cgit logo image.
  25055. Defaults to @samp{""}.
  25056. @end deftypevr
  25057. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  25058. Command which will be invoked to format the Owner column of the main
  25059. page.
  25060. Defaults to @samp{""}.
  25061. @end deftypevr
  25062. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  25063. Number of items to display in atom feeds view.
  25064. Defaults to @samp{10}.
  25065. @end deftypevr
  25066. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  25067. Number of entries to list per page in "log" view.
  25068. Defaults to @samp{50}.
  25069. @end deftypevr
  25070. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  25071. Number of commit message characters to display in "log" view.
  25072. Defaults to @samp{80}.
  25073. @end deftypevr
  25074. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  25075. Specifies the number of entries to list per page on the repository index
  25076. page.
  25077. Defaults to @samp{50}.
  25078. @end deftypevr
  25079. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  25080. Specifies the maximum number of repo description characters to display
  25081. on the repository index page.
  25082. Defaults to @samp{80}.
  25083. @end deftypevr
  25084. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  25085. Specifies the maximum size of a blob to display HTML for in KBytes.
  25086. Defaults to @samp{0}.
  25087. @end deftypevr
  25088. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  25089. Maximum statistics period. Valid values are @samp{week},@samp{month},
  25090. @samp{quarter} and @samp{year}.
  25091. Defaults to @samp{""}.
  25092. @end deftypevr
  25093. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  25094. Mimetype for the specified filename extension.
  25095. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  25096. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  25097. "image/png") (svg "image/svg+xml"))}.
  25098. @end deftypevr
  25099. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  25100. Specifies the file to use for automatic mimetype lookup.
  25101. Defaults to @samp{""}.
  25102. @end deftypevr
  25103. @deftypevr {@code{cgit-configuration} parameter} string module-link
  25104. Text which will be used as the formatstring for a hyperlink when a
  25105. submodule is printed in a directory listing.
  25106. Defaults to @samp{""}.
  25107. @end deftypevr
  25108. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  25109. If set to the value @samp{#t} caching will be disabled.
  25110. Defaults to @samp{#f}.
  25111. @end deftypevr
  25112. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  25113. If set to @samp{#t} showing full author email addresses will be
  25114. disabled.
  25115. Defaults to @samp{#f}.
  25116. @end deftypevr
  25117. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  25118. Flag which, when set to @samp{#t}, will make cgit omit the standard
  25119. header on all pages.
  25120. Defaults to @samp{#f}.
  25121. @end deftypevr
  25122. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  25123. A list of subdirectories inside of @code{repository-directory}, relative
  25124. to it, that should loaded as Git repositories. An empty list means that
  25125. all subdirectories will be loaded.
  25126. Defaults to @samp{()}.
  25127. @end deftypevr
  25128. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  25129. Text which will be used as default value for @code{cgit-repo-readme}.
  25130. Defaults to @samp{""}.
  25131. @end deftypevr
  25132. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  25133. If set to @code{#t} and @code{repository-directory} is enabled, if any
  25134. repositories are found with a suffix of @code{.git}, this suffix will be
  25135. removed for the URL and name.
  25136. Defaults to @samp{#f}.
  25137. @end deftypevr
  25138. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  25139. Maximum number of files to consider when detecting renames.
  25140. Defaults to @samp{-1}.
  25141. @end deftypevr
  25142. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  25143. The way in which repositories in each section are sorted.
  25144. Defaults to @samp{""}.
  25145. @end deftypevr
  25146. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  25147. Text used as content for the @code{robots} meta-tag.
  25148. Defaults to @samp{("noindex" "nofollow")}.
  25149. @end deftypevr
  25150. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  25151. Text printed below the heading on the repository index page.
  25152. Defaults to @samp{"a fast webinterface for the git dscm"}.
  25153. @end deftypevr
  25154. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  25155. The content of the file specified with this option will be included
  25156. verbatim below the ``about'' link on the repository index page.
  25157. Defaults to @samp{""}.
  25158. @end deftypevr
  25159. @deftypevr {@code{cgit-configuration} parameter} string root-title
  25160. Text printed as heading on the repository index page.
  25161. Defaults to @samp{""}.
  25162. @end deftypevr
  25163. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  25164. If set to @samp{#t} and repository-directory is enabled,
  25165. repository-directory will recurse into directories whose name starts
  25166. with a period. Otherwise, repository-directory will stay away from such
  25167. directories, considered as ``hidden''. Note that this does not apply to
  25168. the @file{.git} directory in non-bare repos.
  25169. Defaults to @samp{#f}.
  25170. @end deftypevr
  25171. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  25172. Text which specifies the default set of snapshot formats that cgit
  25173. generates links for.
  25174. Defaults to @samp{()}.
  25175. @end deftypevr
  25176. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  25177. Name of the directory to scan for repositories (represents
  25178. @code{scan-path}).
  25179. Defaults to @samp{"/srv/git"}.
  25180. @end deftypevr
  25181. @deftypevr {@code{cgit-configuration} parameter} string section
  25182. The name of the current repository section - all repositories defined
  25183. after this option will inherit the current section name.
  25184. Defaults to @samp{""}.
  25185. @end deftypevr
  25186. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  25187. Flag which, when set to @samp{1}, will sort the sections on the
  25188. repository listing by name.
  25189. Defaults to @samp{""}.
  25190. @end deftypevr
  25191. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  25192. A number which, if defined prior to repository-directory, specifies how
  25193. many path elements from each repo path to use as a default section name.
  25194. Defaults to @samp{0}.
  25195. @end deftypevr
  25196. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  25197. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  25198. default.
  25199. Defaults to @samp{#f}.
  25200. @end deftypevr
  25201. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  25202. Specifies a command which will be invoked to format plaintext blobs in
  25203. the tree view.
  25204. Defaults to @samp{""}.
  25205. @end deftypevr
  25206. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  25207. Specifies the number of branches to display in the repository ``summary''
  25208. view.
  25209. Defaults to @samp{10}.
  25210. @end deftypevr
  25211. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  25212. Specifies the number of log entries to display in the repository
  25213. ``summary'' view.
  25214. Defaults to @samp{10}.
  25215. @end deftypevr
  25216. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  25217. Specifies the number of tags to display in the repository ``summary''
  25218. view.
  25219. Defaults to @samp{10}.
  25220. @end deftypevr
  25221. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  25222. Filename which, if specified, needs to be present within the repository
  25223. for cgit to allow access to that repository.
  25224. Defaults to @samp{""}.
  25225. @end deftypevr
  25226. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  25227. URL which, if specified, will be used as root for all cgit links.
  25228. Defaults to @samp{"/"}.
  25229. @end deftypevr
  25230. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  25231. A list of @dfn{cgit-repo} records to use with config.
  25232. Defaults to @samp{()}.
  25233. Available @code{repository-cgit-configuration} fields are:
  25234. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  25235. A mask of snapshot formats for this repo that cgit generates links for,
  25236. restricted by the global @code{snapshots} setting.
  25237. Defaults to @samp{()}.
  25238. @end deftypevr
  25239. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  25240. Override the default @code{source-filter}.
  25241. Defaults to @samp{""}.
  25242. @end deftypevr
  25243. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  25244. The relative URL used to access the repository.
  25245. Defaults to @samp{""}.
  25246. @end deftypevr
  25247. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  25248. Override the default @code{about-filter}.
  25249. Defaults to @samp{""}.
  25250. @end deftypevr
  25251. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  25252. Flag which, when set to @samp{age}, enables date ordering in the branch
  25253. ref list, and when set to @samp{name} enables ordering by branch name.
  25254. Defaults to @samp{""}.
  25255. @end deftypevr
  25256. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  25257. A list of URLs which can be used to clone repo.
  25258. Defaults to @samp{()}.
  25259. @end deftypevr
  25260. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  25261. Override the default @code{commit-filter}.
  25262. Defaults to @samp{""}.
  25263. @end deftypevr
  25264. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  25265. Flag which, when set to @samp{date}, enables strict date ordering in the
  25266. commit log, and when set to @samp{topo} enables strict topological
  25267. ordering.
  25268. Defaults to @samp{""}.
  25269. @end deftypevr
  25270. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  25271. The name of the default branch for this repository. If no such branch
  25272. exists in the repository, the first branch name (when sorted) is used as
  25273. default instead. By default branch pointed to by HEAD, or ``master'' if
  25274. there is no suitable HEAD.
  25275. Defaults to @samp{""}.
  25276. @end deftypevr
  25277. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  25278. The value to show as repository description.
  25279. Defaults to @samp{""}.
  25280. @end deftypevr
  25281. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  25282. The value to show as repository homepage.
  25283. Defaults to @samp{""}.
  25284. @end deftypevr
  25285. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  25286. Override the default @code{email-filter}.
  25287. Defaults to @samp{""}.
  25288. @end deftypevr
  25289. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  25290. A flag which can be used to disable the global setting
  25291. @code{enable-commit-graph?}.
  25292. Defaults to @samp{disabled}.
  25293. @end deftypevr
  25294. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  25295. A flag which can be used to disable the global setting
  25296. @code{enable-log-filecount?}.
  25297. Defaults to @samp{disabled}.
  25298. @end deftypevr
  25299. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  25300. A flag which can be used to disable the global setting
  25301. @code{enable-log-linecount?}.
  25302. Defaults to @samp{disabled}.
  25303. @end deftypevr
  25304. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  25305. Flag which, when set to @code{#t}, will make cgit display remote
  25306. branches in the summary and refs views.
  25307. Defaults to @samp{disabled}.
  25308. @end deftypevr
  25309. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  25310. A flag which can be used to override the global setting
  25311. @code{enable-subject-links?}.
  25312. Defaults to @samp{disabled}.
  25313. @end deftypevr
  25314. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  25315. A flag which can be used to override the global setting
  25316. @code{enable-html-serving?}.
  25317. Defaults to @samp{disabled}.
  25318. @end deftypevr
  25319. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  25320. Flag which, when set to @code{#t}, hides the repository from the
  25321. repository index.
  25322. Defaults to @samp{#f}.
  25323. @end deftypevr
  25324. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  25325. Flag which, when set to @samp{#t}, ignores the repository.
  25326. Defaults to @samp{#f}.
  25327. @end deftypevr
  25328. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  25329. URL which specifies the source of an image which will be used as a logo
  25330. on this repo’s pages.
  25331. Defaults to @samp{""}.
  25332. @end deftypevr
  25333. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  25334. URL loaded when clicking on the cgit logo image.
  25335. Defaults to @samp{""}.
  25336. @end deftypevr
  25337. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  25338. Override the default @code{owner-filter}.
  25339. Defaults to @samp{""}.
  25340. @end deftypevr
  25341. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  25342. Text which will be used as the formatstring for a hyperlink when a
  25343. submodule is printed in a directory listing. The arguments for the
  25344. formatstring are the path and SHA1 of the submodule commit.
  25345. Defaults to @samp{""}.
  25346. @end deftypevr
  25347. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  25348. Text which will be used as the formatstring for a hyperlink when a
  25349. submodule with the specified subdirectory path is printed in a directory
  25350. listing.
  25351. Defaults to @samp{()}.
  25352. @end deftypevr
  25353. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  25354. Override the default maximum statistics period.
  25355. Defaults to @samp{""}.
  25356. @end deftypevr
  25357. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  25358. The value to show as repository name.
  25359. Defaults to @samp{""}.
  25360. @end deftypevr
  25361. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  25362. A value used to identify the owner of the repository.
  25363. Defaults to @samp{""}.
  25364. @end deftypevr
  25365. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  25366. An absolute path to the repository directory.
  25367. Defaults to @samp{""}.
  25368. @end deftypevr
  25369. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  25370. A path (relative to repo) which specifies a file to include verbatim as
  25371. the ``About'' page for this repo.
  25372. Defaults to @samp{""}.
  25373. @end deftypevr
  25374. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  25375. The name of the current repository section - all repositories defined
  25376. after this option will inherit the current section name.
  25377. Defaults to @samp{""}.
  25378. @end deftypevr
  25379. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  25380. Extra options will be appended to cgitrc file.
  25381. Defaults to @samp{()}.
  25382. @end deftypevr
  25383. @end deftypevr
  25384. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  25385. Extra options will be appended to cgitrc file.
  25386. Defaults to @samp{()}.
  25387. @end deftypevr
  25388. @c %end of fragment
  25389. However, it could be that you just want to get a @code{cgitrc} up and
  25390. running. In that case, you can pass an @code{opaque-cgit-configuration}
  25391. as a record to @code{cgit-service-type}. As its name indicates, an
  25392. opaque configuration does not have easy reflective capabilities.
  25393. Available @code{opaque-cgit-configuration} fields are:
  25394. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  25395. The cgit package.
  25396. @end deftypevr
  25397. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  25398. The contents of the @code{cgitrc}, as a string.
  25399. @end deftypevr
  25400. For example, if your @code{cgitrc} is just the empty string, you
  25401. could instantiate a cgit service like this:
  25402. @lisp
  25403. (service cgit-service-type
  25404. (opaque-cgit-configuration
  25405. (cgitrc "")))
  25406. @end lisp
  25407. @subsubheading Gitolite Service
  25408. @cindex Gitolite service
  25409. @cindex Git, hosting
  25410. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  25411. repositories on a central server.
  25412. Gitolite can handle multiple repositories and users, and supports flexible
  25413. configuration of the permissions for the users on the repositories.
  25414. The following example will configure Gitolite using the default @code{git}
  25415. user, and the provided SSH public key.
  25416. @lisp
  25417. (service gitolite-service-type
  25418. (gitolite-configuration
  25419. (admin-pubkey (plain-file
  25420. "yourname.pub"
  25421. "ssh-rsa AAAA... guix@@example.com"))))
  25422. @end lisp
  25423. Gitolite is configured through a special admin repository which you can clone,
  25424. for example, if you setup Gitolite on @code{example.com}, you would run the
  25425. following command to clone the admin repository.
  25426. @example
  25427. git clone git@@example.com:gitolite-admin
  25428. @end example
  25429. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  25430. be inserted in to the @file{keydir} directory in the gitolite-admin
  25431. repository. If this results in a change in the repository, it will be
  25432. committed using the message ``gitolite setup by GNU Guix''.
  25433. @deftp {Data Type} gitolite-configuration
  25434. Data type representing the configuration for @code{gitolite-service-type}.
  25435. @table @asis
  25436. @item @code{package} (default: @var{gitolite})
  25437. Gitolite package to use.
  25438. @item @code{user} (default: @var{git})
  25439. User to use for Gitolite. This will be user that you use when accessing
  25440. Gitolite over SSH.
  25441. @item @code{group} (default: @var{git})
  25442. Group to use for Gitolite.
  25443. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  25444. Directory in which to store the Gitolite configuration and repositories.
  25445. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  25446. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  25447. representing the configuration for Gitolite.
  25448. @item @code{admin-pubkey} (default: @var{#f})
  25449. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  25450. setup Gitolite. This will be inserted in to the @file{keydir} directory
  25451. within the gitolite-admin repository.
  25452. To specify the SSH key as a string, use the @code{plain-file} function.
  25453. @lisp
  25454. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  25455. @end lisp
  25456. @end table
  25457. @end deftp
  25458. @deftp {Data Type} gitolite-rc-file
  25459. Data type representing the Gitolite RC file.
  25460. @table @asis
  25461. @item @code{umask} (default: @code{#o0077})
  25462. This controls the permissions Gitolite sets on the repositories and their
  25463. contents.
  25464. A value like @code{#o0027} will give read access to the group used by Gitolite
  25465. (by default: @code{git}). This is necessary when using Gitolite with software
  25466. like cgit or gitweb.
  25467. @item @code{unsafe-pattern} (default: @code{#f})
  25468. An optional Perl regular expression for catching unsafe configurations in
  25469. the configuration file. See
  25470. @uref{https://gitolite.com/gitolite/git-config.html#compensating-for-unsafe_patt,
  25471. Gitolite's documentation} for more information.
  25472. When the value is not @code{#f}, it should be a string containing a Perl
  25473. regular expression, such as @samp{"[`~#\$\&()|;<>]"}, which is the default
  25474. value used by gitolite. It rejects any special character in configuration
  25475. that might be interpreted by a shell, which is useful when sharing the
  25476. administration burden with other people that do not otherwise have shell
  25477. access on the server.
  25478. @item @code{git-config-keys} (default: @code{""})
  25479. Gitolite allows you to set git config values using the @samp{config}
  25480. keyword. This setting allows control over the config keys to accept.
  25481. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  25482. Set the role names allowed to be used by users running the perms command.
  25483. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  25484. This setting controls the commands and features to enable within Gitolite.
  25485. @end table
  25486. @end deftp
  25487. @subsubheading Gitile Service
  25488. @cindex Gitile service
  25489. @cindex Git, forge
  25490. @uref{https://git.lepiller.eu/gitile, Gitile} is a Git forge for viewing
  25491. public git repository contents from a web browser.
  25492. Gitile works best in collaboration with Gitolite, and will serve the public
  25493. repositories from Gitolite by default. The service should listen only on
  25494. a local port, and a webserver should be configured to serve static resources.
  25495. The gitile service provides an easy way to extend the Nginx service for
  25496. that purpose (@pxref{NGINX}).
  25497. The following example will configure Gitile to serve repositories from a
  25498. custom location, with some default messages for the home page and the
  25499. footers.
  25500. @lisp
  25501. (service gitile-service-type
  25502. (gitile-configuration
  25503. (repositories "/srv/git")
  25504. (base-git-url "https://myweb.site/git")
  25505. (index-title "My git repositories")
  25506. (intro '((p "This is all my public work!")))
  25507. (footer '((p "This is the end")))
  25508. (nginx-server-block
  25509. (nginx-server-configuration
  25510. (ssl-certificate
  25511. "/etc/letsencrypt/live/myweb.site/fullchain.pem")
  25512. (ssl-certificate-key
  25513. "/etc/letsencrypt/live/myweb.site/privkey.pem")
  25514. (listen '("443 ssl http2" "[::]:443 ssl http2"))
  25515. (locations
  25516. (list
  25517. ;; Allow for https anonymous fetch on /git/ urls.
  25518. (git-http-nginx-location-configuration
  25519. (git-http-configuration
  25520. (uri-path "/git/")
  25521. (git-root "/var/lib/gitolite/repositories")))))))))
  25522. @end lisp
  25523. In addition to the configuration record, you should configure your git
  25524. repositories to contain some optional information. First, your public
  25525. repositories need to contain the @file{git-daemon-export-ok} magic file
  25526. that allows Git to export the repository. Gitile uses the presence of this
  25527. file to detect public repositories it should make accessible. To do so with
  25528. Gitolite for instance, modify your @file{conf/gitolite.conf} to include
  25529. this in the repositories you want to make public:
  25530. @example
  25531. repo foo
  25532. R = daemon
  25533. @end example
  25534. In addition, Gitile can read the repository configuration to display more
  25535. information on the repository. Gitile uses the gitweb namespace for its
  25536. configuration. As an example, you can use the following in your
  25537. @file{conf/gitolite.conf}:
  25538. @example
  25539. repo foo
  25540. R = daemon
  25541. desc = A long description, optionally with <i>HTML</i>, shown on the index page
  25542. config gitweb.name = The Foo Project
  25543. config gitweb.synopsis = A short description, shown on the main page of the project
  25544. @end example
  25545. Do not forget to commit and push these changes once you are satisfied. You
  25546. may need to change your gitolite configuration to allow the previous
  25547. configuration options to be set. One way to do that is to add the
  25548. following service definition:
  25549. @lisp
  25550. (service gitolite-service-type
  25551. (gitolite-configuration
  25552. (admin-pubkey (local-file "key.pub"))
  25553. (rc-file
  25554. (gitolite-rc-file
  25555. (umask #o0027)
  25556. ;; Allow to set any configuration key
  25557. (git-config-keys ".*")
  25558. ;; Allow any text as a valid configuration value
  25559. (unsafe-patt "^$")))))
  25560. @end lisp
  25561. @deftp {Data Type} gitile-configuration
  25562. Data type representing the configuration for @code{gitile-service-type}.
  25563. @table @asis
  25564. @item @code{package} (default: @var{gitile})
  25565. Gitile package to use.
  25566. @item @code{host} (default: @code{"localhost"})
  25567. The host on which gitile is listening.
  25568. @item @code{port} (default: @code{8080})
  25569. The port on which gitile is listening.
  25570. @item @code{database} (default: @code{"/var/lib/gitile/gitile-db.sql"})
  25571. The location of the database.
  25572. @item @code{repositories} (default: @code{"/var/lib/gitolite/repositories"})
  25573. The location of the repositories. Note that only public repositories will
  25574. be shown by Gitile. To make a repository public, add an empty
  25575. @file{git-daemon-export-ok} file at the root of that repository.
  25576. @item @code{base-git-url}
  25577. The base git url that will be used to show clone commands.
  25578. @item @code{index-title} (default: @code{"Index"})
  25579. The page title for the index page that lists all the available repositories.
  25580. @item @code{intro} (default: @code{'()})
  25581. The intro content, as a list of sxml expressions. This is shown above the list
  25582. of repositories, on the index page.
  25583. @item @code{footer} (default: @code{'()})
  25584. The footer content, as a list of sxml expressions. This is shown on every
  25585. page served by Gitile.
  25586. @item @code{nginx-server-block}
  25587. An nginx server block that will be extended and used as a reverse proxy by
  25588. Gitile to serve its pages, and as a normal web server to serve its assets.
  25589. You can use this block to add more custom URLs to your domain, such as a
  25590. @code{/git/} URL for anonymous clones, or serving any other files you would
  25591. like to serve.
  25592. @end table
  25593. @end deftp
  25594. @node Game Services
  25595. @subsection Game Services
  25596. @subsubheading The Battle for Wesnoth Service
  25597. @cindex wesnothd
  25598. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  25599. based tactical strategy game, with several single player campaigns, and
  25600. multiplayer games (both networked and local).
  25601. @defvar {Scheme Variable} wesnothd-service-type
  25602. Service type for the wesnothd service. Its value must be a
  25603. @code{wesnothd-configuration} object. To run wesnothd in the default
  25604. configuration, instantiate it as:
  25605. @lisp
  25606. (service wesnothd-service-type)
  25607. @end lisp
  25608. @end defvar
  25609. @deftp {Data Type} wesnothd-configuration
  25610. Data type representing the configuration of @command{wesnothd}.
  25611. @table @asis
  25612. @item @code{package} (default: @code{wesnoth-server})
  25613. The wesnoth server package to use.
  25614. @item @code{port} (default: @code{15000})
  25615. The port to bind the server to.
  25616. @end table
  25617. @end deftp
  25618. @node PAM Mount Service
  25619. @subsection PAM Mount Service
  25620. @cindex pam-mount
  25621. The @code{(gnu services pam-mount)} module provides a service allowing
  25622. users to mount volumes when they log in. It should be able to mount any
  25623. volume format supported by the system.
  25624. @defvar {Scheme Variable} pam-mount-service-type
  25625. Service type for PAM Mount support.
  25626. @end defvar
  25627. @deftp {Data Type} pam-mount-configuration
  25628. Data type representing the configuration of PAM Mount.
  25629. It takes the following parameters:
  25630. @table @asis
  25631. @item @code{rules}
  25632. The configuration rules that will be used to generate
  25633. @file{/etc/security/pam_mount.conf.xml}.
  25634. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  25635. Guile Reference Manual}), and the default ones don't mount anything for
  25636. anyone at login:
  25637. @lisp
  25638. `((debug (@@ (enable "0")))
  25639. (mntoptions (@@ (allow ,(string-join
  25640. '("nosuid" "nodev" "loop"
  25641. "encryption" "fsck" "nonempty"
  25642. "allow_root" "allow_other")
  25643. ","))))
  25644. (mntoptions (@@ (require "nosuid,nodev")))
  25645. (logout (@@ (wait "0")
  25646. (hup "0")
  25647. (term "no")
  25648. (kill "no")))
  25649. (mkmountpoint (@@ (enable "1")
  25650. (remove "true"))))
  25651. @end lisp
  25652. Some @code{volume} elements must be added to automatically mount volumes
  25653. at login. Here's an example allowing the user @code{alice} to mount her
  25654. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  25655. the partition where he stores his data:
  25656. @lisp
  25657. (define pam-mount-rules
  25658. `((debug (@@ (enable "0")))
  25659. (volume (@@ (user "alice")
  25660. (fstype "crypt")
  25661. (path "/dev/sda2")
  25662. (mountpoint "/home/alice")))
  25663. (volume (@@ (user "bob")
  25664. (fstype "auto")
  25665. (path "/dev/sdb3")
  25666. (mountpoint "/home/bob/data")
  25667. (options "defaults,autodefrag,compress")))
  25668. (mntoptions (@@ (allow ,(string-join
  25669. '("nosuid" "nodev" "loop"
  25670. "encryption" "fsck" "nonempty"
  25671. "allow_root" "allow_other")
  25672. ","))))
  25673. (mntoptions (@@ (require "nosuid,nodev")))
  25674. (logout (@@ (wait "0")
  25675. (hup "0")
  25676. (term "no")
  25677. (kill "no")))
  25678. (mkmountpoint (@@ (enable "1")
  25679. (remove "true")))))
  25680. (service pam-mount-service-type
  25681. (pam-mount-configuration
  25682. (rules pam-mount-rules)))
  25683. @end lisp
  25684. The complete list of possible options can be found in the man page for
  25685. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  25686. @end table
  25687. @end deftp
  25688. @node Guix Services
  25689. @subsection Guix Services
  25690. @subsubheading Guix Build Coordinator
  25691. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  25692. Coordinator} aids in distributing derivation builds among machines
  25693. running an @dfn{agent}. The build daemon is still used to build the
  25694. derivations, but the Guix Build Coordinator manages allocating builds
  25695. and working with the results.
  25696. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  25697. more connected @dfn{agent} processes. The coordinator process handles
  25698. clients submitting builds, and allocating builds to agents. The agent
  25699. processes talk to a build daemon to actually perform the builds, then
  25700. send the results back to the coordinator.
  25701. There is a script to run the coordinator component of the Guix Build
  25702. Coordinator, but the Guix service uses a custom Guile script instead, to
  25703. provide better integration with G-expressions used in the configuration.
  25704. @defvar {Scheme Variable} guix-build-coordinator-service-type
  25705. Service type for the Guix Build Coordinator. Its value must be a
  25706. @code{guix-build-coordinator-configuration} object.
  25707. @end defvar
  25708. @deftp {Data Type} guix-build-coordinator-configuration
  25709. Data type representing the configuration of the Guix Build Coordinator.
  25710. @table @asis
  25711. @item @code{package} (default: @code{guix-build-coordinator})
  25712. The Guix Build Coordinator package to use.
  25713. @item @code{user} (default: @code{"guix-build-coordinator"})
  25714. The system user to run the service as.
  25715. @item @code{group} (default: @code{"guix-build-coordinator"})
  25716. The system group to run the service as.
  25717. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  25718. The URI to use for the database.
  25719. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  25720. The URI describing how to listen to requests from agent processes.
  25721. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  25722. The URI describing how to listen to requests from clients. The client
  25723. API allows submitting builds and currently isn't authenticated, so take
  25724. care when configuring this value.
  25725. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  25726. A G-expression for the allocation strategy to be used. This is a
  25727. procedure that takes the datastore as an argument and populates the
  25728. allocation plan in the database.
  25729. @item @code{hooks} (default: @var{'()})
  25730. An association list of hooks. These provide a way to execute arbitrary
  25731. code upon certain events, like a build result being processed.
  25732. @item @code{guile} (default: @code{guile-3.0-latest})
  25733. The Guile package with which to run the Guix Build Coordinator.
  25734. @end table
  25735. @end deftp
  25736. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  25737. Service type for a Guix Build Coordinator agent. Its value must be a
  25738. @code{guix-build-coordinator-agent-configuration} object.
  25739. @end defvar
  25740. @deftp {Data Type} guix-build-coordinator-agent-configuration
  25741. Data type representing the configuration a Guix Build Coordinator agent.
  25742. @table @asis
  25743. @item @code{package} (default: @code{guix-build-coordinator/agent-only})
  25744. The Guix Build Coordinator package to use.
  25745. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  25746. The system user to run the service as.
  25747. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  25748. The URI to use when connecting to the coordinator.
  25749. @item @code{authentication}
  25750. Record describing how this agent should authenticate with the
  25751. coordinator. Possible record types are described below.
  25752. @item @code{systems} (default: @code{#f})
  25753. The systems for which this agent should fetch builds. The agent process
  25754. will use the current system it's running on as the default.
  25755. @item @code{max-parallel-builds} (default: @code{1})
  25756. The number of builds to perform in parallel.
  25757. @item @code{max-1min-load-average} (default: @code{#f})
  25758. Load average value to look at when considering starting new builds, if
  25759. the 1 minute load average exceeds this value, the agent will wait before
  25760. starting new builds.
  25761. This will be unspecified if the value is @code{#f}, and the agent will
  25762. use the number of cores reported by the system as the max 1 minute load
  25763. average.
  25764. @item @code{derivation-substitute-urls} (default: @code{#f})
  25765. URLs from which to attempt to fetch substitutes for derivations, if the
  25766. derivations aren't already available.
  25767. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  25768. URLs from which to attempt to fetch substitutes for build inputs, if the
  25769. input store items aren't already available.
  25770. @end table
  25771. @end deftp
  25772. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  25773. Data type representing an agent authenticating with a coordinator via a
  25774. UUID and password.
  25775. @table @asis
  25776. @item @code{uuid}
  25777. The UUID of the agent. This should be generated by the coordinator
  25778. process, stored in the coordinator database, and used by the intended
  25779. agent.
  25780. @item @code{password}
  25781. The password to use when connecting to the coordinator.
  25782. @end table
  25783. @end deftp
  25784. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  25785. Data type representing an agent authenticating with a coordinator via a
  25786. UUID and password read from a file.
  25787. @table @asis
  25788. @item @code{uuid}
  25789. The UUID of the agent. This should be generated by the coordinator
  25790. process, stored in the coordinator database, and used by the intended
  25791. agent.
  25792. @item @code{password-file}
  25793. A file containing the password to use when connecting to the
  25794. coordinator.
  25795. @end table
  25796. @end deftp
  25797. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  25798. Data type representing an agent authenticating with a coordinator via a
  25799. dynamic auth token and agent name.
  25800. @table @asis
  25801. @item @code{agent-name}
  25802. Name of an agent, this is used to match up to an existing entry in the
  25803. database if there is one. When no existing entry is found, a new entry
  25804. is automatically added.
  25805. @item @code{token}
  25806. Dynamic auth token, this is created and stored in the coordinator
  25807. database, and is used by the agent to authenticate.
  25808. @end table
  25809. @end deftp
  25810. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  25811. Data type representing an agent authenticating with a coordinator via a
  25812. dynamic auth token read from a file and agent name.
  25813. @table @asis
  25814. @item @code{agent-name}
  25815. Name of an agent, this is used to match up to an existing entry in the
  25816. database if there is one. When no existing entry is found, a new entry
  25817. is automatically added.
  25818. @item @code{token-file}
  25819. File containing the dynamic auth token, this is created and stored in
  25820. the coordinator database, and is used by the agent to authenticate.
  25821. @end table
  25822. @end deftp
  25823. The Guix Build Coordinator package contains a script to query an
  25824. instance of the Guix Data Service for derivations to build, and then
  25825. submit builds for those derivations to the coordinator. The service
  25826. type below assists in running this script. This is an additional tool
  25827. that may be useful when building derivations contained within an
  25828. instance of the Guix Data Service.
  25829. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  25830. Service type for the
  25831. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  25832. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  25833. object.
  25834. @end defvar
  25835. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  25836. Data type representing the options to the queue builds from guix data
  25837. service script.
  25838. @table @asis
  25839. @item @code{package} (default: @code{guix-build-coordinator})
  25840. The Guix Build Coordinator package to use.
  25841. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  25842. The system user to run the service as.
  25843. @item @code{coordinator} (default: @code{"http://localhost:8746"})
  25844. The URI to use when connecting to the coordinator.
  25845. @item @code{systems} (default: @code{#f})
  25846. The systems for which to fetch derivations to build.
  25847. @item @code{systems-and-targets} (default: @code{#f})
  25848. An association list of system and target pairs for which to fetch
  25849. derivations to build.
  25850. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  25851. The Guix Data Service instance from which to query to find out about
  25852. derivations to build.
  25853. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  25854. A file to record which commits have been processed, to avoid needlessly
  25855. processing them again if the service is restarted.
  25856. @end table
  25857. @end deftp
  25858. @subsubheading Guix Data Service
  25859. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  25860. and provides data about GNU Guix. This includes information about
  25861. packages, derivations and lint warnings.
  25862. The data is stored in a PostgreSQL database, and available through a web
  25863. interface.
  25864. @defvar {Scheme Variable} guix-data-service-type
  25865. Service type for the Guix Data Service. Its value must be a
  25866. @code{guix-data-service-configuration} object. The service optionally
  25867. extends the getmail service, as the guix-commits mailing list is used to
  25868. find out about changes in the Guix git repository.
  25869. @end defvar
  25870. @deftp {Data Type} guix-data-service-configuration
  25871. Data type representing the configuration of the Guix Data Service.
  25872. @table @asis
  25873. @item @code{package} (default: @code{guix-data-service})
  25874. The Guix Data Service package to use.
  25875. @item @code{user} (default: @code{"guix-data-service"})
  25876. The system user to run the service as.
  25877. @item @code{group} (default: @code{"guix-data-service"})
  25878. The system group to run the service as.
  25879. @item @code{port} (default: @code{8765})
  25880. The port to bind the web service to.
  25881. @item @code{host} (default: @code{"127.0.0.1"})
  25882. The host to bind the web service to.
  25883. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  25884. If set, this is the list of mailboxes that the getmail service will be
  25885. configured to listen to.
  25886. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  25887. If set, this is the @code{getmail-retriever-configuration} object with
  25888. which to configure getmail to fetch mail from the guix-commits mailing
  25889. list.
  25890. @item @code{extra-options} (default: @var{'()})
  25891. Extra command line options for @code{guix-data-service}.
  25892. @item @code{extra-process-jobs-options} (default: @var{'()})
  25893. Extra command line options for @code{guix-data-service-process-jobs}.
  25894. @end table
  25895. @end deftp
  25896. @node Linux Services
  25897. @subsection Linux Services
  25898. @cindex oom
  25899. @cindex out of memory killer
  25900. @cindex earlyoom
  25901. @cindex early out of memory daemon
  25902. @subsubheading Early OOM Service
  25903. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  25904. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  25905. space and provides a more responsive and configurable alternative to the
  25906. in-kernel OOM killer. It is useful to prevent the system from becoming
  25907. unresponsive when it runs out of memory.
  25908. @deffn {Scheme Variable} earlyoom-service-type
  25909. The service type for running @command{earlyoom}, the Early OOM daemon.
  25910. Its value must be a @code{earlyoom-configuration} object, described
  25911. below. The service can be instantiated in its default configuration
  25912. with:
  25913. @lisp
  25914. (service earlyoom-service-type)
  25915. @end lisp
  25916. @end deffn
  25917. @deftp {Data Type} earlyoom-configuration
  25918. This is the configuration record for the @code{earlyoom-service-type}.
  25919. @table @asis
  25920. @item @code{earlyoom} (default: @var{earlyoom})
  25921. The Earlyoom package to use.
  25922. @item @code{minimum-available-memory} (default: @code{10})
  25923. The threshold for the minimum @emph{available} memory, in percentages.
  25924. @item @code{minimum-free-swap} (default: @code{10})
  25925. The threshold for the minimum free swap memory, in percentages.
  25926. @item @code{prefer-regexp} (default: @code{#f})
  25927. A regular expression (as a string) to match the names of the processes
  25928. that should be preferably killed.
  25929. @item @code{avoid-regexp} (default: @code{#f})
  25930. A regular expression (as a string) to match the names of the processes
  25931. that should @emph{not} be killed.
  25932. @item @code{memory-report-interval} (default: @code{0})
  25933. The interval in seconds at which a memory report is printed. It is
  25934. disabled by default.
  25935. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  25936. A boolean indicating whether the positive adjustments set in
  25937. @file{/proc/*/oom_score_adj} should be ignored.
  25938. @item @code{show-debug-messages?} (default: @code{#f})
  25939. A boolean indicating whether debug messages should be printed. The logs
  25940. are saved at @file{/var/log/earlyoom.log}.
  25941. @item @code{send-notification-command} (default: @code{#f})
  25942. This can be used to provide a custom command used for sending
  25943. notifications.
  25944. @end table
  25945. @end deftp
  25946. @cindex modprobe
  25947. @cindex kernel module loader
  25948. @subsubheading Kernel Module Loader Service
  25949. The kernel module loader service allows one to load loadable kernel
  25950. modules at boot. This is especially useful for modules that don't
  25951. autoload and need to be manually loaded, as is the case with
  25952. @code{ddcci}.
  25953. @deffn {Scheme Variable} kernel-module-loader-service-type
  25954. The service type for loading loadable kernel modules at boot with
  25955. @command{modprobe}. Its value must be a list of strings representing
  25956. module names. For example loading the drivers provided by
  25957. @code{ddcci-driver-linux}, in debugging mode by passing some module
  25958. parameters, can be done as follow:
  25959. @lisp
  25960. (use-modules (gnu) (gnu services))
  25961. (use-package-modules linux)
  25962. (use-service-modules linux)
  25963. (define ddcci-config
  25964. (plain-file "ddcci.conf"
  25965. "options ddcci dyndbg delay=120"))
  25966. (operating-system
  25967. ...
  25968. (services (cons* (service kernel-module-loader-service-type
  25969. '("ddcci" "ddcci_backlight"))
  25970. (simple-service 'ddcci-config etc-service-type
  25971. (list `("modprobe.d/ddcci.conf"
  25972. ,ddcci-config)))
  25973. %base-services))
  25974. (kernel-loadable-modules (list ddcci-driver-linux)))
  25975. @end lisp
  25976. @end deffn
  25977. @cindex rasdaemon
  25978. @cindex Platform Reliability, Availability and Serviceability daemon
  25979. @subsubheading Rasdaemon Service
  25980. The Rasdaemon service provides a daemon which monitors platform
  25981. @acronym{RAS, Reliability@comma{} Availability@comma{} and Serviceability} reports from
  25982. Linux kernel trace events, logging them to syslogd.
  25983. Reliability, Availability and Serviceability is a concept used on servers meant
  25984. to measure their robustness.
  25985. @strong{Relability} is the probability that a system will produce correct
  25986. outputs:
  25987. @itemize @bullet
  25988. @item Generally measured as Mean Time Between Failures (MTBF), and
  25989. @item Enhanced by features that help to avoid, detect and repair hardware
  25990. faults
  25991. @end itemize
  25992. @strong{Availability} is the probability that a system is operational at a
  25993. given time:
  25994. @itemize @bullet
  25995. @item Generally measured as a percentage of downtime per a period of time, and
  25996. @item Often uses mechanisms to detect and correct hardware faults in runtime.
  25997. @end itemize
  25998. @strong{Serviceability} is the simplicity and speed with which a system can be
  25999. repaired or maintained:
  26000. @itemize @bullet
  26001. @item Generally measured on Mean Time Between Repair (MTBR).
  26002. @end itemize
  26003. Among the monitoring measures, the most usual ones include:
  26004. @itemize @bullet
  26005. @item CPU – detect errors at instruction execution and at L1/L2/L3 caches;
  26006. @item Memory – add error correction logic (ECC) to detect and correct errors;
  26007. @item I/O – add CRC checksums for transferred data;
  26008. @item Storage – RAID, journal file systems, checksums, Self-Monitoring,
  26009. Analysis and Reporting Technology (SMART).
  26010. @end itemize
  26011. By monitoring the number of occurrences of error detections, it is possible to
  26012. identify if the probability of hardware errors is increasing, and, on such
  26013. case, do a preventive maintenance to replace a degraded component while those
  26014. errors are correctable.
  26015. For detailed information about the types of error events gathered and how to
  26016. make sense of them, see the kernel administrator's guide at
  26017. @url{https://www.kernel.org/doc/html/latest/admin-guide/ras.html}.
  26018. @defvr {Scheme Variable} rasdaemon-service-type
  26019. Service type for the @command{rasdaemon} service. It accepts a
  26020. @code{rasdaemon-configuration} object. Instantiating like
  26021. @lisp
  26022. (service rasdaemon-service-type)
  26023. @end lisp
  26024. will load with a default configuration, which monitors all events and logs to
  26025. syslogd.
  26026. @end defvr
  26027. @deftp {Data Type} rasdaemon-configuration
  26028. The data type representing the configuration of @command{rasdaemon}.
  26029. @table @asis
  26030. @item @code{record?} (default: @code{#f})
  26031. A boolean indicating whether to record the events in an SQLite database. This
  26032. provides a more structured access to the information contained in the log file.
  26033. The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
  26034. @end table
  26035. @end deftp
  26036. @cindex zram
  26037. @cindex compressed swap
  26038. @cindex Compressed RAM-based block devices
  26039. @subsubheading Zram Device Service
  26040. The Zram device service provides a compressed swap device in system
  26041. memory. The Linux Kernel documentation has more information about
  26042. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  26043. devices.
  26044. @deffn {Scheme Variable} zram-device-service-type
  26045. This service creates the zram block device, formats it as swap and
  26046. enables it as a swap device. The service's value is a
  26047. @code{zram-device-configuration} record.
  26048. @deftp {Data Type} zram-device-configuration
  26049. This is the data type representing the configuration for the zram-device
  26050. service.
  26051. @table @asis
  26052. @item @code{size} (default @code{"1G"})
  26053. This is the amount of space you wish to provide for the zram device. It
  26054. accepts a string and can be a number of bytes or use a suffix, eg.:
  26055. @code{"512M"} or @code{1024000}.
  26056. @item @code{compression-algorithm} (default @code{'lzo})
  26057. This is the compression algorithm you wish to use. It is difficult to
  26058. list all the possible compression options, but common ones supported by
  26059. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  26060. @item @code{memory-limit} (default @code{0})
  26061. This is the maximum amount of memory which the zram device can use.
  26062. Setting it to '0' disables the limit. While it is generally expected
  26063. that compression will be 2:1, it is possible that uncompressable data
  26064. can be written to swap and this is a method to limit how much memory can
  26065. be used. It accepts a string and can be a number of bytes or use a
  26066. suffix, eg.: @code{"2G"}.
  26067. @item @code{priority} (default @code{-1})
  26068. This is the priority of the swap device created from the zram device.
  26069. @code{swapon} accepts values between -1 and 32767, with higher values
  26070. indicating higher priority. Higher priority swap will generally be used
  26071. first.
  26072. @end table
  26073. @end deftp
  26074. @end deffn
  26075. @node Hurd Services
  26076. @subsection Hurd Services
  26077. @defvr {Scheme Variable} hurd-console-service-type
  26078. This service starts the fancy @code{VGA} console client on the Hurd.
  26079. The service's value is a @code{hurd-console-configuration} record.
  26080. @end defvr
  26081. @deftp {Data Type} hurd-console-configuration
  26082. This is the data type representing the configuration for the
  26083. hurd-console-service.
  26084. @table @asis
  26085. @item @code{hurd} (default: @var{hurd})
  26086. The Hurd package to use.
  26087. @end table
  26088. @end deftp
  26089. @defvr {Scheme Variable} hurd-getty-service-type
  26090. This service starts a tty using the Hurd @code{getty} program.
  26091. The service's value is a @code{hurd-getty-configuration} record.
  26092. @end defvr
  26093. @deftp {Data Type} hurd-getty-configuration
  26094. This is the data type representing the configuration for the
  26095. hurd-getty-service.
  26096. @table @asis
  26097. @item @code{hurd} (default: @var{hurd})
  26098. The Hurd package to use.
  26099. @item @code{tty}
  26100. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  26101. @item @code{baud-rate} (default: @code{38400})
  26102. An integer specifying the baud rate of the tty.
  26103. @end table
  26104. @end deftp
  26105. @node Miscellaneous Services
  26106. @subsection Miscellaneous Services
  26107. @cindex fingerprint
  26108. @subsubheading Fingerprint Service
  26109. The @code{(gnu services authentication)} module provides a DBus service to
  26110. read and identify fingerprints via a fingerprint sensor.
  26111. @defvr {Scheme Variable} fprintd-service-type
  26112. The service type for @command{fprintd}, which provides the fingerprint
  26113. reading capability.
  26114. @lisp
  26115. (service fprintd-service-type)
  26116. @end lisp
  26117. @end defvr
  26118. @cindex sysctl
  26119. @subsubheading System Control Service
  26120. The @code{(gnu services sysctl)} provides a service to configure kernel
  26121. parameters at boot.
  26122. @defvr {Scheme Variable} sysctl-service-type
  26123. The service type for @command{sysctl}, which modifies kernel parameters
  26124. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  26125. instantiated as:
  26126. @lisp
  26127. (service sysctl-service-type
  26128. (sysctl-configuration
  26129. (settings '(("net.ipv4.ip_forward" . "1")))))
  26130. @end lisp
  26131. Since @code{sysctl-service-type} is used in the default lists of
  26132. services, @code{%base-services} and @code{%desktop-services}, you can
  26133. use @code{modify-services} to change its configuration and add the
  26134. kernel parameters that you want (@pxref{Service Reference,
  26135. @code{modify-services}}).
  26136. @lisp
  26137. (modify-services %base-services
  26138. (sysctl-service-type config =>
  26139. (sysctl-configuration
  26140. (settings (append '(("net.ipv4.ip_forward" . "1"))
  26141. %default-sysctl-settings)))))
  26142. @end lisp
  26143. @end defvr
  26144. @deftp {Data Type} sysctl-configuration
  26145. The data type representing the configuration of @command{sysctl}.
  26146. @table @asis
  26147. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  26148. The @command{sysctl} executable to use.
  26149. @item @code{settings} (default: @code{%default-sysctl-settings})
  26150. An association list specifies kernel parameters and their values.
  26151. @end table
  26152. @end deftp
  26153. @defvr {Scheme Variable} %default-sysctl-settings
  26154. An association list specifying the default @command{sysctl} parameters
  26155. on Guix System.
  26156. @end defvr
  26157. @cindex pcscd
  26158. @subsubheading PC/SC Smart Card Daemon Service
  26159. The @code{(gnu services security-token)} module provides the following service
  26160. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  26161. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  26162. manager that coordinates communications with smart card readers, smart cards
  26163. and cryptographic tokens that are connected to the system.
  26164. @defvr {Scheme Variable} pcscd-service-type
  26165. Service type for the @command{pcscd} service. Its value must be a
  26166. @code{pcscd-configuration} object. To run pcscd in the default
  26167. configuration, instantiate it as:
  26168. @lisp
  26169. (service pcscd-service-type)
  26170. @end lisp
  26171. @end defvr
  26172. @deftp {Data Type} pcscd-configuration
  26173. The data type representing the configuration of @command{pcscd}.
  26174. @table @asis
  26175. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  26176. The pcsc-lite package that provides pcscd.
  26177. @item @code{usb-drivers} (default: @code{(list ccid)})
  26178. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  26179. under @file{pcsc/drivers} in the store directory of the package.
  26180. @end table
  26181. @end deftp
  26182. @cindex lirc
  26183. @subsubheading Lirc Service
  26184. The @code{(gnu services lirc)} module provides the following service.
  26185. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  26186. [#:device #f] [#:driver #f] [#:config-file #f] @
  26187. [#:extra-options '()]
  26188. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  26189. decodes infrared signals from remote controls.
  26190. Optionally, @var{device}, @var{driver} and @var{config-file}
  26191. (configuration file name) may be specified. See @command{lircd} manual
  26192. for details.
  26193. Finally, @var{extra-options} is a list of additional command-line options
  26194. passed to @command{lircd}.
  26195. @end deffn
  26196. @cindex spice
  26197. @subsubheading Spice Service
  26198. The @code{(gnu services spice)} module provides the following service.
  26199. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  26200. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  26201. that enables sharing the clipboard with a vm and setting the guest display
  26202. resolution when the graphical console window resizes.
  26203. @end deffn
  26204. @cindex inputattach
  26205. @subsubheading inputattach Service
  26206. @cindex tablet input, for Xorg
  26207. @cindex touchscreen input, for Xorg
  26208. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  26209. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  26210. Xorg display server.
  26211. @deffn {Scheme Variable} inputattach-service-type
  26212. Type of a service that runs @command{inputattach} on a device and
  26213. dispatches events from it.
  26214. @end deffn
  26215. @deftp {Data Type} inputattach-configuration
  26216. @table @asis
  26217. @item @code{device-type} (default: @code{"wacom"})
  26218. The type of device to connect to. Run @command{inputattach --help}, from the
  26219. @code{inputattach} package, to see the list of supported device types.
  26220. @item @code{device} (default: @code{"/dev/ttyS0"})
  26221. The device file to connect to the device.
  26222. @item @code{baud-rate} (default: @code{#f})
  26223. Baud rate to use for the serial connection.
  26224. Should be a number or @code{#f}.
  26225. @item @code{log-file} (default: @code{#f})
  26226. If true, this must be the name of a file to log messages to.
  26227. @end table
  26228. @end deftp
  26229. @subsubheading Dictionary Service
  26230. @cindex dictionary
  26231. The @code{(gnu services dict)} module provides the following service:
  26232. @defvr {Scheme Variable} dicod-service-type
  26233. This is the type of the service that runs the @command{dicod} daemon, an
  26234. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  26235. @end defvr
  26236. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  26237. Return a service that runs the @command{dicod} daemon, an implementation
  26238. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  26239. The optional @var{config} argument specifies the configuration for
  26240. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  26241. default it serves the GNU Collaborative International Dictionary of English.
  26242. You can add @command{open localhost} to your @file{~/.dico} file to make
  26243. @code{localhost} the default server for @command{dico} client
  26244. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  26245. @end deffn
  26246. @deftp {Data Type} dicod-configuration
  26247. Data type representing the configuration of dicod.
  26248. @table @asis
  26249. @item @code{dico} (default: @var{dico})
  26250. Package object of the GNU Dico dictionary server.
  26251. @item @code{interfaces} (default: @var{'("localhost")})
  26252. This is the list of IP addresses and ports and possibly socket file
  26253. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  26254. dico, GNU Dico Manual}).
  26255. @item @code{handlers} (default: @var{'()})
  26256. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  26257. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  26258. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  26259. @end table
  26260. @end deftp
  26261. @deftp {Data Type} dicod-handler
  26262. Data type representing a dictionary handler (module instance).
  26263. @table @asis
  26264. @item @code{name}
  26265. Name of the handler (module instance).
  26266. @item @code{module} (default: @var{#f})
  26267. Name of the dicod module of the handler (instance). If it is @code{#f},
  26268. the module has the same name as the handler.
  26269. (@pxref{Modules,,, dico, GNU Dico Manual}).
  26270. @item @code{options}
  26271. List of strings or gexps representing the arguments for the module handler
  26272. @end table
  26273. @end deftp
  26274. @deftp {Data Type} dicod-database
  26275. Data type representing a dictionary database.
  26276. @table @asis
  26277. @item @code{name}
  26278. Name of the database, will be used in DICT commands.
  26279. @item @code{handler}
  26280. Name of the dicod handler (module instance) used by this database
  26281. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  26282. @item @code{complex?} (default: @var{#f})
  26283. Whether the database configuration complex. The complex configuration
  26284. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  26285. @item @code{options}
  26286. List of strings or gexps representing the arguments for the database
  26287. (@pxref{Databases,,, dico, GNU Dico Manual}).
  26288. @end table
  26289. @end deftp
  26290. @defvr {Scheme Variable} %dicod-database:gcide
  26291. A @code{<dicod-database>} object serving the GNU Collaborative International
  26292. Dictionary of English using the @code{gcide} package.
  26293. @end defvr
  26294. The following is an example @code{dicod-service} configuration.
  26295. @lisp
  26296. (dicod-service #:config
  26297. (dicod-configuration
  26298. (handlers (list (dicod-handler
  26299. (name "wordnet")
  26300. (module "dictorg")
  26301. (options
  26302. (list #~(string-append "dbdir=" #$wordnet))))))
  26303. (databases (list (dicod-database
  26304. (name "wordnet")
  26305. (complex? #t)
  26306. (handler "wordnet")
  26307. (options '("database=wn")))
  26308. %dicod-database:gcide))))
  26309. @end lisp
  26310. @cindex Docker
  26311. @subsubheading Docker Service
  26312. The @code{(gnu services docker)} module provides the following services.
  26313. @defvr {Scheme Variable} docker-service-type
  26314. This is the type of the service that runs @url{https://www.docker.com,Docker},
  26315. a daemon that can execute application bundles (sometimes referred to as
  26316. ``containers'') in isolated environments.
  26317. @end defvr
  26318. @deftp {Data Type} docker-configuration
  26319. This is the data type representing the configuration of Docker and Containerd.
  26320. @table @asis
  26321. @item @code{docker} (default: @code{docker})
  26322. The Docker daemon package to use.
  26323. @item @code{docker-cli} (default: @code{docker-cli})
  26324. The Docker client package to use.
  26325. @item @code{containerd} (default: @var{containerd})
  26326. The Containerd package to use.
  26327. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  26328. The Docker user-land networking proxy package to use.
  26329. @item @code{enable-proxy?} (default @code{#t})
  26330. Enable or disable the use of the Docker user-land networking proxy.
  26331. @item @code{debug?} (default @code{#f})
  26332. Enable or disable debug output.
  26333. @item @code{enable-iptables?} (default @code{#t})
  26334. Enable or disable the addition of iptables rules.
  26335. @item @code{environment-variables} (default: @code{()})
  26336. List of environment variables to set for @command{dockerd}.
  26337. This must be a list of strings where each string has the form
  26338. @samp{@var{key}=@var{value}} as in this example:
  26339. @lisp
  26340. (list "LANGUAGE=eo:ca:eu"
  26341. "TMPDIR=/tmp/dockerd")
  26342. @end lisp
  26343. @end table
  26344. @end deftp
  26345. @cindex Singularity, container service
  26346. @defvr {Scheme Variable} singularity-service-type
  26347. This is the type of the service that allows you to run
  26348. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  26349. create and run application bundles (aka. ``containers''). The value for this
  26350. service is the Singularity package to use.
  26351. The service does not install a daemon; instead, it installs helper programs as
  26352. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  26353. @command{singularity run} and similar commands.
  26354. @end defvr
  26355. @cindex Audit
  26356. @subsubheading Auditd Service
  26357. The @code{(gnu services auditd)} module provides the following service.
  26358. @defvr {Scheme Variable} auditd-service-type
  26359. This is the type of the service that runs
  26360. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  26361. a daemon that tracks security-relevant information on your system.
  26362. Examples of things that can be tracked:
  26363. @enumerate
  26364. @item
  26365. File accesses
  26366. @item
  26367. System calls
  26368. @item
  26369. Invoked commands
  26370. @item
  26371. Failed login attempts
  26372. @item
  26373. Firewall filtering
  26374. @item
  26375. Network access
  26376. @end enumerate
  26377. @command{auditctl} from the @code{audit} package can be used in order
  26378. to add or remove events to be tracked (until the next reboot).
  26379. In order to permanently track events, put the command line arguments
  26380. of auditctl into a file called @code{audit.rules} in the configuration
  26381. directory (see below).
  26382. @command{aureport} from the @code{audit} package can be used in order
  26383. to view a report of all recorded events.
  26384. The audit daemon by default logs into the file
  26385. @file{/var/log/audit.log}.
  26386. @end defvr
  26387. @deftp {Data Type} auditd-configuration
  26388. This is the data type representing the configuration of auditd.
  26389. @table @asis
  26390. @item @code{audit} (default: @code{audit})
  26391. The audit package to use.
  26392. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  26393. The directory containing the configuration file for the audit package, which
  26394. must be named @code{auditd.conf}, and optionally some audit rules to
  26395. instantiate on startup.
  26396. @end table
  26397. @end deftp
  26398. @cindex rshiny
  26399. @subsubheading R-Shiny service
  26400. The @code{(gnu services science)} module provides the following service.
  26401. @defvr {Scheme Variable} rshiny-service-type
  26402. This is a type of service which is used to run a webapp created with
  26403. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  26404. variable and runs the provided script to call @code{runApp}.
  26405. @deftp {Data Type} rshiny-configuration
  26406. This is the data type representing the configuration of rshiny.
  26407. @table @asis
  26408. @item @code{package} (default: @code{r-shiny})
  26409. The package to use.
  26410. @item @code{binary} (defaunlt @code{"rshiny"})
  26411. The name of the binary or shell script located at @code{package/bin/} to
  26412. run when the service is run.
  26413. The common way to create this file is as follows:
  26414. @lisp
  26415. @dots{}
  26416. (let* ((out (assoc-ref %outputs "out"))
  26417. (targetdir (string-append out "/share/" ,name))
  26418. (app (string-append out "/bin/" ,name))
  26419. (Rbin (search-input-file %build-inputs "/bin/Rscript")))
  26420. ;; @dots{}
  26421. (mkdir-p (string-append out "/bin"))
  26422. (call-with-output-file app
  26423. (lambda (port)
  26424. (format port
  26425. "#!~a
  26426. library(shiny)
  26427. setwd(\"~a\")
  26428. runApp(launch.browser=0, port=4202)~%\n"
  26429. Rbin targetdir))))
  26430. @end lisp
  26431. @end table
  26432. @end deftp
  26433. @end defvr
  26434. @cindex Nix
  26435. @subsubheading Nix service
  26436. The @code{(gnu services nix)} module provides the following service.
  26437. @defvr {Scheme Variable} nix-service-type
  26438. This is the type of the service that runs build daemon of the
  26439. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  26440. how to use it:
  26441. @lisp
  26442. (use-modules (gnu))
  26443. (use-service-modules nix)
  26444. (use-package-modules package-management)
  26445. (operating-system
  26446. ;; @dots{}
  26447. (packages (append (list nix)
  26448. %base-packages))
  26449. (services (append (list (service nix-service-type))
  26450. %base-services)))
  26451. @end lisp
  26452. After @command{guix system reconfigure} configure Nix for your user:
  26453. @itemize
  26454. @item Add a Nix channel and update it. See
  26455. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  26456. @item Create a symlink to your profile and activate Nix profile:
  26457. @end itemize
  26458. @example
  26459. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  26460. $ source /run/current-system/profile/etc/profile.d/nix.sh
  26461. @end example
  26462. @end defvr
  26463. @deftp {Data Type} nix-configuration
  26464. This data type represents the configuration of the Nix daemon.
  26465. @table @asis
  26466. @item @code{nix} (default: @code{nix})
  26467. The Nix package to use.
  26468. @item @code{sandbox} (default: @code{#t})
  26469. Specifies whether builds are sandboxed by default.
  26470. @item @code{build-sandbox-items} (default: @code{'()})
  26471. This is a list of strings or objects appended to the
  26472. @code{build-sandbox-items} field of the configuration file.
  26473. @item @code{extra-config} (default: @code{'()})
  26474. This is a list of strings or objects appended to the configuration file.
  26475. It is used to pass extra text to be added verbatim to the configuration
  26476. file.
  26477. @item @code{extra-options} (default: @code{'()})
  26478. Extra command line options for @code{nix-service-type}.
  26479. @end table
  26480. @end deftp
  26481. @node Setuid Programs
  26482. @section Setuid Programs
  26483. @cindex setuid programs
  26484. Some programs need to run with ``root'' privileges, even when they are
  26485. launched by unprivileged users. A notorious example is the
  26486. @command{passwd} program, which users can run to change their
  26487. password, and which needs to access the @file{/etc/passwd} and
  26488. @file{/etc/shadow} files---something normally restricted to root, for
  26489. obvious security reasons. To address that, these executables are
  26490. @dfn{setuid-root}, meaning that they always run with root privileges
  26491. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  26492. for more info about the setuid mechanism).
  26493. The store itself @emph{cannot} contain setuid programs: that would be a
  26494. security issue since any user on the system can write derivations that
  26495. populate the store (@pxref{The Store}). Thus, a different mechanism is
  26496. used: instead of changing the setuid bit directly on files that are in
  26497. the store, we let the system administrator @emph{declare} which programs
  26498. should be setuid root.
  26499. The @code{setuid-programs} field of an @code{operating-system}
  26500. declaration contains a list of @code{<setuid-program>} denoting the
  26501. names of programs to have a setuid or setgid bit set (@pxref{Using the
  26502. Configuration System}). For instance, the @command{mount.nfs} program,
  26503. which is part of the nfs-utils package, with a setuid root can be
  26504. designated like this:
  26505. @example
  26506. (setuid-program
  26507. (program (file-append nfs-utils "/sbin/mount.nfs")))
  26508. @end example
  26509. And then, to make @command{mount.nfs} setuid on your system, add the
  26510. previous example to your operating system declaration by appending it to
  26511. @code{%setuid-programs} like this:
  26512. @example
  26513. (setuid-programs
  26514. (append (list (setuid-program
  26515. (program (file-append nfs-utils "/sbin/mount.nfs"))))
  26516. %setuid-programs))
  26517. @end example
  26518. @deftp {Data Type} setuid-program
  26519. This data type represents a program with a setuid or setgid bit set.
  26520. @table @asis
  26521. @item @code{program}
  26522. A file-like object having its setuid and/or setgid bit set.
  26523. @item @code{setuid?} (default: @code{#t})
  26524. Whether to set user setuid bit.
  26525. @item @code{setgid?} (default: @code{#f})
  26526. Whether to set group setgid bit.
  26527. @item @code{user} (default: @code{0})
  26528. UID (integer) or user name (string) for the user owner of the program,
  26529. defaults to root.
  26530. @item @code{group} (default: @code{0})
  26531. GID (integer) goup name (string) for the group owner of the program,
  26532. defaults to root.
  26533. @end table
  26534. @end deftp
  26535. A default set of setuid programs is defined by the
  26536. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  26537. @defvr {Scheme Variable} %setuid-programs
  26538. A list of @code{<setuid-program>} denoting common programs that are
  26539. setuid-root.
  26540. The list includes commands such as @command{passwd}, @command{ping},
  26541. @command{su}, and @command{sudo}.
  26542. @end defvr
  26543. Under the hood, the actual setuid programs are created in the
  26544. @file{/run/setuid-programs} directory at system activation time. The
  26545. files in this directory refer to the ``real'' binaries, which are in the
  26546. store.
  26547. @node X.509 Certificates
  26548. @section X.509 Certificates
  26549. @cindex HTTPS, certificates
  26550. @cindex X.509 certificates
  26551. @cindex TLS
  26552. Web servers available over HTTPS (that is, HTTP over the transport-layer
  26553. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  26554. that the client can then use to @emph{authenticate} the server. To do
  26555. that, clients verify that the server's certificate is signed by a
  26556. so-called @dfn{certificate authority} (CA). But to verify the CA's
  26557. signature, clients must have first acquired the CA's certificate.
  26558. Web browsers such as GNU@tie{}IceCat include their own set of CA
  26559. certificates, such that they are able to verify CA signatures
  26560. out-of-the-box.
  26561. However, most other programs that can talk HTTPS---@command{wget},
  26562. @command{git}, @command{w3m}, etc.---need to be told where CA
  26563. certificates can be found.
  26564. @cindex @code{nss-certs}
  26565. In Guix, this is done by adding a package that provides certificates
  26566. to the @code{packages} field of the @code{operating-system} declaration
  26567. (@pxref{operating-system Reference}). Guix includes one such package,
  26568. @code{nss-certs}, which is a set of CA certificates provided as part of
  26569. Mozilla's Network Security Services.
  26570. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  26571. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  26572. most applications and libraries look for certificates by default, points
  26573. to the certificates installed globally.
  26574. Unprivileged users, including users of Guix on a foreign distro,
  26575. can also install their own certificate package in
  26576. their profile. A number of environment variables need to be defined so
  26577. that applications and libraries know where to find them. Namely, the
  26578. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  26579. variables. Some applications add their own environment variables; for
  26580. instance, the Git version control system honors the certificate bundle
  26581. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  26582. would typically run something like:
  26583. @example
  26584. guix install nss-certs
  26585. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  26586. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  26587. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  26588. @end example
  26589. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  26590. variable to point to a certificate bundle, so you would have to run
  26591. something like this:
  26592. @example
  26593. guix install nss-certs
  26594. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  26595. @end example
  26596. For other applications you may want to look up the required environment
  26597. variable in the relevant documentation.
  26598. @node Name Service Switch
  26599. @section Name Service Switch
  26600. @cindex name service switch
  26601. @cindex NSS
  26602. The @code{(gnu system nss)} module provides bindings to the
  26603. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  26604. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  26605. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  26606. extended with new ``name'' lookup methods for system databases, which
  26607. includes host names, service names, user accounts, and more (@pxref{Name
  26608. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  26609. C Library Reference Manual}).
  26610. The NSS configuration specifies, for each system database, which lookup
  26611. method is to be used, and how the various methods are chained
  26612. together---for instance, under which circumstances NSS should try the
  26613. next method in the list. The NSS configuration is given in the
  26614. @code{name-service-switch} field of @code{operating-system} declarations
  26615. (@pxref{operating-system Reference, @code{name-service-switch}}).
  26616. @cindex nss-mdns
  26617. @cindex .local, host name lookup
  26618. As an example, the declaration below configures the NSS to use the
  26619. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  26620. back-end}, which supports host name lookups over multicast DNS (mDNS)
  26621. for host names ending in @code{.local}:
  26622. @lisp
  26623. (name-service-switch
  26624. (hosts (list %files ;first, check /etc/hosts
  26625. ;; If the above did not succeed, try
  26626. ;; with 'mdns_minimal'.
  26627. (name-service
  26628. (name "mdns_minimal")
  26629. ;; 'mdns_minimal' is authoritative for
  26630. ;; '.local'. When it returns "not found",
  26631. ;; no need to try the next methods.
  26632. (reaction (lookup-specification
  26633. (not-found => return))))
  26634. ;; Then fall back to DNS.
  26635. (name-service
  26636. (name "dns"))
  26637. ;; Finally, try with the "full" 'mdns'.
  26638. (name-service
  26639. (name "mdns")))))
  26640. @end lisp
  26641. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  26642. contains this configuration, so you will not have to type it if all you
  26643. want is to have @code{.local} host lookup working.
  26644. Note that, in this case, in addition to setting the
  26645. @code{name-service-switch} of the @code{operating-system} declaration,
  26646. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  26647. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  26648. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  26649. to the name service cache daemon (@pxref{Base Services,
  26650. @code{nscd-service}}).
  26651. For convenience, the following variables provide typical NSS
  26652. configurations.
  26653. @defvr {Scheme Variable} %default-nss
  26654. This is the default name service switch configuration, a
  26655. @code{name-service-switch} object.
  26656. @end defvr
  26657. @defvr {Scheme Variable} %mdns-host-lookup-nss
  26658. This is the name service switch configuration with support for host name
  26659. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  26660. @end defvr
  26661. The reference for name service switch configuration is given below. It
  26662. is a direct mapping of the configuration file format of the C library , so
  26663. please refer to the C library manual for more information (@pxref{NSS
  26664. Configuration File,,, libc, The GNU C Library Reference Manual}).
  26665. Compared to the configuration file format of libc NSS, it has the advantage
  26666. not only of adding this warm parenthetic feel that we like, but also
  26667. static checks: you will know about syntax errors and typos as soon as you
  26668. run @command{guix system}.
  26669. @deftp {Data Type} name-service-switch
  26670. This is the data type representation the configuration of libc's name
  26671. service switch (NSS). Each field below represents one of the supported
  26672. system databases.
  26673. @table @code
  26674. @item aliases
  26675. @itemx ethers
  26676. @itemx group
  26677. @itemx gshadow
  26678. @itemx hosts
  26679. @itemx initgroups
  26680. @itemx netgroup
  26681. @itemx networks
  26682. @itemx password
  26683. @itemx public-key
  26684. @itemx rpc
  26685. @itemx services
  26686. @itemx shadow
  26687. The system databases handled by the NSS@. Each of these fields must be a
  26688. list of @code{<name-service>} objects (see below).
  26689. @end table
  26690. @end deftp
  26691. @deftp {Data Type} name-service
  26692. This is the data type representing an actual name service and the
  26693. associated lookup action.
  26694. @table @code
  26695. @item name
  26696. A string denoting the name service (@pxref{Services in the NSS
  26697. configuration,,, libc, The GNU C Library Reference Manual}).
  26698. Note that name services listed here must be visible to nscd. This is
  26699. achieved by passing the @code{#:name-services} argument to
  26700. @code{nscd-service} the list of packages providing the needed name
  26701. services (@pxref{Base Services, @code{nscd-service}}).
  26702. @item reaction
  26703. An action specified using the @code{lookup-specification} macro
  26704. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  26705. Reference Manual}). For example:
  26706. @lisp
  26707. (lookup-specification (unavailable => continue)
  26708. (success => return))
  26709. @end lisp
  26710. @end table
  26711. @end deftp
  26712. @node Initial RAM Disk
  26713. @section Initial RAM Disk
  26714. @cindex initrd
  26715. @cindex initial RAM disk
  26716. For bootstrapping purposes, the Linux-Libre kernel is passed an
  26717. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  26718. root file system as well as an initialization script. The latter is
  26719. responsible for mounting the real root file system, and for loading any
  26720. kernel modules that may be needed to achieve that.
  26721. The @code{initrd-modules} field of an @code{operating-system}
  26722. declaration allows you to specify Linux-libre kernel modules that must
  26723. be available in the initrd. In particular, this is where you would list
  26724. modules needed to actually drive the hard disk where your root partition
  26725. is---although the default value of @code{initrd-modules} should cover
  26726. most use cases. For example, assuming you need the @code{megaraid_sas}
  26727. module in addition to the default modules to be able to access your root
  26728. file system, you would write:
  26729. @lisp
  26730. (operating-system
  26731. ;; @dots{}
  26732. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  26733. @end lisp
  26734. @defvr {Scheme Variable} %base-initrd-modules
  26735. This is the list of kernel modules included in the initrd by default.
  26736. @end defvr
  26737. Furthermore, if you need lower-level customization, the @code{initrd}
  26738. field of an @code{operating-system} declaration allows
  26739. you to specify which initrd you would like to use. The @code{(gnu
  26740. system linux-initrd)} module provides three ways to build an initrd: the
  26741. high-level @code{base-initrd} procedure and the low-level
  26742. @code{raw-initrd} and @code{expression->initrd} procedures.
  26743. The @code{base-initrd} procedure is intended to cover most common uses.
  26744. For example, if you want to add a bunch of kernel modules to be loaded
  26745. at boot time, you can define the @code{initrd} field of the operating
  26746. system declaration like this:
  26747. @lisp
  26748. (initrd (lambda (file-systems . rest)
  26749. ;; Create a standard initrd but set up networking
  26750. ;; with the parameters QEMU expects by default.
  26751. (apply base-initrd file-systems
  26752. #:qemu-networking? #t
  26753. rest)))
  26754. @end lisp
  26755. The @code{base-initrd} procedure also handles common use cases that
  26756. involves using the system as a QEMU guest, or as a ``live'' system with
  26757. volatile root file system.
  26758. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  26759. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  26760. such as trying to guess which kernel modules and packages should be included
  26761. to the initrd. An example use of @code{raw-initrd} is when a user has
  26762. a custom Linux kernel configuration and default kernel modules included by
  26763. @code{base-initrd} are not available.
  26764. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  26765. honors several options passed on the Linux kernel command line
  26766. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  26767. @code{-append} option of QEMU), notably:
  26768. @table @code
  26769. @item --load=@var{boot}
  26770. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  26771. program, once it has mounted the root file system.
  26772. Guix uses this option to yield control to a boot program that runs the
  26773. service activation programs and then spawns the GNU@tie{}Shepherd, the
  26774. initialization system.
  26775. @item --root=@var{root}
  26776. Mount @var{root} as the root file system. @var{root} can be a device
  26777. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  26778. When unspecified, the device name from the root file system of the
  26779. operating system declaration is used.
  26780. @item fsck.mode=@var{mode}
  26781. Whether to check the @var{root} file system for errors before mounting
  26782. it. @var{mode} is one of @code{skip} (never check), @code{force} (always
  26783. check), or @code{auto} to respect the root file-system object's 'check?'
  26784. setting (@pxref{File Systems}) and run a full scan only if the file system
  26785. was not cleanly shut down.
  26786. @code{auto} is the default if this option is not present or if @var{mode}
  26787. is not one of the above.
  26788. @item fsck.repair=@var{level}
  26789. The level of repairs to perform automatically if errors are found in the
  26790. @var{root} file system. @var{level} is one of @code{no} (do not write to
  26791. @var{root} at all if possible), @code{yes} (repair as much as possible),
  26792. or @code{preen} to repair problems considered safe to repair automatically.
  26793. @code{preen} is the default if this option is not present or if @var{level}
  26794. is not one of the above.
  26795. @item --system=@var{system}
  26796. Have @file{/run/booted-system} and @file{/run/current-system} point to
  26797. @var{system}.
  26798. @item modprobe.blacklist=@var{modules}@dots{}
  26799. @cindex module, black-listing
  26800. @cindex black list, of kernel modules
  26801. Instruct the initial RAM disk as well as the @command{modprobe} command
  26802. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  26803. must be a comma-separated list of module names---e.g.,
  26804. @code{usbkbd,9pnet}.
  26805. @item --repl
  26806. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  26807. tries to load kernel modules and to mount the root file system. Our
  26808. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  26809. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  26810. Manual}, for more information on Guile's REPL.
  26811. @end table
  26812. Now that you know all the features that initial RAM disks produced by
  26813. @code{base-initrd} and @code{raw-initrd} provide,
  26814. here is how to use it and customize it further.
  26815. @cindex initrd
  26816. @cindex initial RAM disk
  26817. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  26818. [#:linux-modules '()] [#:mapped-devices '()] @
  26819. [#:keyboard-layout #f] @
  26820. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  26821. Return a derivation that builds a raw initrd. @var{file-systems} is
  26822. a list of file systems to be mounted by the initrd, possibly in addition to
  26823. the root file system specified on the kernel command line via @option{--root}.
  26824. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  26825. @var{mapped-devices} is a list of device mappings to realize before
  26826. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  26827. @var{helper-packages} is a list of packages to be copied in the initrd.
  26828. It may
  26829. include @code{e2fsck/static} or other packages needed by the initrd to check
  26830. the root file system.
  26831. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  26832. the desired console keyboard layout. This is done before @var{mapped-devices}
  26833. are set up and before @var{file-systems} are mounted such that, should the
  26834. user need to enter a passphrase or use the REPL, this happens using the
  26835. intended keyboard layout.
  26836. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  26837. parameters. When @var{virtio?} is true, load additional modules so that the
  26838. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  26839. When @var{volatile-root?} is true, the root file system is writable but any changes
  26840. to it are lost.
  26841. @end deffn
  26842. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  26843. [#:mapped-devices '()] [#:keyboard-layout #f] @
  26844. [#:qemu-networking? #f] [#:volatile-root? #f] @
  26845. [#:linux-modules '()]
  26846. Return as a file-like object a generic initrd, with kernel
  26847. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  26848. mounted by the initrd, possibly in addition to the root file system specified
  26849. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  26850. mappings to realize before @var{file-systems} are mounted.
  26851. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  26852. the desired console keyboard layout. This is done before @var{mapped-devices}
  26853. are set up and before @var{file-systems} are mounted such that, should the
  26854. user need to enter a passphrase or use the REPL, this happens using the
  26855. intended keyboard layout.
  26856. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  26857. The initrd is automatically populated with all the kernel modules necessary
  26858. for @var{file-systems} and for the given options. Additional kernel
  26859. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  26860. loaded at boot time in the order in which they appear.
  26861. @end deffn
  26862. Needless to say, the initrds we produce and use embed a
  26863. statically-linked Guile, and the initialization program is a Guile
  26864. program. That gives a lot of flexibility. The
  26865. @code{expression->initrd} procedure builds such an initrd, given the
  26866. program to run in that initrd.
  26867. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  26868. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  26869. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  26870. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  26871. upon booting. All the derivations referenced by @var{exp} are
  26872. automatically copied to the initrd.
  26873. @end deffn
  26874. @node Bootloader Configuration
  26875. @section Bootloader Configuration
  26876. @cindex bootloader
  26877. @cindex boot loader
  26878. The operating system supports multiple bootloaders. The bootloader is
  26879. configured using @code{bootloader-configuration} declaration. All the
  26880. fields of this structure are bootloader agnostic except for one field,
  26881. @code{bootloader} that indicates the bootloader to be configured and
  26882. installed.
  26883. Some of the bootloaders do not honor every field of
  26884. @code{bootloader-configuration}. For instance, the extlinux
  26885. bootloader does not support themes and thus ignores the @code{theme}
  26886. field.
  26887. @deftp {Data Type} bootloader-configuration
  26888. The type of a bootloader configuration declaration.
  26889. @table @asis
  26890. @item @code{bootloader}
  26891. @cindex EFI, bootloader
  26892. @cindex UEFI, bootloader
  26893. @cindex BIOS, bootloader
  26894. The bootloader to use, as a @code{bootloader} object. For now
  26895. @code{grub-bootloader}, @code{grub-efi-bootloader},
  26896. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  26897. @code{u-boot-bootloader} are supported.
  26898. @cindex ARM, bootloaders
  26899. @cindex AArch64, bootloaders
  26900. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  26901. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  26902. of bootloaders for a wide range of ARM and AArch64 systems, using the
  26903. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  26904. @vindex grub-efi-bootloader
  26905. @code{grub-efi-bootloader} allows to boot on modern systems using the
  26906. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  26907. use if the installation image contains a @file{/sys/firmware/efi} directory
  26908. when you boot it on your system.
  26909. @vindex grub-bootloader
  26910. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  26911. in ``legacy'' BIOS mode.
  26912. @vindex grub-efi-netboot-bootloader
  26913. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  26914. through TFTP@. In combination with an NFS root file system this allows you to
  26915. build a diskless Guix system.
  26916. The installation of the @code{grub-efi-netboot-bootloader} generates the
  26917. content of the TFTP root directory at @code{targets} (@pxref{Bootloader
  26918. Configuration, @code{targets}}), to be served by a TFTP server. You may
  26919. want to mount your TFTP server directories onto the @code{targets} to
  26920. move the required files to the TFTP server automatically.
  26921. If you plan to use an NFS root file system as well (actually if you mount the
  26922. store from an NFS share), then the TFTP server needs to serve the file
  26923. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  26924. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  26925. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  26926. files from the store will be accessed by GRUB through TFTP with their normal
  26927. store path, for example as
  26928. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  26929. Two symlinks are created to make this possible. For each target in the
  26930. @code{targets} field, the first symlink is
  26931. @samp{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  26932. @file{../../../boot/grub/grub.cfg}, where @samp{target} may be
  26933. @file{/boot}. In this case the link is not leaving the served TFTP root
  26934. directory, but otherwise it does. The second link is
  26935. @samp{target}@file{/gnu/store} and points to @file{../gnu/store}. This
  26936. link is leaving the served TFTP root directory.
  26937. The assumption behind all this is that you have an NFS server exporting
  26938. the root file system for your Guix system, and additionally a TFTP
  26939. server exporting your @code{targets} directories—usually a single
  26940. @file{/boot}—from that same root file system for your Guix system. In
  26941. this constellation the symlinks will work.
  26942. For other constellations you will have to program your own bootloader
  26943. installer, which then takes care to make necessary files from the store
  26944. accessible through TFTP, for example by copying them into the TFTP root
  26945. directory to your @code{targets}.
  26946. It is important to note that symlinks pointing outside the TFTP root directory
  26947. may need to be allowed in the configuration of your TFTP server. Further the
  26948. store link exposes the whole store through TFTP@. Both points need to be
  26949. considered carefully for security aspects.
  26950. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  26951. NFS servers, you also need a properly configured DHCP server to make the booting
  26952. over netboot possible. For all this we can currently only recommend you to look
  26953. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  26954. @item @code{targets}
  26955. This is a list of strings denoting the targets onto which to install the
  26956. bootloader.
  26957. The interpretation of targets depends on the bootloader in question.
  26958. For @code{grub-bootloader}, for example, they should be device names
  26959. understood by the bootloader @command{installer} command, such as
  26960. @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
  26961. GNU GRUB Manual}). For @code{grub-efi-bootloader}, they should be mount
  26962. points of the EFI file system, usually @file{/boot/efi}. For
  26963. @code{grub-efi-netboot-bootloader}, @code{targets} should be the mount
  26964. points corresponding to TFTP root directories served by your TFTP
  26965. server.
  26966. @item @code{menu-entries} (default: @code{()})
  26967. A possibly empty list of @code{menu-entry} objects (see below), denoting
  26968. entries to appear in the bootloader menu, in addition to the current
  26969. system entry and the entry pointing to previous system generations.
  26970. @item @code{default-entry} (default: @code{0})
  26971. The index of the default boot menu entry. Index 0 is for the entry of the
  26972. current system.
  26973. @item @code{timeout} (default: @code{5})
  26974. The number of seconds to wait for keyboard input before booting. Set to
  26975. 0 to boot immediately, and to -1 to wait indefinitely.
  26976. @cindex keyboard layout, for the bootloader
  26977. @item @code{keyboard-layout} (default: @code{#f})
  26978. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  26979. layout, usually US@tie{}English (``qwerty'').
  26980. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  26981. Layout}).
  26982. @quotation Note
  26983. This option is currently ignored by bootloaders other than @code{grub} and
  26984. @code{grub-efi}.
  26985. @end quotation
  26986. @item @code{theme} (default: @var{#f})
  26987. The bootloader theme object describing the theme to use. If no theme
  26988. is provided, some bootloaders might use a default theme, that's true
  26989. for GRUB.
  26990. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  26991. The output terminals used for the bootloader boot menu, as a list of
  26992. symbols. GRUB accepts the values: @code{console}, @code{serial},
  26993. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  26994. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  26995. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  26996. configuration,,, grub,GNU GRUB manual}).
  26997. @item @code{terminal-inputs} (default: @code{'()})
  26998. The input terminals used for the bootloader boot menu, as a list of
  26999. symbols. For GRUB, the default is the native platform terminal as
  27000. determined at run-time. GRUB accepts the values: @code{console},
  27001. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  27002. @code{usb_keyboard}. This field corresponds to the GRUB variable
  27003. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  27004. manual}).
  27005. @item @code{serial-unit} (default: @code{#f})
  27006. The serial unit used by the bootloader, as an integer from 0 to 3.
  27007. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  27008. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  27009. @item @code{serial-speed} (default: @code{#f})
  27010. The speed of the serial interface, as an integer. For GRUB, the
  27011. default value is chosen at run-time; currently GRUB chooses
  27012. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  27013. @end table
  27014. @end deftp
  27015. @cindex dual boot
  27016. @cindex boot menu
  27017. Should you want to list additional boot menu entries @i{via} the
  27018. @code{menu-entries} field above, you will need to create them with the
  27019. @code{menu-entry} form. For example, imagine you want to be able to
  27020. boot another distro (hard to imagine!), you can define a menu entry
  27021. along these lines:
  27022. @lisp
  27023. (menu-entry
  27024. (label "The Other Distro")
  27025. (linux "/boot/old/vmlinux-2.6.32")
  27026. (linux-arguments '("root=/dev/sda2"))
  27027. (initrd "/boot/old/initrd"))
  27028. @end lisp
  27029. Details below.
  27030. @deftp {Data Type} menu-entry
  27031. The type of an entry in the bootloader menu.
  27032. @table @asis
  27033. @item @code{label}
  27034. The label to show in the menu---e.g., @code{"GNU"}.
  27035. @item @code{linux} (default: @code{#f})
  27036. The Linux kernel image to boot, for example:
  27037. @lisp
  27038. (file-append linux-libre "/bzImage")
  27039. @end lisp
  27040. For GRUB, it is also possible to specify a device explicitly in the
  27041. file path using GRUB's device naming convention (@pxref{Naming
  27042. convention,,, grub, GNU GRUB manual}), for example:
  27043. @example
  27044. "(hd0,msdos1)/boot/vmlinuz"
  27045. @end example
  27046. If the device is specified explicitly as above, then the @code{device}
  27047. field is ignored entirely.
  27048. @item @code{linux-arguments} (default: @code{()})
  27049. The list of extra Linux kernel command-line arguments---e.g.,
  27050. @code{("console=ttyS0")}.
  27051. @item @code{initrd} (default: @code{#f})
  27052. A G-Expression or string denoting the file name of the initial RAM disk
  27053. to use (@pxref{G-Expressions}).
  27054. @item @code{device} (default: @code{#f})
  27055. The device where the kernel and initrd are to be found---i.e., for GRUB,
  27056. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  27057. This may be a file system label (a string), a file system UUID (a
  27058. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  27059. the bootloader will search the device containing the file specified by
  27060. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  27061. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  27062. @item @code{multiboot-kernel} (default: @code{#f})
  27063. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  27064. manual}). When this field is set, a Multiboot menu-entry is generated.
  27065. For example:
  27066. @lisp
  27067. (file-append mach "/boot/gnumach")
  27068. @end lisp
  27069. @item @code{multiboot-arguments} (default: @code{()})
  27070. The list of extra command-line arguments for the multiboot-kernel.
  27071. @item @code{multiboot-modules} (default: @code{()})
  27072. The list of commands for loading Multiboot modules. For example:
  27073. @lisp
  27074. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  27075. @dots{})
  27076. (list (file-append libc "/lib/ld.so.1") "exec"
  27077. @dots{}))
  27078. @end lisp
  27079. @end table
  27080. @end deftp
  27081. @cindex HDPI
  27082. @cindex HiDPI
  27083. @cindex resolution
  27084. @c FIXME: Write documentation once it's stable.
  27085. For now only GRUB has theme support. GRUB themes are created using
  27086. the @code{grub-theme} form, which is not fully documented yet.
  27087. @deftp {Data Type} grub-theme
  27088. Data type representing the configuration of the GRUB theme.
  27089. @table @asis
  27090. @item @code{gfxmode} (default: @code{'("auto")})
  27091. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  27092. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  27093. @end table
  27094. @end deftp
  27095. @deffn {Scheme Procedure} grub-theme
  27096. Return the default GRUB theme used by the operating system if no
  27097. @code{theme} field is specified in @code{bootloader-configuration}
  27098. record.
  27099. It comes with a fancy background image displaying the GNU and Guix
  27100. logos.
  27101. @end deffn
  27102. For example, to override the default resolution, you may use something
  27103. like
  27104. @lisp
  27105. (bootloader
  27106. (bootloader-configuration
  27107. ;; @dots{}
  27108. (theme (grub-theme
  27109. (inherit (grub-theme))
  27110. (gfxmode '("1024x786x32" "auto"))))))
  27111. @end lisp
  27112. @node Invoking guix system
  27113. @section Invoking @code{guix system}
  27114. Once you have written an operating system declaration as seen in the
  27115. previous section, it can be @dfn{instantiated} using the @command{guix
  27116. system} command. The synopsis is:
  27117. @example
  27118. guix system @var{options}@dots{} @var{action} @var{file}
  27119. @end example
  27120. @var{file} must be the name of a file containing an
  27121. @code{operating-system} declaration. @var{action} specifies how the
  27122. operating system is instantiated. Currently the following values are
  27123. supported:
  27124. @table @code
  27125. @item search
  27126. Display available service type definitions that match the given regular
  27127. expressions, sorted by relevance:
  27128. @cindex HDPI
  27129. @cindex HiDPI
  27130. @cindex resolution
  27131. @example
  27132. $ guix system search console
  27133. name: console-fonts
  27134. location: gnu/services/base.scm:806:2
  27135. extends: shepherd-root
  27136. description: Install the given fonts on the specified ttys (fonts are per
  27137. + virtual console on GNU/Linux). The value of this service is a list of
  27138. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  27139. + package or any valid argument to `setfont', as in this example:
  27140. +
  27141. + '(("tty1" . "LatGrkCyr-8x16")
  27142. + ("tty2" . (file-append
  27143. + font-tamzen
  27144. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  27145. + ("tty3" . (file-append
  27146. + font-terminus
  27147. + "/share/consolefonts/ter-132n"))) ; for HDPI
  27148. relevance: 9
  27149. name: mingetty
  27150. location: gnu/services/base.scm:1190:2
  27151. extends: shepherd-root
  27152. description: Provide console login using the `mingetty' program.
  27153. relevance: 2
  27154. name: login
  27155. location: gnu/services/base.scm:860:2
  27156. extends: pam
  27157. description: Provide a console log-in service as specified by its
  27158. + configuration value, a `login-configuration' object.
  27159. relevance: 2
  27160. @dots{}
  27161. @end example
  27162. As for @command{guix package --search}, the result is written in
  27163. @code{recutils} format, which makes it easy to filter the output
  27164. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  27165. @item reconfigure
  27166. Build the operating system described in @var{file}, activate it, and
  27167. switch to it@footnote{This action (and the related actions
  27168. @code{switch-generation} and @code{roll-back}) are usable only on
  27169. systems already running Guix System.}.
  27170. @quotation Note
  27171. @c The paragraph below refers to the problem discussed at
  27172. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  27173. It is highly recommended to run @command{guix pull} once before you run
  27174. @command{guix system reconfigure} for the first time (@pxref{Invoking
  27175. guix pull}). Failing to do that you would see an older version of Guix
  27176. once @command{reconfigure} has completed.
  27177. @end quotation
  27178. This effects all the configuration specified in @var{file}: user
  27179. accounts, system services, global package list, setuid programs, etc.
  27180. The command starts system services specified in @var{file} that are not
  27181. currently running; if a service is currently running this command will
  27182. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  27183. @code{herd stop X} or @code{herd restart X}).
  27184. This command creates a new generation whose number is one greater than
  27185. the current generation (as reported by @command{guix system
  27186. list-generations}). If that generation already exists, it will be
  27187. overwritten. This behavior mirrors that of @command{guix package}
  27188. (@pxref{Invoking guix package}).
  27189. It also adds a bootloader menu entry for the new OS configuration,
  27190. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  27191. entries for older configurations to a submenu, allowing you to choose
  27192. an older system generation at boot time should you need it.
  27193. @cindex provenance tracking, of the operating system
  27194. Upon completion, the new system is deployed under
  27195. @file{/run/current-system}. This directory contains @dfn{provenance
  27196. meta-data}: the list of channels in use (@pxref{Channels}) and
  27197. @var{file} itself, when available. You can view it by running:
  27198. @example
  27199. guix system describe
  27200. @end example
  27201. This information is useful should you later want to inspect how this
  27202. particular generation was built. In fact, assuming @var{file} is
  27203. self-contained, you can later rebuild generation @var{n} of your
  27204. operating system with:
  27205. @example
  27206. guix time-machine \
  27207. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  27208. system reconfigure \
  27209. /var/guix/profiles/system-@var{n}-link/configuration.scm
  27210. @end example
  27211. You can think of it as some sort of built-in version control! Your
  27212. system is not just a binary artifact: @emph{it carries its own source}.
  27213. @xref{Service Reference, @code{provenance-service-type}}, for more
  27214. information on provenance tracking.
  27215. By default, @command{reconfigure} @emph{prevents you from downgrading
  27216. your system}, which could (re)introduce security vulnerabilities and
  27217. also cause problems with ``stateful'' services such as database
  27218. management systems. You can override that behavior by passing
  27219. @option{--allow-downgrades}.
  27220. @item switch-generation
  27221. @cindex generations
  27222. Switch to an existing system generation. This action atomically
  27223. switches the system profile to the specified system generation. It
  27224. also rearranges the system's existing bootloader menu entries. It
  27225. makes the menu entry for the specified system generation the default,
  27226. and it moves the entries for the other generations to a submenu, if
  27227. supported by the bootloader being used. The next time the system
  27228. boots, it will use the specified system generation.
  27229. The bootloader itself is not being reinstalled when using this
  27230. command. Thus, the installed bootloader is used with an updated
  27231. configuration file.
  27232. The target generation can be specified explicitly by its generation
  27233. number. For example, the following invocation would switch to system
  27234. generation 7:
  27235. @example
  27236. guix system switch-generation 7
  27237. @end example
  27238. The target generation can also be specified relative to the current
  27239. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  27240. ``3 generations ahead of the current generation,'' and @code{-1} means
  27241. ``1 generation prior to the current generation.'' When specifying a
  27242. negative value such as @code{-1}, you must precede it with @code{--} to
  27243. prevent it from being parsed as an option. For example:
  27244. @example
  27245. guix system switch-generation -- -1
  27246. @end example
  27247. Currently, the effect of invoking this action is @emph{only} to switch
  27248. the system profile to an existing generation and rearrange the
  27249. bootloader menu entries. To actually start using the target system
  27250. generation, you must reboot after running this action. In the future,
  27251. it will be updated to do the same things as @command{reconfigure},
  27252. like activating and deactivating services.
  27253. This action will fail if the specified generation does not exist.
  27254. @item roll-back
  27255. @cindex rolling back
  27256. Switch to the preceding system generation. The next time the system
  27257. boots, it will use the preceding system generation. This is the inverse
  27258. of @command{reconfigure}, and it is exactly the same as invoking
  27259. @command{switch-generation} with an argument of @code{-1}.
  27260. Currently, as with @command{switch-generation}, you must reboot after
  27261. running this action to actually start using the preceding system
  27262. generation.
  27263. @item delete-generations
  27264. @cindex deleting system generations
  27265. @cindex saving space
  27266. Delete system generations, making them candidates for garbage collection
  27267. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  27268. collector'').
  27269. This works in the same way as @samp{guix package --delete-generations}
  27270. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  27271. arguments, all system generations but the current one are deleted:
  27272. @example
  27273. guix system delete-generations
  27274. @end example
  27275. You can also select the generations you want to delete. The example below
  27276. deletes all the system generations that are more than two months old:
  27277. @example
  27278. guix system delete-generations 2m
  27279. @end example
  27280. Running this command automatically reinstalls the bootloader with an updated
  27281. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  27282. longer lists the generations that have been deleted.
  27283. @item build
  27284. Build the derivation of the operating system, which includes all the
  27285. configuration files and programs needed to boot and run the system.
  27286. This action does not actually install anything.
  27287. @item init
  27288. Populate the given directory with all the files necessary to run the
  27289. operating system specified in @var{file}. This is useful for first-time
  27290. installations of Guix System. For instance:
  27291. @example
  27292. guix system init my-os-config.scm /mnt
  27293. @end example
  27294. copies to @file{/mnt} all the store items required by the configuration
  27295. specified in @file{my-os-config.scm}. This includes configuration
  27296. files, packages, and so on. It also creates other essential files
  27297. needed for the system to operate correctly---e.g., the @file{/etc},
  27298. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  27299. This command also installs bootloader on the targets specified in
  27300. @file{my-os-config}, unless the @option{--no-bootloader} option was
  27301. passed.
  27302. @item vm
  27303. @cindex virtual machine
  27304. @cindex VM
  27305. @anchor{guix system vm}
  27306. Build a virtual machine (VM) that contains the operating system declared
  27307. in @var{file}, and return a script to run that VM.
  27308. @quotation Note
  27309. The @code{vm} action and others below
  27310. can use KVM support in the Linux-libre kernel. Specifically, if the
  27311. machine has hardware virtualization support, the corresponding
  27312. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  27313. must exist and be readable and writable by the user and by the
  27314. build users of the daemon (@pxref{Build Environment Setup}).
  27315. @end quotation
  27316. Arguments given to the script are passed to QEMU as in the example
  27317. below, which enables networking and requests 1@tie{}GiB of RAM for the
  27318. emulated machine:
  27319. @example
  27320. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci
  27321. @end example
  27322. It's possible to combine the two steps into one:
  27323. @example
  27324. $ $(guix system vm my-config.scm) -m 1024 -smp 2 -nic user,model=virtio-net-pci
  27325. @end example
  27326. The VM shares its store with the host system.
  27327. Additional file systems can be shared between the host and the VM using
  27328. the @option{--share} and @option{--expose} command-line options: the former
  27329. specifies a directory to be shared with write access, while the latter
  27330. provides read-only access to the shared directory.
  27331. The example below creates a VM in which the user's home directory is
  27332. accessible read-only, and where the @file{/exchange} directory is a
  27333. read-write mapping of @file{$HOME/tmp} on the host:
  27334. @example
  27335. guix system vm my-config.scm \
  27336. --expose=$HOME --share=$HOME/tmp=/exchange
  27337. @end example
  27338. On GNU/Linux, the default is to boot directly to the kernel; this has
  27339. the advantage of requiring only a very tiny root disk image since the
  27340. store of the host can then be mounted.
  27341. The @option{--full-boot} option forces a complete boot sequence, starting
  27342. with the bootloader. This requires more disk space since a root image
  27343. containing at least the kernel, initrd, and bootloader data files must
  27344. be created.
  27345. The @option{--image-size} option can be used to specify the size of the
  27346. image.
  27347. The @option{--no-graphic} option will instruct @command{guix system} to
  27348. spawn a headless VM that will use the invoking tty for IO. Among other
  27349. things, this enables copy-pasting, and scrollback. Use the @kbd{ctrl-a}
  27350. prefix to issue QEMU commands; e.g. @kbd{ctrl-a h} prints a help,
  27351. @kbd{ctrl-a x} quits the VM, and @kbd{ctrl-a c} switches between the
  27352. QEMU monitor and the VM.
  27353. @cindex System images, creation in various formats
  27354. @cindex Creating system images in various formats
  27355. @item image
  27356. @cindex image, creating disk images
  27357. The @code{image} command can produce various image types. The
  27358. image type can be selected using the @option{--image-type} option. It
  27359. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  27360. @option{--label} option can be used to specify a volume ID with
  27361. @code{image}. By default, the root file system of a disk image is
  27362. mounted non-volatile; the @option{--volatile} option can be provided to
  27363. make it volatile instead. When using @code{image}, the bootloader
  27364. installed on the generated image is taken from the provided
  27365. @code{operating-system} definition. The following example demonstrates
  27366. how to generate an image that uses the @code{grub-efi-bootloader}
  27367. bootloader and boot it with QEMU:
  27368. @example
  27369. image=$(guix system image --image-type=qcow2 \
  27370. gnu/system/examples/lightweight-desktop.tmpl)
  27371. cp $image /tmp/my-image.qcow2
  27372. chmod +w /tmp/my-image.qcow2
  27373. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  27374. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  27375. @end example
  27376. When using the @code{efi-raw} image type, a raw disk image is produced;
  27377. it can be copied as is to a USB stick, for instance. Assuming
  27378. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  27379. the image to it using the following command:
  27380. @example
  27381. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  27382. @end example
  27383. The @code{--list-image-types} command lists all the available image
  27384. types.
  27385. @cindex creating virtual machine images
  27386. When using the @code{qcow2} image type, the returned image is in qcow2
  27387. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  27388. in a VM}, for more information on how to run the image in a virtual
  27389. machine. The @code{grub-bootloader} bootloader is always used
  27390. independently of what is declared in the @code{operating-system} file
  27391. passed as argument. This is to make it easier to work with QEMU, which
  27392. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  27393. in the Master Boot Record (MBR).
  27394. @cindex docker-image, creating docker images
  27395. When using the @code{docker} image type, a Docker image is produced.
  27396. Guix builds the image from scratch, not from a pre-existing Docker base
  27397. image. As a result, it contains @emph{exactly} what you define in the
  27398. operating system configuration file. You can then load the image and
  27399. launch a Docker container using commands like the following:
  27400. @example
  27401. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  27402. container_id="$(docker create $image_id)"
  27403. docker start $container_id
  27404. @end example
  27405. This command starts a new Docker container from the specified image. It
  27406. will boot the Guix system in the usual manner, which means it will
  27407. start any services you have defined in the operating system
  27408. configuration. You can get an interactive shell running in the container
  27409. using @command{docker exec}:
  27410. @example
  27411. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  27412. @end example
  27413. Depending on what you run in the Docker container, it
  27414. may be necessary to give the container additional permissions. For
  27415. example, if you intend to build software using Guix inside of the Docker
  27416. container, you may need to pass the @option{--privileged} option to
  27417. @code{docker create}.
  27418. Last, the @option{--network} option applies to @command{guix system
  27419. docker-image}: it produces an image where network is supposedly shared
  27420. with the host, and thus without services like nscd or NetworkManager.
  27421. @item container
  27422. Return a script to run the operating system declared in @var{file}
  27423. within a container. Containers are a set of lightweight isolation
  27424. mechanisms provided by the kernel Linux-libre. Containers are
  27425. substantially less resource-demanding than full virtual machines since
  27426. the kernel, shared objects, and other resources can be shared with the
  27427. host system; this also means they provide thinner isolation.
  27428. Currently, the script must be run as root in order to support more than
  27429. a single user and group. The container shares its store with the host
  27430. system.
  27431. As with the @code{vm} action (@pxref{guix system vm}), additional file
  27432. systems to be shared between the host and container can be specified
  27433. using the @option{--share} and @option{--expose} options:
  27434. @example
  27435. guix system container my-config.scm \
  27436. --expose=$HOME --share=$HOME/tmp=/exchange
  27437. @end example
  27438. @quotation Note
  27439. This option requires Linux-libre 3.19 or newer.
  27440. @end quotation
  27441. @end table
  27442. @var{options} can contain any of the common build options (@pxref{Common
  27443. Build Options}). In addition, @var{options} can contain one of the
  27444. following:
  27445. @table @option
  27446. @item --expression=@var{expr}
  27447. @itemx -e @var{expr}
  27448. Consider the operating-system @var{expr} evaluates to.
  27449. This is an alternative to specifying a file which evaluates to an
  27450. operating system.
  27451. This is used to generate the Guix system installer @pxref{Building the
  27452. Installation Image}).
  27453. @item --system=@var{system}
  27454. @itemx -s @var{system}
  27455. Attempt to build for @var{system} instead of the host system type.
  27456. This works as per @command{guix build} (@pxref{Invoking guix build}).
  27457. @item --derivation
  27458. @itemx -d
  27459. Return the derivation file name of the given operating system without
  27460. building anything.
  27461. @cindex provenance tracking, of the operating system
  27462. @item --save-provenance
  27463. As discussed above, @command{guix system init} and @command{guix system
  27464. reconfigure} always save provenance information @i{via} a dedicated
  27465. service (@pxref{Service Reference, @code{provenance-service-type}}).
  27466. However, other commands don't do that by default. If you wish to, say,
  27467. create a virtual machine image that contains provenance information, you
  27468. can run:
  27469. @example
  27470. guix system image -t qcow2 --save-provenance config.scm
  27471. @end example
  27472. That way, the resulting image will effectively ``embed its own source''
  27473. in the form of meta-data in @file{/run/current-system}. With that
  27474. information, one can rebuild the image to make sure it really contains
  27475. what it pretends to contain; or they could use that to derive a variant
  27476. of the image.
  27477. @item --image-type=@var{type}
  27478. @itemx -t @var{type}
  27479. For the @code{image} action, create an image with given @var{type}.
  27480. When this option is omitted, @command{guix system} uses the
  27481. @code{efi-raw} image type.
  27482. @cindex ISO-9660 format
  27483. @cindex CD image format
  27484. @cindex DVD image format
  27485. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  27486. for burning on CDs and DVDs.
  27487. @item --image-size=@var{size}
  27488. For the @code{image} action, create an image of the given @var{size}.
  27489. @var{size} may be a number of bytes, or it may include a unit as a
  27490. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  27491. Coreutils}).
  27492. When this option is omitted, @command{guix system} computes an estimate
  27493. of the image size as a function of the size of the system declared in
  27494. @var{file}.
  27495. @item --network
  27496. @itemx -N
  27497. For the @code{container} action, allow containers to access the host network,
  27498. that is, do not create a network namespace.
  27499. @item --root=@var{file}
  27500. @itemx -r @var{file}
  27501. Make @var{file} a symlink to the result, and register it as a garbage
  27502. collector root.
  27503. @item --skip-checks
  27504. Skip pre-installation safety checks.
  27505. By default, @command{guix system init} and @command{guix system
  27506. reconfigure} perform safety checks: they make sure the file systems that
  27507. appear in the @code{operating-system} declaration actually exist
  27508. (@pxref{File Systems}), and that any Linux kernel modules that may be
  27509. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  27510. RAM Disk}). Passing this option skips these tests altogether.
  27511. @item --allow-downgrades
  27512. Instruct @command{guix system reconfigure} to allow system downgrades.
  27513. By default, @command{reconfigure} prevents you from downgrading your
  27514. system. It achieves that by comparing the provenance info of your
  27515. system (shown by @command{guix system describe}) with that of your
  27516. @command{guix} command (shown by @command{guix describe}). If the
  27517. commits for @command{guix} are not descendants of those used for your
  27518. system, @command{guix system reconfigure} errors out. Passing
  27519. @option{--allow-downgrades} allows you to bypass these checks.
  27520. @quotation Note
  27521. Make sure you understand its security implications before using
  27522. @option{--allow-downgrades}.
  27523. @end quotation
  27524. @cindex on-error
  27525. @cindex on-error strategy
  27526. @cindex error strategy
  27527. @item --on-error=@var{strategy}
  27528. Apply @var{strategy} when an error occurs when reading @var{file}.
  27529. @var{strategy} may be one of the following:
  27530. @table @code
  27531. @item nothing-special
  27532. Report the error concisely and exit. This is the default strategy.
  27533. @item backtrace
  27534. Likewise, but also display a backtrace.
  27535. @item debug
  27536. Report the error and enter Guile's debugger. From there, you can run
  27537. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  27538. display local variable values, and more generally inspect the state of the
  27539. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  27540. a list of available debugging commands.
  27541. @end table
  27542. @end table
  27543. Once you have built, configured, re-configured, and re-re-configured
  27544. your Guix installation, you may find it useful to list the operating
  27545. system generations available on disk---and that you can choose from the
  27546. bootloader boot menu:
  27547. @table @code
  27548. @item describe
  27549. Describe the current system generation: its file name, the kernel and
  27550. bootloader used, etc., as well as provenance information when available.
  27551. @item list-generations
  27552. List a summary of each generation of the operating system available on
  27553. disk, in a human-readable way. This is similar to the
  27554. @option{--list-generations} option of @command{guix package}
  27555. (@pxref{Invoking guix package}).
  27556. Optionally, one can specify a pattern, with the same syntax that is used
  27557. in @command{guix package --list-generations}, to restrict the list of
  27558. generations displayed. For instance, the following command displays
  27559. generations that are up to 10 days old:
  27560. @example
  27561. $ guix system list-generations 10d
  27562. @end example
  27563. @end table
  27564. The @command{guix system} command has even more to offer! The following
  27565. sub-commands allow you to visualize how your system services relate to
  27566. each other:
  27567. @anchor{system-extension-graph}
  27568. @table @code
  27569. @item extension-graph
  27570. Emit to standard output the @dfn{service
  27571. extension graph} of the operating system defined in @var{file}
  27572. (@pxref{Service Composition}, for more information on service
  27573. extensions). By default the output is in Dot/Graphviz format, but you
  27574. can choose a different format with @option{--graph-backend}, as with
  27575. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  27576. The command:
  27577. @example
  27578. $ guix system extension-graph @var{file} | xdot -
  27579. @end example
  27580. shows the extension relations among services.
  27581. @anchor{system-shepherd-graph}
  27582. @item shepherd-graph
  27583. Emit to standard output the @dfn{dependency
  27584. graph} of shepherd services of the operating system defined in
  27585. @var{file}. @xref{Shepherd Services}, for more information and for an
  27586. example graph.
  27587. Again, the default output format is Dot/Graphviz, but you can pass
  27588. @option{--graph-backend} to select a different one.
  27589. @end table
  27590. @node Invoking guix deploy
  27591. @section Invoking @code{guix deploy}
  27592. We've already seen @code{operating-system} declarations used to manage a
  27593. machine's configuration locally. Suppose you need to configure multiple
  27594. machines, though---perhaps you're managing a service on the web that's
  27595. comprised of several servers. @command{guix deploy} enables you to use those
  27596. same @code{operating-system} declarations to manage multiple remote hosts at
  27597. once as a logical ``deployment''.
  27598. @quotation Note
  27599. The functionality described in this section is still under development
  27600. and is subject to change. Get in touch with us on
  27601. @email{guix-devel@@gnu.org}!
  27602. @end quotation
  27603. @example
  27604. guix deploy @var{file}
  27605. @end example
  27606. Such an invocation will deploy the machines that the code within @var{file}
  27607. evaluates to. As an example, @var{file} might contain a definition like this:
  27608. @lisp
  27609. ;; This is a Guix deployment of a "bare bones" setup, with
  27610. ;; no X11 display server, to a machine with an SSH daemon
  27611. ;; listening on localhost:2222. A configuration such as this
  27612. ;; may be appropriate for virtual machine with ports
  27613. ;; forwarded to the host's loopback interface.
  27614. (use-service-modules networking ssh)
  27615. (use-package-modules bootloaders)
  27616. (define %system
  27617. (operating-system
  27618. (host-name "gnu-deployed")
  27619. (timezone "Etc/UTC")
  27620. (bootloader (bootloader-configuration
  27621. (bootloader grub-bootloader)
  27622. (targets '("/dev/vda"))
  27623. (terminal-outputs '(console))))
  27624. (file-systems (cons (file-system
  27625. (mount-point "/")
  27626. (device "/dev/vda1")
  27627. (type "ext4"))
  27628. %base-file-systems))
  27629. (services
  27630. (append (list (service dhcp-client-service-type)
  27631. (service openssh-service-type
  27632. (openssh-configuration
  27633. (permit-root-login #t)
  27634. (allow-empty-passwords? #t))))
  27635. %base-services))))
  27636. (list (machine
  27637. (operating-system %system)
  27638. (environment managed-host-environment-type)
  27639. (configuration (machine-ssh-configuration
  27640. (host-name "localhost")
  27641. (system "x86_64-linux")
  27642. (user "alice")
  27643. (identity "./id_rsa")
  27644. (port 2222)))))
  27645. @end lisp
  27646. The file should evaluate to a list of @var{machine} objects. This example,
  27647. upon being deployed, will create a new generation on the remote system
  27648. realizing the @code{operating-system} declaration @code{%system}.
  27649. @code{environment} and @code{configuration} specify how the machine should be
  27650. provisioned---that is, how the computing resources should be created and
  27651. managed. The above example does not create any resources, as a
  27652. @code{'managed-host} is a machine that is already running the Guix system and
  27653. available over the network. This is a particularly simple case; a more
  27654. complex deployment may involve, for example, starting virtual machines through
  27655. a Virtual Private Server (VPS) provider. In such a case, a different
  27656. @var{environment} type would be used.
  27657. Do note that you first need to generate a key pair on the coordinator machine
  27658. to allow the daemon to export signed archives of files from the store
  27659. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  27660. System:
  27661. @example
  27662. # guix archive --generate-key
  27663. @end example
  27664. @noindent
  27665. Each target machine must authorize the key of the master machine so that it
  27666. accepts store items it receives from the coordinator:
  27667. @example
  27668. # guix archive --authorize < coordinator-public-key.txt
  27669. @end example
  27670. @code{user}, in this example, specifies the name of the user account to log in
  27671. as to perform the deployment. Its default value is @code{root}, but root
  27672. login over SSH may be forbidden in some cases. To work around this,
  27673. @command{guix deploy} can log in as an unprivileged user and employ
  27674. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  27675. currently installed on the remote and can be invoked non-interactively as
  27676. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  27677. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  27678. be accomplished with the following operating system configuration snippet:
  27679. @lisp
  27680. (use-modules ...
  27681. (gnu system)) ;for %sudoers-specification
  27682. (define %user "username")
  27683. (operating-system
  27684. ...
  27685. (sudoers-file
  27686. (plain-file "sudoers"
  27687. (string-append (plain-file-content %sudoers-specification)
  27688. (format #f "~a ALL = NOPASSWD: ALL~%"
  27689. %user)))))
  27690. @end lisp
  27691. For more information regarding the format of the @file{sudoers} file,
  27692. consult @command{man sudoers}.
  27693. @deftp {Data Type} machine
  27694. This is the data type representing a single machine in a heterogeneous Guix
  27695. deployment.
  27696. @table @asis
  27697. @item @code{operating-system}
  27698. The object of the operating system configuration to deploy.
  27699. @item @code{environment}
  27700. An @code{environment-type} describing how the machine should be provisioned.
  27701. @item @code{configuration} (default: @code{#f})
  27702. An object describing the configuration for the machine's @code{environment}.
  27703. If the @code{environment} has a default configuration, @code{#f} may be used.
  27704. If @code{#f} is used for an environment with no default configuration,
  27705. however, an error will be thrown.
  27706. @end table
  27707. @end deftp
  27708. @deftp {Data Type} machine-ssh-configuration
  27709. This is the data type representing the SSH client parameters for a machine
  27710. with an @code{environment} of @code{managed-host-environment-type}.
  27711. @table @asis
  27712. @item @code{host-name}
  27713. @item @code{build-locally?} (default: @code{#t})
  27714. If false, system derivations will be built on the machine being deployed to.
  27715. @item @code{system}
  27716. The system type describing the architecture of the machine being deployed
  27717. to---e.g., @code{"x86_64-linux"}.
  27718. @item @code{authorize?} (default: @code{#t})
  27719. If true, the coordinator's signing key will be added to the remote's ACL
  27720. keyring.
  27721. @item @code{port} (default: @code{22})
  27722. @item @code{user} (default: @code{"root"})
  27723. @item @code{identity} (default: @code{#f})
  27724. If specified, the path to the SSH private key to use to authenticate with the
  27725. remote host.
  27726. @item @code{host-key} (default: @code{#f})
  27727. This should be the SSH host key of the machine, which looks like this:
  27728. @example
  27729. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  27730. @end example
  27731. When @code{host-key} is @code{#f}, the server is authenticated against
  27732. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  27733. client does.
  27734. @item @code{allow-downgrades?} (default: @code{#f})
  27735. Whether to allow potential downgrades.
  27736. Like @command{guix system reconfigure}, @command{guix deploy} compares
  27737. the channel commits currently deployed on the remote host (as returned
  27738. by @command{guix system describe}) to those currently in use (as
  27739. returned by @command{guix describe}) to determine whether commits
  27740. currently in use are descendants of those deployed. When this is not
  27741. the case and @code{allow-downgrades?} is false, it raises an error.
  27742. This ensures you do not accidentally downgrade remote machines.
  27743. @end table
  27744. @end deftp
  27745. @deftp {Data Type} digital-ocean-configuration
  27746. This is the data type describing the Droplet that should be created for a
  27747. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  27748. @table @asis
  27749. @item @code{ssh-key}
  27750. The path to the SSH private key to use to authenticate with the remote
  27751. host. In the future, this field may not exist.
  27752. @item @code{tags}
  27753. A list of string ``tags'' that uniquely identify the machine. Must be given
  27754. such that no two machines in the deployment have the same set of tags.
  27755. @item @code{region}
  27756. A Digital Ocean region slug, such as @code{"nyc3"}.
  27757. @item @code{size}
  27758. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  27759. @item @code{enable-ipv6?}
  27760. Whether or not the droplet should be created with IPv6 networking.
  27761. @end table
  27762. @end deftp
  27763. @node Running Guix in a VM
  27764. @section Running Guix in a Virtual Machine
  27765. @cindex virtual machine
  27766. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM
  27767. image distributed at
  27768. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2}.
  27769. This image is a compressed image in QCOW format. You can pass it to an
  27770. emulator such as @uref{https://qemu.org/, QEMU} (see below for details).
  27771. This image boots the Xfce graphical environment and it contains some
  27772. commonly used tools. You can install more software in the image by running
  27773. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  27774. also reconfigure the system based on its initial configuration file available
  27775. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  27776. Configuration System}).
  27777. Instead of using this pre-built image, one can also build their own
  27778. image using @command{guix system image} (@pxref{Invoking guix system}).
  27779. @cindex QEMU
  27780. If you built your own image, you must copy it out of the store
  27781. (@pxref{The Store}) and give yourself permission to write to the copy
  27782. before you can use it. When invoking QEMU, you must choose a system
  27783. emulator that is suitable for your hardware platform. Here is a minimal
  27784. QEMU invocation that will boot the result of @command{guix system
  27785. image -t qcow2} on x86_64 hardware:
  27786. @example
  27787. $ qemu-system-x86_64 \
  27788. -nic user,model=virtio-net-pci \
  27789. -enable-kvm -m 1024 \
  27790. -device virtio-blk,drive=myhd \
  27791. -drive if=none,file=/tmp/qemu-image,id=myhd
  27792. @end example
  27793. Here is what each of these options means:
  27794. @table @code
  27795. @item qemu-system-x86_64
  27796. This specifies the hardware platform to emulate. This should match the
  27797. host.
  27798. @item -nic user,model=virtio-net-pci
  27799. Enable the unprivileged user-mode network stack. The guest OS can
  27800. access the host but not vice versa. This is the simplest way to get the
  27801. guest OS online. @code{model} specifies which network device to emulate:
  27802. @code{virtio-net-pci} is a special device made for virtualized operating
  27803. systems and recommended for most uses. Assuming your hardware platform is
  27804. x86_64, you can get a list of available NIC models by running
  27805. @command{qemu-system-x86_64 -nic model=help}.
  27806. @item -enable-kvm
  27807. If your system has hardware virtualization extensions, enabling the
  27808. virtual machine support (KVM) of the Linux kernel will make things run
  27809. faster.
  27810. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  27811. @item -m 1024
  27812. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  27813. which may be insufficient for some operations.
  27814. @item -device virtio-blk,drive=myhd
  27815. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  27816. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  27817. better performance than if it were emulating a complete disk drive. See the
  27818. QEMU and KVM documentation for more info.
  27819. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  27820. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  27821. store of the ``myhd'' drive.
  27822. @end table
  27823. The default @command{run-vm.sh} script that is returned by an invocation of
  27824. @command{guix system vm} does not add a @command{-nic user} flag by default.
  27825. To get network access from within the vm add the @code{(dhcp-client-service)}
  27826. to your system definition and start the VM using
  27827. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  27828. @command{-nic user} for networking is that @command{ping} will not work, because
  27829. it uses the ICMP protocol. You'll have to use a different command to check for
  27830. network connectivity, for example @command{guix download}.
  27831. @subsection Connecting Through SSH
  27832. @cindex SSH
  27833. @cindex SSH server
  27834. To enable SSH inside a VM you need to add an SSH server like
  27835. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  27836. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  27837. 22 by default, to the host. You can do this with
  27838. @example
  27839. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  27840. @end example
  27841. To connect to the VM you can run
  27842. @example
  27843. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
  27844. @end example
  27845. The @command{-p} tells @command{ssh} the port you want to connect to.
  27846. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  27847. every time you modify your @command{config.scm} file and the
  27848. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  27849. connection to an unknown host every time you connect.
  27850. @quotation Note
  27851. If you find the above @samp{hostfwd} example not to be working (e.g.,
  27852. your SSH client hangs attempting to connect to the mapped port of your
  27853. VM), make sure that your Guix System VM has networking support, such as
  27854. by using the @code{dhcp-client-service-type} service type.
  27855. @end quotation
  27856. @subsection Using @command{virt-viewer} with Spice
  27857. As an alternative to the default @command{qemu} graphical client you can
  27858. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  27859. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  27860. @command{qemu}. See previous section for further information on how to do this.
  27861. Spice also allows you to do some nice stuff like share your clipboard with your
  27862. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  27863. @example
  27864. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  27865. -chardev spicevmc,name=vdagent,id=vdagent
  27866. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,\
  27867. name=com.redhat.spice.0
  27868. @end example
  27869. You'll also need to add the @code{(spice-vdagent-service)} to your
  27870. system definition (@pxref{Miscellaneous Services, Spice service}).
  27871. @node Defining Services
  27872. @section Defining Services
  27873. The previous sections show the available services and how one can combine
  27874. them in an @code{operating-system} declaration. But how do we define
  27875. them in the first place? And what is a service anyway?
  27876. @menu
  27877. * Service Composition:: The model for composing services.
  27878. * Service Types and Services:: Types and services.
  27879. * Service Reference:: API reference.
  27880. * Shepherd Services:: A particular type of service.
  27881. * Complex Configurations:: Defining bindings for complex configurations.
  27882. @end menu
  27883. @node Service Composition
  27884. @subsection Service Composition
  27885. @cindex services
  27886. @cindex daemons
  27887. Here we define a @dfn{service} as, broadly, something that extends the
  27888. functionality of the operating system. Often a service is a process---a
  27889. @dfn{daemon}---started when the system boots: a secure shell server, a
  27890. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  27891. whose execution can be triggered by another daemon---e.g., an FTP server
  27892. started by @command{inetd} or a D-Bus service activated by
  27893. @command{dbus-daemon}. Occasionally, a service does not map to a
  27894. daemon. For instance, the ``account'' service collects user accounts
  27895. and makes sure they exist when the system runs; the ``udev'' service
  27896. collects device management rules and makes them available to the eudev
  27897. daemon; the @file{/etc} service populates the @file{/etc} directory
  27898. of the system.
  27899. @cindex service extensions
  27900. Guix system services are connected by @dfn{extensions}. For instance, the
  27901. secure shell service @emph{extends} the Shepherd---the
  27902. initialization system, running as PID@tie{}1---by giving it the command
  27903. lines to start and stop the secure shell daemon (@pxref{Networking
  27904. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  27905. service by passing it its @file{.service} specification, and extends the
  27906. udev service by passing it device management rules (@pxref{Desktop
  27907. Services, @code{upower-service}}); the Guix daemon service extends the
  27908. Shepherd by passing it the command lines to start and stop the daemon,
  27909. and extends the account service by passing it a list of required build
  27910. user accounts (@pxref{Base Services}).
  27911. All in all, services and their ``extends'' relations form a directed
  27912. acyclic graph (DAG). If we represent services as boxes and extensions
  27913. as arrows, a typical system might provide something like this:
  27914. @image{images/service-graph,,5in,Typical service extension graph.}
  27915. @cindex system service
  27916. At the bottom, we see the @dfn{system service}, which produces the
  27917. directory containing everything to run and boot the system, as returned
  27918. by the @command{guix system build} command. @xref{Service Reference},
  27919. to learn about the other service types shown here.
  27920. @xref{system-extension-graph, the @command{guix system extension-graph}
  27921. command}, for information on how to generate this representation for a
  27922. particular operating system definition.
  27923. @cindex service types
  27924. Technically, developers can define @dfn{service types} to express these
  27925. relations. There can be any number of services of a given type on the
  27926. system---for instance, a system running two instances of the GNU secure
  27927. shell server (lsh) has two instances of @code{lsh-service-type}, with
  27928. different parameters.
  27929. The following section describes the programming interface for service
  27930. types and services.
  27931. @node Service Types and Services
  27932. @subsection Service Types and Services
  27933. A @dfn{service type} is a node in the DAG described above. Let us start
  27934. with a simple example, the service type for the Guix build daemon
  27935. (@pxref{Invoking guix-daemon}):
  27936. @lisp
  27937. (define guix-service-type
  27938. (service-type
  27939. (name 'guix)
  27940. (extensions
  27941. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  27942. (service-extension account-service-type guix-accounts)
  27943. (service-extension activation-service-type guix-activation)))
  27944. (default-value (guix-configuration))))
  27945. @end lisp
  27946. @noindent
  27947. It defines three things:
  27948. @enumerate
  27949. @item
  27950. A name, whose sole purpose is to make inspection and debugging easier.
  27951. @item
  27952. A list of @dfn{service extensions}, where each extension designates the
  27953. target service type and a procedure that, given the parameters of the
  27954. service, returns a list of objects to extend the service of that type.
  27955. Every service type has at least one service extension. The only
  27956. exception is the @dfn{boot service type}, which is the ultimate service.
  27957. @item
  27958. Optionally, a default value for instances of this type.
  27959. @end enumerate
  27960. In this example, @code{guix-service-type} extends three services:
  27961. @table @code
  27962. @item shepherd-root-service-type
  27963. The @code{guix-shepherd-service} procedure defines how the Shepherd
  27964. service is extended. Namely, it returns a @code{<shepherd-service>}
  27965. object that defines how @command{guix-daemon} is started and stopped
  27966. (@pxref{Shepherd Services}).
  27967. @item account-service-type
  27968. This extension for this service is computed by @code{guix-accounts},
  27969. which returns a list of @code{user-group} and @code{user-account}
  27970. objects representing the build user accounts (@pxref{Invoking
  27971. guix-daemon}).
  27972. @item activation-service-type
  27973. Here @code{guix-activation} is a procedure that returns a gexp, which is
  27974. a code snippet to run at ``activation time''---e.g., when the service is
  27975. booted.
  27976. @end table
  27977. A service of this type is instantiated like this:
  27978. @lisp
  27979. (service guix-service-type
  27980. (guix-configuration
  27981. (build-accounts 5)
  27982. (extra-options '("--gc-keep-derivations"))))
  27983. @end lisp
  27984. The second argument to the @code{service} form is a value representing
  27985. the parameters of this specific service instance.
  27986. @xref{guix-configuration-type, @code{guix-configuration}}, for
  27987. information about the @code{guix-configuration} data type. When the
  27988. value is omitted, the default value specified by
  27989. @code{guix-service-type} is used:
  27990. @lisp
  27991. (service guix-service-type)
  27992. @end lisp
  27993. @code{guix-service-type} is quite simple because it extends other
  27994. services but is not extensible itself.
  27995. @c @subsubsubsection Extensible Service Types
  27996. The service type for an @emph{extensible} service looks like this:
  27997. @lisp
  27998. (define udev-service-type
  27999. (service-type (name 'udev)
  28000. (extensions
  28001. (list (service-extension shepherd-root-service-type
  28002. udev-shepherd-service)))
  28003. (compose concatenate) ;concatenate the list of rules
  28004. (extend (lambda (config rules)
  28005. (match config
  28006. (($ <udev-configuration> udev initial-rules)
  28007. (udev-configuration
  28008. (udev udev) ;the udev package to use
  28009. (rules (append initial-rules rules)))))))))
  28010. @end lisp
  28011. This is the service type for the
  28012. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  28013. management daemon}. Compared to the previous example, in addition to an
  28014. extension of @code{shepherd-root-service-type}, we see two new fields:
  28015. @table @code
  28016. @item compose
  28017. This is the procedure to @dfn{compose} the list of extensions to
  28018. services of this type.
  28019. Services can extend the udev service by passing it lists of rules; we
  28020. compose those extensions simply by concatenating them.
  28021. @item extend
  28022. This procedure defines how the value of the service is @dfn{extended} with
  28023. the composition of the extensions.
  28024. Udev extensions are composed into a list of rules, but the udev service
  28025. value is itself a @code{<udev-configuration>} record. So here, we
  28026. extend that record by appending the list of rules it contains to the
  28027. list of contributed rules.
  28028. @item description
  28029. This is a string giving an overview of the service type. The string can
  28030. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  28031. @command{guix system search} command searches these strings and displays
  28032. them (@pxref{Invoking guix system}).
  28033. @end table
  28034. There can be only one instance of an extensible service type such as
  28035. @code{udev-service-type}. If there were more, the
  28036. @code{service-extension} specifications would be ambiguous.
  28037. Still here? The next section provides a reference of the programming
  28038. interface for services.
  28039. @node Service Reference
  28040. @subsection Service Reference
  28041. We have seen an overview of service types (@pxref{Service Types and
  28042. Services}). This section provides a reference on how to manipulate
  28043. services and service types. This interface is provided by the
  28044. @code{(gnu services)} module.
  28045. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  28046. Return a new service of @var{type}, a @code{<service-type>} object (see
  28047. below). @var{value} can be any object; it represents the parameters of
  28048. this particular service instance.
  28049. When @var{value} is omitted, the default value specified by @var{type}
  28050. is used; if @var{type} does not specify a default value, an error is
  28051. raised.
  28052. For instance, this:
  28053. @lisp
  28054. (service openssh-service-type)
  28055. @end lisp
  28056. @noindent
  28057. is equivalent to this:
  28058. @lisp
  28059. (service openssh-service-type
  28060. (openssh-configuration))
  28061. @end lisp
  28062. In both cases the result is an instance of @code{openssh-service-type}
  28063. with the default configuration.
  28064. @end deffn
  28065. @deffn {Scheme Procedure} service? @var{obj}
  28066. Return true if @var{obj} is a service.
  28067. @end deffn
  28068. @deffn {Scheme Procedure} service-kind @var{service}
  28069. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  28070. @end deffn
  28071. @deffn {Scheme Procedure} service-value @var{service}
  28072. Return the value associated with @var{service}. It represents its
  28073. parameters.
  28074. @end deffn
  28075. Here is an example of how a service is created and manipulated:
  28076. @lisp
  28077. (define s
  28078. (service nginx-service-type
  28079. (nginx-configuration
  28080. (nginx nginx)
  28081. (log-directory log-directory)
  28082. (run-directory run-directory)
  28083. (file config-file))))
  28084. (service? s)
  28085. @result{} #t
  28086. (eq? (service-kind s) nginx-service-type)
  28087. @result{} #t
  28088. @end lisp
  28089. The @code{modify-services} form provides a handy way to change the
  28090. parameters of some of the services of a list such as
  28091. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  28092. evaluates to a list of services. Of course, you could always use
  28093. standard list combinators such as @code{map} and @code{fold} to do that
  28094. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  28095. @code{modify-services} simply provides a more concise form for this
  28096. common pattern.
  28097. @deffn {Scheme Syntax} modify-services @var{services} @
  28098. (@var{type} @var{variable} => @var{body}) @dots{}
  28099. Modify the services listed in @var{services} according to the given
  28100. clauses. Each clause has the form:
  28101. @example
  28102. (@var{type} @var{variable} => @var{body})
  28103. @end example
  28104. where @var{type} is a service type---e.g.,
  28105. @code{guix-service-type}---and @var{variable} is an identifier that is
  28106. bound within the @var{body} to the service parameters---e.g., a
  28107. @code{guix-configuration} instance---of the original service of that
  28108. @var{type}.
  28109. The @var{body} should evaluate to the new service parameters, which will
  28110. be used to configure the new service. This new service will replace the
  28111. original in the resulting list. Because a service's service parameters
  28112. are created using @code{define-record-type*}, you can write a succinct
  28113. @var{body} that evaluates to the new service parameters by using the
  28114. @code{inherit} feature that @code{define-record-type*} provides.
  28115. Clauses can also have the following form:
  28116. @lisp
  28117. (delete @var{type})
  28118. @end lisp
  28119. Such a clause removes all services of the given @var{type} from
  28120. @var{services}.
  28121. @xref{Using the Configuration System}, for example usage.
  28122. @end deffn
  28123. Next comes the programming interface for service types. This is
  28124. something you want to know when writing new service definitions, but not
  28125. necessarily when simply looking for ways to customize your
  28126. @code{operating-system} declaration.
  28127. @deftp {Data Type} service-type
  28128. @cindex service type
  28129. This is the representation of a @dfn{service type} (@pxref{Service Types
  28130. and Services}).
  28131. @table @asis
  28132. @item @code{name}
  28133. This is a symbol, used only to simplify inspection and debugging.
  28134. @item @code{extensions}
  28135. A non-empty list of @code{<service-extension>} objects (see below).
  28136. @item @code{compose} (default: @code{#f})
  28137. If this is @code{#f}, then the service type denotes services that cannot
  28138. be extended---i.e., services that do not receive ``values'' from other
  28139. services.
  28140. Otherwise, it must be a one-argument procedure. The procedure is called
  28141. by @code{fold-services} and is passed a list of values collected from
  28142. extensions. It may return any single value.
  28143. @item @code{extend} (default: @code{#f})
  28144. If this is @code{#f}, services of this type cannot be extended.
  28145. Otherwise, it must be a two-argument procedure: @code{fold-services}
  28146. calls it, passing it the initial value of the service as the first
  28147. argument and the result of applying @code{compose} to the extension
  28148. values as the second argument. It must return a value that is a valid
  28149. parameter value for the service instance.
  28150. @item @code{description}
  28151. This is a string, possibly using Texinfo markup, describing in a couple
  28152. of sentences what the service is about. This string allows users to
  28153. find about the service through @command{guix system search}
  28154. (@pxref{Invoking guix system}).
  28155. @item @code{default-value} (default: @code{&no-default-value})
  28156. The default value associated for instances of this service type. This
  28157. allows users to use the @code{service} form without its second argument:
  28158. @lisp
  28159. (service @var{type})
  28160. @end lisp
  28161. The returned service in this case has the default value specified by
  28162. @var{type}.
  28163. @end table
  28164. @xref{Service Types and Services}, for examples.
  28165. @end deftp
  28166. @deffn {Scheme Procedure} service-extension @var{target-type} @
  28167. @var{compute}
  28168. Return a new extension for services of type @var{target-type}.
  28169. @var{compute} must be a one-argument procedure: @code{fold-services}
  28170. calls it, passing it the value associated with the service that provides
  28171. the extension; it must return a valid value for the target service.
  28172. @end deffn
  28173. @deffn {Scheme Procedure} service-extension? @var{obj}
  28174. Return true if @var{obj} is a service extension.
  28175. @end deffn
  28176. Occasionally, you might want to simply extend an existing service. This
  28177. involves creating a new service type and specifying the extension of
  28178. interest, which can be verbose; the @code{simple-service} procedure
  28179. provides a shorthand for this.
  28180. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  28181. Return a service that extends @var{target} with @var{value}. This works
  28182. by creating a singleton service type @var{name}, of which the returned
  28183. service is an instance.
  28184. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  28185. an additional job:
  28186. @lisp
  28187. (simple-service 'my-mcron-job mcron-service-type
  28188. #~(job '(next-hour (3)) "guix gc -F 2G"))
  28189. @end lisp
  28190. @end deffn
  28191. At the core of the service abstraction lies the @code{fold-services}
  28192. procedure, which is responsible for ``compiling'' a list of services
  28193. down to a single directory that contains everything needed to boot and
  28194. run the system---the directory shown by the @command{guix system build}
  28195. command (@pxref{Invoking guix system}). In essence, it propagates
  28196. service extensions down the service graph, updating each node parameters
  28197. on the way, until it reaches the root node.
  28198. @deffn {Scheme Procedure} fold-services @var{services} @
  28199. [#:target-type @var{system-service-type}]
  28200. Fold @var{services} by propagating their extensions down to the root of
  28201. type @var{target-type}; return the root service adjusted accordingly.
  28202. @end deffn
  28203. Lastly, the @code{(gnu services)} module also defines several essential
  28204. service types, some of which are listed below.
  28205. @defvr {Scheme Variable} system-service-type
  28206. This is the root of the service graph. It produces the system directory
  28207. as returned by the @command{guix system build} command.
  28208. @end defvr
  28209. @defvr {Scheme Variable} boot-service-type
  28210. The type of the ``boot service'', which produces the @dfn{boot script}.
  28211. The boot script is what the initial RAM disk runs when booting.
  28212. @end defvr
  28213. @defvr {Scheme Variable} etc-service-type
  28214. The type of the @file{/etc} service. This service is used to create
  28215. files under @file{/etc} and can be extended by
  28216. passing it name/file tuples such as:
  28217. @lisp
  28218. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  28219. @end lisp
  28220. In this example, the effect would be to add an @file{/etc/issue} file
  28221. pointing to the given file.
  28222. @end defvr
  28223. @defvr {Scheme Variable} setuid-program-service-type
  28224. Type for the ``setuid-program service''. This service collects lists of
  28225. executable file names, passed as gexps, and adds them to the set of
  28226. setuid-root programs on the system (@pxref{Setuid Programs}).
  28227. @end defvr
  28228. @defvr {Scheme Variable} profile-service-type
  28229. Type of the service that populates the @dfn{system profile}---i.e., the
  28230. programs under @file{/run/current-system/profile}. Other services can
  28231. extend it by passing it lists of packages to add to the system profile.
  28232. @end defvr
  28233. @cindex provenance tracking, of the operating system
  28234. @anchor{provenance-service-type}
  28235. @defvr {Scheme Variable} provenance-service-type
  28236. This is the type of the service that records @dfn{provenance meta-data}
  28237. in the system itself. It creates several files under
  28238. @file{/run/current-system}:
  28239. @table @file
  28240. @item channels.scm
  28241. This is a ``channel file'' that can be passed to @command{guix pull -C}
  28242. or @command{guix time-machine -C}, and which describes the channels used
  28243. to build the system, if that information was available
  28244. (@pxref{Channels}).
  28245. @item configuration.scm
  28246. This is the file that was passed as the value for this
  28247. @code{provenance-service-type} service. By default, @command{guix
  28248. system reconfigure} automatically passes the OS configuration file it
  28249. received on the command line.
  28250. @item provenance
  28251. This contains the same information as the two other files but in a
  28252. format that is more readily processable.
  28253. @end table
  28254. In general, these two pieces of information (channels and configuration
  28255. file) are enough to reproduce the operating system ``from source''.
  28256. @quotation Caveats
  28257. This information is necessary to rebuild your operating system, but it
  28258. is not always sufficient. In particular, @file{configuration.scm}
  28259. itself is insufficient if it is not self-contained---if it refers to
  28260. external Guile modules or to extra files. If you want
  28261. @file{configuration.scm} to be self-contained, we recommend that modules
  28262. or files it refers to be part of a channel.
  28263. Besides, provenance meta-data is ``silent'' in the sense that it does
  28264. not change the bits contained in your system, @emph{except for the
  28265. meta-data bits themselves}. Two different OS configurations or sets of
  28266. channels can lead to the same system, bit-for-bit; when
  28267. @code{provenance-service-type} is used, these two systems will have
  28268. different meta-data and thus different store file names, which makes
  28269. comparison less trivial.
  28270. @end quotation
  28271. This service is automatically added to your operating system
  28272. configuration when you use @command{guix system reconfigure},
  28273. @command{guix system init}, or @command{guix deploy}.
  28274. @end defvr
  28275. @defvr {Scheme Variable} linux-loadable-module-service-type
  28276. Type of the service that collects lists of packages containing
  28277. kernel-loadable modules, and adds them to the set of kernel-loadable
  28278. modules.
  28279. This service type is intended to be extended by other service types,
  28280. such as below:
  28281. @lisp
  28282. (simple-service 'installing-module
  28283. linux-loadable-module-service-type
  28284. (list module-to-install-1
  28285. module-to-install-2))
  28286. @end lisp
  28287. This does not actually load modules at bootup, only adds it to the
  28288. kernel profile so that it @emph{can} be loaded by other means.
  28289. @end defvr
  28290. @node Shepherd Services
  28291. @subsection Shepherd Services
  28292. @cindex shepherd services
  28293. @cindex PID 1
  28294. @cindex init system
  28295. The @code{(gnu services shepherd)} module provides a way to define
  28296. services managed by the GNU@tie{}Shepherd, which is the
  28297. initialization system---the first process that is started when the
  28298. system boots, also known as PID@tie{}1
  28299. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  28300. Services in the Shepherd can depend on each other. For instance, the
  28301. SSH daemon may need to be started after the syslog daemon has been
  28302. started, which in turn can only happen once all the file systems have
  28303. been mounted. The simple operating system defined earlier (@pxref{Using
  28304. the Configuration System}) results in a service graph like this:
  28305. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  28306. You can actually generate such a graph for any operating system
  28307. definition using the @command{guix system shepherd-graph} command
  28308. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  28309. The @code{%shepherd-root-service} is a service object representing
  28310. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  28311. by passing it lists of @code{<shepherd-service>} objects.
  28312. @deftp {Data Type} shepherd-service
  28313. The data type representing a service managed by the Shepherd.
  28314. @table @asis
  28315. @item @code{provision}
  28316. This is a list of symbols denoting what the service provides.
  28317. These are the names that may be passed to @command{herd start},
  28318. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  28319. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  28320. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  28321. @item @code{requirement} (default: @code{'()})
  28322. List of symbols denoting the Shepherd services this one depends on.
  28323. @cindex one-shot services, for the Shepherd
  28324. @item @code{one-shot?} (default: @code{#f})
  28325. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  28326. after their @code{start} action has completed. @xref{Slots of services,,,
  28327. shepherd, The GNU Shepherd Manual}, for more info.
  28328. @item @code{respawn?} (default: @code{#t})
  28329. Whether to restart the service when it stops, for instance when the
  28330. underlying process dies.
  28331. @item @code{start}
  28332. @itemx @code{stop} (default: @code{#~(const #f)})
  28333. The @code{start} and @code{stop} fields refer to the Shepherd's
  28334. facilities to start and stop processes (@pxref{Service De- and
  28335. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  28336. G-expressions that get expanded in the Shepherd configuration file
  28337. (@pxref{G-Expressions}).
  28338. @item @code{actions} (default: @code{'()})
  28339. @cindex actions, of Shepherd services
  28340. This is a list of @code{shepherd-action} objects (see below) defining
  28341. @dfn{actions} supported by the service, in addition to the standard
  28342. @code{start} and @code{stop} actions. Actions listed here become available as
  28343. @command{herd} sub-commands:
  28344. @example
  28345. herd @var{action} @var{service} [@var{arguments}@dots{}]
  28346. @end example
  28347. @item @code{auto-start?} (default: @code{#t})
  28348. Whether this service should be started automatically by the Shepherd. If it
  28349. is @code{#f} the service has to be started manually with @code{herd start}.
  28350. @item @code{documentation}
  28351. A documentation string, as shown when running:
  28352. @example
  28353. herd doc @var{service-name}
  28354. @end example
  28355. where @var{service-name} is one of the symbols in @code{provision}
  28356. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  28357. @item @code{modules} (default: @code{%default-modules})
  28358. This is the list of modules that must be in scope when @code{start} and
  28359. @code{stop} are evaluated.
  28360. @end table
  28361. @end deftp
  28362. The example below defines a Shepherd service that spawns
  28363. @command{syslogd}, the system logger from the GNU Networking Utilities
  28364. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  28365. Inetutils}):
  28366. @example
  28367. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  28368. (shepherd-service
  28369. (documentation "Run the syslog daemon (syslogd).")
  28370. (provision '(syslogd))
  28371. (requirement '(user-processes))
  28372. (start #~(make-forkexec-constructor
  28373. (list #$(file-append inetutils "/libexec/syslogd")
  28374. "--rcfile" #$config)
  28375. #:pid-file "/var/run/syslog.pid"))
  28376. (stop #~(make-kill-destructor))))
  28377. @end example
  28378. Key elements in this example are the @code{start} and @code{stop}
  28379. fields: they are @dfn{staged} code snippets that use the
  28380. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  28381. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  28382. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  28383. field will have @command{shepherd} spawn @command{syslogd} with the
  28384. given option; note that we pass @code{config} after @option{--rcfile},
  28385. which is a configuration file declared above (contents of this file are
  28386. omitted). Likewise, the @code{stop} field tells how this service is to
  28387. be stopped; in this case, it is stopped by making the @code{kill} system
  28388. call on its PID@. Code staging is achieved using G-expressions:
  28389. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  28390. (@pxref{G-Expressions}).
  28391. @deftp {Data Type} shepherd-action
  28392. This is the data type that defines additional actions implemented by a
  28393. Shepherd service (see above).
  28394. @table @code
  28395. @item name
  28396. Symbol naming the action.
  28397. @item documentation
  28398. This is a documentation string for the action. It can be viewed by running:
  28399. @example
  28400. herd doc @var{service} action @var{action}
  28401. @end example
  28402. @item procedure
  28403. This should be a gexp that evaluates to a procedure of at least one argument,
  28404. which is the ``running value'' of the service (@pxref{Slots of services,,,
  28405. shepherd, The GNU Shepherd Manual}).
  28406. @end table
  28407. The following example defines an action called @code{say-hello} that kindly
  28408. greets the user:
  28409. @lisp
  28410. (shepherd-action
  28411. (name 'say-hello)
  28412. (documentation "Say hi!")
  28413. (procedure #~(lambda (running . args)
  28414. (format #t "Hello, friend! arguments: ~s\n"
  28415. args)
  28416. #t)))
  28417. @end lisp
  28418. Assuming this action is added to the @code{example} service, then you can do:
  28419. @example
  28420. # herd say-hello example
  28421. Hello, friend! arguments: ()
  28422. # herd say-hello example a b c
  28423. Hello, friend! arguments: ("a" "b" "c")
  28424. @end example
  28425. This, as you can see, is a fairly sophisticated way to say hello.
  28426. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  28427. info on actions.
  28428. @end deftp
  28429. @defvr {Scheme Variable} shepherd-root-service-type
  28430. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  28431. This is the service type that extensions target when they want to create
  28432. shepherd services (@pxref{Service Types and Services}, for an example).
  28433. Each extension must pass a list of @code{<shepherd-service>}. Its
  28434. value must be a @code{shepherd-configuration}, as described below.
  28435. @end defvr
  28436. @deftp {Data Type} shepherd-configuration
  28437. This data type represents the Shepherd's configuration.
  28438. @table @code
  28439. @item shepherd (default: @code{shepherd})
  28440. The Shepherd package to use.
  28441. @item services (default: @code{'()})
  28442. A list of @code{<shepherd-service>} to start.
  28443. You should probably use the service extension
  28444. mechanism instead (@pxref{Shepherd Services}).
  28445. @end table
  28446. @end deftp
  28447. The following example specifies the Shepherd package for the operating
  28448. system:
  28449. @lisp
  28450. (operating-system
  28451. ;; ...
  28452. (services (append (list openssh-service-type))
  28453. ;; ...
  28454. %desktop-services)
  28455. ;; ...
  28456. ;; Use own Shepherd package.
  28457. (essential-services
  28458. (modify-services (operating-system-default-essential-services
  28459. this-operating-system)
  28460. (shepherd-root-service-type config => (shepherd-configuration
  28461. (inherit config)
  28462. (shepherd my-shepherd))))))
  28463. @end lisp
  28464. @defvr {Scheme Variable} %shepherd-root-service
  28465. This service represents PID@tie{}1.
  28466. @end defvr
  28467. @node Complex Configurations
  28468. @subsection Complex Configurations
  28469. @cindex complex configurations
  28470. Some programs might have rather complex configuration files or formats,
  28471. and to make it easier to create Scheme bindings for these configuration
  28472. files, you can use the utilities defined in the @code{(gnu services
  28473. configuration)} module.
  28474. The main utility is the @code{define-configuration} macro, which you
  28475. will use to define a Scheme record type (@pxref{Record Overview,,,
  28476. guile, GNU Guile Reference Manual}). The Scheme record will be
  28477. serialized to a configuration file by using @dfn{serializers}, which are
  28478. procedures that take some kind of Scheme value and returns a
  28479. G-expression (@pxref{G-Expressions}), which should, once serialized to
  28480. the disk, return a string. More details are listed below.
  28481. @deffn {Scheme Syntax} define-configuration @var{name} @var{clause1} @
  28482. @var{clause2} ...
  28483. Create a record type named @code{@var{name}} that contains the
  28484. fields found in the clauses.
  28485. A clause can have one of the following forms:
  28486. @example
  28487. (@var{field-name}
  28488. (@var{type} @var{default-value})
  28489. @var{documentation})
  28490. (@var{field-name}
  28491. (@var{type} @var{default-value})
  28492. @var{documentation}
  28493. @var{serializer})
  28494. (@var{field-name}
  28495. (@var{type})
  28496. @var{documentation})
  28497. (@var{field-name}
  28498. (@var{type})
  28499. @var{documentation}
  28500. @var{serializer})
  28501. @end example
  28502. @var{field-name} is an identifier that denotes the name of the field in
  28503. the generated record.
  28504. @var{type} is the type of the value corresponding to @var{field-name};
  28505. since Guile is untyped, a predicate
  28506. procedure---@code{@var{type}?}---will be called on the value
  28507. corresponding to the field to ensure that the value is of the correct
  28508. type. This means that if say, @var{type} is @code{package}, then a
  28509. procedure named @code{package?} will be applied on the value to make
  28510. sure that it is indeed a @code{<package>} object.
  28511. @var{default-value} is the default value corresponding to the field; if
  28512. none is specified, the user is forced to provide a value when creating
  28513. an object of the record type.
  28514. @c XXX: Should these be full sentences or are they allow to be very
  28515. @c short like package synopses?
  28516. @var{documentation} is a string formatted with Texinfo syntax which
  28517. should provide a description of what setting this field does.
  28518. @var{serializer} is the name of a procedure which takes two arguments,
  28519. the first is the name of the field, and the second is the value
  28520. corresponding to the field. The procedure should return a string or
  28521. G-expression (@pxref{G-Expressions}) that represents the content that
  28522. will be serialized to the configuration file. If none is specified, a
  28523. procedure of the name @code{serialize-@var{type}} will be used.
  28524. A simple serializer procedure could look like this:
  28525. @lisp
  28526. (define (serialize-boolean field-name value)
  28527. (let ((value (if value "true" "false")))
  28528. #~(string-append #$field-name #$value)))
  28529. @end lisp
  28530. In some cases multiple different configuration records might be defined
  28531. in the same file, but their serializers for the same type might have to
  28532. be different, because they have different configuration formats. For
  28533. example, the @code{serialize-boolean} procedure for the Getmail service
  28534. would have to be different for the one for the Transmission service. To
  28535. make it easier to deal with this situation, one can specify a serializer
  28536. prefix by using the @code{prefix} literal in the
  28537. @code{define-configuration} form. This means that one doesn't have to
  28538. manually specify a custom @var{serializer} for every field.
  28539. @lisp
  28540. (define (foo-serialize-string field-name value)
  28541. @dots{})
  28542. (define (bar-serialize-string field-name value)
  28543. @dots{})
  28544. (define-configuration foo-configuration
  28545. (label
  28546. (string)
  28547. "The name of label.")
  28548. (prefix foo-))
  28549. (define-configuration bar-configuration
  28550. (ip-address
  28551. (string)
  28552. "The IPv4 address for this device.")
  28553. (prefix bar-))
  28554. @end lisp
  28555. However, in some cases you might not want to serialize any of the values
  28556. of the record, to do this, you can use the @code{no-serialization}
  28557. literal. There is also the @code{define-configuration/no-serialization}
  28558. macro which is a shorthand of this.
  28559. @lisp
  28560. ;; Nothing will be serialized to disk.
  28561. (define-configuration foo-configuration
  28562. (field
  28563. (string "test")
  28564. "Some documentation.")
  28565. (no-serialization))
  28566. ;; The same thing as above.
  28567. (define-configuration/no-serialization bar-configuration
  28568. (field
  28569. (string "test")
  28570. "Some documentation."))
  28571. @end lisp
  28572. @end deffn
  28573. @deffn {Scheme Syntax} define-maybe @var{type}
  28574. Sometimes a field should not be serialized if the user doesn’t specify a
  28575. value. To achieve this, you can use the @code{define-maybe} macro to
  28576. define a ``maybe type''; if the value of a maybe type is set to the
  28577. @code{disabled}, it will not be serialized.
  28578. When defining a ``maybe type'', the corresponding serializer for the
  28579. regular type will be used by default. For example, a field of type
  28580. @code{maybe-string} will be serialized using the @code{serialize-string}
  28581. procedure by default, you can of course change this by specifying a
  28582. custom serializer procedure. Likewise, the type of the value would have
  28583. to be a string, unless it is set to the @code{disabled} symbol.
  28584. @lisp
  28585. (define-maybe string)
  28586. (define (serialize-string field-name value)
  28587. @dots{})
  28588. (define-configuration baz-configuration
  28589. (name
  28590. ;; Nothing will be serialized by default. If set to a string, the
  28591. ;; `serialize-string' procedure will be used to serialize the string.
  28592. (maybe-string 'disabled)
  28593. "The name of this module."))
  28594. @end lisp
  28595. Like with @code{define-configuration}, one can set a prefix for the
  28596. serializer name by using the @code{prefix} literal.
  28597. @lisp
  28598. (define-maybe integer
  28599. (prefix baz-))
  28600. (define (baz-serialize-interger field-name value)
  28601. @dots{})
  28602. @end lisp
  28603. There is also the @code{no-serialization} literal, which when set means
  28604. that no serializer will be defined for the ``maybe type'', regardless of
  28605. its value is @code{disabled} or not.
  28606. @code{define-maybe/no-serialization} is a shorthand for specifying the
  28607. @code{no-serialization} literal.
  28608. @lisp
  28609. (define-maybe/no-serialization symbol)
  28610. (define-configuration/no-serialization test-configuration
  28611. (mode
  28612. (maybe-symbol 'disabled)
  28613. "Docstring."))
  28614. @end lisp
  28615. @end deffn
  28616. @deffn {Scheme Procedure} serialize-configuration @var{configuration} @
  28617. @var{fields}
  28618. Return a G-expression that contains the values corresponding to the
  28619. @var{fields} of @var{configuration}, a record that has been generated by
  28620. @code{define-configuration}. The G-expression can then be serialized to
  28621. disk by using something like @code{mixed-text-file}.
  28622. @end deffn
  28623. @deffn {Scheme Procedure} validate-configuration @var{configuration}
  28624. @var{fields}
  28625. Type-check @var{fields}, a list of field names of @var{configuration}, a
  28626. configuration record created by @code{define-configuration}.
  28627. @end deffn
  28628. @deffn {Scheme Procedure} empty-serializer @var{field-name} @var{value}
  28629. A serializer that just returns an empty string. The
  28630. @code{serialize-package} procedure is an alias for this.
  28631. @end deffn
  28632. Once you have defined a configuration record, you will most likely also
  28633. want to document it so that other people know to use it. To help with
  28634. that, there are two procedures, both of which are documented below.
  28635. @deffn {Scheme Procedure} generate-documentation @var{documentation} @
  28636. @var{documentation-name}
  28637. Generate a Texinfo fragment from the docstrings in @var{documentation},
  28638. a list of @code{(@var{label} @var{fields} @var{sub-documentation} ...)}.
  28639. @var{label} should be a symbol and should be the name of the
  28640. configuration record. @var{fields} should be a list of all the fields
  28641. available for the configuration record.
  28642. @var{sub-documentation} is a @code{(@var{field-name}
  28643. @var{configuration-name})} tuple. @var{field-name} is the name of the
  28644. field which takes another configuration record as its value, and
  28645. @var{configuration-name} is the name of that configuration record.
  28646. @var{sub-documentation} is only needed if there are nested configuration
  28647. records. For example, the @code{getmail-configuration} record
  28648. (@pxref{Mail Services}) accepts a @code{getmail-configuration-file}
  28649. record in one of its @code{rcfile} field, therefore documentation for
  28650. @code{getmail-configuration-file} is nested in
  28651. @code{getmail-configuration}.
  28652. @lisp
  28653. (generate-documentation
  28654. `((getmail-configuration ,getmail-configuration-fields
  28655. (rcfile getmail-configuration-file))
  28656. @dots{})
  28657. 'getmail-configuration)
  28658. @end lisp
  28659. @var{documentation-name} should be a symbol and should be the name of
  28660. the configuration record.
  28661. @end deffn
  28662. @deffn {Scheme Procedure} configuration->documentation
  28663. @var{configuration-symbol}
  28664. Take @var{configuration-symbol}, the symbol corresponding to the name
  28665. used when defining a configuration record with
  28666. @code{define-configuration}, and print the Texinfo documentation of its
  28667. fields. This is useful if there aren’t any nested configuration records
  28668. since it only prints the documentation for the top-level fields.
  28669. @end deffn
  28670. As of right now, there is no automated way to generate documentation for
  28671. configuration records and put them in the manual. Instead, every
  28672. time you make a change to the docstrings of a configuration record, you
  28673. have to manually call @code{generate-documentation} or
  28674. @code{configuration->documentation}, and paste the output into the
  28675. @file{doc/guix.texi} file.
  28676. @c TODO: Actually test this
  28677. Below is an example of a record type created using
  28678. @code{define-configuration} and friends.
  28679. @lisp
  28680. (use-modules (gnu services)
  28681. (guix gexp)
  28682. (gnu services configuration)
  28683. (srfi srfi-26)
  28684. (srfi srfi-1))
  28685. ;; Turn field names, which are Scheme symbols into strings
  28686. (define (uglify-field-name field-name)
  28687. (let ((str (symbol->string field-name)))
  28688. ;; field? -> is-field
  28689. (if (string-suffix? "?" str)
  28690. (string-append "is-" (string-drop-right str 1))
  28691. str)))
  28692. (define (serialize-string field-name value)
  28693. #~(string-append #$(uglify-field-name field-name) " = " #$value "\n"))
  28694. (define (serialize-integer field-name value)
  28695. (serialize-string field-name (number->string value)))
  28696. (define (serialize-boolean field-name value)
  28697. (serialize-string field-name (if value "true" "false")))
  28698. (define (serialize-contact-name field-name value)
  28699. #~(string-append "\n[" #$value "]\n"))
  28700. (define (list-of-contact-configurations? lst)
  28701. (every contact-configuration? lst))
  28702. (define (serialize-list-of-contact-configurations field-name value)
  28703. #~(string-append #$@@(map (cut serialize-configuration <>
  28704. contact-configuration-fields)
  28705. value)))
  28706. (define (serialize-contacts-list-configuration configuration)
  28707. (mixed-text-file
  28708. "contactrc"
  28709. #~(string-append "[Owner]\n"
  28710. #$(serialize-configuration
  28711. configuration contacts-list-configuration-fields))))
  28712. (define-maybe integer)
  28713. (define-maybe string)
  28714. (define-configuration contact-configuration
  28715. (name
  28716. (string)
  28717. "The name of the contact."
  28718. serialize-contact-name)
  28719. (phone-number
  28720. (maybe-integer 'disabled)
  28721. "The person's phone number.")
  28722. (email
  28723. (maybe-string 'disabled)
  28724. "The person's email address.")
  28725. (married?
  28726. (boolean)
  28727. "Whether the person is married."))
  28728. (define-configuration contacts-list-configuration
  28729. (name
  28730. (string)
  28731. "The name of the owner of this contact list.")
  28732. (email
  28733. (string)
  28734. "The owner's email address.")
  28735. (contacts
  28736. (list-of-contact-configurations '())
  28737. "A list of @@code@{contact-configuation@} records which contain
  28738. information about all your contacts."))
  28739. @end lisp
  28740. A contacts list configuration could then be created like this:
  28741. @lisp
  28742. (define my-contacts
  28743. (contacts-list-configuration
  28744. (name "Alice")
  28745. (email "alice@@example.org")
  28746. (contacts
  28747. (list (contact-configuration
  28748. (name "Bob")
  28749. (phone-number 1234)
  28750. (email "bob@@gnu.org")
  28751. (married? #f))
  28752. (contact-configuration
  28753. (name "Charlie")
  28754. (phone-number 0000)
  28755. (married? #t))))))
  28756. @end lisp
  28757. After serializing the configuration to disk, the resulting file would
  28758. look like this:
  28759. @example
  28760. [owner]
  28761. name = Alice
  28762. email = alice@@example.org
  28763. [Bob]
  28764. phone-number = 1234
  28765. email = bob@@gnu.org
  28766. is-married = false
  28767. [Charlie]
  28768. phone-number = 0
  28769. is-married = true
  28770. @end example
  28771. @node Home Configuration
  28772. @chapter Home Configuration
  28773. @cindex home configuration
  28774. Guix supports declarative configuration of @dfn{home environments} by
  28775. utilizing the configuration mechanism described in the previous chapter
  28776. (@pxref{Defining Services}), but for user's dotfiles and packages. It
  28777. works both on Guix System and foreign distros and allows users to
  28778. declare all the packages and services that should be installed and
  28779. configured for the user. Once a user has written a file containing
  28780. @code{home-environment} record, such a configuration can be
  28781. @dfn{instantiated} by an unprivileged user with the @command{guix home}
  28782. command (@pxref{Invoking guix home}).
  28783. @c Maybe later, it will be possible to make home configuration a part of
  28784. @c system configuration to make everything managed by guix system.
  28785. @quotation Note
  28786. The functionality described in this section is still under development
  28787. and is subject to change. Get in touch with us on
  28788. @email{guix-devel@@gnu.org}!
  28789. @end quotation
  28790. The user's home environment usually consists of three basic parts:
  28791. software, configuration, and state. Software in mainstream distros are
  28792. usually installed system-wide, but with GNU Guix most software packages
  28793. can be installed on a per-user basis without needing root privileges,
  28794. and are thus considered part of the user’s @dfn{home environment}.
  28795. Packages on their own not very useful in many cases, because often they
  28796. require some additional configuration, usually config files that reside
  28797. in @env{XDG_CONFIG_HOME} (@file{~/.config} by default) or other
  28798. directories. Everything else can be considered state, like media files,
  28799. application databases, and logs.
  28800. Using Guix for managing home environments provides a number of
  28801. advantages:
  28802. @itemize
  28803. @item All software can be configured in one language (Guile Scheme),
  28804. this gives users the ability to share values between configurations of
  28805. different programs.
  28806. @item A well-defined home environment is self-contained and can be
  28807. created in a declarative and reproducible way---there is no need to grab
  28808. external binaries or manually edit some configuration file.
  28809. @item After every @command{guix home reconfigure} invocation, a new home
  28810. environment generation will be created. This means that users can
  28811. rollback to a previous home environment generation so they don’t have to
  28812. worry about breaking their configuration.
  28813. @item It is possible to manage stateful data with Guix Home, this
  28814. includes the ability to automatically clone Git repositories on the
  28815. initial setup of the machine, and periodically running commands like
  28816. @command{rsync} to sync data with another host. This functionality is
  28817. still in an experimental stage, though.
  28818. @end itemize
  28819. @menu
  28820. * Declaring the Home Environment:: Customizing your Home.
  28821. * Configuring the Shell:: Enabling home environment.
  28822. * Home Services:: Specifying home services.
  28823. * Invoking guix home:: Instantiating a home configuration.
  28824. @end menu
  28825. @node Declaring the Home Environment
  28826. @section Declaring the Home Environment
  28827. The home environment is configured by providing a
  28828. @code{home-environment} declaration in a file that can be passed to the
  28829. @command{guix home} command (@pxref{Invoking guix home}). The easiest
  28830. way to get started is by generating an initial configuration with
  28831. @command{guix home import}:
  28832. @example
  28833. guix home import ~/src/guix-config
  28834. @end example
  28835. The @command{guix home import} command reads some of the ``dot files''
  28836. such as @file{~/.bashrc} found in your home directory and copies them to
  28837. the given directory, @file{~/src/guix-config} in this case; it also
  28838. reads the contents of your profile, @file{~/.guix-profile}, and, based
  28839. on that, it populates @file{~/src/guix-config/home-configuration.scm}
  28840. with a Home configuration that resembles your current configuration.
  28841. A simple setup can include Bash and a custom text configuration, like in
  28842. the example below. Don't be afraid to declare home environment parts,
  28843. which overlaps with your current dot files: before installing any
  28844. configuration files, Guix Home will back up existing config files to a
  28845. separate place in the home directory.
  28846. @quotation Note
  28847. It is highly recommended that you manage your shell or shells with Guix
  28848. Home, because it will make sure that all the necessary scripts are
  28849. sourced by the shell configuration file. Otherwise you will need to do
  28850. it manually. (@pxref{Configuring the Shell}).
  28851. @end quotation
  28852. @findex home-environment
  28853. @lisp
  28854. @include he-config-bare-bones.scm
  28855. @end lisp
  28856. The @code{packages} field should be self-explanatory, it will install
  28857. the list of packages into the user's profile. The most important field
  28858. is @code{services}, it contains a list of @dfn{home services}, which are
  28859. the basic building blocks of a home environment.
  28860. There is no daemon (at least not necessarily) related to a home service,
  28861. a home service is just an element that is used to declare part of home
  28862. environment and extend other parts of it. The extension mechanism
  28863. discussed in the previous chapter (@pxref{Defining Services}) should not
  28864. be confused with Shepherd services (@pxref{Shepherd Services}). Using this extension
  28865. mechanism and some Scheme code that glues things together gives the user
  28866. the freedom to declare their own, very custom, home environments.
  28867. Once you have a configuration file that suits your needs, you can
  28868. reconfigure your home by running:
  28869. @example
  28870. guix home reconfigure config.scm
  28871. @end example
  28872. This ``builds'' your home environment and creates @file{~/.guix-home}
  28873. pointing to it. Voilà!
  28874. @quotation Note
  28875. Make sure the operating system has elogind, systemd, or a similar
  28876. mechanism to create the XDG run-time directory and has the
  28877. @env{XDG_RUNTIME_DIR} variable set. Failing that, the
  28878. @file{on-first-login} script will not execute anything, and processes
  28879. like user Shepherd and its descendants will not start.
  28880. @end quotation
  28881. @node Configuring the Shell
  28882. @section Configuring the Shell
  28883. This section is safe to skip if your shell or shells are managed by
  28884. Guix Home. Otherwise, read it carefully.
  28885. There are a few scripts that must be evaluated by a login shell to
  28886. activate the home environment. The shell startup files only read by
  28887. login shells often have @code{profile} suffix. For more information
  28888. about login shells see @ref{Invoking Bash,,, bash, The GNU Bash
  28889. Reference Manual} and see @ref{Bash Startup Files,,, bash, The GNU Bash
  28890. Reference Manual}.
  28891. The first script that needs to be sourced is @file{setup-environment},
  28892. which sets all the necessary environment variables (including variables
  28893. declared by the user) and the second one is @file{on-first-login}, which
  28894. starts Shepherd for the current user and performs actions declared by
  28895. other home services that extends
  28896. @code{home-run-on-first-login-service-type}.
  28897. Guix Home will always create @file{~/.profile}, which contains the
  28898. following lines:
  28899. @example
  28900. HOME_ENVIRONMENT=$HOME/.guix-home
  28901. . $HOME_ENVIRONMENT/setup-environment
  28902. $HOME_ENVIRONMENT/on-first-login
  28903. @end example
  28904. This makes POSIX compliant login shells activate the home environment.
  28905. However, in most cases this file won't be read by most modern shells,
  28906. because they are run in non POSIX mode by default and have their own
  28907. @file{*profile} startup files. For example Bash will prefer
  28908. @file{~/.bash_profile} in case it exists and only if it doesn't will it
  28909. fallback to @file{~/.profile}. Zsh (if no additional options are
  28910. specified) will ignore @file{~/.profile}, even if @file{~/.zprofile}
  28911. doesn't exist.
  28912. To make your shell respect @file{~/.profile}, add @code{. ~/.profile} or
  28913. @code{source ~/profile} to the startup file for the login shell. In
  28914. case of Bash, it is @file{~/.bash_profile}, and in case of Zsh, it is
  28915. @file{~/.zprofile}.
  28916. @quotation Note
  28917. This step is only required if your shell is NOT managed by Guix Home.
  28918. Otherwise, everything will be done automatically.
  28919. @end quotation
  28920. @node Home Services
  28921. @section Home Services
  28922. @cindex home services
  28923. A @dfn{home service} is not necessarily something that has a daemon and
  28924. is managed by Shepherd (@pxref{Jump Start,,, shepherd, The GNU Shepherd
  28925. Manual}), in most cases it doesn't. It's a simple building block of the
  28926. home environment, often declaring a set of packages to be installed in
  28927. the home environment profile, a set of config files to be symlinked into
  28928. @env{XDG_CONFIG_HOME} (@file{~/.config} by default), and environment
  28929. variables to be set by a login shell.
  28930. There is a service extension mechanism (@pxref{Service Composition})
  28931. which allows home services to extend other home services and utilize
  28932. capabilities they provide; for example: declare mcron jobs
  28933. (@pxref{Top,,, mcron, GNU@tie{}Mcron}) by extending @ref{Mcron Home
  28934. Service}; declare daemons by extending @ref{Shepherd Home Service}; add
  28935. commands, which will be invoked on by the Bash by extending
  28936. @ref{Shells Home Services, @code{home-bash-service-type}}.
  28937. A good way to discover avaliable home services is using the
  28938. @command{guix home search} command (@pxref{Invoking guix home}). After
  28939. the required home services are found, include its module with the
  28940. @code{use-modules} form (@pxref{use-modules,, Using Guile Modules,
  28941. guile, The GNU Guile Reference Manual}), or the @code{#:use-modules}
  28942. directive (@pxref{define-module,, Creating Guile Modules, guile, The GNU
  28943. Guile Reference Manual}) and declare a home service using the
  28944. @code{service} function, or extend a service type by declaring a new
  28945. service with the @code{simple-service} procedure from @code{(gnu
  28946. services)}.
  28947. @menu
  28948. * Essential Home Services:: Environment variables, packages, on-* scripts.
  28949. * Shells: Shells Home Services. POSIX shells, Bash, Zsh.
  28950. * Mcron: Mcron Home Service. Scheduled User's Job Execution.
  28951. * Shepherd: Shepherd Home Service. Managing User's Daemons.
  28952. @end menu
  28953. @c In addition to that Home Services can provide
  28954. @node Essential Home Services
  28955. @subsection Essential Home Services
  28956. There are a few essential home services defined in
  28957. @code{(gnu services)}, they are mostly for internal use and are required
  28958. to build a home environment, but some of them will be useful for the end
  28959. user.
  28960. @cindex environment variables
  28961. @defvr {Scheme Variable} home-environment-variables-service-type
  28962. The service of this type will be instantiated by every home environment
  28963. automatically by default, there is no need to define it, but someone may
  28964. want to extend it with a list of pairs to set some environment
  28965. variables.
  28966. @lisp
  28967. (list ("ENV_VAR1" . "value1")
  28968. ("ENV_VAR2" . "value2"))
  28969. @end lisp
  28970. The easiest way to extend a service type, without defining new service
  28971. type is to use the @code{simple-service} helper from @code{(gnu
  28972. services)}.
  28973. @lisp
  28974. (simple-service 'some-useful-env-vars-service
  28975. home-environment-variables-service-type
  28976. `(("LESSHISTFILE" . "$XDG_CACHE_HOME/.lesshst")
  28977. ("SHELL" . ,(file-append zsh "/bin/zsh"))
  28978. ("USELESS_VAR" . #f)
  28979. ("_JAVA_AWT_WM_NONREPARENTING" . #t)))
  28980. @end lisp
  28981. If you include such a service in you home environment definition, it
  28982. will add the following content to the @file{setup-environment} script
  28983. (which is expected to be sourced by the login shell):
  28984. @example
  28985. export LESSHISTFILE=$XDG_CACHE_HOME/.lesshst
  28986. export SHELL=/gnu/store/2hsg15n644f0glrcbkb1kqknmmqdar03-zsh-5.8/bin/zsh
  28987. export _JAVA_AWT_WM_NONREPARENTING
  28988. @end example
  28989. @quotation Note
  28990. Make sure that module @code{(gnu packages shells)} is imported with
  28991. @code{use-modules} or any other way, this namespace contains the
  28992. definition of the @code{zsh} packages, which is used in the example
  28993. above.
  28994. @end quotation
  28995. The association list (@pxref{Association Lists, alists, Association
  28996. Lists, guile, The GNU Guile Reference manual}) is a data structure
  28997. containing key-value pairs, for
  28998. @code{home-environment-variables-service-type} the key is always a
  28999. string, the value can be a string, string-valued gexp
  29000. (@pxref{G-Expressions}), file-like object (@pxref{G-Expressions,
  29001. file-like object}) or boolean. For gexps, the variable will be set to
  29002. the value of the gexp; for file-like objects, it will be set to the path
  29003. of the file in the store (@pxref{The Store}); for @code{#t}, it will
  29004. export the variable without any value; and for @code{#f}, it will omit
  29005. variable.
  29006. @end defvr
  29007. @defvr {Scheme Variable} home-profile-service-type
  29008. The service of this type will be instantiated by every home environment
  29009. automatically, there is no need to define it, but you may want to extend
  29010. it with a list of packages if you want to install additional packages
  29011. into your profile. Other services, which need to make some programs
  29012. avaliable to the user will also extend this service type.
  29013. The extension value is just a list of packages:
  29014. @lisp
  29015. (list htop vim emacs)
  29016. @end lisp
  29017. The same approach as @code{simple-service} (@pxref{Service Reference,
  29018. simple-service}) for @code{home-environment-variables-service-type} can
  29019. be used here, too. Make sure that modules containing the specified
  29020. packages are imported with @code{use-modules}. To find a package or
  29021. information about its module use @command{guix search} (@pxref{Invoking
  29022. guix package}). Alternatively, @code{specification->package} can be
  29023. used to get the package record from string without importing related
  29024. module.
  29025. @end defvr
  29026. There are few more essential services, but users are not expected to
  29027. extend them.
  29028. @defvr {Scheme Variable} home-service-type
  29029. The root of home services DAG, it generates a folder, which later will be
  29030. symlinked to @file{~/.guix-home}, it contains configurations,
  29031. profile with binaries and libraries, and some necessary scripts to glue
  29032. things together.
  29033. @end defvr
  29034. @defvr {Scheme Variable} home-run-on-first-login-service-type
  29035. The service of this type generates a Guile script, which is expected to
  29036. be executed by the login shell. It is only executed if the special flag
  29037. file inside @env{XDG_RUNTIME_DIR} hasn't been created, this prevents
  29038. redundant executions of the script if multiple login shells are spawned.
  29039. It can be extended with a gexp. However, to autostart an application,
  29040. users @emph{should not} use this service, in most cases it's better to extend
  29041. @code{home-shepherd-service-type} with a Shepherd service
  29042. (@pxref{Shepherd Services}), or extend the shell's startup file with
  29043. the required command using the appropriate service type.
  29044. @end defvr
  29045. @defvr {Scheme Variable} home-activation-service-type
  29046. The service of this type generates a guile script, which runs on every
  29047. @command{guix home reconfigure} invocation or any other action, which
  29048. leads to the activation of the home environment.
  29049. @end defvr
  29050. @node Shells Home Services
  29051. @subsection Shells
  29052. @cindex shell
  29053. @cindex login shell
  29054. @cindex interactive shell
  29055. @cindex bash
  29056. @cindex zsh
  29057. Shells play a quite important role in the environment initialization
  29058. process, you can configure them manually as described in section
  29059. @ref{Configuring the Shell}, but the recommended way is to use home services
  29060. listed below. It's both easier and more reliable.
  29061. Each home environment instantiates
  29062. @code{home-shell-profile-service-type}, which creates a
  29063. @file{~/.profile} startup file for all POSIX-compatible shells. This
  29064. file contains all the necessary steps to properly initialize the
  29065. environment, but many modern shells like Bash or Zsh prefer their own
  29066. startup files, that's why the respective home services
  29067. (@code{home-bash-service-type} and @code{home-zsh-service-type}) ensure
  29068. that @file{~/.profile} is sourced by @file{~/.bash_profile} and
  29069. @file{~/.zprofile}, respectively.
  29070. @subsubheading Shell Profile Service
  29071. @deftp {Data Type} home-shell-profile-configuration
  29072. Available @code{home-shell-profile-configuration} fields are:
  29073. @table @asis
  29074. @item @code{profile} (default: @code{()}) (type: text-config)
  29075. @code{home-shell-profile} is instantiated automatically by
  29076. @code{home-environment}, DO NOT create this service manually, it can
  29077. only be extended. @code{profile} is a list of file-like objects, which
  29078. will go to @file{~/.profile}. By default @file{~/.profile} contains the
  29079. initialization code, which have to be evaluated by login shell to make
  29080. home-environment's profile avaliable to the user, but other commands can
  29081. be added to the file if it is really necessary. In most cases shell's
  29082. configuration files are preferred places for user's customizations.
  29083. Extend home-shell-profile service only if you really know what you do.
  29084. @end table
  29085. @end deftp
  29086. @subsubheading Bash Home Service
  29087. @anchor{home-bash-configuration}
  29088. @deftp {Data Type} home-bash-configuration
  29089. Available @code{home-bash-configuration} fields are:
  29090. @table @asis
  29091. @item @code{package} (default: @code{bash}) (type: package)
  29092. The Bash package to use.
  29093. @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
  29094. Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
  29095. @command{ls} to the end of the @file{.bashrc} file.
  29096. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29097. Association list of environment variables to set for the Bash session. The
  29098. rules for the @code{home-environment-variables-service-type} apply
  29099. here (@pxref{Essential Home Services}). The contents of this field will be
  29100. added after the contents of the @code{bash-profile} field.
  29101. @item @code{aliases} (default: @code{()}) (type: alist)
  29102. Association list of aliases to set for the Bash session. The aliases
  29103. will be defined after the contents of the @code{bashrc} field has been
  29104. put in the @file{.bashrc} file. The alias will automatically be quoted,
  29105. so something line this:
  29106. @lisp
  29107. '((\"ls\" . \"ls -alF\"))
  29108. @end lisp
  29109. turns into
  29110. @example
  29111. alias ls=\"ls -alF\"
  29112. @end example
  29113. @item @code{bash-profile} (default: @code{()}) (type: text-config)
  29114. List of file-like objects, which will be added to @file{.bash_profile}.
  29115. Used for executing user's commands at start of login shell (In most
  29116. cases the shell started on tty just after login). @file{.bash_login}
  29117. won't be ever read, because @file{.bash_profile} always present.
  29118. @item @code{bashrc} (default: @code{()}) (type: text-config)
  29119. List of file-like objects, which will be added to @file{.bashrc}. Used
  29120. for executing user's commands at start of interactive shell (The shell
  29121. for interactive usage started by typing @code{bash} or by terminal app
  29122. or any other program).
  29123. @item @code{bash-logout} (default: @code{()}) (type: text-config)
  29124. List of file-like objects, which will be added to @file{.bash_logout}.
  29125. Used for executing user's commands at the exit of login shell. It won't
  29126. be read in some cases (if the shell terminates by exec'ing another
  29127. process for example).
  29128. @end table
  29129. @end deftp
  29130. You can extend the Bash service by using the @code{home-bash-extension}
  29131. configuration record, whose fields most mirror that of
  29132. @code{home-bash-configuration} (@pxref{home-bash-configuration}). The
  29133. contents of the extensions will be added to the end of the corresponding
  29134. Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
  29135. Bash Reference Manual}.
  29136. @deftp {Data Type} home-bash-extension
  29137. Available @code{home-bash-extension} fields are:
  29138. @table @asis
  29139. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29140. Additional environment variables to set. These will be combined with the
  29141. environment variables from other extensions and the base service to form one
  29142. coherent block of environment variables.
  29143. @item @code{aliases} (default: @code{()}) (type: alist)
  29144. Additional aliases to set. These will be combined with the aliases from
  29145. other extensions and the base service.
  29146. @item @code{bash-profile} (default: @code{()}) (type: text-config)
  29147. Additional text blocks to add to @file{.bash_profile}, which will be combined
  29148. with text blocks from other extensions and the base service.
  29149. @item @code{bashrc} (default: @code{()}) (type: text-config)
  29150. Additional text blocks to add to @file{.bashrc}, which will be combined
  29151. with text blocks from other extensions and the base service.
  29152. @item @code{bash-logout} (default: @code{()}) (type: text-config)
  29153. Additional text blocks to add to @file{.bash_logout}, which will be combined
  29154. with text blocks from other extensions and the base service.
  29155. @end table
  29156. @end deftp
  29157. @subsubheading Zsh Home Service
  29158. @deftp {Data Type} home-zsh-configuration
  29159. Available @code{home-zsh-configuration} fields are:
  29160. @table @asis
  29161. @item @code{package} (default: @code{zsh}) (type: package)
  29162. The Zsh package to use.
  29163. @item @code{xdg-flavor?} (default: @code{#t}) (type: boolean)
  29164. Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes
  29165. @file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}.
  29166. Shell startup process will continue with
  29167. @file{$XDG_CONFIG_HOME/zsh/.zshenv}.
  29168. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29169. Association list of environment variables to set for the Zsh session.
  29170. @item @code{zshenv} (default: @code{()}) (type: text-config)
  29171. List of file-like objects, which will be added to @file{.zshenv}. Used
  29172. for setting user's shell environment variables. Must not contain
  29173. commands assuming the presence of tty or producing output. Will be read
  29174. always. Will be read before any other file in @env{ZDOTDIR}.
  29175. @item @code{zprofile} (default: @code{()}) (type: text-config)
  29176. List of file-like objects, which will be added to @file{.zprofile}. Used
  29177. for executing user's commands at start of login shell (In most cases the
  29178. shell started on tty just after login). Will be read before
  29179. @file{.zlogin}.
  29180. @item @code{zshrc} (default: @code{()}) (type: text-config)
  29181. List of file-like objects, which will be added to @file{.zshrc}. Used
  29182. for executing user's commands at start of interactive shell (The shell
  29183. for interactive usage started by typing @code{zsh} or by terminal app or
  29184. any other program).
  29185. @item @code{zlogin} (default: @code{()}) (type: text-config)
  29186. List of file-like objects, which will be added to @file{.zlogin}. Used
  29187. for executing user's commands at the end of starting process of login
  29188. shell.
  29189. @item @code{zlogout} (default: @code{()}) (type: text-config)
  29190. List of file-like objects, which will be added to @file{.zlogout}. Used
  29191. for executing user's commands at the exit of login shell. It won't be
  29192. read in some cases (if the shell terminates by exec'ing another process
  29193. for example).
  29194. @end table
  29195. @end deftp
  29196. @node Mcron Home Service
  29197. @subsection Scheduled User's Job Execution
  29198. @cindex cron
  29199. @cindex mcron
  29200. @cindex scheduling jobs
  29201. The @code{(gnu home services mcron)} module provides an interface to
  29202. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  29203. mcron, GNU@tie{}mcron}). The information about system's mcron is
  29204. applicable here (@pxref{Scheduled Job Execution}), the only difference
  29205. for home services is that they have to be declared in a
  29206. @code{home-envirnoment} record instead of an @code{operating-system}
  29207. record.
  29208. @defvr {Scheme Variable} home-mcron-service-type
  29209. This is the type of the @code{mcron} home service, whose value is an
  29210. @code{home-mcron-configuration} object. It allows to manage scheduled
  29211. tasks.
  29212. This service type can be the target of a service extension that provides
  29213. additional job specifications (@pxref{Service Composition}). In other
  29214. words, it is possible to define services that provide additional mcron
  29215. jobs to run.
  29216. @end defvr
  29217. @deftp {Data Type} home-mcron-configuration
  29218. Data type representing the configuration of mcron.
  29219. @table @asis
  29220. @item @code{mcron} (default: @var{mcron})
  29221. The mcron package to use.
  29222. @item @code{jobs}
  29223. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  29224. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  29225. specifications,, mcron, GNU@tie{}mcron}).
  29226. @end table
  29227. @end deftp
  29228. @node Shepherd Home Service
  29229. @subsection Managing User's Daemons
  29230. @cindex shepherd services
  29231. @defvr {Scheme Variable} home-shepherd-service-type
  29232. The service type for the userland Shepherd, which allows one to manage
  29233. long-running processes or one-shot tasks. User's Shepherd is not an
  29234. init process (PID 1), but almost all other information described in
  29235. (@pxref{Shepherd Services}) is applicable here too.
  29236. This is the service type that extensions target when they want to create
  29237. shepherd services (@pxref{Service Types and Services}, for an example).
  29238. Each extension must pass a list of @code{<shepherd-service>}. Its
  29239. value must be a @code{home-shepherd-configuration}, as described below.
  29240. @end defvr
  29241. @deftp {Data Type} home-shepherd-configuration
  29242. This data type represents the Shepherd's configuration.
  29243. @table @code
  29244. @item shepherd (default: @code{shepherd})
  29245. The Shepherd package to use.
  29246. @item auto-start? (default: @code{#t})
  29247. Whether or not to start Shepherd on first login.
  29248. @item services (default: @code{'()})
  29249. A list of @code{<shepherd-service>} to start.
  29250. You should probably use the service extension
  29251. mechanism instead (@pxref{Shepherd Services}).
  29252. @end table
  29253. @end deftp
  29254. @node Invoking guix home
  29255. @section Invoking @code{guix home}
  29256. Once you have written a home environment declaration (@pxref{Declaring
  29257. the Home Environment,,,,}, it can be @dfn{instantiated} using the
  29258. @command{guix home} command. The synopsis is:
  29259. @example
  29260. guix home @var{options}@dots{} @var{action} @var{file}
  29261. @end example
  29262. @var{file} must be the name of a file containing a
  29263. @code{home-environment} declaration. @var{action} specifies how the
  29264. home environment is instantiated, but there are few auxiliary actions
  29265. which don't instantiate it. Currently the following values are
  29266. supported:
  29267. @table @code
  29268. @item search
  29269. Display available home service type definitions that match the given
  29270. regular expressions, sorted by relevance:
  29271. @cindex shell
  29272. @cindex shell-profile
  29273. @cindex bash
  29274. @cindex zsh
  29275. @example
  29276. $ guix home search shell
  29277. name: home-shell-profile
  29278. location: gnu/home/services/shells.scm:73:2
  29279. extends: home-files
  29280. description: Create `~/.profile', which is used for environment initialization
  29281. + of POSIX compatible login shells. Can be extended with a list of strings or
  29282. + gexps.
  29283. relevance: 6
  29284. name: home-zsh-plugin-manager
  29285. location: gnu/home/services/shellutils.scm:28:2
  29286. extends: home-zsh home-profile
  29287. description: Install plugins in profile and configure Zsh to load them.
  29288. relevance: 1
  29289. name: home-zsh-direnv
  29290. location: gnu/home/services/shellutils.scm:69:2
  29291. extends: home-profile home-zsh
  29292. description: Enables `direnv' for `zsh'. Adds hook to `.zshrc' and installs a
  29293. + package in the profile.
  29294. relevance: 1
  29295. name: home-zsh-autosuggestions
  29296. location: gnu/home/services/shellutils.scm:43:2
  29297. extends: home-zsh-plugin-manager home-zsh
  29298. description: Enables Fish-like fast/unobtrusive autosuggestions for `zsh' and
  29299. + sets reasonable default values for some plugin's variables to improve perfomance
  29300. + and adjust behavior: `(history completion)' is set for strategy, manual rebind
  29301. + and async are enabled.
  29302. relevance: 1
  29303. name: home-zsh
  29304. location: gnu/home/services/shells.scm:236:2
  29305. extends: home-files home-profile
  29306. description: Install and configure Zsh.
  29307. relevance: 1
  29308. name: home-bash
  29309. location: gnu/home/services/shells.scm:388:2
  29310. extends: home-files home-profile
  29311. description: Install and configure Bash.
  29312. relevance: 1
  29313. @dots{}
  29314. @end example
  29315. As for @command{guix package --search}, the result is written in
  29316. @code{recutils} format, which makes it easy to filter the output
  29317. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  29318. @item reconfigure
  29319. Build the home environment described in @var{file}, and switch to it.
  29320. Switching means that the activation script will be evaluated and (in
  29321. basic scenario) symlinks to configuration files generated from
  29322. @code{home-environment} declaration will be created in @file{~}. If the
  29323. file with the same path already exists in home folder it will be moved
  29324. to @file{~/TIMESTAMP-guix-home-legacy-configs-backup}, where TIMESTAMP
  29325. is a current UNIX epoch time.
  29326. @quotation Note
  29327. It is highly recommended to run @command{guix pull} once before you run
  29328. @command{guix home reconfigure} for the first time (@pxref{Invoking guix
  29329. pull}).
  29330. @end quotation
  29331. This effects all the configuration specified in @var{file}. The command
  29332. starts Shepherd services specified in @var{file} that are not currently
  29333. running; if a service is currently running, this command will arrange
  29334. for it to be upgraded the next time it is stopped (e.g.@: by @code{herd
  29335. stop X} or @code{herd restart X}).
  29336. This command creates a new generation whose number is one greater than
  29337. the current generation (as reported by @command{guix home
  29338. list-generations}). If that generation already exists, it will be
  29339. overwritten. This behavior mirrors that of @command{guix package}
  29340. (@pxref{Invoking guix package}).
  29341. @cindex provenance tracking, of the home environment
  29342. Upon completion, the new home is deployed under @file{~/.guix-home}.
  29343. This directory contains @dfn{provenance meta-data}: the list of channels
  29344. in use (@pxref{Channels}) and @var{file} itself, when available. You
  29345. can view the provenance information by running:
  29346. @example
  29347. guix home describe
  29348. @end example
  29349. This information is useful should you later want to inspect how this
  29350. particular generation was built. In fact, assuming @var{file} is
  29351. self-contained, you can later rebuild generation @var{n} of your
  29352. home environment with:
  29353. @example
  29354. guix time-machine \
  29355. -C /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/channels.scm -- \
  29356. home reconfigure \
  29357. /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/configuration.scm
  29358. @end example
  29359. You can think of it as some sort of built-in version control! Your
  29360. home is not just a binary artifact: @emph{it carries its own source}.
  29361. @c @xref{Service Reference, @code{provenance-service-type}}, for more
  29362. @c information on provenance tracking.
  29363. @c @footnote{This action (and the related actions
  29364. @c @code{switch-generation} and @code{roll-back}) are usable after the
  29365. @c home environment is initialized.}.
  29366. @item switch-generation
  29367. @cindex home generations
  29368. Switch to an existing home generation. This action atomically switches
  29369. the home profile to the specified home generation.
  29370. The target generation can be specified explicitly by its generation
  29371. number. For example, the following invocation would switch to home
  29372. generation 7:
  29373. @example
  29374. guix home switch-generation 7
  29375. @end example
  29376. The target generation can also be specified relative to the current
  29377. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  29378. ``3 generations ahead of the current generation,'' and @code{-1} means
  29379. ``1 generation prior to the current generation.'' When specifying a
  29380. negative value such as @code{-1}, you must precede it with @code{--} to
  29381. prevent it from being parsed as an option. For example:
  29382. @example
  29383. guix home switch-generation -- -1
  29384. @end example
  29385. This action will fail if the specified generation does not exist.
  29386. @item roll-back
  29387. @cindex rolling back
  29388. Switch to the preceding home generation. This is the inverse
  29389. of @command{reconfigure}, and it is exactly the same as invoking
  29390. @command{switch-generation} with an argument of @code{-1}.
  29391. @item delete-generations
  29392. @cindex deleting home generations
  29393. @cindex saving space
  29394. Delete home generations, making them candidates for garbage collection
  29395. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  29396. collector'').
  29397. This works in the same way as @samp{guix package --delete-generations}
  29398. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  29399. arguments, all home generations but the current one are deleted:
  29400. @example
  29401. guix home delete-generations
  29402. @end example
  29403. You can also select the generations you want to delete. The example below
  29404. deletes all the home generations that are more than two months old:
  29405. @example
  29406. guix home delete-generations 2m
  29407. @end example
  29408. @item build
  29409. Build the derivation of the home environment, which includes all the
  29410. configuration files and programs needed. This action does not actually
  29411. install anything.
  29412. @item describe
  29413. Describe the current home generation: its file name, as well as
  29414. provenance information when available.
  29415. @item list-generations
  29416. List a summary of each generation of the home environment available on
  29417. disk, in a human-readable way. This is similar to the
  29418. @option{--list-generations} option of @command{guix package}
  29419. (@pxref{Invoking guix package}).
  29420. Optionally, one can specify a pattern, with the same syntax that is used
  29421. in @command{guix package --list-generations}, to restrict the list of
  29422. generations displayed. For instance, the following command displays
  29423. generations that are up to 10 days old:
  29424. @example
  29425. $ guix home list-generations 10d
  29426. @end example
  29427. @item import
  29428. Generate a @dfn{home environment} from the packages in the default
  29429. profile and configuration files found in the user's home directory. The
  29430. configuration files will be copied to the specified directory, and a
  29431. @file{home-configuration.scm} will be populated with the home
  29432. environment. Note that not every home service that exists is supported
  29433. (@pxref{Home Services}).
  29434. @example
  29435. $ guix home import ~/guix-config
  29436. guix home: '/home/alice/guix-config' populated with all the Home configuration files
  29437. @end example
  29438. @end table
  29439. @var{options} can contain any of the common build options (@pxref{Common
  29440. Build Options}). In addition, @var{options} can contain one of the
  29441. following:
  29442. @table @option
  29443. @item --expression=@var{expr}
  29444. @itemx -e @var{expr}
  29445. Consider the home-environment @var{expr} evaluates to.
  29446. This is an alternative to specifying a file which evaluates to a home
  29447. environment.
  29448. @end table
  29449. @node Documentation
  29450. @chapter Documentation
  29451. @cindex documentation, searching for
  29452. @cindex searching for documentation
  29453. @cindex Info, documentation format
  29454. @cindex man pages
  29455. @cindex manual pages
  29456. In most cases packages installed with Guix come with documentation.
  29457. There are two main documentation formats: ``Info'', a browsable
  29458. hypertext format used for GNU software, and ``manual pages'' (or ``man
  29459. pages''), the linear documentation format traditionally found on Unix.
  29460. Info manuals are accessed with the @command{info} command or with Emacs,
  29461. and man pages are accessed using @command{man}.
  29462. You can look for documentation of software installed on your system by
  29463. keyword. For example, the following command searches for information
  29464. about ``TLS'' in Info manuals:
  29465. @example
  29466. $ info -k TLS
  29467. "(emacs)Network Security" -- STARTTLS
  29468. "(emacs)Network Security" -- TLS
  29469. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  29470. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  29471. @dots{}
  29472. @end example
  29473. @noindent
  29474. The command below searches for the same keyword in man
  29475. pages@footnote{The database searched by @command{man -k} is only created
  29476. in profiles that contain the @code{man-db} package.}:
  29477. @example
  29478. $ man -k TLS
  29479. SSL (7) - OpenSSL SSL/TLS library
  29480. certtool (1) - GnuTLS certificate tool
  29481. @dots {}
  29482. @end example
  29483. These searches are purely local to your computer so you have the
  29484. guarantee that documentation you find corresponds to what you have
  29485. actually installed, you can access it off-line, and your privacy is
  29486. respected.
  29487. Once you have these results, you can view the relevant documentation by
  29488. running, say:
  29489. @example
  29490. $ info "(gnutls)Core TLS API"
  29491. @end example
  29492. @noindent
  29493. or:
  29494. @example
  29495. $ man certtool
  29496. @end example
  29497. Info manuals contain sections and indices as well as hyperlinks like
  29498. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  29499. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  29500. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  29501. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  29502. Introduction}, for an introduction to Info navigation.
  29503. @node Installing Debugging Files
  29504. @chapter Installing Debugging Files
  29505. @cindex debugging files
  29506. Program binaries, as produced by the GCC compilers for instance, are
  29507. typically written in the ELF format, with a section containing
  29508. @dfn{debugging information}. Debugging information is what allows the
  29509. debugger, GDB, to map binary code to source code; it is required to
  29510. debug a compiled program in good conditions.
  29511. This chapter explains how to use separate debug info when packages
  29512. provide it, and how to rebuild packages with debug info when it's
  29513. missing.
  29514. @menu
  29515. * Separate Debug Info:: Installing 'debug' outputs.
  29516. * Rebuilding Debug Info:: Building missing debug info.
  29517. @end menu
  29518. @node Separate Debug Info
  29519. @section Separate Debug Info
  29520. The problem with debugging information is that is takes up a fair amount
  29521. of disk space. For example, debugging information for the GNU C Library
  29522. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  29523. debugging info of all the installed programs is usually not an option.
  29524. Yet, space savings should not come at the cost of an impediment to
  29525. debugging---especially in the GNU system, which should make it easier
  29526. for users to exert their computing freedom (@pxref{GNU Distribution}).
  29527. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  29528. mechanism that allows users to get the best of both worlds: debugging
  29529. information can be stripped from the binaries and stored in separate
  29530. files. GDB is then able to load debugging information from those files,
  29531. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  29532. with GDB}).
  29533. The GNU distribution takes advantage of this by storing debugging
  29534. information in the @code{lib/debug} sub-directory of a separate package
  29535. output unimaginatively called @code{debug} (@pxref{Packages with
  29536. Multiple Outputs}). Users can choose to install the @code{debug} output
  29537. of a package when they need it. For instance, the following command
  29538. installs the debugging information for the GNU C Library and for GNU
  29539. Guile:
  29540. @example
  29541. guix install glibc:debug guile:debug
  29542. @end example
  29543. GDB must then be told to look for debug files in the user's profile, by
  29544. setting the @code{debug-file-directory} variable (consider setting it
  29545. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  29546. GDB}):
  29547. @example
  29548. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  29549. @end example
  29550. From there on, GDB will pick up debugging information from the
  29551. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  29552. Below is an alternative GDB script which is useful when working with
  29553. other profiles. It takes advantage of the optional Guile integration in
  29554. GDB. This snippet is included by default on Guix System in the
  29555. @file{~/.gdbinit} file.
  29556. @example
  29557. guile
  29558. (use-modules (gdb))
  29559. (execute (string-append "set debug-file-directory "
  29560. (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
  29561. "~/.guix-profile/lib/debug")))
  29562. end
  29563. @end example
  29564. In addition, you will most likely want GDB to be able to show the source
  29565. code being debugged. To do that, you will have to unpack the source
  29566. code of the package of interest (obtained with @code{guix build
  29567. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  29568. directory using the @code{directory} command (@pxref{Source Path,
  29569. @code{directory},, gdb, Debugging with GDB}).
  29570. @c XXX: keep me up-to-date
  29571. The @code{debug} output mechanism in Guix is implemented by the
  29572. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  29573. opt-in---debugging information is available only for the packages with
  29574. definitions explicitly declaring a @code{debug} output. To check
  29575. whether a package has a @code{debug} output, use @command{guix package
  29576. --list-available} (@pxref{Invoking guix package}).
  29577. Read on for how to deal with packages lacking a @code{debug} output.
  29578. @node Rebuilding Debug Info
  29579. @section Rebuilding Debug Info
  29580. @cindex debugging info, rebuilding
  29581. As we saw above, some packages, but not all, provide debugging info in a
  29582. @code{debug} output. What can you do when debugging info is missing?
  29583. The @option{--with-debug-info} option provides a solution to that: it
  29584. allows you to rebuild the package(s) for which debugging info is
  29585. missing---and only those---and to graft those onto the application
  29586. you're debugging. Thus, while it's not as fast as installing a
  29587. @code{debug} output, it is relatively inexpensive.
  29588. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  29589. and would like to see what's going on in GLib, a library that's deep
  29590. down in its dependency graph. As it turns out, GLib does not have a
  29591. @code{debug} output and the backtrace GDB shows is all sadness:
  29592. @example
  29593. (gdb) bt
  29594. #0 0x00007ffff5f92190 in g_getenv ()
  29595. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  29596. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  29597. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  29598. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  29599. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  29600. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  29601. at dl-init.c:118
  29602. @end example
  29603. To address that, you install Inkscape linked against a variant GLib that
  29604. contains debug info:
  29605. @example
  29606. guix install inkscape --with-debug-info=glib
  29607. @end example
  29608. This time, debugging will be a whole lot nicer:
  29609. @example
  29610. $ gdb --args sh -c 'exec inkscape'
  29611. @dots{}
  29612. (gdb) b g_getenv
  29613. Function "g_getenv" not defined.
  29614. Make breakpoint pending on future shared library load? (y or [n]) y
  29615. Breakpoint 1 (g_getenv) pending.
  29616. (gdb) r
  29617. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  29618. @dots{}
  29619. (gdb) bt
  29620. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  29621. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  29622. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  29623. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  29624. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  29625. @dots{}
  29626. @end example
  29627. Much better!
  29628. Note that there can be packages for which @option{--with-debug-info}
  29629. will not have the desired effect. @xref{Package Transformation Options,
  29630. @option{--with-debug-info}}, for more information.
  29631. @node Security Updates
  29632. @chapter Security Updates
  29633. @cindex security updates
  29634. @cindex security vulnerabilities
  29635. Occasionally, important security vulnerabilities are discovered in software
  29636. packages and must be patched. Guix developers try hard to keep track of
  29637. known vulnerabilities and to apply fixes as soon as possible in the
  29638. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  29639. containing only security updates). The @command{guix lint} tool helps
  29640. developers find out about vulnerable versions of software packages in the
  29641. distribution:
  29642. @smallexample
  29643. $ guix lint -c cve
  29644. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  29645. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  29646. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  29647. @dots{}
  29648. @end smallexample
  29649. @xref{Invoking guix lint}, for more information.
  29650. Guix follows a functional
  29651. package management discipline (@pxref{Introduction}), which implies
  29652. that, when a package is changed, @emph{every package that depends on it}
  29653. must be rebuilt. This can significantly slow down the deployment of
  29654. fixes in core packages such as libc or Bash, since basically the whole
  29655. distribution would need to be rebuilt. Using pre-built binaries helps
  29656. (@pxref{Substitutes}), but deployment may still take more time than
  29657. desired.
  29658. @cindex grafts
  29659. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  29660. for fast deployment of critical updates without the costs associated
  29661. with a whole-distribution rebuild. The idea is to rebuild only the
  29662. package that needs to be patched, and then to ``graft'' it onto packages
  29663. explicitly installed by the user and that were previously referring to
  29664. the original package. The cost of grafting is typically very low, and
  29665. order of magnitudes lower than a full rebuild of the dependency chain.
  29666. @cindex replacements of packages, for grafts
  29667. For instance, suppose a security update needs to be applied to Bash.
  29668. Guix developers will provide a package definition for the ``fixed''
  29669. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  29670. Packages}). Then, the original package definition is augmented with a
  29671. @code{replacement} field pointing to the package containing the bug fix:
  29672. @lisp
  29673. (define bash
  29674. (package
  29675. (name "bash")
  29676. ;; @dots{}
  29677. (replacement bash-fixed)))
  29678. @end lisp
  29679. From there on, any package depending directly or indirectly on Bash---as
  29680. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  29681. gc})---that is installed is automatically ``rewritten'' to refer to
  29682. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  29683. time proportional to the size of the package, usually less than a
  29684. minute for an ``average'' package on a recent machine. Grafting is
  29685. recursive: when an indirect dependency requires grafting, then grafting
  29686. ``propagates'' up to the package that the user is installing.
  29687. Currently, the length of the name and version of the graft and that of
  29688. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  29689. above) must be equal. This restriction mostly comes from the fact that
  29690. grafting works by patching files, including binary files, directly.
  29691. Other restrictions may apply: for instance, when adding a graft to a
  29692. package providing a shared library, the original shared library and its
  29693. replacement must have the same @code{SONAME} and be binary-compatible.
  29694. The @option{--no-grafts} command-line option allows you to forcefully
  29695. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  29696. Thus, the command:
  29697. @example
  29698. guix build bash --no-grafts
  29699. @end example
  29700. @noindent
  29701. returns the store file name of the original Bash, whereas:
  29702. @example
  29703. guix build bash
  29704. @end example
  29705. @noindent
  29706. returns the store file name of the ``fixed'', replacement Bash. This
  29707. allows you to distinguish between the two variants of Bash.
  29708. To verify which Bash your whole profile refers to, you can run
  29709. (@pxref{Invoking guix gc}):
  29710. @example
  29711. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  29712. @end example
  29713. @noindent
  29714. @dots{} and compare the store file names that you get with those above.
  29715. Likewise for a complete Guix system generation:
  29716. @example
  29717. guix gc -R $(guix system build my-config.scm) | grep bash
  29718. @end example
  29719. Lastly, to check which Bash running processes are using, you can use the
  29720. @command{lsof} command:
  29721. @example
  29722. lsof | grep /gnu/store/.*bash
  29723. @end example
  29724. @node Bootstrapping
  29725. @chapter Bootstrapping
  29726. @c Adapted from the ELS 2013 paper.
  29727. @cindex bootstrapping
  29728. Bootstrapping in our context refers to how the distribution gets built
  29729. ``from nothing''. Remember that the build environment of a derivation
  29730. contains nothing but its declared inputs (@pxref{Introduction}). So
  29731. there's an obvious chicken-and-egg problem: how does the first package
  29732. get built? How does the first compiler get compiled?
  29733. It is tempting to think of this question as one that only die-hard
  29734. hackers may care about. However, while the answer to that question is
  29735. technical in nature, its implications are wide-ranging. How the
  29736. distribution is bootstrapped defines the extent to which we, as
  29737. individuals and as a collective of users and hackers, can trust the
  29738. software we run. It is a central concern from the standpoint of
  29739. @emph{security} and from a @emph{user freedom} viewpoint.
  29740. @cindex bootstrap binaries
  29741. The GNU system is primarily made of C code, with libc at its core. The
  29742. GNU build system itself assumes the availability of a Bourne shell and
  29743. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  29744. `grep'. Furthermore, build programs---programs that run
  29745. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  29746. (@pxref{Derivations}). Consequently, to be able to build anything at
  29747. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  29748. Binutils, libc, and the other packages mentioned above---the
  29749. @dfn{bootstrap binaries}.
  29750. These bootstrap binaries are ``taken for granted'', though we can also
  29751. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  29752. Binaries}).
  29753. @menu
  29754. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  29755. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  29756. @end menu
  29757. @node Reduced Binary Seed Bootstrap
  29758. @section The Reduced Binary Seed Bootstrap
  29759. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  29760. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  29761. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  29762. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  29763. ``taken for granted.''
  29764. Taking the bootstrap binaries for granted means that we consider them to
  29765. be a correct and trustworthy ``seed'' for building the complete system.
  29766. Therein lies a problem: the combined size of these bootstrap binaries is
  29767. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  29768. or even inspecting these is next to impossible.
  29769. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  29770. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  29771. Source Bootstrap'' and while we are working towards that goal it would
  29772. be hyperbole to use that term for what we do now.}.
  29773. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  29774. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  29775. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  29776. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  29777. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  29778. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  29779. C Library are built from source. From here on the more traditional
  29780. bootstrap process resumes. This approach has reduced the bootstrap
  29781. binaries in size to about 145MB in Guix v1.1.
  29782. The next step that Guix has taken is to replace the shell and all its
  29783. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  29784. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  29785. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  29786. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  29787. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  29788. removed are now built from source.
  29789. Building the GNU System from source is currently only possible by adding
  29790. some historical GNU packages as intermediate steps@footnote{Packages
  29791. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  29792. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  29793. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  29794. and GNU packages become more bootstrappable again (e.g., new releases of
  29795. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  29796. hard to bootstrap @code{xz}-compression), this set of added packages can
  29797. hopefully be reduced again.
  29798. The graph below shows the resulting dependency graph for
  29799. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  29800. traditional bootstrap of the rest of the Guix System.
  29801. @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
  29802. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  29803. The only significant binary bootstrap seeds that remain@footnote{
  29804. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  29805. together with @code{mes}.} are a Scheme interpreter and a Scheme
  29806. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  29807. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  29808. to get Guile running.}.
  29809. This further reduction has brought down the size of the binary seed to
  29810. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  29811. Work is ongoing to remove all binary blobs from our free software
  29812. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  29813. is work to bring these bootstraps to the @code{arm-linux} and
  29814. @code{aarch64-linux} architectures and to the Hurd.
  29815. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  29816. IRC network or discuss on @email{bug-mes@@gnu.org} or
  29817. @email{gash-devel@@nongnu.org}.
  29818. @node Preparing to Use the Bootstrap Binaries
  29819. @section Preparing to Use the Bootstrap Binaries
  29820. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  29821. @c large image, it's hard to scroll. Oh well.
  29822. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  29823. The figure above shows the very beginning of the dependency graph of the
  29824. distribution, corresponding to the package definitions of the @code{(gnu
  29825. packages bootstrap)} module. A similar figure can be generated with
  29826. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  29827. @example
  29828. guix graph -t derivation \
  29829. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  29830. | dot -Tps > gcc.ps
  29831. @end example
  29832. or, for the further Reduced Binary Seed bootstrap
  29833. @example
  29834. guix graph -t derivation \
  29835. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  29836. | dot -Tps > mes.ps
  29837. @end example
  29838. At this level of detail, things are
  29839. slightly complex. First, Guile itself consists of an ELF executable,
  29840. along with many source and compiled Scheme files that are dynamically
  29841. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  29842. tarball shown in this graph. This tarball is part of Guix's ``source''
  29843. distribution, and gets inserted into the store with @code{add-to-store}
  29844. (@pxref{The Store}).
  29845. But how do we write a derivation that unpacks this tarball and adds it
  29846. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  29847. derivation---the first one that gets built---uses @code{bash} as its
  29848. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  29849. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  29850. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  29851. the Guix source distribution, whose sole purpose is to allow the Guile
  29852. tarball to be unpacked.
  29853. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  29854. Guile that can be used to run subsequent build programs. Its first task
  29855. is to download tarballs containing the other pre-built binaries---this
  29856. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  29857. @code{ftp-client.scm} are used for this purpose. The
  29858. @code{module-import.drv} derivations import those modules in a directory
  29859. in the store, using the original layout. The
  29860. @code{module-import-compiled.drv} derivations compile those modules, and
  29861. write them in an output directory with the right layout. This
  29862. corresponds to the @code{#:modules} argument of
  29863. @code{build-expression->derivation} (@pxref{Derivations}).
  29864. Finally, the various tarballs are unpacked by the derivations
  29865. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  29866. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  29867. point we have a working C tool chain.
  29868. @unnumberedsec Building the Build Tools
  29869. Bootstrapping is complete when we have a full tool chain that does not
  29870. depend on the pre-built bootstrap tools discussed above. This
  29871. no-dependency requirement is verified by checking whether the files of
  29872. the final tool chain contain references to the @file{/gnu/store}
  29873. directories of the bootstrap inputs. The process that leads to this
  29874. ``final'' tool chain is described by the package definitions found in
  29875. the @code{(gnu packages commencement)} module.
  29876. The @command{guix graph} command allows us to ``zoom out'' compared to
  29877. the graph above, by looking at the level of package objects instead of
  29878. individual derivations---remember that a package may translate to
  29879. several derivations, typically one derivation to download its source,
  29880. one to build the Guile modules it needs, and one to actually build the
  29881. package from source. The command:
  29882. @example
  29883. guix graph -t bag \
  29884. -e '(@@@@ (gnu packages commencement)
  29885. glibc-final-with-bootstrap-bash)' | xdot -
  29886. @end example
  29887. @noindent
  29888. displays the dependency graph leading to the ``final'' C
  29889. library@footnote{You may notice the @code{glibc-intermediate} label,
  29890. suggesting that it is not @emph{quite} final, but as a good
  29891. approximation, we will consider it final.}, depicted below.
  29892. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  29893. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  29894. The first tool that gets built with the bootstrap binaries is
  29895. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  29896. for all the following packages. From there Findutils and Diffutils get
  29897. built.
  29898. Then come the first-stage Binutils and GCC, built as pseudo cross
  29899. tools---i.e., with @option{--target} equal to @option{--host}. They are
  29900. used to build libc. Thanks to this cross-build trick, this libc is
  29901. guaranteed not to hold any reference to the initial tool chain.
  29902. From there the final Binutils and GCC (not shown above) are built. GCC
  29903. uses @command{ld} from the final Binutils, and links programs against
  29904. the just-built libc. This tool chain is used to build the other
  29905. packages used by Guix and by the GNU Build System: Guile, Bash,
  29906. Coreutils, etc.
  29907. And voilà! At this point we have the complete set of build tools that
  29908. the GNU Build System expects. These are in the @code{%final-inputs}
  29909. variable of the @code{(gnu packages commencement)} module, and are
  29910. implicitly used by any package that uses @code{gnu-build-system}
  29911. (@pxref{Build Systems, @code{gnu-build-system}}).
  29912. @unnumberedsec Building the Bootstrap Binaries
  29913. @cindex bootstrap binaries
  29914. Because the final tool chain does not depend on the bootstrap binaries,
  29915. those rarely need to be updated. Nevertheless, it is useful to have an
  29916. automated way to produce them, should an update occur, and this is what
  29917. the @code{(gnu packages make-bootstrap)} module provides.
  29918. The following command builds the tarballs containing the bootstrap binaries
  29919. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  29920. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  29921. and Guile, and a tarball containing a mixture of Coreutils and other basic
  29922. command-line tools):
  29923. @example
  29924. guix build bootstrap-tarballs
  29925. @end example
  29926. The generated tarballs are those that should be referred to in the
  29927. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  29928. this section.
  29929. Still here? Then perhaps by now you've started to wonder: when do we
  29930. reach a fixed point? That is an interesting question! The answer is
  29931. unknown, but if you would like to investigate further (and have
  29932. significant computational and storage resources to do so), then let us
  29933. know.
  29934. @unnumberedsec Reducing the Set of Bootstrap Binaries
  29935. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  29936. binary code! Why is that a problem? It's a problem because these big chunks
  29937. of binary code are practically non-auditable, which makes it hard to establish
  29938. what source code produced them. Every unauditable binary also leaves us
  29939. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  29940. paper @emph{Reflections on Trusting Trust}.
  29941. This is mitigated by the fact that our bootstrap binaries were generated
  29942. from an earlier Guix revision. Nevertheless it lacks the level of
  29943. transparency that we get in the rest of the package dependency graph,
  29944. where Guix always gives us a source-to-binary mapping. Thus, our goal
  29945. is to reduce the set of bootstrap binaries to the bare minimum.
  29946. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  29947. on-going projects to do that. One of these is about replacing the
  29948. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  29949. of increasing complexity, which could be built from source starting from
  29950. a simple and auditable assembler.
  29951. Our first major achievement is the replacement of of GCC, the GNU C Library
  29952. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  29953. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  29954. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  29955. bootstrapped yet and thus we inject them as binary seeds. We call this the
  29956. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  29957. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  29958. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  29959. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  29960. also looking at any other bootstrap binaries. Your help is welcome!
  29961. @node Porting
  29962. @chapter Porting to a New Platform
  29963. As discussed above, the GNU distribution is self-contained, and
  29964. self-containment is achieved by relying on pre-built ``bootstrap
  29965. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  29966. operating system kernel, CPU architecture, and application binary
  29967. interface (ABI). Thus, to port the distribution to a platform that is
  29968. not yet supported, one must build those bootstrap binaries, and update
  29969. the @code{(gnu packages bootstrap)} module to use them on that platform.
  29970. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  29971. When everything goes well, and assuming the GNU tool chain supports the
  29972. target platform, this can be as simple as running a command like this
  29973. one:
  29974. @example
  29975. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  29976. @end example
  29977. For this to work, the @code{glibc-dynamic-linker} procedure in
  29978. @code{(gnu packages bootstrap)} must be augmented to return the right
  29979. file name for libc's dynamic linker on that platform; likewise,
  29980. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  29981. taught about the new platform.
  29982. Once these are built, the @code{(gnu packages bootstrap)} module needs
  29983. to be updated to refer to these binaries on the target platform. That
  29984. is, the hashes and URLs of the bootstrap tarballs for the new platform
  29985. must be added alongside those of the currently supported platforms. The
  29986. bootstrap Guile tarball is treated specially: it is expected to be
  29987. available locally, and @file{gnu/local.mk} has rules to download it for
  29988. the supported architectures; a rule for the new platform must be added
  29989. as well.
  29990. In practice, there may be some complications. First, it may be that the
  29991. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  29992. above) is not recognized by all the GNU tools. Typically, glibc
  29993. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  29994. configure flag (see @code{gcc.scm} for examples of how to handle this).
  29995. Second, some of the required packages could fail to build for that
  29996. platform. Lastly, the generated binaries could be broken for some
  29997. reason.
  29998. @c *********************************************************************
  29999. @include contributing.texi
  30000. @c *********************************************************************
  30001. @node Acknowledgments
  30002. @chapter Acknowledgments
  30003. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  30004. which was designed and
  30005. implemented by Eelco Dolstra, with contributions from other people (see
  30006. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  30007. management, and promoted unprecedented features, such as transactional
  30008. package upgrades and rollbacks, per-user profiles, and referentially
  30009. transparent build processes. Without this work, Guix would not exist.
  30010. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  30011. an inspiration for Guix.
  30012. GNU@tie{}Guix itself is a collective work with contributions from a
  30013. number of people. See the @file{AUTHORS} file in Guix for more
  30014. information on these fine people. The @file{THANKS} file lists people
  30015. who have helped by reporting bugs, taking care of the infrastructure,
  30016. providing artwork and themes, making suggestions, and more---thank you!
  30017. @c *********************************************************************
  30018. @node GNU Free Documentation License
  30019. @appendix GNU Free Documentation License
  30020. @cindex license, GNU Free Documentation License
  30021. @include fdl-1.3.texi
  30022. @c *********************************************************************
  30023. @node Concept Index
  30024. @unnumbered Concept Index
  30025. @printindex cp
  30026. @node Programming Index
  30027. @unnumbered Programming Index
  30028. @syncodeindex tp fn
  30029. @syncodeindex vr fn
  30030. @printindex fn
  30031. @bye
  30032. @c Local Variables:
  30033. @c ispell-local-dictionary: "american";
  30034. @c End: